{"commit":"9ed083c43a36515a298b3d68b59374016388cace","subject":"Added brl.system import for Linux (X11 dependency issue in 1.39).","message":"Added brl.system import for Linux (X11 dependency issue in 1.39).\n","repos":"maximos\/maximus","old_file":"maximus.bmx","new_file":"maximus.bmx","new_contents":"\nRem\nCopyright (c) 2010 Tim Howard\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and\/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\nEnd Rem\n\nSuperStrict\n\nFramework brl.blitz\nImport brl.standardio\nImport brl.maxutil\nImport brl.ramstream\n\n' We have to import this for BMax 1.39 on Linux because of a dependency issue in brl.system\n' http:\/\/blitzbasic.com\/Community\/posts.php?topic=90547\n?Linux\nImport brl.glgraphics\n?\n\nImport gman.zipengine\nImport htbaapub.rest\n\nImport duct.variables\nImport duct.objectmap\nImport duct.json\nImport duct.locale\nImport duct.argparser\n\nIncbin \"locales\/en.loc\"\n\nInclude \"src\/logger.bmx\"\nInclude \"src\/errors.bmx\"\nInclude \"src\/config.bmx\"\nInclude \"src\/dependencies.bmx\"\nInclude \"src\/module.bmx\"\nInclude \"src\/sources.bmx\"\nInclude \"src\/utils.bmx\"\nInclude \"src\/arghandler.bmx\"\nInclude \"src\/impl\/help.bmx\"\nInclude \"src\/impl\/version.bmx\"\nInclude \"src\/impl\/modpath.bmx\"\nInclude \"src\/impl\/install.bmx\"\nInclude \"src\/impl\/update.bmx\"\nInclude \"src\/impl\/list.bmx\"\n\nGlobal logger:mxLogger = New mxLogger\nGlobal mainapp:mxApp\nNew mxApp.Create(AppArgs[1..]) ' Skip the first element because it is the program's location\nmainapp.Run()\n\nRem\n\tbbdoc: Maximus app.\n\tabout: This handles the basic flow of the program (initiation, parsing, command calling, exiting..)\nEnd Rem\nType mxApp\n\t\n\tConst c_version:String = \"0.01\"\n\tConst c_configfile:String = \"maximus.config\"\n\t\n\tField m_confighandler:mxConfigHandler\n\tField m_defaultlocale:dLocale, m_locale:dLocale\n\tField m_maxpath:String, m_modpath:String\n\tField m_sourcesfile:String = \"sources\", m_sourcesurl:String = \"http:\/\/maximus.htbaa.com\/module\/sources\/json\"\n\tField m_useragent:String\n\t\n\tField m_args:dIdentifier\n\tField m_arghandler:mxArgumentHandler\n\tField m_sourceshandler:mxSourcesHandler\n\t\n\tRem\n\t\tbbdoc: Create a new mxApp.\n\t\treturns: Itself.\n\tEnd Rem\n\tMethod Create:mxApp(args:String[])\n\t\tmainapp = Self\n\t\tSetArgs(args)\n\t\tOnInit()\n\t\tReturn Self\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Called when the application is created.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod OnInit()\n\t\tTry\n\t\t\tm_maxpath = BlitzMaxPath()\n\t\tCatch e:Object\n\t\t\tThrowError(_s(\"error.notfound.maxpath\"))\n\t\tEnd Try\n\t\tSetModPath(m_maxpath + \"\/mod\", False)\n\t\tm_confighandler = New mxConfigHandler.Create(c_configfile)\n\t\tm_confighandler.LoadDefaultLocale()\n\t\tm_confighandler.Load()\n\t\tm_arghandler = New mxArgumentHandler\n\t\tm_arghandler.AddArgImpl(New mxHelpImpl)\n\t\tm_arghandler.AddArgImpl(New mxVersionImpl)\n\t\tm_arghandler.AddArgImpl(New mxModPathImpl)\n\t\tm_arghandler.AddArgImpl(New mxInstallImpl)\n\t\tm_arghandler.AddArgImpl(New mxUpdateImpl)\n\t\tm_arghandler.AddArgImpl(New mxListImpl)\n\t\tm_sourceshandler = New mxSourcesHandler.FromFile(m_sourcesfile)\n\t\tIf m_sourceshandler = Null\n\t\t\t' Don't throw an error here, the user may be updating the sources (an error will occur otherwise)\n\t\t\tlogger.LogWarning(_s(\"error.load.sources.file\", [m_sourcesfile]))\n\t\tEnd If\n\t\tLocal os:String\n\t\t?Win32\n\t\t\tos = \"Windows\"\n\t\t?Linux\n\t\t\tos = \"Linux\"\n\t\t?MacOS\n\t\t\tos = \"MacOS\"\n\t\t?\n\t\tm_useragent = \"Maximus\/\" + c_version + \" (\" + os + \"; \" + m_locale.GetName() + \")\"\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Called when the application is ended (this includes #ThrowError calls).\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod OnExit()\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Run the application.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod Run()\n\t\tLocal argimpl:mxArgumentImplementation, isopt:Int\n\t\tFor Local arg:dIdentifier = EachIn m_args.GetValues()\n\t\t\targimpl = m_arghandler.GetArgImplFromAlias(arg.GetName())\n\t\t\tisopt = (arg.GetName()[0] = 45)\n\t\t\tIf argimpl <> Null\n\t\t\t\tIf isopt = True\n\t\t\t\t\targimpl.SetCallConvention(mxCallConvention.OPTION)\n\t\t\t\t\targimpl.SetArgs(arg)\n\t\t\t\t\targimpl.CheckArgs()\n\t\t\t\t\targimpl.Execute()\n\t\t\t\tElse\n\t\t\t\t\targimpl.SetCallConvention(mxCallConvention.COMMAND)\n\t\t\t\t\targimpl.SetArgs(arg)\n\t\t\t\t\targimpl.CheckArgs()\n\t\t\t\t\targimpl.Execute()\n\t\t\t\t\tExit\n\t\t\t\tEnd If\n\t\t\tElse\n\t\t\t\tIf isopt = True\n\t\t\t\t\tThrowCommonError(mxOptErrors.UNKNOWN, arg.GetName())\n\t\t\t\tElse\n\t\t\t\t\tThrowCommonError(mxCmdErrors.UNKNOWN, arg.GetName())\n\t\t\t\tEnd If\n\t\t\tEnd If\n\t\tNext\n\t\tOnExit()\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the application's arguments.\n\t\treturns: Nothing.\n\t\tabout: NOTE: This will resolve to '--help' if the given args are Null.\n\tEnd Rem\n\tMethod SetArgs(args:String[])\n\t\tIf args = Null\n\t\t\targs = [\"--help\"]\n\t\tEnd If\n\t\tm_args = dArgParser.ParseArray(args, False, 1)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the module path.\n\t\treturns: Nothing.\n\t\tabout: This will throw an error if the module path could not be found.\n\tEnd Rem\n\tMethod SetModPath(modpath:String, logchange:Int = True)\n\t\tm_modpath = FixPathEnding(modpath, True)\n\t\tIf FileType(mainapp.m_modpath) = FILETYPE_DIR\n\t\t\tIf logchange = True Then logger.LogMessage(_s(\"message.setmodpath\", [mainapp.m_modpath]))\n\t\tElse\n\t\t\tThrowError(_s(\"error.notfound.modpath\", [mainapp.m_modpath]))\n\t\tEnd If\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the sources url.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetSourcesUrl(url:String)\n\t\tm_sourcesurl = url\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the sources file.\n\t\treturns: Nothing.\n\t\tabout: NOTE: This will throw an error if the path is Null (and, later, a warning will be logged if the path does not exist).\n\tEnd Rem\n\tMethod SetSourcesFile(file:String)\n\t\tIf file = Null\n\t\t\tThrowError(_s(\"error.sources.setfile\"))\n\t\tEnd If\n\t\tm_sourcesfile = file\n\tEnd Method\n\t\nEnd Type\n\nRem\n\tbbdoc: Throw an error (terminating the application).\n\treturns: Nothing.\nEnd Rem\nFunction ThrowError(error:String)\n\tlogger.LogError(error)\n\tmainapp.OnExit()\n\tEnd\nEnd Function\n\nRem\n\tbbdoc: Get the localized text for the given identifier.\n\treturns: The translated text.\nEnd Rem\nFunction _s:String(iden:String, extra:String[] = Null)\n\tGlobal replacer:TTextReplacer = New TTextReplacer\n\tLocal ltext:dLocalizedText\n\tIf mainapp.m_locale <> Null Then ltext = mainapp.m_locale.TextFromStructureL(iden)\n\tIf ltext = Null Then ltext = mainapp.m_defaultlocale.TextFromStructureL(iden)\n\tIf ltext <> Null\n\t\treplacer.SetString(ltext.GetValue())\n\t\treplacer.AutoReplacements(\"{\", \"}\")\n\t\tIf extra <> Null\n\t\t\tLocal i:Int\n\t\t\tFor Local rep:TTextReplacement = EachIn replacer.GetList()\n\t\t\t\tIf i > extra.Length Then Exit\n\t\t\t\trep.SetReplacement(extra[i])\n\t\t\t\ti:+ 1\n\t\t\tNext\n\t\tEnd If\n\t\tReturn replacer.DoReplacements()\n\tElse\n\t\tDebugLog(\"Failed to find localized text from structure: ~q\" + iden + \"~q\")\n\tEnd If\nEnd Function\n\n","old_contents":"\nRem\nCopyright (c) 2010 Tim Howard\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and\/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\nEnd Rem\n\nSuperStrict\n\nFramework brl.blitz\nImport brl.standardio\nImport brl.maxutil\nImport brl.ramstream\n\nImport gman.zipengine\nImport htbaapub.rest\n\nImport duct.variables\nImport duct.objectmap\nImport duct.json\nImport duct.locale\nImport duct.argparser\n\nIncbin \"locales\/en.loc\"\n\nInclude \"src\/logger.bmx\"\nInclude \"src\/errors.bmx\"\nInclude \"src\/config.bmx\"\nInclude \"src\/dependencies.bmx\"\nInclude \"src\/module.bmx\"\nInclude \"src\/sources.bmx\"\nInclude \"src\/utils.bmx\"\nInclude \"src\/arghandler.bmx\"\nInclude \"src\/impl\/help.bmx\"\nInclude \"src\/impl\/version.bmx\"\nInclude \"src\/impl\/modpath.bmx\"\nInclude \"src\/impl\/install.bmx\"\nInclude \"src\/impl\/update.bmx\"\nInclude \"src\/impl\/list.bmx\"\n\nGlobal logger:mxLogger = New mxLogger\nGlobal mainapp:mxApp\nNew mxApp.Create(AppArgs[1..]) ' Skip the first element because it is the program's location\nmainapp.Run()\n\nRem\n\tbbdoc: Maximus app.\n\tabout: This handles the basic flow of the program (initiation, parsing, command calling, exiting..)\nEnd Rem\nType mxApp\n\t\n\tConst c_version:String = \"0.01\"\n\tConst c_configfile:String = \"maximus.config\"\n\t\n\tField m_confighandler:mxConfigHandler\n\tField m_defaultlocale:dLocale, m_locale:dLocale\n\tField m_maxpath:String, m_modpath:String\n\tField m_sourcesfile:String = \"sources\", m_sourcesurl:String = \"http:\/\/maximus.htbaa.com\/module\/sources\/json\"\n\tField m_useragent:String\n\t\n\tField m_args:dIdentifier\n\tField m_arghandler:mxArgumentHandler\n\tField m_sourceshandler:mxSourcesHandler\n\t\n\tRem\n\t\tbbdoc: Create a new mxApp.\n\t\treturns: Itself.\n\tEnd Rem\n\tMethod Create:mxApp(args:String[])\n\t\tmainapp = Self\n\t\tSetArgs(args)\n\t\tOnInit()\n\t\tReturn Self\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Called when the application is created.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod OnInit()\n\t\tTry\n\t\t\tm_maxpath = BlitzMaxPath()\n\t\tCatch e:Object\n\t\t\tThrowError(_s(\"error.notfound.maxpath\"))\n\t\tEnd Try\n\t\tSetModPath(m_maxpath + \"\/mod\", False)\n\t\tm_confighandler = New mxConfigHandler.Create(c_configfile)\n\t\tm_confighandler.LoadDefaultLocale()\n\t\tm_confighandler.Load()\n\t\tm_arghandler = New mxArgumentHandler\n\t\tm_arghandler.AddArgImpl(New mxHelpImpl)\n\t\tm_arghandler.AddArgImpl(New mxVersionImpl)\n\t\tm_arghandler.AddArgImpl(New mxModPathImpl)\n\t\tm_arghandler.AddArgImpl(New mxInstallImpl)\n\t\tm_arghandler.AddArgImpl(New mxUpdateImpl)\n\t\tm_arghandler.AddArgImpl(New mxListImpl)\n\t\tm_sourceshandler = New mxSourcesHandler.FromFile(m_sourcesfile)\n\t\tIf m_sourceshandler = Null\n\t\t\t' Don't throw an error here, the user may be updating the sources (an error will occur otherwise)\n\t\t\tlogger.LogWarning(_s(\"error.load.sources.file\", [m_sourcesfile]))\n\t\tEnd If\n\t\tLocal os:String\n\t\t?Win32\n\t\t\tos = \"Windows\"\n\t\t?Linux\n\t\t\tos = \"Linux\"\n\t\t?MacOS\n\t\t\tos = \"MacOS\"\n\t\t?\n\t\tm_useragent = \"Maximus\/\" + c_version + \" (\" + os + \"; \" + m_locale.GetName() + \")\"\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Called when the application is ended (this includes #ThrowError calls).\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod OnExit()\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Run the application.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod Run()\n\t\tLocal argimpl:mxArgumentImplementation, isopt:Int\n\t\tFor Local arg:dIdentifier = EachIn m_args.GetValues()\n\t\t\targimpl = m_arghandler.GetArgImplFromAlias(arg.GetName())\n\t\t\tisopt = (arg.GetName()[0] = 45)\n\t\t\tIf argimpl <> Null\n\t\t\t\tIf isopt = True\n\t\t\t\t\targimpl.SetCallConvention(mxCallConvention.OPTION)\n\t\t\t\t\targimpl.SetArgs(arg)\n\t\t\t\t\targimpl.CheckArgs()\n\t\t\t\t\targimpl.Execute()\n\t\t\t\tElse\n\t\t\t\t\targimpl.SetCallConvention(mxCallConvention.COMMAND)\n\t\t\t\t\targimpl.SetArgs(arg)\n\t\t\t\t\targimpl.CheckArgs()\n\t\t\t\t\targimpl.Execute()\n\t\t\t\t\tExit\n\t\t\t\tEnd If\n\t\t\tElse\n\t\t\t\tIf isopt = True\n\t\t\t\t\tThrowCommonError(mxOptErrors.UNKNOWN, arg.GetName())\n\t\t\t\tElse\n\t\t\t\t\tThrowCommonError(mxCmdErrors.UNKNOWN, arg.GetName())\n\t\t\t\tEnd If\n\t\t\tEnd If\n\t\tNext\n\t\tOnExit()\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the application's arguments.\n\t\treturns: Nothing.\n\t\tabout: NOTE: This will resolve to '--help' if the given args are Null.\n\tEnd Rem\n\tMethod SetArgs(args:String[])\n\t\tIf args = Null\n\t\t\targs = [\"--help\"]\n\t\tEnd If\n\t\tm_args = dArgParser.ParseArray(args, False, 1)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the module path.\n\t\treturns: Nothing.\n\t\tabout: This will throw an error if the module path could not be found.\n\tEnd Rem\n\tMethod SetModPath(modpath:String, logchange:Int = True)\n\t\tm_modpath = FixPathEnding(modpath, True)\n\t\tIf FileType(mainapp.m_modpath) = FILETYPE_DIR\n\t\t\tIf logchange = True Then logger.LogMessage(_s(\"message.setmodpath\", [mainapp.m_modpath]))\n\t\tElse\n\t\t\tThrowError(_s(\"error.notfound.modpath\", [mainapp.m_modpath]))\n\t\tEnd If\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the sources url.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetSourcesUrl(url:String)\n\t\tm_sourcesurl = url\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the sources file.\n\t\treturns: Nothing.\n\t\tabout: NOTE: This will throw an error if the path is Null (and, later, a warning will be logged if the path does not exist).\n\tEnd Rem\n\tMethod SetSourcesFile(file:String)\n\t\tIf file = Null\n\t\t\tThrowError(_s(\"error.sources.setfile\"))\n\t\tEnd If\n\t\tm_sourcesfile = file\n\tEnd Method\n\t\nEnd Type\n\nRem\n\tbbdoc: Throw an error (terminating the application).\n\treturns: Nothing.\nEnd Rem\nFunction ThrowError(error:String)\n\tlogger.LogError(error)\n\tmainapp.OnExit()\n\tEnd\nEnd Function\n\nRem\n\tbbdoc: Get the localized text for the given identifier.\n\treturns: The translated text.\nEnd Rem\nFunction _s:String(iden:String, extra:String[] = Null)\n\tGlobal replacer:TTextReplacer = New TTextReplacer\n\tLocal ltext:dLocalizedText\n\tIf mainapp.m_locale <> Null Then ltext = mainapp.m_locale.TextFromStructureL(iden)\n\tIf ltext = Null Then ltext = mainapp.m_defaultlocale.TextFromStructureL(iden)\n\tIf ltext <> Null\n\t\treplacer.SetString(ltext.GetValue())\n\t\treplacer.AutoReplacements(\"{\", \"}\")\n\t\tIf extra <> Null\n\t\t\tLocal i:Int\n\t\t\tFor Local rep:TTextReplacement = EachIn replacer.GetList()\n\t\t\t\tIf i > extra.Length Then Exit\n\t\t\t\trep.SetReplacement(extra[i])\n\t\t\t\ti:+ 1\n\t\t\tNext\n\t\tEnd If\n\t\tReturn replacer.DoReplacements()\n\tElse\n\t\tDebugLog(\"Failed to find localized text from structure: ~q\" + iden + \"~q\")\n\tEnd If\nEnd Function\n\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"e8a7d061d8fb7ca0f63436ac2aba1831c364f8a6","subject":"Wrapped more XMLRPC-EPI functions","message":"Wrapped more XMLRPC-EPI functions\n","repos":"Htbaa\/xmlrpc.mod,Htbaa\/xmlrpc.mod,Htbaa\/xmlrpc.mod,Htbaa\/xmlrpc.mod,Htbaa\/xmlrpc.mod","old_file":"wrapper.bmx","new_file":"wrapper.bmx","new_contents":"'XMLRPC_REQUEST_TYPE\nConst xmlrpc_request_none:Int = 0\nConst xmlrpc_request_call:Int = 1\nConst xmlrpc_request_response:Int = 2\n\n'XMLRPC_VERSION\nConst xmlrpc_version_none:Int = 0\nConst xmlrpc_version_1_0:Int = 1\nConst xmlrpc_version_simple:Int = 2\nConst xmlrpc_version_danda:Int = 2\nConst xmlrpc_version_soap_1_1:Int = 3\n\n'XMLRPC_VECTOR_TYPE\nConst xmlrpc_vector_none:Int = 0\nConst xmlrpc_vector_array:Int = 1\nConst xmlrpc_vector_mixed:Int = 2\nConst xmlrpc_vector_struct:Int = 3\n\n'XMLRPC_VALUE_TYPE\nConst xmlrpc_none:Int = 0\nConst xmlrpc_empty:Int = 1\nConst xmlrpc_base64:Int = 2\nConst xmlrpc_boolean:Int = 3\nConst xmlrpc_datetime:Int = 4\nConst xmlrpc_double:Int = 5\nConst xmlrpc_int:Int = 6\nConst xmlrpc_string:Int = 7\nConst xmlrpc_vector:Int = 8\n\n'XMLRPC_VALUE_TYPE_EASY\nConst xmlrpc_type_none:Int = 0\nConst xmlrpc_type_empty:Int = 1\nConst xmlrpc_type_base64:Int = 2\nConst xmlrpc_type_boolean:Int = 3\nConst xmlrpc_type_datetime:Int = 4\nConst xmlrpc_type_double:Int = 5\nConst xmlrpc_type_int:Int = 6\nConst xmlrpc_type_string:Int = 7\nConst xmlrpc_type_array:Int = 8\nConst xmlrpc_type_mixed:Int = 9\nConst xmlrpc_type_struct:Int = 10\n\n'XMLRPC_ERROR_CODE\nConst xmlrpc_error_none:Int = 0\nConst xmlrpc_error_parse_xml_syntax:Int = -32700\nConst xmlrpc_error_parse_unknown_encoding:Int = -32701\nConst xmlrpc_error_parse_bad_encoding:Int = -32702\nConst xmlrpc_error_invalid_xmlrpc:Int = -32600\nConst xmlrpc_error_unknown_method:Int = -32601\nConst xmlrpc_error_invalid_params:Int = -32602\nConst xmlrpc_error_internal_server:Int = -32603\nConst xmlrpc_error_application:Int = -32500\nConst xmlrpc_error_system:Int = -32400\nConst xmlrpc_error_transport:Int = -32300\n\n'XMLRPC_SERVER_VALIDATION\nConst validation_none:Int = 0\nConst validation_all:Int = 1\nConst validation_if_defined:Int = 2\n\n'XMLRPC_CASE_COMPARISON\nConst xmlrpc_case_insensitive:Int = 0\nConst xmlrpc_case_sensitive:Int = 1\n\n'XMLRPC_CASE\nConst xmlrpc_case_exact:Int = 0\nConst xmlrpc_case_lower:Int = 1\nConst xmlrpc_case_upper:Int = 2\n\nExtern\n\tFunction XMLRPC_Create_STRUCT_XMLRPC_REQUEST_OUTPUT_OPTIONS:Byte Ptr(version:Int)\n'\tFunction XMLRPC_Delete_Request_Output_Options(options:Byte Ptr)\nEnd Extern\n\nExtern \"C\"\n\n\tFunction XMLRPC_RequestNew:Byte Ptr()\n\tFunction XMLRPC_RequestFree(request:Byte Ptr, bFreeIO:Int)\n\tFunction XMLRPC_RequestSetMethodName:Byte Ptr(request:Byte Ptr, methodName:Byte Ptr)\n\tFunction XMLRPC_RequestGetMethodName:Byte Ptr(request:Byte Ptr)\n\tFunction XMLRPC_RequestSetRequestType:Int(request:Byte Ptr, iType:Int)\n\tFunction XMLRPC_RequestGetRequestType:Int(request:Byte Ptr)\n\tFunction XMLRPC_RequestSetData:Byte Ptr(request:Byte Ptr, data:Byte Ptr)\n\tFunction XMLRPC_RequestGetData:Byte Ptr(request:Byte Ptr)\n\n\tFunction XMLRPC_REQUEST_ToXML:Byte Ptr(request:Byte Ptr, buf_len:Byte Ptr)\n\tFunction XMLRPC_REQUEST_FromXML:Byte Ptr(in_buf:Byte Ptr, length:Int, in_options:Byte Ptr)\n\tFunction XMLRPC_VALUE_ToXML:Byte Ptr(val:Int, buf_len:Byte Ptr)\n\tFunction XMLRPC_VALUE_FromXML:Byte Ptr(in_buf:Byte Ptr, length:Int, in_options:Byte Ptr)\n\n\tFunction XMLRPC_RequestSetOutputOptions:Byte Ptr(request:Byte Ptr, output:Byte Ptr)\n\tFunction XMLRPC_RequestGetOutputOptions:Byte Ptr(request:Byte Ptr)\n\n\tFunction XMLRPC_CreateVector:Byte Ptr(id:String, iType:Int)\n\tFunction XMLRPC_AddValueToVector:Int(target:Byte Ptr, source:Byte Ptr)\n\tFunction XMLRPC_VectorSize:Int(value:Byte Ptr)\n\tFunction XMLRPC_VectorRewind:Byte Ptr(value:Byte Ptr)\n\tFunction XMLRPC_VectorNext:Byte Ptr(value:Byte Ptr)\n\t\n\tFunction XMLRPC_CreateValueBoolean:Byte Ptr(id:Byte Ptr, truth:Int)\n\tFunction XMLRPC_CreateValueBase64:Byte Ptr(id:Byte Ptr, s:Byte Ptr, length:Int)\n\tFunction XMLRPC_CreateValueDateTime:Byte Ptr(id:Byte Ptr, time:Long)\n\tFunction XMLRPC_CreateValueDateTime_ISO8601:Byte Ptr(id:Byte Ptr, s:Byte Ptr)\n\tFunction XMLRPC_CreateValueDouble:Byte Ptr(id:Byte Ptr, f:Double)\n\tFunction XMLRPC_CreateValueInt:Byte Ptr(id:Byte Ptr, i:Int)\n\tFunction XMLRPC_CreateValueEmpty:Byte Ptr()\n\tFunction XMLRPC_CreateValueString:Byte Ptr(id:Byte Ptr, s:Byte Ptr, length:Int)\n\n\tFunction XMLRPC_RequestSetError:Int(request:Byte Ptr, error:Int)\n\tFunction XMLRPC_RequestGetError:Int(request:Byte Ptr)\n\n\tFunction XMLRPC_VectorGetValueWithID_Case:Byte Ptr(vector:Byte Ptr, id:Byte Ptr, id_case:Int)\n\t\n\tFunction XMLRPC_GetValueType:Int(v:Byte Ptr)\n\t'XMLRPC_VALUE_TYPE_EASY XMLRPC_GetValueTypeEasy(XMLRPC_VALUE v);\n\t'XMLRPC_VECTOR_TYPE XMLRPC_GetVectorType(XMLRPC_VALUE v);\n\t\n\tFunction XMLRPC_GetValueString:Byte Ptr(value:Byte Ptr)\n\tFunction XMLRPC_GetValueStringLen:Int(value:Byte Ptr)\n\tFunction XMLRPC_GetValueInt:Int(value:Byte Ptr)\n\tFunction XMLRPC_GetValueBoolean:Int(value:Byte Ptr)\n\tFunction XMLRPC_GetValueDouble:Double(value:Byte Ptr)\n\tFunction XMLRPC_GetValueBase64:Byte Ptr(value:Byte Ptr)\n\tFunction XMLRPC_GetValueDateTime:Long(value:Byte Ptr)\n\tFunction XMLRPC_GetValueDateTime_ISO8601:Byte Ptr(value:Byte Ptr)\n\tFunction XMLRPC_GetValueID:Byte Ptr(value:Byte Ptr)\n\t\n\tFunction XMLRPC_ValueIsFault:Int(value:Byte Ptr)\n\tFunction XMLRPC_ResponseIsFault(response:Byte Ptr)\n\tFunction XMLRPC_GetValueFaultCode:Int(value:Byte Ptr)\n\tFunction XMLRPC_GetResponseFaultCode:Int(response:Byte Ptr)\n\tFunction XMLRPC_GetValueFaultString:Byte Ptr(value:Byte Ptr)\n\tFunction XMLRPC_GetResponseFaultString:Byte Ptr(response:Byte Ptr)\n\tFunction XMLRPC_Free(mem:Byte Ptr)\n\tFunction XMLRPC_GetVersionString:Byte Ptr()\nRem\n\n\nXMLRPC_VALUE XMLRPC_UtilityCreateFault(int fault_code, const char* fault_string);\n\n\/* Get Values *\/\n#define XMLRPC_VectorGetStringWithID(vector, id) XMLRPC_GetValueString(XMLRPC_VectorGetValueWithID(vector, id))\n#define XMLRPC_VectorGetBase64WithID(vector, id) XMLRPC_GetValueBase64(XMLRPC_VectorGetValueWithID(vector, id))\n#define XMLRPC_VectorGetDateTimeWithID(vector, id) XMLRPC_GetValueDateTime(XMLRPC_VectorGetValueWithID(vector, id))\n#define XMLRPC_VectorGetDoubleWithID(vector, id) XMLRPC_GetValueDouble(XMLRPC_VectorGetValueWithID(vector, id))\n#define XMLRPC_VectorGetIntWithID(vector, id) XMLRPC_GetValueInt(XMLRPC_VectorGetValueWithID(vector, id))\n#define XMLRPC_VectorGetBooleanWithID(vector, id) XMLRPC_GetValueBoolean(XMLRPC_VectorGetValueWithID(vector, id))\nEndrem\nEnd Extern\n\nFunction XMLRPC_VectorGetValueWithID:Byte Ptr(vector:Byte Ptr, id:String)\n\tReturn XMLRPC_VectorGetValueWithID_Case(vector, id.ToCString(), xmlrpc_case_sensitive)\nEnd Function\n\nFunction XMLRPC_VectorAppendString:Int(vector:Byte Ptr, id:String, s:String, length:Int = 0)\n\tReturn XMLRPC_AddValueToVector(vector, XMLRPC_CreateValueString(id.ToCString(), s.ToCString(), length))\nEnd Function\n\nFunction XMLRPC_VectorAppendBase64:Int(vector:Byte Ptr, id:String, s:String, length:Int = 0)\n\tReturn XMLRPC_AddValueToVector(vector, XMLRPC_CreateValueBase64(id.ToCString(), s.ToCString(), length))\nEnd Function\n\nFunction XMLRPC_VectorAppendDateTime:Int(vector:Byte Ptr, id:Byte Ptr, time:Long)\n\tReturn XMLRPC_AddValueToVector(vector, XMLRPC_CreateValueDateTime(id, time))\nEnd Function\n\nFunction XMLRPC_VectorAppendDateTime_ISO8601:Int(vector:Byte Ptr, id:String, s:String)\n\tReturn XMLRPC_AddValueToVector(vector, XMLRPC_CreateValueDateTime_ISO8601(id.ToCString(), s.ToCString()))\nEnd Function\n\nFunction XMLRPC_VectorAppendDouble:Int(vector:Byte Ptr, id:String, f:Double)\n\tReturn XMLRPC_AddValueToVector(vector, XMLRPC_CreateValueDouble(id.ToCString(), f))\nEnd Function\n\nFunction XMLRPC_VectorAppendInt:Int(vector:Byte Ptr, id:String, i:Int)\n\tReturn XMLRPC_AddValueToVector(vector, XMLRPC_CreateValueInt(id.ToCString(), i))\nEnd Function\n\nFunction XMLRPC_VectorAppendBoolean:Int(vector:Byte Ptr, id:String, i:Int)\n\tReturn XMLRPC_AddValueToVector(vector, XMLRPC_CreateValueBoolean(id.ToCString(), i))\nEnd Function\nrem\n\/****s* VALUE\/XMLRPC_REQUEST_INPUT_OPTIONS\n * NAME\n * XMLRPC_REQUEST_INPUT_OPTIONS\n * NOTES\n * Defines options for reading in xml data\n * SEE ALSO\n * XMLRPC_VERSION\n * XML_ELEM_INPUT_OPTIONS\n * XMLRPC_REQUEST_From_XML ()\n * SOURCE\n *\/\ntypedef struct _xmlrpc_request_input_options {\n STRUCT_XML_ELEM_INPUT_OPTIONS xml_elem_opts; \/* xml_element specific output options *\/\n} STRUCT_XMLRPC_REQUEST_INPUT_OPTIONS, *XMLRPC_REQUEST_INPUT_OPTIONS;\n\/******\/\n\n\/****s* VALUE\/XMLRPC_ERROR\n * NAME\n * XMLRPC_ERROR\n * NOTES\n * For the reporting and handling of errors\n * SOURCE\n *\/\ntypedef struct _xmlrpc_error {\n XMLRPC_ERROR_CODE code;\n STRUCT_XML_ELEM_ERROR xml_elem_error; \/* xml_element errors (parser errors) *\/\n} STRUCT_XMLRPC_ERROR, *XMLRPC_ERROR;\n\/******\/\nendrem\n\n\nRem\n\tString conversion stuff below. Shamelessly stolen from Brucey :-)\nEnd Rem\n\nExtern\n\tFunction _strlen:Int(s:Byte Ptr) = \"strlen\"\nEnd Extern\n\n' Convert from Max to UTF8\nFunction convertISO8859toUTF8:String(text:String)\n\tIf Not text Then\n\t\tReturn \"\"\n\tEnd If\n\t\n\tLocal l:Int = text.length\n\tIf l = 0 Then\n\t\tReturn \"\"\n\tEnd If\n\t\n\tLocal count:Int = 0\n\tLocal s:Byte[] = New Byte[l * 3]\n\t\n\tFor Local i:Int = 0 Until l\n\t\tLocal char:Int = text[i]\n\n\t\tIf char < 128 Then\n\t\t\ts[count] = char\n\t\t\tcount:+ 1\n\t\t\tContinue\n\t\tElse If char<2048\n\t\t\ts[count] = char\/64 | 192\n\t\t\tcount:+ 1\n\t\t\ts[count] = char Mod 64 | 128\n\t\t\tcount:+ 1\n\t\t\tContinue\n\t\tElse\n\t\t\ts[count] = char\/4096 | 224\n\t\t\tcount:+ 1\n\t\t\ts[count] = char\/64 Mod 64 | 128\n\t\t\tcount:+ 1\n\t\t\ts[count] = char Mod 64 | 128\n\t\t\tcount:+ 1\n\t\t\tContinue\n\t\tEndIf\n\t\t\n\tNext\n\n\tReturn String.fromBytes(s, count)\nEnd Function\n\n' Convert from UTF8 to Max\nFunction convertUTF8toISO8859:String(s:Byte Ptr)\n\n\tLocal l:Int = _strlen(s)\n\n\tLocal b:Short[] = New Short[l]\n\tLocal bc:Int = -1\n\tLocal c:Int\n\tLocal d:Int\n\tLocal e:Int\n\tFor Local i:Int = 0 Until l\n\n\t\tbc:+1\n\t\tc = s[i]\n\t\tIf c<128 \n\t\t\tb[bc] = c\n\t\t\tContinue\n\t\tEnd If\n\t\ti:+1\n\t\td=s[i]\n\t\tIf c<224 \n\t\t\tb[bc] = (c-192)*64+(d-128)\n\t\t\tContinue\n\t\tEnd If\n\t\ti:+1\n\t\te = s[i]\n\t\tIf c < 240 \n\t\t\tb[bc] = (c-224)*4096+(d-128)*64+(e-128)\n\t\t\tIf b[bc] = 8233 Then\n\t\t\t\tb[bc] = 10\n\t\t\tEnd If\n\t\t\tContinue\n\t\tEnd If\n\tNext\n\n\tReturn String.fromshorts(b, bc + 1)\nEnd Function\n\nFunction sizedUTF8toISO8859:String(s:Byte Ptr, size:Int)\n\n\tLocal l:Int = size\n\tLocal b:Short[] = New Short[l]\n\tLocal bc:Int = -1\n\tLocal c:Int\n\tLocal d:Int\n\tLocal e:Int\n\tFor Local i:Int = 0 Until l\n\n\t\tc = s[i]\n\t\tIf c = 0 Continue\n\n\t\tbc:+1\n\t\tIf c<128\n\t\t\tb[bc] = c\n\t\t\tContinue\n\t\tEnd If\n\t\ti:+1\n\t\td=s[i]\n\t\tIf c<224 \n\t\t\tb[bc] = (c-192)*64+(d-128)\n\t\t\tContinue\n\t\tEnd If\n\t\ti:+1\n\t\te = s[i]\n\t\tIf c < 240 \n\t\t\tb[bc] = (c-224)*4096+(d-128)*64+(e-128)\n\t\t\tIf b[bc] = 8233 Then\n\t\t\t\tb[bc] = 10\n\t\t\tEnd If\n\t\t\tContinue\n\t\tEnd If\n\tNext\n\n\tReturn String.fromshorts(b, bc + 1)\nEnd Function","old_contents":"'XMLRPC_REQUEST_TYPE\nConst xmlrpc_request_none:Int = 0\nConst xmlrpc_request_call:Int = 1\nConst xmlrpc_request_response:Int = 2\n\n'XMLRPC_VERSION\nConst xmlrpc_version_none:Int = 0\nConst xmlrpc_version_1_0:Int = 1\nConst xmlrpc_version_simple:Int = 2\nConst xmlrpc_version_danda:Int = 2\nConst xmlrpc_version_soap_1_1:Int = 3\n\n'XMLRPC_VECTOR_TYPE\nConst xmlrpc_vector_none:Int = 0\nConst xmlrpc_vector_array:Int = 1\nConst xmlrpc_vector_mixed:Int = 2\nConst xmlrpc_vector_struct:Int = 3\n\n'XMLRPC_VALUE_TYPE\nConst xmlrpc_none:Int = 0\nConst xmlrpc_empty:Int = 1\nConst xmlrpc_base64:Int = 2\nConst xmlrpc_boolean:Int = 3\nConst xmlrpc_datetime:Int = 4\nConst xmlrpc_double:Int = 5\nConst xmlrpc_int:Int = 6\nConst xmlrpc_string:Int = 7\nConst xmlrpc_vector:Int = 8\n\n'XMLRPC_VALUE_TYPE_EASY\nConst xmlrpc_type_none:Int = 0\nConst xmlrpc_type_empty:Int = 1\nConst xmlrpc_type_base64:Int = 2\nConst xmlrpc_type_boolean:Int = 3\nConst xmlrpc_type_datetime:Int = 4\nConst xmlrpc_type_double:Int = 5\nConst xmlrpc_type_int:Int = 6\nConst xmlrpc_type_string:Int = 7\nConst xmlrpc_type_array:Int = 8\nConst xmlrpc_type_mixed:Int = 9\nConst xmlrpc_type_struct:Int = 10\n\n'XMLRPC_ERROR_CODE\nConst xmlrpc_error_none:Int = 0\nConst xmlrpc_error_parse_xml_syntax:Int = -32700\nConst xmlrpc_error_parse_unknown_encoding:Int = -32701\nConst xmlrpc_error_parse_bad_encoding:Int = -32702\nConst xmlrpc_error_invalid_xmlrpc:Int = -32600\nConst xmlrpc_error_unknown_method:Int = -32601\nConst xmlrpc_error_invalid_params:Int = -32602\nConst xmlrpc_error_internal_server:Int = -32603\nConst xmlrpc_error_application:Int = -32500\nConst xmlrpc_error_system:Int = -32400\nConst xmlrpc_error_transport:Int = -32300\n\n'XMLRPC_SERVER_VALIDATION\nConst validation_none:Int = 0\nConst validation_all:Int = 1\nConst validation_if_defined:Int = 2\n\n'XMLRPC_CASE_COMPARISON\nConst xmlrpc_case_insensitive:Int = 0\nConst xmlrpc_case_sensitive:Int = 1\n\n'XMLRPC_CASE\nConst xmlrpc_case_exact:Int = 0\nConst xmlrpc_case_lower:Int = 1\nConst xmlrpc_case_upper:Int = 2\n\nExtern\n\tFunction XMLRPC_Create_STRUCT_XMLRPC_REQUEST_OUTPUT_OPTIONS:Byte Ptr(version:Int)\n'\tFunction XMLRPC_Delete_Request_Output_Options(options:Byte Ptr)\nEnd Extern\n\nExtern \"C\"\n\n\tFunction XMLRPC_RequestNew:Byte Ptr()\n\tFunction XMLRPC_RequestFree(request:Byte Ptr, bFreeIO:Int)\n\tFunction XMLRPC_RequestSetMethodName:Byte Ptr(request:Byte Ptr, methodName:Byte Ptr)\n\tFunction XMLRPC_RequestGetMethodName:Byte Ptr(request:Byte Ptr)\n\tFunction XMLRPC_RequestSetRequestType:Int(request:Byte Ptr, iType:Int)\n\tFunction XMLRPC_RequestGetRequestType:Int(request:Byte Ptr)\n\tFunction XMLRPC_RequestSetData:Byte Ptr(request:Byte Ptr, data:Byte Ptr)\n\tFunction XMLRPC_RequestGetData:Byte Ptr(request:Byte Ptr)\n\n\tFunction XMLRPC_REQUEST_ToXML:Byte Ptr(request:Byte Ptr, buf_len:Byte Ptr)\n\tFunction XMLRPC_REQUEST_FromXML:Byte Ptr(in_buf:Byte Ptr, length:Int, in_options:Byte Ptr)\n\tFunction XMLRPC_VALUE_ToXML:Byte Ptr(val:Int, buf_len:Byte Ptr)\n\tFunction XMLRPC_VALUE_FromXML:Byte Ptr(in_buf:Byte Ptr, length:Int, in_options:Byte Ptr)\n\n\tFunction XMLRPC_RequestSetOutputOptions:Byte Ptr(request:Byte Ptr, output:Byte Ptr)\n\tFunction XMLRPC_RequestGetOutputOptions:Byte Ptr(request:Byte Ptr)\n\n\tFunction XMLRPC_CreateVector:Byte Ptr(id:String, iType:Int)\n\tFunction XMLRPC_AddValueToVector:Int(target:Byte Ptr, source:Byte Ptr)\n\tFunction XMLRPC_VectorSize:Int(value:Byte Ptr)\n\tFunction XMLRPC_VectorRewind:Byte Ptr(value:Byte Ptr)\n\tFunction XMLRPC_VectorNext:Byte Ptr(value:Byte Ptr)\n\t\n\tFunction XMLRPC_CreateValueBoolean:Byte Ptr(id:Byte Ptr, truth:Int)\n\tFunction XMLRPC_CreateValueBase64:Byte Ptr(id:Byte Ptr, s:Byte Ptr, length:Int)\n\tFunction XMLRPC_CreateValueDateTime:Byte Ptr(id:Byte Ptr, time:Long)\n\tFunction XMLRPC_CreateValueDateTime_ISO8601:Byte Ptr(id:Byte Ptr, s:Byte Ptr)\n\tFunction XMLRPC_CreateValueDouble:Byte Ptr(id:Byte Ptr, f:Double)\n\tFunction XMLRPC_CreateValueInt:Byte Ptr(id:Byte Ptr, i:Int)\n\tFunction XMLRPC_CreateValueEmpty:Byte Ptr()\n\tFunction XMLRPC_CreateValueString:Byte Ptr(id:Byte Ptr, s:Byte Ptr, length:Int)\n\n\tFunction XMLRPC_RequestSetError:Int(request:Byte Ptr, error:Int)\n\tFunction XMLRPC_RequestGetError:Int(request:Byte Ptr)\n\n\tFunction XMLRPC_VectorGetValueWithID_Case:Byte Ptr(vector:Byte Ptr, id:Byte Ptr, id_case:Int)\n\t\n\tFunction XMLRPC_GetValueType:Int(v:Byte Ptr)\n\t'XMLRPC_VALUE_TYPE_EASY XMLRPC_GetValueTypeEasy(XMLRPC_VALUE v);\n\t'XMLRPC_VECTOR_TYPE XMLRPC_GetVectorType(XMLRPC_VALUE v);\n\t\n\tFunction XMLRPC_GetValueString:Byte Ptr(value:Byte Ptr)\n\tFunction XMLRPC_GetValueStringLen:Int(value:Byte Ptr)\n\tFunction XMLRPC_GetValueInt:Int(value:Byte Ptr)\n\tFunction XMLRPC_GetValueBoolean:Int(value:Byte Ptr)\n\tFunction XMLRPC_GetValueDouble:Double(value:Byte Ptr)\n\tFunction XMLRPC_GetValueBase64:Byte Ptr(value:Byte Ptr)\n\tFunction XMLRPC_GetValueDateTime:Long(value:Byte Ptr)\n\tFunction XMLRPC_GetValueDateTime_ISO8601:Byte Ptr(value:Byte Ptr)\n\tFunction XMLRPC_GetValueID:Byte Ptr(value:Byte Ptr)\nRem\n\/* Get Values *\/\n\n\n\n\n#define XMLRPC_VectorGetStringWithID(vector, id) XMLRPC_GetValueString(XMLRPC_VectorGetValueWithID(vector, id))\n#define XMLRPC_VectorGetBase64WithID(vector, id) XMLRPC_GetValueBase64(XMLRPC_VectorGetValueWithID(vector, id))\n#define XMLRPC_VectorGetDateTimeWithID(vector, id) XMLRPC_GetValueDateTime(XMLRPC_VectorGetValueWithID(vector, id))\n#define XMLRPC_VectorGetDoubleWithID(vector, id) XMLRPC_GetValueDouble(XMLRPC_VectorGetValueWithID(vector, id))\n#define XMLRPC_VectorGetIntWithID(vector, id) XMLRPC_GetValueInt(XMLRPC_VectorGetValueWithID(vector, id))\n#define XMLRPC_VectorGetBooleanWithID(vector, id) XMLRPC_GetValueBoolean(XMLRPC_VectorGetValueWithID(vector, id))\nEndrem\nEnd Extern\n\nFunction XMLRPC_VectorGetValueWithID:Byte Ptr(vector:Byte Ptr, id:String)\n\tReturn XMLRPC_VectorGetValueWithID_Case(vector, id.ToCString(), xmlrpc_case_sensitive)\nEnd Function\n\nFunction XMLRPC_VectorAppendString:Int(vector:Byte Ptr, id:String, s:String, length:Int = 0)\n\tReturn XMLRPC_AddValueToVector(vector, XMLRPC_CreateValueString(id.ToCString(), s.ToCString(), length))\nEnd Function\n\nFunction XMLRPC_VectorAppendBase64:Int(vector:Byte Ptr, id:String, s:String, length:Int = 0)\n\tReturn XMLRPC_AddValueToVector(vector, XMLRPC_CreateValueBase64(id.ToCString(), s.ToCString(), length))\nEnd Function\n\nFunction XMLRPC_VectorAppendDateTime:Int(vector:Byte Ptr, id:Byte Ptr, time:Long)\n\tReturn XMLRPC_AddValueToVector(vector, XMLRPC_CreateValueDateTime(id, time))\nEnd Function\n\nFunction XMLRPC_VectorAppendDateTime_ISO8601:Int(vector:Byte Ptr, id:String, s:String)\n\tReturn XMLRPC_AddValueToVector(vector, XMLRPC_CreateValueDateTime_ISO8601(id.ToCString(), s.ToCString()))\nEnd Function\n\nFunction XMLRPC_VectorAppendDouble:Int(vector:Byte Ptr, id:String, f:Double)\n\tReturn XMLRPC_AddValueToVector(vector, XMLRPC_CreateValueDouble(id.ToCString(), f))\nEnd Function\n\nFunction XMLRPC_VectorAppendInt:Int(vector:Byte Ptr, id:String, i:Int)\n\tReturn XMLRPC_AddValueToVector(vector, XMLRPC_CreateValueInt(id.ToCString(), i))\nEnd Function\n\nFunction XMLRPC_VectorAppendBoolean:Int(vector:Byte Ptr, id:String, i:Int)\n\tReturn XMLRPC_AddValueToVector(vector, XMLRPC_CreateValueBoolean(id.ToCString(), i))\nEnd Function\nrem\n\/****s* VALUE\/XMLRPC_REQUEST_INPUT_OPTIONS\n * NAME\n * XMLRPC_REQUEST_INPUT_OPTIONS\n * NOTES\n * Defines options for reading in xml data\n * SEE ALSO\n * XMLRPC_VERSION\n * XML_ELEM_INPUT_OPTIONS\n * XMLRPC_REQUEST_From_XML ()\n * SOURCE\n *\/\ntypedef struct _xmlrpc_request_input_options {\n STRUCT_XML_ELEM_INPUT_OPTIONS xml_elem_opts; \/* xml_element specific output options *\/\n} STRUCT_XMLRPC_REQUEST_INPUT_OPTIONS, *XMLRPC_REQUEST_INPUT_OPTIONS;\n\/******\/\n\n\/****s* VALUE\/XMLRPC_ERROR\n * NAME\n * XMLRPC_ERROR\n * NOTES\n * For the reporting and handling of errors\n * SOURCE\n *\/\ntypedef struct _xmlrpc_error {\n XMLRPC_ERROR_CODE code;\n STRUCT_XML_ELEM_ERROR xml_elem_error; \/* xml_element errors (parser errors) *\/\n} STRUCT_XMLRPC_ERROR, *XMLRPC_ERROR;\n\/******\/\nendrem\n\n\nRem\n\tString conversion stuff below. Shamelessly stolen from Brucey :-)\nEnd Rem\n\nExtern\n\tFunction _strlen:Int(s:Byte Ptr) = \"strlen\"\nEnd Extern\n\n' Convert from Max to UTF8\nFunction convertISO8859toUTF8:String(text:String)\n\tIf Not text Then\n\t\tReturn \"\"\n\tEnd If\n\t\n\tLocal l:Int = text.length\n\tIf l = 0 Then\n\t\tReturn \"\"\n\tEnd If\n\t\n\tLocal count:Int = 0\n\tLocal s:Byte[] = New Byte[l * 3]\n\t\n\tFor Local i:Int = 0 Until l\n\t\tLocal char:Int = text[i]\n\n\t\tIf char < 128 Then\n\t\t\ts[count] = char\n\t\t\tcount:+ 1\n\t\t\tContinue\n\t\tElse If char<2048\n\t\t\ts[count] = char\/64 | 192\n\t\t\tcount:+ 1\n\t\t\ts[count] = char Mod 64 | 128\n\t\t\tcount:+ 1\n\t\t\tContinue\n\t\tElse\n\t\t\ts[count] = char\/4096 | 224\n\t\t\tcount:+ 1\n\t\t\ts[count] = char\/64 Mod 64 | 128\n\t\t\tcount:+ 1\n\t\t\ts[count] = char Mod 64 | 128\n\t\t\tcount:+ 1\n\t\t\tContinue\n\t\tEndIf\n\t\t\n\tNext\n\n\tReturn String.fromBytes(s, count)\nEnd Function\n\n' Convert from UTF8 to Max\nFunction convertUTF8toISO8859:String(s:Byte Ptr)\n\n\tLocal l:Int = _strlen(s)\n\n\tLocal b:Short[] = New Short[l]\n\tLocal bc:Int = -1\n\tLocal c:Int\n\tLocal d:Int\n\tLocal e:Int\n\tFor Local i:Int = 0 Until l\n\n\t\tbc:+1\n\t\tc = s[i]\n\t\tIf c<128 \n\t\t\tb[bc] = c\n\t\t\tContinue\n\t\tEnd If\n\t\ti:+1\n\t\td=s[i]\n\t\tIf c<224 \n\t\t\tb[bc] = (c-192)*64+(d-128)\n\t\t\tContinue\n\t\tEnd If\n\t\ti:+1\n\t\te = s[i]\n\t\tIf c < 240 \n\t\t\tb[bc] = (c-224)*4096+(d-128)*64+(e-128)\n\t\t\tIf b[bc] = 8233 Then\n\t\t\t\tb[bc] = 10\n\t\t\tEnd If\n\t\t\tContinue\n\t\tEnd If\n\tNext\n\n\tReturn String.fromshorts(b, bc + 1)\nEnd Function\n\nFunction sizedUTF8toISO8859:String(s:Byte Ptr, size:Int)\n\n\tLocal l:Int = size\n\tLocal b:Short[] = New Short[l]\n\tLocal bc:Int = -1\n\tLocal c:Int\n\tLocal d:Int\n\tLocal e:Int\n\tFor Local i:Int = 0 Until l\n\n\t\tc = s[i]\n\t\tIf c = 0 Continue\n\n\t\tbc:+1\n\t\tIf c<128\n\t\t\tb[bc] = c\n\t\t\tContinue\n\t\tEnd If\n\t\ti:+1\n\t\td=s[i]\n\t\tIf c<224 \n\t\t\tb[bc] = (c-192)*64+(d-128)\n\t\t\tContinue\n\t\tEnd If\n\t\ti:+1\n\t\te = s[i]\n\t\tIf c < 240 \n\t\t\tb[bc] = (c-224)*4096+(d-128)*64+(e-128)\n\t\t\tIf b[bc] = 8233 Then\n\t\t\t\tb[bc] = 10\n\t\t\tEnd If\n\t\t\tContinue\n\t\tEnd If\n\tNext\n\n\tReturn String.fromshorts(b, bc + 1)\nEnd Function","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"254cec7bb89c626463688210300de82a9a7a52fd","subject":"Now builds again","message":"Now builds again\n\ne0c09b3b76e88124897f4592b7415ac62be9f05c broke the build by removing a bit\ntoo much\n\nrefs gh-15, gh-6\n","repos":"maximos\/maximus","old_file":"src\/impl\/install.bmx","new_file":"src\/impl\/install.bmx","new_contents":"\nRem\n\tbbdoc: Maximus 'install' argument implementation.\nEnd Rem\nType mxInstallImpl Extends dArgumentImplementation\n\t\n\tField m_instmap:dObjectMap\n\tField m_depcheckmap:dObjectMap\n\tField m_unmanagedmap:dObjectMap\n\tField m_nobuild:Int = False, m_nounpack:Int = False, m_keeptemp:Int = False\n\tField m_nothreaded:Int = False, m_makedocs:Int = False, m_forceinstall:Int = False\n\t\n\tMethod New()\n\t\tinit([\"install\"])\n\t\tm_instmap = New dObjectMap\n\t\tm_depcheckmap = New dObjectMap\n\t\tm_unmanagedmap = New dObjectMap\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Check the current arguments for errors (according to the specific implementation).\n\t\treturns: Nothing.\n\t\tabout: This method will throw an error if the arguments are invalid.\n\tEnd Rem\n\tMethod CheckArgs()\n\t\tIf GetArgumentCount() = 0\n\t\t\tThrowCommonError(mxCmdErrors.REQUIRESPARAMS, m_args.GetName())\n\t\tEnd If\n\t\tCheckOptions()\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get a string describing the typical usage of the argument.\n\t\treturns: A string describing the typical usage of the argument.\n\tEnd Rem\n\tMethod GetUsage:String()\n\t\tReturn _s(\"arg.install.usage\")\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Execute the implementation's operation.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod Execute()\n\t\tm_instmap.Clear()\n\t\tm_depcheckmap.Clear()\n\t\tm_unmanagedmap.Clear()\n\t\tIf mainapp.m_sourceshandler\n\t\t\tLocal nfounds:dObjectMap = New dObjectMap\n\t\t\tFor Local svar:dStringVariable = EachIn m_args\n\t\t\t\tLocal verid:String = svar.Get(), modid:String = mxModUtils.GetIDFromVerID(verid)\n\t\t\t\tLocal modul:mxModule = mainapp.m_sourceshandler.GetModuleWithID(modid)\n\t\t\t\tIf modul\n\t\t\t\t\tLocal instmod:mxInstModule = New mxInstModule.Create(verid, modul)\n\t\t\t\t\tIf instmod.SetVersionFromVerID(verid)\n\t\t\t\t\t\tm_instmap._Insert(modid, instmod)\n\t\t\t\t\tElse\n\t\t\t\t\t\tThrowError(_s(\"arg.install.notfound.version\", [modid, mxModUtils.GetVersionFromVerID(verid)]))\n\t\t\t\t\tEnd If\n\t\t\t\tElse\n\t\t\t\t\tnfounds._Insert(modid, modid)\n\t\t\t\tEnd If\n\t\t\tNext\n\t\t\tIf nfounds.Count() > 0\n\t\t\t\tlogger.LogError(_s(\"arg.install.notfound.instmods\"))\n\t\t\t\tLocal a:String\n\t\t\t\tFor Local b:String = EachIn nfounds.ValueEnumerator()\n\t\t\t\t\ta:+ b + \" \"\n\t\t\t\tNext\n\t\t\t\ta = a[..a.Length - 1]\n\t\t\t\tlogger.LogMessage(\"~t\" + a)\n\t\t\t\tReturn\n\t\t\tEnd If\n\t\t\tIf CheckDependencies()\n\t\t\t\t'Make sure we only install\/update managed modules\n\t\t\t\tIf CheckVersions()\n\t\t\t\t\tDoInstall()\n\t\t\t\tEnd If\n\t\t\tEnd If\n\t\tElse\n\t\t\tThrowError(_s(\"error.install.nosources\"))\n\t\tEnd If\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Check the options given to the command.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod CheckOptions()\n\t\tm_nobuild = False; m_nounpack = False; m_keeptemp = False\n\t\tm_nothreaded = False; m_makedocs = False\n\t\tFor Local opt:dIdentifier = EachIn m_args\n\t\t\tSelect opt.GetName().ToLower()\n\t\t\t\tCase \"-nobuild\" m_nobuild = True\n\t\t\t\tCase \"-nounpack\" m_nounpack = True\n\t\t\t\tCase \"-keeptemp\" m_keeptemp = True\n\t\t\t\tCase \"-nothreaded\" m_nothreaded = True\n\t\t\t\tCase \"-makedocs\" m_makedocs = True\n\t\t\t\tCase \"-force\" m_forceinstall = True\n\t\t\t\tDefault ThrowCommonError(mxOptErrors.UNKNOWN, opt.GetName())\n\t\t\tEnd Select\n\t\tNext\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Check for version conflictions and warn the user.\n\t\treturns: True if the installtion should continue, or False if the user halted the operation.\n\tEnd Rem\n\tMethod CheckVersions:Int()\n\t\tFor Local instmod:mxInstModule = EachIn m_instmap.ValueEnumerator()\n\t\t\tLocal ver:String = mxModUtils.GetInstalledVersionFromVerID(instmod.GetVerID())\n\t\t\t'Make sure we skip unmanaged modules\n\t\t\tIf ver = \"unmanaged\"\n\t\t\t\tm_instmap._Remove(instmod.GetID())\n\t\t\t\tm_unmanagedmap._Insert(instmod.GetID(), instmod)\n\t\t\tEnd If\n\t\tNext\n\t\tReturn True\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Check the dependencies for the modules to be installed.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod CheckDependencies:Int()\n\t\tLocal nfounds:dObjectMap = New dObjectMap\n\t\tFor Local instmod:mxInstModule = EachIn m_instmap.ValueEnumerator()\n\t\t\tCheckModuleDependencies(instmod, nfounds)\n\t\tNext\n\t\tIf nfounds.Count() > 0\n\t\t\tlogger.LogError(_s(\"arg.install.notfound.instdeps\"))\n\t\t\tLocal a:String\n\t\t\tFor Local b:String = EachIn nfounds.ValueEnumerator()\n\t\t\t\ta:+ b + \" \"\n\t\t\tNext\n\t\t\ta = a[..a.Length - 1]\n\t\t\tlogger.LogMessage(\"~t\" + a)\n\t\t\tIf m_forceinstall\n\t\t\t\tm_nobuild = True\n\t\t\t\tLocal resp:String = Input(_s(\"arg.install.missingdeps\") + \" \").ToLower()\n\t\t\t\tIf resp = \"y\" Or resp = \"yes\"\n\t\t\t\t\tReturn True\n\t\t\t\tEnd If\n\t\t\tEnd If\n\t\t\tReturn False\n\t\tEnd If\n\t\tReturn True\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Check the dependencies for the given module and adapt the install list accordingly.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod CheckModuleDependencies(instmod:mxInstModule, nfounds:dObjectMap)\n\t\tLocal addlist:TListEx = instmod.CheckCompliance()\n\t\tIf addlist\n\t\t\tFor Local modid:String = EachIn addlist\n\t\t\t\tIf Not m_depcheckmap._Contains(modid)\n\t\t\t\t\tLocal dmodul:mxModule = mainapp.m_sourceshandler.GetModuleWithID(modid)\n\t\t\t\t\tm_depcheckmap._Insert(modid, modid)\n\t\t\t\t\tIf dmodul\n\t\t\t\t\t\tIf Not m_instmap._Contains(modid)\n\t\t\t\t\t\t\tLocal dinstmod:mxInstModule = New mxInstModule.Create(modid, dmodul)\n\t\t\t\t\t\t\tIf instmod.GetVersionName().ToLower() = \"dev\"\n\t\t\t\t\t\t\t\tdinstmod.SetVersionFromName(\"dev\")\n\t\t\t\t\t\t\tElse\n\t\t\t\t\t\t\t\tdinstmod.SetVersion(Null)\n\t\t\t\t\t\t\tEnd If\n\t\t\t\t\t\t\tm_instmap._Insert(modid, dinstmod)\n\t\t\t\t\t\t\tCheckModuleDependencies(dinstmod, nfounds)\n\t\t\t\t\t\tEnd If\n\t\t\t\t\tElse\n\t\t\t\t\t\tnfounds._Insert(modid, modid)\n\t\t\t\t\tEnd If\n\t\t\t\tEnd If\n\t\t\tNext\n\t\tEnd If\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Do the actual installing.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod DoInstall()\n\t\tIf m_instmap.Count() > 0\n\t\t\tLocal a:String, instmod:mxInstModule\n\n\t\t\tIf m_unmanagedmap.Count()\n\t\t\t\tlogger.LogMessage(_s(\"arg.install.modulestoskip\"))\n\t\t\t\tFor instmod = EachIn m_unmanagedmap.ValueEnumerator()\n\t\t\t\t\ta:+instmod.GetVerID() + \" \"\n\t\t\t\tNext\n\t\t\t\ta = a[..a.Length - 1]\n\t\t\t\tlogger.LogMessage(\"~t\" + a)\n\t\t\t\ta = \"\"\n\t\t\tEnd If\n\n\t\t\tlogger.LogMessage(_s(\"arg.install.modulestoinstall\"))\n\t\t\tFor instmod = EachIn m_instmap.ValueEnumerator()\n\t\t\t\ta:+ instmod.GetVerID() + \" \"\n\t\t\tNext\n\t\t\ta = a[..a.Length - 1]\n\t\t\tlogger.LogMessage(\"~t\" + a)\n\t\t\tLocal resp:String = Input(_s(\"arg.install.continuewithinstall\") + \" \").ToLower()\n\t\t\tIf resp = \"y\" Or resp = \"yes\"\n\t\t\t\tFor instmod = EachIn m_instmap.ValueEnumerator()\n\t\t\t\t\tinstmod.FetchSourceArchive()\n\t\t\t\tNext\n\t\t\t\tIf Not m_nounpack\n\t\t\t\t\tFor instmod = EachIn m_instmap.ValueEnumerator()\n\t\t\t\t\t\tinstmod.Unpack()\n\t\t\t\t\tNext\n\t\t\t\tElse\n\t\t\t\t\tlogger.LogMessage(_s(\"message.skipping.unpack\"))\n\t\t\t\tEnd If\n\t\t\t\tIf Not m_keeptemp Then DeleteDir(\"tmp\/\", True)\n\t\t\t\tIf Not m_nobuild\n\t\t\t\t\tLocal scopes:dObjectMap = New dObjectMap\n\t\t\t\t\tFor instmod = EachIn m_instmap.ValueEnumerator()\n\t\t\t\t\t\tscopes._Insert(instmod.GetModuleScope(), instmod.GetModuleScope())\n\t\t\t\t\tNext\n\t\t\t\t\tFor Local scope:String = EachIn scopes.ValueEnumerator()\n\t\t\t\t\t\tIf mxBMKUtils.MakeMods(scope, m_nothreaded ~ 1) <> 0\n\t\t\t\t\t\t\tThrowError(_s(\"error.install.build\", [scope]))\n\t\t\t\t\t\tEnd If\n\t\t\t\t\tNext\n\t\t\t\t\tIf m_makedocs\n\t\t\t\t\t\t'For instmod = EachIn m_instmap.ValueEnumerator()\n\t\t\t\t\t\t'\tmxModUtils.DocMods(instmod.GetID())\n\t\t\t\t\t\t'Next\n\t\t\t\t\t\t' Can't build docs for individual modules yet\n\t\t\t\t\t\tmxModUtils.DocMods()\n\t\t\t\t\tEnd If\n\t\t\t\tElse\n\t\t\t\t\tlogger.LogMessage(_s(\"message.skipping.install\"))\n\t\t\t\tEnd If\n\t\t\tEnd If\n\t\tElse\n\t\t\tlogger.LogMessage(_s(\"arg.install.nomodulestoinstall\"))\n\t\t\tIf m_unmanagedmap.Count()\n\t\t\t\tlogger.LogMessage(_s(\"arg.install.modulestoskip\"))\n\t\t\t\tLocal a:String\n\t\t\t\tFor Local instmod:mxInstModule = EachIn m_unmanagedmap.ValueEnumerator()\n\t\t\t\t\ta:+instmod.GetVerID() + \" \"\n\t\t\t\tNext\n\t\t\t\ta = a[..a.Length - 1]\n\t\t\t\tlogger.LogMessage(\"~t\" + a)\n\t\t\tEnd If\n\t\tEnd If\n\tEnd Method\n\t\nEnd Type\n\nRem\n\tbbdoc: Maximus install info module.\n\tabout: This type is used for temporary install information on modules.\nEnd Rem\nType mxInstModule\n\t\n\tField m_id:String\n\tField m_version:mxModuleVersion\n\tField m_module:mxModule\n\t\n\tRem\n\t\tbbdoc: Create a new mxInstModule.\n\t\treturns: Itself.\n\tEnd Rem\n\tMethod Create:mxInstModule(verid:String, modul:mxModule)\n\t\tSetID(mxModUtils.GetIDFromVerID(verid))\n\t\tSetModule(modul)\n\t\tReturn Self\n\tEnd Method\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the modid to be installed.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetID(id:String)\n\t\tm_id = id\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the modid to be installed.\n\t\treturns: The modid to be installed.\n\tEnd Rem\n\tMethod GetID:String()\n\t\tReturn m_id\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the version from the given versioned-module name (e.g. \"foo.bar\/1.02\").\n\t\treturns: True if the version was set, or False if the version could not be found (was not found).\n\t\tabout: The latest version will be set if the given id is Null (or if it isn't versioned (e.g. \"foo.bar\", would result in the latest version being selected)).\n\tEnd Rem\n\tMethod SetVersionFromVerID:Int(verid:String)\n\t\tReturn SetVersionFromName(mxModUtils.GetVersionFromVerID(verid))\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the version to be installed from the given version name (e.g. \"1.02\").\n\t\treturns: True if the version was set, or False if the version could not be set (was not found).\n\t\tabout: The latest version will be set if the given name is Null.\n\tEnd Rem\n\tMethod SetVersionFromName:Int(name:String)\n\t\tIf Not name\n\t\t\tSetVersion(Null) ' Set the latest version (the version wasn't forced)\n\t\t\tReturn True\n\t\tElse\n\t\t\tLocal ver:mxModuleVersion = m_module.GetVersionWithName(name)\n\t\t\tIf ver\n\t\t\t\tSetVersion(ver)\n\t\t\t\tReturn True\n\t\t\tEnd If\n\t\tEnd If\n\t\tReturn False\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the install version.\n\t\treturns: Nothing.\n\t\tabout: If the given value is Null, it will be automatically set to the latest (non-development) version.\n\tEnd Rem\n\tMethod SetVersion(version:mxModuleVersion)\n\t\tm_version = version\n\t\tIf Not m_version\n\t\t\tm_version = m_module.GetLatestVersion()\n\t\tEnd If\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the install version.\n\t\treturns: The version to be installed.\n\tEnd Rem\n\tMethod GetVersion:mxModuleVersion()\n\t\tReturn m_version\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the module to be installed.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetModule(modul:mxModule)\n\t\tm_module = modul\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the module to be installed.\n\t\treturns: The module to be installed.\n\tEnd Rem\n\tMethod GetModule:mxModule()\n\t\tReturn m_module\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the module's scope.\n\t\treturns: The module's scope.\n\tEnd Rem\n\tMethod GetModuleScope:String()\n\t\tReturn mxModUtils.GetScopeFromID(m_id)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the module's name.\n\t\treturns: The module's name.\n\tEnd Rem\n\tMethod GetModuleName:String()\n\t\tReturn mxModUtils.GetNameFromID(m_id)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the versioned-module id.\n\t\treturns: The exact module to be installed (e.g. \"foo.bar\/1.02\").\n\tEnd Rem\n\tMethod GetVerID:String()\n\t\tReturn m_id + \"\/\" + m_version.GetName()\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the name of the version to be installed.\n\t\treturns: The name of the version to be installed.\n\tEnd Rem\n\tMethod GetVersionName:String()\n\t\tReturn m_version.GetName()\n\tEnd Method\n\t\n'#end region Field accessors\n\t\n\tRem\n\t\tbbdoc: Check the dependency compliance of the current module set.\n\t\treturns: Null if all dependencies are matched by existing modules, or a list of module ids that are not yet installed.\n\tEnd Rem\n\tMethod CheckCompliance:TListEx()\n\t\tReturn m_version.GetDependencies().CheckCompliance()\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Fetch the source archive for the version to be installed.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod FetchSourceArchive()\n\t\tm_version.FetchSourceArchive()\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Unpack the version's archive.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod Unpack()\n\t\tLocal archivepath:String = m_version.GetTemporaryFilePath()\n\t\tLocal zreader:ZipReader = New ZipReader\n\t\tlogger.LogMessage(_s(\"message.unpacking\", [archivepath]))\n\t\tIf zreader.OpenZip(archivepath)\n\t\t\tLocal filename:String, outputpath:String\n\t\t\tLocal basepath:String = mainapp.m_modpath + \"\/\" + mxModUtils.GetScopeFromID(m_id) + \".mod\/\"\n\t\t\tFor Local fileinfo:SZipFileEntry = EachIn zreader.m_zipFileList.FileList\n\t\t\t\tfilename = fileinfo.zipFileName\n\t\t\t\toutputpath = basepath + filename\n\t\t\t\t'DebugLog(\"Zip outputpath: ~q\" + outputpath + \"~q\")\n\t\t\t\tIf filename[filename.Length - 1] = 47 ' \"\/\"\n\t\t\t\t\tCreateDir(outputpath, True)\n\t\t\t\tElse\n\t\t\t\t\tIf CreateFileExplicitly(outputpath)\n\t\t\t\t\t\tzreader.ExtractFileToDisk(filename, outputpath, False)\n\t\t\t\t\tElse\n\t\t\t\t\t\tzreader.CloseZip()\n\t\t\t\t\t\tThrowError(_s(\"error.writeperms\", [outputpath]))\n\t\t\t\t\tEnd If\n\t\t\t\tEnd If\n\t\t\tNext\n\t\t\tzreader.CloseZip()\n\n\t\t\tLocal metafile:mxMetaFile = New mxMetaFile.Create(basepath + GetModuleName() + \".mod\/meta.maximus\")\n\t\t\tmetafile.SetMetaData(GetModuleScope(), GetModuleName(), GetVersionName())\n\t\t\tmetafile.Save()\n\t\tElse\n\t\t\tThrowError(_s(\"error.install.openarchive\", [archivepath]))\n\t\tEnd If\n\tEnd Method\n\t\nEnd Type\n\n","old_contents":"\nRem\n\tbbdoc: Maximus 'install' argument implementation.\nEnd Rem\nType mxInstallImpl Extends dArgumentImplementation\n\t\n\tField m_instmap:dObjectMap\n\tField m_depcheckmap:dObjectMap\n\tField m_unmanagedmap:dObjectMap\n\tField m_nobuild:Int = False, m_nounpack:Int = False, m_keeptemp:Int = False\n\tField m_nothreaded:Int = False, m_makedocs:Int = False, m_forceinstall:Int = False\n\t\n\tMethod New()\n\t\tinit([\"install\"])\n\t\tm_instmap = New dObjectMap\n\t\tm_depcheckmap = New dObjectMap\n\t\tm_unmanagedmap = New dObjectMap\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Check the current arguments for errors (according to the specific implementation).\n\t\treturns: Nothing.\n\t\tabout: This method will throw an error if the arguments are invalid.\n\tEnd Rem\n\tMethod CheckArgs()\n\t\tIf GetArgumentCount() = 0\n\t\t\tThrowCommonError(mxCmdErrors.REQUIRESPARAMS, m_args.GetName())\n\t\tEnd If\n\t\tCheckOptions()\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get a string describing the typical usage of the argument.\n\t\treturns: A string describing the typical usage of the argument.\n\tEnd Rem\n\tMethod GetUsage:String()\n\t\tReturn _s(\"arg.install.usage\")\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Execute the implementation's operation.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod Execute()\n\t\tm_instmap.Clear()\n\t\tm_depcheckmap.Clear()\n\t\tm_unmanagedmap.Clear()\n\t\tIf mainapp.m_sourceshandler\n\t\t\tLocal nfounds:dObjectMap = New dObjectMap\n\t\t\tFor Local svar:dStringVariable = EachIn m_args\n\t\t\t\tLocal verid:String = svar.Get(), modid:String = mxModUtils.GetIDFromVerID(verid)\n\t\t\t\tLocal modul:mxModule = mainapp.m_sourceshandler.GetModuleWithID(modid)\n\t\t\t\tIf modul\n\t\t\t\t\tLocal instmod:mxInstModule = New mxInstModule.Create(verid, modul)\n\t\t\t\t\tIf instmod.SetVersionFromVerID(verid)\n\t\t\t\t\t\tm_instmap._Insert(modid, instmod)\n\t\t\t\t\tElse\n\t\t\t\t\t\tThrowError(_s(\"arg.install.notfound.version\", [modid, mxModUtils.GetVersionFromVerID(verid)]))\n\t\t\t\t\tEnd If\n\t\t\t\tElse\n\t\t\t\t\tnfounds._Insert(modid, modid)\n\t\t\t\tEnd If\n\t\t\tNext\n\t\t\tIf nfounds.Count() > 0\n\t\t\t\tlogger.LogError(_s(\"arg.install.notfound.instmods\"))\n\t\t\t\tLocal a:String\n\t\t\t\tFor Local b:String = EachIn nfounds.ValueEnumerator()\n\t\t\t\t\ta:+ b + \" \"\n\t\t\t\tNext\n\t\t\t\ta = a[..a.Length - 1]\n\t\t\t\tlogger.LogMessage(\"~t\" + a)\n\t\t\t\tReturn\n\t\t\tEnd If\n\t\t\tIf CheckDependencies()\n\t\t\t\t'Make sure we only install\/update managed modules\n\t\t\t\tIf CheckVersions()\n\t\t\t\t\tDoInstall()\n\t\t\t\tEnd If\n\t\t\tEnd If\n\t\tElse\n\t\t\tThrowError(_s(\"error.install.nosources\"))\n\t\tEnd If\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Check the options given to the command.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod CheckOptions()\n\t\tm_nobuild = False; m_nounpack = False; m_keeptemp = False\n\t\tm_nothreaded = False; m_makedocs = False\n\t\tFor Local opt:dIdentifier = EachIn m_args\n\t\t\tSelect opt.GetName().ToLower()\n\t\t\t\tCase \"-nobuild\" m_nobuild = True\n\t\t\t\tCase \"-nounpack\" m_nounpack = True\n\t\t\t\tCase \"-keeptemp\" m_keeptemp = True\n\t\t\t\tCase \"-nothreaded\" m_nothreaded = True\n\t\t\t\tCase \"-makedocs\" m_makedocs = True\n\t\t\t\tCase \"-force\" m_forceinstall = True\n\t\t\t\tDefault ThrowCommonError(mxOptErrors.UNKNOWN, opt.GetName())\n\t\t\tEnd Select\n\t\tNext\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Check for version conflictions and warn the user.\n\t\treturns: True if the installtion should continue, or False if the user halted the operation.\n\tEnd Rem\n\tMethod CheckVersions:Int()\n\t\tFor Local instmod:mxInstModule = EachIn m_instmap.ValueEnumerator()\n\t\t\tLocal ver:String = mxModUtils.GetInstalledVersionFromVerID(instmod.GetVerID())\n\t\t\t'Make sure we skip unmanaged modules\n\t\t\tIf ver = \"unmanaged\"\n\t\t\t\tm_instmap._Remove(instmod.GetID())\n\t\t\t\tm_unmanagedmap._Insert(instmod.GetID(), instmod)\n\t\t\tEnd If\n\t\tNext\n\t\tReturn True\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Check the dependencies for the modules to be installed.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod CheckDependencies:Int()\n\t\tFor Local instmod:mxInstModule = EachIn m_instmap.ValueEnumerator()\n\t\t\tCheckModuleDependencies(instmod, nfounds)\n\t\tNext\n\t\tIf nfounds.Count() > 0\n\t\t\tlogger.LogError(_s(\"arg.install.notfound.instdeps\"))\n\t\t\tLocal a:String\n\t\t\tFor Local b:String = EachIn nfounds.ValueEnumerator()\n\t\t\t\ta:+ b + \" \"\n\t\t\tNext\n\t\t\ta = a[..a.Length - 1]\n\t\t\tlogger.LogMessage(\"~t\" + a)\n\t\t\tIf m_forceinstall\n\t\t\t\tm_nobuild = True\n\t\t\t\tLocal resp:String = Input(_s(\"arg.install.missingdeps\") + \" \").ToLower()\n\t\t\t\tIf resp = \"y\" Or resp = \"yes\"\n\t\t\t\t\tReturn True\n\t\t\t\tEnd If\n\t\t\tEnd If\n\t\t\tReturn False\n\t\tEnd If\n\t\tReturn True\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Check the dependencies for the given module and adapt the install list accordingly.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod CheckModuleDependencies(instmod:mxInstModule, nfounds:dObjectMap)\n\t\tLocal addlist:TListEx = instmod.CheckCompliance()\n\t\tIf addlist\n\t\t\tFor Local modid:String = EachIn addlist\n\t\t\t\tIf Not m_depcheckmap._Contains(modid)\n\t\t\t\t\tLocal dmodul:mxModule = mainapp.m_sourceshandler.GetModuleWithID(modid)\n\t\t\t\t\tm_depcheckmap._Insert(modid, modid)\n\t\t\t\t\tIf dmodul\n\t\t\t\t\t\tIf Not m_instmap._Contains(modid)\n\t\t\t\t\t\t\tLocal dinstmod:mxInstModule = New mxInstModule.Create(modid, dmodul)\n\t\t\t\t\t\t\tIf instmod.GetVersionName().ToLower() = \"dev\"\n\t\t\t\t\t\t\t\tdinstmod.SetVersionFromName(\"dev\")\n\t\t\t\t\t\t\tElse\n\t\t\t\t\t\t\t\tdinstmod.SetVersion(Null)\n\t\t\t\t\t\t\tEnd If\n\t\t\t\t\t\t\tm_instmap._Insert(modid, dinstmod)\n\t\t\t\t\t\t\tCheckModuleDependencies(dinstmod, nfounds)\n\t\t\t\t\t\tEnd If\n\t\t\t\t\tElse\n\t\t\t\t\t\tnfounds._Insert(modid, modid)\n\t\t\t\t\tEnd If\n\t\t\t\tEnd If\n\t\t\tNext\n\t\tEnd If\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Do the actual installing.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod DoInstall()\n\t\tIf m_instmap.Count() > 0\n\t\t\tLocal a:String, instmod:mxInstModule\n\n\t\t\tIf m_unmanagedmap.Count()\n\t\t\t\tlogger.LogMessage(_s(\"arg.install.modulestoskip\"))\n\t\t\t\tFor instmod = EachIn m_unmanagedmap.ValueEnumerator()\n\t\t\t\t\ta:+instmod.GetVerID() + \" \"\n\t\t\t\tNext\n\t\t\t\ta = a[..a.Length - 1]\n\t\t\t\tlogger.LogMessage(\"~t\" + a)\n\t\t\t\ta = \"\"\n\t\t\tEnd If\n\n\t\t\tlogger.LogMessage(_s(\"arg.install.modulestoinstall\"))\n\t\t\tFor instmod = EachIn m_instmap.ValueEnumerator()\n\t\t\t\ta:+ instmod.GetVerID() + \" \"\n\t\t\tNext\n\t\t\ta = a[..a.Length - 1]\n\t\t\tlogger.LogMessage(\"~t\" + a)\n\t\t\tLocal resp:String = Input(_s(\"arg.install.continuewithinstall\") + \" \").ToLower()\n\t\t\tIf resp = \"y\" Or resp = \"yes\"\n\t\t\t\tFor instmod = EachIn m_instmap.ValueEnumerator()\n\t\t\t\t\tinstmod.FetchSourceArchive()\n\t\t\t\tNext\n\t\t\t\tIf Not m_nounpack\n\t\t\t\t\tFor instmod = EachIn m_instmap.ValueEnumerator()\n\t\t\t\t\t\tinstmod.Unpack()\n\t\t\t\t\tNext\n\t\t\t\tElse\n\t\t\t\t\tlogger.LogMessage(_s(\"message.skipping.unpack\"))\n\t\t\t\tEnd If\n\t\t\t\tIf Not m_keeptemp Then DeleteDir(\"tmp\/\", True)\n\t\t\t\tIf Not m_nobuild\n\t\t\t\t\tLocal scopes:dObjectMap = New dObjectMap\n\t\t\t\t\tFor instmod = EachIn m_instmap.ValueEnumerator()\n\t\t\t\t\t\tscopes._Insert(instmod.GetModuleScope(), instmod.GetModuleScope())\n\t\t\t\t\tNext\n\t\t\t\t\tFor Local scope:String = EachIn scopes.ValueEnumerator()\n\t\t\t\t\t\tIf mxBMKUtils.MakeMods(scope, m_nothreaded ~ 1) <> 0\n\t\t\t\t\t\t\tThrowError(_s(\"error.install.build\", [scope]))\n\t\t\t\t\t\tEnd If\n\t\t\t\t\tNext\n\t\t\t\t\tIf m_makedocs\n\t\t\t\t\t\t'For instmod = EachIn m_instmap.ValueEnumerator()\n\t\t\t\t\t\t'\tmxModUtils.DocMods(instmod.GetID())\n\t\t\t\t\t\t'Next\n\t\t\t\t\t\t' Can't build docs for individual modules yet\n\t\t\t\t\t\tmxModUtils.DocMods()\n\t\t\t\t\tEnd If\n\t\t\t\tElse\n\t\t\t\t\tlogger.LogMessage(_s(\"message.skipping.install\"))\n\t\t\t\tEnd If\n\t\t\tEnd If\n\t\tElse\n\t\t\tlogger.LogMessage(_s(\"arg.install.nomodulestoinstall\"))\n\t\t\tIf m_unmanagedmap.Count()\n\t\t\t\tlogger.LogMessage(_s(\"arg.install.modulestoskip\"))\n\t\t\t\tLocal a:String\n\t\t\t\tFor Local instmod:mxInstModule = EachIn m_unmanagedmap.ValueEnumerator()\n\t\t\t\t\ta:+instmod.GetVerID() + \" \"\n\t\t\t\tNext\n\t\t\t\ta = a[..a.Length - 1]\n\t\t\t\tlogger.LogMessage(\"~t\" + a)\n\t\t\tEnd If\n\t\tEnd If\n\tEnd Method\n\t\nEnd Type\n\nRem\n\tbbdoc: Maximus install info module.\n\tabout: This type is used for temporary install information on modules.\nEnd Rem\nType mxInstModule\n\t\n\tField m_id:String\n\tField m_version:mxModuleVersion\n\tField m_module:mxModule\n\t\n\tRem\n\t\tbbdoc: Create a new mxInstModule.\n\t\treturns: Itself.\n\tEnd Rem\n\tMethod Create:mxInstModule(verid:String, modul:mxModule)\n\t\tSetID(mxModUtils.GetIDFromVerID(verid))\n\t\tSetModule(modul)\n\t\tReturn Self\n\tEnd Method\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the modid to be installed.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetID(id:String)\n\t\tm_id = id\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the modid to be installed.\n\t\treturns: The modid to be installed.\n\tEnd Rem\n\tMethod GetID:String()\n\t\tReturn m_id\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the version from the given versioned-module name (e.g. \"foo.bar\/1.02\").\n\t\treturns: True if the version was set, or False if the version could not be found (was not found).\n\t\tabout: The latest version will be set if the given id is Null (or if it isn't versioned (e.g. \"foo.bar\", would result in the latest version being selected)).\n\tEnd Rem\n\tMethod SetVersionFromVerID:Int(verid:String)\n\t\tReturn SetVersionFromName(mxModUtils.GetVersionFromVerID(verid))\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the version to be installed from the given version name (e.g. \"1.02\").\n\t\treturns: True if the version was set, or False if the version could not be set (was not found).\n\t\tabout: The latest version will be set if the given name is Null.\n\tEnd Rem\n\tMethod SetVersionFromName:Int(name:String)\n\t\tIf Not name\n\t\t\tSetVersion(Null) ' Set the latest version (the version wasn't forced)\n\t\t\tReturn True\n\t\tElse\n\t\t\tLocal ver:mxModuleVersion = m_module.GetVersionWithName(name)\n\t\t\tIf ver\n\t\t\t\tSetVersion(ver)\n\t\t\t\tReturn True\n\t\t\tEnd If\n\t\tEnd If\n\t\tReturn False\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the install version.\n\t\treturns: Nothing.\n\t\tabout: If the given value is Null, it will be automatically set to the latest (non-development) version.\n\tEnd Rem\n\tMethod SetVersion(version:mxModuleVersion)\n\t\tm_version = version\n\t\tIf Not m_version\n\t\t\tm_version = m_module.GetLatestVersion()\n\t\tEnd If\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the install version.\n\t\treturns: The version to be installed.\n\tEnd Rem\n\tMethod GetVersion:mxModuleVersion()\n\t\tReturn m_version\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the module to be installed.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetModule(modul:mxModule)\n\t\tm_module = modul\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the module to be installed.\n\t\treturns: The module to be installed.\n\tEnd Rem\n\tMethod GetModule:mxModule()\n\t\tReturn m_module\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the module's scope.\n\t\treturns: The module's scope.\n\tEnd Rem\n\tMethod GetModuleScope:String()\n\t\tReturn mxModUtils.GetScopeFromID(m_id)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the module's name.\n\t\treturns: The module's name.\n\tEnd Rem\n\tMethod GetModuleName:String()\n\t\tReturn mxModUtils.GetNameFromID(m_id)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the versioned-module id.\n\t\treturns: The exact module to be installed (e.g. \"foo.bar\/1.02\").\n\tEnd Rem\n\tMethod GetVerID:String()\n\t\tReturn m_id + \"\/\" + m_version.GetName()\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the name of the version to be installed.\n\t\treturns: The name of the version to be installed.\n\tEnd Rem\n\tMethod GetVersionName:String()\n\t\tReturn m_version.GetName()\n\tEnd Method\n\t\n'#end region Field accessors\n\t\n\tRem\n\t\tbbdoc: Check the dependency compliance of the current module set.\n\t\treturns: Null if all dependencies are matched by existing modules, or a list of module ids that are not yet installed.\n\tEnd Rem\n\tMethod CheckCompliance:TListEx()\n\t\tReturn m_version.GetDependencies().CheckCompliance()\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Fetch the source archive for the version to be installed.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod FetchSourceArchive()\n\t\tm_version.FetchSourceArchive()\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Unpack the version's archive.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod Unpack()\n\t\tLocal archivepath:String = m_version.GetTemporaryFilePath()\n\t\tLocal zreader:ZipReader = New ZipReader\n\t\tlogger.LogMessage(_s(\"message.unpacking\", [archivepath]))\n\t\tIf zreader.OpenZip(archivepath)\n\t\t\tLocal filename:String, outputpath:String\n\t\t\tLocal basepath:String = mainapp.m_modpath + \"\/\" + mxModUtils.GetScopeFromID(m_id) + \".mod\/\"\n\t\t\tFor Local fileinfo:SZipFileEntry = EachIn zreader.m_zipFileList.FileList\n\t\t\t\tfilename = fileinfo.zipFileName\n\t\t\t\toutputpath = basepath + filename\n\t\t\t\t'DebugLog(\"Zip outputpath: ~q\" + outputpath + \"~q\")\n\t\t\t\tIf filename[filename.Length - 1] = 47 ' \"\/\"\n\t\t\t\t\tCreateDir(outputpath, True)\n\t\t\t\tElse\n\t\t\t\t\tIf CreateFileExplicitly(outputpath)\n\t\t\t\t\t\tzreader.ExtractFileToDisk(filename, outputpath, False)\n\t\t\t\t\tElse\n\t\t\t\t\t\tzreader.CloseZip()\n\t\t\t\t\t\tThrowError(_s(\"error.writeperms\", [outputpath]))\n\t\t\t\t\tEnd If\n\t\t\t\tEnd If\n\t\t\tNext\n\t\t\tzreader.CloseZip()\n\n\t\t\tLocal metafile:mxMetaFile = New mxMetaFile.Create(basepath + GetModuleName() + \".mod\/meta.maximus\")\n\t\t\tmetafile.SetMetaData(GetModuleScope(), GetModuleName(), GetVersionName())\n\t\t\tmetafile.Save()\n\t\tElse\n\t\t\tThrowError(_s(\"error.install.openarchive\", [archivepath]))\n\t\tEnd If\n\tEnd Method\n\t\nEnd Type\n\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"1d01b092c02d94e16e3665bcbe9514457897bbe8","subject":"*TABSI stricter with replaced ip","message":"*TABSI stricter with replaced ip\n","repos":"Leushenko\/blue-moon","old_file":"bluefoldcodegen.bmx","new_file":"bluefoldcodegen.bmx","new_contents":"\n' Blue Moon\n' FOLD delegate to generate assembly instructions\n\n' this file is a Private Include\n\n'SuperStrict\n\n\nType CompileFold\n\tField opc:BlueOpcode = New BlueOpcode, bi:BlueInstr = New BlueInstr, f:BlueAssembly, _gq:TList = CreateList()\n\t\n\tFunction Make:CompileFold(f:BlueAssembly)\n\t\tLocal c:CompileFold = New Self ; c.f = f ; Return c\n\tEnd Function\n\t\n\tMethod l_varref:Node(n:Leaf)\n\t\tLocal v:VarDef = f.fd.vars[StrToNum(n.val)], op:Int\n\t\tIf v.isClosure Then op = opc.SETLC Else op = opc.MOV\n\t\tReturn BytecodeNode.MakeL(n.key, bi.Make(op, v.stkpos, f.Pop()), n)\n\tEnd Method\n\tMethod l_closref:Node(n:Leaf)\n\t\tLocal ref:Int = StrToNum(n.val)\n\t\tReturn BytecodeNode.MakeL(n.key, bi.Make(opc.SETUPV, ref, f.Pop()))\n\tEnd Method\n\tMethod l_getfield:Node(n:Rose)\n\t\tLocal r:BytecodeNode = BytecodeNode.Join(n.key, [n.arg[0]])\n\t\tLocal k:Int = f.GetConst(\"1\", Leaf(n.arg[1]).val), tab:Int = f.Pop()\n\t\tr.inst.AddLast bi.Make(opc.SETTAB, tab, f.Pop(), k)\n\t\tReturn r\n\tEnd Method\n\tMethod l_index:Node(n:Rose)\n\t\tLocal r:BytecodeNode = BytecodeNode.Join(n.key, n.arg)\n\t\tLocal ind:Int = f.Pop(), tab:Int = f.Pop(), val:Int = f.Pop()\n\t\tLocal pv:BlueInstr = BlueInstr(r.inst.Last())\n\t\tIf pv.op = opc.LOADSI And Abs(pv.c) < f.VSI_LIMIT And pv.c = Abs pv.c\n\t\t\tpv.op = opc.SETTABSI ; pv.ra = tab ; pv.rb = val\n\t\tElse\n\t\t\tr.inst.AddLast bi.Make(opc.SETTABI, tab, val, ind)\n\t\tEndIf\n\t\tReturn r\n\tEnd Method\n\tMethod l_discard:Node(n:Node)\n\t\tf.Pop() ; Return BytecodeNode.Nil()\n\tEnd Method\n\t\n\tMethod LocalVar:Node(n:Rose)\n\t\tLocal vars:Node[] = Rose(BytecodeNode(n.arg[1]).old).arg\n\t\tLocal r:BytecodeNode = BytecodeNode.Join(n.key, n.arg)\n\t\tFor Local vi:Int = vars.Length - 1 To 0 Step -1\n\t\t\tLocal v:VarDef = f.fd.vars[StrToNum(Leaf(BytecodeNode(vars[vi]).old).val)]\n\t\t\tIf v.isClosure Then r.inst.AddFirst bi.Make(opc.NEWUPV, v.stkpos, 0)\n\t\tNext\n\t\tReturn r\n\tEnd Method\n\t\n\tMethod ReturnS:Node(n:Rose)\n\t\tLocal r:BytecodeNode = BytecodeNode.Join(n.key, n.arg)\n\t\tr.inst.AddLast(bi.MakeK(opc.RET, f.Peek(), n.arg.Length))\n\t\tf.Pop(n.arg.Length) ; Return r\n\tEnd Method\n\tMethod return_va:Node(n:Node)\n\t\tReturn BytecodeNode.MakeL(n.key, bi.Make(opc.RETVA, 0, 0))\n\tEnd Method\n\t\n\tMethod break:Node(n:Node)\n\t\tReturn BytecodeNode.MakeL(n.key, bi.Make(opc.JMP, -1, -1, -1))\n\tEnd Method\n\tMethod RepeatS:Node(n:Rose)\n\t\tLocal r:BytecodeNode = BytecodeNode.Join(n.key, n.arg), _lt:TList = f.fd._lt, _gt:TList = f.fd._gt\n\t\tLocal loopStart:LabelDef = New LabelDef, lsID:Int = _lt.Count(), loop:GotoDef = New GotoDef, lID:Int = _gt.Count()\n\t\tloop.tgt = loopStart ; _lt.AddLast loopStart ; _gt.AddLast loop\n\t\tLocal lastop:BlueInstr = BlueInstr(r.inst.Last()), reg:Int = f.Pop()\n\t\tIf lastop.op = opc.LNOT\n\t\t\tlastop.op = opc.JIF ; lastop.ra = lastop.rb ; lastop.rb = 0 ; lastop.c = lID\t'replace NOT with inverted jump\n\t\tElse\n\t\t\tr.inst.AddLast bi.MakeK(opc.JNOT, reg, lID)\n\t\tEndIf\n\t\tr.inst.AddFirst bi.Make(opc.MOV, 0, 0, lsID)\n\t\tr.inst.AddLast bi.Make(opc.MOV, -1, -1, -1)\n\t\tReturn r\n\tEnd Method\n\tMethod IfS:Node(n:Rose) { WhileS }\n\t\tLocal r:BytecodeNode = BytecodeNode.Join(n.key, [n.arg[0]]), lastop:BlueInstr = BlueInstr(r.inst.Last())\n\t\tLocal before:LabelDef, befID:Int, loopRound:GotoDef, loopID:Int, _lt:TList = f.fd._lt, _gt:TList = f.fd._gt\n\t\tIf n.key = \"WhileS\"\n\t\t\tbefore = New LabelDef ; befID = _lt.Count() ; _lt.AddLast before\n\t\t\tloopRound = New GotoDef ;loopRound.tgt = before ; loopID = _gt.Count() ; _gt.AddLast loopRound\n\t\t\tr.inst.AddFirst bi.Make(opc.MOV, 0, 0, befID)\n\t\tEndIf\n\t\tLocal postThen:LabelDef = New LabelDef, skipThen:GotoDef = New GotoDef, ptID:Int = _lt.Count(), stID:Int = _gt.Count()\n\t\t_lt.AddLast postThen ; skipThen.tgt = postThen ; _gt.AddLast skipThen\n\t\tIf lastop.op = opc.LNOT\n\t\t\tlastop.op = opc.JIF ; lastop.ra = lastop.rb ; lastop.rb = 0 ; lastop.c = stID\t'replace NOT with inverted jump\n\t\tElse\n\t\t\tr.inst.AddLast bi.MakeK(opc.JNOT, f.Peek(), stID)\n\t\tEndIf\n\t\tf.Pop()\n\t\tFor Local op:BlueInstr = EachIn BytecodeNode(n.arg[1]).inst\n\t\t\tr.inst.AddLast op\n\t\tNext\n\t\tLocal postElse:LabelDef, skipElse:GotoDef\n\t\tIf n.arg.Length > 2\t'there's an else\n\t\t\tpostElse = New LabelDef ; skipElse = New GotoDef ; skipElse.tgt = postElse\n\t\t\tLocal peID:Int = _lt.Count(), seID:Int = _gt.Count()\n\t\t\t_lt.AddLast postElse ; _gt.AddLast skipElse\n\t\t\tr.inst.AddLast bi.MakeK(opc.JMP, 0, seID)\n\t\t\tr.inst.AddLast bi.Make(opc.MOV, 0, 0, ptID)\n\t\t\tFor Local op:BlueInstr = EachIn BytecodeNode(n.arg[2]).inst\n\t\t\t\tr.inst.AddLast op\n\t\t\tNext\n\t\t\tr.inst.AddLast bi.Make(opc.MOV, 0, 0, peID)\n\t\tElse\n\t\t\tIf n.key = \"WhileS\" Then r.inst.AddLast bi.MakeK(opc.JMP, 0, loopID) ; r.inst.AddLast bi.Make(opc.MOV, -1, -1, -1)\n\t\t\tr.inst.AddLast bi.Make(opc.MOV, 0, 0, ptID)\n\t\tEndIf\n\t\tReturn r\n\tEnd Method\n\tMethod kand:Node(n:Rose) { kor }\n\t\tLocal r:BytecodeNode = BytecodeNode.Join(n.key, [n.arg[0]]), lastop:BlueInstr = BlueInstr(r.inst.Last())\n\t\tLocal _lt:TList = f.fd._lt, _gt:TList = f.fd._gt\n\t\tLocal postR:LabelDef = New LabelDef, skipR:GotoDef = New GotoDef, prID:Int = _lt.Count(), srID:Int = _gt.Count()\n\t\t_lt.AddLast postR ; skipR.tgt = postR ; _gt.AddLast skipR\n\t\tLocal reg:Int = f.Pop()\n\t\tIf lastop.op = opc.LNOT\n\t\t\tLocal op:Int = opc.JIF ; If n.key = \"kor\" Then op = opc.JNOT\n\t\t\tlastop.op = op ; lastop.ra = lastop.rb ; lastop.rb = 0 ; lastop.c = srID\t'replace NOT with inverted jump\n\t\tElse\n\t\t\tLocal op:Int = opc.JNOT ; If n.key = \"kor\" Then op = opc.JIF\n\t\t\tr.inst.AddLast bi.MakeK(op, reg - 1, srID)\n\t\tEndIf\n\t\tFor Local op:BlueInstr = EachIn BytecodeNode(n.arg[1]).inst\n\t\t\tr.inst.AddLast op\n\t\tNext\n\t\tr.inst.AddLast bi.Make(opc.MOV, reg - 1, reg)\n\t\tr.inst.AddLast bi.Make(opc.MOV, 0, 0, prID)\n\t\tReturn r\n\tEnd Method\n\t\n\tMethod fcall:Node(n:Rose) { pfcall tfcall va_fcall }\t'\"p\" prefix = \"procedure\" i.e. no return value required\n\t\tLocal r:BytecodeNode = BytecodeNode.Join(n.key, n.arg), argc:Int = Int(Leaf(n.arg[3]).val), retc:Int = Int(Leaf(n.arg[2]).val)\n\t\tLocal func:Int = f.Pop(argc + 1), args:Int = func + 1, op:Int = opc.CALL\n\t\tIf n.key = \"tfcall\" Then op = opc.TCALL\n\t\tr.inst.AddLast bi.Make(op, func, args, argc)\n\t\tIf n.key = \"fcall\"\n\t\t\tr.inst.AddLast bi.MakeK(opc.POSTCALL, f.Peek() + 1, retc) ; f.Push(retc)\n\t\tElseIf n.key = \"va_fcall\"\n\t\t\tr.inst.AddLast bi.Make(opc.CALLINIT, -1, 0)\n\t\tEndIf\n\t\tReturn r\n\tEnd Method\n\tMethod mcall:Node(n:Rose) { pmcall tmcall va_mcall }\n\t\tLocal r:BytecodeNode = BytecodeNode.Join(n.key, n.arg), argc:Int = Int(Leaf(n.arg[3]).val), retc:Int = Int(Leaf(n.arg[2]).val)\n\t\tLocal func:Int = f.Push(), argv:Int = f.Pop(argc + 2), op:Int = opc.CALL\n\t\tLocal ks:String = Leaf(Rose(BytecodeNode(n.arg[1]).old).arg[0]).val\t\t'yeesh\n\t\tr.inst.AddLast bi.Make(opc.GETTAB, func, argv, f.GetConst(\"1\", ks))\n\t\tIf n.key = \"tmcall\" Then op = opc.TCALL\n\t\tr.inst.AddLast bi.Make(op, func, argv, argc + 1)\n\t\tIf n.key = \"mcall\"\n\t\t\tr.inst.AddLast bi.MakeK(opc.POSTCALL, argv, retc) ; f.Push(retc)\n\t\tElseIf n.key = \"va_fcall\"\n\t\t\tr.inst.AddLast bi.Make(opc.CALLINIT, -1, 0)\n\t\tEndIf\n\t\tReturn r\n\tEnd Method\n\tMethod dotdotdot:Node(n:Leaf)\n\t\tLocal retc:Int = Int(n.val), r:BytecodeNode\n\t\tr = BytecodeNode.MakeL(n.key, bi.MakeK(opc.VARARG, f.Peek() + 1, retc))\n\t\tf.Push(retc)\n\t\tReturn r\n\tEnd Method\n\t\n\tMethod BinaryOp:Node(n:Rose) { plus minus mul div kmod pow dotdot lt gt leq geq eq neq }\n\t\tLocal r:BytecodeNode = BytecodeNode.Join(n.key, n.arg), op:Int\n\t\tSelect n.key\n\t\t\tCase \"plus\" ; op = opc.ADD\n\t\t\tCase \"minus\" ; op = opc.SUB\n\t\t\tCase \"mul\" ; op = opc.MUL\n\t\t\tCase \"div\" ; op = opc.DIV\n\t\t\tCase \"kmod\" ; op = opc.NMOD\n\t\t\tCase \"pow\" ; op = opc.POW\n\t\t\tCase \"dotdot\" ; op = opc.CAT\n\t\t\t\n\t\t\tCase \"lt\" ; op = opc.LT\n\t\t\tCase \"gt\" ; op = opc.LEQ\n\t\t\tCase \"leq\" ; op = opc.LEQ\n\t\t\tCase \"geq\" ; op = opc.LT\n\t\t\tCase \"eq\" ; op = opc.EQ\n\t\t\tCase \"neq\" ; op = opc.EQ\n\t\tEnd Select\n\t\tLocal lop:Int = f.Pop(), rop:Int = f.Pop()\n\t\tIf n.key = \"geq\" Or n.key = \"gt\"\n\t\t\tr.inst.AddLast bi.Make(op, f.Push(), rop, lop)\t'technically this violates IEEE-754, but it's how Lua defines it\n\t\tElse\n\t\t\tr.inst.AddLast bi.Make(op, f.Push(), lop, rop)\n\t\t\tIf n.key = \"neq\" Then r.inst.AddLast bi.Make(opc.LNOT, f.Peek(), f.Peek())\n\t\tEndIf\n\t\tReturn r\n\tEnd Method\n\tMethod UnaryOp:Node(n:Rose) { negate klen knot }\n\t\tLocal r:BytecodeNode = BytecodeNode.Join(n.key, n.arg), op:Int\n\t\tSelect n.key\n\t\t\tCase \"negate\" ; op = opc.UNM\n\t\t\tCase \"klen\" ; op = opc.ALEN\n\t\t\tCase \"knot\" ; op = opc.LNOT\n\t\t\tCase \"posate\" ; op = opc.UNP\n\t\tEnd Select\n\t\tLocal arg:Int = f.Pop()\n\t\tr.inst.AddLast bi.Make(op, f.Push(), arg)\n\t\tReturn r\n\tEnd Method\n\t\n\tMethod dconst:Node(n:Leaf) { sconst }\n\t\tLocal ki:Int = Int(n.val), op:Int = opc.LOADK\n\t\tIf n.key = \"dconst\" And Abs(ki) < BlueAssembly.SI_LIMIT And Double(n.val) = Double(ki)\n\t\t\top = opc.LOADSI\n\t\tElse\n\t\t\tki = f.GetConst(String(n.key = \"sconst\"), n.val)\n\t\tEndIf\n\t\tReturn BytecodeNode.MakeL(n.key, bi.MakeK(op, f.Push(), ki))\n\tEnd Method\n\tMethod bconst:Node(n:Leaf) { nil }\n\t\tLocal ins:BlueInstr\n\t\tSelect n.val\n\t\t\tCase \"true\" ; ins = bi.MakeK(opc.LOADBOOL, f.Push(), 1)\n\t\t\tCase \"false\" ; ins = bi.MakeK(opc.LOADBOOL, f.Push(), 0)\n\t\t\tCase \"nil\" ; ins = bi.MakeK(opc.LOADNIL, f.Push(), 0)\n\t\tEnd Select\n\t\tReturn BytecodeNode.MakeL(n.key, ins)\n\tEnd Method\n\t\n\tMethod funref:Node(n:Leaf) { varref closref }\n\t\tLocal i:BlueInstr, ref:Int = StrToNum(n.val)\n\t\tSelect n.key\n\t\t\tCase \"funref\" ; i = bi.MakeK(opc.CLOSURE, f.Push(), ref)\n\t\t\tCase \"varref\"\n\t\t\t\tLocal v:VarDef = f.fd.vars[ref], op:Int = opc.MOV ; If v.isClosure Then op = opc.GETLC\n\t\t\t\ti = bi.Make(op, f.Push(), v.stkpos)\n\t\t\tCase \"closref\" ; i = bi.Make(opc.GETUPV, f.Push(), ref)' + f.fd.vmax)\n\t\tEnd Select\n\t\tReturn BytecodeNode.MakeL(n.key, i)\n\tEnd Method\n\tMethod getfield:Node(n:Rose) { index }\n\t\tLocal r:BytecodeNode = BytecodeNode.Join(n.key, n.arg), i:BlueInstr\n\t\tIf n.key = \"getfield\"\n\t\t\tLocal k:Int = f.GetConst(\"1\", Leaf(n.arg[1]).val), tab:Int = f.Pop()\n\t\t\tr.inst.AddLast bi.Make(opc.GETTAB, f.Push(), tab, k)\n\t\tElse\n\t\t\tLocal idx:Int = f.Pop(), tab:Int = f.Pop()\n\t\t\tLocal pv:BlueInstr = BlueInstr(r.inst.Last())\n\t\t\tIf pv.op = opc.LOADSI And Abs(pv.c) < f.VSI_LIMIT And pv.c = Abs pv.c\n\t\t\t\tpv.op = opc.GETTABSI ; pv.ra = f.Push() ; pv.rb = tab\n\t\t\tElse\n\t\t\t\tr.inst.AddLast bi.Make(opc.GETTABI, f.Push(), tab, idx)\n\t\t\tEndIf\n\t\tEndIf\n\t\tReturn r\n\tEnd Method\n\t\n\tMethod TableCons:Node(n:Rose)\n\t\tLocal r:BytecodeNode = BytecodeNode.Join(n.key, n.arg), fld:BytecodeNode = Null\n\t\tLocal rslot:Int = f.Push(), tslot:Int = f.vars '+ f.upvars\n\t\tFor fld = EachIn n.arg\t'work out where it's safe to put the table\n\t\t\tFor Local in:BlueInstr = EachIn fld.inst\n\t\t\t\tIf in.ra >= tslot Then tslot = in.ra + 1\n\t\t\tNext\n\t\tNext\n\t\tFor fld = EachIn n.arg\t'then patch the operations to point there\n\t\t\tFor Local in:BlueInstr = EachIn fld.inst\n\t\t\t\tIf in.ra = -1 And (in.op = opc.SETTAB Or in.op = opc.SETTABI ..\n\t\t\t\t\tOr in.op = opc.VAINIT Or in.op = opc.CALLINIT) Then in.ra = tslot\n\t\t\tNext\n\t\tNext\n\t\tIf n.arg\t'pass the ongoing index count to the variable initializer\n\t\t\tfld = BytecodeNode(n.arg[n.arg.Length - 2])\n\t\t\tIf fld.key = \"va_fcall\" Or fld.key = \"va_init\"\n\t\t\t\tLocal in:BlueInstr = BlueInstr(fld.inst.Last())\n\t\t\t\tin.c = Int(Leaf(n.arg[n.arg.Length - 1]).val)\n\t\t\tEndIf\n\t\tEndIf\n\t\tIf tslot = -1 Then tslot = rslot Else tslot = f.Push(tslot - f.Peek())\n\t\tr.inst.AddFirst bi.Make(opc.NEWTAB, tslot, 0)\n\t\tIf tslot <> rslot Then r.inst.AddLast bi.Make(opc.MOV, rslot, tslot)\t'put the resulting table in the expected slot\n\t\tf.Pop(f.Peek() - rslot)\t'...and correct the stack\n\t\tReturn r\n\tEnd Method\n\tMethod FieldIndex:Node(n:Rose) { FieldKey }\n\t\tLocal r:BytecodeNode = BytecodeNode.Join(n.key, n.arg)\n\t\tLocal val:Int = f.Pop(), idx:Int, op:Int\n\t\tIf n.key = \"FieldIndex\"\n\t\t\tidx = f.Pop() ; op = opc.SETTABI\n\t\tElse\n\t\t\tidx = f.GetConst(\"1\", Leaf(n.arg[0]).val) ; op = opc.SETTAB\n\t\tEndIf\n\t\tr.inst.AddLast bi.Make(op, -1, val, idx)\n\t\tReturn r\n\tEnd Method\n\tMethod va_init:Node(n:Node)\n\t\tReturn BytecodeNode.MakeL(n.key, bi.Make(opc.VAINIT, -1, 0))\n\tEnd Method\n\t\n\tMethod Label:Node(n:Leaf)\t'insert dummy instructions to remove in the next pass\n\t\tReturn BytecodeNode.MakeL(n.key, bi.Make(opc.MOV, 0, 0, StrToNum(n.val)))\n\tEnd Method\n\tMethod GotoS:Node(n:Leaf)\t'resolve these in the next pass after removing dummy targets\n\t\tReturn BytecodeNode.MakeL(n.key, bi.MakeK(opc.JMP, 0, StrToNum(n.val)))\n\tEnd Method\n\t\n\tMethod PASSTHROUGH:Node(n:Node) { FuncBody Block ExpList FArgs MArgs NameList VarList Assgt }\n\t\tIf Rose(n)\n\t\t\tReturn BytecodeNode.Join(n.key, Rose(n).arg, n)\t'combine instruction sequences where they exist\n\t\tElse\n\t\t\tReturn BytecodeNode.Nil(n.key, n)\n\t\tEndIf\n\tEnd Method\n\tMethod IGNORE:Node(n:Node) { fname param rcount acount icount }\n\t\tReturn n\t'some things don't represent instructions at all and should be passed as data nodes\n\tEnd Method\n\tMethod any:Node(n:Node)\n\t\tIf Rose(n)\n\t\t\tPrint \"unhandled (passthrough): \" + n.key\n\t\t\tReturn BytecodeNode.Join(n.key, Rose(n).arg, n)\n\t\tElse\n\t\t\tPrint \"unhandled: \" + n.key\n\t\t\tReturn BytecodeNode.Nil(n.key, n)\n\t\tEndIf\n\tEnd Method\nEnd Type\n\nType BytecodeNode Extends Node\n\tField inst:TList, old:Node\n\tFunction MakeL:BytecodeNode(key:String, ins:BlueInstr, old:Node = Null)\n\t\tLocal n:BytecodeNode = New Self ; n.key = key ; n.inst = CreateList() ; n.old = old\n\t\tn.inst.AddLast(ins) ; Return n\n\tEnd Function\n\tFunction MakeR:BytecodeNode(key:String, inst:BlueInstr[], old:Node = Null)\n\t\tLocal n:BytecodeNode = New Self ; n.key = key ; n.inst = TList.FromArray(inst) ; n.old = old ; Return n\n\tEnd Function\n\tFunction Join:BytecodeNode(key:String, els:Node[], old:Node = Null)\n\t\tLocal n:BytecodeNode = New Self ; n.key = key ; n.inst = CreateList() ; n.old = old\n\t\tFor Local e:BytecodeNode = EachIn els\t'use of Eachin is important, as it autocasts\n\t\t\tFor Local o:Object = EachIn e.inst\n\t\t\t\tn.inst.AddLast o\n\t\t\tNext\n\t\tNext\n\t\tReturn n\n\tEnd Function\n\tFunction Nil:BytecodeNode(key:String = \"@\", old:Node = Null)\n\t\tReturn MakeR(key, Null, old)\n\tEnd Function\nEnd Type\n\n","old_contents":"\n' Blue Moon\n' FOLD delegate to generate assembly instructions\n\n' this file is a Private Include\n\n'SuperStrict\n\n\nType CompileFold\n\tField opc:BlueOpcode = New BlueOpcode, bi:BlueInstr = New BlueInstr, f:BlueAssembly, _gq:TList = CreateList()\n\t\n\tFunction Make:CompileFold(f:BlueAssembly)\n\t\tLocal c:CompileFold = New Self ; c.f = f ; Return c\n\tEnd Function\n\t\n\tMethod l_varref:Node(n:Leaf)\n\t\tLocal v:VarDef = f.fd.vars[StrToNum(n.val)], op:Int\n\t\tIf v.isClosure Then op = opc.SETLC Else op = opc.MOV\n\t\tReturn BytecodeNode.MakeL(n.key, bi.Make(op, v.stkpos, f.Pop()), n)\n\tEnd Method\n\tMethod l_closref:Node(n:Leaf)\n\t\tLocal ref:Int = StrToNum(n.val)\n\t\tReturn BytecodeNode.MakeL(n.key, bi.Make(opc.SETUPV, ref, f.Pop()))\n\tEnd Method\n\tMethod l_getfield:Node(n:Rose)\n\t\tLocal r:BytecodeNode = BytecodeNode.Join(n.key, [n.arg[0]])\n\t\tLocal k:Int = f.GetConst(\"1\", Leaf(n.arg[1]).val), tab:Int = f.Pop()\n\t\tr.inst.AddLast bi.Make(opc.SETTAB, tab, f.Pop(), k)\n\t\tReturn r\n\tEnd Method\n\tMethod l_index:Node(n:Rose)\n\t\tLocal r:BytecodeNode = BytecodeNode.Join(n.key, n.arg)\n\t\tLocal ind:Int = f.Pop(), tab:Int = f.Pop(), val:Int = f.Pop()\n\t\tLocal pv:BlueInstr = BlueInstr(r.inst.Last())\n\t\tIf pv.op = opc.LOADSI\n\t\t\tpv.op = opc.SETTABSI ; pv.ra = tab ; pv.rb = val\n\t\tElse\n\t\t\tr.inst.AddLast bi.Make(opc.SETTABI, tab, val, ind)\n\t\tEndIf\n\t\tReturn r\n\tEnd Method\n\tMethod l_discard:Node(n:Node)\n\t\tf.Pop() ; Return BytecodeNode.Nil()\n\tEnd Method\n\t\n\tMethod LocalVar:Node(n:Rose)\n\t\tLocal vars:Node[] = Rose(BytecodeNode(n.arg[1]).old).arg\n\t\tLocal r:BytecodeNode = BytecodeNode.Join(n.key, n.arg)\n\t\tFor Local vi:Int = vars.Length - 1 To 0 Step -1\n\t\t\tLocal v:VarDef = f.fd.vars[StrToNum(Leaf(BytecodeNode(vars[vi]).old).val)]\n\t\t\tIf v.isClosure Then r.inst.AddFirst bi.Make(opc.NEWUPV, v.stkpos, 0)\n\t\tNext\n\t\tReturn r\n\tEnd Method\n\t\n\tMethod ReturnS:Node(n:Rose)\n\t\tLocal r:BytecodeNode = BytecodeNode.Join(n.key, n.arg)\n\t\tr.inst.AddLast(bi.MakeK(opc.RET, f.Peek(), n.arg.Length))\n\t\tf.Pop(n.arg.Length) ; Return r\n\tEnd Method\n\tMethod return_va:Node(n:Node)\n\t\tReturn BytecodeNode.MakeL(n.key, bi.Make(opc.RETVA, 0, 0))\n\tEnd Method\n\t\n\tMethod break:Node(n:Node)\n\t\tReturn BytecodeNode.MakeL(n.key, bi.Make(opc.JMP, -1, -1, -1))\n\tEnd Method\n\tMethod RepeatS:Node(n:Rose)\n\t\tLocal r:BytecodeNode = BytecodeNode.Join(n.key, n.arg), _lt:TList = f.fd._lt, _gt:TList = f.fd._gt\n\t\tLocal loopStart:LabelDef = New LabelDef, lsID:Int = _lt.Count(), loop:GotoDef = New GotoDef, lID:Int = _gt.Count()\n\t\tloop.tgt = loopStart ; _lt.AddLast loopStart ; _gt.AddLast loop\n\t\tLocal lastop:BlueInstr = BlueInstr(r.inst.Last()), reg:Int = f.Pop()\n\t\tIf lastop.op = opc.LNOT\n\t\t\tlastop.op = opc.JIF ; lastop.ra = lastop.rb ; lastop.rb = 0 ; lastop.c = lID\t'replace NOT with inverted jump\n\t\tElse\n\t\t\tr.inst.AddLast bi.MakeK(opc.JNOT, reg, lID)\n\t\tEndIf\n\t\tr.inst.AddFirst bi.Make(opc.MOV, 0, 0, lsID)\n\t\tr.inst.AddLast bi.Make(opc.MOV, -1, -1, -1)\n\t\tReturn r\n\tEnd Method\n\tMethod IfS:Node(n:Rose) { WhileS }\n\t\tLocal r:BytecodeNode = BytecodeNode.Join(n.key, [n.arg[0]]), lastop:BlueInstr = BlueInstr(r.inst.Last())\n\t\tLocal before:LabelDef, befID:Int, loopRound:GotoDef, loopID:Int, _lt:TList = f.fd._lt, _gt:TList = f.fd._gt\n\t\tIf n.key = \"WhileS\"\n\t\t\tbefore = New LabelDef ; befID = _lt.Count() ; _lt.AddLast before\n\t\t\tloopRound = New GotoDef ;loopRound.tgt = before ; loopID = _gt.Count() ; _gt.AddLast loopRound\n\t\t\tr.inst.AddFirst bi.Make(opc.MOV, 0, 0, befID)\n\t\tEndIf\n\t\tLocal postThen:LabelDef = New LabelDef, skipThen:GotoDef = New GotoDef, ptID:Int = _lt.Count(), stID:Int = _gt.Count()\n\t\t_lt.AddLast postThen ; skipThen.tgt = postThen ; _gt.AddLast skipThen\n\t\tIf lastop.op = opc.LNOT\n\t\t\tlastop.op = opc.JIF ; lastop.ra = lastop.rb ; lastop.rb = 0 ; lastop.c = stID\t'replace NOT with inverted jump\n\t\tElse\n\t\t\tr.inst.AddLast bi.MakeK(opc.JNOT, f.Peek(), stID)\n\t\tEndIf\n\t\tf.Pop()\n\t\tFor Local op:BlueInstr = EachIn BytecodeNode(n.arg[1]).inst\n\t\t\tr.inst.AddLast op\n\t\tNext\n\t\tLocal postElse:LabelDef, skipElse:GotoDef\n\t\tIf n.arg.Length > 2\t'there's an else\n\t\t\tpostElse = New LabelDef ; skipElse = New GotoDef ; skipElse.tgt = postElse\n\t\t\tLocal peID:Int = _lt.Count(), seID:Int = _gt.Count()\n\t\t\t_lt.AddLast postElse ; _gt.AddLast skipElse\n\t\t\tr.inst.AddLast bi.MakeK(opc.JMP, 0, seID)\n\t\t\tr.inst.AddLast bi.Make(opc.MOV, 0, 0, ptID)\n\t\t\tFor Local op:BlueInstr = EachIn BytecodeNode(n.arg[2]).inst\n\t\t\t\tr.inst.AddLast op\n\t\t\tNext\n\t\t\tr.inst.AddLast bi.Make(opc.MOV, 0, 0, peID)\n\t\tElse\n\t\t\tIf n.key = \"WhileS\" Then r.inst.AddLast bi.MakeK(opc.JMP, 0, loopID) ; r.inst.AddLast bi.Make(opc.MOV, -1, -1, -1)\n\t\t\tr.inst.AddLast bi.Make(opc.MOV, 0, 0, ptID)\n\t\tEndIf\n\t\tReturn r\n\tEnd Method\n\tMethod kand:Node(n:Rose) { kor }\n\t\tLocal r:BytecodeNode = BytecodeNode.Join(n.key, [n.arg[0]]), lastop:BlueInstr = BlueInstr(r.inst.Last())\n\t\tLocal _lt:TList = f.fd._lt, _gt:TList = f.fd._gt\n\t\tLocal postR:LabelDef = New LabelDef, skipR:GotoDef = New GotoDef, prID:Int = _lt.Count(), srID:Int = _gt.Count()\n\t\t_lt.AddLast postR ; skipR.tgt = postR ; _gt.AddLast skipR\n\t\tLocal reg:Int = f.Pop()\n\t\tIf lastop.op = opc.LNOT\n\t\t\tLocal op:Int = opc.JIF ; If n.key = \"kor\" Then op = opc.JNOT\n\t\t\tlastop.op = op ; lastop.ra = lastop.rb ; lastop.rb = 0 ; lastop.c = srID\t'replace NOT with inverted jump\n\t\tElse\n\t\t\tLocal op:Int = opc.JNOT ; If n.key = \"kor\" Then op = opc.JIF\n\t\t\tr.inst.AddLast bi.MakeK(op, reg - 1, srID)\n\t\tEndIf\n\t\tFor Local op:BlueInstr = EachIn BytecodeNode(n.arg[1]).inst\n\t\t\tr.inst.AddLast op\n\t\tNext\n\t\tr.inst.AddLast bi.Make(opc.MOV, reg - 1, reg)\n\t\tr.inst.AddLast bi.Make(opc.MOV, 0, 0, prID)\n\t\tReturn r\n\tEnd Method\n\t\n\tMethod fcall:Node(n:Rose) { pfcall tfcall va_fcall }\t'\"p\" prefix = \"procedure\" i.e. no return value required\n\t\tLocal r:BytecodeNode = BytecodeNode.Join(n.key, n.arg), argc:Int = Int(Leaf(n.arg[3]).val), retc:Int = Int(Leaf(n.arg[2]).val)\n\t\tLocal func:Int = f.Pop(argc + 1), args:Int = func + 1, op:Int = opc.CALL\n\t\tIf n.key = \"tfcall\" Then op = opc.TCALL\n\t\tr.inst.AddLast bi.Make(op, func, args, argc)\n\t\tIf n.key = \"fcall\"\n\t\t\tr.inst.AddLast bi.MakeK(opc.POSTCALL, f.Peek() + 1, retc) ; f.Push(retc)\n\t\tElseIf n.key = \"va_fcall\"\n\t\t\tr.inst.AddLast bi.Make(opc.CALLINIT, -1, 0)\n\t\tEndIf\n\t\tReturn r\n\tEnd Method\n\tMethod mcall:Node(n:Rose) { pmcall tmcall va_mcall }\n\t\tLocal r:BytecodeNode = BytecodeNode.Join(n.key, n.arg), argc:Int = Int(Leaf(n.arg[3]).val), retc:Int = Int(Leaf(n.arg[2]).val)\n\t\tLocal func:Int = f.Push(), argv:Int = f.Pop(argc + 2), op:Int = opc.CALL\n\t\tLocal ks:String = Leaf(Rose(BytecodeNode(n.arg[1]).old).arg[0]).val\t\t'yeesh\n\t\tr.inst.AddLast bi.Make(opc.GETTAB, func, argv, f.GetConst(\"1\", ks))\n\t\tIf n.key = \"tmcall\" Then op = opc.TCALL\n\t\tr.inst.AddLast bi.Make(op, func, argv, argc + 1)\n\t\tIf n.key = \"mcall\"\n\t\t\tr.inst.AddLast bi.MakeK(opc.POSTCALL, argv, retc) ; f.Push(retc)\n\t\tElseIf n.key = \"va_fcall\"\n\t\t\tr.inst.AddLast bi.Make(opc.CALLINIT, -1, 0)\n\t\tEndIf\n\t\tReturn r\n\tEnd Method\n\tMethod dotdotdot:Node(n:Leaf)\n\t\tLocal retc:Int = Int(n.val), r:BytecodeNode\n\t\tr = BytecodeNode.MakeL(n.key, bi.MakeK(opc.VARARG, f.Peek() + 1, retc))\n\t\tf.Push(retc)\n\t\tReturn r\n\tEnd Method\n\t\n\tMethod BinaryOp:Node(n:Rose) { plus minus mul div kmod pow dotdot lt gt leq geq eq neq }\n\t\tLocal r:BytecodeNode = BytecodeNode.Join(n.key, n.arg), op:Int\n\t\tSelect n.key\n\t\t\tCase \"plus\" ; op = opc.ADD\n\t\t\tCase \"minus\" ; op = opc.SUB\n\t\t\tCase \"mul\" ; op = opc.MUL\n\t\t\tCase \"div\" ; op = opc.DIV\n\t\t\tCase \"kmod\" ; op = opc.NMOD\n\t\t\tCase \"pow\" ; op = opc.POW\n\t\t\tCase \"dotdot\" ; op = opc.CAT\n\t\t\t\n\t\t\tCase \"lt\" ; op = opc.LT\n\t\t\tCase \"gt\" ; op = opc.LEQ\n\t\t\tCase \"leq\" ; op = opc.LEQ\n\t\t\tCase \"geq\" ; op = opc.LT\n\t\t\tCase \"eq\" ; op = opc.EQ\n\t\t\tCase \"neq\" ; op = opc.EQ\n\t\tEnd Select\n\t\tLocal lop:Int = f.Pop(), rop:Int = f.Pop()\n\t\tIf n.key = \"geq\" Or n.key = \"gt\"\n\t\t\tr.inst.AddLast bi.Make(op, f.Push(), rop, lop)\t'technically this violates IEEE-754, but it's how Lua defines it\n\t\tElse\n\t\t\tr.inst.AddLast bi.Make(op, f.Push(), lop, rop)\n\t\t\tIf n.key = \"neq\" Then r.inst.AddLast bi.Make(opc.LNOT, f.Peek(), f.Peek())\n\t\tEndIf\n\t\tReturn r\n\tEnd Method\n\tMethod UnaryOp:Node(n:Rose) { negate klen knot }\n\t\tLocal r:BytecodeNode = BytecodeNode.Join(n.key, n.arg), op:Int\n\t\tSelect n.key\n\t\t\tCase \"negate\" ; op = opc.UNM\n\t\t\tCase \"klen\" ; op = opc.ALEN\n\t\t\tCase \"knot\" ; op = opc.LNOT\n\t\t\tCase \"posate\" ; op = opc.UNP\n\t\tEnd Select\n\t\tLocal arg:Int = f.Pop()\n\t\tr.inst.AddLast bi.Make(op, f.Push(), arg)\n\t\tReturn r\n\tEnd Method\n\t\n\tMethod dconst:Node(n:Leaf) { sconst }\n\t\tLocal ki:Int = Int(n.val), op:Int = opc.LOADK\n\t\tIf n.key = \"dconst\" And Abs(ki) < BlueAssembly.SI_LIMIT And Double(n.val) = Double(ki)\n\t\t\top = opc.LOADSI\n\t\tElse\n\t\t\tki = f.GetConst(String(n.key = \"sconst\"), n.val)\n\t\tEndIf\n\t\tReturn BytecodeNode.MakeL(n.key, bi.MakeK(op, f.Push(), ki))\n\tEnd Method\n\tMethod bconst:Node(n:Leaf) { nil }\n\t\tLocal ins:BlueInstr\n\t\tSelect n.val\n\t\t\tCase \"true\" ; ins = bi.MakeK(opc.LOADBOOL, f.Push(), 1)\n\t\t\tCase \"false\" ; ins = bi.MakeK(opc.LOADBOOL, f.Push(), 0)\n\t\t\tCase \"nil\" ; ins = bi.MakeK(opc.LOADNIL, f.Push(), 0)\n\t\tEnd Select\n\t\tReturn BytecodeNode.MakeL(n.key, ins)\n\tEnd Method\n\t\n\tMethod funref:Node(n:Leaf) { varref closref }\n\t\tLocal i:BlueInstr, ref:Int = StrToNum(n.val)\n\t\tSelect n.key\n\t\t\tCase \"funref\" ; i = bi.MakeK(opc.CLOSURE, f.Push(), ref)\n\t\t\tCase \"varref\"\n\t\t\t\tLocal v:VarDef = f.fd.vars[ref], op:Int = opc.MOV ; If v.isClosure Then op = opc.GETLC\n\t\t\t\ti = bi.Make(op, f.Push(), v.stkpos)\n\t\t\tCase \"closref\" ; i = bi.Make(opc.GETUPV, f.Push(), ref)' + f.fd.vmax)\n\t\tEnd Select\n\t\tReturn BytecodeNode.MakeL(n.key, i)\n\tEnd Method\n\tMethod getfield:Node(n:Rose) { index }\n\t\tLocal r:BytecodeNode = BytecodeNode.Join(n.key, n.arg), i:BlueInstr\n\t\tIf n.key = \"getfield\"\n\t\t\tLocal k:Int = f.GetConst(\"1\", Leaf(n.arg[1]).val), tab:Int = f.Pop()\n\t\t\tr.inst.AddLast bi.Make(opc.GETTAB, f.Push(), tab, k)\n\t\tElse\n\t\t\tLocal idx:Int = f.Pop(), tab:Int = f.Pop()\n\t\t\tLocal pv:BlueInstr = BlueInstr(r.inst.Last())\n\t\t\tIf pv.op = opc.LOADSI And Abs(pv.c) < f.VSI_LIMIT\n\t\t\t\tpv.op = opc.GETTABSI ; pv.ra = f.Push() ; pv.rb = tab\n\t\t\tElse\n\t\t\t\tr.inst.AddLast bi.Make(opc.GETTABI, f.Push(), tab, idx)\n\t\t\tEndIf\n\t\tEndIf\n\t\tReturn r\n\tEnd Method\n\t\n\tMethod TableCons:Node(n:Rose)\n\t\tLocal r:BytecodeNode = BytecodeNode.Join(n.key, n.arg), fld:BytecodeNode = Null\n\t\tLocal rslot:Int = f.Push(), tslot:Int = f.vars '+ f.upvars\n\t\tFor fld = EachIn n.arg\t'work out where it's safe to put the table\n\t\t\tFor Local in:BlueInstr = EachIn fld.inst\n\t\t\t\tIf in.ra >= tslot Then tslot = in.ra + 1\n\t\t\tNext\n\t\tNext\n\t\tFor fld = EachIn n.arg\t'then patch the operations to point there\n\t\t\tFor Local in:BlueInstr = EachIn fld.inst\n\t\t\t\tIf in.ra = -1 And (in.op = opc.SETTAB Or in.op = opc.SETTABI ..\n\t\t\t\t\tOr in.op = opc.VAINIT Or in.op = opc.CALLINIT) Then in.ra = tslot\n\t\t\tNext\n\t\tNext\n\t\tIf n.arg\t'pass the ongoing index count to the variable initializer\n\t\t\tfld = BytecodeNode(n.arg[n.arg.Length - 2])\n\t\t\tIf fld.key = \"va_fcall\" Or fld.key = \"va_init\"\n\t\t\t\tLocal in:BlueInstr = BlueInstr(fld.inst.Last())\n\t\t\t\tin.c = Int(Leaf(n.arg[n.arg.Length - 1]).val)\n\t\t\tEndIf\n\t\tEndIf\n\t\tIf tslot = -1 Then tslot = rslot Else tslot = f.Push(tslot - f.Peek())\n\t\tr.inst.AddFirst bi.Make(opc.NEWTAB, tslot, 0)\n\t\tIf tslot <> rslot Then r.inst.AddLast bi.Make(opc.MOV, rslot, tslot)\t'put the resulting table in the expected slot\n\t\tf.Pop(f.Peek() - rslot)\t'...and correct the stack\n\t\tReturn r\n\tEnd Method\n\tMethod FieldIndex:Node(n:Rose) { FieldKey }\n\t\tLocal r:BytecodeNode = BytecodeNode.Join(n.key, n.arg)\n\t\tLocal val:Int = f.Pop(), idx:Int, op:Int\n\t\tIf n.key = \"FieldIndex\"\n\t\t\tidx = f.Pop() ; op = opc.SETTABI\n\t\tElse\n\t\t\tidx = f.GetConst(\"1\", Leaf(n.arg[0]).val) ; op = opc.SETTAB\n\t\tEndIf\n\t\tr.inst.AddLast bi.Make(op, -1, val, idx)\n\t\tReturn r\n\tEnd Method\n\tMethod va_init:Node(n:Node)\n\t\tReturn BytecodeNode.MakeL(n.key, bi.Make(opc.VAINIT, -1, 0))\n\tEnd Method\n\t\n\tMethod Label:Node(n:Leaf)\t'insert dummy instructions to remove in the next pass\n\t\tReturn BytecodeNode.MakeL(n.key, bi.Make(opc.MOV, 0, 0, StrToNum(n.val)))\n\tEnd Method\n\tMethod GotoS:Node(n:Leaf)\t'resolve these in the next pass after removing dummy targets\n\t\tReturn BytecodeNode.MakeL(n.key, bi.MakeK(opc.JMP, 0, StrToNum(n.val)))\n\tEnd Method\n\t\n\tMethod PASSTHROUGH:Node(n:Node) { FuncBody Block ExpList FArgs MArgs NameList VarList Assgt }\n\t\tIf Rose(n)\n\t\t\tReturn BytecodeNode.Join(n.key, Rose(n).arg, n)\t'combine instruction sequences where they exist\n\t\tElse\n\t\t\tReturn BytecodeNode.Nil(n.key, n)\n\t\tEndIf\n\tEnd Method\n\tMethod IGNORE:Node(n:Node) { fname param rcount acount icount }\n\t\tReturn n\t'some things don't represent instructions at all and should be passed as data nodes\n\tEnd Method\n\tMethod any:Node(n:Node)\n\t\tIf Rose(n)\n\t\t\tPrint \"unhandled (passthrough): \" + n.key\n\t\t\tReturn BytecodeNode.Join(n.key, Rose(n).arg, n)\n\t\tElse\n\t\t\tPrint \"unhandled: \" + n.key\n\t\t\tReturn BytecodeNode.Nil(n.key, n)\n\t\tEndIf\n\tEnd Method\nEnd Type\n\nType BytecodeNode Extends Node\n\tField inst:TList, old:Node\n\tFunction MakeL:BytecodeNode(key:String, ins:BlueInstr, old:Node = Null)\n\t\tLocal n:BytecodeNode = New Self ; n.key = key ; n.inst = CreateList() ; n.old = old\n\t\tn.inst.AddLast(ins) ; Return n\n\tEnd Function\n\tFunction MakeR:BytecodeNode(key:String, inst:BlueInstr[], old:Node = Null)\n\t\tLocal n:BytecodeNode = New Self ; n.key = key ; n.inst = TList.FromArray(inst) ; n.old = old ; Return n\n\tEnd Function\n\tFunction Join:BytecodeNode(key:String, els:Node[], old:Node = Null)\n\t\tLocal n:BytecodeNode = New Self ; n.key = key ; n.inst = CreateList() ; n.old = old\n\t\tFor Local e:BytecodeNode = EachIn els\t'use of Eachin is important, as it autocasts\n\t\t\tFor Local o:Object = EachIn e.inst\n\t\t\t\tn.inst.AddLast o\n\t\t\tNext\n\t\tNext\n\t\tReturn n\n\tEnd Function\n\tFunction Nil:BytecodeNode(key:String = \"@\", old:Node = Null)\n\t\tReturn MakeR(key, Null, old)\n\tEnd Function\nEnd Type\n\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"62b56ce6c5dc41fef0de3157bd2cd953bfdb2ea0","subject":"Fixed wireframe viewing in tron sample.","message":"Fixed wireframe viewing in tron sample.\n","repos":"kfprimm\/maxb3d,kfprimm\/maxb3d","old_file":"doc\/samples\/mak\/tron.bmx","new_file":"doc\/samples\/mak\/tron.bmx","new_contents":"\nStrict\n\nImport MaxB3D.Drivers\n\nGraphics 800,600\n\nLocal smooth=True\n\nLocal grid_tex:TTexture=CreateTexture( 32,32,8 )\nSetTextureScale grid_tex,10,10\nSetBuffer TextureBuffer( grid_tex )\nSetColor 0,0,64;DrawRect 0,0,32,32\nSetColor 0,0,255;DrawRect 0,0,32,32\nSetBuffer BackBuffer()\n\n\nLocal grid_plane:TFlat=CreateFlat()\nSetEntityTexture grid_plane,grid_tex\nSetEntityBlend grid_plane,1\nSetEntityAlpha grid_plane,.6\nSetEntityFX grid_plane,FX_FULLBRIGHT\n\n'Local mirror:TMirror=CreateMirror()\nrem\nLocal pivot=CreatePivot()\n\np=CreatePivot( p )\ncube=CreateCube( p )\nScaleEntity cube,1,1,5\nSetAnimKey cube,0\nRotateEntity cube,0,120,0\nSetAnimKey cube,60\nRotateEntity cube,0,240,0\nSetAnimKey cube,120\nRotateEntity cube,0,0,0\nSetAnimKey cube,180\nAddAnimSeq p,180\n\nFor x=-100 To 100 Step 25\nFor z=-100 To 100 Step 25\ne=CopyEntity( p,pivot )\nPositionEntity e,x,5,z\nAnimate e\nNext\nNext\nFreeEntity cube\nEnd Rem\n\nLocal trail_mesh:TMesh=CreateMesh()\nLocal trail_brush:TBrush=CreateBrush()\nSetBrushColor trail_brush,255,0,0\nSetBrushBlend trail_brush,3\nSetBrushFX trail_brush,FX_FULLBRIGHT\nLocal trail_surf:TSurface=AddMeshSurface( trail_mesh,trail_brush )\nAddSurfaceVertex trail_surf,0,2,0,0,0\nAddSurfaceVertex trail_surf,0,0,0,0,1\nAddSurfaceVertex trail_surf,0,2,0,0,0\nAddSurfaceVertex trail_surf,0,0,0,0,1\nAddSurfaceTriangle trail_surf,0,2,3\nAddSurfaceTriangle trail_surf,0,3,1\nAddSurfaceTriangle trail_surf,0,3,2\nAddSurfaceTriangle trail_surf,0,1,3\nLocal trail_vert=2\n\nLocal bike:TMesh=CreateSphere()\nScaleMesh bike,.75,1,2\nSetEntityPosition bike,0,1,0\nSetEntityShine bike,1\nSetEntityColor bike,192,0,255\n\nLocal camera:TCamera=CreateCamera()\nTurnEntity camera,45,0,0\nLocal cam_d#=30\n\nLocal light:TLight=CreateLight()\nTurnEntity light,45,45,0\n\nLocal add_flag=False,add_cnt\n\nWhile Not KeyHit(KEY_ESCAPE) And Not AppTerminate()\n\tSetWireFrame KeyDown(KEY_W)\n\t\n\tIf KeyDown(KEY_A) cam_d=cam_d-1\n\tIf KeyDown(KEY_Z) cam_d=cam_d+1\n\t\n\tLocal turn=0\n\tIf smooth\n\t\tIf KeyDown(KEY_LEFT) turn=5\n\t\tIf KeyDown(KEY_RIGHT) turn=-5\n\t\tIf turn\n\t\t\tadd_cnt=add_cnt+1\n\t\t\tIf add_cnt=3\n\t\t\t\tadd_cnt=0\n\t\t\t\tadd_flag=True\n\t\t\tElse\n\t\t\t\tadd_flag=False\n\t\t\tEndIf\n\t\tElse If add_cnt\n\t\t\tadd_cnt=0\n\t\t\tadd_flag=True\n\t\tElse\n\t\t\tadd_flag=False\n\t\tEndIf\n\tElse\n\t\tIf KeyHit(KEY_LEFT) turn=90\n\t\tIf KeyHit(KEY_RIGHT) turn=-90\n\t\tIf turn Then add_flag=True Else add_flag=False\n\tEndIf\n\t\n\tIf turn\n\t\tTurnEntity bike,0,turn,0\n\tEndIf\n\t\n\tMoveEntity bike,0,0,1\n\t\n\tLocal x#,y#,z#\n\tGetEntityPosition bike,x,y,z\n\tIf add_flag\n\t\tAddSurfaceVertex trail_surf,x,2,z,0,0\n\t\tAddSurfaceVertex trail_surf,x,0,z,0,1\n\t\tAddSurfaceTriangle trail_surf,trail_vert,trail_vert+2,trail_vert+3\n\t\tAddSurfaceTriangle trail_surf,trail_vert,trail_vert+3,trail_vert+1\n\t\tAddSurfaceTriangle trail_surf,trail_vert,trail_vert+3,trail_vert+2\n\t\tAddSurfaceTriangle trail_surf,trail_vert,trail_vert+1,trail_vert+3\n\t\ttrail_vert=trail_vert+2\n\tElse\n\t\tSetSurfaceCoords trail_surf,trail_vert,x,2,z\n\t\tSetSurfaceCoords trail_surf,trail_vert+1,x,0,z\n\tEndIf\n\t\n\tUpdateWorld\n\t\n\tSetEntityPosition camera,x-5,0,z\n\tMoveEntity camera,0,0,-cam_d\n\n'\tPositionEntity camera,0,20,0\n'\tPointEntity camera,bike\n\t\n\tRenderWorld\n\tFlip\nWend\n\n","old_contents":"\nStrict\n\nImport MaxB3D.Drivers\n\nGraphics 800,600\n\nLocal smooth=True\n\nLocal grid_tex:TTexture=CreateTexture( 32,32,8 )\nSetTextureScale grid_tex,10,10\nSetBuffer TextureBuffer( grid_tex )\nSetColor 0,0,64;DrawRect 0,0,32,32\nSetColor 0,0,255;DrawRect 0,0,32,32\nSetBuffer BackBuffer()\n\n\nLocal grid_plane:TFlat=CreateFlat()\nSetEntityTexture grid_plane,grid_tex\nSetEntityBlend grid_plane,1\nSetEntityAlpha grid_plane,.6\nSetEntityFX grid_plane,FX_FULLBRIGHT\n\n'Local mirror:TMirror=CreateMirror()\nrem\nLocal pivot=CreatePivot()\n\np=CreatePivot( p )\ncube=CreateCube( p )\nScaleEntity cube,1,1,5\nSetAnimKey cube,0\nRotateEntity cube,0,120,0\nSetAnimKey cube,60\nRotateEntity cube,0,240,0\nSetAnimKey cube,120\nRotateEntity cube,0,0,0\nSetAnimKey cube,180\nAddAnimSeq p,180\n\nFor x=-100 To 100 Step 25\nFor z=-100 To 100 Step 25\ne=CopyEntity( p,pivot )\nPositionEntity e,x,5,z\nAnimate e\nNext\nNext\nFreeEntity cube\nEnd Rem\n\nLocal trail_mesh:TMesh=CreateMesh()\nLocal trail_brush:TBrush=CreateBrush()\nSetBrushColor trail_brush,255,0,0\nSetBrushBlend trail_brush,3\nSetBrushFX trail_brush,FX_FULLBRIGHT\nLocal trail_surf:TSurface=AddMeshSurface( trail_mesh,trail_brush )\nAddSurfaceVertex trail_surf,0,2,0,0,0\nAddSurfaceVertex trail_surf,0,0,0,0,1\nAddSurfaceVertex trail_surf,0,2,0,0,0\nAddSurfaceVertex trail_surf,0,0,0,0,1\nAddSurfaceTriangle trail_surf,0,2,3\nAddSurfaceTriangle trail_surf,0,3,1\nAddSurfaceTriangle trail_surf,0,3,2\nAddSurfaceTriangle trail_surf,0,1,3\nLocal trail_vert=2\n\nLocal bike:TMesh=CreateSphere()\nScaleMesh bike,.75,1,2\nSetEntityPosition bike,0,1,0\nSetEntityShine bike,1\nSetEntityColor bike,192,0,255\n\nLocal camera:TCamera=CreateCamera()\nTurnEntity camera,45,0,0\nLocal cam_d#=30\n\nLocal light:TLight=CreateLight()\nTurnEntity light,45,45,0\n\nLocal add_flag=False,add_cnt\n\nWhile Not KeyHit(KEY_ESCAPE) And Not AppTerminate()\n\tSetWireFrame KeyHit(KEY_W)\n\t\n\tIf KeyDown(KEY_A) cam_d=cam_d-1\n\tIf KeyDown(KEY_Z) cam_d=cam_d+1\n\t\n\tLocal turn=0\n\tIf smooth\n\t\tIf KeyDown(KEY_LEFT) turn=5\n\t\tIf KeyDown(KEY_RIGHT) turn=-5\n\t\tIf turn\n\t\t\tadd_cnt=add_cnt+1\n\t\t\tIf add_cnt=3\n\t\t\t\tadd_cnt=0\n\t\t\t\tadd_flag=True\n\t\t\tElse\n\t\t\t\tadd_flag=False\n\t\t\tEndIf\n\t\tElse If add_cnt\n\t\t\tadd_cnt=0\n\t\t\tadd_flag=True\n\t\tElse\n\t\t\tadd_flag=False\n\t\tEndIf\n\tElse\n\t\tIf KeyHit(KEY_LEFT) turn=90\n\t\tIf KeyHit(KEY_RIGHT) turn=-90\n\t\tIf turn Then add_flag=True Else add_flag=False\n\tEndIf\n\t\n\tIf turn\n\t\tTurnEntity bike,0,turn,0\n\tEndIf\n\t\n\tMoveEntity bike,0,0,1\n\t\n\tLocal x#,y#,z#\n\tGetEntityPosition bike,x,y,z\n\tIf add_flag\n\t\tAddSurfaceVertex trail_surf,x,2,z,0,0\n\t\tAddSurfaceVertex trail_surf,x,0,z,0,1\n\t\tAddSurfaceTriangle trail_surf,trail_vert,trail_vert+2,trail_vert+3\n\t\tAddSurfaceTriangle trail_surf,trail_vert,trail_vert+3,trail_vert+1\n\t\tAddSurfaceTriangle trail_surf,trail_vert,trail_vert+3,trail_vert+2\n\t\tAddSurfaceTriangle trail_surf,trail_vert,trail_vert+1,trail_vert+3\n\t\ttrail_vert=trail_vert+2\n\tElse\n\t\tSetSurfaceCoords trail_surf,trail_vert,x,2,z\n\t\tSetSurfaceCoords trail_surf,trail_vert+1,x,0,z\n\tEndIf\n\t\n\tUpdateWorld\n\t\n\tSetEntityPosition camera,x-5,0,z\n\tMoveEntity camera,0,0,-cam_d\n\n'\tPositionEntity camera,0,20,0\n'\tPointEntity camera,bike\n\t\n\tRenderWorld\n\tFlip\nWend\n\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"dd24f08ba608124fb6ea9f5b4573a96e76e1afa4","subject":"Passing exception to logger as it's already localized","message":"Passing exception to logger as it's already localized\n\nrefs gh-1\n","repos":"maximos\/maximus","old_file":"src\/module.bmx","new_file":"src\/module.bmx","new_contents":"\nRem\n\tbbdoc: Maximus module base.\n\tabout: An abstract type for the similarities between module scopes and modules.\nEnd Rem\nType mxModuleBase Abstract\n\t\n\tField m_name:String\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the base's name.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetName(name:String)\n\t\tAssert name, \"(mxModuleBase.SetName) name cannot be Null\"\n\t\tm_name = name\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the base's name.\n\t\treturns: The base's name.\n\tEnd Rem\n\tMethod GetName:String()\n\t\tReturn m_name\n\tEnd Method\n\t\n'#end region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set a common field from the given variable.\n\t\treturns: True if the given variable was handled, or False if it was not.\n\tEnd Rem\n\tMethod SetCommonFromVariable:Int(variable:dVariable)\n\t\tReturn False\n\tEnd Method\n\t\nEnd Type\n\nRem\n\tbbdoc: Maximus module scope.\nEnd Rem\nType mxModuleScope Extends mxModuleBase\n\t\n\tField m_modules:dObjectMap\n\t\n\tMethod New()\n\t\tm_modules = New dObjectMap\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Add the given module to the scope.\n\t\treturns: True if the module was added, or False if it was not (the module is Null).\n\tEnd Rem\n\tMethod AddModule:Int(modul:mxModule)\n\t\tIf modul\n\t\t\tm_modules._Insert(modul.GetName(), modul)\n\t\t\tmodul.SetParent(Self)\n\t\t\tReturn True\n\t\tEnd If\n\t\tReturn False\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Check if the given module name is found in the scope.\n\t\treturns: True if the given module was found in the scope, or False if it was not.\n\tEnd Rem\n\tMethod HasModule:Int(modname:String)\n\t\tReturn m_modules._Contains(modname)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get a module with the given name.\n\t\treturns: The module with the given name, or Null if there is no module with the given name.\n\tEnd Rem\n\tMethod GetModuleWithName:mxModule(modname:String)\n\t\tReturn mxModule(m_modules._ObjectWithKey(modname))\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Load the given dJObject into the scope.\n\t\treturns: Itself, or Null if @root is Null.\n\tEnd Rem\n\tMethod FromJSON:mxModuleScope(root:dJObject)\n\t\tIf root\n\t\t\tSetName(root.GetName())\n\t\t\tFor Local variable:dVariable = EachIn root\n\t\t\t\tIf dJObject(variable)\n\t\t\t\t\tAddModule(New mxModule.FromJSON(dJObject(variable)))\n\t\t\t\t'Else\n\t\t\t\t'\tSetCommonFromVariable(variable)\n\t\t\t\tEnd If\n\t\t\tNext\n\t\t\tReturn Self\n\t\tEnd If\n\t\tReturn Null\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the module enumerator for the scope.\n\t\treturns: The module enumerator for the scope.\n\tEnd Rem\n\tMethod ModuleEnumerator:TMapEnumerator()\n\t\tReturn m_modules.ValueEnumerator()\n\tEnd Method\n\t\nEnd Type\n\nRem\n\tbbdoc: Maximus module.\nEnd Rem\nType mxModule Extends mxModuleBase\n\t\n\tField m_parent:mxModuleScope\n\tField m_description:String\n\tField m_versions:dObjectMap\n\t\n\tMethod New()\n\t\tm_versions = New dObjectMap\n\tEnd Method\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the module's parent.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetParent(parent:mxModuleScope)\n\t\tm_parent = parent\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the module's parent.\n\t\treturns: The module's parent.\n\tEnd Rem\n\tMethod GetParent:mxModuleScope()\n\t\tReturn m_parent\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the full name of the module (e.g. \"modscope.module\").\n\t\treturns: The full name of the module.\n\tEnd Rem\n\tMethod GetFullName:String()\n\t\tReturn m_parent.m_name + \".\" + m_name\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the module's description.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetDescription(description:String)\n\t\tm_description = description\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the module's description.\n\t\treturns: The module's description.\n\tEnd Rem\n\tMethod GetDescription:String()\n\t\tReturn m_description\n\tEnd Method\n\t\n'#end region Field accessors\n\t\n\tRem\n\t\tbbdoc: Get the installed version of the module (if it is installed).\n\t\treturns: The version of the module that is installed, or Null if the module is not installed.\n\tEnd Rem\n\tMethod GetInstalledVersion:mxModuleVersion()\n\t\tLocal version:String = mxModUtils.GetInstalledVersionFromVerID(GetFullName())\n\t\tIf version\n\t\t\tReturn New mxModuleVersion.Create(Self, version, Null)\n\t\tEnd If\n\t\tReturn Null\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Add the given version to the module.\n\t\treturns: True if the version was added, or False if it was not (the version is Null).\n\tEnd Rem\n\tMethod AddVersion:Int(version:mxModuleVersion)\n\t\tIf version\n\t\t\tm_versions._Insert(version.GetName(), version)\n\t\t\tversion.SetParent(Self)\n\t\t\tReturn True\n\t\tEnd If\n\t\tReturn False\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Check if there is a version with the given name.\n\t\treturns: True if the version was found, or False if it was not.\n\tEnd Rem\n\tMethod HasVersion:Int(name:String)\n\t\tReturn m_versions._Contains(name)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get a version with the given name.\n\t\treturns: The version with the given name, or Null if there is no version with the given name.\n\tEnd Rem\n\tMethod GetVersionWithName:mxModuleVersion(name:String)\n\t\tReturn mxModuleVersion(m_versions._ObjectWithKey(name))\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the latest (non-dev if available) version for this module.\n\t\treturns: The latest version for this module.\n\t\tabout: The latest version will be returned, or the dev version if it is the only version.\n\tEnd Rem\n\tMethod GetLatestVersion:mxModuleVersion()\n\t\tLocal hver:mxModuleVersion\n\t\tFor Local ver:mxModuleVersion = EachIn VersionEnumerator()\n\t\t\tIf ver.GetName() <> \"dev\"\n\t\t\t\tIf Not hver Or ver.Compare(hver) = 1\n\t\t\t\t\thver = ver\n\t\t\t\tEnd If\n\t\t\tEnd If\n\t\tNext\n\t\tIf Not hver\n\t\t\thver = GetVersionWithName(\"dev\")\n\t\tEnd If\n\t\tReturn hver\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set a common field from the given variable.\n\t\treturns: True if the given variable was handled, or False if it was not.\n\tEnd Rem\n\tMethod SetCommonFromVariable:Int(variable:dVariable)\n\t\tIf Super.SetCommonFromVariable(variable)\n\t\t\tReturn True\n\t\tElse\n\t\t\tSelect variable.GetName().ToLower()\n\t\t\t\tCase \"desc\"\n\t\t\t\t\tSetDescription(dValueVariable(variable).ValueAsString())\n\t\t\t\tCase \"versions\"\n\t\t\t\t\tFor Local jobj:dJObject = EachIn dJObject(variable)\n\t\t\t\t\t\tAddVersion(New mxModuleVersion.FromJSON(jobj))\n\t\t\t\t\tNext\n\t\t\t\tDefault\n\t\t\t\t\tReturn False\n\t\t\tEnd Select\n\t\t\tReturn True\n\t\tEnd If\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Load the given dJObject into the module.\n\t\treturns: Itself, or Null if @root is Null.\n\tEnd Rem\n\tMethod FromJSON:mxModule(root:dJObject)\n\t\tIf root\n\t\t\tSetName(root.GetName())\n\t\t\tFor Local variable:dVariable = EachIn root\n\t\t\t\tSetCommonFromVariable(variable)\n\t\t\tNext\n\t\t\tReturn Self\n\t\tEnd If\n\t\tReturn Null\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the version enumerator for the module.\n\t\treturns: The version enumerator for the module.\n\tEnd Rem\n\tMethod VersionEnumerator:TMapEnumerator()\n\t\tReturn m_versions.ValueEnumerator()\n\tEnd Method\n\t\nEnd Type\n\nRem\n\tbbdoc: Maximus module version.\nEnd Rem\nType mxModuleVersion\n\t\n\tField m_parent:mxModule\n\tField m_name:String, m_url:String\n\tField m_dependencies:mxModuleDependencies\n\t\n\tMethod New()\n\t\tm_dependencies = New mxModuleDependencies\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Create a module version.\n\t\treturns: Itself.\n\tEnd Rem\n\tMethod Create:mxModuleVersion(parent:mxModule, name:String, url:String)\n\t\tSetParent(parent)\n\t\tSetName(name)\n\t\tSetUrl(url)\n\t\tReturn Self\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Clone the version.\n\t\treturns: A clone of the version.\n\t\tabout: If @withdeps is True (default value), the dependencies will be added as well.\n\tEnd Rem\n\tMethod Clone:mxModuleVersion(withdeps:Int = True)\n\t\tLocal v:mxModuleVersion = New mxModuleVersion.Create(m_parent, m_name, m_url)\n\t\tFor Local dep:mxModuleDependency = EachIn DependencyEnumerator()\n\t\t\tv.m_dependencies.AddDependency(dep)\n\t\tNext\n\t\tReturn v\n\tEnd Method\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the version's parent.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetParent(parent:mxModule)\n\t\tm_parent = parent\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the version's parent.\n\t\treturns: The version's parent.\n\tEnd Rem\n\tMethod GetParent:mxModule()\n\t\tReturn m_parent\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the version's name.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetName(name:String)\n\t\tAssert name, \"(mxModuleVersion.SetName) name cannot be Null!\"\n\t\tm_name = name\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the version's name.\n\t\treturns: The version's name.\n\tEnd Rem\n\tMethod GetName:String()\n\t\tReturn m_name\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the version's url.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetUrl(url:String)\n\t\t'Assert url, \"(mxModuleVersion.SetUrl) url cannot be Null!\"\n\t\tm_url = url\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the version's url.\n\t\treturns: The version's url.\n\tEnd Rem\n\tMethod GetUrl:String()\n\t\tReturn m_url\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the temporary fetch path for the version's source archive.\n\t\treturns: The temporary file path for the version's source archive.\n\tEnd Rem\n\tMethod GetTemporaryFilePath:String()\n\t\tReturn \"tmp\/\" + m_parent.GetFullName() + \"-\" + m_name + \".zip\"\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the version's dependencies.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetDependencies(dependencies:mxModuleDependencies)\n\t\tm_dependencies = dependencies\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the version's dependencies.\n\t\treturns: The version's dependencies.\n\tEnd Rem\n\tMethod GetDependencies:mxModuleDependencies()\n\t\tReturn m_dependencies\n\tEnd Method\n\t\n'#end region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set a common field from the given variable.\n\t\treturns: True if the given variable was handled, or False if it was not.\n\tEnd Rem\n\tMethod SetCommonFromVariable:Int(variable:dVariable)\n\t\tSelect variable.GetName().ToLower()\n\t\t\tCase \"url\"\n\t\t\t\tSetUrl(dValueVariable(variable).ValueAsString())\n\t\t\tCase \"deps\"\n\t\t\t\tm_dependencies.FromJSON(dJArray(variable))\n\t\t\tDefault\n\t\t\t\tReturn False\n\t\tEnd Select\n\t\tReturn True\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Load the given dJObject into the version.\n\t\treturns: Itself, or Null if @root is Null.\n\tEnd Rem\n\tMethod FromJSON:mxModuleVersion(root:dJObject)\n\t\tIf root\n\t\t\tSetName(root.GetName())\n\t\t\tFor Local variable:dVariable = EachIn root\n\t\t\t\tSetCommonFromVariable(variable)\n\t\t\tNext\n\t\t\tReturn Self\n\t\tEnd If\n\t\tReturn Null\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the dependency enumerator for the version.\n\t\treturns: The dependency enumerator for the version.\n\tEnd Rem\n\tMethod DependencyEnumerator:TMapEnumerator()\n\t\tReturn m_dependencies.DependencyEnumerator()\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Compare the version with the given version.\n\t\treturns: 0 if the two versions are the same (same in version number alone), 1 if this version is greater than the given, or -1 if the given version is greater than this version.\n\tEnd Rem\n\tMethod Compare:Int(with:Object)\n\t\tLocal ver:mxModuleVersion = mxModuleVersion(with)\n\t\tIf ver\n\t\t\tLocal version1:mxVersionObject = New mxVersionObject.Parse(m_name)\n\t\t\tLocal version2:mxVersionObject = New mxVersionObject.Parse(ver.m_name)\n\t\t\tReturn version1.Compare(version2)\n\t\tEnd If\n\t\tReturn Super.Compare(with)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Fetch the version's source archive.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod FetchSourceArchive()\n\t\tLocal file:String = GetTemporaryFilePath()\n\t\tlogger.LogMessage(\"fetching: \" + GetUrl() + \" -> \" + file + \" \", False)\n\t\tIf FileType(file) = FILETYPE_NONE\n\t\t\tLocal stream:TStream = WriteFileExplicitly(file)\n\t\t\tIf stream\n\t\t\t\tLocal request:TRESTRequest = New TRESTRequest, response:TRESTResponse\n\t\t\t\trequest.SetProgressCallback(_ProgressCallback, New _mxProgressStore)\n\t\t\t\trequest.SetStream(stream)\n\t\t\t\tTry\n\t\t\t\t\tresponse = request.Call(GetUrl(), [\"User-Agent: \" + mainapp.m_useragent], \"GET\")\n\t\t\t\tCatch e:Object\n\t\t\t\t\tstream.Close()\n\t\t\t\t\tDeleteFile(file)\n\t\t\t\t\tlogger.LogMessage(\"\")\n\t\t\t\t\tThrowError(_s(\"error.fetch.archive\", [e.ToString()]))\n\t\t\t\tEnd Try\n\t\t\t\tstream.Close()\n\t\t\t\tIf response.responseCode = 200\n\t\t\t\t\tlogger.LogMessage(_s(\"message.fetch.done\", [String(response.responseCode)]))\n\t\t\t\tElse\n\t\t\t\t\tDeleteFile(file)\n\t\t\t\t\tlogger.LogMessage(\"\")\n\t\t\t\t\tThrowError(_s(\"error.fetch.archive\", [\"Bad response code: \" + String(response.responseCode)]))\n\t\t\t\tEnd If\n\t\t\tElse\n\t\t\t\tThrowError(_s(\"error.writeperms\", [file]))\n\t\t\tEnd If\n\t\tElse\n\t\t\tlogger.LogMessage(_s(\"message.fetch.alreadyfetched\"))\n\t\tEnd If\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Progress callback for source archive fetching.\n\t\treturns: Zero (no error).\n\tEnd Rem\n\tFunction _ProgressCallback:Int(data:Object, dltotal:Double, dlnow:Double, ultotal:Double, ulnow:Double)\n\t\tLocal store:_mxProgressStore = _mxProgressStore(data)\n\t\tLocal prog:Int = (dlnow \/ dltotal) * 100\n\t\tIf prog > store.m_progress + 5\n\t\t\tstore.m_progress = prog\n\t\t\tWriteStdOut(\".\")\n\t\tEnd If\n\t\tReturn 0\n\tEnd Function\n\t\nEnd Type\n\nRem\n\tbbdoc: A object representing a version, not to be confused with mxModuleVersion\n\tabout: Supported formats are 1, 1.1 and 1.1.1.\n\tDo note that because the version is represented as a Double there's a change\n\tthe precision of the final number is off.\n\t\n\t1.1.2 Would be converted to 1.001002 but when converted to a Double it results\n\tin 1.0010019999999999.\n\t\n\t1.1.12 However would be converted to 1.001012 and when converted to a Double it\n\tresults in 1.0010120000000000.\n\t\n\tA version string of 'dev' will be represented as 99999\nEnd Rem\nType mxVersionObject\n\n\tField m_version:Double\n\n\tRem\n\t\tbbdoc: Parse a version string\n\t\treturns: Itself.\n\tEnd Rem\n\tMethod Parse:mxVersionObject(version:String)\n\t\tIf version = \"dev\"\n\t\t\tm_version = 99999\n\t\t\tReturn Self\n\t\tEnd If\n\n\t\tLocal parts:String[] = version.Split(\".\")\n\t\tLocal converted:String = parts[0]\n\t\tIf parts.Length > 1\n\t\t\tconverted:+\".\"\n\t\t\tFor Local part:String = EachIn parts[1..]\n\t\t\t\tWhile part.Length <> 3\n\t\t\t\t\tpart = \"0\" + part\n\t\t\t\tWEnd\n\t\t\t\tconverted:+part\n\t\t\tNext\n\n\t\t\t'Make sure we format to x.x.x\n\t\t\tIf parts.Length = 2\n\t\t\t\tconverted:+\"000\"\n\t\t\tEnd If\n\t\tEnd If\n\n\t\tm_version = converted.ToDouble()\n\t\tReturn Self\n\tEnd Method\n\n\tRem\n\t\tbbdoc: Compare version numbers\n\tEnd Rem\n\tMethod Compare:Int(withObject:Object)\n\t\tLocal version:mxVersionObject = mxVersionObject(withObject)\n\t\tIf version\n\t\t\tIf m_version = version.m_version\n\t\t\t\tReturn 0\n\t\t\tElse If m_version > version.m_version\n\t\t\t\tReturn 1\n\t\t\tElse If m_version < version.m_version\n\t\t\t\tReturn - 1\n\t\t\tEnd If\n\t\tEnd If\n\t\tReturn Super.Compare(withObject)\n\tEnd Method\nEnd Type\n\nRem\n\tbbdoc: Maximus metafile handler\nEnd Rem\nType mxMetaFile\n\n\tField m_metafile:String\n\tField m_scope:String\n\tField m_name:String\n\tField m_version:String\n\t\n\tRem\n\t\tbbdoc: Create a metafile handler.\n\t\treturns: Itself.\n\tEnd Rem\n\tMethod Create:mxMetaFile(metafile:String)\n\t\tSetMetaFile(metafile)\n\t\tReturn Self\n\tEnd Method\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the metafile file path.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetMetaFile(metafile:String)\n\t\tm_metafile = metafile\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the metafile path.\n\t\treturns: The metafile path.\n\tEnd Rem\n\tMethod GetMetaFile:String()\n\t\tReturn m_metafile\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set metadata\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetMetaData(scope:String, name:String, version:String)\n\t\tSelf.m_scope = scope\n\t\tSelf.m_name = name\n\t\tSelf.m_version = version\n\tEnd Method\n\t\n'#end region Field accessors\n\t\n\tRem\n\t\tbbdoc: Load the configuration.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod Load()\n\t\tIf FileType(GetMetaFile()) = FILETYPE_FILE\n\t\t\tTry\n\t\t\t\tLocal contents:String = LoadText(GetMetaFile()).Trim()\n\t\t\t\tLocal parts:String[] = contents.Split(\"\/\")\n\t\t\t\t\n\t\t\t\tIf parts.Length <> 2\n\t\t\t\t\tThrow _s(\"error.load.meta.invalid_format\") ;\n\t\t\t\tEnd If\n\t\t\t\t\n\t\t\t\tLocal modinfo:String[] = parts[0].Split(\".\")\n\t\t\t\tm_scope = modinfo[0]\n\t\t\t\tm_name = modinfo[1]\n\t\t\t\tm_version = parts[1]\n\t\t\tCatch e:Object\n\t\t\t\tlogger.LogError(_s(\"error.load.metafile.parse\", [GetMetaFile()]))\n\t\t\t\tlogger.LogError(e.ToString())\n\t\t\tEnd Try\n\t\tElse\n\t\t\tlogger.LogWarning(_s(\"error.load.metafile.notfound\", [GetMetaFile()]))\n\t\tEnd If\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Save the configuration\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod Save()\n\t\tIf m_scope.Length = 0 Or m_name.Length = 0 Or m_version.Length = 0\n\t\t\tThrowError(_s(\"error.save.metafile.incomplete\", [m_scope, m_name, m_version]))\n\t\tEnd If\n\t\t\n\t\tLocal file:String = GetMetaFile()\n\t\tLocal stream:TStream = WriteFileExplicitly(file)\n\t\tIf stream\n\t\t\tstream.WriteString(m_scope + \".\" + m_name + \"\/\" + m_version)\n\t\t\tstream.Close\n\t\tElse\n\t\t\tThrowError(_s(\"error.writeperms\", [file]))\n\t\tEnd If\n\tEnd Method\nEnd Type\n","old_contents":"\nRem\n\tbbdoc: Maximus module base.\n\tabout: An abstract type for the similarities between module scopes and modules.\nEnd Rem\nType mxModuleBase Abstract\n\t\n\tField m_name:String\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the base's name.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetName(name:String)\n\t\tAssert name, \"(mxModuleBase.SetName) name cannot be Null\"\n\t\tm_name = name\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the base's name.\n\t\treturns: The base's name.\n\tEnd Rem\n\tMethod GetName:String()\n\t\tReturn m_name\n\tEnd Method\n\t\n'#end region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set a common field from the given variable.\n\t\treturns: True if the given variable was handled, or False if it was not.\n\tEnd Rem\n\tMethod SetCommonFromVariable:Int(variable:dVariable)\n\t\tReturn False\n\tEnd Method\n\t\nEnd Type\n\nRem\n\tbbdoc: Maximus module scope.\nEnd Rem\nType mxModuleScope Extends mxModuleBase\n\t\n\tField m_modules:dObjectMap\n\t\n\tMethod New()\n\t\tm_modules = New dObjectMap\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Add the given module to the scope.\n\t\treturns: True if the module was added, or False if it was not (the module is Null).\n\tEnd Rem\n\tMethod AddModule:Int(modul:mxModule)\n\t\tIf modul\n\t\t\tm_modules._Insert(modul.GetName(), modul)\n\t\t\tmodul.SetParent(Self)\n\t\t\tReturn True\n\t\tEnd If\n\t\tReturn False\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Check if the given module name is found in the scope.\n\t\treturns: True if the given module was found in the scope, or False if it was not.\n\tEnd Rem\n\tMethod HasModule:Int(modname:String)\n\t\tReturn m_modules._Contains(modname)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get a module with the given name.\n\t\treturns: The module with the given name, or Null if there is no module with the given name.\n\tEnd Rem\n\tMethod GetModuleWithName:mxModule(modname:String)\n\t\tReturn mxModule(m_modules._ObjectWithKey(modname))\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Load the given dJObject into the scope.\n\t\treturns: Itself, or Null if @root is Null.\n\tEnd Rem\n\tMethod FromJSON:mxModuleScope(root:dJObject)\n\t\tIf root\n\t\t\tSetName(root.GetName())\n\t\t\tFor Local variable:dVariable = EachIn root\n\t\t\t\tIf dJObject(variable)\n\t\t\t\t\tAddModule(New mxModule.FromJSON(dJObject(variable)))\n\t\t\t\t'Else\n\t\t\t\t'\tSetCommonFromVariable(variable)\n\t\t\t\tEnd If\n\t\t\tNext\n\t\t\tReturn Self\n\t\tEnd If\n\t\tReturn Null\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the module enumerator for the scope.\n\t\treturns: The module enumerator for the scope.\n\tEnd Rem\n\tMethod ModuleEnumerator:TMapEnumerator()\n\t\tReturn m_modules.ValueEnumerator()\n\tEnd Method\n\t\nEnd Type\n\nRem\n\tbbdoc: Maximus module.\nEnd Rem\nType mxModule Extends mxModuleBase\n\t\n\tField m_parent:mxModuleScope\n\tField m_description:String\n\tField m_versions:dObjectMap\n\t\n\tMethod New()\n\t\tm_versions = New dObjectMap\n\tEnd Method\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the module's parent.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetParent(parent:mxModuleScope)\n\t\tm_parent = parent\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the module's parent.\n\t\treturns: The module's parent.\n\tEnd Rem\n\tMethod GetParent:mxModuleScope()\n\t\tReturn m_parent\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the full name of the module (e.g. \"modscope.module\").\n\t\treturns: The full name of the module.\n\tEnd Rem\n\tMethod GetFullName:String()\n\t\tReturn m_parent.m_name + \".\" + m_name\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the module's description.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetDescription(description:String)\n\t\tm_description = description\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the module's description.\n\t\treturns: The module's description.\n\tEnd Rem\n\tMethod GetDescription:String()\n\t\tReturn m_description\n\tEnd Method\n\t\n'#end region Field accessors\n\t\n\tRem\n\t\tbbdoc: Get the installed version of the module (if it is installed).\n\t\treturns: The version of the module that is installed, or Null if the module is not installed.\n\tEnd Rem\n\tMethod GetInstalledVersion:mxModuleVersion()\n\t\tLocal version:String = mxModUtils.GetInstalledVersionFromVerID(GetFullName())\n\t\tIf version\n\t\t\tReturn New mxModuleVersion.Create(Self, version, Null)\n\t\tEnd If\n\t\tReturn Null\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Add the given version to the module.\n\t\treturns: True if the version was added, or False if it was not (the version is Null).\n\tEnd Rem\n\tMethod AddVersion:Int(version:mxModuleVersion)\n\t\tIf version\n\t\t\tm_versions._Insert(version.GetName(), version)\n\t\t\tversion.SetParent(Self)\n\t\t\tReturn True\n\t\tEnd If\n\t\tReturn False\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Check if there is a version with the given name.\n\t\treturns: True if the version was found, or False if it was not.\n\tEnd Rem\n\tMethod HasVersion:Int(name:String)\n\t\tReturn m_versions._Contains(name)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get a version with the given name.\n\t\treturns: The version with the given name, or Null if there is no version with the given name.\n\tEnd Rem\n\tMethod GetVersionWithName:mxModuleVersion(name:String)\n\t\tReturn mxModuleVersion(m_versions._ObjectWithKey(name))\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the latest (non-dev if available) version for this module.\n\t\treturns: The latest version for this module.\n\t\tabout: The latest version will be returned, or the dev version if it is the only version.\n\tEnd Rem\n\tMethod GetLatestVersion:mxModuleVersion()\n\t\tLocal hver:mxModuleVersion\n\t\tFor Local ver:mxModuleVersion = EachIn VersionEnumerator()\n\t\t\tIf ver.GetName() <> \"dev\"\n\t\t\t\tIf Not hver Or ver.Compare(hver) = 1\n\t\t\t\t\thver = ver\n\t\t\t\tEnd If\n\t\t\tEnd If\n\t\tNext\n\t\tIf Not hver\n\t\t\thver = GetVersionWithName(\"dev\")\n\t\tEnd If\n\t\tReturn hver\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set a common field from the given variable.\n\t\treturns: True if the given variable was handled, or False if it was not.\n\tEnd Rem\n\tMethod SetCommonFromVariable:Int(variable:dVariable)\n\t\tIf Super.SetCommonFromVariable(variable)\n\t\t\tReturn True\n\t\tElse\n\t\t\tSelect variable.GetName().ToLower()\n\t\t\t\tCase \"desc\"\n\t\t\t\t\tSetDescription(dValueVariable(variable).ValueAsString())\n\t\t\t\tCase \"versions\"\n\t\t\t\t\tFor Local jobj:dJObject = EachIn dJObject(variable)\n\t\t\t\t\t\tAddVersion(New mxModuleVersion.FromJSON(jobj))\n\t\t\t\t\tNext\n\t\t\t\tDefault\n\t\t\t\t\tReturn False\n\t\t\tEnd Select\n\t\t\tReturn True\n\t\tEnd If\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Load the given dJObject into the module.\n\t\treturns: Itself, or Null if @root is Null.\n\tEnd Rem\n\tMethod FromJSON:mxModule(root:dJObject)\n\t\tIf root\n\t\t\tSetName(root.GetName())\n\t\t\tFor Local variable:dVariable = EachIn root\n\t\t\t\tSetCommonFromVariable(variable)\n\t\t\tNext\n\t\t\tReturn Self\n\t\tEnd If\n\t\tReturn Null\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the version enumerator for the module.\n\t\treturns: The version enumerator for the module.\n\tEnd Rem\n\tMethod VersionEnumerator:TMapEnumerator()\n\t\tReturn m_versions.ValueEnumerator()\n\tEnd Method\n\t\nEnd Type\n\nRem\n\tbbdoc: Maximus module version.\nEnd Rem\nType mxModuleVersion\n\t\n\tField m_parent:mxModule\n\tField m_name:String, m_url:String\n\tField m_dependencies:mxModuleDependencies\n\t\n\tMethod New()\n\t\tm_dependencies = New mxModuleDependencies\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Create a module version.\n\t\treturns: Itself.\n\tEnd Rem\n\tMethod Create:mxModuleVersion(parent:mxModule, name:String, url:String)\n\t\tSetParent(parent)\n\t\tSetName(name)\n\t\tSetUrl(url)\n\t\tReturn Self\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Clone the version.\n\t\treturns: A clone of the version.\n\t\tabout: If @withdeps is True (default value), the dependencies will be added as well.\n\tEnd Rem\n\tMethod Clone:mxModuleVersion(withdeps:Int = True)\n\t\tLocal v:mxModuleVersion = New mxModuleVersion.Create(m_parent, m_name, m_url)\n\t\tFor Local dep:mxModuleDependency = EachIn DependencyEnumerator()\n\t\t\tv.m_dependencies.AddDependency(dep)\n\t\tNext\n\t\tReturn v\n\tEnd Method\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the version's parent.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetParent(parent:mxModule)\n\t\tm_parent = parent\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the version's parent.\n\t\treturns: The version's parent.\n\tEnd Rem\n\tMethod GetParent:mxModule()\n\t\tReturn m_parent\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the version's name.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetName(name:String)\n\t\tAssert name, \"(mxModuleVersion.SetName) name cannot be Null!\"\n\t\tm_name = name\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the version's name.\n\t\treturns: The version's name.\n\tEnd Rem\n\tMethod GetName:String()\n\t\tReturn m_name\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the version's url.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetUrl(url:String)\n\t\t'Assert url, \"(mxModuleVersion.SetUrl) url cannot be Null!\"\n\t\tm_url = url\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the version's url.\n\t\treturns: The version's url.\n\tEnd Rem\n\tMethod GetUrl:String()\n\t\tReturn m_url\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the temporary fetch path for the version's source archive.\n\t\treturns: The temporary file path for the version's source archive.\n\tEnd Rem\n\tMethod GetTemporaryFilePath:String()\n\t\tReturn \"tmp\/\" + m_parent.GetFullName() + \"-\" + m_name + \".zip\"\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the version's dependencies.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetDependencies(dependencies:mxModuleDependencies)\n\t\tm_dependencies = dependencies\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the version's dependencies.\n\t\treturns: The version's dependencies.\n\tEnd Rem\n\tMethod GetDependencies:mxModuleDependencies()\n\t\tReturn m_dependencies\n\tEnd Method\n\t\n'#end region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set a common field from the given variable.\n\t\treturns: True if the given variable was handled, or False if it was not.\n\tEnd Rem\n\tMethod SetCommonFromVariable:Int(variable:dVariable)\n\t\tSelect variable.GetName().ToLower()\n\t\t\tCase \"url\"\n\t\t\t\tSetUrl(dValueVariable(variable).ValueAsString())\n\t\t\tCase \"deps\"\n\t\t\t\tm_dependencies.FromJSON(dJArray(variable))\n\t\t\tDefault\n\t\t\t\tReturn False\n\t\tEnd Select\n\t\tReturn True\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Load the given dJObject into the version.\n\t\treturns: Itself, or Null if @root is Null.\n\tEnd Rem\n\tMethod FromJSON:mxModuleVersion(root:dJObject)\n\t\tIf root\n\t\t\tSetName(root.GetName())\n\t\t\tFor Local variable:dVariable = EachIn root\n\t\t\t\tSetCommonFromVariable(variable)\n\t\t\tNext\n\t\t\tReturn Self\n\t\tEnd If\n\t\tReturn Null\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the dependency enumerator for the version.\n\t\treturns: The dependency enumerator for the version.\n\tEnd Rem\n\tMethod DependencyEnumerator:TMapEnumerator()\n\t\tReturn m_dependencies.DependencyEnumerator()\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Compare the version with the given version.\n\t\treturns: 0 if the two versions are the same (same in version number alone), 1 if this version is greater than the given, or -1 if the given version is greater than this version.\n\tEnd Rem\n\tMethod Compare:Int(with:Object)\n\t\tLocal ver:mxModuleVersion = mxModuleVersion(with)\n\t\tIf ver\n\t\t\tLocal version1:mxVersionObject = New mxVersionObject.Parse(m_name)\n\t\t\tLocal version2:mxVersionObject = New mxVersionObject.Parse(ver.m_name)\n\t\t\tReturn version1.Compare(version2)\n\t\tEnd If\n\t\tReturn Super.Compare(with)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Fetch the version's source archive.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod FetchSourceArchive()\n\t\tLocal file:String = GetTemporaryFilePath()\n\t\tlogger.LogMessage(\"fetching: \" + GetUrl() + \" -> \" + file + \" \", False)\n\t\tIf FileType(file) = FILETYPE_NONE\n\t\t\tLocal stream:TStream = WriteFileExplicitly(file)\n\t\t\tIf stream\n\t\t\t\tLocal request:TRESTRequest = New TRESTRequest, response:TRESTResponse\n\t\t\t\trequest.SetProgressCallback(_ProgressCallback, New _mxProgressStore)\n\t\t\t\trequest.SetStream(stream)\n\t\t\t\tTry\n\t\t\t\t\tresponse = request.Call(GetUrl(), [\"User-Agent: \" + mainapp.m_useragent], \"GET\")\n\t\t\t\tCatch e:Object\n\t\t\t\t\tstream.Close()\n\t\t\t\t\tDeleteFile(file)\n\t\t\t\t\tlogger.LogMessage(\"\")\n\t\t\t\t\tThrowError(_s(\"error.fetch.archive\", [e.ToString()]))\n\t\t\t\tEnd Try\n\t\t\t\tstream.Close()\n\t\t\t\tIf response.responseCode = 200\n\t\t\t\t\tlogger.LogMessage(_s(\"message.fetch.done\", [String(response.responseCode)]))\n\t\t\t\tElse\n\t\t\t\t\tDeleteFile(file)\n\t\t\t\t\tlogger.LogMessage(\"\")\n\t\t\t\t\tThrowError(_s(\"error.fetch.archive\", [\"Bad response code: \" + String(response.responseCode)]))\n\t\t\t\tEnd If\n\t\t\tElse\n\t\t\t\tThrowError(_s(\"error.writeperms\", [file]))\n\t\t\tEnd If\n\t\tElse\n\t\t\tlogger.LogMessage(_s(\"message.fetch.alreadyfetched\"))\n\t\tEnd If\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Progress callback for source archive fetching.\n\t\treturns: Zero (no error).\n\tEnd Rem\n\tFunction _ProgressCallback:Int(data:Object, dltotal:Double, dlnow:Double, ultotal:Double, ulnow:Double)\n\t\tLocal store:_mxProgressStore = _mxProgressStore(data)\n\t\tLocal prog:Int = (dlnow \/ dltotal) * 100\n\t\tIf prog > store.m_progress + 5\n\t\t\tstore.m_progress = prog\n\t\t\tWriteStdOut(\".\")\n\t\tEnd If\n\t\tReturn 0\n\tEnd Function\n\t\nEnd Type\n\nRem\n\tbbdoc: A object representing a version, not to be confused with mxModuleVersion\n\tabout: Supported formats are 1, 1.1 and 1.1.1.\n\tDo note that because the version is represented as a Double there's a change\n\tthe precision of the final number is off.\n\t\n\t1.1.2 Would be converted to 1.001002 but when converted to a Double it results\n\tin 1.0010019999999999.\n\t\n\t1.1.12 However would be converted to 1.001012 and when converted to a Double it\n\tresults in 1.0010120000000000.\n\t\n\tA version string of 'dev' will be represented as 99999\nEnd Rem\nType mxVersionObject\n\n\tField m_version:Double\n\n\tRem\n\t\tbbdoc: Parse a version string\n\t\treturns: Itself.\n\tEnd Rem\n\tMethod Parse:mxVersionObject(version:String)\n\t\tIf version = \"dev\"\n\t\t\tm_version = 99999\n\t\t\tReturn Self\n\t\tEnd If\n\n\t\tLocal parts:String[] = version.Split(\".\")\n\t\tLocal converted:String = parts[0]\n\t\tIf parts.Length > 1\n\t\t\tconverted:+\".\"\n\t\t\tFor Local part:String = EachIn parts[1..]\n\t\t\t\tWhile part.Length <> 3\n\t\t\t\t\tpart = \"0\" + part\n\t\t\t\tWEnd\n\t\t\t\tconverted:+part\n\t\t\tNext\n\n\t\t\t'Make sure we format to x.x.x\n\t\t\tIf parts.Length = 2\n\t\t\t\tconverted:+\"000\"\n\t\t\tEnd If\n\t\tEnd If\n\n\t\tm_version = converted.ToDouble()\n\t\tReturn Self\n\tEnd Method\n\n\tRem\n\t\tbbdoc: Compare version numbers\n\tEnd Rem\n\tMethod Compare:Int(withObject:Object)\n\t\tLocal version:mxVersionObject = mxVersionObject(withObject)\n\t\tIf version\n\t\t\tIf m_version = version.m_version\n\t\t\t\tReturn 0\n\t\t\tElse If m_version > version.m_version\n\t\t\t\tReturn 1\n\t\t\tElse If m_version < version.m_version\n\t\t\t\tReturn - 1\n\t\t\tEnd If\n\t\tEnd If\n\t\tReturn Super.Compare(withObject)\n\tEnd Method\nEnd Type\n\nRem\n\tbbdoc: Maximus metafile handler\nEnd Rem\nType mxMetaFile\n\n\tField m_metafile:String\n\tField m_scope:String\n\tField m_name:String\n\tField m_version:String\n\t\n\tRem\n\t\tbbdoc: Create a metafile handler.\n\t\treturns: Itself.\n\tEnd Rem\n\tMethod Create:mxMetaFile(metafile:String)\n\t\tSetMetaFile(metafile)\n\t\tReturn Self\n\tEnd Method\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the metafile file path.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetMetaFile(metafile:String)\n\t\tm_metafile = metafile\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the metafile path.\n\t\treturns: The metafile path.\n\tEnd Rem\n\tMethod GetMetaFile:String()\n\t\tReturn m_metafile\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set metadata\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetMetaData(scope:String, name:String, version:String)\n\t\tSelf.m_scope = scope\n\t\tSelf.m_name = name\n\t\tSelf.m_version = version\n\tEnd Method\n\t\n'#end region Field accessors\n\t\n\tRem\n\t\tbbdoc: Load the configuration.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod Load()\n\t\tIf FileType(GetMetaFile()) = FILETYPE_FILE\n\t\t\tTry\n\t\t\t\tLocal contents:String = LoadText(GetMetaFile()).Trim()\n\t\t\t\tLocal parts:String[] = contents.Split(\"\/\")\n\t\t\t\t\n\t\t\t\tIf parts.Length <> 2\n\t\t\t\t\tThrow _s(\"error.load.meta.invalid_format\") ;\n\t\t\t\tEnd If\n\t\t\t\t\n\t\t\t\tLocal modinfo:String[] = parts[0].Split(\".\")\n\t\t\t\tm_scope = modinfo[0]\n\t\t\t\tm_name = modinfo[1]\n\t\t\t\tm_version = parts[1]\n\t\t\tCatch e:Object\n\t\t\t\tlogger.LogError(_s(\"error.load.metafile.parse\", [GetMetaFile()]))\n\t\t\t\tlogger.LogError(_s(\"error.load.metafile.parse\", [e.ToString()]))\n\t\t\tEnd Try\n\t\tElse\n\t\t\tlogger.LogWarning(_s(\"error.load.metafile.notfound\", [GetMetaFile()]))\n\t\tEnd If\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Save the configuration\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod Save()\n\t\tIf m_scope.Length = 0 Or m_name.Length = 0 Or m_version.Length = 0\n\t\t\tThrowError(_s(\"error.save.metafile.incomplete\", [m_scope, m_name, m_version]))\n\t\tEnd If\n\t\t\n\t\tLocal file:String = GetMetaFile()\n\t\tLocal stream:TStream = WriteFileExplicitly(file)\n\t\tIf stream\n\t\t\tstream.WriteString(m_scope + \".\" + m_name + \"\/\" + m_version)\n\t\t\tstream.Close\n\t\tElse\n\t\t\tThrowError(_s(\"error.writeperms\", [file]))\n\t\tEnd If\n\tEnd Method\nEnd Type\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"c786724dc9f33885a8db37adc16c7d53cb90057b","subject":"b3dloader is now slightly more efficient","message":"b3dloader is now slightly more efficient\n","repos":"kfprimm\/maxb3d,kfprimm\/maxb3d","old_file":"b3dloader.mod\/b3dloader.bmx","new_file":"b3dloader.mod\/b3dloader.bmx","new_contents":"\nStrict\n\nRem\n\tbbdoc: Blitz3D model loader for MaxB3D\nEnd Rem\nModule MaxB3D.B3DLoader\nModuleInfo \"Author: Kevin Primm\"\nModuleInfo \"License: MIT\"\n\nImport MaxB3D.Core\nImport MaxB3D.BoneAnimator\nImport Prime.libB3D\n\nType TMeshLoaderB3D Extends TMeshLoader\n\tField _mesh:TMesh\n\t\n\tMethod Run(mesh:TMesh,stream:TStream,url:Object)\n\t\tLocal model:TBB3DChunk=TBB3DChunk.Load(url)\n\t\tIf model=Null Return False\t\n\t\t\n\t\tLocal olddir$=CurrentDir()\n\t\tIf String(url) ChangeDir(ExtractDir(String(url)))\n\t\t\n\t\tLocal texture:TTexture[model.texs.length]\n\t\tLocal brush:TBrush[model.brus.length]\n\t\t\n\t\tFor Local i=0 To texture.length-1\n\t\t\tLocal chunk:TTEXSChunk=model.texs[i]\t\t\t\n\t\t\ttexture[i]=_currentworld.AddTexture(chunk.file,chunk.flags)\n\t\t\tIf texture[i]\n\t\t\t\ttexture[i].SetBlend chunk.blend\n\t\t\t\ttexture[i].SetPosition chunk.x_pos,chunk.y_pos\n\t\t\t\ttexture[i].SetScale chunk.x_scale,chunk.y_scale\n\t\t\t\ttexture[i].SetRotation chunk.rotation*(180.0\/Pi)\n\t\t\t\tIf chunk.flags&65536 texture[i].SetCoords 1\n\t\t\tEndIf\n\t\tNext\n\t\t\n\t\tFor Local i=0 To brush.length-1\n\t\t\tLocal chunk:TBRUSChunk=model.brus[i]\n\t\t\tbrush[i]=_currentworld.AddBrush()\n\t\t\tbrush[i].SetName chunk.name\n\t\t\tbrush[i].SetColor chunk.red*255,chunk.green*255,chunk.blue*255;brush[i].SetAlpha chunk.alpha\n\t\t\tbrush[i].SetShine chunk.shininess\n\t\t\tbrush[i].SetBlend chunk.blend;brush[i].SetFX chunk.fx\n\t\t\tFor Local j=0 To chunk.n_texs-1\n\t\t\t\tIf chunk.texture_id[j]>-1 brush[i].SetTexture texture[chunk.texture_id[j]],j\n\t\t\tNext\n\t\tNext\t\t\n\t\tChangeDir olddir\n\t\t\n\t\t' model.dump StandardIOStream\n\t\t \n\t\tIf model.node\n\t\t\tParseNode model.node,mesh,brush,mesh\n\t\t\tReturn True\n\t\tEndIf\n\t\tReturn False\n\tEnd Method\n\t\n\tMethod ParseNode(node:TNODEChunk,parent:TEntity,brush:TBrush[],entity:TEntity=Null)\n\t\tLocal meshchunk:TMESHChunk=TMESHChunk(node.kind),bonechunk:TBONEChunk=TBONEChunk(node.kind)\n\t\t\t\t\n\t\tSelect node.kind\n\t\tCase Null\n\t\t\tentity=_currentworld.AddPivot(parent)\n\t\tCase meshchunk\t\t\t\n\t\t\tIf entity=Null entity=_currentworld.AddMesh(\"*empty*\",parent)\n\t\t\tLocal mesh:TMesh=TMesh(entity)\n\t\t\tmesh._animator=New TBoneAnimator\n\t\t\t_mesh=mesh\n\t\t\t\n\t\t\tIf meshchunk.brush_id>-1 entity.SetBrush brush[meshchunk.brush_id]\n\t\t\t\n\t\t\tLocal vrts:TVRTSChunk=meshchunk.vrts\n\t\t\tLocal vertsurface:TSurface=New TSurface\n\t\t\tvertsurface.Resize(vrts.xyz.length\/3,0)\n\t\t\t\n\t\t\tFor Local i=0 To vertsurface.CountVertices()-1\n\t\t\t\tvertsurface.SetCoords i,vrts.xyz[i*3+0],vrts.xyz[i*3+1],vrts.xyz[i*3+2]\n\t\t\t\tIf vrts.nxyz vertsurface.SetNormal i,vrts.nxyz[i*3+0],vrts.nxyz[i*3+1],vrts.nxyz[i*3+2]\n\t\t\t\tIf vrts.rgba vertsurface.SetColor i,vrts.rgba[i*4+0]*255,vrts.rgba[i*4+1]*255,vrts.rgba[i*4+2]*255,vrts.rgba[i*4+3]\n\t\t\t\tIf vrts.SetSize()>1 \n\t\t\t\t\tFor Local j=0 To vrts.SetCount()-1\n\t\t\t\t\t\tvertsurface.SetTexCoords i,1-vrts.tex_coords[i][j,0],vrts.tex_coords[i][j,1],j\n\t\t\t\t\tNext\n\t\t\t\tEndIf\n\t\t\tNext\n\t\t\t\n\t\t\tFor Local i=0 To meshchunk.tris.length-1\n\t\t\t\tLocal tri:TTRISChunk=meshchunk.tris[i]\n\t\t\t\tLocal surface:TSurface=vertsurface.Copy()\n\t\t\t\tsurface.Resize(-1,tri.vertex_id.length\/3)\n\t\t\t\tIf tri.brush_id>-1 surface.SetBrush brush[tri.brush_id]\n\t\t\t\tFor Local t=0 To surface.CountTriangles()-1\n\t\t\t\t\tsurface.SetTriangle t,tri.vertex_id[t*3+0],tri.vertex_id[t*3+1],tri.vertex_id[t*3+2]\n\t\t\t\tNext\n\t\t\t\tIf vrts.nxyz=Null surface.UpdateNormals\t\t\t\n\t\t\t\tmesh.AppendSurface surface\n\t\t\tNext\n\t\tCase bonechunk\n\t\t\tentity=_currentworld.AddBone(parent)\n\t\t\tLocal bone:TBone=TBone(entity)\n\t\t\t\n\t\t\tFor Local surface:TSurface=EachIn _mesh._surfaces\n\t\t\t\tbone.AddSurface surface\n\t\t\t\tFor Local i=0 To bonechunk.vertex_id.length-1\n\t\t\t\t\tbone.AddVertex surface,bonechunk.vertex_id[i],bonechunk.weight[i]\n\t\t\t\tNext\n\t\t\tNext\t\t\t\n\t\t\t\n\t\t\tLocal ident_matrix:TMatrix=TMatrix.Identity()\n\t\t\tFor Local chunk:TKEYSChunk=EachIn node.keys\n\t\t\t\tLocal keys:TAnimKey[chunk.frame.length]\n\t\t\t\tLocal pos#[]=chunk.position,rot#[]=chunk.rotation,scl#[]=chunk.scale\n\t\t\t\tFor Local i=0 To chunk.frame.length-1\n\t\t\t\t\tLocal bonekey:TBoneKey=New TBoneKey\n\t\t\t\t\t\n\t\t\t\t\tIf pos.length>0 bonekey._px=pos[i*3+0];bonekey._py=pos[i*3+1];bonekey._pz=pos[i*3+2]\n\t\t\t\t\tIf rot.length>0 bonekey._rw=rot[i*4+0];bonekey._rx=rot[i*4+1];bonekey._ry=rot[i*4+2];bonekey._rz=rot[i*4+3]\n\t\t\t\t\tIf scl.length>0 bonekey._sx=scl[i*3+0];bonekey._sy=scl[i*3+1];bonekey._sz=scl[i*3+2]\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\tLocal key:TAnimKey=New TAnimKey\n\t\t\t\t\tkey._frame=chunk.frame[i]\n\t\t\t\t\tkey._object=bonekey\n\t\t\t\t\tkeys[i]=key\n\t\t\t\tNext\n\t\t\t\tTBoneAnimator(_mesh._animator).AddBone bone,keys\n\t\t\tNext\n\t\tDefault\n\t\t\tentity=_currentworld.AddPivot(parent)\n\t\tEnd Select\t\t\n\t\t\n\t\tentity.SetName node.name\n\t\tentity.SetPosition node.position[0],node.position[1],node.position[2]\n\t\tLocal pitch#,yaw#,roll#\n\t\tTQuaternion.Euler node.rotation[0],node.rotation[1],node.rotation[2],node.rotation[3],pitch,yaw,roll\n\t\tentity.SetRotation pitch,yaw,roll\n\t\tentity.SetScale node.scale[0],node.scale[1],node.scale[2]\n\t\t\n\t\tFor Local child:TNODEChunk=EachIn node.node\n\t\t\tParseNode child,entity,brush\n\t\tNext\n\t\tIf TMesh(entity) If TBoneAnimator(TMesh(entity)._animator)._root=Null TMesh(entity)._animator=Null\n\t\tIf TBone(entity) TBone(entity)._start_matrix=entity.GetMatrix()\n\tEnd Method\n\t\n\tMethod Info$()\n\t\tReturn \"Blitz3D|b3d\"\n\tEnd Method\n\tMethod ModuleName$()\n\t\tReturn \"b3dloader\"\n\tEnd Method\nEnd Type\nNew TMeshLoaderB3D\n","old_contents":"\nStrict\n\nRem\n\tbbdoc: Blitz3D model loader for MaxB3D\nEnd Rem\nModule MaxB3D.B3DLoader\nModuleInfo \"Author: Kevin Primm\"\nModuleInfo \"License: MIT\"\n\nImport MaxB3D.Core\nImport MaxB3D.BoneAnimator\nImport Prime.libB3D\n\nType TMeshLoaderB3D Extends TMeshLoader\n\tField _mesh:TMesh\n\t\n\tMethod Run(mesh:TMesh,stream:TStream,url:Object)\n\t\tLocal model:TBB3DChunk=TBB3DChunk.Load(url)\n\t\tIf model=Null Return False\t\n\t\t\n\t\tLocal olddir$=CurrentDir()\n\t\tIf String(url) ChangeDir(ExtractDir(String(url)))\n\t\t\n\t\tLocal texture:TTexture[model.texs.length]\n\t\tLocal brush:TBrush[model.brus.length]\n\t\t\n\t\tFor Local i=0 To texture.length-1\n\t\t\tLocal chunk:TTEXSChunk=model.texs[i]\t\t\t\n\t\t\ttexture[i]=_currentworld.AddTexture(chunk.file,chunk.flags)\n\t\t\tIf texture[i]\n\t\t\t\ttexture[i].SetBlend chunk.blend\n\t\t\t\ttexture[i].SetPosition chunk.x_pos,chunk.y_pos\n\t\t\t\ttexture[i].SetScale chunk.x_scale,chunk.y_scale\n\t\t\t\ttexture[i].SetRotation chunk.rotation*(180.0\/Pi)\n\t\t\t\tIf chunk.flags&65536 texture[i].SetCoords 1\n\t\t\tEndIf\n\t\tNext\n\t\t\n\t\tFor Local i=0 To brush.length-1\n\t\t\tLocal chunk:TBRUSChunk=model.brus[i]\n\t\t\tbrush[i]=_currentworld.AddBrush()\n\t\t\tbrush[i].SetName chunk.name\n\t\t\tbrush[i].SetColor chunk.red*255,chunk.green*255,chunk.blue*255;brush[i].SetAlpha chunk.alpha\n\t\t\tbrush[i].SetShine chunk.shininess\n\t\t\tbrush[i].SetBlend chunk.blend;brush[i].SetFX chunk.fx\n\t\t\tFor Local j=0 To chunk.n_texs-1\n\t\t\t\tIf chunk.texture_id[j]>-1 brush[i].SetTexture texture[chunk.texture_id[j]],j\n\t\t\tNext\n\t\tNext\t\t\n\t\tChangeDir olddir\n\t\t\n\t\t' model.dump StandardIOStream\n\t\t \n\t\tIf model.node\n\t\t\tParseNode model.node,mesh,brush,mesh\n\t\t\tReturn True\n\t\tEndIf\n\t\tReturn False\n\tEnd Method\n\t\n\tMethod ParseNode(node:TNODEChunk,parent:TEntity,brush:TBrush[],entity:TEntity=Null)\n\t\tLocal meshchunk:TMESHChunk=TMESHChunk(node.kind),bonechunk:TBONEChunk=TBONEChunk(node.kind)\n\t\t\t\t\n\t\tSelect node.kind\n\t\tCase Null\n\t\t\tentity=_currentworld.AddPivot(parent)\n\t\tCase meshchunk\t\t\t\n\t\t\tIf entity=Null entity=_currentworld.AddMesh(\"*empty*\",parent)\n\t\t\tLocal mesh:TMesh=TMesh(entity)\n\t\t\tmesh._animator=New TBoneAnimator\n\t\t\t_mesh=mesh\n\t\t\t\n\t\t\tIf meshchunk.brush_id>-1 entity.SetBrush brush[meshchunk.brush_id]\n\t\t\t\n\t\t\tLocal vrts:TVRTSChunk=meshchunk.vrts\n\t\t\tLocal vertsurface:TSurface=New TSurface\n\t\t\tvertsurface.Resize(vrts.xyz.length\/3,0)\n\t\t\t\n\t\t\tFor Local i=0 To vertsurface.CountVertices()-1\n\t\t\t\tvertsurface.SetCoords i,vrts.xyz[i*3+0],vrts.xyz[i*3+1],vrts.xyz[i*3+2]\n\t\t\t\tIf vrts.nxyz vertsurface.SetNormal i,vrts.nxyz[i*3+0],vrts.nxyz[i*3+1],vrts.nxyz[i*3+2]\n\t\t\t\tIf vrts.rgba vertsurface.SetColor i,vrts.rgba[i*4+0]*255,vrts.rgba[i*4+1]*255,vrts.rgba[i*4+2]*255,vrts.rgba[i*4+3]\n\t\t\t\tFor Local j=0 To vrts.SetCount()-1\n\t\t\t\t\tLocal u#,v#\n\t\t\t\t\tIf vrts.SetSize()>1 u=vrts.tex_coords[i][j,0];v=vrts.tex_coords[i][j,1]\n\t\t\t\t\tvertsurface.SetTexCoords i,1-u,v,j\n\t\t\t\tNext\n\t\t\tNext\n\t\t\t\n\t\t\tFor Local i=0 To meshchunk.tris.length-1\n\t\t\t\tLocal tri:TTRISChunk=meshchunk.tris[i]\n\t\t\t\tLocal surface:TSurface=vertsurface.Copy()\n\t\t\t\tsurface.Resize(-1,tri.vertex_id.length\/3)\n\t\t\t\tIf tri.brush_id>-1 surface.SetBrush brush[tri.brush_id]\n\t\t\t\tFor Local t=0 To surface.CountTriangles()-1\n\t\t\t\t\tsurface.SetTriangle t,tri.vertex_id[t*3+0],tri.vertex_id[t*3+1],tri.vertex_id[t*3+2]\n\t\t\t\tNext\n\t\t\t\tIf vrts.nxyz=Null surface.UpdateNormals\t\t\t\n\t\t\t\tmesh.AppendSurface surface\n\t\t\tNext\n\t\tCase bonechunk\n\t\t\tentity=_currentworld.AddBone(parent)\n\t\t\tLocal bone:TBone=TBone(entity)\n\t\t\t\n\t\t\tFor Local surface:TSurface=EachIn _mesh._surfaces\n\t\t\t\tbone.AddSurface surface\n\t\t\t\tFor Local i=0 To bonechunk.vertex_id.length-1\n\t\t\t\t\tbone.AddVertex surface,bonechunk.vertex_id[i],bonechunk.weight[i]\n\t\t\t\tNext\n\t\t\tNext\t\t\t\n\t\t\t\n\t\t\tLocal ident_matrix:TMatrix=TMatrix.Identity()\n\t\t\tFor Local chunk:TKEYSChunk=EachIn node.keys\n\t\t\t\tLocal keys:TAnimKey[chunk.frame.length]\n\t\t\t\tLocal pos#[]=chunk.position,rot#[]=chunk.rotation,scl#[]=chunk.scale\n\t\t\t\tFor Local i=0 To chunk.frame.length-1\n\t\t\t\t\tLocal bonekey:TBoneKey=New TBoneKey\n\t\t\t\t\t\n\t\t\t\t\tIf pos.length>0 bonekey._px=pos[i*3+0];bonekey._py=pos[i*3+1];bonekey._pz=pos[i*3+2]\n\t\t\t\t\tIf rot.length>0 bonekey._rw=rot[i*4+0];bonekey._rx=rot[i*4+1];bonekey._ry=rot[i*4+2];bonekey._rz=rot[i*4+3]\n\t\t\t\t\tIf scl.length>0 bonekey._sx=scl[i*3+0];bonekey._sy=scl[i*3+1];bonekey._sz=scl[i*3+2]\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\tLocal key:TAnimKey=New TAnimKey\n\t\t\t\t\tkey._frame=chunk.frame[i]\n\t\t\t\t\tkey._object=bonekey\n\t\t\t\t\tkeys[i]=key\n\t\t\t\tNext\n\t\t\t\tTBoneAnimator(_mesh._animator).AddBone bone,keys\n\t\t\tNext\n\t\tDefault\n\t\t\tentity=_currentworld.AddPivot(parent)\n\t\tEnd Select\t\t\n\t\t\n\t\tentity.SetName node.name\n\t\tentity.SetPosition node.position[0],node.position[1],node.position[2]\n\t\tLocal pitch#,yaw#,roll#\n\t\tTQuaternion.Euler node.rotation[0],node.rotation[1],node.rotation[2],node.rotation[3],pitch,yaw,roll\n\t\tentity.SetRotation pitch,yaw,roll\n\t\tentity.SetScale node.scale[0],node.scale[1],node.scale[2]\n\t\t\n\t\tFor Local child:TNODEChunk=EachIn node.node\n\t\t\tParseNode child,entity,brush\n\t\tNext\n\t\tIf TMesh(entity) If TBoneAnimator(TMesh(entity)._animator)._root=Null TMesh(entity)._animator=Null\n\t\tIf TBone(entity) TBone(entity)._start_matrix=entity.GetMatrix()\n\tEnd Method\n\t\n\tMethod Info$()\n\t\tReturn \"Blitz3D|b3d\"\n\tEnd Method\n\tMethod ModuleName$()\n\t\tReturn \"b3dloader\"\n\tEnd Method\nEnd Type\nNew TMeshLoaderB3D\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"58bdcd94687b21bcce907f2ca45f1480aeda6d60","subject":"core.bmx: Added some brief comments about the enumerators in there, since they're sort of mysterious otherwise. They're probably still mysterious. I'll have to work on that...","message":"core.bmx: Added some brief comments about the enumerators in there, since they're sort of mysterious otherwise. They're probably still mysterious. I'll have to work on that...","repos":"nilium\/lugi.mod,nilium\/lugi.mod","old_file":"core.mod\/core.bmx","new_file":"core.mod\/core.bmx","new_contents":"Rem\n\tCopyright (c) 2009 Noel R. Cower\n\n\tPermission is hereby granted, free of charge, to any person obtaining a copy\n\tof this software and associated documentation files (the \"Software\"), to deal\n\tin the Software without restriction, including without limitation the rights\n\tto use, copy, modify, merge, publish, distribute, sublicense, and\/or sell\n\tcopies of the Software, and to permit persons to whom the Software is\n\tfurnished to do so, subject to the following conditions:\n\n\tThe above copyright notice and this permission notice shall be included in\n\tall copies or substantial portions of the Software.\n\n\tTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n\tIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n\tFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n\tAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n\tLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n\tOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n\tTHE SOFTWARE.\nEndRem\n\nSuperStrict\n\nModule LuGI.Core\n\nModuleInfo \"Name: LuGI Core\"\nModuleInfo \"Description: Core API provided by LuGI to interact with BMax objects via Lua\"\nModuleInfo \"Author: Noel Cower\"\nModuleInfo \"License: MIT\"\nModuleInfo \"URL: http:\/\/github.com\/nilium\/lugi.mod\/<\/a>\"\n\n?Threaded\nImport Brl.Threads\n?\nImport Brl.LinkedList\nImport Pub.Lua\nImport \"lgcore.cpp\"\n\nPublic\n\n' LuGI field types - used by LuGI to determine how to access fields at runtime\n' The only reason these are public is because the generated code uses them, otherwise I'd hide\n' them away too. But then if I hide them and use number constants in the generated code, we'll\n' get the chance that changing these later will break existing glue code, and doing that is bad.\nConst LUGI_BYTEFIELD:Int = $0001\nConst LUGI_SHORTFIELD:Int = $0002\nConst LUGI_INTFIELD:Int = $0004\nConst LUGI_FLOATFIELD:Int = $0008\nConst LUGI_LONGFIELD:Int = $0010\nConst LUGI_DOUBLEFIELD:Int = $0020\nConst LUGI_STRINGFIELD:Int = $0040\nConst LUGI_OBJECTFIELD:Int = $0080\nConst LUGI_ARRAYFIELD:Int = $0100\n' Optional flag to specify that an integer field (Int, Short, Byte, or Long) should be treated as a\n' boolean value when passed to Lua\nConst LUGI_BOOLFIELDOPT:Int = $8000\n\nType LuGIInitFunction\n\t\n\t' Registers the callback provided as a pre-init stage routine\n\tMethod PreInit:LuGIInitFunction(cb(vm:Byte Ptr, rfield(off%, typ%, name$, clas@ Ptr), rmethod(fn:Int(state@ Ptr), name$, clas@ Ptr)))\n\t\t_cb = cb\n\t\t?Threaded\n\t\tp_lugi_initlock.Lock()\n\t\t?\n\t\tIf p_lugi_preinit_cb = Null Then\n\t\t\tp_lugi_preinit_cb = New TList\n\t\tEndIf\n\t\tp_lugi_preinit_cb.AddLast(Self)\n\t\t?Threaded\n\t\tp_lugi_initlock.Unlock()\n\t\t?\n\t\tReturn Self\n\tEnd Method\n\t\n\t' Registers the callback provided as a post-init stage routine\n\tMethod PostInit:LuGIInitFunction(cb(state:Byte Ptr, constructor:Int(state:Byte Ptr)))\n\t\t_cb = cb\n\t\t?Threaded\n\t\tp_lugi_initlock.Lock()\n\t\t?\n\t\tIf p_lugi_postinit_cb = Null Then\n\t\t\tp_lugi_postinit_cb = New TList\n\t\tEndIf\n\t\tp_lugi_postinit_cb.AddLast(Self)\n\t\t?Threaded\n\t\tp_lugi_initlock.Unlock()\n\t\t?\n\t\tReturn Self\n\tEnd Method\n\t\n\t' #region PRIVATE\n\t\n\tField _cb:Byte Ptr\n\t\n\tMethod Pre(vm:Byte Ptr, rfield(off%, typ%, name$, clas@ Ptr), rmethod(fn:Int(state@ Ptr), name$, clas@ Ptr))\n\t\tLocal cb(vm:Byte Ptr, rfield(off%, typ%, name$, clas@ Ptr), rmethod(fn:Int(state@ Ptr), name$, clas@ Ptr)) = _cb\n\t\tcb(vm, rfield, rmethod)\n\tEnd Method\n\t\n\tMethod Post(vm:Byte Ptr, constructor:Int(state:Byte Ptr))\n\t\tLocal cb(vm:Byte Ptr, constructor:Int(state:Byte Ptr)) = _cb\n\t\tcb(vm, constructor)\n\tEnd Method\n\t\n\t' #endregion\n\t\nEnd Type\n\nPrivate\n\n' There is really no good way to do this in a thread-safe manner, so the best I can do is to make\n' all access to the initialization lists a critical section\n?Threaded\nGlobal p_lugi_initlock:TMutex = TMutex.Create()\n?\nGlobal p_lugi_preinit_cb:TList\nGlobal p_lugi_postinit_cb:TList\n\n' Executes init functions that are to occur prior to creation of any BMax objects, VMTs, etc.\n' Doesn't lock the lists since it's only supposed to be called after the lists have been locked\nFunction PreInitLuGI(vm@ Ptr)\n\tIf Not p_lugi_preinit_cb Then\n\t\tReturn\n\tEndIf\n\tFor Local cb:LuGIInitFunction = EachIn p_lugi_preinit_cb\n\t\tcb.Pre(vm, p_lugi_register_field, p_lugi_register_method)\n\tNext\nEnd Function\n\n' Executes init functions that are to occur following the creation of BMax VMTs, metatables, cache, etc.\n' Doesn't lock the lists since it's only supposed to be called after the lists have been locked\nFunction PostInitLuGI(vm@ Ptr)\n\tIf Not p_lugi_postinit_cb Then\n\t\tReturn\n\tEndIf\n\tFor Local cb:LuGIInitFunction = EachIn p_lugi_postinit_cb\n\t\tcb.Post(vm, p_lugi_new_object)\n\tNext\nEnd Function\n\n' Private\/internal code that shouldn't be directly accessed (only provided)\nExtern \"C\"\n\tFunction p_lugi_register_method(fn:Int(state@ Ptr), name$, clas@ Ptr=Null)\n\tFunction p_lugi_register_field(off%, typ%, name$, clas@ Ptr)\n\t\n\tFunction p_lugi_init(state@ Ptr)\n\t\n\t' Constructor object - push with BBClass for type as upvalue\n\tFunction p_lugi_new_object:Int(state@ Ptr)\nEnd Extern\n\nPublic\n\nExtern \"C\"\n\t' Pushing\/getting BBObjects (BBObjects, BBStrings, and BBArrays to tables\/tables to BBArrays respectively)\n\tFunction lua_pushbmaxobject(state@ Ptr, obj:Object)\n\tFunction lua_tobmaxobject:Object(state@ Ptr, index:Int)\n\t\n\t' Pushing\/getting BBArrays (BBArrays to tables\/tables to BBArrays respectively)\n\t' @arr has to be treated as an Object in BMax since passing an Int[] as an Object[] doesn't work\n\tFunction lua_pushbmaxarray(state@ Ptr, arr:Object)\n\tFunction lua_tobmaxarray:Object(state@ Ptr, index:Int)\nEnd Extern\n\n' Initializes the Lua state for use with BMax objects via LuGI\nFunction InitLuGI(vm:Byte Ptr)\n\t?Threaded\n\tp_lugi_initlock.Lock()\n\t?\n\tPreInitLuGI(vm)\n\tp_lugi_init(vm)\n\tPostInitLuGI(vm)\n\t?Threaded\n\tp_lugi_initlock.Unlock()\n\t?\nEnd Function\n","old_contents":"Rem\n\tCopyright (c) 2009 Noel R. Cower\n\n\tPermission is hereby granted, free of charge, to any person obtaining a copy\n\tof this software and associated documentation files (the \"Software\"), to deal\n\tin the Software without restriction, including without limitation the rights\n\tto use, copy, modify, merge, publish, distribute, sublicense, and\/or sell\n\tcopies of the Software, and to permit persons to whom the Software is\n\tfurnished to do so, subject to the following conditions:\n\n\tThe above copyright notice and this permission notice shall be included in\n\tall copies or substantial portions of the Software.\n\n\tTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n\tIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n\tFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n\tAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n\tLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n\tOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n\tTHE SOFTWARE.\nEndRem\n\nSuperStrict\n\nModule LuGI.Core\n\nModuleInfo \"Name: LuGI Core\"\nModuleInfo \"Description: Core API provided by LuGI to interact with BMax objects via Lua\"\nModuleInfo \"Author: Noel Cower\"\nModuleInfo \"License: MIT\"\nModuleInfo \"URL: http:\/\/github.com\/nilium\/lugi.mod\/<\/a>\"\n\n?Threaded\nImport Brl.Threads\n?\nImport Brl.LinkedList\nImport Pub.Lua\nImport \"lgcore.cpp\"\n\nPublic\n\nConst LUGI_BYTEFIELD:Int = $0001\nConst LUGI_SHORTFIELD:Int = $0002\nConst LUGI_INTFIELD:Int = $0004\nConst LUGI_FLOATFIELD:Int = $0008\nConst LUGI_LONGFIELD:Int = $0010\nConst LUGI_DOUBLEFIELD:Int = $0020\nConst LUGI_STRINGFIELD:Int = $0040\nConst LUGI_OBJECTFIELD:Int = $0080\nConst LUGI_ARRAYFIELD:Int = $0100\nConst LUGI_BOOLFIELDOPT:Int = $8000\n\nType LuGIInitFunction\n\t\n\t' Registers the callback provided as a pre-init stage routine\n\tMethod PreInit:LuGIInitFunction(cb(vm:Byte Ptr, rfield(off%, typ%, name$, clas@ Ptr), rmethod(fn:Int(state@ Ptr), name$, clas@ Ptr)))\n\t\t_cb = cb\n\t\t?Threaded\n\t\tp_lugi_initlock.Lock()\n\t\t?\n\t\tIf p_lugi_preinit_cb = Null Then\n\t\t\tp_lugi_preinit_cb = New TList\n\t\tEndIf\n\t\tp_lugi_preinit_cb.AddLast(Self)\n\t\t?Threaded\n\t\tp_lugi_initlock.Unlock()\n\t\t?\n\t\tReturn Self\n\tEnd Method\n\t\n\t' Registers the callback provided as a post-init stage routine\n\tMethod PostInit:LuGIInitFunction(cb(state:Byte Ptr, constructor:Int(state:Byte Ptr)))\n\t\t_cb = cb\n\t\t?Threaded\n\t\tp_lugi_initlock.Lock()\n\t\t?\n\t\tIf p_lugi_postinit_cb = Null Then\n\t\t\tp_lugi_postinit_cb = New TList\n\t\tEndIf\n\t\tp_lugi_postinit_cb.AddLast(Self)\n\t\t?Threaded\n\t\tp_lugi_initlock.Unlock()\n\t\t?\n\t\tReturn Self\n\tEnd Method\n\t\n\t' #region PRIVATE\n\t\n\tField _cb:Byte Ptr\n\t\n\tMethod Pre(vm:Byte Ptr, rfield(off%, typ%, name$, clas@ Ptr), rmethod(fn:Int(state@ Ptr), name$, clas@ Ptr))\n\t\tLocal cb(vm:Byte Ptr, rfield(off%, typ%, name$, clas@ Ptr), rmethod(fn:Int(state@ Ptr), name$, clas@ Ptr)) = _cb\n\t\tcb(vm, rfield, rmethod)\n\tEnd Method\n\t\n\tMethod Post(vm:Byte Ptr, constructor:Int(state:Byte Ptr))\n\t\tLocal cb(vm:Byte Ptr, constructor:Int(state:Byte Ptr)) = _cb\n\t\tcb(vm, constructor)\n\tEnd Method\n\t\n\t' #endregion\n\t\nEnd Type\n\nPrivate\n\n' There is really no good way to do this in a thread-safe manner, so the best I can do is to make\n' all access to the initialization lists a critical section\n?Threaded\nGlobal p_lugi_initlock:TMutex = TMutex.Create()\n?\nGlobal p_lugi_preinit_cb:TList\nGlobal p_lugi_postinit_cb:TList\n\n' Executes init functions that are to occur prior to creation of any BMax objects, VMTs, etc.\n' Doesn't lock the lists since it's only supposed to be called after the lists have been locked\nFunction PreInitLuGI(vm@ Ptr)\n\tIf Not p_lugi_preinit_cb Then\n\t\tReturn\n\tEndIf\n\tFor Local cb:LuGIInitFunction = EachIn p_lugi_preinit_cb\n\t\tcb.Pre(vm, p_lugi_register_field, p_lugi_register_method)\n\tNext\nEnd Function\n\n' Executes init functions that are to occur following the creation of BMax VMTs, metatables, cache, etc.\n' Doesn't lock the lists since it's only supposed to be called after the lists have been locked\nFunction PostInitLuGI(vm@ Ptr)\n\tIf Not p_lugi_postinit_cb Then\n\t\tReturn\n\tEndIf\n\tFor Local cb:LuGIInitFunction = EachIn p_lugi_postinit_cb\n\t\tcb.Post(vm, p_lugi_new_object)\n\tNext\nEnd Function\n\n' Private\/internal code that shouldn't be directly accessed (only provided)\nExtern \"C\"\n\tFunction p_lugi_register_method(fn:Int(state@ Ptr), name$, clas@ Ptr=Null)\n\tFunction p_lugi_register_field(off%, typ%, name$, clas@ Ptr)\n\t\n\tFunction p_lugi_init(state@ Ptr)\n\t\n\t' Constructor object - push with BBClass for type as upvalue\n\tFunction p_lugi_new_object:Int(state@ Ptr)\nEnd Extern\n\nPublic\n\nExtern \"C\"\n\t' Pushing\/getting BBObjects (BBObjects, BBStrings, and BBArrays to tables\/tables to BBArrays respectively)\n\tFunction lua_pushbmaxobject(state@ Ptr, obj:Object)\n\tFunction lua_tobmaxobject:Object(state@ Ptr, index:Int)\n\t\n\t' Pushing\/getting BBArrays (BBArrays to tables\/tables to BBArrays respectively)\n\t' @arr has to be treated as an Object in BMax since passing an Int[] as an Object[] doesn't work\n\tFunction lua_pushbmaxarray(state@ Ptr, arr:Object)\n\tFunction lua_tobmaxarray:Object(state@ Ptr, index:Int)\nEnd Extern\n\n' Initializes the Lua state for use with BMax objects via LuGI\nFunction InitLuGI(vm:Byte Ptr)\n\t?Threaded\n\tp_lugi_initlock.Lock()\n\t?\n\tPreInitLuGI(vm)\n\tp_lugi_init(vm)\n\tPostInitLuGI(vm)\n\t?Threaded\n\tp_lugi_initlock.Unlock()\n\t?\nEnd Function\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"0264a63b3f9225f97b1a249355def27ef13900e4","subject":"remember all ops","message":"remember all ops\n","repos":"Leushenko\/blue-moon","old_file":"bluecompiler.bmx","new_file":"bluecompiler.bmx","new_contents":"\n' Blue Moon\n' Bytecode compiler: accepts program fragments as strings, or program files (and outputs)\n\nSuperStrict\n\nImport \"blueparser.bmx\"\nImport \"blueerror.bmx\"\nImport \"blueversion.bmx\"\nPrivate\nInclude \"TFold.bmx\"\nInclude \"bluefoldsyntax.bmx\"\nInclude \"bluefoldsemantics.bmx\"\nInclude \"bluefoldcodegen.bmx\"\nInclude \"debugfold.bmx\"\nPublic\n\nType BlueCompiler\n\tFunction CompileFile(infile:String, outfile:String = \"\")\n\t\tIf outfile = \"\" Then outfile = infile + \".so\"\n\t\tLocal n:TParseNode = BlueParseFile(infile)\n\t\tLocal compiled:BlueBinary = BlueBinary.Make(infile, ASTToAssembly(n))\n\t\tcompiled.WriteObjectFile(outFile)\n\tEnd Function\n\t\n\tFunction CompileFileForLoad:BlueBinary(infile:String)\n\t\tLocal n:TParseNode = BlueParseFile(infile)\n\t\tLocal code:BlueBinary = BlueBinary.Make(infile, ASTToAssembly(n))\n\t\tLocal sz:Int, mem:Byte Ptr = code.WriteMemory(sz)\n\t\tcode = code.ReadMemory(mem, sz) ; MemFree(mem)\n\t\tReturn code\n\tEnd Function\n\t\n'\tFunction CompileString:BlueBinary(program:String)\n'\t\tLocal n:TParseNode = BlueParseString(program)\n'\t\tReturn BlueBinary.Make(\"\", ASTToAssembly(n))\n'\tEnd Function\n\t\n\tFunction ShowBytecode:String(infile:String)\n\t\tLocal n:TParseNode = BlueParseFile(infile), out:String = infile + \":~n\"\n\t\tLocal assemblies:TList = ASTToAssembly(n)\n\t\tFor Local f:BlueAssembly = EachIn assemblies\n\t\t\tout :+ f.ToString()\n\t\tNext\n\t\tReturn out\n\tEnd Function\n\t\n\tFunction ASTToAssembly:TList(n:TParseNode)\n\t\tLocal tbl:NodeTable = Node.FromParse(n), r:Node = tbl.n\n\t\t\n\t\tr = Node.Fold(r, NormalizeFold.Make(tbl))\n\t\t\n\t\tLocal errf:SyntaxErrFold = SyntaxErrFold.Make(tbl)\n\t\tr = Node.Fold(r, errf) ; errf.BreakCheck()\n\t\t\n\t\tr = Node.Fold(r, New ConstantFold)\n\t\t\n\t\tLocal semf:SemanticFold = SemanticFold.Make(r, tbl)\n\t\tr = Node.Fold(r, semf, Node.BOTH)\t'fold both ways to push and pop environments\n\t\tSemanticFold.Close(semf, r)\n\t\t\n\t\tLocal funs:FunDef[] = FunDef[](semf.funs.ToArray()) ; semf = Null\n\t\t\n\t\t' if we wanted a type checker, it would go here\n\t\ttbl = Null\t'source information no longer needed\n\t\t\n\t\tLocal assemblies:TList = CreateList()\n\t\tFor Local f:FunDef = EachIn funs\n\t\t\tLocal com:CompileFold = CompileFold.Make(BlueAssembly.Make(f))\n\t\t'\tPrint \"F #\" + f.id + \": \" + f.n.ToString()\n\t\t\tLocal inst:TList = BytecodeNode(Node.Fold(f.n, com)).inst\n\t\t\tcom.f.Finish(inst, com.opc)\n\t\t\tassemblies.AddLast(com.f)\n\t\tNext\n\t\t\n\t\t?Debug\n\t\tDebug_KeyListFold.Run(funs, CompileFold.Make(Null))\n\t\t?\n\t\tReturn assemblies\n\tEnd Function\nEnd Type\n\nType BlueOpcode Final\n\tField MOV:Int = 0, GETLC:Int = 1, SETLC:Int = 2\t\t'these are constants, ignore their definition as fields\n\tField LOADK:Int = 3, LOADSI:Int = 4, LOADBOOL:Int = 5, LOADNIL:Int = 6\n\t\n\tField GETTAB:Int = 7, GETTABSI:Int = 8, SETTAB:Int = 9, SETTABSI:Int = 10\n\tField GETTABI:Int = 11, SETTABI:Int = 12, GETUPV:Int = 13, SETUPV:Int = 14\n\tField NEWTAB:Int = 15, CLOSURE:Int = 16, NEWUPV:Int = 17\n\t\n\tField ADD:Int = 18, SUB:Int = 19, MUL:Int = 20, DIV:Int = 21, NMOD:Int = 22, POW:Int = 23, CAT:Int = 24\n\tField IDIV:Int = 25, BAND:Int = 26, BOR:Int = 27, BXOR:Int = 28, BSHL:Int = 29, BSHR:Int = 30\n\tField UNM:Int = 31, LNOT:Int = 32, ALEN:Int = 33, BNOT:Int = 34, UNP:Int = 35\n\tField EQ:Int = 36, LT:Int = 37, LEQ:Int = 38\n\t\n\tField JMP:Int = 39, JIF:Int = 40, JNOT:Int = 41\n\tField CALL:Int = 42, TCALL:Int = 43, RET:Int = 44, RETVA:Int = 45\n\tField POSTCALL:Int = 46, VARARG:Int = 47, VAINIT:Int = 48, CALLINIT:Int = 49\n\t\n\tFunction Make:Int(i:BlueInstr)\n\t\tGlobal opc:BlueOpcode = New Self\n\t\tLocal c:Int = i.c\n\t\tSelect i.op\n\t\t\tCase opc.LOADK, opc.LOADSI, opc.LOADBOOL, opc.LOADNIL, opc.JMP, opc.JIF, opc.JNOT, opc.RET\n\t\t\t\tIf c < 0 Then c :& (Int(2^18) - 1)\n\t\t\t\tReturn i.op | ((i.ra & $FF) Shl 6) | (c Shl 14)\n\t\t\tDefault\n\t\t\t\tIf c < 0 Then c :& (Int(2^10) - 1)\n\t\t\t\tReturn i.op | ((i.ra & $FF) Shl 6) | ((i.rb & $FF) Shl 14) | (c Shl 22)\n\t\tEnd Select\n\tEnd Function\n\tFunction Read(i:Int, op:Int Var, ra:Int Var, rb:Int Var, c:Int Var)\n\t\tGlobal opc:BlueOpcode = New Self\n\t\top = i & %111111 ; ra = (i Shr 6) & $FF\n\t\tSelect op\n\t\t\tCase opc.LOADK, opc.LOADSI, opc.LOADBOOL, opc.LOADNIL, opc.JMP, opc.JIF, opc.JNOT, opc.RET\n\t\t\t\trb = 0 ; c = i Sar 14\t'sign-extend (already MSB)\n\t\t\tDefault\n\t\t\t\trb = (i Shr 14) & $FF ; c = i Sar 22\n\t\tEnd Select\n\tEnd Function\nEnd Type\n\nType BlueInstr\n\tField op:Int, ra:Int, rb:Int, c:Int\n\tFunction Make:BlueInstr(op:Int, ra:Int, rb:Int, c:Int = 0)\n\t\tLocal i:BlueInstr = New BlueInstr ; i.op = op ; i.ra = ra ; i.rb = rb ; i.c = c ; Return i\n\tEnd Function\n\tFunction MakeK:BlueInstr(op:Int, ra:Int, c:Int)\n\t\tReturn Make(op, ra, 0, c)\n\tEnd Function\n\tMethod ToString:String()\n\t\tGlobal opc:BlueOpcode = New BlueOpcode\n\t\tLocal n:String = \"??\"\n\t\tFor Local f:TField = EachIn TTypeId.ForObject(opc).Fields()\n\t\t\tIf f.GetInt(opc) = op Then n = f.Name()[..10] ; Exit\n\t\tNext\n\t\tSelect op\n\t\t\tCase opc.LOADNIL, opc.NEWUPV, opc.NEWTAB\n\t\t\t\tReturn n + \" \" + ra\n\t\t\tCase opc.MOV, opc.SETLC, opc.GETLC, opc.SETUPV, opc.GETUPV\n\t\t\t\tReturn n + \" \" + ra + \", \" + rb\n\t\t\tCase opc.LOADK, opc.LOADSI, opc.LOADBOOL, opc.CLOSURE, opc.RET, opc.POSTCALL, opc.VARARG\n\t\t\t\tReturn n + \" \" + ra + \", \" + c\n\t\t\tDefault ; Return n + \" \" + ra + \", \" + rb + \", \" + c\n\t\tEnd Select\n\tEnd Method\nEnd Type\n\nType BlueBinary\n\tConst MAGICNUMBER:Long = 5642816051412814914:Long\t'BLUEMOON\n\tField out:Int[], buf:Int[]\t'out = output bytestream, buf = input\/readable bytestream\n\t\n\tFunction Make:BlueBinary(file:String, funs:TList)\n\t\tLocal b:BlueBinary = New Self, ktbl:TList = CreateList(), kc:Int = 0\n\t\t\n\t\tLocal binSz:Int = 0, fcount:Int = 0\n\t\tFor Local f:BlueAssembly = EachIn funs\n\t\t\tLocal ki:Int = 0\n\t\t\tFor Local k:String = EachIn f.ktbl\n\t\t\t\tf.kidx[ki] = AddKTblEntry(k, ktbl, kc) ; ki :+ 1\t'consolidate constants into single table\n\t\t\tNext\n\t\t\t\n\t\t\tIf f.framesz > f.MAXVARS - 3 Or f.upvars > f.MAXVARS Then Throw ..\n\t\t\t\tBlueAssemblyError.Make(file, \"too many variables\/temporaries in function #\" + f.id ..\n\t\t\t\t+ \"; consider splitting into more blocks or helper functions\")\n\t\t\t\n\t\t\tbinSz :+ (7 ..\t'id, instruction count, k count, param count, var count, upvar count, frame size\n\t\t\t + 2 * f.upvars ..\t'upvar levels and stack positions (interleaved)\n\t\t\t + f.kc ..\t'constant index table\n\t\t\t + f.inst.Count())\t'instructions\n\t\t\tfcount :+ 1\n\t\tNext\n\t\t\n\t\tbinSz :+ (kc + 1)\n\t\tFor Local k:String = EachIn ktbl\n\t\t\tIf k[0] = \"0\"[0] Then binSz :+ 2 Else binSz :+ Ceil((k.Length - 2) \/ 2.0) + 2\n\t\tNext\n\t\t\n\t\tLocal headerSz:Int = 3 + fcount\t'function count, k count, k table offset, function offset list\n\t\tbinSz :+ headerSz\n\t\t\n\t\tLocal out:Int[] = New Int[binSz] ; b.out = out\n\t\tout[0] = fcount\n\t\tout[1] = kc\n\t\t\n\t\tLocal pos:Int = headerSz, opc:BlueOpcode = New BlueOpcode\n\t\tFor Local f:BlueAssembly = EachIn funs\n\t\t\tout[3 + f.id] = pos\n\t\t\tout[pos] = f.id ; out[pos + 1] = f.inst.Count() ; out[pos + 2] = f.kc ; out[pos + 3] = f.params\n\t\t\tout[pos + 4] = f.vars ; out[pos + 5] = f.upvars ; out[pos + 6] = f.framesz\n\t\t\tpos :+ 7\n\t\t\tFor Local v:Int = 0 Until f.upvars\n\t\t\t\tout[pos] = f.upvarTier[v] ; out[pos + 1] = f.upvarStkPos[v] ; pos :+ 2\n\t\t\tNext\n\t\t\tFor Local k:Int = 0 Until f.kc\n\t\t\t\tout[pos] = f.kidx[k] ; pos :+ 1\n\t\t\tNext\n\t\t\tFor Local i:BlueInstr = EachIn f.inst\n\t\t\t\tout[pos] = BlueOpcode.Make(i) ; pos :+ 1\n\t\t\tNext\n\t\tNext\n\t\t\n\t\tout[2] = pos ; Local ktblpos:Int = pos ; pos :+ (kc + 1)\n\t\tFor Local k:String = EachIn ktbl\n\t\t\tLocal d:Double, dp:Byte Ptr = Varptr(d)\n\t\t\tout[ktblpos] = pos ; ktblpos :+ 1\n\t\t\tIf k[0] = \"0\"[0]\n\t\t\t\td = Double(k[2..])\n\t\t\t\tout[pos] = Int Ptr(dp)[0] ; out[pos + 1] = Int Ptr(dp)[1]\n\t\t\t\tpos :+ 2\n\t\t\tElse\n\t\t\t\td = k.Length - 2\n\t\t\t\tout[pos] = Int Ptr(dp)[0] ; out[pos + 1] = Int Ptr(dp)[1] ; pos :+ 2\n\t\t\t\tIf k.Length Mod 2 = 1 Then k :+ \" \"\t'even the length for ease of writing\n\t\t\t\tFor Local c:Int = 2 Until k.Length Step 2\n\t\t\t\t\tout[pos] = Short(k[c]) | (Short(k[c + 1]) Shl 16) ; pos :+ 1\n\t\t\t\tNext\n\t\t\tEndIf\n\t\tNext\n\t\tout[ktblpos] = pos\n\t\tAssert pos = binSz, \"assembly write error: binary size mismatch (critical compiler error)\"\n\t\t\n\t\tReturn b\n\tEnd Function\n\t\n\tFunction AddKTblEntry:Int(k:String, tbl:TList, kc:Int Var)\n\t\tLocal ki:Int = 0\n\t\tFor Local ek:String = EachIn tbl\n\t\t\tIf ek = k Then Return ki\n\t\t\tki :+ 1\n\t\tNext\n\t\ttbl.AddLast(k) ; kc :+ 1'ktbl.Count()\n\t\tReturn ki\n\tEnd Function\n\t\n\tMethod WriteMemory:Byte Ptr(size:Int Var)\n\t\tsize = out.Length * 8 + 16\n\t\tLocal mem:Byte Ptr = MemAlloc(size)\n\t\tAssert mem, \"failed to allocate memory for instruction buffer\"\n\t\tWrite(CreateRamStream(mem, out.Length * 8 + 16, 0, 1))\n\t\tReturn mem\n\tEnd Method\n\t\n\tMethod WriteObjectFile(filename:String)\n\t\tWrite(WriteFile(filename))\n\tEnd Method\n\t\n\tFunction ReadMemory:BlueBinary(mem:Byte Ptr, size:Int)\n\t\tReturn Read(CreateRamStream(mem, size, 1, 0), \"\", size)\n\tEnd Function\n\t\n\tFunction ReadObjectFile:BlueBinary(filename:String)\n\t\tReturn Read(ReadFile(filename), filename, FileSize(filename))\n\tEnd Function\n\t\n\tFunction Read:BlueBinary(file:TStream, filename:String, sz:Int)\n\t\tLocal b:BlueBinary\n\t\tTry\n\t\t\tLocal opc:BlueOpcode = New BlueOpcode\n\t\t\tLocal corrupt:BlueAssemblyError = BlueAssemblyError.Make(filename, \"not a valid Blue Moon binary file (possibly corrupt)\")\n\t\t\tLocal badInst:BlueError = corrupt.Make(filename, \"invalid Blue Moon instruction (out of bounds error); could not load file\")\n\t\t\tsz :- (8 + 8) ; If sz < 12 Or (sz Mod 4 <> 0) Then Throw corrupt\n\t\t\t\n\t\t\tLocal magic:Long = file.ReadLong() ; If magic <> MAGICNUMBER Then Throw corrupt\n\t\t\tLocal major:Int = file.ReadInt()\n\t\t\tIf major <> BlueMoonVersion.MAJORVERSION Then Throw corrupt.Make(filename, \"incompatible major version of interpreter for bytecode\")\n\t\t\tLocal minor:Int = file.ReadInt()\n\t\t\tIf minor > BlueMoonVersion.MINORVERSION Then Throw corrupt.Make(filename, \"incompatible version of interpreter for bytecode\")\n\t\t\t\n\t\t\tLocal fc:Int = file.ReadInt(), kc:Int = file.ReadInt(), koffs:Int = file.ReadInt(), headerSz:Int = 3 + fc\n\t\t\tsz :\/ 4 ; If sz < headerSz + fc * 7 Or sz < koffs + kc * 3 Then Throw corrupt\n\t\t\t\n\t\t\tLocal bufSz:Int = headerSz + (koffs - headerSz) * 2 + (sz - koffs), buf:Int[bufSz]\n\t\t\tbuf[0] = fc ; buf[1] = kc ; buf[2] = koffs\n\t\t\t\n\t\t\tFor Local fi:Int = 0 Until fc\n\t\t\t\tLocal foff:Int = file.ReadInt() ; If sz < foff Then Throw corrupt\n\t\t\t\tbuf[3 + fi] = headerSz + (foff - headerSz) * 2\n\t\t\tNext\n\t\t\t\n\t\t\tLocal pos:Int = headerSz, sizeExtension:Int = 0\n\t\t\tFor Local fi:Int = 0 Until fc\n\t\t\t'binSz :+ (7 ..\t'id, instruction count, k count, param count, var count, upvar count, frame size\n\t\t\t ' + 2 * f.upvars ..\t'upvar levels and stack positions (interleaved)\n\t\t\t ' + f.kc ..\t'constant index table\n\t\t\t ' + f.inst.Count())\t'instructions\n\t\t\t\tLocal id:Int = file.ReadInt(), icount:Int = file.ReadInt(), kcount:Int = file.ReadInt(), pcount:Int = file.ReadInt()\n\t\t\t\tLocal vars:Int = file.ReadInt(), upvars:Int = file.ReadInt(), framesz:Int = file.ReadInt()\n\t\t\t\tIf pos <> buf[3 + fi] Or id <> fi Or (icount|kcount|pcount|vars|upvars|framesz) < 0 Then Throw corrupt\n\t\t\t\tbuf[pos] = id ; buf[pos + 1] = icount ; buf[pos + 2] = kcount ; buf[pos + 3] = pcount\n\t\t\t\tbuf[pos + 4] = vars ; buf[pos + 5] = upvars ; buf[pos + 6] = framesz ; pos :+ 7\n\t\t\t\tIf (pos - sizeExtension) + 2 * upvars + kcount + icount > sz Then Throw corrupt\n\t\t\t\tsizeExtension :+ (7 + 2 * upvars + kcount + icount) * 2\n\t\t\t\t\n\t\t\t\tFor Local up:Int = 0 Until upvars\n\t\t\t\t\tbuf[pos] = file.ReadInt() ; buf[pos + 1] = file.ReadInt() ; pos :+ 2\n\t\t\t\tNext\n\t\t\t\tFor Local ki:Int = 0 Until kcount\n\t\t\t\t\tbuf[pos] = file.ReadInt()\n\t\t\t\t\tIf buf[pos] >= kc Then Throw corrupt\n\t\t\t\t\tpos :+ 1\n\t\t\t\tNext\n\t\t\t\t\n\t\t\t\tFor Local i:Int = 0 Until icount\n\t\t\t\t\tLocal in:Int = file.ReadInt(), op:Int, ra:Int, rb:Int, c:Int\n\t\t\t\t\tBlueOpcode.Read(in, op, ra, rb, c)\n\t\t\t\t\t\n\t\t\t\t\tSelect op\t\t'verify operation as not going out of bounds!\n\t\t\t\t\t\tCase opc.RETVA\t'ignore\n\t\t\t\t\t\tCase opc.JMP, opc.JNOT, opc.JIF\n\t\t\t\t\t\t\tIf i + c >= icount Or i + c < 0 Then Throw badinst\n\t\t\t\t\t\tCase opc.CALL, opc.TCALL\n\t\t\t\t\t\t\tIf Max(ra, rb + c) >= framesz Or Min(ra, Min(rb, c)) < 0 Then Throw badInst\n\t\t\t\t\t\tCase opc.RET, opc.POSTCALL\n\t\t\t\t\t\t\tIf ra + c >= framesz Or ra < 0 Or c < 0 Then Throw badInst\n\t\t\t\t\t\tCase opc.GETUPV\n\t\t\t\t\t\t\tIf ra >= framesz Or ra < 0 Or rb >= upvars Or rb < 0 Then Throw badInst\n\t\t\t\t\t\tCase opc.SETUPV\n\t\t\t\t\t\t\tIf rb >= framesz Or rb < 0 Or ra >= upvars Or ra < 0 Then Throw badInst\n\t\t\t\t\t\tDefault\n\t\t\t\t\t\t\tIf ra >= framesz Or rb >= framesz Or ra < 0 Or rb < 0 Then Throw badInst\n\t\t\t\t\t\t\tIf (op >= opc.ADD And op <= opc.BSHR) Or (op >= opc.EQ And op <= opc.LEQ)\n\t\t\t\t\t\t\t\tIf c >= framesz Or c < 0 Then Throw badInst\n\t\t\t\t\t\t\tElse\n\t\t\t\t\t\t\t\tSelect op\n\t\t\t\t\t\t\t\t\tCase opc.GETTAB, opc.SETTAB, opc.LOADK\n\t\t\t\t\t\t\t\t\t\tIf c >= kcount Or c < 0 Then Throw badInst\n\t\t\t\t\t\t\t\t\tCase opc.VARARG', opc.VAINIT, opc.CALLINIT\n\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\tCase opc.CLOSURE\n\t\t\t\t\t\t\t\t\t\tIf c >= fc Or c < 0 Then Throw badInst\n\t\t\t\t\t\t\t\tEnd Select\n\t\t\t\t\t\t\tEndIf\n\t\t\t\t\tEnd Select\n\t\t\t\t\t\n\t\t\t\t\tbuf[pos] = op | (ra Shl 8) | (rb Shl 16) ; buf[pos + 1] = c\n\t\t\t\t\tpos :+ 2\n\t\t\t\tNext\n\t\t\t\t\n\t\t\t\tpos :+ (7 + 2 * upvars + kcount)\t'unused space because of buffer doubling\n\t\t\tNext\n\t\t\t\n\t\t\tsizeExtension :\/ 2\n\t\t\tIf pos - sizeExtension <> koffs Then Throw corrupt\n\t\t\tbuf[2] = pos\t'update koffs\n\t\t\tFor Local ki:Int = 0 To kc\t'[sic] - we need to copy the end marker too\n\t\t\t\tLocal koff:Int = file.ReadInt() ; If sz < koff Or koff < koffs + kc + 1 Then Throw corrupt\n\t\t\t\tbuf[pos] = koff + sizeExtension ; pos :+ 1\n\t\t\tNext\n\t\t\tFor Local ki:Int = 0 Until kc\n\t\t\t\tLocal d:Double = file.ReadDouble(), dp:Int Ptr = Int Ptr(Varptr(d))\n\t\t\t\tbuf[pos] = dp[0] ; buf[pos + 1] = dp[1] ; pos :+ 2\n\t\t\t\tIf pos <> buf[koffs + sizeExtension + ki + 1]\t'string\n\t\t\t\t\tFor Local c:Int = 0 Until Ceil(d \/ 2)\n\t\t\t\t\t\tbuf[pos + c] = file.ReadInt()\n\t\t\t\t\tNext\n\t\t\t\t\tpos :+ Ceil(d \/ 2)\n\t\t\t\tEndIf\n\t\t\tNext\n\t\t\t\n\t\t\tb = New Self ; b.buf = buf\n\t\tCatch o:Object\n\t\t\tCloseStream(file) ; Throw o\n\t\tEnd Try\n\t\tCloseStream(file)\n\t\tReturn b\n\tEnd Function\n\t\n\tMethod Write(file:TStream)\n\t\tTry\n\t\t\tfile.WriteLong MAGICNUMBER\n\t\t\tfile.WriteInt BlueMoonVersion.MAJORVERSION ; file.WriteInt BlueMoonVersion.MINORVERSION\n\t\t\tFor Local i:Int = 0 Until out.Length\n\t\t\t\tfile.WriteInt out[i]\n\t\t\tNext\n\t\tCatch o:Object\n\t\t\tCloseStream(file) ; Throw o\n\t\tEnd Try\n\t\tCloseStream(file)\n\tEnd Method\nEnd Type\n\nType BlueAssembly\n\tConst MAXVARS:Int = 255, SI_LIMIT:Int = 131071, VSI_LIMIT:Int = 511\n\tField fd:FunDef, id:Int\n\tField vsp:Int\n\tField ktbl:TList, kc:Int, kidx:Int[]\n\tField inst:TList\n\tField lbl:LabelDef[], gto:GotoDef[]\n\tField params:Int, vars:Int, upvars:Int, framesz:Int, upvarTier:Int[], upvarStkPos:Int[]\n\t\n\tFunction Make:BlueAssembly(fd:FunDef)\n\t\tLocal f:BlueAssembly = New BlueAssembly\n\t\tf.fd = fd ; f.id = fd.id\n\t\tf.params = fd.pcount ; f.vars = fd.vmax ; f.upvars = fd.clos.Length\n\t\tf.vsp = f.vars '+ f.upvars\n\t\tf.upvarTier = New Int[f.upvars] ; f.upvarStkPos = New Int[f.upvars]\n\t\tFor Local v:Int = 0 Until f.upvars\n\t\t\tLocal el:Int = 1, env:FunDef = fd.env\n\t\t\tIf env\n\t\t\t\tf.upvarStkPos[v] = -1\n\t\t\t\tFor Local l:Int = 0 Until env.vars.Length\n\t\t\t\t\tIf env.vars[l] = fd.clos[v] Then f.upvarStkPos[v] = l ; Exit\n\t\t\t\tNext\n\t\t\t\tIf f.upvarStkPos[v] = -1\n\t\t\t\t\tFor Local c:Int = 0 Until env.clos.Length\n\t\t\t\t\t\tIf env.clos[c] = fd.clos[v]\n\t\t\t\t\t\t\tf.upvarTier[v] = 1 ; f.upvarStkPos[v] = c ; Exit\n\t\t\t\t\t\tEndIf\n\t\t\t\t\tNext\n\t\t\t\t\tAssert f.upvarStkPos[v] <> -1, \"compile error: unable to resolve closure (critical compiler error)\"\n\t\t\t\tEndIf\n\t\t\tElse\n\t\t\t\tf.upvarTier[v] = -1 ; f.upvarStkPos[v] = 0\n\t\t\tEndIf\n\t\tNext\n\t\tf.ktbl = CreateList() ; f.kc = 0\n\t\tReturn f\n\tEnd Function\n\t\n\tMethod Push:Int(n:Int = 1)\n\t\tvsp :+ n ; Return vsp - 1\n\tEnd Method\n\tMethod Pop:Int(n:Int = 1)\n\t\tvsp :- n ; Return vsp\n\tEnd Method\n\tMethod Peek:Int()\n\t\tReturn vsp - 1\n\tEnd Method\n\t\n\tMethod GetConst:Int(t:String, val:String)\n\t\tReturn BlueBinary.AddKTblEntry(t + \":\" + val, ktbl, kc)\n\tEnd Method\n\t\n\tMethod ToString:String()\n\t\tLocal s:String = \"F: \" + id + \"~n\"\n\t\ts :+ \" Constants:~n\"\n\t\tFor Local k:String = EachIn ktbl\n\t\t\ts :+ \" \" + k + \"~n\"\n\t\tNext\n\t\ts :+ \" Upvars:~n\"\n\t\tFor Local v:Int = 0 Until upvars\n\t\t\ts :+ \" \" + upvarTier[v] + \"\/\" + upvarStkPos[v] + \"~n\"\n\t\tNext\n\t\ts :+ \" Instructions:~n\"\n\t\tFor Local i:BlueInstr = EachIn inst\n\t\t\ts :+ \" \" + i.ToString() + \"~n\"\n\t\tNext\n\t\tReturn s\n\tEnd Method\n\t\n\tMethod Finish(_inst:TList, opc:BlueOpcode)\n\t\tinst = _inst\n\t\tlbl = LabelDef[](fd._lt.ToArray())\n\t\tgto = GotoDef[](fd._gt.ToArray())\n\t\t\n\t\t' allow closures over parameters\n\t\tFor Local p:Int = params - 1 To 0 Step -1\n\t\t\tIf fd.vars[p].isClosure Then inst.AddFirst(BlueInstr.Make(opc.NEWUPV, fd.vars[p].stkpos, 0))\n\t\tNext\n\t\t\n\t\t' add final return so that jumps don't run off the end\n\t\tinst.AddLast BlueInstr.Make(opc.RET, 0, 0, 0)\n\t\t' remove redundant MOV instructions\n\t\tSelf.ReduceMovs(opc)\n\t\t' resolve targeted jumps and remove dummy target instructions\n\t\tSelf.ResolveJumps(opc)\n\t\t' resolve break jumps and remove dummy target instructions\n\t\tSelf.ResolveBreaks(opc)\n\t\t\n\t\tframesz = vars'upvars + vars\n\t\tFor Local i:BlueInstr = EachIn inst\n\t\t\tSelect i.op\n\t\t\t\tCase opc.JMP, opc.VARARG, opc.VAINIT, opc.CALLINIT, opc.RETVA\t'ignore\n\t\t\t\tCase opc.CALL, opc.TCALL\n\t\t\t\t\tframesz = Max(framesz, Max(i.ra, i.rb + i.c) + 1)\n\t\t\t\tCase opc.RET, opc.POSTCALL\n\t\t\t\t\tframesz = Max(framesz, i.ra + i.c + 1)\n\t\t\t\tDefault\n\t\t\t\t\tframesz = Max(framesz, i.ra + 1)\n\t\t\tEnd Select\n\t\tNext\n\t\t\n\t\tkidx = New Int[kc]\n\t\tfd = Null\n\tEnd Method\n\t\n\tMethod ResolveJumps(opc:BlueOpcode)\n\t\tLocal il:TLink = inst.FirstLink(), i:Int = 0\n\t\tWhile il\n\t\t\tLocal in:BlueInstr = BlueInstr(il.Value())\n\t\t\tIf in.op = opc.MOV And in.ra = 0 And in.rb = 0\n\t\t\t\tLocal lab:LabelDef = lbl[in.c]\n\t\t\t\tlab.insl = il ; lab.insc = i\n\t\t\tElseIf Not (in.op = opc.MOV And in.ra = in.rb)\n\t\t\t\ti :+ 1\n\t\t\tEndIf\n\t\t\til = il.NextLink()\n\t\tWend\n\t\ti = 0 ; il = inst.FirstLink()\n\t\tWhile il\n\t\t\tLocal in:BlueInstr = BlueInstr(il.Value())\n\t\t\tIf (in.op >= opc.JMP And in.op <= opc.JNOT) And in.c >= 0\n\t\t\t\tLocal jmp:GotoDef = gto[in.c]\n\t\t\t\tin.c = jmp.tgt.insc - i ; jmp.tgt.insl.Remove()\n\t\t\tEndIf\n\t\t\tIf Not (in.op = opc.MOV And in.ra = in.rb) Then i :+ 1\n\t\t\til = il.NextLink()\n\t\tWend\n\tEnd Method\n\t\n\tMethod ResolveBreaks(opc:BlueOpcode)\n\t\tLocal il:TLink = inst.FirstLink()\n\t\tWhile il\n\t\t\tLocal in:BlueInstr = BlueInstr(il.Value())\n\t\t\tIf in.op = opc.JMP And in.ra = -1\n\t\t\t\tLocal tgl:TLink = il.NextLink(), cnt:Int = 1\n\t\t\t\tWhile True\n\t\t\t\t\tLocal tgt:BlueInstr = BlueInstr(tgl.Value())\n\t\t\t\t\tIf tgt.op = opc.MOV And tgt.c = -1\n\t\t\t\t\t\tin.ra = 0 ; in.rb = 0 ; in.c = cnt ; Exit\n\t\t\t\t\tEndIf\n\t\t\t\t\ttgl = tgl.NextLink() ; cnt :+ 1\n\t\t\t\tWend\n\t\t\tEndIf\n\t\t\til = il.NextLink()\n\t\tWend\n\t\til = inst.FirstLink()\t'remove break point markers\n\t\tWhile il\n\t\t\tLocal in:BlueInstr = BlueInstr(il.Value())\n\t\t\tIf in.op = opc.MOV And in.c = -1 Then il.Remove()\n\t\t\til = il.NextLink()\n\t\tWend\n\tEnd Method\n\t\n\tMethod ReduceMovs(opc:BlueOpcode)\n\t\tFunction replaceMov1:TLink(ml:TLink Var, in:BlueInstr, ra:Int, rb:Int, c:Int)\t'update a later instruction and then go back to look for more MOVs\n\t\t\tLocal ret:TLink = ml.PrevLink()\t'won't be null\n\t\t\tml.Remove() ; ml = Null\n\t\t\tin.ra = ra ; in.rb = rb ; in.c = c\n\t\t\tReturn ret\n\t\tEnd Function\n\t\t\n\t\t'first MOVs from variables to temps\n\t\tLocal ml:TLink, mov:BlueInstr, il:TLink = inst.FirstLink(), vmax:Int = fd.vmax, tmpStk:Int = vmax' + fd.clos.Length\n\t\tWhile il\n\t\t\tLocal in:BlueInstr = BlueInstr(il.Value())\n\t\t\tIf in.op = opc.MOV\t'if it's a move to temp space and nothing is pending\n\t\t\t\tIf in.ra = in.rb\t'jump target; do not cross\n\t\t\t\t\tml = Null\n\t\t\t\tElseIf ml = Null And in.ra >= tmpStk And in.rb < vmax\n\t\t\t\t\tml = il ; mov = BlueInstr(ml.Value())\n\t\t\t\tElseIf ml <> Null And in.rb = mov.ra And in.ra <> mov.rb\n\t\t\t\t\til = replaceMov1(ml, in, in.ra, mov.rb, in.c)\n\t\t\t\tEndIf\n\t\t\tElseIf ml <> Null\n\t\t\t\tIf in.op >= opc.JMP\t'any control-flow related op cancels\n\t\t\t\t\tIf (in.op = opc.JIF Or in.op = opc.JNOT) And mov.ra = in.ra Then il = replaceMov1(ml, in, mov.rb, in.rb, in.c) Else il = ml\n\t\t\t\t\tml = Null\n\t\t\t\tElseIf in.op = opc.GETTAB Or in.op = opc.GETTABSI Or (in.op >= opc.UNM And in.op <= opc.UNP)\n\t\t\t\t\tIf mov.ra = in.rb Then il = replaceMov1(ml, in, in.ra, mov.rb, in.c)\n\t\t\t\tElseIf in.op = opc.SETTAB Or in.op = opc.SETTABSI\n\t\t\t\t\tIf mov.ra = in.ra Then il = replaceMov1(ml, in, mov.rb, in.rb, in.c)\n\t\t\t\tElseIf in.op = opc.GETTABI Or (in.op >= opc.ADD And in.op < opc.UNM) Or (in.op >= opc.EQ And in.op <= opc.LEQ)\n\t\t\t\t\tIf mov.ra = in.rb\n\t\t\t\t\t\til = replaceMov1(ml, in, in.ra, mov.rb, in.c)\n\t\t\t\t\tElseIf mov.ra = in.c\n\t\t\t\t\t\til = replaceMov1(ml, in, in.ra, in.rb, mov.rb)\n\t\t\t\t\tEndIf\n\t\t\t\tElseIf in.op = opc.SETTABI\n\t\t\t\t\tIf mov.ra = in.ra\n\t\t\t\t\t\til = replaceMov1(ml, in, mov.rb, in.rb, in.c)\n\t\t\t\t\tElseIf mov.ra = in.c\n\t\t\t\t\t\til = replaceMov1(ml, in, in.ra, in.rb, mov.rb)\n\t\t\t\t\tEndIf\n\t\t\t\tEndIf\n\t\t\tEndIf\n\t\t\tIf il = Null Then il = inst.FirstLink()\n\t\t\til = il.NextLink()\n\t\tWend\n\t\tml = Null ; il = inst.LastLink()\t'then MOVs from temps to variables\n\t\tWhile il\n\t\t\tLocal in:BlueInstr = BlueInstr(il.Value())\n\t\t\tIf in.op = opc.MOV\n\t\t\t\tIf in.ra = in.rb\n\t\t\t\t\tml = Null\n\t\t\t\tElseIf ml = Null And in.ra < vmax And in.rb >= tmpStk\n\t\t\t\t\tml = il ; mov = BlueInstr(ml.Value())\n\t\t\t\tEndIf\n\t\t\tElseIf ml <> Null\n\t\t\t\tIf in.op >= opc.JMP\n\t\t\t\t\tml = Null\n\t\t\t\tElseIf in.op = opc.GETTAB Or in.op = opc.GETTABI Or in.op = opc.GETTABSI Or in.op = opc.CLOSURE Or in.op = opc.NEWTAB Or ..\n\t\t\t\t\t\t(in.op >= opc.ADD And in.op <= opc.LEQ) Or (in.op >= opc.LOADK And in.op <= opc.LOADNIL)\n\t\t\t\t\tIf mov.rb = in.ra\n\t\t\t\t\t\til = ml.NextLink()\t'won't be null\n\t\t\t\t\t\tml.Remove() ; ml = Null ; in.ra = mov.ra\n\t\t\t\t\tEndIf\n\t\t\t\tEndIf\n\t\t\tEndIf\n\t\t\til = il.PrevLink()\n\t\tWend\n\tEnd Method\nEnd Type\n\n","old_contents":"\n' Blue Moon\n' Bytecode compiler: accepts program fragments as strings, or program files (and outputs)\n\nSuperStrict\n\nImport \"blueparser.bmx\"\nImport \"blueerror.bmx\"\nImport \"blueversion.bmx\"\nPrivate\nInclude \"TFold.bmx\"\nInclude \"bluefoldsyntax.bmx\"\nInclude \"bluefoldsemantics.bmx\"\nInclude \"bluefoldcodegen.bmx\"\nInclude \"debugfold.bmx\"\nPublic\n\nType BlueCompiler\n\tFunction CompileFile(infile:String, outfile:String = \"\")\n\t\tIf outfile = \"\" Then outfile = infile + \".so\"\n\t\tLocal n:TParseNode = BlueParseFile(infile)\n\t\tLocal compiled:BlueBinary = BlueBinary.Make(infile, ASTToAssembly(n))\n\t\tcompiled.WriteObjectFile(outFile)\n\tEnd Function\n\t\n\tFunction CompileFileForLoad:BlueBinary(infile:String)\n\t\tLocal n:TParseNode = BlueParseFile(infile)\n\t\tLocal code:BlueBinary = BlueBinary.Make(infile, ASTToAssembly(n))\n\t\tLocal sz:Int, mem:Byte Ptr = code.WriteMemory(sz)\n\t\tcode = code.ReadMemory(mem, sz) ; MemFree(mem)\n\t\tReturn code\n\tEnd Function\n\t\n'\tFunction CompileString:BlueBinary(program:String)\n'\t\tLocal n:TParseNode = BlueParseString(program)\n'\t\tReturn BlueBinary.Make(\"\", ASTToAssembly(n))\n'\tEnd Function\n\t\n\tFunction ShowBytecode:String(infile:String)\n\t\tLocal n:TParseNode = BlueParseFile(infile), out:String = infile + \":~n\"\n\t\tLocal assemblies:TList = ASTToAssembly(n)\n\t\tFor Local f:BlueAssembly = EachIn assemblies\n\t\t\tout :+ f.ToString()\n\t\tNext\n\t\tReturn out\n\tEnd Function\n\t\n\tFunction ASTToAssembly:TList(n:TParseNode)\n\t\tLocal tbl:NodeTable = Node.FromParse(n), r:Node = tbl.n\n\t\t\n\t\tr = Node.Fold(r, NormalizeFold.Make(tbl))\n\t\t\n\t\tLocal errf:SyntaxErrFold = SyntaxErrFold.Make(tbl)\n\t\tr = Node.Fold(r, errf) ; errf.BreakCheck()\n\t\t\n\t\tr = Node.Fold(r, New ConstantFold)\n\t\t\n\t\tLocal semf:SemanticFold = SemanticFold.Make(r, tbl)\n\t\tr = Node.Fold(r, semf, Node.BOTH)\t'fold both ways to push and pop environments\n\t\tSemanticFold.Close(semf, r)\n\t\t\n\t\tLocal funs:FunDef[] = FunDef[](semf.funs.ToArray()) ; semf = Null\n\t\t\n\t\t' if we wanted a type checker, it would go here\n\t\ttbl = Null\t'source information no longer needed\n\t\t\n\t\tLocal assemblies:TList = CreateList()\n\t\tFor Local f:FunDef = EachIn funs\n\t\t\tLocal com:CompileFold = CompileFold.Make(BlueAssembly.Make(f))\n\t\t'\tPrint \"F #\" + f.id + \": \" + f.n.ToString()\n\t\t\tLocal inst:TList = BytecodeNode(Node.Fold(f.n, com)).inst\n\t\t\tcom.f.Finish(inst, com.opc)\n\t\t\tassemblies.AddLast(com.f)\n\t\tNext\n\t\t\n\t\t?Debug\n\t\tDebug_KeyListFold.Run(funs, CompileFold.Make(Null))\n\t\t?\n\t\tReturn assemblies\n\tEnd Function\nEnd Type\n\nType BlueOpcode Final\n\tField MOV:Int = 0, GETLC:Int = 1, SETLC:Int = 2\t\t'these are constants, ignore their definition as fields\n\tField LOADK:Int = 3, LOADSI:Int = 4, LOADBOOL:Int = 5, LOADNIL:Int = 6\n\t\n\tField GETTAB:Int = 7, GETTABSI:Int = 8, SETTAB:Int = 9, SETTABSI:Int = 10\n\tField GETTABI:Int = 11, SETTABI:Int = 12, GETUPV:Int = 13, SETUPV:Int = 14\n\tField NEWTAB:Int = 15, CLOSURE:Int = 16, NEWUPV:Int = 17\n\t\n\tField ADD:Int = 18, SUB:Int = 19, MUL:Int = 20, DIV:Int = 21, NMOD:Int = 22, POW:Int = 23, CAT:Int = 24\n\tField IDIV:Int = 25, BAND:Int = 26, BOR:Int = 27, BXOR:Int = 28, BSHL:Int = 29, BSHR:Int = 30\n\tField UNM:Int = 31, LNOT:Int = 32, ALEN:Int = 33, BNOT:Int = 34, UNP:Int = 35\n\tField EQ:Int = 36, LT:Int = 37, LEQ:Int = 38\n\t\n\tField JMP:Int = 39, JIF:Int = 40, JNOT:Int = 41\n\tField CALL:Int = 42, TCALL:Int = 43, RET:Int = 44, RETVA:Int = 45\n\tField POSTCALL:Int = 46, VARARG:Int = 47, VAINIT:Int = 48, CALLINIT:Int = 49\n\t\n\tFunction Make:Int(i:BlueInstr)\n\t\tGlobal opc:BlueOpcode = New Self\n\t\tLocal c:Int = i.c\n\t\tSelect i.op\n\t\t\tCase opc.LOADK, opc.LOADSI, opc.LOADBOOL, opc.LOADNIL, opc.JMP, opc.JIF, opc.JNOT, opc.RET\n\t\t\t\tIf c < 0 Then c :& (Int(2^18) - 1)\n\t\t\t\tReturn i.op | ((i.ra & $FF) Shl 6) | (c Shl 14)\n\t\t\tDefault\n\t\t\t\tIf c < 0 Then c :& (Int(2^10) - 1)\n\t\t\t\tReturn i.op | ((i.ra & $FF) Shl 6) | ((i.rb & $FF) Shl 14) | (c Shl 22)\n\t\tEnd Select\n\tEnd Function\n\tFunction Read(i:Int, op:Int Var, ra:Int Var, rb:Int Var, c:Int Var)\n\t\tGlobal opc:BlueOpcode = New Self\n\t\top = i & %111111 ; ra = (i Shr 6) & $FF\n\t\tSelect op\n\t\t\tCase opc.LOADK, opc.LOADSI, opc.LOADBOOL, opc.LOADNIL, opc.JMP, opc.JIF, opc.JNOT, opc.RET\n\t\t\t\trb = 0 ; c = i Sar 14\t'sign-extend (already MSB)\n\t\t\tDefault\n\t\t\t\trb = (i Shr 14) & $FF ; c = i Sar 22\n\t\tEnd Select\n\tEnd Function\nEnd Type\n\nType BlueInstr\n\tField op:Int, ra:Int, rb:Int, c:Int\n\tFunction Make:BlueInstr(op:Int, ra:Int, rb:Int, c:Int = 0)\n\t\tLocal i:BlueInstr = New BlueInstr ; i.op = op ; i.ra = ra ; i.rb = rb ; i.c = c ; Return i\n\tEnd Function\n\tFunction MakeK:BlueInstr(op:Int, ra:Int, c:Int)\n\t\tReturn Make(op, ra, 0, c)\n\tEnd Function\n\tMethod ToString:String()\n\t\tGlobal opc:BlueOpcode = New BlueOpcode\n\t\tLocal n:String = \"??\"\n\t\tFor Local f:TField = EachIn TTypeId.ForObject(opc).Fields()\n\t\t\tIf f.GetInt(opc) = op Then n = f.Name()[..10] ; Exit\n\t\tNext\n\t\tSelect op\n\t\t\tCase opc.LOADNIL, opc.NEWUPV, opc.NEWTAB\n\t\t\t\tReturn n + \" \" + ra\n\t\t\tCase opc.MOV, opc.SETLC, opc.GETLC, opc.SETUPV, opc.GETUPV\n\t\t\t\tReturn n + \" \" + ra + \", \" + rb\n\t\t\tCase opc.LOADK, opc.LOADSI, opc.LOADBOOL, opc.CLOSURE, opc.RET, opc.POSTCALL, opc.VARARG\n\t\t\t\tReturn n + \" \" + ra + \", \" + c\n\t\t\tDefault ; Return n + \" \" + ra + \", \" + rb + \", \" + c\n\t\tEnd Select\n\tEnd Method\nEnd Type\n\nType BlueBinary\n\tConst MAGICNUMBER:Long = 5642816051412814914:Long\t'BLUEMOON\n\tField out:Int[], buf:Int[]\t'out = output bytestream, buf = input\/readable bytestream\n\t\n\tFunction Make:BlueBinary(file:String, funs:TList)\n\t\tLocal b:BlueBinary = New Self, ktbl:TList = CreateList(), kc:Int = 0\n\t\t\n\t\tLocal binSz:Int = 0, fcount:Int = 0\n\t\tFor Local f:BlueAssembly = EachIn funs\n\t\t\tLocal ki:Int = 0\n\t\t\tFor Local k:String = EachIn f.ktbl\n\t\t\t\tf.kidx[ki] = AddKTblEntry(k, ktbl, kc) ; ki :+ 1\t'consolidate constants into single table\n\t\t\tNext\n\t\t\t\n\t\t\tIf f.framesz > f.MAXVARS - 3 Or f.upvars > f.MAXVARS Then Throw ..\n\t\t\t\tBlueAssemblyError.Make(file, \"too many variables\/temporaries in function #\" + f.id ..\n\t\t\t\t+ \"; consider splitting into more blocks or helper functions\")\n\t\t\t\n\t\t\tbinSz :+ (7 ..\t'id, instruction count, k count, param count, var count, upvar count, frame size\n\t\t\t + 2 * f.upvars ..\t'upvar levels and stack positions (interleaved)\n\t\t\t + f.kc ..\t'constant index table\n\t\t\t + f.inst.Count())\t'instructions\n\t\t\tfcount :+ 1\n\t\tNext\n\t\t\n\t\tbinSz :+ (kc + 1)\n\t\tFor Local k:String = EachIn ktbl\n\t\t\tIf k[0] = \"0\"[0] Then binSz :+ 2 Else binSz :+ Ceil((k.Length - 2) \/ 2.0) + 2\n\t\tNext\n\t\t\n\t\tLocal headerSz:Int = 3 + fcount\t'function count, k count, k table offset, function offset list\n\t\tbinSz :+ headerSz\n\t\t\n\t\tLocal out:Int[] = New Int[binSz] ; b.out = out\n\t\tout[0] = fcount\n\t\tout[1] = kc\n\t\t\n\t\tLocal pos:Int = headerSz, opc:BlueOpcode = New BlueOpcode\n\t\tFor Local f:BlueAssembly = EachIn funs\n\t\t\tout[3 + f.id] = pos\n\t\t\tout[pos] = f.id ; out[pos + 1] = f.inst.Count() ; out[pos + 2] = f.kc ; out[pos + 3] = f.params\n\t\t\tout[pos + 4] = f.vars ; out[pos + 5] = f.upvars ; out[pos + 6] = f.framesz\n\t\t\tpos :+ 7\n\t\t\tFor Local v:Int = 0 Until f.upvars\n\t\t\t\tout[pos] = f.upvarTier[v] ; out[pos + 1] = f.upvarStkPos[v] ; pos :+ 2\n\t\t\tNext\n\t\t\tFor Local k:Int = 0 Until f.kc\n\t\t\t\tout[pos] = f.kidx[k] ; pos :+ 1\n\t\t\tNext\n\t\t\tFor Local i:BlueInstr = EachIn f.inst\n\t\t\t\tout[pos] = BlueOpcode.Make(i) ; pos :+ 1\n\t\t\tNext\n\t\tNext\n\t\t\n\t\tout[2] = pos ; Local ktblpos:Int = pos ; pos :+ (kc + 1)\n\t\tFor Local k:String = EachIn ktbl\n\t\t\tLocal d:Double, dp:Byte Ptr = Varptr(d)\n\t\t\tout[ktblpos] = pos ; ktblpos :+ 1\n\t\t\tIf k[0] = \"0\"[0]\n\t\t\t\td = Double(k[2..])\n\t\t\t\tout[pos] = Int Ptr(dp)[0] ; out[pos + 1] = Int Ptr(dp)[1]\n\t\t\t\tpos :+ 2\n\t\t\tElse\n\t\t\t\td = k.Length - 2\n\t\t\t\tout[pos] = Int Ptr(dp)[0] ; out[pos + 1] = Int Ptr(dp)[1] ; pos :+ 2\n\t\t\t\tIf k.Length Mod 2 = 1 Then k :+ \" \"\t'even the length for ease of writing\n\t\t\t\tFor Local c:Int = 2 Until k.Length Step 2\n\t\t\t\t\tout[pos] = Short(k[c]) | (Short(k[c + 1]) Shl 16) ; pos :+ 1\n\t\t\t\tNext\n\t\t\tEndIf\n\t\tNext\n\t\tout[ktblpos] = pos\n\t\tAssert pos = binSz, \"assembly write error: binary size mismatch (critical compiler error)\"\n\t\t\n\t\tReturn b\n\tEnd Function\n\t\n\tFunction AddKTblEntry:Int(k:String, tbl:TList, kc:Int Var)\n\t\tLocal ki:Int = 0\n\t\tFor Local ek:String = EachIn tbl\n\t\t\tIf ek = k Then Return ki\n\t\t\tki :+ 1\n\t\tNext\n\t\ttbl.AddLast(k) ; kc :+ 1'ktbl.Count()\n\t\tReturn ki\n\tEnd Function\n\t\n\tMethod WriteMemory:Byte Ptr(size:Int Var)\n\t\tsize = out.Length * 8 + 16\n\t\tLocal mem:Byte Ptr = MemAlloc(size)\n\t\tAssert mem, \"failed to allocate memory for instruction buffer\"\n\t\tWrite(CreateRamStream(mem, out.Length * 8 + 16, 0, 1))\n\t\tReturn mem\n\tEnd Method\n\t\n\tMethod WriteObjectFile(filename:String)\n\t\tWrite(WriteFile(filename))\n\tEnd Method\n\t\n\tFunction ReadMemory:BlueBinary(mem:Byte Ptr, size:Int)\n\t\tReturn Read(CreateRamStream(mem, size, 1, 0), \"\", size)\n\tEnd Function\n\t\n\tFunction ReadObjectFile:BlueBinary(filename:String)\n\t\tReturn Read(ReadFile(filename), filename, FileSize(filename))\n\tEnd Function\n\t\n\tFunction Read:BlueBinary(file:TStream, filename:String, sz:Int)\n\t\tLocal b:BlueBinary\n\t\tTry\n\t\t\tLocal opc:BlueOpcode = New BlueOpcode\n\t\t\tLocal corrupt:BlueAssemblyError = BlueAssemblyError.Make(filename, \"not a valid Blue Moon binary file (possibly corrupt)\")\n\t\t\tLocal badInst:BlueError = corrupt.Make(filename, \"invalid Blue Moon instruction (out of bounds error); could not load file\")\n\t\t\tsz :- (8 + 8) ; If sz < 12 Or (sz Mod 4 <> 0) Then Throw corrupt\n\t\t\t\n\t\t\tLocal magic:Long = file.ReadLong() ; If magic <> MAGICNUMBER Then Throw corrupt\n\t\t\tLocal major:Int = file.ReadInt()\n\t\t\tIf major <> BlueMoonVersion.MAJORVERSION Then Throw corrupt.Make(filename, \"incompatible major version of interpreter for bytecode\")\n\t\t\tLocal minor:Int = file.ReadInt()\n\t\t\tIf minor > BlueMoonVersion.MINORVERSION Then Throw corrupt.Make(filename, \"incompatible version of interpreter for bytecode\")\n\t\t\t\n\t\t\tLocal fc:Int = file.ReadInt(), kc:Int = file.ReadInt(), koffs:Int = file.ReadInt(), headerSz:Int = 3 + fc\n\t\t\tsz :\/ 4 ; If sz < headerSz + fc * 7 Or sz < koffs + kc * 3 Then Throw corrupt\n\t\t\t\n\t\t\tLocal bufSz:Int = headerSz + (koffs - headerSz) * 2 + (sz - koffs), buf:Int[bufSz]\n\t\t\tbuf[0] = fc ; buf[1] = kc ; buf[2] = koffs\n\t\t\t\n\t\t\tFor Local fi:Int = 0 Until fc\n\t\t\t\tLocal foff:Int = file.ReadInt() ; If sz < foff Then Throw corrupt\n\t\t\t\tbuf[3 + fi] = headerSz + (foff - headerSz) * 2\n\t\t\tNext\n\t\t\t\n\t\t\tLocal pos:Int = headerSz, sizeExtension:Int = 0\n\t\t\tFor Local fi:Int = 0 Until fc\n\t\t\t'binSz :+ (7 ..\t'id, instruction count, k count, param count, var count, upvar count, frame size\n\t\t\t ' + 2 * f.upvars ..\t'upvar levels and stack positions (interleaved)\n\t\t\t ' + f.kc ..\t'constant index table\n\t\t\t ' + f.inst.Count())\t'instructions\n\t\t\t\tLocal id:Int = file.ReadInt(), icount:Int = file.ReadInt(), kcount:Int = file.ReadInt(), pcount:Int = file.ReadInt()\n\t\t\t\tLocal vars:Int = file.ReadInt(), upvars:Int = file.ReadInt(), framesz:Int = file.ReadInt()\n\t\t\t\tIf pos <> buf[3 + fi] Or id <> fi Or (icount|kcount|pcount|vars|upvars|framesz) < 0 Then Throw corrupt\n\t\t\t\tbuf[pos] = id ; buf[pos + 1] = icount ; buf[pos + 2] = kcount ; buf[pos + 3] = pcount\n\t\t\t\tbuf[pos + 4] = vars ; buf[pos + 5] = upvars ; buf[pos + 6] = framesz ; pos :+ 7\n\t\t\t\tIf (pos - sizeExtension) + 2 * upvars + kcount + icount > sz Then Throw corrupt\n\t\t\t\tsizeExtension :+ (7 + 2 * upvars + kcount + icount) * 2\n\t\t\t\t\n\t\t\t\tFor Local up:Int = 0 Until upvars\n\t\t\t\t\tbuf[pos] = file.ReadInt() ; buf[pos + 1] = file.ReadInt() ; pos :+ 2\n\t\t\t\tNext\n\t\t\t\tFor Local ki:Int = 0 Until kcount\n\t\t\t\t\tbuf[pos] = file.ReadInt()\n\t\t\t\t\tIf buf[pos] >= kc Then Throw corrupt\n\t\t\t\t\tpos :+ 1\n\t\t\t\tNext\n\t\t\t\t\n\t\t\t\tFor Local i:Int = 0 Until icount\n\t\t\t\t\tLocal in:Int = file.ReadInt(), op:Int, ra:Int, rb:Int, c:Int\n\t\t\t\t\tBlueOpcode.Read(in, op, ra, rb, c)\n\t\t\t\t\t\n\t\t\t\t\tSelect op\t\t'verify operation as not going out of bounds!\n\t\t\t\t\t\tCase opc.RETVA\t'ignore\n\t\t\t\t\t\tCase opc.JMP, opc.JNOT, opc.JIF\n\t\t\t\t\t\t\tIf i + c >= icount Or i + c < 0 Then Throw badinst\n\t\t\t\t\t\tCase opc.CALL, opc.TCALL\n\t\t\t\t\t\t\tIf Max(ra, rb + c) >= framesz Or Min(ra, Min(rb, c)) < 0 Then Throw badInst\n\t\t\t\t\t\tCase opc.RET, opc.POSTCALL\n\t\t\t\t\t\t\tIf ra + c >= framesz Or ra < 0 Or c < 0 Then Throw badInst\n\t\t\t\t\t\tCase opc.GETUPV\n\t\t\t\t\t\t\tIf ra >= framesz Or ra < 0 Or rb >= upvars Or rb < 0 Then Throw badInst\n\t\t\t\t\t\tCase opc.SETUPV\n\t\t\t\t\t\t\tIf rb >= framesz Or rb < 0 Or ra >= upvars Or ra < 0 Then Throw badInst\n\t\t\t\t\t\tDefault\n\t\t\t\t\t\t\tIf ra >= framesz Or rb >= framesz Or ra < 0 Or rb < 0 Then Throw badInst\n\t\t\t\t\t\t\tIf (op >= opc.ADD And op <= opc.BSHR) Or (op >= opc.EQ And op <= opc.LEQ)\n\t\t\t\t\t\t\t\tIf c >= framesz Or c < 0 Then Throw badInst\n\t\t\t\t\t\t\tElse\n\t\t\t\t\t\t\t\tSelect op\n\t\t\t\t\t\t\t\t\tCase opc.GETTAB, opc.SETTAB, opc.LOADK\n\t\t\t\t\t\t\t\t\t\tIf c >= kcount Or c < 0 Then Throw badInst\n\t\t\t\t\t\t\t\t\tCase opc.VARARG', opc.VAINIT, opc.CALLINIT\n\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\tCase opc.CLOSURE\n\t\t\t\t\t\t\t\t\t\tIf c >= fc Or c < 0 Then Throw badInst\n\t\t\t\t\t\t\t\tEnd Select\n\t\t\t\t\t\t\tEndIf\n\t\t\t\t\tEnd Select\n\t\t\t\t\t\n\t\t\t\t\tbuf[pos] = op | (ra Shl 8) | (rb Shl 16) ; buf[pos + 1] = c\n\t\t\t\t\tpos :+ 2\n\t\t\t\tNext\n\t\t\t\t\n\t\t\t\tpos :+ (7 + 2 * upvars + kcount)\t'unused space because of buffer doubling\n\t\t\tNext\n\t\t\t\n\t\t\tsizeExtension :\/ 2\n\t\t\tIf pos - sizeExtension <> koffs Then Throw corrupt\n\t\t\tbuf[2] = pos\t'update koffs\n\t\t\tFor Local ki:Int = 0 To kc\t'[sic] - we need to copy the end marker too\n\t\t\t\tLocal koff:Int = file.ReadInt() ; If sz < koff Or koff < koffs + kc + 1 Then Throw corrupt\n\t\t\t\tbuf[pos] = koff + sizeExtension ; pos :+ 1\n\t\t\tNext\n\t\t\tFor Local ki:Int = 0 Until kc\n\t\t\t\tLocal d:Double = file.ReadDouble(), dp:Int Ptr = Int Ptr(Varptr(d))\n\t\t\t\tbuf[pos] = dp[0] ; buf[pos + 1] = dp[1] ; pos :+ 2\n\t\t\t\tIf pos <> buf[koffs + sizeExtension + ki + 1]\t'string\n\t\t\t\t\tFor Local c:Int = 0 Until Ceil(d \/ 2)\n\t\t\t\t\t\tbuf[pos + c] = file.ReadInt()\n\t\t\t\t\tNext\n\t\t\t\t\tpos :+ Ceil(d \/ 2)\n\t\t\t\tEndIf\n\t\t\tNext\n\t\t\t\n\t\t\tb = New Self ; b.buf = buf\n\t\tCatch o:Object\n\t\t\tCloseStream(file) ; Throw o\n\t\tEnd Try\n\t\tCloseStream(file)\n\t\tReturn b\n\tEnd Function\n\t\n\tMethod Write(file:TStream)\n\t\tTry\n\t\t\tfile.WriteLong MAGICNUMBER\n\t\t\tfile.WriteInt BlueMoonVersion.MAJORVERSION ; file.WriteInt BlueMoonVersion.MINORVERSION\n\t\t\tFor Local i:Int = 0 Until out.Length\n\t\t\t\tfile.WriteInt out[i]\n\t\t\tNext\n\t\tCatch o:Object\n\t\t\tCloseStream(file) ; Throw o\n\t\tEnd Try\n\t\tCloseStream(file)\n\tEnd Method\nEnd Type\n\nType BlueAssembly\n\tConst MAXVARS:Int = 255, SI_LIMIT:Int = 131071, VSI_LIMIT:Int = 511\n\tField fd:FunDef, id:Int\n\tField vsp:Int\n\tField ktbl:TList, kc:Int, kidx:Int[]\n\tField inst:TList\n\tField lbl:LabelDef[], gto:GotoDef[]\n\tField params:Int, vars:Int, upvars:Int, framesz:Int, upvarTier:Int[], upvarStkPos:Int[]\n\t\n\tFunction Make:BlueAssembly(fd:FunDef)\n\t\tLocal f:BlueAssembly = New BlueAssembly\n\t\tf.fd = fd ; f.id = fd.id\n\t\tf.params = fd.pcount ; f.vars = fd.vmax ; f.upvars = fd.clos.Length\n\t\tf.vsp = f.vars '+ f.upvars\n\t\tf.upvarTier = New Int[f.upvars] ; f.upvarStkPos = New Int[f.upvars]\n\t\tFor Local v:Int = 0 Until f.upvars\n\t\t\tLocal el:Int = 1, env:FunDef = fd.env\n\t\t\tIf env\n\t\t\t\tf.upvarStkPos[v] = -1\n\t\t\t\tFor Local l:Int = 0 Until env.vars.Length\n\t\t\t\t\tIf env.vars[l] = fd.clos[v] Then f.upvarStkPos[v] = l ; Exit\n\t\t\t\tNext\n\t\t\t\tIf f.upvarStkPos[v] = -1\n\t\t\t\t\tFor Local c:Int = 0 Until env.clos.Length\n\t\t\t\t\t\tIf env.clos[c] = fd.clos[v]\n\t\t\t\t\t\t\tf.upvarTier[v] = 1 ; f.upvarStkPos[v] = c ; Exit\n\t\t\t\t\t\tEndIf\n\t\t\t\t\tNext\n\t\t\t\t\tAssert f.upvarStkPos[v] <> -1, \"compile error: unable to resolve closure (critical compiler error)\"\n\t\t\t\tEndIf\n\t\t\tElse\n\t\t\t\tf.upvarTier[v] = -1 ; f.upvarStkPos[v] = 0\n\t\t\tEndIf\n\t\tNext\n\t\tf.ktbl = CreateList() ; f.kc = 0\n\t\tReturn f\n\tEnd Function\n\t\n\tMethod Push:Int(n:Int = 1)\n\t\tvsp :+ n ; Return vsp - 1\n\tEnd Method\n\tMethod Pop:Int(n:Int = 1)\n\t\tvsp :- n ; Return vsp\n\tEnd Method\n\tMethod Peek:Int()\n\t\tReturn vsp - 1\n\tEnd Method\n\t\n\tMethod GetConst:Int(t:String, val:String)\n\t\tReturn BlueBinary.AddKTblEntry(t + \":\" + val, ktbl, kc)\n\tEnd Method\n\t\n\tMethod ToString:String()\n\t\tLocal s:String = \"F: \" + id + \"~n\"\n\t\ts :+ \" Constants:~n\"\n\t\tFor Local k:String = EachIn ktbl\n\t\t\ts :+ \" \" + k + \"~n\"\n\t\tNext\n\t\ts :+ \" Upvars:~n\"\n\t\tFor Local v:Int = 0 Until upvars\n\t\t\ts :+ \" \" + upvarTier[v] + \"\/\" + upvarStkPos[v] + \"~n\"\n\t\tNext\n\t\ts :+ \" Instructions:~n\"\n\t\tFor Local i:BlueInstr = EachIn inst\n\t\t\ts :+ \" \" + i.ToString() + \"~n\"\n\t\tNext\n\t\tReturn s\n\tEnd Method\n\t\n\tMethod Finish(_inst:TList, opc:BlueOpcode)\n\t\tinst = _inst\n\t\tlbl = LabelDef[](fd._lt.ToArray())\n\t\tgto = GotoDef[](fd._gt.ToArray())\n\t\t\n\t\t' allow closures over parameters\n\t\tFor Local p:Int = params - 1 To 0 Step -1\n\t\t\tIf fd.vars[p].isClosure Then inst.AddFirst(BlueInstr.Make(opc.NEWUPV, fd.vars[p].stkpos, 0))\n\t\tNext\n\t\t\n\t\t' add final return so that jumps don't run off the end\n\t\tinst.AddLast BlueInstr.Make(opc.RET, 0, 0, 0)\n\t\t' remove redundant MOV instructions\n\t\tSelf.ReduceMovs(opc)\n\t\t' resolve targeted jumps and remove dummy target instructions\n\t\tSelf.ResolveJumps(opc)\n\t\t' resolve break jumps and remove dummy target instructions\n\t\tSelf.ResolveBreaks(opc)\n\t\t\n\t\tframesz = vars'upvars + vars\n\t\tFor Local i:BlueInstr = EachIn inst\n\t\t\tSelect i.op\n\t\t\t\tCase opc.JMP, opc.VARARG, opc.VAINIT, opc.CALLINIT, opc.RETVA\t'ignore\n\t\t\t\tCase opc.CALL, opc.TCALL\n\t\t\t\t\tframesz = Max(framesz, Max(i.ra, i.rb + i.c) + 1)\n\t\t\t\tCase opc.RET, opc.POSTCALL\n\t\t\t\t\tframesz = Max(framesz, i.ra + i.c + 1)\n\t\t\t\tDefault\n\t\t\t\t\tframesz = Max(framesz, i.ra + 1)\n\t\t\tEnd Select\n\t\tNext\n\t\t\n\t\tkidx = New Int[kc]\n\t\tfd = Null\n\tEnd Method\n\t\n\tMethod ResolveJumps(opc:BlueOpcode)\n\t\tLocal il:TLink = inst.FirstLink(), i:Int = 0\n\t\tWhile il\n\t\t\tLocal in:BlueInstr = BlueInstr(il.Value())\n\t\t\tIf in.op = opc.MOV And in.ra = 0 And in.rb = 0\n\t\t\t\tLocal lab:LabelDef = lbl[in.c]\n\t\t\t\tlab.insl = il ; lab.insc = i\n\t\t\tElseIf Not (in.op = opc.MOV And in.ra = in.rb)\n\t\t\t\ti :+ 1\n\t\t\tEndIf\n\t\t\til = il.NextLink()\n\t\tWend\n\t\ti = 0 ; il = inst.FirstLink()\n\t\tWhile il\n\t\t\tLocal in:BlueInstr = BlueInstr(il.Value())\n\t\t\tIf (in.op >= opc.JMP And in.op <= opc.JNOT) And in.c >= 0\n\t\t\t\tLocal jmp:GotoDef = gto[in.c]\n\t\t\t\tin.c = jmp.tgt.insc - i ; jmp.tgt.insl.Remove()\n\t\t\tEndIf\n\t\t\tIf Not (in.op = opc.MOV And in.ra = in.rb) Then i :+ 1\n\t\t\til = il.NextLink()\n\t\tWend\n\tEnd Method\n\t\n\tMethod ResolveBreaks(opc:BlueOpcode)\n\t\tLocal il:TLink = inst.FirstLink()\n\t\tWhile il\n\t\t\tLocal in:BlueInstr = BlueInstr(il.Value())\n\t\t\tIf in.op = opc.JMP And in.ra = -1\n\t\t\t\tLocal tgl:TLink = il.NextLink(), cnt:Int = 1\n\t\t\t\tWhile True\n\t\t\t\t\tLocal tgt:BlueInstr = BlueInstr(tgl.Value())\n\t\t\t\t\tIf tgt.op = opc.MOV And tgt.c = -1\n\t\t\t\t\t\tin.ra = 0 ; in.rb = 0 ; in.c = cnt ; Exit\n\t\t\t\t\tEndIf\n\t\t\t\t\ttgl = tgl.NextLink() ; cnt :+ 1\n\t\t\t\tWend\n\t\t\tEndIf\n\t\t\til = il.NextLink()\n\t\tWend\n\t\til = inst.FirstLink()\t'remove break point markers\n\t\tWhile il\n\t\t\tLocal in:BlueInstr = BlueInstr(il.Value())\n\t\t\tIf in.op = opc.MOV And in.c = -1 Then il.Remove()\n\t\t\til = il.NextLink()\n\t\tWend\n\tEnd Method\n\t\n\tMethod ReduceMovs(opc:BlueOpcode)\n\t\tFunction replaceMov1:TLink(ml:TLink Var, in:BlueInstr, ra:Int, rb:Int, c:Int)\t'update a later instruction and then go back to look for more MOVs\n\t\t\tLocal ret:TLink = ml.PrevLink()\t'won't be null\n\t\t\tml.Remove() ; ml = Null\n\t\t\tin.ra = ra ; in.rb = rb ; in.c = c\n\t\t\tReturn ret\n\t\tEnd Function\n\t\t\n\t\t'first MOVs from variables to temps\n\t\tLocal ml:TLink, mov:BlueInstr, il:TLink = inst.FirstLink(), vmax:Int = fd.vmax, tmpStk:Int = vmax' + fd.clos.Length\n\t\tWhile il\n\t\t\tLocal in:BlueInstr = BlueInstr(il.Value())\n\t\t\tIf in.op = opc.MOV\t'if it's a move to temp space and nothing is pending\n\t\t\t\tIf in.ra = in.rb\t'jump target; do not cross\n\t\t\t\t\tml = Null\n\t\t\t\tElseIf ml = Null And in.ra >= tmpStk And in.rb < vmax\n\t\t\t\t\tml = il ; mov = BlueInstr(ml.Value())\n\t\t\t\tElseIf ml <> Null And in.rb = mov.ra And in.ra <> mov.rb\n\t\t\t\t\til = replaceMov1(ml, in, in.ra, mov.rb, in.c)\n\t\t\t\tEndIf\n\t\t\tElseIf ml <> Null\n\t\t\t\tIf in.op >= opc.JMP\t'any control-flow related op cancels\n\t\t\t\t\tIf (in.op = opc.JIF Or in.op = opc.JNOT) And mov.ra = in.ra Then il = replaceMov1(ml, in, mov.rb, in.rb, in.c) Else il = ml\n\t\t\t\t\tml = Null\n\t\t\t\tElseIf in.op = opc.GETTAB Or in.op = opc.GETTABSI Or (in.op >= opc.UNM And in.op <= opc.UNP)\n\t\t\t\t\tIf mov.ra = in.rb Then il = replaceMov1(ml, in, in.ra, mov.rb, in.c)\n\t\t\t\tElseIf in.op = opc.SETTAB Or in.op = opc.SETTABSI\n\t\t\t\t\tIf mov.ra = in.ra Then il = replaceMov1(ml, in, mov.rb, in.rb, in.c)\n\t\t\t\tElseIf in.op = opc.GETTABI Or (in.op >= opc.ADD And in.op < opc.UNM) Or (in.op >= opc.EQ And in.op <= opc.LEQ)\n\t\t\t\t\tIf mov.ra = in.rb\n\t\t\t\t\t\til = replaceMov1(ml, in, in.ra, mov.rb, in.c)\n\t\t\t\t\tElseIf mov.ra = in.c\n\t\t\t\t\t\til = replaceMov1(ml, in, in.ra, in.rb, mov.rb)\n\t\t\t\t\tEndIf\n\t\t\t\tElseIf in.op = opc.SETTABI\n\t\t\t\t\tIf mov.ra = in.ra\n\t\t\t\t\t\til = replaceMov1(ml, in, mov.rb, in.rb, in.c)\n\t\t\t\t\tElseIf mov.ra = in.c\n\t\t\t\t\t\til = replaceMov1(ml, in, in.ra, in.rb, mov.rb)\n\t\t\t\t\tEndIf\n\t\t\t\tEndIf\n\t\t\tEndIf\n\t\t\tIf il = Null Then il = inst.FirstLink()\n\t\t\til = il.NextLink()\n\t\tWend\n\t\tml = Null ; il = inst.LastLink()\t'then MOVs from temps to variables\n\t\tWhile il\n\t\t\tLocal in:BlueInstr = BlueInstr(il.Value())\n\t\t\tIf in.op = opc.MOV\n\t\t\t\tIf in.ra = in.rb\n\t\t\t\t\tml = Null\n\t\t\t\tElseIf ml = Null And in.ra < vmax And in.rb >= tmpStk\n\t\t\t\t\tml = il ; mov = BlueInstr(ml.Value())\n\t\t\t\tEndIf\n\t\t\tElseIf ml <> Null\n\t\t\t\tIf in.op >= opc.JMP\n\t\t\t\t\tml = Null\n\t\t\t\tElseIf in.op = opc.GETTAB Or in.op = opc.GETTABI Or in.op = opc.GETTABSI Or in.op = opc.CLOSURE Or ..\n\t\t\t\t\t\t(in.op >= opc.ADD And in.op <= opc.LEQ) Or (in.op >= opc.LOADK And in.op <= opc.LOADNIL)\n\t\t\t\t\tIf mov.rb = in.ra\n\t\t\t\t\t\til = ml.NextLink()\t'won't be null\n\t\t\t\t\t\tml.Remove() ; ml = Null ; in.ra = mov.ra\n\t\t\t\t\tEndIf\n\t\t\t\tEndIf\n\t\t\tEndIf\n\t\t\til = il.PrevLink()\n\t\tWend\n\tEnd Method\nEnd Type\n\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"dff32bb8cc36ef0ac4de7a6c384225b30b0454e9","subject":"type.bmx: * Implemented most of the code for building information for exposed types\/methods\/fields.","message":"type.bmx:\n* Implemented most of the code for building information for exposed types\/methods\/fields.","repos":"nilium\/lugi.mod,nilium\/lugi.mod","old_file":"Generator\/type.bmx","new_file":"Generator\/type.bmx","new_contents":"SuperStrict\n\nImport \"field.bmx\"\nImport \"method.bmx\"\nImport \"metadata.bmx\"\n\nImport Brl.LinkedList\n\nPrivate\n\nGlobal _exposedTypes:TList = New TList\n\nPublic\n\nType LExposedType\n\tField exposed%\n\tField static%\n\tField noclass%\n\tField hidefields%\n\tField nonew%\n\t\n\tField typeid:TTypeId\n\tField methods:TList\t\t\t' TList\n\tField fields:TList\t\t\t' TList\n\tField constructor$\n\tField name$\n\t\n\t' Returns an LExposedType for a typeid - recommended to use this instead of creating a new LExposedType and initializing it\n\tFunction ForType:LExposedType(typeid:TTypeId)\n\t\tIf typeid = ObjectTypeId Or typeid = StringTypeId Or typeid._class = ArrayTypeId._class Then\n\t\t\tReturn Null\n\t\tEndIf\n\t\t\n\t\tLocal link:TLink = _exposedTypes.FindLink(typeid)\n\t\tIf link Then\n\t\t\tReturn LExposedType(link.Value())\n\t\tEndIf\n\t\tReturn New LExposedType.InitWithTypeID(typeid)\n\tEnd Function\n\t\n\t' Compares LExposedTypes based on the TTypeId associated with each LExposedType\n\tMethod Compare:Int(other:Object)\n\t\tLocal ot:LExposedType = LExposedType(other)\n\t\tIf other = Null Then\n\t\t\tReturn 1\n\t\tElseIf TTypeId(other) Then\n\t\t\tReturn typeid.Compare(other)\n\t\tElseIf other And Not ot Then\n\t\t\tThrow \"Invalid type to compare LExposedType against\"\n\t\tElse\n\t\t\tReturn typeid.Compare(ot.typeid)\n\t\tEndIf\n\tEnd Method\n\t\n\t' Returns a list of exposed types to iterate over\n\tFunction EnumTypes:TList()\n\t\tReturn _exposedTypes.Copy()\n\tEnd Function\n\t\n\t' Initializes an LExposedType with information for the type passed\n\t' The object returned may not be the one you originally sent the initialize message to\n\t' If there is already an instance for this type, that instance will be returned instead\n\t' of proceeding with intialization\n\tMethod InitWithTypeID:LExposedType(tid:TTypeId)\n\t\tIf tid = ObjectTypeId Or tid = StringTypeId Or tid._class = ArrayTypeId._class Then\n\t\t\tReturn Null\n\t\tEndIf\n\t\t\n\t\tLocal lnk:TLink = _exposedTypes.FindLink(tid)\n\t\tIf lnk Then\n\t\t\tReturn LExposedType(lnk.Value())\n\t\tEndIf\n\t\t\n\t\ttypeid = tid\n\t\t\n\t\texposed = typeid.Metadata(LUGI_META_EXPOSE).ToInt()>0\n\t\t\n\t\tIf Not exposed Then\n\t\t\tReturn Null\n\t\tEndIf\n\t\t\n\t\tDebugLog \"Building type info for \"+tid.Name()\n\t\t\n\t\tstatic = typeid.Metadata(LUGI_META_STATIC).ToInt()>0\n\t\tnoclass = typeid.Metadata(LUGI_META_NOCLASS).ToInt()>0\n\t\thidefields = typeid.Metadata(LUGI_META_HIDEFIELDS).ToInt()>0\n\t\tnonew = typeid.Metadata(LUGI_META_DISABLECONSTRUCTOR).ToInt()>0\n\t\t\n\t\tname = typeid.Metadata(LUGI_META_RENAME).Trim()\n\t\tIf Not name Then\n\t\t\tname = typeid.Name()\n\t\tEndIf\n\t\t\n\t\tIf Not (nonew Or (static and noclass)) Then\n\t\t\tconstructor = typeid.Metadata(LUGI_META_CONSTRUCTOR).Trim()\n\t\t\tIf Not constructor Then\n\t\t\t\t' Force New[A-Z_].* as default\n\t\t\t\tconstructor = \"New\"+name[0..1].ToUpper()+name[1..]\n\t\t\tEndIf\n\t\tEndIf\n\t\t\n\t\t__initMethods\n\t\t__initFields\n\t\t\n\t\t_exposedTypes.AddLast(Self)\n\t\t\n\t\tReturn Self\n\tEnd Method\n\t\n\tMethod PreInitBlock:String()\n\t\tIf Not exposed Then\n\t\t\tReturn Null\n\t\tEndIf\n\t\t\n\t\tLocal outs$=\"\"\n\t\t\n\t\tDebugLog \"Pre-init block for \"+typeid.Name()\n\t\t\n\t\tIf Not (static And noclass) Then\n\t\t\tDebugLog \"Instance methods\"\n\t\t\tFor Local m:LExposedMethod = EachIn methods\n\t\t\t\tLocal initString$ = m.PreInitBlock()\n\t\t\t\tIf initString Then\n\t\t\t\t\touts :+ \"~t\" + initString + \"~n\"\n\t\t\t\tEndIf\n\t\t\tNext\n\t\tEndIf\n\t\t\n\t\tIf Not noclass Then\n\t\t\tDebugLog \"Fields\"\n\t\t\tFor Local f:LExposedField = EachIn fields\n\t\t\t\tLocal initString$ = f.PreInitBlock()\n\t\t\t\tIf initString Then\n\t\t\t\t\touts :+ \"~t\" + initString + \"~n\"\n\t\t\t\tEndIf\n\t\t\tNext\n\t\tEndIf\n\t\t\n\t\tReturn outs\n\tEnd Method\n\t\n\tMethod PostInitBlock:String()\n\t\tIf Not exposed Then\n\t\t\tReturn Null\n\t\tEndIf\n\t\t\n\t\tDebugLog \"Post-init block for \"+typeid.Name()\n\t\t\n\t\tIf Not (nonew Or (static And noclass)) Then\n\t\t\tReturn \t\"~tlua_pushlightuserdata lua_vm, Byte Ptr(TTypeId.ForName(~q\" + typeid.Name() + \"~q)._class)~n\" + ..\n\t\t\t\t\t\"~tlua_pushcclosure lua_vm, p_lugi_new_object, 1~n\"\n\t\tElseIf static And Not noclass Then\n\t\t\tReturn\t\"~t\"\n\t\tEndIf\n\tEnd Method\n\t\n\tMethod MethodImplementations:String()\n\t\tIf Not exposed Then\n\t\t\tReturn Null\n\t\tEndIf\n\t\t\n\t\tDebugLog \"Method implementations for \"+typeid.Name()\n\t\t\n\t\tLocal m:LExposedMethod\n\t\tLocal outs$\n\t\tLocal instMethod% = Not (static And noclass)\n\t\tLocal block$\n\t\t\n\t\tFor m = EachIn methods\n\t\t\tLocal parentImp:LExposedMethod = __methodExposedInParent(m)\n\t\t\t\n\t\t\tIf m <> parentImp Then\n\t\t\t\tContinue\n\t\t\tEndIf\n\t\t\t\n\t\t\tblock = m.Implementation(instMethod)\n\t\t\tIf block Then\n\t\t\t\touts :+ \"~n\"+block+\"~n\"\n\t\t\tEndIf\n\t\tNext\n\t\t\n\t\tReturn outs\n\tEnd Method\n\t\n\tMethod __methodExposedInParent:LExposedMethod(current:LExposedMethod)\n\t\tLocal name$ = current.methodid.Name().ToLower()\n\t\t\n\t\tLocal typ:TTypeId = typeid.SuperType()\n\t\tLocal parentImp:LExposedMethod\n\t\tWhile typ\n\t\t\tLocal exp:LExposedType = ForType(typ)\n\t\t\t\n\t\t\tIf exp Then\n\t\t\t\tFor Local m:LExposedMethod = EachIn exp.methods\n\t\t\t\t\tIf m.methodid.Name().ToLower() = name Then\n\t\t\t\t\t\tparentImp = m\n\t\t\t\t\t\tExit\t' go onto next parent\n\t\t\t\t\tEndIf\n\t\t\t\tNext\n\t\t\tEndIf\n\t\t\t\n\t\t\ttyp = typ.SuperType()\n\t\tWend\n\t\t\n\t\tIf Not parentImp Then\n\t\t\tReturn current\n\t\tElse\n\t\t\tReturn parentImp\n\t\tEndIf\n\tEnd Method\n\t\n\tMethod __initMethods()\n\t\tmethods = New TList\n\t\t\n\t\tIf Not exposed Then\n\t\t\tReturn\n\t\tEndIf\n\t\t\n\t\t' Build list of exposed methods\n\t\tFor Local m:TMethod = EachIn typeid.Methods()\n\t\t\tIf \"sendmessage^compare^new^delete^tostring\".Find(m.Name().ToLower()) = -1 Then\n\t\t\t\tmethods.AddLast(New LExposedMethod.InitWithMethod(m, typeid))\n\t\t\tEndIf\n\t\tNext\n\tEnd Method\n\t\n\tMethod __initFields()\n\t\tfields = New TList\n\t\t\n\t\tIf Not exposed Or hidefields Then\n\t\t\tReturn\n\t\tEndIf\n\t\t\n\t\t' Build list of exposed fields\n\t\tFor Local f:TField = EachIn typeid.Fields()\n\t\t\tfields.AddLast(New LExposedField.InitWithField(f, typeid))\n\t\tNext\n\tEnd Method\nEnd Type\n\n' Builds up the information for all types\nFunction BuildTypeInfo()\n\tDebugLog \"Building type info...\"\n\tTTypeID._Update()\n\t_buildTypeInfo(ObjectTypeId.DerivedTypes())\nEnd Function\n\nPrivate\n\n' Recursively creates the information for types\nFunction _buildTypeInfo(types:TList)\n\t' Iterate over types and load data for them\n\tFor Local tid:TTypeId = EachIn types\n\t\tNew LExposedType.InitWithTypeID(tid)\n\t\t_buildTypeInfo(tid.DerivedTypes())\n\tNext\nEnd Function\n","old_contents":"SuperStrict\n\nImport \"field.bmx\"\nImport \"method.bmx\"\nImport \"metadata.bmx\"\n\nImport Brl.LinkedList\n\nPrivate\n\nGlobal _exposedTypes:TList = New TList\n\nPublic\n\nType LExposedType\n\tField exposed%\n\tField static%\n\tField noclass%\n\tField hidefields%\n\tField nonew%\n\t\n\tField typeid:TTypeId\n\tField methods:TList\t\t\t' TList\n\tField fields:TList\t\t\t' TList\n\tField constructor$\n\tField name$\n\t\n\t' Returns an LExposedType for a typeid - recommended to use this instead of creating a new LExposedType and initializing it\n\tFunction ForType:LExposedType(typeid:TTypeId)\n\t\tIf typeid = ObjectTypeId Or typeid = StringTypeId Or typeid._class = ArrayTypeId._class Then\n\t\t\tReturn Null\n\t\tEndIf\n\t\t\n\t\tLocal link:TLink = _exposedTypes.FindLink(typeid)\n\t\tIf link Then\n\t\t\tReturn LExposedType(link.Value())\n\t\tEndIf\n\t\tReturn New LExposedType.InitWithTypeID(typeid)\n\tEnd Function\n\t\n\t' Compares LExposedTypes based on the TTypeId associated with each LExposedType\n\tMethod Compare:Int(other:Object)\n\t\tLocal ot:LExposedType = LExposedType(other)\n\t\tIf other = Null Then\n\t\t\tReturn 1\n\t\tElseIf TTypeId(other) Then\n\t\t\tReturn typeid.Compare(other)\n\t\tElseIf other And Not ot Then\n\t\t\tThrow \"Invalid type to compare LExposedType against\"\n\t\tElse\n\t\t\tReturn typeid.Compare(ot.typeid)\n\t\tEndIf\n\tEnd Method\n\t\n\t' Returns a list of exposed types to iterate over\n\tFunction EnumTypes:TList()\n\t\tReturn _exposedTypes.Copy()\n\tEnd Function\n\t\n\t' Initializes an LExposedType with information for the type passed\n\t' The object returned may not be the one you originally sent the initialize message to\n\t' If there is already an instance for this type, that instance will be returned instead\n\t' of proceeding with intialization\n\tMethod InitWithTypeID:LExposedType(tid:TTypeId)\n\t\tIf tid = ObjectTypeId Or tid = StringTypeId Or tid._class = ArrayTypeId._class Then\n\t\t\tReturn Null\n\t\tEndIf\n\t\t\n\t\tLocal lnk:TLink = _exposedTypes.FindLink(tid)\n\t\tIf lnk Then\n\t\t\tReturn LExposedType(lnk.Value())\n\t\tEndIf\n\t\t\n\t\texposed = typeid.Metadata(LUGI_META_EXPOSE).ToInt()>0\n\t\tstatic = typeid.Metadata(LUGI_META_STATIC).ToInt()>0\n\t\tnoclass = typeid.Metadata(LUGI_META_NOCLASS).ToInt()>0\n\t\thidefields = typeid.Metadata(LUGI_META_HIDEFIELDS).ToInt()>0\n\t\tnonew = typeid.Metadata(LUGI_META_DISABLECONSTRUCTOR).ToInt()>0\n\t\t\n\t\tname = typeid.Metadata(LUGI_META_RENAME).Trim()\n\t\tIf Not name Then\n\t\t\tname = typeid.Name()\n\t\tEndIf\n\t\t\n\t\tIf Not (nonew Or (static and noclass)) Then\n\t\t\tconstructor = typeid.Metadata(LUGI_META_CONSTRUCTOR).Trim()\n\t\t\tIf Not constructor Then\n\t\t\t\t' Force New[A-Z_].* as default\n\t\t\t\tconstructor = \"New\"+name[0..1].ToUpper()+name[1..]\n\t\t\tEndIf\n\t\tEndIf\n\t\t\n\t\t__initMethods\n\t\t__initFields\n\t\t\n\t\t_exposedTypes.AddLast(Self)\n\t\t\n\t\tReturn Self\n\tEnd Method\n\t\n\tMethod PreInitBlock:String()\n\t\tLocal outs$=\"\"\n\t\t\n\t\tIf Not (static And noclass) Then\n\t\t\tFor Local m:LExposedMethod = EachIn methods\n\t\t\t\tLocal initString$ = m.PreInitBlock()\n\t\t\t\tIf initString Then\n\t\t\t\t\touts :+ \"~t\" + initString + \"~n\"\n\t\t\t\tEndIf\n\t\t\tNext\n\t\tEndIf\n\t\t\n\t\tIf Not noclass Then\n\t\t\tFor Local f:LExposedField = EachIn fields\n\t\t\t\tLocal initString$ = f.PreInitBlock()\n\t\t\t\tIf initString Then\n\t\t\t\t\touts :+ \"~t\" + initString + \"~n\"\n\t\t\t\tEndIf\n\t\t\tNext\n\t\tEndIf\n\t\t\n\t\tReturn outs\n\tEnd Method\n\t\n\tMethod PostInitBlock:String()\n\t\tIf Not (nonew Or (static And noclass)) Then\n\t\t\tReturn \t\"~tlua_pushlightuserdata lua_vm, Byte Ptr(TTypeId.ForName(~q\" + typeid.Name() + \"~q)._class)\" + ..\n\t\t\t\t\t\"~tlua_pushcclosure lua_vm, p_lugi_new_object, 1\"\n\t\tElseIf static And Not noclass Then\n\t\t\tReturn\t\"~t\"\n\t\tEndIf\n\tEnd Method\n\t\n\tMethod MethodImplementations:String()\n\t\tLocal m:LExposedMethod\n\t\tLocal outs$\n\t\tLocal instMethod% = Not (static And noclass)\n\t\tLocal block$\n\t\t\n\t\tFor m = EachIn methods\n\t\t\tblock = m.Implementation(instMethod)\n\t\t\tIf block Then\n\t\t\t\touts :+ \"~n~n\"+block\n\t\t\tEndIf\n\t\tNext\n\t\t\n\t\tReturn outs\n\tEnd Method\n\t\n\tMethod _exposedInParent:Int(m:TMethod)\n\t\tLocal name$ = m.Name().ToLower()\n\t\t\n\t\tLocal typ:TTypeId = typeid.SuperType()\n\t\tWhile typ\n\t\t\t\n\t\tWend\n\tEnd Method\n\t\n\tMethod __initMethods()\n\t\tmethods = New TList\n\t\t\n\t\tIf Not exposed Then\n\t\t\tReturn\n\t\tEndIf\n\t\t\n\t\t' Build list of exposed methods\n\t\tFor Local m:TMethod = EachIn typeid.Methods()\n\t\t\t\n\t\tNext\n\tEnd Method\n\t\n\tMethod __initFields()\n\t\tfields = New TList\n\t\t\n\t\tIf Not exposed Or hidefields Then\n\t\t\tReturn\n\t\tEndIf\n\t\t\n\t\tFor Local f:TField = EachIn typeid.Fields()\n\t\t\t\n\t\tNext\n\tEnd Method\nEnd Type\n\n' Builds up the information for all types\nFunction BuildTypeInfo()\nEnd Function\n\nPrivate\n\n' Recursively creates the information for types\nFunction _buildTypeInfo(types:TList)\n\t' Iterate over types and load data for them\n\tFor Local tid:TTypeId = EachIn types\n\t\tNew LExposedType.InitWithTypeID(tid)\n\t\t_buildTypeInfo(tid.DerivedTypes())\n\tNext\nEnd Function\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"9c4e87c2b41c6e7714af6c857ea3fc909b995d2b","subject":"Changed sample to use FX constant instead of number.","message":"Changed sample to use FX constant instead of number.\n","repos":"kfprimm\/maxb3d,kfprimm\/maxb3d","old_file":"doc\/samples\/mak\/dragon.bmx","new_file":"doc\/samples\/mak\/dragon.bmx","new_contents":"\nStrict\n\nImport MaxB3D.Drivers\nImport MaxB3D.MD2Loader\n\nGraphics 800,600\n\nLocal room_texture:TTexture=LoadTexture( \"media\/chorme-2.bmp\" )\nSetTextureScale room_texture,1.0\/3,1.0\/3\n\nLocal room:TMesh=CreateCube()\nSetEntityTexture room,room_texture\nSetEntityAlpha room,.4\nSetEntityFX room,FX_FULLBRIGHT\nFitMesh room,-250,0,-250,500,500,500\nFlipMesh room\n\n'Local mirror:TMirror=CreateMirror()\n\nLocal light:TLight=CreateLight()\nTurnEntity light,45,45,0\n\nLocal camera:TCamera=CreateCamera()\nLocal cam_xr#=30,cam_yr#=0,cam_zr#=0,cam_z#=-100\n\nLocal dragon_texture:TTexture=LoadTexture( \"media\/dragon.bmp\" )\nLocal dragon:TMesh=LoadMesh( \"media\/dragon.md2\" )\nSetEntityTexture dragon,dragon_texture\nSetEntityPosition dragon,0,25,0\nTurnEntity dragon,0,150,0\n\nLocal anim:TAnimSeq[8]\nanim[0]=CreateAnimSeq(0,40,\"Idle\")\nanim[1]=CreateAnimSeq(40,46,\"Run\")\nanim[2]=CreateAnimSeq(46,54,\"Attack\")\nanim[3]=CreateAnimSeq(54,58,\"Pain A\")\nanim[4]=CreateAnimSeq(58,62,\"Pain B\")\nanim[5]=CreateAnimSeq(62,66,\"Pain C\")\nanim[6]=CreateAnimSeq(66,72,\"Jump\")\nanim[7]=CreateAnimSeq(72,84,\"Flip\")\n\nSetMeshAnim dragon,anim[0],ANIMATION_LOOP,.05\nLocal curr_anim\n\nWhile Not KeyHit(KEY_ESCAPE) And Not AppTerminate()\n\tFor Local i=0 To anim.length-1\n\t\tIf KeyHit(KEY_1+i)\n\t\t\tSetMeshAnim dragon,anim[i],ANIMATION_LOOP,.05\n\t\t\tcurr_anim=i\n\t\tEndIf\n\tNext\n\t\n\tIf KeyDown(KEY_LEFT)\n\t\tcam_yr=cam_yr-2\n\tElse If KeyDown(KEY_RIGHT)\n\t\tcam_yr=cam_yr+2\n\tEndIf\n\t\n\tIf KeyDown(KEY_UP)\n\t\tcam_xr=cam_xr+2\n\t\tIf cam_xr>90 cam_xr=90\n\tElse If KeyDown(KEY_DOWN)\n\t\tcam_xr=cam_xr-2\n\t\tIf cam_xr<5 cam_xr=5\n\tEndIf\n\t\n\tIf KeyDown(KEY_S)\n\t\tcam_zr=cam_zr+2\n\tElse If KeyDown(KEY_X)\n\t\tcam_zr=cam_zr-2\n\tEndIf\n\t\n\tIf KeyDown(KEY_A)\n\t\tcam_z=cam_z+1;If cam_z>-10 cam_z=-10\n\tElse If KeyDown(KEY_Z)\n\t\tcam_z=cam_z-1;If cam_z<-180 cam_z=-180\n\tEndIf\n\t\n\tSetEntityPosition camera,0,0,0\n\tSetEntityRotation camera,cam_xr,cam_yr,cam_zr\n\tMoveEntity camera,0,0,cam_z\n\n\tUpdateWorld\n\tLocal info:TRenderInfo=RenderWorld()\n\tDoMax2D\n\tDrawText \"Use arrows keys to pan, A\/Z to zoom\",0,0\n\tDrawText \"FPS: \"+info.FPS,0,15\n\tDrawText \"Current animation: \"+GetAnimSeqName(anim[curr_anim]),0,30\n\t\n\tFlip\nWend\n","old_contents":"\nStrict\n\nImport MaxB3D.Drivers\nImport MaxB3D.MD2Loader\n\nGraphics 800,600\n\nLocal room_texture:TTexture=LoadTexture( \"media\/chorme-2.bmp\" )\nSetTextureScale room_texture,1.0\/3,1.0\/3\n\nLocal room:TMesh=CreateCube()\nSetEntityTexture room,room_texture\nSetEntityAlpha room,.4\nSetEntityFX room,1\nFitMesh room,-250,0,-250,500,500,500\nFlipMesh room\n\n'Local mirror:TMirror=CreateMirror()\n\nLocal light:TLight=CreateLight()\nTurnEntity light,45,45,0\n\nLocal camera:TCamera=CreateCamera()\nLocal cam_xr#=30,cam_yr#=0,cam_zr#=0,cam_z#=-100\n\nLocal dragon_texture:TTexture=LoadTexture( \"media\/dragon.bmp\" )\nLocal dragon:TMesh=LoadMesh( \"media\/dragon.md2\" )\nSetEntityTexture dragon,dragon_texture\nSetEntityPosition dragon,0,25,0\nTurnEntity dragon,0,150,0\n\nLocal anim:TAnimSeq[8]\nanim[0]=CreateAnimSeq(0,40,\"Idle\")\nanim[1]=CreateAnimSeq(40,46,\"Run\")\nanim[2]=CreateAnimSeq(46,54,\"Attack\")\nanim[3]=CreateAnimSeq(54,58,\"Pain A\")\nanim[4]=CreateAnimSeq(58,62,\"Pain B\")\nanim[5]=CreateAnimSeq(62,66,\"Pain C\")\nanim[6]=CreateAnimSeq(66,72,\"Jump\")\nanim[7]=CreateAnimSeq(72,84,\"Flip\")\n\nSetMeshAnim dragon,anim[0],ANIMATION_LOOP,.05\nLocal curr_anim\n\nWhile Not KeyHit(KEY_ESCAPE) And Not AppTerminate()\n\tFor Local i=0 To anim.length-1\n\t\tIf KeyHit(KEY_1+i)\n\t\t\tSetMeshAnim dragon,anim[i],ANIMATION_LOOP,.05\n\t\t\tcurr_anim=i\n\t\tEndIf\n\tNext\n\t\n\tIf KeyDown(KEY_LEFT)\n\t\tcam_yr=cam_yr-2\n\tElse If KeyDown(KEY_RIGHT)\n\t\tcam_yr=cam_yr+2\n\tEndIf\n\t\n\tIf KeyDown(KEY_UP)\n\t\tcam_xr=cam_xr+2\n\t\tIf cam_xr>90 cam_xr=90\n\tElse If KeyDown(KEY_DOWN)\n\t\tcam_xr=cam_xr-2\n\t\tIf cam_xr<5 cam_xr=5\n\tEndIf\n\t\n\tIf KeyDown(KEY_S)\n\t\tcam_zr=cam_zr+2\n\tElse If KeyDown(KEY_X)\n\t\tcam_zr=cam_zr-2\n\tEndIf\n\t\n\tIf KeyDown(KEY_A)\n\t\tcam_z=cam_z+1;If cam_z>-10 cam_z=-10\n\tElse If KeyDown(KEY_Z)\n\t\tcam_z=cam_z-1;If cam_z<-180 cam_z=-180\n\tEndIf\n\t\n\tSetEntityPosition camera,0,0,0\n\tSetEntityRotation camera,cam_xr,cam_yr,cam_zr\n\tMoveEntity camera,0,0,cam_z\n\n\tUpdateWorld\n\tLocal info:TRenderInfo=RenderWorld()\n\tDoMax2D\n\tDrawText \"Use arrows keys to pan, A\/Z to zoom\",0,0\n\tDrawText \"FPS: \"+info.FPS,0,15\n\tDrawText \"Current animation: \"+GetAnimSeqName(anim[curr_anim]),0,30\n\t\n\tFlip\nWend\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"af419d2b95e899f9dcc603ef981dd1a482faea66","subject":"Small TCamera.Unproject mod.","message":"Small TCamera.Unproject mod.\n","repos":"kfprimm\/maxb3d,kfprimm\/maxb3d","old_file":"core.mod\/camera.bmx","new_file":"core.mod\/camera.bmx","new_contents":"\nStrict\n\nImport \"entity.bmx\"\nImport \"worldconfig.bmx\"\n\nConst CAMMODE_NONE\t= 0\nConst CAMMODE_PERSP\t= 1\nConst CAMMODE_ORTHO\t= 2\n\nConst CLSMODE_COLOR\t= 1\nConst CLSMODE_DEPTH\t= 2\n\nConst FOGMODE_NONE\t\t= 0\nConst FOGMODE_LINEAR\t= 1\n\nType TCamera Extends TEntity\n\tField _projmode\n\tField _fogmode,_fogr#,_fogg#,_fogb#,_fognear#,_fogfar#\n\tField _viewx,_viewy,_viewwidth,_viewheight\n\tField _clsmode,_near#,_far#\n\tField _zoom#\n\t\n\tField _lastmodelview:TMatrix=New TMatrix\n\tField _lastprojection:TMatrix=New TMatrix\n\tField _lastviewport[4]\n\tField _lastfrustum:TFrustum\n\t\n\tMethod New()\n\t\tSetMode CAMMODE_PERSP\n\t\tSetFogMode FOGMODE_NONE\n\t\tSetFogRange 1,1000\n\t\tSetViewport 0,0,WorldConfig.Width,WorldConfig.Height\n\t\tSetClsMode CLSMODE_COLOR|CLSMODE_DEPTH\n\t\tSetColor 0,0,0\n\t\tSetRange 1,1000\n\t\tSetZoom 1.0\n\tEnd Method\n\t\n\tMethod Copy:TCamera(parent:TEntity=Null)\n\t\tLocal camera:TCamera=New TCamera\n\t\tcamera.SetMode _projmode\n\t\tcamera.SetFogMode _fogmode\n\t\tcamera.SetFogColor _fogr*255.0,_fogg*255.0,_fogb*255.0\n\t\tcamera.SetFogRange _fognear,_fogfar\n\t\tcamera.SetViewport _viewx,_viewy,_viewwidth,_viewheight\n\t\tcamera.SetClsMode _clsmode\n\t\tcamera.SetRange _near,_far\n\t\tcamera.SetZoom _zoom\n\t\tReturn camera\n\tEnd Method\n\t\n\tMethod GetMode()\n\t\tReturn _projmode\n\tEnd Method\n\tMethod SetMode(mode)\n\t\t_projmode=mode\n\tEnd Method\t\n\t\n\tMethod GetFogMode()\n\t\tReturn _fogmode\n\tEnd Method\n\tMethod SetFogMode(mode)\n\t\t_fogmode=mode\n\tEnd Method\n\t\n\tMethod GetFogColor(red Var,green Var,blue Var)\n\t\tred=_fogr*255.0;green=_fogg*255.0;blue=_fogb*255.0\n\tEnd Method\n\tMethod SetFogColor(red,green,blue)\n\t\t_fogr=red\/255.0;_fogg=green\/255.0;_fogb=blue\/255.0\n\tEnd Method\n\t\n\tMethod GetFogRange(near# Var,far# Var)\n\t\tnear=_fognear;far=_fogfar\n\tEnd Method\n\tMethod SetFogRange(near#,far#)\n\t\t_fognear=Max(near,0);_fogfar=Max(far,0.001)\n\tEnd Method\n\t\n\tMethod GetViewport(x Var,y Var,width Var,height Var)\n\t\tx=_viewx;y=_viewy;width=_viewwidth;height=_viewheight\n\tEnd Method\n\tMethod SetViewport(x,y,width,height)\n\t\t_viewx=x;_viewy=y;_viewwidth=width;_viewheight=height\n\tEnd Method\n\t\n\tMethod GetClsMode()\n\t\tReturn _clsmode\n\tEnd Method\n\tMethod SetClsMode(mode)\n\t\t_clsmode=mode\n\tEnd Method\n\t\n\tMethod GetRange(near# Var,far# Var)\n\t\tnear=_near;far=_far\n\tEnd Method\n\tMethod SetRange(near#,far#)\n\t\t_near=near;_far=far\n\tEnd Method\t\n\t\n\tMethod GetZoom#()\n\t\tReturn _zoom\n\tEnd Method\n\tMethod SetZoom(zoom#)\n\t\t_zoom=zoom\n\tEnd Method\n\t\n\tMethod GetEye:TRay()\n\t\tLocal x#,y#,z#,dx#,dy#,dz#=1.0,o:TVector,d:TVector\n\t\tGetPosition x,y,z,True\n\t\t_matrix.TransformVec3 dx,dy,dz\n\t\tReturn New TRay.Create(New TVector.Create3(x,y,z),New TVector.Create3(dx-x,dy-y,dz-x))\t\t\n\tEnd Method\n\t\n\tMethod Project(target:Object,x# Var,y# Var, offset#[] = Null)\n\t\tLocal z#\n\t\tTEntity.GetTargetPosition target,x,y,z\n\t\t\n\t\tIf offset\n\t\t x :+ offset[0]\n\t\t y :+ offset[1]\n\t\t z :+ offset[2]\n\t\tEndIf\n\t\t\n\t\tLocal w#=1.0\n\t _lastmodelview.TransformVec4 x,y,z,w\n\t _lastprojection.TransformVec4 x,y,z,w\n\t If w=0 Return False\n\t x:\/w;y:\/w;z:\/w\n\t \n\t x=x*0.5+0.5;y=-y*0.5+0.5;z=z*0.5+0.5;\n\t\n\t x=x*_lastviewport[2]+_lastviewport[0]\n\t y=y*_lastviewport[3]+_lastviewport[1]\n\t\tReturn True\n\tEnd Method\n\t\n\tMethod Unproject(wx#,wy#,wz#,x# Var,y# Var,z# Var)\n\t\tLocal matrix:TMatrix=_lastprojection.Multiply(_lastmodelview).Inverse()\n\t\t\n\t\tx=(wx-_lastviewport[0])*2\/_lastviewport[2] - 1.0\n\t\ty=(wy-_lastviewport[1])*2\/_lastviewport[3] - 1.0\n\t\tz=2*wz-1.0\n\t\tLocal w#=1.0\n\t\t\t\t\n\t\tmatrix.TransformVec4 x,y,z,w\n\t\tIf w=0 Return False\n\t\t\n\t\tx:\/w;y:\/w;z:\/w\n\t\tReturn True\n\tEnd Method\n\t\n\tMethod InView#(target:Object)\n\t\tLocal x#,y#,z#,radius#\n\t\tLocal entity:TEntity=TEntity(target),point#[]=Float[](target)\n\t\tIf entity\n\t\t\tentity.GetCullParams x,y,z,radius\n\t\tElse\n\t\t\tx=point[0];y=point[1];z=point[2];radius=point[3]\n\t\tEndIf\n\t\tReturn _lastfrustum.IntersectsPoint(x,y,z,radius)\n\tEnd Method\nEnd Type\n","old_contents":"\nStrict\n\nImport \"entity.bmx\"\nImport \"worldconfig.bmx\"\n\nConst CAMMODE_NONE\t= 0\nConst CAMMODE_PERSP\t= 1\nConst CAMMODE_ORTHO\t= 2\n\nConst CLSMODE_COLOR\t= 1\nConst CLSMODE_DEPTH\t= 2\n\nConst FOGMODE_NONE\t\t= 0\nConst FOGMODE_LINEAR\t= 1\n\nType TCamera Extends TEntity\n\tField _projmode\n\tField _fogmode,_fogr#,_fogg#,_fogb#,_fognear#,_fogfar#\n\tField _viewx,_viewy,_viewwidth,_viewheight\n\tField _clsmode,_near#,_far#\n\tField _zoom#\n\t\n\tField _lastmodelview:TMatrix=New TMatrix\n\tField _lastprojection:TMatrix=New TMatrix\n\tField _lastviewport[4]\n\tField _lastfrustum:TFrustum\n\t\n\tMethod New()\n\t\tSetMode CAMMODE_PERSP\n\t\tSetFogMode FOGMODE_NONE\n\t\tSetFogRange 1,1000\n\t\tSetViewport 0,0,WorldConfig.Width,WorldConfig.Height\n\t\tSetClsMode CLSMODE_COLOR|CLSMODE_DEPTH\n\t\tSetColor 0,0,0\n\t\tSetRange 1,1000\n\t\tSetZoom 1.0\n\tEnd Method\n\t\n\tMethod Copy:TCamera(parent:TEntity=Null)\n\t\tLocal camera:TCamera=New TCamera\n\t\tcamera.SetMode _projmode\n\t\tcamera.SetFogMode _fogmode\n\t\tcamera.SetFogColor _fogr*255.0,_fogg*255.0,_fogb*255.0\n\t\tcamera.SetFogRange _fognear,_fogfar\n\t\tcamera.SetViewport _viewx,_viewy,_viewwidth,_viewheight\n\t\tcamera.SetClsMode _clsmode\n\t\tcamera.SetRange _near,_far\n\t\tcamera.SetZoom _zoom\n\t\tReturn camera\n\tEnd Method\n\t\n\tMethod GetMode()\n\t\tReturn _projmode\n\tEnd Method\n\tMethod SetMode(mode)\n\t\t_projmode=mode\n\tEnd Method\t\n\t\n\tMethod GetFogMode()\n\t\tReturn _fogmode\n\tEnd Method\n\tMethod SetFogMode(mode)\n\t\t_fogmode=mode\n\tEnd Method\n\t\n\tMethod GetFogColor(red Var,green Var,blue Var)\n\t\tred=_fogr*255.0;green=_fogg*255.0;blue=_fogb*255.0\n\tEnd Method\n\tMethod SetFogColor(red,green,blue)\n\t\t_fogr=red\/255.0;_fogg=green\/255.0;_fogb=blue\/255.0\n\tEnd Method\n\t\n\tMethod GetFogRange(near# Var,far# Var)\n\t\tnear=_fognear;far=_fogfar\n\tEnd Method\n\tMethod SetFogRange(near#,far#)\n\t\t_fognear=Max(near,0);_fogfar=Max(far,0.001)\n\tEnd Method\n\t\n\tMethod GetViewport(x Var,y Var,width Var,height Var)\n\t\tx=_viewx;y=_viewy;width=_viewwidth;height=_viewheight\n\tEnd Method\n\tMethod SetViewport(x,y,width,height)\n\t\t_viewx=x;_viewy=y;_viewwidth=width;_viewheight=height\n\tEnd Method\n\t\n\tMethod GetClsMode()\n\t\tReturn _clsmode\n\tEnd Method\n\tMethod SetClsMode(mode)\n\t\t_clsmode=mode\n\tEnd Method\n\t\n\tMethod GetRange(near# Var,far# Var)\n\t\tnear=_near;far=_far\n\tEnd Method\n\tMethod SetRange(near#,far#)\n\t\t_near=near;_far=far\n\tEnd Method\t\n\t\n\tMethod GetZoom#()\n\t\tReturn _zoom\n\tEnd Method\n\tMethod SetZoom(zoom#)\n\t\t_zoom=zoom\n\tEnd Method\n\t\n\tMethod GetEye:TRay()\n\t\tLocal x#,y#,z#,dx#,dy#,dz#=1.0,o:TVector,d:TVector\n\t\tGetPosition x,y,z,True\n\t\t_matrix.TransformVec3 dx,dy,dz\n\t\tReturn New TRay.Create(New TVector.Create3(x,y,z),New TVector.Create3(dx-x,dy-y,dz-x))\t\t\n\tEnd Method\n\t\n\tMethod Project(target:Object,x# Var,y# Var, offset#[] = Null)\n\t\tLocal z#\n\t\tTEntity.GetTargetPosition target,x,y,z\n\t\t\n\t\tIf offset\n\t\t x :+ offset[0]\n\t\t y :+ offset[1]\n\t\t z :+ offset[2]\n\t\tEndIf\n\t\t\n\t\tLocal w#=1.0\n\t _lastmodelview.TransformVec4 x,y,z,w\n\t _lastprojection.TransformVec4 x,y,z,w\n\t If w=0 Return False\n\t x:\/w;y:\/w;z:\/w\n\t \n\t x=x*0.5+0.5;y=-y*0.5+0.5;z=z*0.5+0.5;\n\t\n\t x=x*_lastviewport[2]+_lastviewport[0]\n\t y=y*_lastviewport[3]+_lastviewport[1]\n\t\tReturn True\n\tEnd Method\n\t\n\tMethod Unproject(wx#,wy#,wz#,x# Var,y# Var,z# Var)\n\t\tLocal matrix:TMatrix=_lastmodelview.Multiply(_lastprojection).Inverse()\n\t\t\n\t\tLocal w#=1.0\n\t\tx=wx;y=_lastviewport[3] - wy;z=wz\n\t\t\n\t\tx=(x-_lastviewport[0])\/_lastviewport[2]\n\t\ty=(y-_lastviewport[1])\/_lastviewport[3]\n\t\t\n\t\tx=x*2-1;y=y*2-1;z=z*2-1\n\t\t\n\t\tmatrix.TransformVec4 x,y,z,w\n\t\tIf w=0 Return False\n\t\t\n\t\tx:\/w;y:\/w;z:\/w\n\t\tReturn True\n\tEnd Method\n\t\n\tMethod InView#(target:Object)\n\t\tLocal x#,y#,z#,radius#\n\t\tLocal entity:TEntity=TEntity(target),point#[]=Float[](target)\n\t\tIf entity\n\t\t\tentity.GetCullParams x,y,z,radius\n\t\tElse\n\t\t\tx=point[0];y=point[1];z=point[2];radius=point[3]\n\t\tEndIf\n\t\tReturn _lastfrustum.IntersectsPoint(x,y,z,radius)\n\tEnd Method\nEnd Type\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"1fc38af964462f5a9491e699fce8f6faa0dc7c29","subject":"Pass flags parameter to TZMQ_Socket.Send when message is a String","message":"Pass flags parameter to TZMQ_Socket.Send when message is a String\n","repos":"Htbaa\/zmq.mod,Htbaa\/zmq.mod","old_file":"socket.bmx","new_file":"socket.bmx","new_contents":"Rem\n\tCopyright (c) 2012 Christiaan Kras\n\t\n\tPermission is hereby granted, free of charge, to any person obtaining a copy\n\tof this software and associated documentation files (the \"Software\"), to deal\n\tin the Software without restriction, including without limitation the rights\n\tto use, copy, modify, merge, publish, distribute, sublicense, and\/or sell\n\tcopies of the Software, and to permit persons to whom the Software is\n\tfurnished to do so, subject to the following conditions:\n\t\n\tThe above copyright notice and this permission notice shall be included in\n\tall copies or substantial portions of the Software.\n\t\n\tTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n\tIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n\tFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n\tAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n\tLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n\tOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n\tTHE SOFTWARE.\nEnd Rem\n\nRem\n\tbbdoc: Type that represents a ZMQ socket\nEnd Rem\nType TZMQ_Socket\n\n\tRem\n\t\tbbdoc: Pointer to a ZMQ context\n\tEnd Rem\n\tField context:Byte Ptr\n\n\tRem\n\t\tbbdoc: Pointer to a ZMQ socket\n\t\tabout: Use @Close() to free socket\n\tEnd Rem\n\tField socket:Byte Ptr\n\n\tRem\n\t\tbbdoc: Create a ZMQ Socket\n\t\treturns: TZMQ_Socket\n\t\tabout: Throws a TZMQ_Exception on errors\n\tEnd Rem\n\tMethod Create:TZMQ_Socket(context:Byte Ptr, socket_type:Int)\n\t\tIf socket Then Throw \"Socket already exists!\"\n\t\tSelf.context = context\n\t\tSelf.socket = zmq_socket(Self.context, socket_type)\n\t\tIf Self.socket = Null Then Throw New TZMQ_Exception\n\t\tReturn Self\n\tEnd Method\n\n\tRem\n\t\tbbdoc: Destructor\n\t\tabout: Will call @Close() when collected\n\tEnd Rem\n\tMethod Destroy()\n\t\tSelf.Close()\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Bind to an address\n\t\tabout: Throws a TZMQ_Exception on errors\n\tEnd Rem\n\tMethod Bind(address:String)\n\t\tLocal rc:Int = zmq_bind(Self.socket, address)\n\t\tIf rc = -1 Then Throw New TZMQ_Exception\n\tEnd Method\n\n\tRem\n\t\tbbdoc: Connect to a ZMQ socket\n\t\tabout: Throws a TZMQ_Exception on errors\n\tEnd Rem\n\tMethod Connect(address:String)\n\t\tLocal rc:Int = zmq_connect(Self.socket, address)\n\t\tIf rc = -1 Then Throw New TZMQ_Exception\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Close socket\n\t\tabout: Throws a TZMQ_Exception on errors\n\tEnd Rem\n\tMethod Close()\n\t\tLocal rc:Int = zmq_close(Self.socket)\n\t\tIf rc = -1 Then Throw New TZMQ_Exception\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set a socket option\n\t\tabout: Throws a TZMQ_Exception on errors\n\tEnd Rem\n\tMethod SetSockOpt(socket_option:Int, value:String)\n\t\tLocal rc:Int = zmq_setsockopt(Self.socket, socket_option, value, 0)\n\t\tIf rc = -1 Then Throw New TZMQ_Exception\n\tEnd Method\n\n\tRem\n\t\tbbdoc: Get a socket options\n\t\tabout: Not yet implemented!\n\tEnd Rem\n\tMethod GetSockOpt(socket_option:Int)\n\t\tThrow \"Not yet implemented\"\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Send message to socket\n\t\tabout: Throws a TZMQ_Exception on errors\n\t\tmessage can either be a String, which will be converted to a TZMQ_Message,\n\t\tor you can pass a TZMQ_Message straight away\n\tEnd Rem\n\tMethod Send(message:Object, flags:Int = 0)\n\t\tLocal rc:Int\n\t\tIf TZMQ_Message(message)\n\t\t\trc = zmq_send(Self.socket, TZMQ_Message(message).message, flags)\n\t\tElse If String(message)\n\t\t\tLocal content:String = String(message)\n\t\t\tLocal msg:TZMQ_Message = New TZMQ_Message.Create(content)\n\t\t\trc = Self.Send(msg, flags)\n\t\tEnd If\n\t\t\n\t\tIf rc = -1 Then Throw New TZMQ_Exception\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Receive message from socket\n\t\treturns: TZMQ_Message\n\tEnd Rem\n\tMethod Recv:TZMQ_Message(flags:Int = 0)\n\t\tLocal msg:Byte Ptr = bmx_zmq_message_t()\n\t\tzmq_msg_init(msg)\n\t\tIf zmq_recv(Self.socket, msg, flags) Then Return Null\n\t\tReturn New TZMQ_Message.CreateFromMessage(msg)\n\tEnd Method\nEnd Type","old_contents":"Rem\n\tCopyright (c) 2012 Christiaan Kras\n\t\n\tPermission is hereby granted, free of charge, to any person obtaining a copy\n\tof this software and associated documentation files (the \"Software\"), to deal\n\tin the Software without restriction, including without limitation the rights\n\tto use, copy, modify, merge, publish, distribute, sublicense, and\/or sell\n\tcopies of the Software, and to permit persons to whom the Software is\n\tfurnished to do so, subject to the following conditions:\n\t\n\tThe above copyright notice and this permission notice shall be included in\n\tall copies or substantial portions of the Software.\n\t\n\tTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n\tIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n\tFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n\tAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n\tLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n\tOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n\tTHE SOFTWARE.\nEnd Rem\n\nRem\n\tbbdoc: Type that represents a ZMQ socket\nEnd Rem\nType TZMQ_Socket\n\n\tRem\n\t\tbbdoc: Pointer to a ZMQ context\n\tEnd Rem\n\tField context:Byte Ptr\n\n\tRem\n\t\tbbdoc: Pointer to a ZMQ socket\n\t\tabout: Use @Close() to free socket\n\tEnd Rem\n\tField socket:Byte Ptr\n\n\tRem\n\t\tbbdoc: Create a ZMQ Socket\n\t\treturns: TZMQ_Socket\n\t\tabout: Throws a TZMQ_Exception on errors\n\tEnd Rem\n\tMethod Create:TZMQ_Socket(context:Byte Ptr, socket_type:Int)\n\t\tIf socket Then Throw \"Socket already exists!\"\n\t\tSelf.context = context\n\t\tSelf.socket = zmq_socket(Self.context, socket_type)\n\t\tIf Self.socket = Null Then Throw New TZMQ_Exception\n\t\tReturn Self\n\tEnd Method\n\n\tRem\n\t\tbbdoc: Destructor\n\t\tabout: Will call @Close() when collected\n\tEnd Rem\n\tMethod Destroy()\n\t\tSelf.Close()\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Bind to an address\n\t\tabout: Throws a TZMQ_Exception on errors\n\tEnd Rem\n\tMethod Bind(address:String)\n\t\tLocal rc:Int = zmq_bind(Self.socket, address)\n\t\tIf rc = -1 Then Throw New TZMQ_Exception\n\tEnd Method\n\n\tRem\n\t\tbbdoc: Connect to a ZMQ socket\n\t\tabout: Throws a TZMQ_Exception on errors\n\tEnd Rem\n\tMethod Connect(address:String)\n\t\tLocal rc:Int = zmq_connect(Self.socket, address)\n\t\tIf rc = -1 Then Throw New TZMQ_Exception\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Close socket\n\t\tabout: Throws a TZMQ_Exception on errors\n\tEnd Rem\n\tMethod Close()\n\t\tLocal rc:Int = zmq_close(Self.socket)\n\t\tIf rc = -1 Then Throw New TZMQ_Exception\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set a socket option\n\t\tabout: Throws a TZMQ_Exception on errors\n\tEnd Rem\n\tMethod SetSockOpt(socket_option:Int, value:String)\n\t\tLocal rc:Int = zmq_setsockopt(Self.socket, socket_option, value, 0)\n\t\tIf rc = -1 Then Throw New TZMQ_Exception\n\tEnd Method\n\n\tRem\n\t\tbbdoc: Get a socket options\n\t\tabout: Not yet implemented!\n\tEnd Rem\n\tMethod GetSockOpt(socket_option:Int)\n\t\tThrow \"Not yet implemented\"\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Send message to socket\n\t\tabout: Throws a TZMQ_Exception on errors\n\t\tmessage can either be a String, which will be converted to a TZMQ_Message,\n\t\tor you can pass a TZMQ_Message straight away\n\tEnd Rem\n\tMethod Send(message:Object, flags:Int = 0)\n\t\tLocal rc:Int\n\t\tIf TZMQ_Message(message)\n\t\t\trc = zmq_send(Self.socket, TZMQ_Message(message).message, flags)\n\t\tElse If String(message)\n\t\t\tLocal content:String = String(message)\n\t\t\tLocal msg:TZMQ_Message = New TZMQ_Message.Create(content)\n\t\t\trc = Self.Send(msg)\n\t\tEnd If\n\t\t\n\t\tIf rc = -1 Then Throw New TZMQ_Exception\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Receive message from socket\n\t\treturns: TZMQ_Message\n\tEnd Rem\n\tMethod Recv:TZMQ_Message(flags:Int = 0)\n\t\tLocal msg:Byte Ptr = bmx_zmq_message_t()\n\t\tzmq_msg_init(msg)\n\t\tIf zmq_recv(Self.socket, msg, flags) Then Return Null\n\t\tReturn New TZMQ_Message.CreateFromMessage(msg)\n\tEnd Method\nEnd Type","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"fa2b77361bdc6b8df9dca340078a06dc0accd6a8","subject":"type.bmx: * Changed behavior of InitWithTypeID to not throw an exception when initializing an LExposedType instance with a type that's already been exposed so that it instead returns the already-initialized instance (the original instance is collected by the GC).","message":"type.bmx:\n* Changed behavior of InitWithTypeID to not throw an exception when initializing an LExposedType instance with a type that's already been exposed so that it instead returns the already-initialized instance (the original instance is collected by the GC).","repos":"nilium\/lugi.mod,nilium\/lugi.mod","old_file":"Generator\/type.bmx","new_file":"Generator\/type.bmx","new_contents":"SuperStrict\n\nImport \"field.bmx\"\nImport \"method.bmx\"\nImport \"metadata.bmx\"\n\nImport Brl.LinkedList\n\nPrivate\n\nGlobal _exposedTypes:TList = New TList\n\nPublic\n\nType LExposedType\n\tField exposed%\n\tField static%\n\tField noclass%\n\tField hidefields%\n\tField nonew%\n\t\n\tField typeid:TTypeId\n\tField methods:TList\t\t\t' TList\n\tField fields:TList\t\t\t' TList\n\tField constructor$\n\tField name$\n\t\n\t' Returns an LExposedType for a typeid - recommended to use this instead of creating a new LExposedType and initializing it\n\tFunction ForType:LExposedType(typeid:TTypeId)\n\t\tIf typeid = ObjectTypeId Or typeid = StringTypeId Or typeid._class = ArrayTypeId._class Then\n\t\t\tReturn Null\n\t\tEndIf\n\t\t\n\t\tLocal link:TLink = _exposedTypes.FindLink(typeid)\n\t\tIf link Then\n\t\t\tReturn LExposedType(link.Value())\n\t\tEndIf\n\t\tReturn New LExposedType.InitWithTypeID(typeid)\n\tEnd Function\n\t\n\t' Compares LExposedTypes based on the TTypeId associated with each LExposedType\n\tMethod Compare:Int(other:Object)\n\t\tReturn typeid.Compare(LExposedType(other).typeid)\n\tEnd Method\n\t\n\t' Returns a list of exposed types to iterate over\n\tFunction EnumTypes:TList()\n\t\tReturn _exposedTypes.Copy()\n\tEnd Function\n\t\n\t' Initializes an LExposedType with information for the type passed\n\t' The object returned may not be the one you originally sent the initialize message to\n\t' If there is already an instance for this type, that instance will be returned instead\n\t' of proceeding with intialization\n\tMethod InitWithTypeID:LExposedType(tid:TTypeId)\n\t\tIf tid = ObjectTypeId Or typeid = StringTypeId Or typeid._class = ArrayTypeId._class Then\n\t\t\tReturn Null\n\t\tEndIf\n\t\t\n\t\tLocal lnk:TLink = _exposedTypes.FindLink(tid)\n\t\tIf lnk Then\n\t\t\tReturn LExposedType(lnk.Value())\n\t\tEndIf\n\t\t\n\t\texposed = typeid.Metadata(LUGI_META_EXPOSE).ToInt()>0\n\t\tstatic = typeid.Metadata(LUGI_META_STATIC).ToInt()>0\n\t\tnoclass = typeid.Metadata(LUGI_META_NOCLASS).ToInt()>0\n\t\thidefields = typeid.Metadata(LUGI_META_HIDEFIELDS).ToInt()>0\n\t\tnonew = typeid.Metadata(LUGI_META_DISABLECONSTRUCTOR).ToInt()>0\n\t\t\n\t\tname = typeid.Metadata(LUGI_META_RENAME).Trim()\n\t\tIf Not name Then\n\t\t\tname = typeid.Name()\n\t\tEndIf\n\t\t\n\t\tIf Not (nonew Or (static and noclass)) Then\n\t\t\tconstructor = typeid.Metadata(LUGI_META_CONSTRUCTOR).Trim()\n\t\t\tIf Not constructor Then\n\t\t\t\t' Force New[A-Z_].* as default\n\t\t\t\tconstructor = \"New\"+name[0..1].ToUpper()+name[1..]\n\t\t\tEndIf\n\t\tEndIf\n\t\t\n\t\t__initMethods\n\t\t__initFields\n\t\t\n\t\t_exposedTypes.AddLast(Self)\n\t\t\n\t\tReturn Self\n\tEnd Method\n\t\n\tMethod PreInitBlock:String()\n\t\tLocal outs$=\"\"\n\t\t\n\t\tIf Not (static And noclass) Then\n\t\t\tFor Local m:LExposedMethod = EachIn methods\n\t\t\t\tLocal initString$ = m.PreInitBlock()\n\t\t\t\tIf initString Then\n\t\t\t\t\touts :+ \"~t\" + initString + \"~n\"\n\t\t\t\tEndIf\n\t\t\tNext\n\t\tEndIf\n\t\t\n\t\tIf Not noclass Then\n\t\t\tFor Local f:LExposedField = EachIn fields\n\t\t\t\tLocal initString$ = f.PreInitBlock()\n\t\t\t\tIf initString Then\n\t\t\t\t\touts :+ \"~t\" + initString + \"~n\"\n\t\t\t\tEndIf\n\t\t\tNext\n\t\tEndIf\n\t\t\n\t\tReturn outs\n\tEnd Method\n\t\n\tMethod PostInitBlock:String()\n\t\tIf Not (nonew Or (static And noclass)) Then\n\t\t\tReturn \t\"~tlua_pushlightuserdata lua_vm, Byte Ptr(TTypeId.ForName(~q\" + typeid.Name() + \"~q)._class)\" + ..\n\t\t\t\t\t\"~tlua_pushcclosure lua_vm, p_lugi_new_object, 1\"\n\t\tElseIf static And Not noclass Then\n\t\t\tReturn\t\"~t\"\n\t\tEndIf\n\tEnd Method\n\t\n\tMethod MethodImplementations:String()\n\t\tLocal m:LExposedMethod\n\t\tLocal outs$\n\t\tLocal instMethod% = Not (static And noclass)\n\t\tLocal block$\n\t\t\n\t\tFor m = EachIn methods\n\t\t\tblock = m.Implementation(instMethod)\n\t\t\tIf block Then\n\t\t\t\touts :+ \"~n~n\"+block\n\t\t\tEndIf\n\t\tNext\n\t\t\n\t\tReturn outs\n\tEnd Method\n\t\n\tMethod _exposedInParent:Int(m:TMethod)\n\t\tLocal name$ = m.Name().ToLower()\n\t\t\n\t\tLocal typ:TTypeId = typeid.SuperType()\n\t\tWhile typ\n\t\t\t\n\t\tWend\n\tEnd Method\n\t\n\tMethod __initMethods()\n\t\tmethods = New TList\n\t\t\n\t\tIf Not exposed Then\n\t\t\tReturn\n\t\tEndIf\n\t\t\n\t\t' Build list of exposed methods\n\t\tFor Local m:TMethod = EachIn typeid.Methods()\n\t\t\t\n\t\tNext\n\tEnd Method\n\t\n\tMethod __initFields()\n\t\tfields = New TList\n\t\t\n\t\tIf Not exposed Or hidefields Then\n\t\t\tReturn\n\t\tEndIf\n\t\t\n\t\tFor Local f:TField = EachIn typeid.Fields()\n\t\t\t\n\t\tNext\n\tEnd Method\nEnd Type\n\n' Builds up the information for all types\nFunction BuildTypeInfo()\nEnd Function\n\nPrivate\n\n' Recursively creates the information for types\nFunction _buildTypeInfo(types:TList)\n\t' Iterate over types and load data for them\n\tFor Local tid:TTypeId = EachIn types\n\t\tNew LExposedType.InitWithTypeID(tid)\n\t\t_buildTypeInfo(tid.DerivedTypes())\n\tNext\nEnd Function\n","old_contents":"SuperStrict\n\nImport \"field.bmx\"\nImport \"method.bmx\"\nImport \"metadata.bmx\"\n\nImport Brl.LinkedList\n\nPrivate\n\nGlobal _exposedTypes:TList = New TList\n\nPublic\n\nType LExposedType\n\tField exposed%\n\tField static%\n\tField noclass%\n\tField hidefields%\n\tField nonew%\n\t\n\tField typeid:TTypeId\n\tField methods:TList\t\t\t' TList\n\tField fields:TList\t\t\t' TList\n\tField constructor$\n\tField name$\n\t\n\t' Returns an LExposedType for a typeid - recommended to use this instead of creating a new LExposedType and initializing it\n\tFunction ForType:LExposedType(typeid:TTypeId)\n\t\tIf typeid = ObjectTypeId Or typeid = StringTypeId Or typeid._class = ArrayTypeId._class Then\n\t\t\tReturn Null\n\t\tEndIf\n\t\t\n\t\tLocal link:TLink = _exposedTypes.FindLink(typeid)\n\t\tIf link Then\n\t\t\tReturn LExposedType(link.Value())\n\t\tEndIf\n\t\tReturn New LExposedType.InitWithTypeID(typeid)\n\tEnd Function\n\t\n\t' Compares LExposedTypes based on the TTypeId associated with each LExposedType\n\tMethod Compare:Int(other:Object)\n\t\tReturn typeid.Compare(LExposedType(other).typeid)\n\tEnd Method\n\t\n\t' Returns a list of exposed types to iterate over\n\tFunction EnumTypes:TList()\n\t\tReturn _exposedTypes.Copy()\n\tEnd Function\n\t\n\t' Initializes an LExposedType with information for the type passed\n\t' Will throw an exception if an LExposedType for the typeid has already been created and initialized\n\tMethod InitWithTypeID:LExposedType(tid:TTypeId)\n\t\ttypeid = tid\n\t\t\n\t\tIf _exposedTypes.Contains(_exposedTypes) Then\n\t\t\tThrow \"Attempt to initialize duplicate LExposedType for type \"+tid.Name()\n\t\tEndIf\n\t\t\n\t\texposed = typeid.Metadata(LUGI_META_EXPOSE).ToInt()>0\n\t\tstatic = typeid.Metadata(LUGI_META_STATIC).ToInt()>0\n\t\tnoclass = typeid.Metadata(LUGI_META_NOCLASS).ToInt()>0\n\t\thidefields = typeid.Metadata(LUGI_META_HIDEFIELDS).ToInt()>0\n\t\tnonew = typeid.Metadata(LUGI_META_DISABLECONSTRUCTOR).ToInt()>0\n\t\t\n\t\tname = typeid.Metadata(LUGI_META_RENAME).Trim()\n\t\tIf Not name Then\n\t\t\tname = typeid.Name()\n\t\tEndIf\n\t\t\n\t\tIf Not (nonew Or (static and noclass)) Then\n\t\t\tconstructor = typeid.Metadata(LUGI_META_CONSTRUCTOR).Trim()\n\t\t\tIf Not constructor Then\n\t\t\t\t' Force New[A-Z_].* as default\n\t\t\t\tconstructor = \"New\"+name[0..1].ToUpper()+name[1..]\n\t\t\tEndIf\n\t\tEndIf\n\t\t\n\t\t__initMethods\n\t\t__initFields\n\t\t\n\t\t_exposedTypes.AddLast(Self)\n\t\t\n\t\tReturn Self\n\tEnd Method\n\t\n\tMethod PreInitBlock:String()\n\t\tLocal outs$=\"\"\n\t\t\n\t\tIf Not (static And noclass) Then\n\t\t\tFor Local m:LExposedMethod = EachIn methods\n\t\t\t\tLocal initString$ = m.PreInitBlock()\n\t\t\t\tIf initString Then\n\t\t\t\t\touts :+ \"~t\" + initString + \"~n\"\n\t\t\t\tEndIf\n\t\t\tNext\n\t\tEndIf\n\t\t\n\t\tIf Not noclass Then\n\t\t\tFor Local f:LExposedField = EachIn fields\n\t\t\t\tLocal initString$ = f.PreInitBlock()\n\t\t\t\tIf initString Then\n\t\t\t\t\touts :+ \"~t\" + initString + \"~n\"\n\t\t\t\tEndIf\n\t\t\tNext\n\t\tEndIf\n\t\t\n\t\tReturn outs\n\tEnd Method\n\t\n\tMethod PostInitBlock:String()\n\t\tIf Not (nonew Or (static And noclass)) Then\n\t\t\tReturn \t\"~tlua_pushlightuserdata lua_vm, Byte Ptr(TTypeId.ForName(~q\" + typeid.Name() + \"~q)._class)\" + ..\n\t\t\t\t\t\"~tlua_pushcclosure lua_vm, p_lugi_new_object, 1\"\n\t\tElseIf static And Not noclass Then\n\t\t\tReturn\t\"~t\"\n\t\tEndIf\n\tEnd Method\n\t\n\tMethod MethodImplementations:String()\n\t\tLocal m:LExposedMethod\n\t\tLocal outs$\n\t\tLocal instMethod% = Not (static And noclass)\n\t\tLocal block$\n\t\t\n\t\tFor m = EachIn methods\n\t\t\tblock = m.Implementation(instMethod)\n\t\t\tIf block Then\n\t\t\t\touts :+ \"~n~n\"+block\n\t\t\tEndIf\n\t\tNext\n\t\t\n\t\tReturn outs\n\tEnd Method\n\t\n\tMethod _exposedInParent:Int(m:TMethod)\n\t\tLocal name$ = m.Name().ToLower()\n\t\t\n\t\tLocal typ:TTypeId = typeid.SuperType()\n\t\tWhile typ\n\t\t\t\n\t\tWend\n\tEnd Method\n\t\n\tMethod __initMethods()\n\t\tmethods = New TList\n\t\t\n\t\tIf Not exposed Then\n\t\t\tReturn\n\t\tEndIf\n\t\t\n\t\t' Build list of exposed methods\n\t\tFor Local m:TMethod = EachIn typeid.Methods()\n\t\t\t\n\t\tNext\n\tEnd Method\n\t\n\tMethod __initFields()\n\t\tfields = New TList\n\t\t\n\t\tIf Not exposed Or hidefields Then\n\t\t\tReturn\n\t\tEndIf\n\t\t\n\t\tFor Local f:TField = EachIn typeid.Fields()\n\t\t\t\n\t\tNext\n\tEnd Method\nEnd Type\n\n' Builds up the information for all types\nFunction BuildTypeInfo()\nEnd Function\n\nPrivate\n\n' Recursively creates the information for types\nFunction _buildTypeInfo(types:TList)\n\t' Iterate over types and load data for them\n\tFor Local tid:TTypeId = EachIn types\n\t\tNew LExposedType.InitWithTypeID(tid)\n\t\t_buildTypeInfo(tid.DerivedTypes())\n\tNext\nEnd Function\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"14d38f5ff999e8f5c8432b77a089d18fab396e3f","subject":"newline was missing","message":"newline was missing\n","repos":"maximos\/maximus","old_file":"src\/impl\/help.bmx","new_file":"src\/impl\/help.bmx","new_contents":"\nRem\nCopyright (c) 2010 Tim Howard\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and\/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\nEnd Rem\n\nRem\n\tbbdoc: Maximus 'help' argument implementation.\nEnd Rem\nType mxHelpImpl Extends mxArgumentImplementation\n\t\n\tMethod New()\n\t\tinit([\"help\", \"--help\", \"-h\"])\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Check the current arguments for errors (according to the specific implementation).\n\t\treturns: Nothing.\n\t\tabout: This method will throw an error if the given arguments are invalid.\n\tEnd Rem\n\tMethod CheckArgs()\n\t\tSelect GetCallConvention()\n\t\t\tCase mxCallConvention.COMMAND ' \"help\"\n\t\t\t\tIf m_args = Null\n\t\t\t\t\tThrowCommonError(mxCmdErrors.MISSINGPARAMS, \"help\")\n\t\t\t\tEnd If\n\t\t\tCase mxCallConvention.OPTION ' \"--help\" or \"-h\"\n\t\t\t\tIf m_args <> Null\n\t\t\t\t\tThrowCommonError(mxOptErrors.DOESNOTTAKEPARAMS, \"-h|--help\")\n\t\t\t\tEnd If\n\t\tEnd Select\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get a string describing the typical usage of the argument.\n\t\treturns: A string describing the typical usage of the argument.\n\tEnd Rem\n\tMethod GetUsage:String()\n\t\tSelect GetCallConvention()\n\t\t\tCase mxCallConvention.COMMAND\n\t\t\t\tReturn \"usage: maximus help ~n\" + ..\n\t\t\t\t\t\t\"e.g. maximus help get\"\n\t\t\tCase mxCallConvention.OPTION\n\t\t\t\tReturn \"maximus usage: maximus [-v|--version] [-h|--help] COMMAND [ARGS]~n\" + ..\n\t\t\t\t\t\t\"The most commonly used commands:~n\" + ..\n\t\t\t\t\t\t\"~tget~tGet the given set modules~n\" + ..\n\t\t\t\t\t\t\"~tremove~tRemove the given set of modules~n\" + ..\n\t\t\t\t\t\t\"~tupdate~tUpdate the current set of modules~n\" + ..\n\t\t\t\t\t\t\"~thelp~tGet help on a specific command~n\" + ..\n\t\t\t\t\t\t\"Try 'maximus help ' for more information on a specific command.\"\n\t\tEnd Select\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Execute the implementation's operation.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod Execute()\n\t\tSelect GetCallConvention()\n\t\t\tCase mxCallConvention.COMMAND\n\t\t\t\tFor Local command:String = EachIn m_args\n\t\t\t\t\tIf command.ToLower() = \"help\"\n\t\t\t\t\t\tlogger.LogMessage(command + \":~t\" + \"HELP HELP I'M BEING REPRESSED!\")\n\t\t\t\t\tElse\n\t\t\t\t\t\tLocal argimpl:mxArgumentImplementation = mainapp.m_arghandler.GetArgImplFromAlias(command)\n\t\t\t\t\t\tIf argimpl <> Null\n\t\t\t\t\t\t\tlogger.LogMessage(command + \":~t\" + argimpl.GetUsage().Replace(\"~n\", \"~n~t~t\"))\n\t\t\t\t\t\tElse\n\t\t\t\t\t\t\tlogger.LogMessage(command + \":~tCommand not found\")\n\t\t\t\t\t\tEnd If\n\t\t\t\t\tEnd If\n\t\t\t\tNext\n\t\t\tCase mxCallConvention.OPTION\n\t\t\t\tlogger.LogMessage(GetUsage())\n\t\tEnd Select\n\tEnd Method\n\t\nEnd Type\n\n","old_contents":"\nRem\nCopyright (c) 2010 Tim Howard\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and\/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\nEnd Rem\n\nRem\n\tbbdoc: Maximus 'help' argument implementation.\nEnd Rem\nType mxHelpImpl Extends mxArgumentImplementation\n\t\n\tMethod New()\n\t\tinit([\"help\", \"--help\", \"-h\"])\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Check the current arguments for errors (according to the specific implementation).\n\t\treturns: Nothing.\n\t\tabout: This method will throw an error if the given arguments are invalid.\n\tEnd Rem\n\tMethod CheckArgs()\n\t\tSelect GetCallConvention()\n\t\t\tCase mxCallConvention.COMMAND ' \"help\"\n\t\t\t\tIf m_args = Null\n\t\t\t\t\tThrowCommonError(mxCmdErrors.MISSINGPARAMS, \"help\")\n\t\t\t\tEnd If\n\t\t\tCase mxCallConvention.OPTION ' \"--help\" or \"-h\"\n\t\t\t\tIf m_args <> Null\n\t\t\t\t\tThrowCommonError(mxOptErrors.DOESNOTTAKEPARAMS, \"-h|--help\")\n\t\t\t\tEnd If\n\t\tEnd Select\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get a string describing the typical usage of the argument.\n\t\treturns: A string describing the typical usage of the argument.\n\tEnd Rem\n\tMethod GetUsage:String()\n\t\tSelect GetCallConvention()\n\t\t\tCase mxCallConvention.COMMAND\n\t\t\t\tReturn \"usage: maximus help ~n\" + ..\n\t\t\t\t\t\t\"e.g. maximus help get\"\n\t\t\tCase mxCallConvention.OPTION\n\t\t\t\tReturn \"maximus usage: maximus [-v|--version] [-h|--help] COMMAND [ARGS]~n\" + ..\n\t\t\t\t\t\t\"The most commonly used commands:~n\" + ..\n\t\t\t\t\t\t\"~tget~tGet the given set modules~n\" + ..\n\t\t\t\t\t\t\"~tremove~tRemove the given set of modules\" + ..\n\t\t\t\t\t\t\"~tupdate~tUpdate the current set of modules~n\" + ..\n\t\t\t\t\t\t\"~thelp~tGet help on a specific command~n\" + ..\n\t\t\t\t\t\t\"Try 'maximus help ' for more information on a specific command.\"\n\t\tEnd Select\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Execute the implementation's operation.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod Execute()\n\t\tSelect GetCallConvention()\n\t\t\tCase mxCallConvention.COMMAND\n\t\t\t\tFor Local command:String = EachIn m_args\n\t\t\t\t\tIf command.ToLower() = \"help\"\n\t\t\t\t\t\tlogger.LogMessage(command + \":~t\" + \"HELP HELP I'M BEING REPRESSED!\")\n\t\t\t\t\tElse\n\t\t\t\t\t\tLocal argimpl:mxArgumentImplementation = mainapp.m_arghandler.GetArgImplFromAlias(command)\n\t\t\t\t\t\tIf argimpl <> Null\n\t\t\t\t\t\t\tlogger.LogMessage(command + \":~t\" + argimpl.GetUsage().Replace(\"~n\", \"~n~t~t\"))\n\t\t\t\t\t\tElse\n\t\t\t\t\t\t\tlogger.LogMessage(command + \":~tCommand not found\")\n\t\t\t\t\t\tEnd If\n\t\t\t\t\tEnd If\n\t\t\t\tNext\n\t\t\tCase mxCallConvention.OPTION\n\t\t\t\tlogger.LogMessage(GetUsage())\n\t\tEnd Select\n\tEnd Method\n\t\nEnd Type\n\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"a81e4ce27479c4dd70a9b15f4b56e1a35b533cc1","subject":"TXMLRPC_Response_Data.IterateVector() now uses the Value ID as the TMap index when it has been set, otherwise key \"0\" will be used","message":"TXMLRPC_Response_Data.IterateVector() now uses the Value ID as the TMap index when it has been set, otherwise key \"0\" will be used\n","repos":"Htbaa\/xmlrpc.mod,Htbaa\/xmlrpc.mod,Htbaa\/xmlrpc.mod,Htbaa\/xmlrpc.mod,Htbaa\/xmlrpc.mod","old_file":"response.bmx","new_file":"response.bmx","new_contents":"Rem\n\tbbdoc: Exception for TXMLRPC_Response_Data\nEnd Rem\nType TXMLRPC_Response_Data_Exception Extends TXMLRPC_Exception\nEnd Type\n\nRem\n\tbbdoc: Data returned from XML-RPC server\nEnd Rem\nType TXMLRPC_Response_Data\n\tRem\n\t\tbbdoc: This field contains all data returned from a response. If a response value was given an ID it can be accessed by its ID. If not it can be accessed with an ID of 0..inf\n\tEnd Rem\n\tField data:TMap\n\t\n\tRem\n\t\tbbdoc: Create a TXMLRPC_Response_Data object by passing the response XML message and the output options.\n\tEnd Rem\n\tMethod Create:TXMLRPC_Response_Data(xmlMessage:String, options:Byte Ptr)\n\t\tLocal message:Byte Ptr = xmlMessage.ToCString()\n\t\tLocal request:Byte Ptr = XMLRPC_REQUEST_FromXML(message, 0, options)\n\n\t\tLocal el:Byte Ptr = XMLRPC_RequestGetData(request)\n\n\t\tSelf.data = TXMLRPC_Response_Data.IterateVector(el)\n\n\t\tMemFree(message)\n\t\tXMLRPC_RequestFree(request, 1)\n\t\t\n\t\tReturn Self\n\tEnd Method\n\n\tRem\n\t\tbbdoc: Iterate over an XMLRPC vector and add it to a TMap. Private function\n\tEnd Rem\t\n\tFunction IterateVector:TMap(el:Byte Ptr)\n\t\tLocal data:TMap = New TMap\n\n\t\tIf el\n\t\t\t'Rewind vector\n\t\t\tLocal itr:Byte Ptr = XMLRPC_VectorRewind(el)\n\t\t\tIf Not itr\n\t\t\t\tLocal cStr:Byte Ptr = XMLRPC_GetValueID(itr)\n\t\t\t\tLocal id:String = \"0\"\n\t\t\t\tIf cStr\n\t\t\t\t\tid = String.FromCString(cStr)\n\t\t\t\t\tXMLRPC_Free(cstr)\n\t\t\t\tEnd If\n\n\t\t\t\tdata.Insert(id, TXMLRPC_Value_Abstract.XMLRPC_To_BlizMax(el))\n\t\t\tElse\n\t\t\t\tLocal dataCounter:Int = 0\n\t\t\t\tWhile itr\n\t\t\t\t\tLocal cStr:Byte Ptr = XMLRPC_GetValueID(itr)\n\t\t\t\t\tLocal id:String = String.FromCString(cStr)\n\t\t\t\t\t\n\t\t\t\t\tIf id.Length = 0\n\t\t\t\t\t\tid = String.FromInt(dataCounter)\n\t\t\t\t\t\tdataCounter:+1\n\t\t\t\t\tEnd If\n\n\t\t\t\t\tdata.Insert(id, TXMLRPC_Value_Abstract.XMLRPC_To_BlizMax(itr))\n\t\t\t\t\tXMLRPC_Free(cStr)\n\n\t\t\t\t\t'Next element\n\t\t\t\t\titr = XMLRPC_VectorNext(el)\n\t\t\t\tWend\n\t\t\tEnd If\n\t\tEnd If\n\t\t\n\t\tReturn data\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Helper function to show what's inside the map\n\tEnd Rem\n\tFunction DebugData:String(map:TMap, pad:Int Var)\n\t\tLocal str:String\n\t\tLocal prefix:String\n\t\tFor Local i:Int = 0 To pad\n\t\t\tprefix:+\"-\"\n\t\tNext\n\t\t\n\t\tFor Local val:TXMLRPC_Value_Abstract = EachIn map.Values()\n\t\t\tstr:+prefix + \" \" + TTypeId.ForObject(val).Name() + \" (\" + val.name + \") = \" + val.ToString() + \"~n\"\n\t\t\tIf TXMLRPC_Value_Collection(val)\n\t\t\t\tpad:+1\n\t\t\t\tstr:+TXMLRPC_Response_Data.DebugData(TXMLRPC_Value_Collection(val).data, pad) + \"~n\"\n\t\t\t\tpad:-1\n\t\t\tEnd If\n\t\tNext\n\t\tReturn str\n\tEnd Function\nEnd Type\n","old_contents":"Rem\n\tbbdoc: Exception for TXMLRPC_Response_Data\nEnd Rem\nType TXMLRPC_Response_Data_Exception Extends TXMLRPC_Exception\nEnd Type\n\nRem\n\tbbdoc: Data returned from XML-RPC server\nEnd Rem\nType TXMLRPC_Response_Data\n\tRem\n\t\tbbdoc: This field contains all data returned from a response. If a response value was given an ID it can be accessed by its ID. If not it can be accessed with an ID of 0..inf\n\tEnd Rem\n\tField data:TMap\n\t\n\tRem\n\t\tbbdoc: Create a TXMLRPC_Response_Data object by passing the response XML message and the output options.\n\tEnd Rem\n\tMethod Create:TXMLRPC_Response_Data(xmlMessage:String, options:Byte Ptr)\n\t\tLocal message:Byte Ptr = xmlMessage.ToCString()\n\t\tLocal request:Byte Ptr = XMLRPC_REQUEST_FromXML(message, 0, options)\n\n\t\tLocal el:Byte Ptr = XMLRPC_RequestGetData(request)\n\n\t\tSelf.data = TXMLRPC_Response_Data.IterateVector(el)\n\n\t\tXMLRPC_RequestFree(request, 1)\n\t\tMemFree(message)\n\t\tReturn Self\n\tEnd Method\n\n\tRem\n\t\tbbdoc: Iterate over an XMLRPC vector and add it to a TMap. Private function\n\tEnd Rem\t\n\tFunction IterateVector:TMap(el:Byte Ptr)\n\t\tLocal data:TMap = New TMap\n\n\t\tIf el\n\t\t\t'Rewind vector\n\t\t\tLocal itr:Byte Ptr = XMLRPC_VectorRewind(el)\n\t\t\tIf Not itr\n\t\t\t\tdata.Insert(\"0\", TXMLRPC_Value_Abstract.XMLRPC_To_BlizMax(el))\n\t\t\tElse\n\t\t\t\tLocal dataCounter:Int = 0\n\t\t\t\tWhile itr\n\t\t\t\t\tLocal cStr:Byte Ptr = XMLRPC_GetValueID(itr)\n\t\t\t\t\tLocal id:String = String.FromCString(cStr)\n\t\t\t\t\t\n\t\t\t\t\tIf id.Length = 0\n\t\t\t\t\t\tid = String.FromInt(dataCounter)\n\t\t\t\t\t\tdataCounter:+1\n\t\t\t\t\tEnd If\n\n\t\t\t\t\tdata.Insert(id, TXMLRPC_Value_Abstract.XMLRPC_To_BlizMax(itr))\n\t\t\t\t\tXMLRPC_Free(cStr)\n\t\n\t\t\t\t\t'Next element\n\t\t\t\t\titr = XMLRPC_VectorNext(el)\n\t\t\t\tWend\n\t\t\tEnd If\n\t\tEnd If\n\t\t\n\t\tReturn data\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Helper function to show what's inside the map\n\tEnd Rem\n\tFunction DebugData:String(map:TMap, pad:Int Var)\n\t\tLocal str:String\n\t\tLocal prefix:String\n\t\tFor Local i:Int = 0 To pad\n\t\t\tprefix:+\"-\"\n\t\tNext\n\t\t\n\t\tFor Local val:TXMLRPC_Value_Abstract = EachIn map.Values()\n\t\t\tstr:+prefix + \" \" + TTypeId.ForObject(val).Name() + \" (\" + val.name + \") = \" + val.ToString() + \"~n\"\n\t\t\tIf TXMLRPC_Value_Collection(val)\n\t\t\t\tpad:+1\n\t\t\t\tstr:+TXMLRPC_Response_Data.DebugData(TXMLRPC_Value_Collection(val).data, pad) + \"~n\"\n\t\t\t\tpad:-1\n\t\t\tEnd If\n\t\tNext\n\t\tReturn str\n\tEnd Function\nEnd Type\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"403aaef850931b33ae059fa736ba0e39ea6e72d1","subject":"Documentation","message":"Documentation\n","repos":"maximos\/maximus","old_file":"src\/userinput.bmx","new_file":"src\/userinput.bmx","new_contents":"\nRem\n\tbbdoc: User Input interface\nEnd Rem\nType mxUserInput\n\n\tRem\n\t\tbbdoc:Command Line Interface\n\tEnd Rem\n\tConst c_cli:Byte = 0\n\t\n\tRem\n\t\tbbdoc:Graphical User Interface\n\tEnd Rem\n\tConst c_gui:Byte = 1\n\n\tField m_driver:mxUserInputDriver\n\t\n\tRem\n\t\tbbdoc: Factory for initializing mxUserInput object\n\t\tabout: interface can be either c_cli of c_gui\n\tEnd Rem\n\tFunction factory:mxUserInput(interface:Byte)\n\t\tLocal ui:mxUserInput = New mxUserInput\n\t\tSelect interface\n\t\t\tCase c_cli\n\t\t\t\tui.m_driver = New mxUserInputDriverCLI\n\t\t\tCase c_gui\n\t\t\t\tui.m_driver = New mxUserInputDriverGUI\n\t\tEnd Select\n\t\tReturn ui\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Ask user to confirm an action\n\t\treturns: True or False\n\tEnd Rem\n\tMethod Confirm:Byte(question:String)\n\t\tReturn Self.m_driver.Confirm(question)\n\tEnd Method\n\nEnd Type\n\nRem\n\tbbdoc: User Input Driver interface\nEnd Rem\nType mxUserInputDriver Abstract\n\t\n\tRem\n\t\tbbdoc: Ask user to confirm an action\n\t\treturns: True or False\n\tEnd Rem\n\tMethod Confirm:Byte(question:String) Abstract\n\t\nEnd Type\n\n\t\nRem\n\tbbdoc: UserInpitDriver for Command Line Interface\nEnd Rem\nType mxUserInputDriverCLI Extends mxUserInputDriver\n\t\n\tRem\n\t\tbbdoc: Ask user to confirm an action\n\t\treturns: True or False\n\tEnd Rem\n\tMethod Confirm:Byte(question:String)\n\t\tLocal resp:String = Input(question + \" \" + _s(\"message.confirm\")).ToLower()\n\t\tIf resp = \"y\" Or resp = \"yes\"\n\t\t\tReturn True\n\t\tElse\n\t\t\tReturn False\n\t\tEnd If\n\tEnd Method\n\nEnd Type\n\nRem\n\tbbdoc: UserInputDriver for Graphical User Interface\nEnd Rem\nType mxUserInputDriverGUI Extends mxUserInputDriver\n\n\tRem\n\t\tbbdoc:Ask user to confirm an action\n\tEnd Rem\n\tMethod Confirm:Byte(question:String)\n\t\tReturn brl.system.Confirm(question)\n\tEnd Method\n\nEnd Type","old_contents":"\nRem\n\tbbdoc: User Input interface\nEnd Rem\nType mxUserInput\n\n\tRem\n\t\tbbdoc:Command Line Interface\n\tEnd Rem\n\tConst c_cli:Byte = 0\n\t\n\tRem\n\t\tbbdoc:Graphical User Interface\n\tEnd Rem\n\tConst c_gui:Byte = 1\n\n\tField m_driver:mxUserInputDriver\n\t\n\tRem\n\t\tbbdoc: Factory for initializing mxUserInput object\n\t\tabout: interface can be either c_cli of c_gui\n\tEnd Rem\n\tFunction factory:mxUserInput(interface:Byte)\n\t\tLocal ui:mxUserInput = New mxUserInput\n\t\tSelect interface\n\t\t\tCase c_cli\n\t\t\t\tui.m_driver = New mxUserInputDriverCLI\n\t\t\tCase c_gui\n\t\t\t\tui.m_driver = New mxUserInputDriverGUI\n\t\tEnd Select\n\t\tReturn ui\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Ask user to confirm an action\n\t\treturns: True or False\n\tEnd Rem\n\tMethod Confirm:Byte(question:String)\n\t\tReturn Self.m_driver.Confirm(question)\n\tEnd Method\n\nEnd Type\n\nRem\n\tbbdoc: User Input Driver interface\nEnd Rem\nType mxUserInputDriver Abstract\n\t\n\tRem\n\t\tbbdoc: Ask user to confirm an action\n\t\treturns: True or False\n\tEnd Rem\n\tMethod Confirm:Byte(question:String) Abstract\n\t\nEnd Type\n\n\t\nRem\n\tbbdoc: UserInpitDriver for Command Line Interface\nEnd Rem\nType mxUserInputDriverCLI Extends mxUserInputDriver\n\t\n\tRem\n\t\tbbdoc: Ask user to confirm an action\n\t\treturns: True or False\n\tEnd Rem\n\tMethod Confirm:Byte(question:String)\n\t\tLocal resp:String = Input(question + \" \" + _s(\"message.confirm\")).ToLower()\n\t\tIf resp = \"y\" Or resp = \"yes\"\n\t\t\tReturn True\n\t\tElse\n\t\t\tReturn False\n\t\tEnd If\n\tEnd Method\n\nEnd Type\n\nType mxUserInputDriverGUI Extends mxUserInputDriver\n\tRem\n\t\tbbdoc:Ask user to confirm an action\n\tEnd Rem\n\tMethod Confirm:Byte(question:String)\n\t\tReturn brl.system.Confirm(question)\n\tEnd Method\n\nEnd Type","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"3035580b596ee76eadcf71fd953d5b094678d819","subject":"Modified to simply call Graphics.","message":"Modified to simply call Graphics.\n","repos":"kfprimm\/maxb3d,kfprimm\/maxb3d","old_file":"doc\/samples\/mak\/multi_tex.bmx","new_file":"doc\/samples\/mak\/multi_tex.bmx","new_contents":"\nStrict\n\nImport MaxB3D.Drivers\n\nGraphics 800,600\nSetAmbientLight 0,0,0\n\nLocal logo:TTexture=LoadTexture(\"media\/blitzlogo.bmp\")\n\nLocal pixmap:TPixmap=CreatePixmap(64,64,PF_RGBA8888)\nFor Local y=0 To 63\n\tFor Local x=0 To 63\n\t\tLocal data:Int Ptr=Int Ptr(PixmapPixelPtr(pixmap,x,y))\n\t\tIf x<32 And y<32 data[0]=$FFFFFFFF\n\t\tIf x>31 And y<32 data[0]=$FF808080\n\t\tIf x<32 And y>31 data[0]=$FF808080\n\t\tIf x>31 And y>31 data[0]=$FFFFFFFF\n\tNext\nNext\n\nLocal grid:TTexture=LoadTexture(pixmap)\nSetTextureScale grid,.5,.5\n\nLocal env:TTexture=LoadTexture(\"media\/spheremap.bmp\",TEXTURE_COLOR|TEXTURE_ALPHA|TEXTURE_SPHEREMAP)\n\nLocal cube:TMesh=CreateCube()\nSetEntityTexture cube,logo,0,0\nSetEntityTexture cube,grid,1,0\nSetEntityTexture cube,env,2,0\nUpdateMeshNormals cube\n\nLocal camera:TCamera=CreateCamera()\nSetEntityPosition camera,0,0,-4\n\nLocal light1:TLight=CreateLight()\nTurnEntity light1,45,45,0\nSetEntityColor light1,255,0,0\n\nLocal light2:TLight=CreateLight()\nTurnEntity light2,-45,45,0\nSetEntityColor light2,0,255,0\n\nLocal light3:TLight=CreateLight()\nTurnEntity light3,45,-45,0\nSetEntityColor light3,0,0,255\n\nLocal blend1=BLEND_MULTIPLY,blend2=BLEND_MULTIPLY,blend3=BLEND_ALPHA\nSetTextureBlend logo,blend1\nSetTextureBlend grid,blend2\nSetTextureBlend env,blend3\n\nLocal offset#\n\nWhile Not KeyHit(KEY_ESCAPE) And Not AppTerminate()\n\tIf KeyHit(KEY_F1)\n\t\tblend1=blend1+1\n\t\tIf blend1=4 blend1=0\n\t\tSetTextureBlend logo,blend1\n\tEndIf\n\tIf KeyHit(KEY_F2)\n\t\tblend2=blend2+1\n\t\tIf blend2=4 blend2=0\n\t\tSetTextureBlend grid,blend2\n\tEndIf\n\tIf KeyHit(KEY_F3)\n\t\tblend3=blend3+1\n\t\tIf blend3=4 blend3=0\n\t\tSetTextureBlend env,blend3\n\tEndIf\n\tIf KeyDown(KEY_A)\n\t\tTranslateEntity camera,0,0,.1\n\tEndIf\n\tIf KeyDown(KEY_Z)\n\t\tTranslateEntity camera,0,0,-.1\n\tEndIf\n\n\toffset=offset-.01\n\tSetTexturePosition logo,offset,0\n\t\n\tTurnEntity cube,.1,.2,.3\n\t\n\tRenderWorld\n\tDoMax2D\n\tDrawText \"(F1) TextureBlend 1=\"+mode(blend1),0,0\n\tDrawText \"(F2) TextureBlend 2=\"+mode(blend2),0,13\n\tDrawText \"(F3) TextureBlend 3=\"+mode(blend3),0,26\n\n\tFlip\nWend\n\nFunction mode$( mode )\n\tSelect mode\n\tCase BLEND_NONE\n\t\tReturn \"BLEND_NONE\"\n\tCase BLEND_ALPHA\n\t\tReturn \"BLEND_ALPHA\"\n\tCase BLEND_MULTIPLY\n\t\tReturn \"BLEND_MULTIPLY\"\n\tCase BLEND_ADD\n\t\tReturn \"BLEND_ADD\"\n\tEnd Select\n\tReturn \"Unknown\"\nEnd Function\n","old_contents":"\nStrict\n\nImport MaxB3D.Drivers\n\nGLGraphics3D 800,600\nSetAmbientLight 0,0,0\n\nLocal logo:TTexture=LoadTexture(\"media\/blitzlogo.bmp\")\n\nLocal pixmap:TPixmap=CreatePixmap(64,64,PF_RGBA8888)\nFor Local y=0 To 63\n\tFor Local x=0 To 63\n\t\tLocal data:Int Ptr=Int Ptr(PixmapPixelPtr(pixmap,x,y))\n\t\tIf x<32 And y<32 data[0]=$FFFFFFFF\n\t\tIf x>31 And y<32 data[0]=$FF808080\n\t\tIf x<32 And y>31 data[0]=$FF808080\n\t\tIf x>31 And y>31 data[0]=$FFFFFFFF\n\tNext\nNext\n\nLocal grid:TTexture=LoadTexture(pixmap)\nSetTextureScale grid,.5,.5\n\nLocal env:TTexture=LoadTexture(\"media\/spheremap.bmp\",TEXTURE_COLOR|TEXTURE_ALPHA|TEXTURE_SPHEREMAP)\n\nLocal cube:TMesh=CreateCube()\nSetEntityTexture cube,logo,0,0\nSetEntityTexture cube,grid,1,0\nSetEntityTexture cube,env,2,0\nUpdateMeshNormals cube\n\nLocal camera:TCamera=CreateCamera()\nSetEntityPosition camera,0,0,-4\n\nLocal light1:TLight=CreateLight()\nTurnEntity light1,45,45,0\nSetEntityColor light1,255,0,0\n\nLocal light2:TLight=CreateLight()\nTurnEntity light2,-45,45,0\nSetEntityColor light2,0,255,0\n\nLocal light3:TLight=CreateLight()\nTurnEntity light3,45,-45,0\nSetEntityColor light3,0,0,255\n\nLocal blend1=BLEND_MULTIPLY,blend2=BLEND_MULTIPLY,blend3=BLEND_ALPHA\nSetTextureBlend logo,blend1\nSetTextureBlend grid,blend2\nSetTextureBlend env,blend3\n\nLocal offset#\n\nWhile Not KeyHit(KEY_ESCAPE) And Not AppTerminate()\n\tIf KeyHit(KEY_F1)\n\t\tblend1=blend1+1\n\t\tIf blend1=4 blend1=0\n\t\tSetTextureBlend logo,blend1\n\tEndIf\n\tIf KeyHit(KEY_F2)\n\t\tblend2=blend2+1\n\t\tIf blend2=4 blend2=0\n\t\tSetTextureBlend grid,blend2\n\tEndIf\n\tIf KeyHit(KEY_F3)\n\t\tblend3=blend3+1\n\t\tIf blend3=4 blend3=0\n\t\tSetTextureBlend env,blend3\n\tEndIf\n\tIf KeyDown(KEY_A)\n\t\tTranslateEntity camera,0,0,.1\n\tEndIf\n\tIf KeyDown(KEY_Z)\n\t\tTranslateEntity camera,0,0,-.1\n\tEndIf\n\n\toffset=offset-.01\n\tSetTexturePosition logo,offset,0\n\t\n\tTurnEntity cube,.1,.2,.3\n\t\n\tRenderWorld\n\tDoMax2D\n\tDrawText \"(F1) TextureBlend 1=\"+mode(blend1),0,0\n\tDrawText \"(F2) TextureBlend 2=\"+mode(blend2),0,13\n\tDrawText \"(F3) TextureBlend 3=\"+mode(blend3),0,26\n\n\tFlip\nWend\n\nFunction mode$( mode )\n\tSelect mode\n\tCase BLEND_NONE\n\t\tReturn \"BLEND_NONE\"\n\tCase BLEND_ALPHA\n\t\tReturn \"BLEND_ALPHA\"\n\tCase BLEND_MULTIPLY\n\t\tReturn \"BLEND_MULTIPLY\"\n\tCase BLEND_ADD\n\t\tReturn \"BLEND_ADD\"\n\tEnd Select\n\tReturn \"Unknown\"\nEnd Function\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"a100a953dbb6d965911f3c75f519235499c7ca6f","subject":"Added module description","message":"Added module description\n","repos":"Htbaa\/zmq.mod,Htbaa\/zmq.mod","old_file":"zmq.bmx","new_file":"zmq.bmx","new_contents":"Rem\n\tCopyright (c) 2012 Christiaan Kras\n\t\n\tPermission is hereby granted, free of charge, to any person obtaining a copy\n\tof this software and associated documentation files (the \"Software\"), to deal\n\tin the Software without restriction, including without limitation the rights\n\tto use, copy, modify, merge, publish, distribute, sublicense, and\/or sell\n\tcopies of the Software, and to permit persons to whom the Software is\n\tfurnished to do so, subject to the following conditions:\n\t\n\tThe above copyright notice and this permission notice shall be included in\n\tall copies or substantial portions of the Software.\n\t\n\tTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n\tIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n\tFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n\tAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n\tLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n\tOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n\tTHE SOFTWARE.\nEnd Rem\n\nSuperStrict\n\nRem\n\tbbdoc: htbaapub.zmq\n\tabout: This module is still an early work in progress. If you run into any\n\tbugs please report them at https:\/\/github.com\/Htbaa\/zmq.mod\/issues<\/a>.\nEndRem\nModule htbaapub.zmq\nModuleInfo \"Name: htbaapub.zmq\"\nModuleInfo \"Description: A wrapper for ZeroMQ\"\nModuleInfo \"Version: 0.01\"\nModuleInfo \"License: MIT\"\nModuleInfo \"Author: Christiaan Kras\"\nModuleInfo \"ZeroMQ: http:\/\/www.zeromq.org<\/a>\"\nModuleInfo \"ZeroMQ License: LGPL (see contents of .\/zeromq)\"\nModuleInfo \"Git repository: https:\/\/github.com\/Htbaa\/zmq.mod\/<\/a>\"\nModuleInfo \"Issues: https:\/\/github.com\/Htbaa\/zmq.mod\/issues<\/a>\"\nModuleInfo \"History: 0.01\"\nModuleInfo \"History: First release of htbaapub.zmq using ZMQ 2.1.11. No support yet for input\/output multiplexing with zmq_poll()\"\n\n?Linux\n\tImport \"-lzmq\"\n?Win32\n\tImport \"zeromq\/lib\/libzmq.dll.a\"\n?\n\nImport \"glue.c\"\nInclude \"exception.bmx\"\nInclude \"constants.bmx\"\nInclude \"context.bmx\"\nInclude \"socket.bmx\"\nInclude \"message.bmx\"\n\n'Glue\/Helper functions\nExtern \"C\"\n\n\tRem\n\t\tbbdoc: Create an empty zmq_message_t struct\n\t\treturns: Returns a pointer to a new zmq_message_t struct\n\tEnd Rem\n\tFunction bmx_zmq_message_t:Byte Ptr()\n\n\tRem\n\t\tbbdoc: Create a zmq_message_t struct with preset data\n\t\treturns: Returns a pointer to a new zmq_message_t struct with given data\n\tEnd Rem\n\tFunction bmx_zmq_new_message:Byte Ptr(str$z)\nEnd Extern\n\n'ZeroMQ functions\nExtern\n\tFunction zmq_version(major:Int Var, minor:Int Var, patch:Int Var)\n\n\tFunction zmq_init:Byte Ptr(io_threads:Int)\n\tFunction zmq_term:Int(context:Byte Ptr)\n\t\n\tFunction zmq_errno:Int()\n\tFunction zmq_strerror$z(errnum:Int)\n\t\n\tFunction zmq_socket:Byte Ptr(context:Byte Ptr, socket_type:Int)\n\tFunction zmq_close:Int(s:Byte Ptr)\n\tFunction zmq_setsockopt:Int(s:Byte Ptr, option:Int, optval$z, length:Int)\n\tFunction zmq_getsockopt:Int(s:Byte Ptr, option:Int, optval:Byte Ptr, length:Int Var)\n\t'ZMQ_EXPORT Int zmq_getsockopt (void *s, Int option, void *optval, size_t *optvallen);\n\tFunction zmq_bind(s:Byte Ptr, addr$z)\n\tFunction zmq_connect:Int(s:Byte Ptr, addr$z)\n\tFunction zmq_send:Int(s:Byte Ptr, msg:Byte Ptr, flags:Int)\n\tFunction zmq_recv:Int(s:Byte Ptr, msg:Byte Ptr, flags:Int)\t\n\n\tFunction zmq_msg_init:Int(msg:Byte Ptr)\n\tFunction zmq_msg_init_size:Int(msg:Byte Ptr, size:Long)\n\tFunction zmq_msg_init_data:Int(msg:Byte Ptr, data:Byte Ptr, size:Long, ffn:Byte Ptr, hint:Byte Ptr)\n\tFunction zmq_msg_close:Int(msg:Byte Ptr)\n\tFunction zmq_msg_move:Int(dest:Byte Ptr, src:Byte Ptr)\n\tFunction zmq_msg_copy:Int(dest:Byte Ptr, src:Byte Ptr)\n\tFunction zmq_msg_data:Byte Ptr(msg:Byte Ptr)\n\tFunction zmq_msg_size:Int(msg:Byte Ptr)\n\t\n\tFunction zmq_poll:Int(items:Byte Ptr, nitems:Int, timeout:Long)\n\t\n\tFunction zmq_device:Int(device:Int, insocket:Byte Ptr, outsocket:Byte Ptr)\nEnd Extern\n\nRem\n\tbbdoc: General ZMQ functions\nEnd Rem\nType TZMQ\n\n\tRem\n\t\tbbdoc: Get ZMQ Version\n\t\treturns: String\n\tEnd Rem\n\tFunction Version:String()\n\t\tLocal major:Int, minor:Int, patch:Int\n\t\tzmq_version(major, minor, patch)\n\t\tReturn major + \".\" + minor + \".\" + patch\n\tEnd Function\n\n\tRem\n\t\tbbdoc: Get current ZMQ error descriptions\n\t\treturns: String\n\tEnd Rem\n\tFunction Error:String()\n\t\tReturn zmq_strerror( TZMQ.ErrorNumber() )\n\tEnd Function\n\n\tRem\n\t\tbbdoc: Get current ZMQ error number\n\t\treturns: Int\n\tEnd Rem\n\tFunction ErrorNumber:Int()\n\t\tReturn zmq_errno()\n\tEnd Function\nEnd Type","old_contents":"Rem\n\tCopyright (c) 2012 Christiaan Kras\n\t\n\tPermission is hereby granted, free of charge, to any person obtaining a copy\n\tof this software and associated documentation files (the \"Software\"), to deal\n\tin the Software without restriction, including without limitation the rights\n\tto use, copy, modify, merge, publish, distribute, sublicense, and\/or sell\n\tcopies of the Software, and to permit persons to whom the Software is\n\tfurnished to do so, subject to the following conditions:\n\t\n\tThe above copyright notice and this permission notice shall be included in\n\tall copies or substantial portions of the Software.\n\t\n\tTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n\tIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n\tFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n\tAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n\tLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n\tOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n\tTHE SOFTWARE.\nEnd Rem\n\nSuperStrict\n\nRem\n\tbbdoc: htbaapub.zmq\n\tabout: This module is still an early work in progress. If you run into any\n\tbugs please report them at https:\/\/github.com\/Htbaa\/zmq.mod\/issues<\/a>.\nEndRem\nModule htbaapub.zmq\nModuleInfo \"Name: htbaapub.zmq\"\nModuleInfo \"Version: 0.01\"\nModuleInfo \"License: MIT\"\nModuleInfo \"Author: Christiaan Kras\"\nModuleInfo \"ZeroMQ: http:\/\/www.zeromq.org<\/a>\"\nModuleInfo \"ZeroMQ License: LGPL (see contents of .\/zeromq)\"\nModuleInfo \"Git repository: https:\/\/github.com\/Htbaa\/zmq.mod\/<\/a>\"\nModuleInfo \"Issues: https:\/\/github.com\/Htbaa\/zmq.mod\/issues<\/a>\"\nModuleInfo \"History: 0.01\"\nModuleInfo \"History: First release of htbaapub.zmq using ZMQ 2.1.11. No support yet for input\/output multiplexing with zmq_poll()\"\n\n?Linux\n\tImport \"-lzmq\"\n?Win32\n\tImport \"zeromq\/lib\/libzmq.dll.a\"\n?\n\nImport \"glue.c\"\nInclude \"exception.bmx\"\nInclude \"constants.bmx\"\nInclude \"context.bmx\"\nInclude \"socket.bmx\"\nInclude \"message.bmx\"\n\n'Glue\/Helper functions\nExtern \"C\"\n\n\tRem\n\t\tbbdoc: Create an empty zmq_message_t struct\n\t\treturns: Returns a pointer to a new zmq_message_t struct\n\tEnd Rem\n\tFunction bmx_zmq_message_t:Byte Ptr()\n\n\tRem\n\t\tbbdoc: Create a zmq_message_t struct with preset data\n\t\treturns: Returns a pointer to a new zmq_message_t struct with given data\n\tEnd Rem\n\tFunction bmx_zmq_new_message:Byte Ptr(str$z)\nEnd Extern\n\n'ZeroMQ functions\nExtern\n\tFunction zmq_version(major:Int Var, minor:Int Var, patch:Int Var)\n\n\tFunction zmq_init:Byte Ptr(io_threads:Int)\n\tFunction zmq_term:Int(context:Byte Ptr)\n\t\n\tFunction zmq_errno:Int()\n\tFunction zmq_strerror$z(errnum:Int)\n\t\n\tFunction zmq_socket:Byte Ptr(context:Byte Ptr, socket_type:Int)\n\tFunction zmq_close:Int(s:Byte Ptr)\n\tFunction zmq_setsockopt:Int(s:Byte Ptr, option:Int, optval$z, length:Int)\n\tFunction zmq_getsockopt:Int(s:Byte Ptr, option:Int, optval:Byte Ptr, length:Int Var)\n\t'ZMQ_EXPORT Int zmq_getsockopt (void *s, Int option, void *optval, size_t *optvallen);\n\tFunction zmq_bind(s:Byte Ptr, addr$z)\n\tFunction zmq_connect:Int(s:Byte Ptr, addr$z)\n\tFunction zmq_send:Int(s:Byte Ptr, msg:Byte Ptr, flags:Int)\n\tFunction zmq_recv:Int(s:Byte Ptr, msg:Byte Ptr, flags:Int)\t\n\n\tFunction zmq_msg_init:Int(msg:Byte Ptr)\n\tFunction zmq_msg_init_size:Int(msg:Byte Ptr, size:Long)\n\tFunction zmq_msg_init_data:Int(msg:Byte Ptr, data:Byte Ptr, size:Long, ffn:Byte Ptr, hint:Byte Ptr)\n\tFunction zmq_msg_close:Int(msg:Byte Ptr)\n\tFunction zmq_msg_move:Int(dest:Byte Ptr, src:Byte Ptr)\n\tFunction zmq_msg_copy:Int(dest:Byte Ptr, src:Byte Ptr)\n\tFunction zmq_msg_data:Byte Ptr(msg:Byte Ptr)\n\tFunction zmq_msg_size:Int(msg:Byte Ptr)\n\t\n\tFunction zmq_poll:Int(items:Byte Ptr, nitems:Int, timeout:Long)\n\t\n\tFunction zmq_device:Int(device:Int, insocket:Byte Ptr, outsocket:Byte Ptr)\nEnd Extern\n\nRem\n\tbbdoc: General ZMQ functions\nEnd Rem\nType TZMQ\n\n\tRem\n\t\tbbdoc: Get ZMQ Version\n\t\treturns: String\n\tEnd Rem\n\tFunction Version:String()\n\t\tLocal major:Int, minor:Int, patch:Int\n\t\tzmq_version(major, minor, patch)\n\t\tReturn major + \".\" + minor + \".\" + patch\n\tEnd Function\n\n\tRem\n\t\tbbdoc: Get current ZMQ error descriptions\n\t\treturns: String\n\tEnd Rem\n\tFunction Error:String()\n\t\tReturn zmq_strerror( TZMQ.ErrorNumber() )\n\tEnd Function\n\n\tRem\n\t\tbbdoc: Get current ZMQ error number\n\t\treturns: Int\n\tEnd Rem\n\tFunction ErrorNumber:Int()\n\t\tReturn zmq_errno()\n\tEnd Function\nEnd Type","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"93b5a4973aec1238a2dbdb0ad6b83ac12ad3d7b0","subject":"Fixed possible TSurface.Copy issue.","message":"Fixed possible TSurface.Copy issue.\n","repos":"kfprimm\/maxb3d,kfprimm\/maxb3d","old_file":"core.mod\/surface.bmx","new_file":"core.mod\/surface.bmx","new_contents":"\nStrict\n\nImport MaxB3D.Math\nImport \"brush.bmx\"\n\nConst SURFACE_POS = 1\nConst SURFACE_NML = 2\nConst SURFACE_CLR = 4\nConst SURFACE_TEX = 8\nConst SURFACE_TRI = 16\nConst SURFACE_ALL = SURFACE_POS|SURFACE_NML|SURFACE_CLR|SURFACE_TEX|SURFACE_TRI\n\nType TSurface\n\tField _brush:TBrush=New TBrush\n\t\n\tField _vertexcnt,_trianglecnt\n\tField _vertexpos#[],_vertexnml#[],_vertexclr#[]\t\n\tField _vertextex#[][],_texcoordsize=-1\n\t\n\tField _triangle[]\n\t\n\tField _res:TSurfaceRes,_reset=-1\n\t\n\tField _resetbounds=True,_minx#,_miny#,_minz#,_maxx#,_maxy#,_maxz#\n\tField _boundsupdatedmsg:TMaxB3DMsg=New TMaxB3DMsg\n\t\n\tMethod Copy:TSurface(data=SURFACE_ALL)\n\t\tLocal surface:TSurface=New TSurface\n\t\tsurface._brush.Load(_brush)\n\t\tsurface._vertexcnt=_vertexcnt\t\t\n\t\tIf data&SURFACE_POS surface._vertexpos=_vertexpos[..]\n\t\tIf data&SURFACE_NML surface._vertexnml=_vertexnml[..]\n\t\tIf data&SURFACE_CLR surface._vertexclr=_vertexclr[..]\n\t\tIf data&SURFACE_TEX\n\t\t\tsurface._vertextex = New Float[][_texcoordsize]\n\t\t\tFor Local i=0 To _texcoordsize-1\n\t\t\t\tsurface._vertextex[i]=_vertextex[i][..]\n\t\t\tNext\n\t\t\tsurface._texcoordsize=_texcoordsize\n\t\tEndIf\n\t\tIf data&SURFACE_TRI surface._trianglecnt=_trianglecnt;surface._triangle=_triangle[..]\n\t\tReturn surface\n\tEnd Method\n\t\n\tMethod Resize(vertexcount,trianglecount)\n\t\tIf vertexcount>-1\n\t\t\t_vertexpos=_vertexpos[..vertexcount*3]\n\t\t\t_vertexnml=_vertexnml[..vertexcount*3]\n\t\t\t_vertexclr=_vertexclr[..vertexcount*4]\n\t\t\tFor Local i=_vertexcnt*4 To vertexcount*4-1\n\t\t\t\t_vertexclr[i]=1.0\n\t\t\tNext\n\t\t\tFor Local i=0 To _texcoordsize-1\n\t\t\t\t_vertextex[i]=_vertextex[i][..vertexcount*2]\n\t\t\tNext\n\t\t\t_vertexcnt=vertexcount\n\t\tEndIf\n\t\t\n\t\tIf trianglecount>-1\n\t\t\t_triangle=_triangle[..trianglecount*3]\n\t\t\t_trianglecnt=trianglecount\n\t\tEndIf\n\tEnd Method\n\t\n\tMethod GetSize(vertices Var,triangles Var)\n\t\tvertices=_vertexcnt\n\t\ttriangles=_trianglecnt\n\tEnd Method\n\n\tMethod AddVertex(x#,y#,z#,u#=0.0,v#=0.0)\n\t\tResize(_vertexcnt+1,-1)\n\t\tSetCoords(_vertexcnt-1,x,y,z)\n\t\tSetTexCoords(_vertexcnt-1,u,v)\n\t\tReturn _vertexcnt-1\n\tEnd Method\n\t\n\tMethod GetCoords(index,x# Var,y# Var,z# Var)\n\t\tx=_vertexpos[index*3+0]\n\t\ty=_vertexpos[index*3+1]\n\t\tz=_vertexpos[index*3+2]\n\tEnd Method\n\tMethod SetCoords(index,x#,y#,z#)\n\t\t_vertexpos[index*3+0]=x\n\t\t_vertexpos[index*3+1]=y\n\t\t_vertexpos[index*3+2]=z\t\t\n\t\t_reset:|1;_resetbounds=True\n\tEnd Method\n\t\n\tMethod GetNormal(index,nx# Var,ny# Var,nz# Var)\n\t\tnx=_vertexnml[index*3+0]*-1\n\t\tny=_vertexnml[index*3+1]*-1\n\t\tnz=_vertexnml[index*3+2]*-1\n\tEnd Method\n\tMethod SetNormal(index,nx#,ny#,nz#)\n\t\t_vertexnml[index*3+0]=nx*-1\n\t\t_vertexnml[index*3+1]=ny*-1\n\t\t_vertexnml[index*3+2]=nz*-1\n\t\t_reset:|2\n\tEnd Method\n\t\n\tMethod GetColor(index,red Var,green Var,blue Var,alpha# Var)\n\t\tred=_vertexclr[index*4+0]*255.0\n\t\tgreen=_vertexclr[index*4+1]*255.0\n\t\tblue=_vertexclr[index*4+2]*255.0\n\t\talpha=_vertexclr[index*4+3]\n\tEnd Method\n\tMethod SetColor(index,red,green,blue,alpha#)\n\t\t_vertexclr[index*4+0]=red\/255.0\n\t\t_vertexclr[index*4+1]=green\/255.0\n\t\t_vertexclr[index*4+2]=blue\/255.0\n\t\t_vertexclr[index*4+3]=alpha\n\t\t_reset:|4\n\tEnd Method\n\t\n\tMethod GetTexCoords(index,u# Var,v# Var,set=0)\n\t\tResizeTexSets set\n\t\tu=_vertextex[set][index*2+0]\n\t\tv=_vertextex[set][index*2+1]\n\tEnd Method\n\tMethod SetTexCoords(index,u#,v#,set=0)\n\t\tResizeTexSets set\n\t\t_vertextex[set][index*2+0]=u\n\t\t_vertextex[set][index*2+1]=v\n\t\t_reset:|Int(2^(4+set))\n\tEnd Method\n\t\n\tMethod ResizeTexSets(set)\n\t\tIf set+1>_texcoordsize\n\t\t\tLocal size=_vertextex.length\n\t\t\t_vertextex=_vertextex[..set+1]\t\t\t\n\t\t\tFor Local i=size To set\n\t\t\t\t_vertextex[i]=New Float[_vertexcnt*2]\n\t\t\tNext\t\n\t\t\t_texcoordsize=set+1\t\t\n\t\tEndIf\n\tEnd Method\n\t\n\tMethod AddTriangle(v0,v1,v2)\n\t\tResize(-1,_trianglecnt+1)\n\t\tSetTriangle _trianglecnt-1,v0,v1,v2\n\t\tReturn _trianglecnt-1\n\tEnd Method\n\t\n\tMethod GetTriangle(index,v0 Var,v1 Var,v2 Var)\n\t\tv0=_triangle[index*3+0]\n\t\tv1=_triangle[index*3+1]\n\t\tv2=_triangle[index*3+2]\n\tEnd Method\n\tMethod SetTriangle(index,v0,v1,v2)\n\t\t_triangle[index*3+0]=v0\n\t\t_triangle[index*3+1]=v1\n\t\t_triangle[index*3+2]=v2\n\t\t_reset:|8\n\tEnd Method\n\t\n\tMethod Flip()\n\t\tFor Local t=0 To _trianglecnt-1\n\t\t\tLocal v2=_triangle[t*3+2]\n\t\t\t_triangle[t*3+2]=_triangle[t*3+0]\n\t\t\t_triangle[t*3+0]=v2\t\t\t\n\t\tNext\n\t\tFor Local v=0 To _vertexcnt-1\n\t\t\t_vertexnml[(v*3)+0]:*-1\n\t\t\t_vertexnml[(v*3)+1]:*-1\n\t\t\t_vertexnml[(v*3)+2]:*-1\n\t\tNext\n\t\t_reset:|2|8\n\tEnd Method\n\t\n\tMethod Transform(matrix:TMatrix)\n\t\tFor Local i=0 To _vertexcnt-1\n\t\t\tmatrix.TransformVec3 _vertexpos[i*3+0],_vertexpos[i*3+1],_vertexpos[i*3+2]\n\t\t\t'matrix.TransformVector _vertexnml[i+0],_vertexnml[i+1],_vertexnml[i+2],w\n\t\tNext\n\tEnd Method\n\t\n\tMethod UpdateBounds(force=False)\n\t\tIf Not _resetbounds And force=false Return\n\t\t_minx=999999999;_miny=999999999;_minz=999999999\n\t\t_maxx=-999999999;_maxy=-999999999;_maxz=-999999999\n\t\tFor Local v=0 To _vertexcnt-1\n\t\t\tLocal x#,y#,z#\n\t\t\tGetCoords v,x,y,z\t\t\t\t\n\t\t\t_minx=Min(x,_minx);_maxx=Max(x,_maxx)\n\t\t\t_miny=Min(y,_miny);_maxy=Max(y,_maxy)\n\t\t\t_minz=Min(z,_minz);_maxz=Max(z,_maxz)\n\t\tNext\n\t\t_boundsupdatedmsg.Run\n\t\t_resetbounds=False\n\tEnd Method\n\t\n\tMethod UpdateNormals(smoothing=True)\n\t\tIf smoothing\n\t\t\tC_UpdateNormals(_trianglecnt,_vertexcnt,_triangle,_vertexpos,_vertexnml)\n\t\tElse\n\t\t\tLocal face_normal:TVector[_trianglecnt],vertex_triangles[][_vertexcnt]\n\t\t\t\t\t\t\n\t\t\tFor Local i=0 To _trianglecnt-1\n\t\t\t\tLocal v0,v1,v2\n\t\t\t\tGetTriangle i,v0,v1,v2\n\t\t\t\t\n\t\t\t\tvertex_triangles[v0]:+[i]\n\t\t\t\tvertex_triangles[v1]:+[i]\n\t\t\t\tvertex_triangles[v2]:+[i]\n\t\t\t\t\n\t\t\t\tLocal a:TVector=New TVector,b:TVector=New TVector,c:TVector=New TVector\n\t\t\t\tGetCoords v0,a.x,a.y,a.z\n\t\t\t\tGetCoords v1,b.x,b.y,b.z\n\t\t\t\tGetCoords v2,c.x,c.y,c.z\n\t\t\t\t\n\t\t\t\tface_normal[i]=New TVector.FromTriangle(a,b,c)\t\n\t\t\tNext\n\t\n\t\t\tLocal normal:TVector=New TVector\n\t\t\tFor Local i=0 To _vertexcnt-1\n\t\t\t\tnormal.Create3(0,0,0)\n\t\t\t\tFor Local t=0 To vertex_triangles[i].length-1\n\t\t\t\t\tnormal=normal.Add(face_normal[vertex_triangles[i][t]])\t\t\n\t\t\t\tNext\n\t\t\t\tnormal.Normalize()\t\t\t\t\n\t\t\t\tSetNormal i,-normal.x,-normal.y,-normal.z\n\t\t\tNext\t\t\n\t\tEndIf\n\t\t_reset:|2\n\tEnd Method\n\t\n\tMethod SetTriangleNormal(index,nx#,ny#,nz#)\n\t\tLocal v0,v1,v2\n\t\tGetTriangle index,v0,v1,v2\n\t\tSetNormal v0,nx,ny,nz\n\t\tSetNormal v1,nx,ny,nz\n\t\tSetNormal v2,nx,ny,nz\n\tEnd Method\n\t\n\tMethod GetBrush:TBrush()\n\t\tReturn _brush.Copy()\n\tEnd Method\t\n\tMethod SetBrush(brush:TBrush)\n\t\t_brush.Load(brush)\n\tEnd Method\n\t\n\tMethod CountVertices()\n\t\tReturn _vertexcnt\n\tEnd Method\n\tMethod CountTriangles()\n\t\tReturn _trianglecnt\n\tEnd Method\n\t\n\tMethod IsEmpty()\n\t\tReturn _vertexcnt=0 And _trianglecnt=0\n\tEnd Method\n\t\t\n\tMethod HasAlpha()\n\t\tReturn _brush.HasAlpha()\n\tEnd Method\t\nEnd Type\n\nType TSurfaceRes Extends TDriverResource\n\tField _vertexcnt\n\tField _trianglecnt\n\t\n\tMethod Copy:TSurfaceRes() Abstract\nEnd Type\n\nType TMaxB3DMsg\n\tField _succ:TMaxB3DMsg\n\tField _context:Object\n\tField _func(context:Object)\n\t\n\tMethod Add(func(context:Object),context:Object)\n\t\tLocal msg:TMaxB3DMsg=Self\n\t\tWhile msg._succ\n\t\t\tmsg=msg._succ\n\t\tWend\n\t\tmsg._succ=New TMaxB3DMsg\n\t\tmsg._context=context\n\t\tmsg._func=func\n\tEnd Method\n\t\n\tMethod Run()\n\t\tLocal msg:TMaxB3DMsg=Self\n\t\tWhile msg\n\t\t\tIf msg._func msg._func(msg._context)\n\t\t\tmsg=msg._succ\n\t\tWend\n\tEnd Method\nEnd Type\n","old_contents":"\nStrict\n\nImport MaxB3D.Math\nImport \"brush.bmx\"\n\nConst SURFACE_POS = 1\nConst SURFACE_NML = 2\nConst SURFACE_CLR = 4\nConst SURFACE_TEX = 8\nConst SURFACE_TRI = 16\nConst SURFACE_ALL = SURFACE_POS|SURFACE_NML|SURFACE_CLR|SURFACE_TEX|SURFACE_TRI\n\nType TSurface\n\tField _brush:TBrush=New TBrush\n\t\n\tField _vertexcnt,_trianglecnt\n\tField _vertexpos#[],_vertexnml#[],_vertexclr#[]\t\n\tField _vertextex#[][],_texcoordsize=-1\n\t\n\tField _triangle[]\n\t\n\tField _res:TSurfaceRes,_reset=-1\n\t\n\tField _resetbounds=True,_minx#,_miny#,_minz#,_maxx#,_maxy#,_maxz#\n\tField _boundsupdatedmsg:TMaxB3DMsg=New TMaxB3DMsg\n\t\n\tMethod Copy:TSurface(data=SURFACE_ALL)\n\t\tLocal surface:TSurface=New TSurface\n\t\tsurface._brush.Load(_brush)\n\t\tsurface._vertexcnt=_vertexcnt\t\t\n\t\tIf data&SURFACE_POS surface._vertexpos=_vertexpos[..]\n\t\tIf data&SURFACE_NML surface._vertexnml=_vertexnml[..]\n\t\tIf data&SURFACE_CLR surface._vertexclr=_vertexclr[..]\n\t\tIf data&SURFACE_TEX surface._vertextex=_vertextex[..];surface._texcoordsize=_texcoordsize\n\t\tIf data&SURFACE_TRI surface._trianglecnt=_trianglecnt;surface._triangle=_triangle[..]\n\t\tReturn surface\n\tEnd Method\n\t\n\tMethod Resize(vertexcount,trianglecount)\n\t\tIf vertexcount>-1\n\t\t\t_vertexpos=_vertexpos[..vertexcount*3]\n\t\t\t_vertexnml=_vertexnml[..vertexcount*3]\n\t\t\t_vertexclr=_vertexclr[..vertexcount*4]\n\t\t\tFor Local i=_vertexcnt*4 To vertexcount*4-1\n\t\t\t\t_vertexclr[i]=1.0\n\t\t\tNext\n\t\t\tFor Local i=0 To _texcoordsize-1\n\t\t\t\t_vertextex[i]=_vertextex[i][..vertexcount*2]\n\t\t\tNext\n\t\t\t_vertexcnt=vertexcount\n\t\tEndIf\n\t\t\n\t\tIf trianglecount>-1\n\t\t\t_triangle=_triangle[..trianglecount*3]\n\t\t\t_trianglecnt=trianglecount\n\t\tEndIf\n\tEnd Method\n\t\n\tMethod GetSize(vertices Var,triangles Var)\n\t\tvertices=_vertexcnt\n\t\ttriangles=_trianglecnt\n\tEnd Method\n\n\tMethod AddVertex(x#,y#,z#,u#=0.0,v#=0.0)\n\t\tResize(_vertexcnt+1,-1)\n\t\tSetCoords(_vertexcnt-1,x,y,z)\n\t\tSetTexCoords(_vertexcnt-1,u,v)\n\t\tReturn _vertexcnt-1\n\tEnd Method\n\t\n\tMethod GetCoords(index,x# Var,y# Var,z# Var)\n\t\tx=_vertexpos[index*3+0]\n\t\ty=_vertexpos[index*3+1]\n\t\tz=_vertexpos[index*3+2]\n\tEnd Method\n\tMethod SetCoords(index,x#,y#,z#)\n\t\t_vertexpos[index*3+0]=x\n\t\t_vertexpos[index*3+1]=y\n\t\t_vertexpos[index*3+2]=z\t\t\n\t\t_reset:|1;_resetbounds=True\n\tEnd Method\n\t\n\tMethod GetNormal(index,nx# Var,ny# Var,nz# Var)\n\t\tnx=_vertexnml[index*3+0]*-1\n\t\tny=_vertexnml[index*3+1]*-1\n\t\tnz=_vertexnml[index*3+2]*-1\n\tEnd Method\n\tMethod SetNormal(index,nx#,ny#,nz#)\n\t\t_vertexnml[index*3+0]=nx*-1\n\t\t_vertexnml[index*3+1]=ny*-1\n\t\t_vertexnml[index*3+2]=nz*-1\n\t\t_reset:|2\n\tEnd Method\n\t\n\tMethod GetColor(index,red Var,green Var,blue Var,alpha# Var)\n\t\tred=_vertexclr[index*4+0]*255.0\n\t\tgreen=_vertexclr[index*4+1]*255.0\n\t\tblue=_vertexclr[index*4+2]*255.0\n\t\talpha=_vertexclr[index*4+3]\n\tEnd Method\n\tMethod SetColor(index,red,green,blue,alpha#)\n\t\t_vertexclr[index*4+0]=red\/255.0\n\t\t_vertexclr[index*4+1]=green\/255.0\n\t\t_vertexclr[index*4+2]=blue\/255.0\n\t\t_vertexclr[index*4+3]=alpha\n\t\t_reset:|4\n\tEnd Method\n\t\n\tMethod GetTexCoords(index,u# Var,v# Var,set=0)\n\t\tResizeTexSets set\n\t\tu=_vertextex[set][index*2+0]\n\t\tv=_vertextex[set][index*2+1]\n\tEnd Method\n\tMethod SetTexCoords(index,u#,v#,set=0)\n\t\tResizeTexSets set\n\t\t_vertextex[set][index*2+0]=u\n\t\t_vertextex[set][index*2+1]=v\n\t\t_reset:|Int(2^(4+set))\n\tEnd Method\n\t\n\tMethod ResizeTexSets(set)\n\t\tIf set+1>_texcoordsize\n\t\t\tLocal size=_vertextex.length\n\t\t\t_vertextex=_vertextex[..set+1]\t\t\t\n\t\t\tFor Local i=size To set\n\t\t\t\t_vertextex[i]=New Float[_vertexcnt*2]\n\t\t\tNext\t\n\t\t\t_texcoordsize=set+1\t\t\n\t\tEndIf\n\tEnd Method\n\t\n\tMethod AddTriangle(v0,v1,v2)\n\t\tResize(-1,_trianglecnt+1)\n\t\tSetTriangle _trianglecnt-1,v0,v1,v2\n\t\tReturn _trianglecnt-1\n\tEnd Method\n\t\n\tMethod GetTriangle(index,v0 Var,v1 Var,v2 Var)\n\t\tv0=_triangle[index*3+0]\n\t\tv1=_triangle[index*3+1]\n\t\tv2=_triangle[index*3+2]\n\tEnd Method\n\tMethod SetTriangle(index,v0,v1,v2)\n\t\t_triangle[index*3+0]=v0\n\t\t_triangle[index*3+1]=v1\n\t\t_triangle[index*3+2]=v2\n\t\t_reset:|8\n\tEnd Method\n\t\n\tMethod Flip()\n\t\tFor Local t=0 To _trianglecnt-1\n\t\t\tLocal v2=_triangle[t*3+2]\n\t\t\t_triangle[t*3+2]=_triangle[t*3+0]\n\t\t\t_triangle[t*3+0]=v2\t\t\t\n\t\tNext\n\t\tFor Local v=0 To _vertexcnt-1\n\t\t\t_vertexnml[(v*3)+0]:*-1\n\t\t\t_vertexnml[(v*3)+1]:*-1\n\t\t\t_vertexnml[(v*3)+2]:*-1\n\t\tNext\n\t\t_reset:|2|8\n\tEnd Method\n\t\n\tMethod Transform(matrix:TMatrix)\n\t\tFor Local i=0 To _vertexcnt-1\n\t\t\tmatrix.TransformVec3 _vertexpos[i*3+0],_vertexpos[i*3+1],_vertexpos[i*3+2]\n\t\t\t'matrix.TransformVector _vertexnml[i+0],_vertexnml[i+1],_vertexnml[i+2],w\n\t\tNext\n\tEnd Method\n\t\n\tMethod UpdateBounds(force=False)\n\t\tIf Not _resetbounds And force=false Return\n\t\t_minx=999999999;_miny=999999999;_minz=999999999\n\t\t_maxx=-999999999;_maxy=-999999999;_maxz=-999999999\n\t\tFor Local v=0 To _vertexcnt-1\n\t\t\tLocal x#,y#,z#\n\t\t\tGetCoords v,x,y,z\t\t\t\t\n\t\t\t_minx=Min(x,_minx);_maxx=Max(x,_maxx)\n\t\t\t_miny=Min(y,_miny);_maxy=Max(y,_maxy)\n\t\t\t_minz=Min(z,_minz);_maxz=Max(z,_maxz)\n\t\tNext\n\t\t_boundsupdatedmsg.Run\n\t\t_resetbounds=False\n\tEnd Method\n\t\n\tMethod UpdateNormals(smoothing=True)\n\t\tIf smoothing\n\t\t\tC_UpdateNormals(_trianglecnt,_vertexcnt,_triangle,_vertexpos,_vertexnml)\n\t\tElse\n\t\t\tLocal face_normal:TVector[_trianglecnt],vertex_triangles[][_vertexcnt]\n\t\t\t\t\t\t\n\t\t\tFor Local i=0 To _trianglecnt-1\n\t\t\t\tLocal v0,v1,v2\n\t\t\t\tGetTriangle i,v0,v1,v2\n\t\t\t\t\n\t\t\t\tvertex_triangles[v0]:+[i]\n\t\t\t\tvertex_triangles[v1]:+[i]\n\t\t\t\tvertex_triangles[v2]:+[i]\n\t\t\t\t\n\t\t\t\tLocal a:TVector=New TVector,b:TVector=New TVector,c:TVector=New TVector\n\t\t\t\tGetCoords v0,a.x,a.y,a.z\n\t\t\t\tGetCoords v1,b.x,b.y,b.z\n\t\t\t\tGetCoords v2,c.x,c.y,c.z\n\t\t\t\t\n\t\t\t\tface_normal[i]=New TVector.FromTriangle(a,b,c)\t\n\t\t\tNext\n\t\n\t\t\tLocal normal:TVector=New TVector\n\t\t\tFor Local i=0 To _vertexcnt-1\n\t\t\t\tnormal.Create3(0,0,0)\n\t\t\t\tFor Local t=0 To vertex_triangles[i].length-1\n\t\t\t\t\tnormal=normal.Add(face_normal[vertex_triangles[i][t]])\t\t\n\t\t\t\tNext\n\t\t\t\tnormal.Normalize()\t\t\t\t\n\t\t\t\tSetNormal i,-normal.x,-normal.y,-normal.z\n\t\t\tNext\t\t\n\t\tEndIf\n\t\t_reset:|2\n\tEnd Method\n\t\n\tMethod SetTriangleNormal(index,nx#,ny#,nz#)\n\t\tLocal v0,v1,v2\n\t\tGetTriangle index,v0,v1,v2\n\t\tSetNormal v0,nx,ny,nz\n\t\tSetNormal v1,nx,ny,nz\n\t\tSetNormal v2,nx,ny,nz\n\tEnd Method\n\t\n\tMethod GetBrush:TBrush()\n\t\tReturn _brush.Copy()\n\tEnd Method\t\n\tMethod SetBrush(brush:TBrush)\n\t\t_brush.Load(brush)\n\tEnd Method\n\t\n\tMethod CountVertices()\n\t\tReturn _vertexcnt\n\tEnd Method\n\tMethod CountTriangles()\n\t\tReturn _trianglecnt\n\tEnd Method\n\t\n\tMethod IsEmpty()\n\t\tReturn _vertexcnt=0 And _trianglecnt=0\n\tEnd Method\n\t\t\n\tMethod HasAlpha()\n\t\tReturn _brush.HasAlpha()\n\tEnd Method\t\nEnd Type\n\nType TSurfaceRes Extends TDriverResource\n\tField _vertexcnt\n\tField _trianglecnt\n\t\n\tMethod Copy:TSurfaceRes() Abstract\nEnd Type\n\nType TMaxB3DMsg\n\tField _succ:TMaxB3DMsg\n\tField _context:Object\n\tField _func(context:Object)\n\t\n\tMethod Add(func(context:Object),context:Object)\n\t\tLocal msg:TMaxB3DMsg=Self\n\t\tWhile msg._succ\n\t\t\tmsg=msg._succ\n\t\tWend\n\t\tmsg._succ=New TMaxB3DMsg\n\t\tmsg._context=context\n\t\tmsg._func=func\n\tEnd Method\n\t\n\tMethod Run()\n\t\tLocal msg:TMaxB3DMsg=Self\n\t\tWhile msg\n\t\t\tIf msg._func msg._func(msg._context)\n\t\t\tmsg=msg._succ\n\t\tWend\n\tEnd Method\nEnd Type\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"967652bf9eca82c62c81b8d0359f4727135e236e","subject":"Forgot to rename option","message":"Forgot to rename option\n\nrefs gh-18\n","repos":"maximos\/maximus","old_file":"src\/impl\/install.bmx","new_file":"src\/impl\/install.bmx","new_contents":"\nRem\n\tbbdoc: Maximus 'install' argument implementation.\nEnd Rem\nType mxInstallImpl Extends dArgumentImplementation\n\t\n\tField m_instmap:dObjectMap\n\tField m_depcheckmap:dObjectMap\n\tField m_unmanagedmap:dObjectMap\n\tField m_nobuild:Int = False, m_nounpack:Int = False, m_keeptemp:Int = False\n\tField m_nothreaded:Int = False, m_makedocs:Int = False, m_forceinstall:Int = False\n\tField m_overwriteunmanaged:Int = False\n\t\n\tMethod New()\n\t\tinit([\"install\"])\n\t\tm_instmap = New dObjectMap\n\t\tm_depcheckmap = New dObjectMap\n\t\tm_unmanagedmap = New dObjectMap\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Check the current arguments for errors (according to the specific implementation).\n\t\treturns: Nothing.\n\t\tabout: This method will throw an error if the arguments are invalid.\n\tEnd Rem\n\tMethod CheckArgs()\n\t\tIf GetArgumentCount() = 0\n\t\t\tThrowCommonError(mxCmdErrors.REQUIRESPARAMS, m_args.GetName())\n\t\tEnd If\n\t\tCheckOptions()\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get a string describing the typical usage of the argument.\n\t\treturns: A string describing the typical usage of the argument.\n\tEnd Rem\n\tMethod GetUsage:String()\n\t\tReturn _s(\"arg.install.usage\")\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Execute the implementation's operation.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod Execute()\n\t\tm_instmap.Clear()\n\t\tm_depcheckmap.Clear()\n\t\tm_unmanagedmap.Clear()\n\t\tIf mainapp.m_sourceshandler\n\t\t\tLocal nfounds:dObjectMap = New dObjectMap\n\t\t\tFor Local svar:dStringVariable = EachIn m_args\n\t\t\t\tLocal verid:String = svar.Get(), modid:String = mxModUtils.GetIDFromVerID(verid)\n\t\t\t\tLocal modul:mxModule = mainapp.m_sourceshandler.GetModuleWithID(modid)\n\t\t\t\tIf modul\n\t\t\t\t\tLocal instmod:mxInstModule = New mxInstModule.Create(verid, modul)\n\t\t\t\t\tIf instmod.SetVersionFromVerID(verid)\n\t\t\t\t\t\tm_instmap._Insert(modid, instmod)\n\t\t\t\t\tElse\n\t\t\t\t\t\tThrowError(_s(\"arg.install.notfound.version\", [modid, mxModUtils.GetVersionFromVerID(verid)]))\n\t\t\t\t\tEnd If\n\t\t\t\tElse\n\t\t\t\t\tnfounds._Insert(modid, modid)\n\t\t\t\tEnd If\n\t\t\tNext\n\t\t\tIf nfounds.Count() > 0\n\t\t\t\tlogger.LogError(_s(\"arg.install.notfound.instmods\"))\n\t\t\t\tLocal a:String\n\t\t\t\tFor Local b:String = EachIn nfounds.ValueEnumerator()\n\t\t\t\t\ta:+ b + \" \"\n\t\t\t\tNext\n\t\t\t\ta = a[..a.Length - 1]\n\t\t\t\tlogger.LogMessage(\"~t\" + a)\n\t\t\t\tReturn\n\t\t\tEnd If\n\t\t\tIf CheckDependencies()\n\t\t\t\t'Make sure we only install\/update managed modules\n\t\t\t\tIf CheckVersions()\n\t\t\t\t\tDoInstall()\n\t\t\t\tEnd If\n\t\t\tEnd If\n\t\tElse\n\t\t\tThrowError(_s(\"error.install.nosources\"))\n\t\tEnd If\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Check the options given to the command.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod CheckOptions()\n\t\tm_nobuild = False; m_nounpack = False; m_keeptemp = False\n\t\tm_nothreaded = False; m_makedocs = False\n\t\tFor Local opt:dIdentifier = EachIn m_args\n\t\t\tSelect opt.GetName().ToLower()\n\t\t\t\tCase \"-nobuild\" m_nobuild = True\n\t\t\t\tCase \"-nounpack\" m_nounpack = True\n\t\t\t\tCase \"-keeptemp\" m_keeptemp = True\n\t\t\t\tCase \"-nothreaded\" m_nothreaded = True\n\t\t\t\tCase \"-makedocs\" m_makedocs = True\n\t\t\t\tCase \"-force\" m_forceinstall = True\n\t\t\t\tCase \"-overwriteunmanaged\" m_overwriteunmanaged = True\n\t\t\t\tDefault ThrowCommonError(mxOptErrors.UNKNOWN, opt.GetName())\n\t\t\tEnd Select\n\t\tNext\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Check for version conflictions and warn the user.\n\t\treturns: True if the installtion should continue, or False if the user halted the operation.\n\tEnd Rem\n\tMethod CheckVersions:Int()\n\t\tFor Local instmod:mxInstModule = EachIn m_instmap.ValueEnumerator()\n\t\t\tLocal ver:String = mxModUtils.GetInstalledVersionFromVerID(instmod.GetVerID())\n\t\t\t'Make sure we skip unmanaged modules\n\t\t\tIf ver = \"unmanaged\"\n\t\t\t\tIf Not m_overwriteunmanaged Then m_instmap._Remove(instmod.GetID())\n\t\t\t\tm_unmanagedmap._Insert(instmod.GetID(), instmod)\n\t\t\tEnd If\n\t\tNext\n\t\tReturn True\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Check the dependencies for the modules to be installed.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod CheckDependencies:Int()\n\t\tLocal nfounds:dObjectMap = New dObjectMap\n\t\tFor Local instmod:mxInstModule = EachIn m_instmap.ValueEnumerator()\n\t\t\tCheckModuleDependencies(instmod, nfounds)\n\t\tNext\n\t\tIf nfounds.Count() > 0\n\t\t\tlogger.LogError(_s(\"arg.install.notfound.instdeps\"))\n\t\t\tLocal a:String\n\t\t\tFor Local b:String = EachIn nfounds.ValueEnumerator()\n\t\t\t\ta:+ b + \" \"\n\t\t\tNext\n\t\t\ta = a[..a.Length - 1]\n\t\t\tlogger.LogMessage(\"~t\" + a)\n\t\t\tIf m_forceinstall\n\t\t\t\tm_nobuild = True\n\t\t\t\tLocal resp:String = Input(_s(\"arg.install.missingdeps\") + \" \").ToLower()\n\t\t\t\tIf resp = \"y\" Or resp = \"yes\"\n\t\t\t\t\tReturn True\n\t\t\t\tEnd If\n\t\t\tEnd If\n\t\t\tReturn False\n\t\tEnd If\n\t\tReturn True\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Check the dependencies for the given module and adapt the install list accordingly.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod CheckModuleDependencies(instmod:mxInstModule, nfounds:dObjectMap)\n\t\tLocal addlist:TListEx = instmod.CheckCompliance()\n\t\tIf addlist\n\t\t\tFor Local modid:String = EachIn addlist\n\t\t\t\tIf Not m_depcheckmap._Contains(modid)\n\t\t\t\t\tLocal dmodul:mxModule = mainapp.m_sourceshandler.GetModuleWithID(modid)\n\t\t\t\t\tm_depcheckmap._Insert(modid, modid)\n\t\t\t\t\tIf dmodul\n\t\t\t\t\t\tIf Not m_instmap._Contains(modid)\n\t\t\t\t\t\t\tLocal dinstmod:mxInstModule = New mxInstModule.Create(modid, dmodul)\n\t\t\t\t\t\t\tIf instmod.GetVersionName().ToLower() = \"dev\"\n\t\t\t\t\t\t\t\tdinstmod.SetVersionFromName(\"dev\")\n\t\t\t\t\t\t\tElse\n\t\t\t\t\t\t\t\tdinstmod.SetVersion(Null)\n\t\t\t\t\t\t\tEnd If\n\t\t\t\t\t\t\tm_instmap._Insert(modid, dinstmod)\n\t\t\t\t\t\t\tCheckModuleDependencies(dinstmod, nfounds)\n\t\t\t\t\t\tEnd If\n\t\t\t\t\tElse\n\t\t\t\t\t\tnfounds._Insert(modid, modid)\n\t\t\t\t\tEnd If\n\t\t\t\tEnd If\n\t\t\tNext\n\t\tEnd If\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Do the actual installing.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod DoInstall()\n\t\tIf m_instmap.Count() > 0\n\t\t\tLocal a:String, instmod:mxInstModule\n\n\t\t\tIf m_unmanagedmap.Count()\n\t\t\t\tIf m_overwriteunmanaged\n\t\t\t\t\tlogger.LogMessage(_s(\"arg.install.modulestooverwrite\"))\n\t\t\t\tElse\n\t\t\t\t\tlogger.LogMessage(_s(\"arg.install.modulestoskip\"))\n\t\t\t\tEnd If\n\t\t\t\tFor instmod = EachIn m_unmanagedmap.ValueEnumerator()\n\t\t\t\t\ta:+instmod.GetVerID() + \" \"\n\t\t\t\tNext\n\t\t\t\ta = a[..a.Length - 1]\n\t\t\t\tlogger.LogMessage(\"~t\" + a)\n\t\t\t\ta = \"\"\n\t\t\tEnd If\n\n\t\t\tlogger.LogMessage(_s(\"arg.install.modulestoinstall\"))\n\t\t\tFor instmod = EachIn m_instmap.ValueEnumerator()\n\t\t\t\ta:+ instmod.GetVerID() + \" \"\n\t\t\tNext\n\t\t\ta = a[..a.Length - 1]\n\t\t\tlogger.LogMessage(\"~t\" + a)\n\t\t\tLocal resp:String = Input(_s(\"arg.install.continuewithinstall\") + \" \").ToLower()\n\t\t\tIf resp = \"y\" Or resp = \"yes\"\n\t\t\t\tFor instmod = EachIn m_instmap.ValueEnumerator()\n\t\t\t\t\tinstmod.FetchSourceArchive()\n\t\t\t\tNext\n\t\t\t\tIf Not m_nounpack\n\t\t\t\t\tFor instmod = EachIn m_instmap.ValueEnumerator()\n\t\t\t\t\t\tinstmod.Unpack()\n\t\t\t\t\tNext\n\t\t\t\tElse\n\t\t\t\t\tlogger.LogMessage(_s(\"message.skipping.unpack\"))\n\t\t\t\tEnd If\n\t\t\t\tIf Not m_keeptemp Then DeleteDir(\"tmp\/\", True)\n\t\t\t\tIf Not m_nobuild\n\t\t\t\t\tLocal scopes:dObjectMap = New dObjectMap\n\t\t\t\t\tFor instmod = EachIn m_instmap.ValueEnumerator()\n\t\t\t\t\t\tscopes._Insert(instmod.GetModuleScope(), instmod.GetModuleScope())\n\t\t\t\t\tNext\n\t\t\t\t\tFor Local scope:String = EachIn scopes.ValueEnumerator()\n\t\t\t\t\t\tIf mxBMKUtils.MakeMods(scope, m_nothreaded ~ 1) <> 0\n\t\t\t\t\t\t\tThrowError(_s(\"error.install.build\", [scope]))\n\t\t\t\t\t\tEnd If\n\t\t\t\t\tNext\n\t\t\t\t\tIf m_makedocs\n\t\t\t\t\t\t'For instmod = EachIn m_instmap.ValueEnumerator()\n\t\t\t\t\t\t'\tmxModUtils.DocMods(instmod.GetID())\n\t\t\t\t\t\t'Next\n\t\t\t\t\t\t' Can't build docs for individual modules yet\n\t\t\t\t\t\tmxModUtils.DocMods()\n\t\t\t\t\tEnd If\n\t\t\t\tElse\n\t\t\t\t\tlogger.LogMessage(_s(\"message.skipping.install\"))\n\t\t\t\tEnd If\n\t\t\tEnd If\n\t\tElse\n\t\t\tlogger.LogMessage(_s(\"arg.install.nomodulestoinstall\"))\n\t\t\tIf m_unmanagedmap.Count()\n\t\t\t\tlogger.LogMessage(_s(\"arg.install.modulestoskip\"))\n\t\t\t\tLocal a:String\n\t\t\t\tFor Local instmod:mxInstModule = EachIn m_unmanagedmap.ValueEnumerator()\n\t\t\t\t\ta:+instmod.GetVerID() + \" \"\n\t\t\t\tNext\n\t\t\t\ta = a[..a.Length - 1]\n\t\t\t\tlogger.LogMessage(\"~t\" + a)\n\t\t\tEnd If\n\t\tEnd If\n\tEnd Method\n\t\nEnd Type\n\nRem\n\tbbdoc: Maximus install info module.\n\tabout: This type is used for temporary install information on modules.\nEnd Rem\nType mxInstModule\n\t\n\tField m_id:String\n\tField m_version:mxModuleVersion\n\tField m_module:mxModule\n\t\n\tRem\n\t\tbbdoc: Create a new mxInstModule.\n\t\treturns: Itself.\n\tEnd Rem\n\tMethod Create:mxInstModule(verid:String, modul:mxModule)\n\t\tSetID(mxModUtils.GetIDFromVerID(verid))\n\t\tSetModule(modul)\n\t\tReturn Self\n\tEnd Method\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the modid to be installed.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetID(id:String)\n\t\tm_id = id\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the modid to be installed.\n\t\treturns: The modid to be installed.\n\tEnd Rem\n\tMethod GetID:String()\n\t\tReturn m_id\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the version from the given versioned-module name (e.g. \"foo.bar\/1.02\").\n\t\treturns: True if the version was set, or False if the version could not be found (was not found).\n\t\tabout: The latest version will be set if the given id is Null (or if it isn't versioned (e.g. \"foo.bar\", would result in the latest version being selected)).\n\tEnd Rem\n\tMethod SetVersionFromVerID:Int(verid:String)\n\t\tReturn SetVersionFromName(mxModUtils.GetVersionFromVerID(verid))\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the version to be installed from the given version name (e.g. \"1.02\").\n\t\treturns: True if the version was set, or False if the version could not be set (was not found).\n\t\tabout: The latest version will be set if the given name is Null.\n\tEnd Rem\n\tMethod SetVersionFromName:Int(name:String)\n\t\tIf Not name\n\t\t\tSetVersion(Null) ' Set the latest version (the version wasn't forced)\n\t\t\tReturn True\n\t\tElse\n\t\t\tLocal ver:mxModuleVersion = m_module.GetVersionWithName(name)\n\t\t\tIf ver\n\t\t\t\tSetVersion(ver)\n\t\t\t\tReturn True\n\t\t\tEnd If\n\t\tEnd If\n\t\tReturn False\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the install version.\n\t\treturns: Nothing.\n\t\tabout: If the given value is Null, it will be automatically set to the latest (non-development) version.\n\tEnd Rem\n\tMethod SetVersion(version:mxModuleVersion)\n\t\tm_version = version\n\t\tIf Not m_version\n\t\t\tm_version = m_module.GetLatestVersion()\n\t\tEnd If\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the install version.\n\t\treturns: The version to be installed.\n\tEnd Rem\n\tMethod GetVersion:mxModuleVersion()\n\t\tReturn m_version\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the module to be installed.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetModule(modul:mxModule)\n\t\tm_module = modul\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the module to be installed.\n\t\treturns: The module to be installed.\n\tEnd Rem\n\tMethod GetModule:mxModule()\n\t\tReturn m_module\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the module's scope.\n\t\treturns: The module's scope.\n\tEnd Rem\n\tMethod GetModuleScope:String()\n\t\tReturn mxModUtils.GetScopeFromID(m_id)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the module's name.\n\t\treturns: The module's name.\n\tEnd Rem\n\tMethod GetModuleName:String()\n\t\tReturn mxModUtils.GetNameFromID(m_id)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the versioned-module id.\n\t\treturns: The exact module to be installed (e.g. \"foo.bar\/1.02\").\n\tEnd Rem\n\tMethod GetVerID:String()\n\t\tReturn m_id + \"\/\" + m_version.GetName()\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the name of the version to be installed.\n\t\treturns: The name of the version to be installed.\n\tEnd Rem\n\tMethod GetVersionName:String()\n\t\tReturn m_version.GetName()\n\tEnd Method\n\t\n'#end region Field accessors\n\t\n\tRem\n\t\tbbdoc: Check the dependency compliance of the current module set.\n\t\treturns: Null if all dependencies are matched by existing modules, or a list of module ids that are not yet installed.\n\tEnd Rem\n\tMethod CheckCompliance:TListEx()\n\t\tReturn m_version.GetDependencies().CheckCompliance()\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Fetch the source archive for the version to be installed.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod FetchSourceArchive()\n\t\tm_version.FetchSourceArchive()\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Unpack the version's archive.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod Unpack()\n\t\tLocal archivepath:String = m_version.GetTemporaryFilePath()\n\t\tLocal zreader:ZipReader = New ZipReader\n\t\tlogger.LogMessage(_s(\"message.unpacking\", [archivepath]))\n\t\tIf zreader.OpenZip(archivepath)\n\t\t\tLocal filename:String, outputpath:String\n\t\t\tLocal basepath:String = mainapp.m_modpath + \"\/\" + mxModUtils.GetScopeFromID(m_id) + \".mod\/\"\n\t\t\tDeleteDir(mxModUtils.ModulePath(m_id), True)\n\t\t\tFor Local fileinfo:SZipFileEntry = EachIn zreader.m_zipFileList.FileList\n\t\t\t\tfilename = fileinfo.zipFileName\n\t\t\t\toutputpath = basepath + filename\n\t\t\t\t'DebugLog(\"Zip outputpath: ~q\" + outputpath + \"~q\")\n\t\t\t\tIf filename[filename.Length - 1] = 47 ' \"\/\"\n\t\t\t\t\tCreateDir(outputpath, True)\n\t\t\t\tElse\n\t\t\t\t\tIf CreateFileExplicitly(outputpath)\n\t\t\t\t\t\tzreader.ExtractFileToDisk(filename, outputpath, False)\n\t\t\t\t\tElse\n\t\t\t\t\t\tzreader.CloseZip()\n\t\t\t\t\t\tThrowError(_s(\"error.writeperms\", [outputpath]))\n\t\t\t\t\tEnd If\n\t\t\t\tEnd If\n\t\t\tNext\n\t\t\tzreader.CloseZip()\n\n\t\t\tLocal metafile:mxMetaFile = New mxMetaFile.Create(basepath + GetModuleName() + \".mod\/meta.maximus\")\n\t\t\tmetafile.SetMetaData(GetModuleScope(), GetModuleName(), GetVersionName())\n\t\t\tmetafile.Save()\n\t\tElse\n\t\t\tThrowError(_s(\"error.install.openarchive\", [archivepath]))\n\t\tEnd If\n\tEnd Method\n\t\nEnd Type\n\n","old_contents":"\nRem\n\tbbdoc: Maximus 'install' argument implementation.\nEnd Rem\nType mxInstallImpl Extends dArgumentImplementation\n\t\n\tField m_instmap:dObjectMap\n\tField m_depcheckmap:dObjectMap\n\tField m_unmanagedmap:dObjectMap\n\tField m_nobuild:Int = False, m_nounpack:Int = False, m_keeptemp:Int = False\n\tField m_nothreaded:Int = False, m_makedocs:Int = False, m_forceinstall:Int = False\n\tField m_overwriteunmanaged:Int = False\n\t\n\tMethod New()\n\t\tinit([\"install\"])\n\t\tm_instmap = New dObjectMap\n\t\tm_depcheckmap = New dObjectMap\n\t\tm_unmanagedmap = New dObjectMap\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Check the current arguments for errors (according to the specific implementation).\n\t\treturns: Nothing.\n\t\tabout: This method will throw an error if the arguments are invalid.\n\tEnd Rem\n\tMethod CheckArgs()\n\t\tIf GetArgumentCount() = 0\n\t\t\tThrowCommonError(mxCmdErrors.REQUIRESPARAMS, m_args.GetName())\n\t\tEnd If\n\t\tCheckOptions()\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get a string describing the typical usage of the argument.\n\t\treturns: A string describing the typical usage of the argument.\n\tEnd Rem\n\tMethod GetUsage:String()\n\t\tReturn _s(\"arg.install.usage\")\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Execute the implementation's operation.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod Execute()\n\t\tm_instmap.Clear()\n\t\tm_depcheckmap.Clear()\n\t\tm_unmanagedmap.Clear()\n\t\tIf mainapp.m_sourceshandler\n\t\t\tLocal nfounds:dObjectMap = New dObjectMap\n\t\t\tFor Local svar:dStringVariable = EachIn m_args\n\t\t\t\tLocal verid:String = svar.Get(), modid:String = mxModUtils.GetIDFromVerID(verid)\n\t\t\t\tLocal modul:mxModule = mainapp.m_sourceshandler.GetModuleWithID(modid)\n\t\t\t\tIf modul\n\t\t\t\t\tLocal instmod:mxInstModule = New mxInstModule.Create(verid, modul)\n\t\t\t\t\tIf instmod.SetVersionFromVerID(verid)\n\t\t\t\t\t\tm_instmap._Insert(modid, instmod)\n\t\t\t\t\tElse\n\t\t\t\t\t\tThrowError(_s(\"arg.install.notfound.version\", [modid, mxModUtils.GetVersionFromVerID(verid)]))\n\t\t\t\t\tEnd If\n\t\t\t\tElse\n\t\t\t\t\tnfounds._Insert(modid, modid)\n\t\t\t\tEnd If\n\t\t\tNext\n\t\t\tIf nfounds.Count() > 0\n\t\t\t\tlogger.LogError(_s(\"arg.install.notfound.instmods\"))\n\t\t\t\tLocal a:String\n\t\t\t\tFor Local b:String = EachIn nfounds.ValueEnumerator()\n\t\t\t\t\ta:+ b + \" \"\n\t\t\t\tNext\n\t\t\t\ta = a[..a.Length - 1]\n\t\t\t\tlogger.LogMessage(\"~t\" + a)\n\t\t\t\tReturn\n\t\t\tEnd If\n\t\t\tIf CheckDependencies()\n\t\t\t\t'Make sure we only install\/update managed modules\n\t\t\t\tIf CheckVersions()\n\t\t\t\t\tDoInstall()\n\t\t\t\tEnd If\n\t\t\tEnd If\n\t\tElse\n\t\t\tThrowError(_s(\"error.install.nosources\"))\n\t\tEnd If\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Check the options given to the command.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod CheckOptions()\n\t\tm_nobuild = False; m_nounpack = False; m_keeptemp = False\n\t\tm_nothreaded = False; m_makedocs = False\n\t\tFor Local opt:dIdentifier = EachIn m_args\n\t\t\tSelect opt.GetName().ToLower()\n\t\t\t\tCase \"-nobuild\" m_nobuild = True\n\t\t\t\tCase \"-nounpack\" m_nounpack = True\n\t\t\t\tCase \"-keeptemp\" m_keeptemp = True\n\t\t\t\tCase \"-nothreaded\" m_nothreaded = True\n\t\t\t\tCase \"-makedocs\" m_makedocs = True\n\t\t\t\tCase \"-force\" m_forceinstall = True\n\t\t\t\tCase \"-ignoreunmanaged\" m_overwriteunmanaged = True\n\t\t\t\tDefault ThrowCommonError(mxOptErrors.UNKNOWN, opt.GetName())\n\t\t\tEnd Select\n\t\tNext\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Check for version conflictions and warn the user.\n\t\treturns: True if the installtion should continue, or False if the user halted the operation.\n\tEnd Rem\n\tMethod CheckVersions:Int()\n\t\tFor Local instmod:mxInstModule = EachIn m_instmap.ValueEnumerator()\n\t\t\tLocal ver:String = mxModUtils.GetInstalledVersionFromVerID(instmod.GetVerID())\n\t\t\t'Make sure we skip unmanaged modules\n\t\t\tIf ver = \"unmanaged\"\n\t\t\t\tIf Not m_overwriteunmanaged Then m_instmap._Remove(instmod.GetID())\n\t\t\t\tm_unmanagedmap._Insert(instmod.GetID(), instmod)\n\t\t\tEnd If\n\t\tNext\n\t\tReturn True\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Check the dependencies for the modules to be installed.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod CheckDependencies:Int()\n\t\tLocal nfounds:dObjectMap = New dObjectMap\n\t\tFor Local instmod:mxInstModule = EachIn m_instmap.ValueEnumerator()\n\t\t\tCheckModuleDependencies(instmod, nfounds)\n\t\tNext\n\t\tIf nfounds.Count() > 0\n\t\t\tlogger.LogError(_s(\"arg.install.notfound.instdeps\"))\n\t\t\tLocal a:String\n\t\t\tFor Local b:String = EachIn nfounds.ValueEnumerator()\n\t\t\t\ta:+ b + \" \"\n\t\t\tNext\n\t\t\ta = a[..a.Length - 1]\n\t\t\tlogger.LogMessage(\"~t\" + a)\n\t\t\tIf m_forceinstall\n\t\t\t\tm_nobuild = True\n\t\t\t\tLocal resp:String = Input(_s(\"arg.install.missingdeps\") + \" \").ToLower()\n\t\t\t\tIf resp = \"y\" Or resp = \"yes\"\n\t\t\t\t\tReturn True\n\t\t\t\tEnd If\n\t\t\tEnd If\n\t\t\tReturn False\n\t\tEnd If\n\t\tReturn True\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Check the dependencies for the given module and adapt the install list accordingly.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod CheckModuleDependencies(instmod:mxInstModule, nfounds:dObjectMap)\n\t\tLocal addlist:TListEx = instmod.CheckCompliance()\n\t\tIf addlist\n\t\t\tFor Local modid:String = EachIn addlist\n\t\t\t\tIf Not m_depcheckmap._Contains(modid)\n\t\t\t\t\tLocal dmodul:mxModule = mainapp.m_sourceshandler.GetModuleWithID(modid)\n\t\t\t\t\tm_depcheckmap._Insert(modid, modid)\n\t\t\t\t\tIf dmodul\n\t\t\t\t\t\tIf Not m_instmap._Contains(modid)\n\t\t\t\t\t\t\tLocal dinstmod:mxInstModule = New mxInstModule.Create(modid, dmodul)\n\t\t\t\t\t\t\tIf instmod.GetVersionName().ToLower() = \"dev\"\n\t\t\t\t\t\t\t\tdinstmod.SetVersionFromName(\"dev\")\n\t\t\t\t\t\t\tElse\n\t\t\t\t\t\t\t\tdinstmod.SetVersion(Null)\n\t\t\t\t\t\t\tEnd If\n\t\t\t\t\t\t\tm_instmap._Insert(modid, dinstmod)\n\t\t\t\t\t\t\tCheckModuleDependencies(dinstmod, nfounds)\n\t\t\t\t\t\tEnd If\n\t\t\t\t\tElse\n\t\t\t\t\t\tnfounds._Insert(modid, modid)\n\t\t\t\t\tEnd If\n\t\t\t\tEnd If\n\t\t\tNext\n\t\tEnd If\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Do the actual installing.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod DoInstall()\n\t\tIf m_instmap.Count() > 0\n\t\t\tLocal a:String, instmod:mxInstModule\n\n\t\t\tIf m_unmanagedmap.Count()\n\t\t\t\tIf m_overwriteunmanaged\n\t\t\t\t\tlogger.LogMessage(_s(\"arg.install.modulestooverwrite\"))\n\t\t\t\tElse\n\t\t\t\t\tlogger.LogMessage(_s(\"arg.install.modulestoskip\"))\n\t\t\t\tEnd If\n\t\t\t\tFor instmod = EachIn m_unmanagedmap.ValueEnumerator()\n\t\t\t\t\ta:+instmod.GetVerID() + \" \"\n\t\t\t\tNext\n\t\t\t\ta = a[..a.Length - 1]\n\t\t\t\tlogger.LogMessage(\"~t\" + a)\n\t\t\t\ta = \"\"\n\t\t\tEnd If\n\n\t\t\tlogger.LogMessage(_s(\"arg.install.modulestoinstall\"))\n\t\t\tFor instmod = EachIn m_instmap.ValueEnumerator()\n\t\t\t\ta:+ instmod.GetVerID() + \" \"\n\t\t\tNext\n\t\t\ta = a[..a.Length - 1]\n\t\t\tlogger.LogMessage(\"~t\" + a)\n\t\t\tLocal resp:String = Input(_s(\"arg.install.continuewithinstall\") + \" \").ToLower()\n\t\t\tIf resp = \"y\" Or resp = \"yes\"\n\t\t\t\tFor instmod = EachIn m_instmap.ValueEnumerator()\n\t\t\t\t\tinstmod.FetchSourceArchive()\n\t\t\t\tNext\n\t\t\t\tIf Not m_nounpack\n\t\t\t\t\tFor instmod = EachIn m_instmap.ValueEnumerator()\n\t\t\t\t\t\tinstmod.Unpack()\n\t\t\t\t\tNext\n\t\t\t\tElse\n\t\t\t\t\tlogger.LogMessage(_s(\"message.skipping.unpack\"))\n\t\t\t\tEnd If\n\t\t\t\tIf Not m_keeptemp Then DeleteDir(\"tmp\/\", True)\n\t\t\t\tIf Not m_nobuild\n\t\t\t\t\tLocal scopes:dObjectMap = New dObjectMap\n\t\t\t\t\tFor instmod = EachIn m_instmap.ValueEnumerator()\n\t\t\t\t\t\tscopes._Insert(instmod.GetModuleScope(), instmod.GetModuleScope())\n\t\t\t\t\tNext\n\t\t\t\t\tFor Local scope:String = EachIn scopes.ValueEnumerator()\n\t\t\t\t\t\tIf mxBMKUtils.MakeMods(scope, m_nothreaded ~ 1) <> 0\n\t\t\t\t\t\t\tThrowError(_s(\"error.install.build\", [scope]))\n\t\t\t\t\t\tEnd If\n\t\t\t\t\tNext\n\t\t\t\t\tIf m_makedocs\n\t\t\t\t\t\t'For instmod = EachIn m_instmap.ValueEnumerator()\n\t\t\t\t\t\t'\tmxModUtils.DocMods(instmod.GetID())\n\t\t\t\t\t\t'Next\n\t\t\t\t\t\t' Can't build docs for individual modules yet\n\t\t\t\t\t\tmxModUtils.DocMods()\n\t\t\t\t\tEnd If\n\t\t\t\tElse\n\t\t\t\t\tlogger.LogMessage(_s(\"message.skipping.install\"))\n\t\t\t\tEnd If\n\t\t\tEnd If\n\t\tElse\n\t\t\tlogger.LogMessage(_s(\"arg.install.nomodulestoinstall\"))\n\t\t\tIf m_unmanagedmap.Count()\n\t\t\t\tlogger.LogMessage(_s(\"arg.install.modulestoskip\"))\n\t\t\t\tLocal a:String\n\t\t\t\tFor Local instmod:mxInstModule = EachIn m_unmanagedmap.ValueEnumerator()\n\t\t\t\t\ta:+instmod.GetVerID() + \" \"\n\t\t\t\tNext\n\t\t\t\ta = a[..a.Length - 1]\n\t\t\t\tlogger.LogMessage(\"~t\" + a)\n\t\t\tEnd If\n\t\tEnd If\n\tEnd Method\n\t\nEnd Type\n\nRem\n\tbbdoc: Maximus install info module.\n\tabout: This type is used for temporary install information on modules.\nEnd Rem\nType mxInstModule\n\t\n\tField m_id:String\n\tField m_version:mxModuleVersion\n\tField m_module:mxModule\n\t\n\tRem\n\t\tbbdoc: Create a new mxInstModule.\n\t\treturns: Itself.\n\tEnd Rem\n\tMethod Create:mxInstModule(verid:String, modul:mxModule)\n\t\tSetID(mxModUtils.GetIDFromVerID(verid))\n\t\tSetModule(modul)\n\t\tReturn Self\n\tEnd Method\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the modid to be installed.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetID(id:String)\n\t\tm_id = id\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the modid to be installed.\n\t\treturns: The modid to be installed.\n\tEnd Rem\n\tMethod GetID:String()\n\t\tReturn m_id\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the version from the given versioned-module name (e.g. \"foo.bar\/1.02\").\n\t\treturns: True if the version was set, or False if the version could not be found (was not found).\n\t\tabout: The latest version will be set if the given id is Null (or if it isn't versioned (e.g. \"foo.bar\", would result in the latest version being selected)).\n\tEnd Rem\n\tMethod SetVersionFromVerID:Int(verid:String)\n\t\tReturn SetVersionFromName(mxModUtils.GetVersionFromVerID(verid))\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the version to be installed from the given version name (e.g. \"1.02\").\n\t\treturns: True if the version was set, or False if the version could not be set (was not found).\n\t\tabout: The latest version will be set if the given name is Null.\n\tEnd Rem\n\tMethod SetVersionFromName:Int(name:String)\n\t\tIf Not name\n\t\t\tSetVersion(Null) ' Set the latest version (the version wasn't forced)\n\t\t\tReturn True\n\t\tElse\n\t\t\tLocal ver:mxModuleVersion = m_module.GetVersionWithName(name)\n\t\t\tIf ver\n\t\t\t\tSetVersion(ver)\n\t\t\t\tReturn True\n\t\t\tEnd If\n\t\tEnd If\n\t\tReturn False\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the install version.\n\t\treturns: Nothing.\n\t\tabout: If the given value is Null, it will be automatically set to the latest (non-development) version.\n\tEnd Rem\n\tMethod SetVersion(version:mxModuleVersion)\n\t\tm_version = version\n\t\tIf Not m_version\n\t\t\tm_version = m_module.GetLatestVersion()\n\t\tEnd If\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the install version.\n\t\treturns: The version to be installed.\n\tEnd Rem\n\tMethod GetVersion:mxModuleVersion()\n\t\tReturn m_version\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the module to be installed.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetModule(modul:mxModule)\n\t\tm_module = modul\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the module to be installed.\n\t\treturns: The module to be installed.\n\tEnd Rem\n\tMethod GetModule:mxModule()\n\t\tReturn m_module\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the module's scope.\n\t\treturns: The module's scope.\n\tEnd Rem\n\tMethod GetModuleScope:String()\n\t\tReturn mxModUtils.GetScopeFromID(m_id)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the module's name.\n\t\treturns: The module's name.\n\tEnd Rem\n\tMethod GetModuleName:String()\n\t\tReturn mxModUtils.GetNameFromID(m_id)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the versioned-module id.\n\t\treturns: The exact module to be installed (e.g. \"foo.bar\/1.02\").\n\tEnd Rem\n\tMethod GetVerID:String()\n\t\tReturn m_id + \"\/\" + m_version.GetName()\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the name of the version to be installed.\n\t\treturns: The name of the version to be installed.\n\tEnd Rem\n\tMethod GetVersionName:String()\n\t\tReturn m_version.GetName()\n\tEnd Method\n\t\n'#end region Field accessors\n\t\n\tRem\n\t\tbbdoc: Check the dependency compliance of the current module set.\n\t\treturns: Null if all dependencies are matched by existing modules, or a list of module ids that are not yet installed.\n\tEnd Rem\n\tMethod CheckCompliance:TListEx()\n\t\tReturn m_version.GetDependencies().CheckCompliance()\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Fetch the source archive for the version to be installed.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod FetchSourceArchive()\n\t\tm_version.FetchSourceArchive()\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Unpack the version's archive.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod Unpack()\n\t\tLocal archivepath:String = m_version.GetTemporaryFilePath()\n\t\tLocal zreader:ZipReader = New ZipReader\n\t\tlogger.LogMessage(_s(\"message.unpacking\", [archivepath]))\n\t\tIf zreader.OpenZip(archivepath)\n\t\t\tLocal filename:String, outputpath:String\n\t\t\tLocal basepath:String = mainapp.m_modpath + \"\/\" + mxModUtils.GetScopeFromID(m_id) + \".mod\/\"\n\t\t\tDeleteDir(mxModUtils.ModulePath(m_id), True)\n\t\t\tFor Local fileinfo:SZipFileEntry = EachIn zreader.m_zipFileList.FileList\n\t\t\t\tfilename = fileinfo.zipFileName\n\t\t\t\toutputpath = basepath + filename\n\t\t\t\t'DebugLog(\"Zip outputpath: ~q\" + outputpath + \"~q\")\n\t\t\t\tIf filename[filename.Length - 1] = 47 ' \"\/\"\n\t\t\t\t\tCreateDir(outputpath, True)\n\t\t\t\tElse\n\t\t\t\t\tIf CreateFileExplicitly(outputpath)\n\t\t\t\t\t\tzreader.ExtractFileToDisk(filename, outputpath, False)\n\t\t\t\t\tElse\n\t\t\t\t\t\tzreader.CloseZip()\n\t\t\t\t\t\tThrowError(_s(\"error.writeperms\", [outputpath]))\n\t\t\t\t\tEnd If\n\t\t\t\tEnd If\n\t\t\tNext\n\t\t\tzreader.CloseZip()\n\n\t\t\tLocal metafile:mxMetaFile = New mxMetaFile.Create(basepath + GetModuleName() + \".mod\/meta.maximus\")\n\t\t\tmetafile.SetMetaData(GetModuleScope(), GetModuleName(), GetVersionName())\n\t\t\tmetafile.Save()\n\t\tElse\n\t\t\tThrowError(_s(\"error.install.openarchive\", [archivepath]))\n\t\tEnd If\n\tEnd Method\n\t\nEnd Type\n\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"1e5bb6a7c0ebddd163c7e61f16fc8179c7475244","subject":"Removed experimental D3D11 driver from default imports.","message":"Removed experimental D3D11 driver from default imports.\n","repos":"kfprimm\/maxb3d,kfprimm\/maxb3d","old_file":"drivers.mod\/drivers.bmx","new_file":"drivers.mod\/drivers.bmx","new_contents":"\nStrict\n\nRem\n\tbbdoc: MaxB3D driver collection\nEnd Rem\nModule MaxB3D.Drivers\nModuleInfo \"Author: Kevin Primm\"\nModuleInfo \"License: MIT\"\n\nImport MaxB3D.Core\nImport MaxB3D.B3DCollision\nImport MaxB3D.Primitives\nImport MaxB3D.GLDriver\nImport MaxB3D.D3D9Driver\nImport MaxB3D.Functions\n\n","old_contents":"\nStrict\n\nRem\n\tbbdoc: MaxB3D driver collection\nEnd Rem\nModule MaxB3D.Drivers\nModuleInfo \"Author: Kevin Primm\"\nModuleInfo \"License: MIT\"\n\nImport MaxB3D.Core\nImport MaxB3D.B3DCollision\nImport MaxB3D.Primitives\nImport MaxB3D.GLDriver\nImport MaxB3D.D3D9Driver\nImport MaxB3D.D3D11Driver\nImport MaxB3D.Functions\n\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"6a5353c987d940349593a3bd100e644e25918a29","subject":"Added RuntimeError if developer tries to load a non-valid sound format into MonkeyMax","message":"Added RuntimeError if developer tries to load a non-valid sound format into MonkeyMax\n","repos":"swoolcock\/diddy,swoolcock\/diddy,swoolcock\/diddy,swoolcock\/diddy,swoolcock\/diddy","old_file":"monkeymax\/modules\/mojo\/native\/mojo.bmax.bmx","new_file":"monkeymax\/modules\/mojo\/native\/mojo.bmax.bmx","new_contents":"' ***** Start mojo.bmax.bmx ******\r\n\r\nGlobal app:gxtkApp\r\n\r\nType gxtkApp\r\n\tField ginput:gxtkInput\r\n\tField gaudio:gxtkAudio\r\n\tField ggraphics:gxtkGraphics\r\n\r\n\tField dead:Int=0\r\n\tField suspended:Int=0\r\n\tField vloading:Int=0\r\n\tField maxloading:Int=0\r\n\tField updateRate:Int=0\r\n\tField nextUpdate:Float=0\r\n\tField updatePeriod:Float=0\r\n\tField startMillis:Float=0\r\n\t\r\n\tMethod New()' gxtkApp()\r\n\t\tapp=Self\r\n\t\tggraphics=New gxtkGraphics\r\n\tEndMethod\r\n\t\r\n\tMethod Setup()\r\n\t\tginput=New gxtkInput\r\n\t\tgaudio=New gxtkAudio\r\n\r\n\t\tbb_input_SetInputDevice(ginput)\r\n\t\tbb_audio_SetAudioDevice(gaudio)\r\n\t\t\r\n\t\tstartMillis=BlitzMaxMillisecs()\r\n\t\t\r\n\t\tSetFrameRate( 0 )\r\n\t\t\r\n\t\tInvokeOnCreate()\r\n\t\tInvokeOnRender()\r\n\t\tUpdate()\r\n\tEndMethod\r\n\t\r\n\tMethod Update()\r\n\t\tWhile Not AppTerminate()\r\n\t\t\tLocal updates:Int = 0\r\n\t\t\t\r\n\t\t\tLocal cont:Int = 1\r\n\t\t\tWhile (cont)\r\n\t\t\t\tnextUpdate:+updatePeriod\r\n\t\t\t\tInvokeOnUpdate()\r\n\t\t\t\tIf Not updatePeriod Then cont = 0\r\n\t\t\t\tIf nextUpdate>BlitzMaxMillisecs() Then cont = 0\r\n\t\t\t\tupdates:+1\r\n\t\t\t\tIf updates = 7 Then\r\n\t\t\t\t\tnextUpdate = BlitzMaxMillisecs()\r\n\t\t\t\t\tcont = 0\r\n\t\t\t\tEndIf\r\n\t\t\tWend\r\n\t\t\tInvokeOnRender()\r\n\t\tWend\r\n\tEndMethod\r\n\t\r\n\tMethod InvokeOnCreate()\r\n\t\tIf dead Return\r\n\t\tdead = 1\r\n\t\tOnCreate()\r\n\t\tdead = 0\r\n\tEndMethod\r\n\r\n\tMethod InvokeOnUpdate()\r\n\t\tIf dead Or suspended Or Not updateRate Or vloading Return\r\n\t\tOnUpdate()\r\n\tEndMethod\r\n\t\r\n\tMethod InvokeOnRender()\r\n\t\tIf dead Or suspended Return\r\n\t\tggraphics.BeginRender()\r\n\t\tIf vloading\r\n\t\t\tOnLoading()\r\n\t\tElse\r\n\t\t\tOnRender()\r\n\t\tEndIf\r\n\t\tggraphics.EndRender()\r\n\tEndMethod\r\n\t\r\n\t\r\n\tMethod SetFrameRate( fps:Int )\r\n\t\tIf fps\r\n\t\t\tupdatePeriod=1000.0\/fps\r\n\t\t\tnextUpdate=BlitzMaxMillisecs() +updatePeriod\r\n\t\tElse\r\n\t\t\tupdatePeriod=0\r\n\t\tEndIf\r\n\tEndMethod\r\n\r\n\tMethod LoadState:String()\r\n'\t\tvar file:SharedObject=SharedObject.getLocal( \"gxtkapp\" );\r\n'\t\tvar state:String=file.data.state;\r\n'\t\tfile.close();\r\n'\t\tif( state ) return state;\r\n\t\tReturn \"\"\r\n\tEndMethod\r\n\t\r\n\tMethod SaveState:Int( state:String )\r\n'\t\tvar file:SharedObject=SharedObject.getLocal( \"gxtkapp\" );\r\n'\t\tfile.data.state=state;\r\n'\t\tfile.close();\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod LoadString:String( path:String )\r\n\t\tpath = \"data\/\" + path\r\n\t\tReturn LoadText( path )\r\n\tEndMethod\r\n\t\r\n\t' ***** GXTK API *****\r\n\t\r\n\tMethod GraphicsDevice:gxtkGraphics()\r\n\t\tReturn ggraphics\r\n\tEndMethod\r\n\r\n\tMethod InputDevice:gxtkInput()\r\n\t\tReturn ginput\r\n\tEndMethod\r\n\r\n\tMethod AudioDevice:gxtkAudio()\r\n\t\tReturn gaudio\r\n\tEndMethod\r\n\r\n\tMethod SetUpdateRate:Int(hertz:Int)\r\n\t\tupdateRate = hertz\r\n\t\tIf Not vloading Then SetFrameRate(updateRate)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod MilliSecs:Int()\r\n\t\tReturn BlitzMaxMillisecs() - startMillis\r\n\tEndMethod\r\n\t\r\n\tMethod Loading:Int()\r\n\t\tReturn vloading\r\n\tEndMethod\r\n\r\n\tMethod OnCreate:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod OnUpdate:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod OnSuspend:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod OnResume:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod OnRender:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod OnLoading:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkGraphics\r\n\tField gmode:Int = 1\r\n\r\n\tMethod Mode:Int()\r\n\t\tReturn gmode\r\n\tEndMethod\r\n\t\r\n\tMethod Cls:Int(r:Int = 0, g:Int = 0, b:Int = 0)\r\n\t\tBlitzMaxCls(r, g, b)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawPoint:Int(x:Float, y:Float)\r\n\t\tPlot x, y\r\n\tEndMethod\r\n\t\r\n\tMethod LoadSurface:gxtkSurface(path:String)\r\n\t\tLocal image:TImage = LoadImage(\"data\/\"+path)\r\n\t\tIf image Then\r\n\t\t\tLocal gs:gxtkSurface = New gxtkSurface\r\n\t\t\tgs.setImage(image)\r\n\t\t\tReturn gs\r\n\t\tEndIf\r\n\t\tReturn Null\r\n\tEndMethod\r\n\t\r\n\tMethod BeginRender()\r\n\tEndMethod\r\n\t\r\n\tMethod EndRender()\r\n\t\tFlip\r\n\tEndMethod\r\n\t\r\n\tMethod SetColor:Int(r:Int, g:Int, b:Int)\r\n\t\tBlitzMaxSetColor(r, g, b)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod SetAlpha:Int(a:Float)\r\n\t\tBlitzMaxSetAlpha(a)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod SetBlend:Int(blend:Int)\r\n\t\tBlitzMaxSetBlend(blend)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod Width:Int()\r\n\t\tReturn GraphicsWidth()\r\n\tEndMethod\r\n\t\r\n\tMethod Height:Int()\r\n\t\tReturn GraphicsHeight()\r\n\tEndMethod\r\n\t\r\n\tMethod SetScissor:Int(x:Int, y:Int, w:Int, h:Int)\r\n\t\tSetViewport(x, y, w, h) ' NOT TESTED!\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod SetMatrix:Int(ix:Float,iy:Float,jx:Float,jy:Float,tx:Float,ty:Float)\r\n\t\tLocal sx:Float = Sqr( (ix*ix) + (jx*jx) )\r\n\t\tLocal sy:Float = Sqr( (iy*iy) + (jy*jy) )\r\n\t\tLocal rot:Float = -Atan2( jx, ix )\r\n\t\tSetTransform( rot, sx, sy )\r\n\t\tSetOrigin( tx, ty )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawSurface:Int(surface:gxtkSurface,x:Float,y:Float)\r\n\t\tDrawImage(surface.image, x, y, 0)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawSurface2:Int(surface:gxtkSurface,x:Float,y:Float, srcx:Int, srcy:Int, srcw:Int, srch:Int )\r\n\t\tDrawSubImageRect(surface.image, x, y, srcw, srch, srcx, srcy, srcw, srch)\t\t\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawLine:Int( x1:Float,y1:Float,x2:Float,y2:Float )\r\n\t\tBlitzMaxDrawLine(x1, y1, x2, y2)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawOval:Int( x:Float, y:Float, w:Float, h:Float )\r\n\t\tBlitzMaxDrawOval(x, y, w, h)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawPoly:Int(vertices:Float[])\r\n\t\tBlitzMaxDrawPoly( vertices )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawRect:Int( x:Float, y:Float, w:Float, h:Float )\r\n\t\tBlitzMaxDrawRect(x, y, w, h)\r\n\t\tReturn 0\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkInput\r\n\tMethod MouseX:Float()\r\n\t\tReturn BRL.PolledInput.MouseX()\r\n\tEndMethod\r\n\r\n\tMethod MouseY:Float()\r\n\t\tReturn BRL.PolledInput.MouseY()\r\n\tEndMethod\r\n\t\r\n\tMethod KeyDown:Int( key:Int )\r\n\t\tif( key = 384 ) key = 1 ' change TOUCH0 to MOUSE_LMB\r\n\r\n\t\tIf( key >= 1 And key <= 3 )\r\n\t\t\tReturn BRL.PolledInput.MouseDown( key )\r\n\t\tEndIf\r\n\t\tIf key < 256\r\n\t\t\tReturn BRL.PolledInput.KeyDown( key )\r\n\t\tElse\r\n\t\t\tReturn 0\r\n\t\tEndIf\r\n\tEndMethod\r\n\r\n\tMethod KeyHit:Int( key:Int )\r\n\t\tif( key = 384 ) key = 1 ' change TOUCH0 to MOUSE_LMB\r\n\t\tIf( key >= 1 And key <= 3 )\r\n\t\t\tReturn BRL.PolledInput.MouseHit( key )\r\n\t\tEndIf\r\n\t\tIf key < 256\r\n\t\t\tReturn BRL.PolledInput.KeyHit( key )\r\n\t\tElse\r\n\t\t\tReturn 0\r\n\t\tEndIf\r\n\tEndMethod\r\n\r\n\tMethod GetChar:Int()\r\n\t\tReturn BRL.PolledInput.GetChar()\r\n\tEndMethod\r\n\r\n\tMethod JoyX:Int( index:Int )\r\n\t\tReturn Pub.FreeJoy.JoyX( index )\r\n\tEndMethod\r\n\r\n\tMethod JoyY:Int( index:Int )\r\n\t\tReturn Pub.FreeJoy.JoyY( index )\r\n\tEndMethod\r\n\r\n\tMethod JoyZ:Int( index:Int )\r\n\t\tReturn Pub.FreeJoy.JoyZ( index )\r\n\tEndMethod\r\n\r\n\tMethod TouchX:Float( index:Int )\r\n\t\tReturn BRL.PolledInput.MouseX()\r\n\tEndMethod\r\n\r\n\tMethod TouchY:Float( index:Int )\r\n\t\tReturn BRL.PolledInput.MouseY()\r\n\tEndMethod\r\n\t\r\n\tMethod AccelX:Int()\r\n\t\treturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod AccelY:Int()\r\n\t\treturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod AccelZ:Int()\r\n\t\treturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod SetKeyboardEnabled:Int( enabled:int )\r\n\t\tReturn 0\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkChannel\r\n\tField channel:TChannel\t' null then not playing\r\n\tField sample:gxtkSample\r\n\tField loops:int\r\n\t'Field transform:SoundTransform=new SoundTransform()\r\n\t'Field pausepos:Number\r\n\tField state:int\r\n\t\r\n\tMethod New()\r\n\t\tchannel = New TChannel\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkAudio\r\n\tField amusicState:Int = 0\r\n\tField channels:gxtkChannel[] = New gxtkChannel[33]\r\n\t\r\n\tMethod New()\r\n\t\tFor local i:Int = 0 To 33 - 1\r\n\t\t\tchannels[i] = New gxtkChannel\r\n\t\tNext\r\n\tEndMethod\r\n\t\r\n\tMethod MusicState:Int()\r\n'\t\tIf( musicState = 1 And music.isPlaying() = False )\r\n'\t\t\tmusicState = 0;\r\n'\t\tEndif\r\n\t\tReturn amusicState\r\n\tEndMethod\r\n\t\r\n\tMethod PlayMusic:Int( path:String, flags:Int )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod ChannelState:int( channel:int )\r\n\t\tReturn -1\r\n\tEndMethod\r\n\t\r\n\tMethod StopMusic()\r\n\tEndMethod\r\n\t\r\n\tMethod StopChannel( channel:Int )\r\n\tEndMethod\r\n\r\n\tMethod PlaySample( sound:gxtkSample, channel:Int, flags:Int )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\t\r\n\t\t'If chan.state <> 0 Then chan.channel.Stop() <-- this crashes after the first play!?\r\n\t\t\r\n\t\tchan.sample = sound\r\n\t\t'chan.loops = flags ? 0x7fffffff : 0;\r\n\t\t'chan.channel = sample.sound.play( 0,chan.loops,chan.transform );\r\n\t\t'chan.channel = sound\r\n\t\tchan.state=1\r\n\t\r\n\t\tPlaySound( sound.sound, chan.channel )\r\n\tEndMethod\r\n\r\n\tMethod SetPan( channel:Int, pan:Float )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tchan.channel.SetPan(pan)\r\n\tEndMethod\r\n\r\n\tMethod SetRate( channel:Int, rate:Float )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tchan.channel.SetRate(rate)\r\n\tEndMethod\r\n\r\n\tMethod PauseMusic:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod ResumeMusic:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod SetMusicVolume:Int( volume:Float )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod SetVolume:Int( channel:Int, volume:Float )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tchan.channel.SetVolume(volume)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod LoadSample:gxtkSample( path:String )\r\n\t\tLocal extension:String = ExtractExt( path)\r\n\t\tIf extension = \"ogg\" Or extension = \"wav\" Then\r\n\t\t\tLocal sound:TSound = LoadSound(\"data\/\"+path)\r\n\t\t\tIf sound Then\r\n\t\t\t\tLocal gs:gxtkSample = New gxtkSample\r\n\t\t\t\tgs.setSound(sound)\r\n\t\t\t\tReturn gs\r\n\t\t\tEndIf\r\n\t\tElse\r\n\t\t\tRuntimeError \"BlitzMax can only use ogg and wav file formats\"\r\n\t\tEndIf\r\n\t\tReturn Null\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkSample\r\n\tField sound:TSound\r\n\t\r\n\tMethod setSound(sound:TSound)\r\n\t\tSelf.sound = sound\r\n\tEndMethod\r\n\t\r\n\tMethod Discard()\r\n\t\tSelf.sound = null\r\n\tEndMethod\r\nEndType\r\n\r\nFunction BlitzMaxDrawPoly:Int(vertices:Float[])\r\n\tDrawPoly vertices\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxDrawRect:Int( x:Float, y:Float, w:Float, h:Float )\r\n\tDrawRect x, y, w, h\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxDrawOval:Int( x:Float, y:Float, w:Float, h:Float )\r\n\tDrawOval x, y, w, h\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxDrawLine:Int( x1:Float,y1:Float,x2:Float,y2:Float )\r\n\tDrawLine x1, y1, x2, y2\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxMillisecs:Int()\r\n\tReturn MilliSecs()\r\nEndFunction\r\n\r\nFunction BlitzMaxSetColor(r:Int, g:Int, b:Int)\r\n\tSetColor(r, g, b)\r\nEndFunction\r\n\r\nFunction BlitzMaxSetBlend(blend:Int)\r\n\tSelect blend\r\n\t\tCase 0\r\n\t\t\tSetBlend( ALPHABLEND )\r\n\t\tCase 1\r\n\t\t\tSetBlend( LIGHTBLEND )\r\n\tEnd Select\r\nEndFunction\r\n\r\nFunction BlitzMaxSetAlpha(a:Float)\r\n\tSetAlpha(a)\r\nEndFunction\r\n\r\nFunction BlitzMaxCls(r:Int = 0, g:Int = 0, b:Int = 0)\r\n\tSetClsColor(r, g, b)\r\n\tCls\r\nEndFunction\r\n\r\nType gxtkSurface\r\n\tField w:Int, h:Int\r\n\tField image:TImage\r\n\t\r\n\tMethod setImage(image:TImage)\r\n\t\tSelf.image = image\r\n\tEndMethod\r\n\t\r\n\tMethod Width:Int()\r\n\t\tReturn image.Width\r\n\tEndMethod\r\n\t\r\n\tMethod Height:Int()\r\n\t\tReturn image.Height\r\n\tEndMethod\r\n\t\r\n\tMethod Discard()\r\n\tEndMethod\r\nEndType\r\n\r\n' ***** End mojo.bmax.bmx ******\r\n\r\n","old_contents":"' ***** Start mojo.bmax.bmx ******\r\n\r\nGlobal app:gxtkApp\r\n\r\nType gxtkApp\r\n\tField ginput:gxtkInput\r\n\tField gaudio:gxtkAudio\r\n\tField ggraphics:gxtkGraphics\r\n\r\n\tField dead:Int=0\r\n\tField suspended:Int=0\r\n\tField vloading:Int=0\r\n\tField maxloading:Int=0\r\n\tField updateRate:Int=0\r\n\tField nextUpdate:Float=0\r\n\tField updatePeriod:Float=0\r\n\tField startMillis:Float=0\r\n\t\r\n\tMethod New()' gxtkApp()\r\n\t\tapp=Self\r\n\t\tggraphics=New gxtkGraphics\r\n\tEndMethod\r\n\t\r\n\tMethod Setup()\r\n\t\tginput=New gxtkInput\r\n\t\tgaudio=New gxtkAudio\r\n\r\n\t\tbb_input_SetInputDevice(ginput)\r\n\t\tbb_audio_SetAudioDevice(gaudio)\r\n\t\t\r\n\t\tstartMillis=BlitzMaxMillisecs()\r\n\t\t\r\n\t\tSetFrameRate( 0 )\r\n\t\t\r\n\t\tInvokeOnCreate()\r\n\t\tInvokeOnRender()\r\n\t\tUpdate()\r\n\tEndMethod\r\n\t\r\n\tMethod Update()\r\n\t\tWhile Not AppTerminate()\r\n\t\t\tLocal updates:Int = 0\r\n\t\t\t\r\n\t\t\tLocal cont:Int = 1\r\n\t\t\tWhile (cont)\r\n\t\t\t\tnextUpdate:+updatePeriod\r\n\t\t\t\tInvokeOnUpdate()\r\n\t\t\t\tIf Not updatePeriod Then cont = 0\r\n\t\t\t\tIf nextUpdate>BlitzMaxMillisecs() Then cont = 0\r\n\t\t\t\tupdates:+1\r\n\t\t\t\tIf updates = 7 Then\r\n\t\t\t\t\tnextUpdate = BlitzMaxMillisecs()\r\n\t\t\t\t\tcont = 0\r\n\t\t\t\tEndIf\r\n\t\t\tWend\r\n\t\t\tInvokeOnRender()\r\n\t\tWend\r\n\tEndMethod\r\n\t\r\n\tMethod InvokeOnCreate()\r\n\t\tIf dead Return\r\n\t\tdead = 1\r\n\t\tOnCreate()\r\n\t\tdead = 0\r\n\tEndMethod\r\n\r\n\tMethod InvokeOnUpdate()\r\n\t\tIf dead Or suspended Or Not updateRate Or vloading Return\r\n\t\tOnUpdate()\r\n\tEndMethod\r\n\t\r\n\tMethod InvokeOnRender()\r\n\t\tIf dead Or suspended Return\r\n\t\tggraphics.BeginRender()\r\n\t\tIf vloading\r\n\t\t\tOnLoading()\r\n\t\tElse\r\n\t\t\tOnRender()\r\n\t\tEndIf\r\n\t\tggraphics.EndRender()\r\n\tEndMethod\r\n\t\r\n\t\r\n\tMethod SetFrameRate( fps:Int )\r\n\t\tIf fps\r\n\t\t\tupdatePeriod=1000.0\/fps\r\n\t\t\tnextUpdate=BlitzMaxMillisecs() +updatePeriod\r\n\t\tElse\r\n\t\t\tupdatePeriod=0\r\n\t\tEndIf\r\n\tEndMethod\r\n\r\n\tMethod LoadState:String()\r\n'\t\tvar file:SharedObject=SharedObject.getLocal( \"gxtkapp\" );\r\n'\t\tvar state:String=file.data.state;\r\n'\t\tfile.close();\r\n'\t\tif( state ) return state;\r\n\t\tReturn \"\"\r\n\tEndMethod\r\n\t\r\n\tMethod SaveState:Int( state:String )\r\n'\t\tvar file:SharedObject=SharedObject.getLocal( \"gxtkapp\" );\r\n'\t\tfile.data.state=state;\r\n'\t\tfile.close();\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod LoadString:String( path:String )\r\n\t\tpath = \"data\/\" + path\r\n\t\tReturn LoadText( path )\r\n\tEndMethod\r\n\t\r\n\t' ***** GXTK API *****\r\n\t\r\n\tMethod GraphicsDevice:gxtkGraphics()\r\n\t\tReturn ggraphics\r\n\tEndMethod\r\n\r\n\tMethod InputDevice:gxtkInput()\r\n\t\tReturn ginput\r\n\tEndMethod\r\n\r\n\tMethod AudioDevice:gxtkAudio()\r\n\t\tReturn gaudio\r\n\tEndMethod\r\n\r\n\tMethod SetUpdateRate:Int(hertz:Int)\r\n\t\tupdateRate = hertz\r\n\t\tIf Not vloading Then SetFrameRate(updateRate)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod MilliSecs:Int()\r\n\t\tReturn BlitzMaxMillisecs() - startMillis\r\n\tEndMethod\r\n\t\r\n\tMethod Loading:Int()\r\n\t\tReturn vloading\r\n\tEndMethod\r\n\r\n\tMethod OnCreate:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod OnUpdate:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod OnSuspend:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod OnResume:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod OnRender:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod OnLoading:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkGraphics\r\n\tField gmode:Int = 1\r\n\r\n\tMethod Mode:Int()\r\n\t\tReturn gmode\r\n\tEndMethod\r\n\t\r\n\tMethod Cls:Int(r:Int = 0, g:Int = 0, b:Int = 0)\r\n\t\tBlitzMaxCls(r, g, b)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawPoint:Int(x:Float, y:Float)\r\n\t\tPlot x, y\r\n\tEndMethod\r\n\t\r\n\tMethod LoadSurface:gxtkSurface(path:String)\r\n\t\tLocal image:TImage = LoadImage(\"data\/\"+path)\r\n\t\tIf image Then\r\n\t\t\tLocal gs:gxtkSurface = New gxtkSurface\r\n\t\t\tgs.setImage(image)\r\n\t\t\tReturn gs\r\n\t\tEndIf\r\n\t\tReturn Null\r\n\tEndMethod\r\n\t\r\n\tMethod BeginRender()\r\n\tEndMethod\r\n\t\r\n\tMethod EndRender()\r\n\t\tFlip\r\n\tEndMethod\r\n\t\r\n\tMethod SetColor:Int(r:Int, g:Int, b:Int)\r\n\t\tBlitzMaxSetColor(r, g, b)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod SetAlpha:Int(a:Float)\r\n\t\tBlitzMaxSetAlpha(a)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod SetBlend:Int(blend:Int)\r\n\t\tBlitzMaxSetBlend(blend)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod Width:Int()\r\n\t\tReturn GraphicsWidth()\r\n\tEndMethod\r\n\t\r\n\tMethod Height:Int()\r\n\t\tReturn GraphicsHeight()\r\n\tEndMethod\r\n\t\r\n\tMethod SetScissor:Int(x:Int, y:Int, w:Int, h:Int)\r\n\t\tSetViewport(x, y, w, h) ' NOT TESTED!\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod SetMatrix:Int(ix:Float,iy:Float,jx:Float,jy:Float,tx:Float,ty:Float)\r\n\t\tLocal sx:Float = Sqr( (ix*ix) + (jx*jx) )\r\n\t\tLocal sy:Float = Sqr( (iy*iy) + (jy*jy) )\r\n\t\tLocal rot:Float = -Atan2( jx, ix )\r\n\t\tSetTransform( rot, sx, sy )\r\n\t\tSetOrigin( tx, ty )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawSurface:Int(surface:gxtkSurface,x:Float,y:Float)\r\n\t\tDrawImage(surface.image, x, y, 0)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawSurface2:Int(surface:gxtkSurface,x:Float,y:Float, srcx:Int, srcy:Int, srcw:Int, srch:Int )\r\n\t\tDrawSubImageRect(surface.image, x, y, srcw, srch, srcx, srcy, srcw, srch)\t\t\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawLine:Int( x1:Float,y1:Float,x2:Float,y2:Float )\r\n\t\tBlitzMaxDrawLine(x1, y1, x2, y2)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawOval:Int( x:Float, y:Float, w:Float, h:Float )\r\n\t\tBlitzMaxDrawOval(x, y, w, h)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawPoly:Int(vertices:Float[])\r\n\t\tBlitzMaxDrawPoly( vertices )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawRect:Int( x:Float, y:Float, w:Float, h:Float )\r\n\t\tBlitzMaxDrawRect(x, y, w, h)\r\n\t\tReturn 0\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkInput\r\n\tMethod MouseX:Float()\r\n\t\tReturn BRL.PolledInput.MouseX()\r\n\tEndMethod\r\n\r\n\tMethod MouseY:Float()\r\n\t\tReturn BRL.PolledInput.MouseY()\r\n\tEndMethod\r\n\t\r\n\tMethod KeyDown:Int( key:Int )\r\n\t\tif( key = 384 ) key = 1 ' change TOUCH0 to MOUSE_LMB\r\n\r\n\t\tIf( key >= 1 And key <= 3 )\r\n\t\t\tReturn BRL.PolledInput.MouseDown( key )\r\n\t\tEndIf\r\n\t\tIf key < 256\r\n\t\t\tReturn BRL.PolledInput.KeyDown( key )\r\n\t\tElse\r\n\t\t\tReturn 0\r\n\t\tEndIf\r\n\tEndMethod\r\n\r\n\tMethod KeyHit:Int( key:Int )\r\n\t\tif( key = 384 ) key = 1 ' change TOUCH0 to MOUSE_LMB\r\n\t\tIf( key >= 1 And key <= 3 )\r\n\t\t\tReturn BRL.PolledInput.MouseHit( key )\r\n\t\tEndIf\r\n\t\tIf key < 256\r\n\t\t\tReturn BRL.PolledInput.KeyHit( key )\r\n\t\tElse\r\n\t\t\tReturn 0\r\n\t\tEndIf\r\n\tEndMethod\r\n\r\n\tMethod GetChar:Int()\r\n\t\tReturn BRL.PolledInput.GetChar()\r\n\tEndMethod\r\n\r\n\tMethod JoyX:Int( index:Int )\r\n\t\tReturn Pub.FreeJoy.JoyX( index )\r\n\tEndMethod\r\n\r\n\tMethod JoyY:Int( index:Int )\r\n\t\tReturn Pub.FreeJoy.JoyY( index )\r\n\tEndMethod\r\n\r\n\tMethod JoyZ:Int( index:Int )\r\n\t\tReturn Pub.FreeJoy.JoyZ( index )\r\n\tEndMethod\r\n\r\n\tMethod TouchX:Float( index:Int )\r\n\t\tReturn BRL.PolledInput.MouseX()\r\n\tEndMethod\r\n\r\n\tMethod TouchY:Float( index:Int )\r\n\t\tReturn BRL.PolledInput.MouseY()\r\n\tEndMethod\r\n\t\r\n\tMethod AccelX:Int()\r\n\t\treturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod AccelY:Int()\r\n\t\treturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod AccelZ:Int()\r\n\t\treturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod SetKeyboardEnabled:Int( enabled:int )\r\n\t\tReturn 0\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkChannel\r\n\tField channel:TChannel\t' null then not playing\r\n\tField sample:gxtkSample\r\n\tField loops:int\r\n\t'Field transform:SoundTransform=new SoundTransform()\r\n\t'Field pausepos:Number\r\n\tField state:int\r\n\t\r\n\tMethod New()\r\n\t\tchannel = New TChannel\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkAudio\r\n\tField amusicState:Int = 0\r\n\tField channels:gxtkChannel[] = New gxtkChannel[33]\r\n\t\r\n\tMethod New()\r\n\t\tFor local i:Int = 0 To 33 - 1\r\n\t\t\tchannels[i] = New gxtkChannel\r\n\t\tNext\r\n\tEndMethod\r\n\t\r\n\tMethod MusicState:Int()\r\n'\t\tIf( musicState = 1 And music.isPlaying() = False )\r\n'\t\t\tmusicState = 0;\r\n'\t\tEndif\r\n\t\tReturn amusicState\r\n\tEndMethod\r\n\t\r\n\tMethod PlayMusic:Int( path:String, flags:Int )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod ChannelState:int( channel:int )\r\n\t\tReturn -1\r\n\tEndMethod\r\n\t\r\n\tMethod StopMusic()\r\n\tEndMethod\r\n\t\r\n\tMethod StopChannel( channel:Int )\r\n\tEndMethod\r\n\r\n\tMethod PlaySample( sound:gxtkSample, channel:Int, flags:Int )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\t\r\n\t\t'If chan.state <> 0 Then chan.channel.Stop() <-- this crashes after the first play!?\r\n\t\t\r\n\t\tchan.sample = sound\r\n\t\t'chan.loops = flags ? 0x7fffffff : 0;\r\n\t\t'chan.channel = sample.sound.play( 0,chan.loops,chan.transform );\r\n\t\t'chan.channel = sound\r\n\t\tchan.state=1\r\n\t\r\n\t\tPlaySound( sound.sound, chan.channel )\r\n\tEndMethod\r\n\r\n\tMethod SetPan( channel:Int, pan:Float )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tchan.channel.SetPan(pan)\r\n\tEndMethod\r\n\r\n\tMethod SetRate( channel:Int, rate:Float )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tchan.channel.SetRate(rate)\r\n\tEndMethod\r\n\r\n\tMethod PauseMusic:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod ResumeMusic:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod SetMusicVolume:Int( volume:Float )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod SetVolume:Int( channel:Int, volume:Float )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tchan.channel.SetVolume(volume)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod LoadSample:gxtkSample( path:String )\r\n\t\tLocal sound:TSound = LoadSound(\"data\/\"+path)\r\n\t\tIf sound Then\r\n\t\t\tLocal gs:gxtkSample = New gxtkSample\r\n\t\t\tgs.setSound(sound)\r\n\t\t\tReturn gs\r\n\t\tEndIf\r\n\t\tReturn Null\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkSample\r\n\tField sound:TSound\r\n\t\r\n\tMethod setSound(sound:TSound)\r\n\t\tSelf.sound = sound\r\n\tEndMethod\r\n\t\r\n\tMethod Discard()\r\n\t\tSelf.sound = null\r\n\tEndMethod\r\nEndType\r\n\r\nFunction BlitzMaxDrawPoly:Int(vertices:Float[])\r\n\tDrawPoly vertices\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxDrawRect:Int( x:Float, y:Float, w:Float, h:Float )\r\n\tDrawRect x, y, w, h\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxDrawOval:Int( x:Float, y:Float, w:Float, h:Float )\r\n\tDrawOval x, y, w, h\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxDrawLine:Int( x1:Float,y1:Float,x2:Float,y2:Float )\r\n\tDrawLine x1, y1, x2, y2\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxMillisecs:Int()\r\n\tReturn MilliSecs()\r\nEndFunction\r\n\r\nFunction BlitzMaxSetColor(r:Int, g:Int, b:Int)\r\n\tSetColor(r, g, b)\r\nEndFunction\r\n\r\nFunction BlitzMaxSetBlend(blend:Int)\r\n\tSelect blend\r\n\t\tCase 0\r\n\t\t\tSetBlend( ALPHABLEND )\r\n\t\tCase 1\r\n\t\t\tSetBlend( LIGHTBLEND )\r\n\tEnd Select\r\nEndFunction\r\n\r\nFunction BlitzMaxSetAlpha(a:Float)\r\n\tSetAlpha(a)\r\nEndFunction\r\n\r\nFunction BlitzMaxCls(r:Int = 0, g:Int = 0, b:Int = 0)\r\n\tSetClsColor(r, g, b)\r\n\tCls\r\nEndFunction\r\n\r\nType gxtkSurface\r\n\tField w:Int, h:Int\r\n\tField image:TImage\r\n\t\r\n\tMethod setImage(image:TImage)\r\n\t\tSelf.image = image\r\n\tEndMethod\r\n\t\r\n\tMethod Width:Int()\r\n\t\tReturn image.Width\r\n\tEndMethod\r\n\t\r\n\tMethod Height:Int()\r\n\t\tReturn image.Height\r\n\tEndMethod\r\n\t\r\n\tMethod Discard()\r\n\tEndMethod\r\nEndType\r\n\r\n' ***** End mojo.bmax.bmx ******\r\n\r\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"1cbed3b8c9f6967a637c81adf46078860f89e71b","subject":"[variables] (v0.21) \tCorrected TVariable.RawToVariable parsing for eval variables; added allowevalvars option","message":"[variables] (v0.21)\n\tCorrected TVariable.RawToVariable parsing for eval variables; added allowevalvars option\n","repos":"komiga\/duct-max,komiga\/duct-max,komiga\/duct-max","old_file":"variables.mod\/variables.bmx","new_file":"variables.mod\/variables.bmx","new_contents":"\nRem\nCopyright (c) 2010 Tim Howard\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and\/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\nEnd Rem\n\nSuperStrict\n\nRem\nbbdoc: Variables module\nEnd Rem\nModule duct.variables\n\nModuleInfo \"Version: 0.21\"\nModuleInfo \"Copyright: Tim Howard\"\nModuleInfo \"License: MIT\"\n\nModuleInfo \"History: Version 0.21\"\nModuleInfo \"History: Corrected TVariable.RawToVariable parsing for eval variables; added allowevalvars option\"\nModuleInfo \"History: Version 0.20\"\nModuleInfo \"History: Added TBoolVariable support in TVariable.DeserializeUniversal\"\nModuleInfo \"History: Added TBoolVariable support in TVariable.RawToVariable\"\nModuleInfo \"History: Fixed an issue with eval variables in TVariable.RawToVariable\"\nModuleInfo \"History: Corrected some method names and some documentation.\"\nModuleInfo \"History: Version 0.19\"\nModuleInfo \"History: Added TBoolVariable; documentation correction\"\nModuleInfo \"History: Version 0.18\"\nModuleInfo \"History: TIdentifier.AddValue now sets the variable's parent to itself\"\nModuleInfo \"History: Added SetParent and GetParent to TVaraible\"\nModuleInfo \"History: Version 0.17\"\nModuleInfo \"History: General cleanup\"\nModuleInfo \"History: Version 0.16\"\nModuleInfo \"History: Added SetAmbiguous to all TVariable types\"\nModuleInfo \"History: Added option to always use quoting with TStringVariables (on by default)\"\nModuleInfo \"History: Fixed TStringVariable.ConvToString returning of Null strings\"\nModuleInfo \"History: Version 0.15\"\nModuleInfo \"History: Change the Create method definition for easier use\"\nModuleInfo \"History: Changed the '\/eval::' recognizer to '\/e:' (as per SNode format change)\"\nModuleInfo \"History: Added the Copy method to every variable type\"\nModuleInfo \"History: Changed some formatting\"\nModuleInfo \"History: Version 0.14\"\nModuleInfo \"History: Changed type tabbing\"\nModuleInfo \"History: Fixed script output for TStringVariable (quotes are now only added if whitespace is present)\"\nModuleInfo \"History: Fixed script output for TIdentifier (identifier names can now contain whitespace, in which case they must be quoted)\"\nModuleInfo \"History: Version 0.13\"\nModuleInfo \"History: Added the DeserializeUniversal function to TVariable\"\nModuleInfo \"History: Added Serialize and Deserialize methods to all variable types\"\nModuleInfo \"History: Version 0.12\"\nModuleInfo \"History: Changed module name from 'variablemap' to 'variables'\"\nModuleInfo \"History: Moved all of duct.utilparser here\"\nModuleInfo \"History: Added the GetTVType function to all variable types\"\nModuleInfo \"History: Moved TV_* constants from duct.template here\"\nModuleInfo \"History: Version 0.11\"\nModuleInfo \"History: Added the ReportType function to all variable types\"\nModuleInfo \"History: Version 0.10\"\nModuleInfo \"History: Added the RawToVariable function to TVariable\"\nModuleInfo \"History: General code cleanup\"\nModuleInfo \"History: Version 0.09\"\nModuleInfo \"History: Corrected usage of syntax (in Returns, Cases, News and Selects)\"\nModuleInfo \"History: Version 0.08\"\nModuleInfo \"History: Added the TEvalVariable type\"\nModuleInfo \"History: Initial release\"\n\nImport brl.stream\n\nImport duct.etc\nImport duct.objectmap\n\nRem\n\tbbdoc: Template variable type for the #TIntVariable type.\nEnd Rem\nConst TV_INTEGER:Int = 1\nRem\n\tbbdoc: Template variable type for the #TStringVariable type.\nEnd Rem\nConst TV_STRING:Int = 2\nRem\n\tbbdoc: Template variable type for the #TFloatVariable type.\nEnd Rem\nConst TV_FLOAT:Int = 3\nRem\n\tbbdoc: Template variable type for the #TEvalVariable type.\nEnd Rem\nConst TV_EVAL:Int = 4\nRem\n\tbbdoc: Template variable type for the #TIdentifier type.\nEnd Rem\nConst TV_IDEN:Int = 5\nRem\n\tbbdoc: Template variable type for the #TBoolVariable type.\nEnd Rem\nConst TV_BOOL:Int = 6\n\nRem\n\tbbdoc: Generic variable type.\n\tabout: This is the base variable type, you should extend from this to use it.\nEnd Rem\nType TVariable Abstract\n\t\n\tField m_name:String\n\tField m_parent:TVariable\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the variable's name.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetName(name:String)\n\t\tm_name = name\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the variable's name.\n\t\treturns: The variable's name.\n\tEnd Rem\n\tMethod GetName:String()\n\t\tReturn m_name\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the variable's parent.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetParent(parent:TVariable)\n\t\tm_parent = parent\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the variable's parent.\n\t\treturns: The variable's parent.\n\tEnd Rem\n\tMethod GetParent:TVariable()\n\t\tReturn m_parent\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Base method for setting the value of the variable to the given string (conversion).\n\tEnd Rem\n\tMethod SetAmbiguous(value:String) Abstract\n\t\n\tRem\n\t\tbbdoc: Base method for converting variable data to a script-ready string.\n\tEnd Rem\n\tMethod ConvToString:String() Abstract\n\t\n\tRem\n\t\tbbdoc: Base method for converting variable data to a printable\/usable-in-code string.\n\tEnd Rem\n\tMethod ValueAsString:String() Abstract\n\t\n'#end region (Field accessors)\n\t\n'#region Data handling\n\t\n\tRem\n\t\tbbdoc: Create a copy of the variable.\n\t\treturns: A clone of the variable.\n\tEnd Rem\n\tMethod Copy:TVariable() Abstract\n\t\n\tRem\n\t\tbbdoc: Serialize the variable to a stream.\n\t\treturns: Nothing.\n\t\tabout: @tv tells the method whether it should serialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod Serialize(stream:TStream, tv:Int = True, name:Int = False) Abstract\n\t\n\tRem\n\t\tbbdoc: Deserialize the variable from a stream.\n\t\treturns: The deserialized variable.\n\t\tabout: @tv tells the method whether it should deserialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod Deserialize:TVariable(stream:TStream, tv:Int = True, name:Int = False) Abstract\n\t\n'#end region (Data handling)\n\t\n\tRem\n\t\tbbdoc: Base method: Get the type of this variable.\n\tEnd Rem\n\tFunction ReportType:String() Abstract\n\t\n\tRem\n\t\tbbdoc: Base method: Get the TV_* type of this variable.\n\tEnd Rem\n\tFunction GetTVType:Int() Abstract\n\t\n\tRem\n\t\tbbdoc: Convert raw data (raw data being things like: \"\/e:(a+b\/0.4181)*a-b\" - a TEvalVariable, \"A String variable\", 3452134 - a TIntVariable, 1204.00321 - a FloatVariable) into a Variable.\n\t\treturns: A new Variable, or Null if something whacky occured.\n\t\tabout: @etype is optional, it is used to go automagically to one type of a Variable (1 & 4=String (will check for '\/e:' - TEvalVariables and TBoolVariables ['true' or 'false']), 2=Integer, 3=Float).\n\t\t@varname is also an optional parameter. It will be used as the name of the variable.\n\t\tIf @allowevalvars (defaults to False) is True, eval variables will be checked for.\n\tEnd Rem\n\tFunction RawToVariable:TVariable(vraw:String, etype:Int = 0, varname:String = \"\", allowevalvars:Int = False)\n\t\tLocal variable:TVariable\n\t\tIf vraw = Null\n\t\t\tDebugLog(\"(TVariable.RawToVariable) @vraw = Null; returning StringVariable (with @varname and Null value)\")\n\t\t\tReturn New TStringVariable.Create(varname, Null)\n\t\tEnd If\n\t\tIf etype = 0 ' Determine the value's type (must be either integer, double, or a string with no spaces)\n\t\t\t' ASCII '0' to '9' = 48-57; '-' = 45, '+' = 43; and '.' = 46\n\t\t\tFor Local i:Int = 0 To vraw.Length - 1\n\t\t\t\tLocal c:Int = vraw[i]\n\t\t\t\tIf c >= 48 And c <= 57 Or c = 43 Or c = 45\n\t\t\t\t\tIf etype = 0 ' Leave float and string alone\n\t\t\t\t\t\tetype = 2 ' Integer so far..\n\t\t\t\t\tEnd If\n\t\t\t\tElse If c = 46\n\t\t\t\t\tIf etype = 2 ' Already declared as an integer?\n\t\t\t\t\t\tetype = 3\n\t\t\t\t\tEnd If\n\t\t\t\tElse ' If the character is not numerical there is nothing else to deduce and the value is a string\n\t\t\t\t\tetype = 4\n\t\t\t\t\tExit\n\t\t\t\tEnd If\n\t\t\tNext\n\t\t\t\n\t\t\tSelect etype\n\t\t\t\tCase 2 ' Integer\n\t\t\t\t\tvariable = TVariable(New TIntVariable.Create(varname, Int(vraw)))\n\t\t\t\tCase 3 ' Double\/Float\n\t\t\t\t\tvariable = TVariable(New TFloatVariable.Create(varname, Float(vraw)))\n\t\t\tEnd Select\n\t\tEnd If\n\t\t\n\t\tIf etype = 1 Or etype = 4\n\t\t\tLocal vrawlower:String = vraw.ToLower()\n\t\t\tIf vrawlower.StartsWith(\"\/e:\") = True and allowevalvars = True\n\t\t\t\tvariable = TVariable(New TEvalVariable.Create(varname, vraw[2..]))\n\t\t\tElse If vrawlower = \"true\" Or vrawlower = \"false\"\n\t\t\t\tvariable = New TBoolVariable.Create(varname, (vrawlower = \"true\") And True Or False)\n\t\t\tElse\n\t\t\t\tvariable = TVariable(New TStringVariable.Create(varname, vraw))\n\t\t\tEnd If\n\t\tEnd If\n\t\t' DebugLog(\"TSNode.LoadScriptFromStream().RawToVariable(); vraw = ~q\" + vraw + \"~q \\\" + etype)\n\t\t?Debug\n\t\tIf variable = Null Then DebugLog(\"( TVariable.RawToVariable() ) Unknown error, 'variable' is Null.\")\n\t\t?\n\t\tReturn variable\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Universally deserialize a variable from the given stream.\n\t\treturns: A Deserialized variable.\n\t\tabout: This will deserialize any variable from the stream.\n\t\tThis requires the variable to have been serialized with the template type (see #Serialize parameters).\n\t\t@name tells the further Deserialize calls if the name should be Deserialized or not.\n\tEnd Rem\n\tFunction DeserializeUniversal:TVariable(stream:TStream, name:Int = False)\n\t\tLocal tv:Int = Int(stream.ReadByte())\n\t\tSelect tv\n\t\t\tCase TV_INTEGER\n\t\t\t\tReturn New TIntVariable.Deserialize(stream, True, name)\n\t\t\tCase TV_STRING\n\t\t\t\tReturn New TStringVariable.Deserialize(stream, True, name)\n\t\t\tCase TV_FLOAT\n\t\t\t\tReturn New TFloatVariable.Deserialize(stream, True, name)\n\t\t\tCase TV_EVAL\n\t\t\t\tReturn New TEvalVariable.Deserialize(stream, True, name)\n\t\t\tCase TV_IDEN\n\t\t\t\tReturn New TIdentifier.Deserialize(stream, True, name)\n\t\t\tCase TV_BOOL\n\t\t\t\tReturn New TBoolVariable.Deserialize(stream, True, name)\n\t\t\tDefault\n\t\t\t\tDebugLog(\"(TVariable.DeserializeUniversal) Failed to recognize the TV in the stream: \" + tv)\n\t\tEnd Select\n\t\tReturn Null\n\tEnd Function\n\t\nEnd Type\n\nRem\n\tbbdoc: String variable.\nEnd Rem\nType TStringVariable Extends TVariable\n\t\n\tGlobal m_alwaysusequotes:Int = True\n\t\n\tField m_value:String\n\t\n\tRem\n\t\tbbdoc: Create a new StringVariable.\n\t\treturns: The new StringVariable (itself).\n\tEnd Rem\n\tMethod Create:TStringVariable(name:String = Null, value:String)\n\t\tSetName(name)\n\t\tSet(value)\n\t\tReturn Self\n\tEnd Method\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the variable's value.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod Set(value:String)\n\t\tm_value = value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the variable's value.\n\t\treturns: The value of the variable.\n\tEnd Rem\n\tMethod Get:String()\n\t\tReturn m_value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the value of the TStringVariable to the given string (ambiguous).\n\t\treturns: Nothing.\n\t\tabout: For this type, this method is no different than calling #Set.\n\tEnd Rem\n\tMethod SetAmbiguous(value:String)\n\t\tm_value = value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Convert the variable to a String.\n\t\treturns: A String representation of the variable.\n\t\tabout: This function is for script output, for in-code use see #ValueAsString.\n\tEnd Rem\n\tMethod ConvToString:String()\n\t\tIf m_alwaysusequotes = True Or m_value.Contains(\"~t\") Or m_value.Contains(\" \") Or m_value = Null\n\t\t\tReturn \"~q\" + m_value + \"~q\"\n\t\tElse\n\t\t\tReturn m_value\n\t\tEnd If\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the StringVariable as a String.\n\t\treturns: The variable's value converted to a String.\n\t\tabout: Here for complete-ness, no difference to `instance.Get()`.\n\tEnd Rem\n\tMethod ValueAsString:String()\n\t\tReturn m_value\n\tEnd Method\n\t\n'#end region (Field accessors)\n\t\n'#region Data handling\n\t\n\tRem\n\t\tbbdoc: Create a copy of the variable\n\t\treturns: A clone of the variable.\n\tEnd Rem\n\tMethod Copy:TStringVariable()\n\t\tReturn New TStringVariable.Create(m_name, m_value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Serialize the variable to a stream.\n\t\treturns: Nothing.\n\t\tabout: @tv tells the method whether it should serialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod Serialize(stream:TStream, tv:Int = True, name:Int = False)\n\t\tIf tv = True\n\t\t\tstream.WriteByte(TV_STRING)\n\t\tEnd If\n\t\tIf name = True\n\t\t\tWriteLString(stream, m_name)\n\t\tEnd If\n\t\t\n\t\tWriteLString(stream, m_value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Deserialize the variable from a stream.\n\t\treturns: The deserialized variable.\n\t\tabout: @tv tells the method whether it should deserialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod Deserialize:TStringVariable(stream:TStream, tv:Int = True, name:Int = False)\n\t\tIf tv = True\n\t\t\tstream.ReadByte()\n\t\tEnd If\n\t\tIf name = True\n\t\t\tm_name = ReadLString(stream)\n\t\tEnd If\n\t\t\n\t\tm_value = ReadLString(stream)\n\t\tReturn Self\n\tEnd Method\n\t\n'#end region (Data handling)\n\t\n\tRem\n\t\tbbdoc: Get the type of this variable.\n\t\treturns: The type of this variable (\"string\").\n\tEnd Rem\n\tFunction ReportType:String()\n\t\tReturn \"string\"\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Get the TV type of this variable.\n\t\treturns: The TV_* type of this variable (TV_STRING).\n\tEnd Rem\n\tFunction GetTVType:Int()\n\t\tReturn TV_STRING\n\tEnd Function\n\t\nEnd Type\n\nRem\n\tbbdoc: Float variable.\nEnd Rem\nType TFloatVariable Extends TVariable\n\t\n\tField m_value:Float\n\t\n\tRem\n\t\tbbdoc: Create a new FloatVariable.\n\t\treturns: The new FloatVariable (itself).\n\tEnd Rem\n\tMethod Create:TFloatVariable(name:String = Null, value:Float)\n\t\tSetName(name)\n\t\tSet(value)\n\t\tReturn Self\n\tEnd Method\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the variable's value.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod Set(value:Float)\n\t\tm_value = value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the variable's value.\n\t\treturns: The value of the variable.\n\tEnd Rem\n\tMethod Get:Float()\n\t\tReturn m_value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the value of the variable to the given string (ambiguous).\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetAmbiguous(value:String)\n\t\tm_value = Float(value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Convert the variable to a String.\n\t\treturns: A scriptable form of the StringVariable.\n\t\tabout: This function is for script output, for in-code use see #ValueAsString.\n\tEnd Rem\n\tMethod ConvToString:String()\n\t\tLocal conv:String = String(m_value), i:Int, encountered:Int\n\t\t\n\t\tFor i = conv.Find(\".\") To conv.Length - 1\n\t\t\tIf conv[i] = 48\n\t\t\t\tIf encountered = True\n\t\t\t\t\tconv = conv[..i]\n\t\t\t\t\tExit\n\t\t\t\tEnd If\n\t\t\tElse If conv[i] <> 46\n\t\t\t\tencountered = True\n\t\t\tEnd If\n\t\tNext\n\t\t\n\t\tReturn conv\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the FloatVariable as a String.\n\t\treturns: The variable's value converted to a String.\n\tEnd Rem\n\tMethod ValueAsString:String()\n\t\tReturn String(m_value)\n\tEnd Method\n\t\n'#end region (Field accessors)\n\t\n'#region Data handling\n\t\n\tRem\n\t\tbbdoc: Create a copy of the variable\n\t\treturns: A clone of the variable.\n\tEnd Rem\n\tMethod Copy:TFloatVariable()\n\t\tReturn New TFloatVariable.Create(m_name, m_value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Serialize the variable to a stream.\n\t\treturns: Nothing.\n\t\tabout: @tv tells the method whether it should serialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod Serialize(stream:TStream, tv:Int = True, name:Int = False)\n\t\tIf tv = True\n\t\t\tstream.WriteByte(TV_FLOAT)\n\t\tEnd If\n\t\tIf name = True\n\t\t\tWriteLString(stream, m_name)\n\t\tEnd If\n\t\tstream.WriteFloat(m_value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Deserialize the variable from a stream.\n\t\treturns: The deserialized variable.\n\t\tabout: @tv tells the method whether it should deserialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod Deserialize:TFloatVariable(stream:TStream, tv:Int = True, name:Int = False)\n\t\tIf tv = True\n\t\t\tstream.ReadByte()\n\t\tEnd If\n\t\tIf name = True\n\t\t\tm_name = ReadLString(stream)\n\t\tEnd If\n\t\tm_value = stream.ReadFloat()\n\t\tReturn Self\n\tEnd Method\n\t\n'#end region (Data handling)\n\t\n\tRem\n\t\tbbdoc: Get the type of this variable.\n\t\treturns: The type of this variable (\"float\").\n\tEnd Rem\n\tFunction ReportType:String()\n\t\tReturn \"float\"\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Get the TV type of this variable.\n\t\treturns: The TV_* type of this variable (TV_FLOAT).\n\tEnd Rem\n\tFunction GetTVType:Int()\n\t\tReturn TV_FLOAT\n\tEnd Function\n\t\nEnd Type\n\nRem\n\tbbdoc: Integer variable.\nEnd Rem\nType TIntVariable Extends TVariable\n\t\n\tField m_value:Int\n\t\n\tRem\n\t\tbbdoc: Create a new IntVariable.\n\t\treturns: The new IntVariable (itself).\n\tEnd Rem\n\tMethod Create:TIntVariable(name:String = Null, value:Int)\n\t\tSetName(name)\n\t\tSet(value)\n\t\tReturn Self\n\tEnd Method\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the variable's value.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod Set(value:Int)\n\t\tm_value = value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the variable's value.\n\t\treturns: The value of the variable.\n\tEnd Rem\n\tMethod Get:Int()\n\t\tReturn m_value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the value of the variable to the given string (ambiguous).\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetAmbiguous(value:String)\n\t\tm_value = Int(value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Convert the variable to a String.\n\t\treturns: A string representation of the variable.\n\t\tabout: This function is for script output, for in-code use see #ValueAsString.\n\tEnd Rem\n\tMethod ConvToString:String()\n\t\tReturn String(m_value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the IntVariable as a String.\n\t\treturns: The variable's value converted to a String.\n\tEnd Rem\n\tMethod ValueAsString:String()\n\t\tReturn String(m_value)\n\tEnd Method\n\t\n'#end region (Field accessors)\n\t\n'#region Data handling\n\t\n\tRem\n\t\tbbdoc: Create a copy of the variable\n\t\treturns: A clone of the variable.\n\tEnd Rem\n\tMethod Copy:TIntVariable()\n\t\tReturn New TIntVariable.Create(m_name, m_value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Serialize the variable to a stream.\n\t\treturns: Nothing.\n\t\tabout: @tv tells the method whether it should serialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod Serialize(stream:TStream, tv:Int = True, name:Int = False)\n\t\tIf tv = True\n\t\t\tstream.WriteByte(TV_INTEGER)\n\t\tEnd If\n\t\tIf name = True\n\t\t\tWriteLString(stream, m_name)\n\t\tEnd If\n\t\t\n\t\tstream.WriteInt(m_value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Deserialize the variable from a stream.\n\t\treturns: The deserialized variable.\n\t\tabout: @tv tells the method whether it should deserialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod Deserialize:TIntVariable(stream:TStream, tv:Int = True, name:Int = False)\n\t\tIf tv = True\n\t\t\tstream.ReadByte()\n\t\tEnd If\n\t\tIf name = True\n\t\t\tm_name = ReadLString(stream)\n\t\tEnd If\n\t\t\n\t\tm_value = stream.ReadInt()\n\t\tReturn Self\n\tEnd Method\n\t\n'#end region (Data handling)\n\t\n\tRem\n\t\tbbdoc: Get the type of this variable.\n\t\treturns: The type of this variable (\"int\").\n\tEnd Rem\n\tFunction ReportType:String()\n\t\tReturn \"int\"\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Get the TV type of this variable.\n\t\treturns: The TV_* type of this variable (TV_INTEGER).\n\tEnd Rem\n\tFunction GetTVType:Int()\n\t\tReturn TV_INTEGER\n\tEnd Function\n\t\nEnd Type\n\nRem\n\tbbdoc: Eval variable (for bah.muparser, and the likes).\nEnd Rem\nType TEvalVariable Extends TVariable\n\t\n\tField m_value:String\n\t\n\tRem\n\t\tbbdoc: Create a new EvalVariable.\n\t\treturns: The new EvalVariable (itself).\n\tEnd Rem\n\tMethod Create:TEvalVariable(name:String = Null, value:String)\n\t\tSetName(name)\n\t\tSet(value)\n\t\tReturn Self\n\tEnd Method\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the equation string for the EvalVariable.\n\t\treturns: Nothing\n\tEnd Rem\n\tMethod Set(value:String)\n\t\tm_value = value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the equation string.\n\t\treturns: The equation string.\n\tEnd Rem\n\tMethod Get:String()\n\t\tReturn m_value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the value of the variable to the given string (ambiguous).\n\t\treturns: Nothing.\n\t\tabout: For this type, this method is no different than calling #Set.\n\tEnd Rem\n\tMethod SetAmbiguous(value:String)\n\t\tm_value = value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Convert the EvalVariable to a visual representation of its data.\n\t\treturns: The scriptable form of the EvalVariable.\n\t\tabout: This function is for script output, for in-code use see #ValueAsString.\n\tEnd Rem\n\tMethod ConvToString:String()\n\t\tReturn \"~q\/e:\" + m_value + \"~q\"\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the EvalVariable as a String.\n\t\treturns: The variable's value converted to a String.\n\tEnd Rem\n\tMethod ValueAsString:String()\n\t\tReturn m_value\n\tEnd Method\n\t\n'#end region (Field accessors)\n\t\n'#region Data handling\n\t\n\tRem\n\t\tbbdoc: Create a copy of the variable\n\t\treturns: A clone of the variable.\n\tEnd Rem\n\tMethod Copy:TEvalVariable()\n\t\tReturn New TEvalVariable.Create(m_name, m_value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Serialize the variable to a stream.\n\t\treturns: Nothing.\n\t\tabout: @tv tells the method whether it should serialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod Serialize(stream:TStream, tv:Int = True, name:Int = False)\n\t\tIf tv = True\n\t\t\tstream.WriteByte(TV_EVAL)\n\t\tEnd If\n\t\tIf name = True\n\t\t\tWriteLString(stream, m_name)\n\t\tEnd If\n\t\t\n\t\tWriteLString(stream, m_value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Deserialize the variable from a stream.\n\t\treturns: The deserialized variable.\n\t\tabout: @tv tells the method whether it should deserialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod Deserialize:TEvalVariable(stream:TStream, tv:Int = True, name:Int = False)\n\t\tIf tv = True\n\t\t\tstream.ReadByte()\n\t\tEnd If\n\t\tIf name = True\n\t\t\tm_name = ReadLString(stream)\n\t\tEnd If\n\t\t\n\t\tm_value = ReadLString(stream)\n\t\tReturn Self\n\tEnd Method\n\t\n'#end region (Data handling)\n\t\n\tRem\n\t\tbbdoc: Get the type of this variable.\n\t\treturns: The type of this variable (\"eval\").\n\tEnd Rem\n\tFunction ReportType:String()\n\t\tReturn \"eval\"\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Get the TV type of this variable.\n\t\treturns: The TV_* type of this variable (TV_EVAL).\n\tEnd Rem\n\tFunction GetTVType:Int()\n\t\tReturn TV_EVAL\n\tEnd Function\n\t\nEnd Type\n\nRem\n\tbbdoc: Boolean variable.\nEnd Rem\nType TBoolVariable Extends TVariable\n\t\n\tField m_value:Int\n\t\n\tRem\n\t\tbbdoc: Create a new BoolVariable.\n\t\treturns: The new BoolVariable (itself).\n\tEnd Rem\n\tMethod Create:TBoolVariable(name:String = Null, value:Int)\n\t\tSetName(name)\n\t\tSet(value)\n\t\tReturn Self\n\tEnd Method\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the variable's value.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod Set(value:Int)\n\t\tm_value = value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the variable's value.\n\t\treturns: The value of the variable.\n\tEnd Rem\n\tMethod Get:Int()\n\t\tReturn m_value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the value of the variable to the given string (ambiguous).\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetAmbiguous(value:String)\n\t\tm_value = Int(value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Convert the variable to a String.\n\t\treturns: A string representation of the variable.\n\t\tabout: This function is for script output, for in-code use see #ValueAsString.\n\tEnd Rem\n\tMethod ConvToString:String()\n\t\tReturn String(m_value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the TBoolVariable as a String.\n\t\treturns: The variable's value converted to a String.\n\tEnd Rem\n\tMethod ValueAsString:String()\n\t\tReturn String(m_value)\n\tEnd Method\n\t\n'#end region (Field accessors)\n\t\n'#region Data handling\n\t\n\tRem\n\t\tbbdoc: Create a copy of the variable\n\t\treturns: A clone of the variable.\n\tEnd Rem\n\tMethod Copy:TBoolVariable()\n\t\tReturn New TBoolVariable.Create(m_name, m_value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Serialize the variable to a stream.\n\t\treturns: Nothing.\n\t\tabout: @tv tells the method whether it should serialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod Serialize(stream:TStream, tv:Int = True, name:Int = False)\n\t\tIf tv = True\n\t\t\tstream.WriteByte(TV_BOOL)\n\t\tEnd If\n\t\tIf name = True\n\t\t\tWriteLString(stream, m_name)\n\t\tEnd If\n\t\tstream.WriteByte(Byte(m_value))\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Deserialize the variable from a stream.\n\t\treturns: The deserialized variable.\n\t\tabout: @tv tells the method whether it should deserialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod Deserialize:TBoolVariable(stream:TStream, tv:Int = True, name:Int = False)\n\t\tIf tv = True\n\t\t\tstream.ReadByte()\n\t\tEnd If\n\t\tIf name = True\n\t\t\tm_name = ReadLString(stream)\n\t\tEnd If\n\t\tm_value = Int(stream.ReadByte())\n\t\tReturn Self\n\tEnd Method\n\t\n'#end region (Data handling)\n\t\n\tRem\n\t\tbbdoc: Get the type of this variable.\n\t\treturns: The type of this variable (\"bool\").\n\tEnd Rem\n\tFunction ReportType:String()\n\t\tReturn \"bool\"\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Get the TV type of this variable.\n\t\treturns: The TV_* type of this variable (TV_BOOL).\n\tEnd Rem\n\tFunction GetTVType:Int()\n\t\tReturn TV_BOOL\n\tEnd Function\n\t\nEnd Type\n\nRem\n\tbbdoc: Identifier (used in parsers, mostly).\nEnd Rem\nType TIdentifier Extends TVariable\n\t\n\tField m_values:TList\n\t\n\tMethod New()\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Create a new TIdentifier.\n\t\treturns: Itself.\n\tEnd Rem\n\tMethod Create:TIdentifier()\n\t\tm_values = New TList\n\t\tReturn Self\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Create a new TIdentifier with the given data.\n\t\treturns: The new Identfier (itself).\n\t\tabout: If the @values parameter is Null a new list will be created.\n\tEnd Rem\n\tMethod CreateByData:TIdentifier(name:String, values:TList = Null)\n\t\tSetName(name)\n\t\tIf values = Null\n\t\t\tm_values = New TList\n\t\tElse\n\t\t\tm_values = values\n\t\tEnd If\n\t\tReturn Self\n\tEnd Method\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the identifier's values.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetValues(values:TList)\n\t\tm_values = values\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the identifier's values.\n\t\treturns: A list containing the values which the identifier holds.\n\tEnd Rem\n\tMethod GetValues:TList()\n\t\tReturn m_values\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Deprecated for this type.\n\t\treturns: Nothing.\n\t\tabout: This does nothing.\n\tEnd Rem\n\tMethod SetAmbiguous(value:String)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Convert the identifier to a string.\n\t\treturns: A string representation of the identifier.\n\tEnd Rem\n\tMethod ConvToString:String()\n\t\tLocal op:String\n\t\tIf m_name.Contains(\"~t\") = True Or m_name.Contains(\" \") = True\n\t\t\top = \"~q\" + m_name + \"~q \"\n\t\tElse\n\t\t\top = m_name + \" \"\n\t\tEnd If\n\t\tFor Local variable:TVariable = EachIn m_values\n\t\t\top:+variable.ConvToString() + \" \"\n\t\tNext\n\t\top = op[..op.Length - 1]\n\t\tReturn op\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the identifier as a string.\n\t\treturns: The identifier contents converted to a string.\n\t\tabout: Here for complete-ness, simply calls #ConvToString.\n\tEnd Rem\n\tMethod ValueAsString:String()\n\t\tReturn ConvToString()\n\tEnd Method\n\t\n'#end region (Field accessors)\n\t\n'#region Value handling\n\t\n\tRem\n\t\tbbdoc: Get a value at an index.\n\t\treturns: The value in the identifier's list at the given index, or Null if it could not be retrieved.\n\t\tabout: The index is zero-based.\n\tEnd Rem\n\tMethod GetValueAtIndex:TVariable(index:Int)\n\t\tIf m_values <> Null And index > - 1 And index < m_values.Count()\n\t\t\tReturn TVariable(m_values.ValueAtIndex(index))\n\t\tEnd If\n\t\tReturn Null\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the number of values.\n\t\treturns: The number of values the identifier contains.\n\tEnd Rem\n\tMethod GetValueCount:Int()\n\t\tIf m_values <> Null\n\t\t\tReturn m_values.Count()\n\t\tEnd If\n\t\tReturn 0\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Add a value to the identifier.\n\t\treturns: True for success, or False for failure.\n\t\tabout: NOTE: This will set the given value's parent.\n\tEnd Rem\n\tMethod AddValue:Int(value:TVariable)\n\t\tIf m_values <> Null And value <> Null\n\t\t\tm_values.AddLast(value)\n\t\t\tvalue.SetParent(Self)\n\t\t\tReturn True\n\t\tEnd If\n\t\tReturn False\n\tEnd Method\n\t\n'#end region (Value handling)\n\t\n'#region Data handling\n\t\n\tRem\n\t\tbbdoc: Create a copy of the identifier\n\t\treturns: A clone of the identifier.\n\tEnd Rem\n\tMethod Copy:TIdentifier()\n\t\tLocal clone:TIdentifier\n\t\tclone = New TIdentifier.CreateByData(m_name)\n\t\tFor Local variable:TVariable = EachIn m_values\n\t\t\tclone.AddValue(variable.Copy())\n\t\tNext\n\t\tReturn clone\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Serialize the variable to a stream.\n\t\treturns: Nothing.\n\t\tabout: @tv tells the method whether it should serialize the TV type for the variable, or to not.\n\t\tIn this case @name tells the method whether it should serialize the values<\/b><\/i>' name (the identifier's name is always read\/written to the stream).\n\tEnd Rem\n\tMethod Serialize(stream:TStream, tv:Int = True, name:Int = False)\n\t\tLocal variable:TVariable\n\t\tIf tv = True\n\t\t\tstream.WriteByte(TV_STRING)\n\t\tEnd If\n\t\tWriteLString(stream, m_name)\n\t\tIf m_values = Null\n\t\t\tstream.WriteInt(0)\n\t\tElse\n\t\t\tstream.WriteInt(m_values.Count())\n\t\t\tFor variable = EachIn m_values\n\t\t\t\tvariable.Serialize(stream, True, name)\n\t\t\tNext\n\t\tEnd If\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Deserialize the variable from a stream.\n\t\treturns: The deserialized variable.\n\t\tabout: @tv tells the method whether it should deserialize the TV type for the variable, or to not.\n\t\tIn this case @name tells the method whether it should deserialize the values<\/b><\/i>' name (the identifier's name is always read\/written to the stream).\n\tEnd Rem\n\tMethod Deserialize:TIdentifier(stream:TStream, tv:Int = True, name:Int = False)\n\t\tLocal count:Int, n:Int\n\t\tIf tv = True\n\t\t\tstream.ReadByte()\n\t\tEnd If\n\t\tm_name = ReadLString(stream)\n\t\tcount = stream.ReadInt()\n\t\tIf count > 0\n\t\t\tFor n = 0 To count - 1\n\t\t\t\tDeserializeUniversal(stream, name)\n\t\t\tNext\n\t\tEnd If\n\t\tReturn Self\n\tEnd Method\n\t\n'#end region (Data handling)\n\t\n\tRem\n\t\tbbdoc: Get the type of this variable.\n\t\treturns: The type of this variable (\"identifier\").\n\tEnd Rem\n\tFunction ReportType:String()\n\t\tReturn \"identifier\"\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Get the TV type of this variable.\n\t\treturns: The TV_* type of this variable (TV_IDEN).\n\tEnd Rem\n\tFunction GetTVType:Int()\n\t\tReturn TV_IDEN\n\tEnd Function\n\t\nEnd Type\n\nRem\n\tbbdoc: Variable map (stores any variable).\nEndRem\nType TVariableMap Extends TObjectMap\n\t\n\tRem\n\t\tbbdoc: Create a new TVariableMap.\n\t\treturns: Itself.\n\tEnd Rem\n\tMethod Create:TVariableMap()\n\t\tReturn Self\n\tEnd Method\n\t\n'#region Collections\n\t\n\tRem\n\t\tbbdoc: Insert a variable into the map.\n\t\treturns: True if the variable was added, or False if it was not (the variable's name is Null).\n\tEnd Rem\n\tMethod InsertVariable:Int(variable:TVariable)\n\t\tIf variable.GetName() <> Null\n\t\t\t_Insert(variable.GetName(), variable)\n\t\t\tReturn True\n\t\tEnd If\n\t\tReturn False\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Remove a variable by the name given.\n\t\treturns: True if a variable was removed, or False if it was not (the map contains no variable with the name given).\n\t\tabout: The name is<\/b> case-sensitive.\n\tEnd Rem\n\tMethod RemoveVariableByName:Int(name:String)\n\t\tReturn _Remove(name)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get a variable from the map by its name.\n\t\treturns: The variable object, or if the variable was not found, Null.\n\t\tabout: The name is<\/b> case-sensitive.\n\tEnd Rem\n\tMethod GetVariableByName:TVariable(name:String)\n\t\tReturn TVariable(_ValueByKey(name))\n\tEnd Method\n\t\n'#end region (Collections)\n\t\nEnd Type\n\n","old_contents":"\nRem\nCopyright (c) 2010 Tim Howard\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and\/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\nEnd Rem\n\nSuperStrict\n\nRem\nbbdoc: Variables module\nEnd Rem\nModule duct.variables\n\nModuleInfo \"Version: 0.20\"\nModuleInfo \"Copyright: Tim Howard\"\nModuleInfo \"License: MIT\"\n\nModuleInfo \"History: Version 0.20\"\nModuleInfo \"History: Added TBoolVariable support in TVariable.DeserializeUniversal\"\nModuleInfo \"History: Added TBoolVariable support in TVariable.RawToVariable\"\nModuleInfo \"History: Fixed an issue with eval variables in TVariable.RawToVariable\"\nModuleInfo \"History: Corrected some method names and some documentation.\"\nModuleInfo \"History: Version 0.19\"\nModuleInfo \"History: Added TBoolVariable; documentation correction\"\nModuleInfo \"History: Version 0.18\"\nModuleInfo \"History: TIdentifier.AddValue now sets the variable's parent to itself\"\nModuleInfo \"History: Added SetParent and GetParent to TVaraible\"\nModuleInfo \"History: Version 0.17\"\nModuleInfo \"History: General cleanup\"\nModuleInfo \"History: Version 0.16\"\nModuleInfo \"History: Added SetAmbiguous to all TVariable types\"\nModuleInfo \"History: Added option to always use quoting with TStringVariables (on by default)\"\nModuleInfo \"History: Fixed TStringVariable.ConvToString returning of Null strings\"\nModuleInfo \"History: Version 0.15\"\nModuleInfo \"History: Change the Create method definition for easier use\"\nModuleInfo \"History: Changed the '\/eval::' recognizer to '\/e:' (as per SNode format change)\"\nModuleInfo \"History: Added the Copy method to every variable type\"\nModuleInfo \"History: Changed some formatting\"\nModuleInfo \"History: Version 0.14\"\nModuleInfo \"History: Changed type tabbing\"\nModuleInfo \"History: Fixed script output for TStringVariable (quotes are now only added if whitespace is present)\"\nModuleInfo \"History: Fixed script output for TIdentifier (identifier names can now contain whitespace, in which case they must be quoted)\"\nModuleInfo \"History: Version 0.13\"\nModuleInfo \"History: Added the DeserializeUniversal function to TVariable\"\nModuleInfo \"History: Added Serialize and Deserialize methods to all variable types\"\nModuleInfo \"History: Version 0.12\"\nModuleInfo \"History: Changed module name from 'variablemap' to 'variables'\"\nModuleInfo \"History: Moved all of duct.utilparser here\"\nModuleInfo \"History: Added the GetTVType function to all variable types\"\nModuleInfo \"History: Moved TV_* constants from duct.template here\"\nModuleInfo \"History: Version 0.11\"\nModuleInfo \"History: Added the ReportType function to all variable types\"\nModuleInfo \"History: Version 0.10\"\nModuleInfo \"History: Added the RawToVariable function to TVariable\"\nModuleInfo \"History: General code cleanup\"\nModuleInfo \"History: Version 0.09\"\nModuleInfo \"History: Corrected usage of syntax (in Returns, Cases, News and Selects)\"\nModuleInfo \"History: Version 0.08\"\nModuleInfo \"History: Added the TEvalVariable type\"\nModuleInfo \"History: Initial release\"\n\nImport brl.stream\n\nImport duct.etc\nImport duct.objectmap\n\nRem\n\tbbdoc: Template variable type for the #TIntVariable type.\nEnd Rem\nConst TV_INTEGER:Int = 1\nRem\n\tbbdoc: Template variable type for the #TStringVariable type.\nEnd Rem\nConst TV_STRING:Int = 2\nRem\n\tbbdoc: Template variable type for the #TFloatVariable type.\nEnd Rem\nConst TV_FLOAT:Int = 3\nRem\n\tbbdoc: Template variable type for the #TEvalVariable type.\nEnd Rem\nConst TV_EVAL:Int = 4\nRem\n\tbbdoc: Template variable type for the #TIdentifier type.\nEnd Rem\nConst TV_IDEN:Int = 5\nRem\n\tbbdoc: Template variable type for the #TBoolVariable type.\nEnd Rem\nConst TV_BOOL:Int = 6\n\nRem\n\tbbdoc: Generic variable type.\n\tabout: This is the base variable type, you should extend from this to use it.\nEnd Rem\nType TVariable Abstract\n\t\n\tField m_name:String\n\tField m_parent:TVariable\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the variable's name.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetName(name:String)\n\t\tm_name = name\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the variable's name.\n\t\treturns: The variable's name.\n\tEnd Rem\n\tMethod GetName:String()\n\t\tReturn m_name\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the variable's parent.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetParent(parent:TVariable)\n\t\tm_parent = parent\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the variable's parent.\n\t\treturns: The variable's parent.\n\tEnd Rem\n\tMethod GetParent:TVariable()\n\t\tReturn m_parent\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Base method for setting the value of the variable to the given string (conversion).\n\tEnd Rem\n\tMethod SetAmbiguous(value:String) Abstract\n\t\n\tRem\n\t\tbbdoc: Base method for converting variable data to a script-ready string.\n\tEnd Rem\n\tMethod ConvToString:String() Abstract\n\t\n\tRem\n\t\tbbdoc: Base method for converting variable data to a printable\/usable-in-code string.\n\tEnd Rem\n\tMethod ValueAsString:String() Abstract\n\t\n'#end region (Field accessors)\n\t\n'#region Data handling\n\t\n\tRem\n\t\tbbdoc: Create a copy of the variable.\n\t\treturns: A clone of the variable.\n\tEnd Rem\n\tMethod Copy:TVariable() Abstract\n\t\n\tRem\n\t\tbbdoc: Serialize the variable to a stream.\n\t\treturns: Nothing.\n\t\tabout: @tv tells the method whether it should serialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod Serialize(stream:TStream, tv:Int = True, name:Int = False) Abstract\n\t\n\tRem\n\t\tbbdoc: Deserialize the variable from a stream.\n\t\treturns: The deserialized variable.\n\t\tabout: @tv tells the method whether it should deserialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod Deserialize:TVariable(stream:TStream, tv:Int = True, name:Int = False) Abstract\n\t\n'#end region (Data handling)\n\t\n\tRem\n\t\tbbdoc: Base method: Get the type of this variable.\n\tEnd Rem\n\tFunction ReportType:String() Abstract\n\t\n\tRem\n\t\tbbdoc: Base method: Get the TV_* type of this variable.\n\tEnd Rem\n\tFunction GetTVType:Int() Abstract\n\t\n\tRem\n\t\tbbdoc: Convert raw data (raw data being things like: \"\/e:(a+b\/0.4181)*a-b\" - a TEvalVariable, \"A String variable\", 3452134 - a TIntVariable, 1204.00321 - a FloatVariable) into a Variable.\n\t\treturns: A new Variable, or Null if something whacky occured.\n\t\tabout: @etype is optional, it is used to go automagically to one type of a Variable (1 & 4=String (will check for '\/eval::' - EvalVariables), 2=Integer, 3=Float).\n\t\t@varname is also an optional parameter. It will be used as the name of the variable.\n\tEnd Rem\n\tFunction RawToVariable:TVariable(vraw:String, etype:Int = 0, varname:String = \"\")\n\t\tLocal variable:TVariable\n\t\tIf vraw = Null\n\t\t\tDebugLog(\"(TVariable.RawToVariable) @vraw = Null; returning StringVariable (with @varname and Null value)\")\n\t\t\tReturn New TStringVariable.Create(varname, Null)\n\t\tEnd If\n\t\tIf etype = 0 ' Determine the value's type (must be either integer, double, or a string with no spaces)\n\t\t\t' ASCII '0' to '9' = 48-57; '-' = 45, '+' = 43; and '.' = 46\n\t\t\tFor Local i:Int = 0 To vraw.Length - 1\n\t\t\t\tLocal c:Int = vraw[i]\n\t\t\t\tIf c >= 48 And c <= 57 Or c = 43 Or c = 45\n\t\t\t\t\tIf etype = 0 ' Leave float and string alone\n\t\t\t\t\t\tetype = 2 ' Integer so far..\n\t\t\t\t\tEnd If\n\t\t\t\tElse If c = 46\n\t\t\t\t\tIf etype = 2 ' Already declared as an integer?\n\t\t\t\t\t\tetype = 3\n\t\t\t\t\tEnd If\n\t\t\t\tElse ' If the character is not numerical there is nothing else to deduce and the value is a string\n\t\t\t\t\tetype = 4\n\t\t\t\t\tExit\n\t\t\t\tEnd If\n\t\t\tNext\n\t\t\t\n\t\t\tSelect etype\n\t\t\t\tCase 2 ' Integer\n\t\t\t\t\tvariable = TVariable(New TIntVariable.Create(varname, Int(vraw)))\n\t\t\t\tCase 3 ' Double\/Float\n\t\t\t\t\tvariable = TVariable(New TFloatVariable.Create(varname, Float(vraw)))\n\t\t\tEnd Select\n\t\tEnd If\n\t\t\n\t\tIf etype = 1 Or etype = 4\n\t\t\tLocal vrawlower:String = vraw.ToLower()\n\t\t\tLocal evaltest:Int = vrawlower.StartsWith(\"\/e:\")\n\t\t\tIf evaltest >= 0\n\t\t\t\tvariable = TVariable(New TEvalVariable.Create(varname, vraw[evaltest + 3..]))\n\t\t\tElse If vrawlower = \"true\" Or vrawlower = \"false\"\n\t\t\t\tvariable = New TBoolVariable.Create(varname, (vrawlower = \"true\") And True Or False)\n\t\t\tElse\n\t\t\t\tvariable = TVariable(New TStringVariable.Create(varname, vraw))\n\t\t\tEnd If\n\t\tEnd If\n\t\t' DebugLog(\"TSNode.LoadScriptFromStream().RawToVariable(); vraw = ~q\" + vraw + \"~q \\\" + etype)\n\t\t?Debug\n\t\tIf variable = Null Then DebugLog(\"( TVariable.RawToVariable() ) Unknown error, 'variable' is Null.\")\n\t\t?\n\t\tReturn variable\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Universally deserialize a variable from the given stream.\n\t\treturns: A Deserialized variable.\n\t\tabout: This will deserialize any variable from the stream.\n\t\tThis requires the variable to have been serialized with the template type (see #Serialize parameters).\n\t\t@name tells the further Deserialize calls if the name should be Deserialized or not.\n\tEnd Rem\n\tFunction DeserializeUniversal:TVariable(stream:TStream, name:Int = False)\n\t\tLocal tv:Int = Int(stream.ReadByte())\n\t\tSelect tv\n\t\t\tCase TV_INTEGER\n\t\t\t\tReturn New TIntVariable.Deserialize(stream, True, name)\n\t\t\tCase TV_STRING\n\t\t\t\tReturn New TStringVariable.Deserialize(stream, True, name)\n\t\t\tCase TV_FLOAT\n\t\t\t\tReturn New TFloatVariable.Deserialize(stream, True, name)\n\t\t\tCase TV_EVAL\n\t\t\t\tReturn New TEvalVariable.Deserialize(stream, True, name)\n\t\t\tCase TV_IDEN\n\t\t\t\tReturn New TIdentifier.Deserialize(stream, True, name)\n\t\t\tCase TV_BOOL\n\t\t\t\tReturn New TBoolVariable.Deserialize(stream, True, name)\n\t\t\tDefault\n\t\t\t\tDebugLog(\"(TVariable.DeserializeUniversal) Failed to recognize the TV in the stream: \" + tv)\n\t\tEnd Select\n\t\tReturn Null\n\tEnd Function\n\t\nEnd Type\n\nRem\n\tbbdoc: String variable.\nEnd Rem\nType TStringVariable Extends TVariable\n\t\n\tGlobal m_alwaysusequotes:Int = True\n\t\n\tField m_value:String\n\t\n\tRem\n\t\tbbdoc: Create a new StringVariable.\n\t\treturns: The new StringVariable (itself).\n\tEnd Rem\n\tMethod Create:TStringVariable(name:String = Null, value:String)\n\t\tSetName(name)\n\t\tSet(value)\n\t\tReturn Self\n\tEnd Method\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the variable's value.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod Set(value:String)\n\t\tm_value = value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the variable's value.\n\t\treturns: The value of the variable.\n\tEnd Rem\n\tMethod Get:String()\n\t\tReturn m_value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the value of the TStringVariable to the given string (ambiguous).\n\t\treturns: Nothing.\n\t\tabout: For this type, this method is no different than calling #Set.\n\tEnd Rem\n\tMethod SetAmbiguous(value:String)\n\t\tm_value = value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Convert the variable to a String.\n\t\treturns: A String representation of the variable.\n\t\tabout: This function is for script output, for in-code use see #ValueAsString.\n\tEnd Rem\n\tMethod ConvToString:String()\n\t\tIf m_alwaysusequotes = True Or m_value.Contains(\"~t\") Or m_value.Contains(\" \") Or m_value = Null\n\t\t\tReturn \"~q\" + m_value + \"~q\"\n\t\tElse\n\t\t\tReturn m_value\n\t\tEnd If\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the StringVariable as a String.\n\t\treturns: The variable's value converted to a String.\n\t\tabout: Here for complete-ness, no difference to `instance.Get()`.\n\tEnd Rem\n\tMethod ValueAsString:String()\n\t\tReturn m_value\n\tEnd Method\n\t\n'#end region (Field accessors)\n\t\n'#region Data handling\n\t\n\tRem\n\t\tbbdoc: Create a copy of the variable\n\t\treturns: A clone of the variable.\n\tEnd Rem\n\tMethod Copy:TStringVariable()\n\t\tReturn New TStringVariable.Create(m_name, m_value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Serialize the variable to a stream.\n\t\treturns: Nothing.\n\t\tabout: @tv tells the method whether it should serialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod Serialize(stream:TStream, tv:Int = True, name:Int = False)\n\t\tIf tv = True\n\t\t\tstream.WriteByte(TV_STRING)\n\t\tEnd If\n\t\tIf name = True\n\t\t\tWriteLString(stream, m_name)\n\t\tEnd If\n\t\t\n\t\tWriteLString(stream, m_value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Deserialize the variable from a stream.\n\t\treturns: The deserialized variable.\n\t\tabout: @tv tells the method whether it should deserialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod Deserialize:TStringVariable(stream:TStream, tv:Int = True, name:Int = False)\n\t\tIf tv = True\n\t\t\tstream.ReadByte()\n\t\tEnd If\n\t\tIf name = True\n\t\t\tm_name = ReadLString(stream)\n\t\tEnd If\n\t\t\n\t\tm_value = ReadLString(stream)\n\t\tReturn Self\n\tEnd Method\n\t\n'#end region (Data handling)\n\t\n\tRem\n\t\tbbdoc: Get the type of this variable.\n\t\treturns: The type of this variable (\"string\").\n\tEnd Rem\n\tFunction ReportType:String()\n\t\tReturn \"string\"\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Get the TV type of this variable.\n\t\treturns: The TV_* type of this variable (TV_STRING).\n\tEnd Rem\n\tFunction GetTVType:Int()\n\t\tReturn TV_STRING\n\tEnd Function\n\t\nEnd Type\n\nRem\n\tbbdoc: Float variable.\nEnd Rem\nType TFloatVariable Extends TVariable\n\t\n\tField m_value:Float\n\t\n\tRem\n\t\tbbdoc: Create a new FloatVariable.\n\t\treturns: The new FloatVariable (itself).\n\tEnd Rem\n\tMethod Create:TFloatVariable(name:String = Null, value:Float)\n\t\tSetName(name)\n\t\tSet(value)\n\t\tReturn Self\n\tEnd Method\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the variable's value.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod Set(value:Float)\n\t\tm_value = value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the variable's value.\n\t\treturns: The value of the variable.\n\tEnd Rem\n\tMethod Get:Float()\n\t\tReturn m_value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the value of the variable to the given string (ambiguous).\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetAmbiguous(value:String)\n\t\tm_value = Float(value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Convert the variable to a String.\n\t\treturns: A scriptable form of the StringVariable.\n\t\tabout: This function is for script output, for in-code use see #ValueAsString.\n\tEnd Rem\n\tMethod ConvToString:String()\n\t\tLocal conv:String = String(m_value), i:Int, encountered:Int\n\t\t\n\t\tFor i = conv.Find(\".\") To conv.Length - 1\n\t\t\tIf conv[i] = 48\n\t\t\t\tIf encountered = True\n\t\t\t\t\tconv = conv[..i]\n\t\t\t\t\tExit\n\t\t\t\tEnd If\n\t\t\tElse If conv[i] <> 46\n\t\t\t\tencountered = True\n\t\t\tEnd If\n\t\tNext\n\t\t\n\t\tReturn conv\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the FloatVariable as a String.\n\t\treturns: The variable's value converted to a String.\n\tEnd Rem\n\tMethod ValueAsString:String()\n\t\tReturn String(m_value)\n\tEnd Method\n\t\n'#end region (Field accessors)\n\t\n'#region Data handling\n\t\n\tRem\n\t\tbbdoc: Create a copy of the variable\n\t\treturns: A clone of the variable.\n\tEnd Rem\n\tMethod Copy:TFloatVariable()\n\t\tReturn New TFloatVariable.Create(m_name, m_value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Serialize the variable to a stream.\n\t\treturns: Nothing.\n\t\tabout: @tv tells the method whether it should serialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod Serialize(stream:TStream, tv:Int = True, name:Int = False)\n\t\tIf tv = True\n\t\t\tstream.WriteByte(TV_FLOAT)\n\t\tEnd If\n\t\tIf name = True\n\t\t\tWriteLString(stream, m_name)\n\t\tEnd If\n\t\tstream.WriteFloat(m_value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Deserialize the variable from a stream.\n\t\treturns: The deserialized variable.\n\t\tabout: @tv tells the method whether it should deserialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod Deserialize:TFloatVariable(stream:TStream, tv:Int = True, name:Int = False)\n\t\tIf tv = True\n\t\t\tstream.ReadByte()\n\t\tEnd If\n\t\tIf name = True\n\t\t\tm_name = ReadLString(stream)\n\t\tEnd If\n\t\tm_value = stream.ReadFloat()\n\t\tReturn Self\n\tEnd Method\n\t\n'#end region (Data handling)\n\t\n\tRem\n\t\tbbdoc: Get the type of this variable.\n\t\treturns: The type of this variable (\"float\").\n\tEnd Rem\n\tFunction ReportType:String()\n\t\tReturn \"float\"\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Get the TV type of this variable.\n\t\treturns: The TV_* type of this variable (TV_FLOAT).\n\tEnd Rem\n\tFunction GetTVType:Int()\n\t\tReturn TV_FLOAT\n\tEnd Function\n\t\nEnd Type\n\nRem\n\tbbdoc: Integer variable.\nEnd Rem\nType TIntVariable Extends TVariable\n\t\n\tField m_value:Int\n\t\n\tRem\n\t\tbbdoc: Create a new IntVariable.\n\t\treturns: The new IntVariable (itself).\n\tEnd Rem\n\tMethod Create:TIntVariable(name:String = Null, value:Int)\n\t\tSetName(name)\n\t\tSet(value)\n\t\tReturn Self\n\tEnd Method\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the variable's value.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod Set(value:Int)\n\t\tm_value = value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the variable's value.\n\t\treturns: The value of the variable.\n\tEnd Rem\n\tMethod Get:Int()\n\t\tReturn m_value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the value of the variable to the given string (ambiguous).\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetAmbiguous(value:String)\n\t\tm_value = Int(value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Convert the variable to a String.\n\t\treturns: A string representation of the variable.\n\t\tabout: This function is for script output, for in-code use see #ValueAsString.\n\tEnd Rem\n\tMethod ConvToString:String()\n\t\tReturn String(m_value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the IntVariable as a String.\n\t\treturns: The variable's value converted to a String.\n\tEnd Rem\n\tMethod ValueAsString:String()\n\t\tReturn String(m_value)\n\tEnd Method\n\t\n'#end region (Field accessors)\n\t\n'#region Data handling\n\t\n\tRem\n\t\tbbdoc: Create a copy of the variable\n\t\treturns: A clone of the variable.\n\tEnd Rem\n\tMethod Copy:TIntVariable()\n\t\tReturn New TIntVariable.Create(m_name, m_value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Serialize the variable to a stream.\n\t\treturns: Nothing.\n\t\tabout: @tv tells the method whether it should serialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod Serialize(stream:TStream, tv:Int = True, name:Int = False)\n\t\tIf tv = True\n\t\t\tstream.WriteByte(TV_INTEGER)\n\t\tEnd If\n\t\tIf name = True\n\t\t\tWriteLString(stream, m_name)\n\t\tEnd If\n\t\t\n\t\tstream.WriteInt(m_value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Deserialize the variable from a stream.\n\t\treturns: The deserialized variable.\n\t\tabout: @tv tells the method whether it should deserialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod Deserialize:TIntVariable(stream:TStream, tv:Int = True, name:Int = False)\n\t\tIf tv = True\n\t\t\tstream.ReadByte()\n\t\tEnd If\n\t\tIf name = True\n\t\t\tm_name = ReadLString(stream)\n\t\tEnd If\n\t\t\n\t\tm_value = stream.ReadInt()\n\t\tReturn Self\n\tEnd Method\n\t\n'#end region (Data handling)\n\t\n\tRem\n\t\tbbdoc: Get the type of this variable.\n\t\treturns: The type of this variable (\"int\").\n\tEnd Rem\n\tFunction ReportType:String()\n\t\tReturn \"int\"\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Get the TV type of this variable.\n\t\treturns: The TV_* type of this variable (TV_INTEGER).\n\tEnd Rem\n\tFunction GetTVType:Int()\n\t\tReturn TV_INTEGER\n\tEnd Function\n\t\nEnd Type\n\nRem\n\tbbdoc: Eval variable (for bah.muparser, and the likes).\nEnd Rem\nType TEvalVariable Extends TVariable\n\t\n\tField m_value:String\n\t\n\tRem\n\t\tbbdoc: Create a new EvalVariable.\n\t\treturns: The new EvalVariable (itself).\n\tEnd Rem\n\tMethod Create:TEvalVariable(name:String = Null, value:String)\n\t\tSetName(name)\n\t\tSet(value)\n\t\tReturn Self\n\tEnd Method\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the equation string for the EvalVariable.\n\t\treturns: Nothing\n\tEnd Rem\n\tMethod Set(value:String)\n\t\tm_value = value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the equation string.\n\t\treturns: The equation string.\n\tEnd Rem\n\tMethod Get:String()\n\t\tReturn m_value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the value of the variable to the given string (ambiguous).\n\t\treturns: Nothing.\n\t\tabout: For this type, this method is no different than calling #Set.\n\tEnd Rem\n\tMethod SetAmbiguous(value:String)\n\t\tm_value = value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Convert the EvalVariable to a visual representation of its data.\n\t\treturns: The scriptable form of the EvalVariable.\n\t\tabout: This function is for script output, for in-code use see #ValueAsString.\n\tEnd Rem\n\tMethod ConvToString:String()\n\t\tReturn \"~q\/e:\" + m_value + \"~q\"\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the EvalVariable as a String.\n\t\treturns: The variable's value converted to a String.\n\tEnd Rem\n\tMethod ValueAsString:String()\n\t\tReturn m_value\n\tEnd Method\n\t\n'#end region (Field accessors)\n\t\n'#region Data handling\n\t\n\tRem\n\t\tbbdoc: Create a copy of the variable\n\t\treturns: A clone of the variable.\n\tEnd Rem\n\tMethod Copy:TEvalVariable()\n\t\tReturn New TEvalVariable.Create(m_name, m_value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Serialize the variable to a stream.\n\t\treturns: Nothing.\n\t\tabout: @tv tells the method whether it should serialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod Serialize(stream:TStream, tv:Int = True, name:Int = False)\n\t\tIf tv = True\n\t\t\tstream.WriteByte(TV_EVAL)\n\t\tEnd If\n\t\tIf name = True\n\t\t\tWriteLString(stream, m_name)\n\t\tEnd If\n\t\t\n\t\tWriteLString(stream, m_value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Deserialize the variable from a stream.\n\t\treturns: The deserialized variable.\n\t\tabout: @tv tells the method whether it should deserialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod Deserialize:TEvalVariable(stream:TStream, tv:Int = True, name:Int = False)\n\t\tIf tv = True\n\t\t\tstream.ReadByte()\n\t\tEnd If\n\t\tIf name = True\n\t\t\tm_name = ReadLString(stream)\n\t\tEnd If\n\t\t\n\t\tm_value = ReadLString(stream)\n\t\tReturn Self\n\tEnd Method\n\t\n'#end region (Data handling)\n\t\n\tRem\n\t\tbbdoc: Get the type of this variable.\n\t\treturns: The type of this variable (\"eval\").\n\tEnd Rem\n\tFunction ReportType:String()\n\t\tReturn \"eval\"\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Get the TV type of this variable.\n\t\treturns: The TV_* type of this variable (TV_EVAL).\n\tEnd Rem\n\tFunction GetTVType:Int()\n\t\tReturn TV_EVAL\n\tEnd Function\n\t\nEnd Type\n\nRem\n\tbbdoc: Boolean variable.\nEnd Rem\nType TBoolVariable Extends TVariable\n\t\n\tField m_value:Int\n\t\n\tRem\n\t\tbbdoc: Create a new BoolVariable.\n\t\treturns: The new BoolVariable (itself).\n\tEnd Rem\n\tMethod Create:TBoolVariable(name:String = Null, value:Int)\n\t\tSetName(name)\n\t\tSet(value)\n\t\tReturn Self\n\tEnd Method\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the variable's value.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod Set(value:Int)\n\t\tm_value = value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the variable's value.\n\t\treturns: The value of the variable.\n\tEnd Rem\n\tMethod Get:Int()\n\t\tReturn m_value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the value of the variable to the given string (ambiguous).\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetAmbiguous(value:String)\n\t\tm_value = Int(value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Convert the variable to a String.\n\t\treturns: A string representation of the variable.\n\t\tabout: This function is for script output, for in-code use see #ValueAsString.\n\tEnd Rem\n\tMethod ConvToString:String()\n\t\tReturn String(m_value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the TBoolVariable as a String.\n\t\treturns: The variable's value converted to a String.\n\tEnd Rem\n\tMethod ValueAsString:String()\n\t\tReturn String(m_value)\n\tEnd Method\n\t\n'#end region (Field accessors)\n\t\n'#region Data handling\n\t\n\tRem\n\t\tbbdoc: Create a copy of the variable\n\t\treturns: A clone of the variable.\n\tEnd Rem\n\tMethod Copy:TBoolVariable()\n\t\tReturn New TBoolVariable.Create(m_name, m_value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Serialize the variable to a stream.\n\t\treturns: Nothing.\n\t\tabout: @tv tells the method whether it should serialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod Serialize(stream:TStream, tv:Int = True, name:Int = False)\n\t\tIf tv = True\n\t\t\tstream.WriteByte(TV_BOOL)\n\t\tEnd If\n\t\tIf name = True\n\t\t\tWriteLString(stream, m_name)\n\t\tEnd If\n\t\tstream.WriteByte(Byte(m_value))\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Deserialize the variable from a stream.\n\t\treturns: The deserialized variable.\n\t\tabout: @tv tells the method whether it should deserialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod Deserialize:TBoolVariable(stream:TStream, tv:Int = True, name:Int = False)\n\t\tIf tv = True\n\t\t\tstream.ReadByte()\n\t\tEnd If\n\t\tIf name = True\n\t\t\tm_name = ReadLString(stream)\n\t\tEnd If\n\t\tm_value = Int(stream.ReadByte())\n\t\tReturn Self\n\tEnd Method\n\t\n'#end region (Data handling)\n\t\n\tRem\n\t\tbbdoc: Get the type of this variable.\n\t\treturns: The type of this variable (\"bool\").\n\tEnd Rem\n\tFunction ReportType:String()\n\t\tReturn \"bool\"\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Get the TV type of this variable.\n\t\treturns: The TV_* type of this variable (TV_BOOL).\n\tEnd Rem\n\tFunction GetTVType:Int()\n\t\tReturn TV_BOOL\n\tEnd Function\n\t\nEnd Type\n\nRem\n\tbbdoc: Identifier (used in parsers, mostly).\nEnd Rem\nType TIdentifier Extends TVariable\n\t\n\tField m_values:TList\n\t\n\tMethod New()\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Create a new TIdentifier.\n\t\treturns: Itself.\n\tEnd Rem\n\tMethod Create:TIdentifier()\n\t\tm_values = New TList\n\t\tReturn Self\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Create a new TIdentifier with the given data.\n\t\treturns: The new Identfier (itself).\n\t\tabout: If the @values parameter is Null a new list will be created.\n\tEnd Rem\n\tMethod CreateByData:TIdentifier(name:String, values:TList = Null)\n\t\tSetName(name)\n\t\tIf values = Null\n\t\t\tm_values = New TList\n\t\tElse\n\t\t\tm_values = values\n\t\tEnd If\n\t\tReturn Self\n\tEnd Method\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the identifier's values.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetValues(values:TList)\n\t\tm_values = values\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the identifier's values.\n\t\treturns: A list containing the values which the identifier holds.\n\tEnd Rem\n\tMethod GetValues:TList()\n\t\tReturn m_values\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Deprecated for this type.\n\t\treturns: Nothing.\n\t\tabout: This does nothing.\n\tEnd Rem\n\tMethod SetAmbiguous(value:String)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Convert the identifier to a string.\n\t\treturns: A string representation of the identifier.\n\tEnd Rem\n\tMethod ConvToString:String()\n\t\tLocal op:String\n\t\tIf m_name.Contains(\"~t\") = True Or m_name.Contains(\" \") = True\n\t\t\top = \"~q\" + m_name + \"~q \"\n\t\tElse\n\t\t\top = m_name + \" \"\n\t\tEnd If\n\t\tFor Local variable:TVariable = EachIn m_values\n\t\t\top:+variable.ConvToString() + \" \"\n\t\tNext\n\t\top = op[..op.Length - 1]\n\t\tReturn op\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the identifier as a string.\n\t\treturns: The identifier contents converted to a string.\n\t\tabout: Here for complete-ness, simply calls #ConvToString.\n\tEnd Rem\n\tMethod ValueAsString:String()\n\t\tReturn ConvToString()\n\tEnd Method\n\t\n'#end region (Field accessors)\n\t\n'#region Value handling\n\t\n\tRem\n\t\tbbdoc: Get a value at an index.\n\t\treturns: The value in the identifier's list at the given index, or Null if it could not be retrieved.\n\t\tabout: The index is zero-based.\n\tEnd Rem\n\tMethod GetValueAtIndex:TVariable(index:Int)\n\t\tIf m_values <> Null And index > - 1 And index < m_values.Count()\n\t\t\tReturn TVariable(m_values.ValueAtIndex(index))\n\t\tEnd If\n\t\tReturn Null\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the number of values.\n\t\treturns: The number of values the identifier contains.\n\tEnd Rem\n\tMethod GetValueCount:Int()\n\t\tIf m_values <> Null\n\t\t\tReturn m_values.Count()\n\t\tEnd If\n\t\tReturn 0\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Add a value to the identifier.\n\t\treturns: True for success, or False for failure.\n\t\tabout: NOTE: This will set the given value's parent.\n\tEnd Rem\n\tMethod AddValue:Int(value:TVariable)\n\t\tIf m_values <> Null And value <> Null\n\t\t\tm_values.AddLast(value)\n\t\t\tvalue.SetParent(Self)\n\t\t\tReturn True\n\t\tEnd If\n\t\tReturn False\n\tEnd Method\n\t\n'#end region (Value handling)\n\t\n'#region Data handling\n\t\n\tRem\n\t\tbbdoc: Create a copy of the identifier\n\t\treturns: A clone of the identifier.\n\tEnd Rem\n\tMethod Copy:TIdentifier()\n\t\tLocal clone:TIdentifier\n\t\tclone = New TIdentifier.CreateByData(m_name)\n\t\tFor Local variable:TVariable = EachIn m_values\n\t\t\tclone.AddValue(variable.Copy())\n\t\tNext\n\t\tReturn clone\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Serialize the variable to a stream.\n\t\treturns: Nothing.\n\t\tabout: @tv tells the method whether it should serialize the TV type for the variable, or to not.\n\t\tIn this case @name tells the method whether it should serialize the values<\/b><\/i>' name (the identifier's name is always read\/written to the stream).\n\tEnd Rem\n\tMethod Serialize(stream:TStream, tv:Int = True, name:Int = False)\n\t\tLocal variable:TVariable\n\t\tIf tv = True\n\t\t\tstream.WriteByte(TV_STRING)\n\t\tEnd If\n\t\tWriteLString(stream, m_name)\n\t\tIf m_values = Null\n\t\t\tstream.WriteInt(0)\n\t\tElse\n\t\t\tstream.WriteInt(m_values.Count())\n\t\t\tFor variable = EachIn m_values\n\t\t\t\tvariable.Serialize(stream, True, name)\n\t\t\tNext\n\t\tEnd If\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Deserialize the variable from a stream.\n\t\treturns: The deserialized variable.\n\t\tabout: @tv tells the method whether it should deserialize the TV type for the variable, or to not.\n\t\tIn this case @name tells the method whether it should deserialize the values<\/b><\/i>' name (the identifier's name is always read\/written to the stream).\n\tEnd Rem\n\tMethod Deserialize:TIdentifier(stream:TStream, tv:Int = True, name:Int = False)\n\t\tLocal count:Int, n:Int\n\t\tIf tv = True\n\t\t\tstream.ReadByte()\n\t\tEnd If\n\t\tm_name = ReadLString(stream)\n\t\tcount = stream.ReadInt()\n\t\tIf count > 0\n\t\t\tFor n = 0 To count - 1\n\t\t\t\tDeserializeUniversal(stream, name)\n\t\t\tNext\n\t\tEnd If\n\t\tReturn Self\n\tEnd Method\n\t\n'#end region (Data handling)\n\t\n\tRem\n\t\tbbdoc: Get the type of this variable.\n\t\treturns: The type of this variable (\"identifier\").\n\tEnd Rem\n\tFunction ReportType:String()\n\t\tReturn \"identifier\"\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Get the TV type of this variable.\n\t\treturns: The TV_* type of this variable (TV_IDEN).\n\tEnd Rem\n\tFunction GetTVType:Int()\n\t\tReturn TV_IDEN\n\tEnd Function\n\t\nEnd Type\n\nRem\n\tbbdoc: Variable map (stores any variable).\nEndRem\nType TVariableMap Extends TObjectMap\n\t\n\tRem\n\t\tbbdoc: Create a new TVariableMap.\n\t\treturns: Itself.\n\tEnd Rem\n\tMethod Create:TVariableMap()\n\t\tReturn Self\n\tEnd Method\n\t\n'#region Collections\n\t\n\tRem\n\t\tbbdoc: Insert a variable into the map.\n\t\treturns: True if the variable was added, or False if it was not (the variable's name is Null).\n\tEnd Rem\n\tMethod InsertVariable:Int(variable:TVariable)\n\t\tIf variable.GetName() <> Null\n\t\t\t_Insert(variable.GetName(), variable)\n\t\t\tReturn True\n\t\tEnd If\n\t\tReturn False\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Remove a variable by the name given.\n\t\treturns: True if a variable was removed, or False if it was not (the map contains no variable with the name given).\n\t\tabout: The name is<\/b> case-sensitive.\n\tEnd Rem\n\tMethod RemoveVariableByName:Int(name:String)\n\t\tReturn _Remove(name)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get a variable from the map by its name.\n\t\treturns: The variable object, or if the variable was not found, Null.\n\t\tabout: The name is<\/b> case-sensitive.\n\tEnd Rem\n\tMethod GetVariableByName:TVariable(name:String)\n\t\tReturn TVariable(_ValueByKey(name))\n\tEnd Method\n\t\n'#end region (Collections)\n\t\nEnd Type\n\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"e0c09b3b76e88124897f4592b7415ac62be9f05c","subject":"Removed unused code","message":"Removed unused code\n\nrefs gh-6\n","repos":"maximos\/maximus","old_file":"src\/impl\/install.bmx","new_file":"src\/impl\/install.bmx","new_contents":"\nRem\n\tbbdoc: Maximus 'install' argument implementation.\nEnd Rem\nType mxInstallImpl Extends dArgumentImplementation\n\t\n\tField m_instmap:dObjectMap\n\tField m_depcheckmap:dObjectMap\n\tField m_unmanagedmap:dObjectMap\n\tField m_nobuild:Int = False, m_nounpack:Int = False, m_keeptemp:Int = False\n\tField m_nothreaded:Int = False, m_makedocs:Int = False, m_forceinstall:Int = False\n\t\n\tMethod New()\n\t\tinit([\"install\"])\n\t\tm_instmap = New dObjectMap\n\t\tm_depcheckmap = New dObjectMap\n\t\tm_unmanagedmap = New dObjectMap\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Check the current arguments for errors (according to the specific implementation).\n\t\treturns: Nothing.\n\t\tabout: This method will throw an error if the arguments are invalid.\n\tEnd Rem\n\tMethod CheckArgs()\n\t\tIf GetArgumentCount() = 0\n\t\t\tThrowCommonError(mxCmdErrors.REQUIRESPARAMS, m_args.GetName())\n\t\tEnd If\n\t\tCheckOptions()\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get a string describing the typical usage of the argument.\n\t\treturns: A string describing the typical usage of the argument.\n\tEnd Rem\n\tMethod GetUsage:String()\n\t\tReturn _s(\"arg.install.usage\")\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Execute the implementation's operation.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod Execute()\n\t\tm_instmap.Clear()\n\t\tm_depcheckmap.Clear()\n\t\tm_unmanagedmap.Clear()\n\t\tIf mainapp.m_sourceshandler\n\t\t\tLocal nfounds:dObjectMap = New dObjectMap\n\t\t\tFor Local svar:dStringVariable = EachIn m_args\n\t\t\t\tLocal verid:String = svar.Get(), modid:String = mxModUtils.GetIDFromVerID(verid)\n\t\t\t\tLocal modul:mxModule = mainapp.m_sourceshandler.GetModuleWithID(modid)\n\t\t\t\tIf modul\n\t\t\t\t\tLocal instmod:mxInstModule = New mxInstModule.Create(verid, modul)\n\t\t\t\t\tIf instmod.SetVersionFromVerID(verid)\n\t\t\t\t\t\tm_instmap._Insert(modid, instmod)\n\t\t\t\t\tElse\n\t\t\t\t\t\tThrowError(_s(\"arg.install.notfound.version\", [modid, mxModUtils.GetVersionFromVerID(verid)]))\n\t\t\t\t\tEnd If\n\t\t\t\tElse\n\t\t\t\t\tnfounds._Insert(modid, modid)\n\t\t\t\tEnd If\n\t\t\tNext\n\t\t\tIf nfounds.Count() > 0\n\t\t\t\tlogger.LogError(_s(\"arg.install.notfound.instmods\"))\n\t\t\t\tLocal a:String\n\t\t\t\tFor Local b:String = EachIn nfounds.ValueEnumerator()\n\t\t\t\t\ta:+ b + \" \"\n\t\t\t\tNext\n\t\t\t\ta = a[..a.Length - 1]\n\t\t\t\tlogger.LogMessage(\"~t\" + a)\n\t\t\t\tReturn\n\t\t\tEnd If\n\t\t\tIf CheckDependencies()\n\t\t\t\t'Make sure we only install\/update managed modules\n\t\t\t\tIf CheckVersions()\n\t\t\t\t\tDoInstall()\n\t\t\t\tEnd If\n\t\t\tEnd If\n\t\tElse\n\t\t\tThrowError(_s(\"error.install.nosources\"))\n\t\tEnd If\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Check the options given to the command.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod CheckOptions()\n\t\tm_nobuild = False; m_nounpack = False; m_keeptemp = False\n\t\tm_nothreaded = False; m_makedocs = False\n\t\tFor Local opt:dIdentifier = EachIn m_args\n\t\t\tSelect opt.GetName().ToLower()\n\t\t\t\tCase \"-nobuild\" m_nobuild = True\n\t\t\t\tCase \"-nounpack\" m_nounpack = True\n\t\t\t\tCase \"-keeptemp\" m_keeptemp = True\n\t\t\t\tCase \"-nothreaded\" m_nothreaded = True\n\t\t\t\tCase \"-makedocs\" m_makedocs = True\n\t\t\t\tCase \"-force\" m_forceinstall = True\n\t\t\t\tDefault ThrowCommonError(mxOptErrors.UNKNOWN, opt.GetName())\n\t\t\tEnd Select\n\t\tNext\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Check for version conflictions and warn the user.\n\t\treturns: True if the installtion should continue, or False if the user halted the operation.\n\tEnd Rem\n\tMethod CheckVersions:Int()\n\t\tFor Local instmod:mxInstModule = EachIn m_instmap.ValueEnumerator()\n\t\t\tLocal ver:String = mxModUtils.GetInstalledVersionFromVerID(instmod.GetVerID())\n\t\t\t'Make sure we skip unmanaged modules\n\t\t\tIf ver = \"unmanaged\"\n\t\t\t\tm_instmap._Remove(instmod.GetID())\n\t\t\t\tm_unmanagedmap._Insert(instmod.GetID(), instmod)\n\t\t\tEnd If\n\t\tNext\n\t\tReturn True\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Check the dependencies for the modules to be installed.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod CheckDependencies:Int()\n\t\tFor Local instmod:mxInstModule = EachIn m_instmap.ValueEnumerator()\n\t\t\tCheckModuleDependencies(instmod, nfounds)\n\t\tNext\n\t\tIf nfounds.Count() > 0\n\t\t\tlogger.LogError(_s(\"arg.install.notfound.instdeps\"))\n\t\t\tLocal a:String\n\t\t\tFor Local b:String = EachIn nfounds.ValueEnumerator()\n\t\t\t\ta:+ b + \" \"\n\t\t\tNext\n\t\t\ta = a[..a.Length - 1]\n\t\t\tlogger.LogMessage(\"~t\" + a)\n\t\t\tIf m_forceinstall\n\t\t\t\tm_nobuild = True\n\t\t\t\tLocal resp:String = Input(_s(\"arg.install.missingdeps\") + \" \").ToLower()\n\t\t\t\tIf resp = \"y\" Or resp = \"yes\"\n\t\t\t\t\tReturn True\n\t\t\t\tEnd If\n\t\t\tEnd If\n\t\t\tReturn False\n\t\tEnd If\n\t\tReturn True\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Check the dependencies for the given module and adapt the install list accordingly.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod CheckModuleDependencies(instmod:mxInstModule, nfounds:dObjectMap)\n\t\tLocal addlist:TListEx = instmod.CheckCompliance()\n\t\tIf addlist\n\t\t\tFor Local modid:String = EachIn addlist\n\t\t\t\tIf Not m_depcheckmap._Contains(modid)\n\t\t\t\t\tLocal dmodul:mxModule = mainapp.m_sourceshandler.GetModuleWithID(modid)\n\t\t\t\t\tm_depcheckmap._Insert(modid, modid)\n\t\t\t\t\tIf dmodul\n\t\t\t\t\t\tIf Not m_instmap._Contains(modid)\n\t\t\t\t\t\t\tLocal dinstmod:mxInstModule = New mxInstModule.Create(modid, dmodul)\n\t\t\t\t\t\t\tIf instmod.GetVersionName().ToLower() = \"dev\"\n\t\t\t\t\t\t\t\tdinstmod.SetVersionFromName(\"dev\")\n\t\t\t\t\t\t\tElse\n\t\t\t\t\t\t\t\tdinstmod.SetVersion(Null)\n\t\t\t\t\t\t\tEnd If\n\t\t\t\t\t\t\tm_instmap._Insert(modid, dinstmod)\n\t\t\t\t\t\t\tCheckModuleDependencies(dinstmod, nfounds)\n\t\t\t\t\t\tEnd If\n\t\t\t\t\tElse\n\t\t\t\t\t\tnfounds._Insert(modid, modid)\n\t\t\t\t\tEnd If\n\t\t\t\tEnd If\n\t\t\tNext\n\t\tEnd If\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Do the actual installing.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod DoInstall()\n\t\tIf m_instmap.Count() > 0\n\t\t\tLocal a:String, instmod:mxInstModule\n\n\t\t\tIf m_unmanagedmap.Count()\n\t\t\t\tlogger.LogMessage(_s(\"arg.install.modulestoskip\"))\n\t\t\t\tFor instmod = EachIn m_unmanagedmap.ValueEnumerator()\n\t\t\t\t\ta:+instmod.GetVerID() + \" \"\n\t\t\t\tNext\n\t\t\t\ta = a[..a.Length - 1]\n\t\t\t\tlogger.LogMessage(\"~t\" + a)\n\t\t\t\ta = \"\"\n\t\t\tEnd If\n\n\t\t\tlogger.LogMessage(_s(\"arg.install.modulestoinstall\"))\n\t\t\tFor instmod = EachIn m_instmap.ValueEnumerator()\n\t\t\t\ta:+ instmod.GetVerID() + \" \"\n\t\t\tNext\n\t\t\ta = a[..a.Length - 1]\n\t\t\tlogger.LogMessage(\"~t\" + a)\n\t\t\tLocal resp:String = Input(_s(\"arg.install.continuewithinstall\") + \" \").ToLower()\n\t\t\tIf resp = \"y\" Or resp = \"yes\"\n\t\t\t\tFor instmod = EachIn m_instmap.ValueEnumerator()\n\t\t\t\t\tinstmod.FetchSourceArchive()\n\t\t\t\tNext\n\t\t\t\tIf Not m_nounpack\n\t\t\t\t\tFor instmod = EachIn m_instmap.ValueEnumerator()\n\t\t\t\t\t\tinstmod.Unpack()\n\t\t\t\t\tNext\n\t\t\t\tElse\n\t\t\t\t\tlogger.LogMessage(_s(\"message.skipping.unpack\"))\n\t\t\t\tEnd If\n\t\t\t\tIf Not m_keeptemp Then DeleteDir(\"tmp\/\", True)\n\t\t\t\tIf Not m_nobuild\n\t\t\t\t\tLocal scopes:dObjectMap = New dObjectMap\n\t\t\t\t\tFor instmod = EachIn m_instmap.ValueEnumerator()\n\t\t\t\t\t\tscopes._Insert(instmod.GetModuleScope(), instmod.GetModuleScope())\n\t\t\t\t\tNext\n\t\t\t\t\tFor Local scope:String = EachIn scopes.ValueEnumerator()\n\t\t\t\t\t\tIf mxBMKUtils.MakeMods(scope, m_nothreaded ~ 1) <> 0\n\t\t\t\t\t\t\tThrowError(_s(\"error.install.build\", [scope]))\n\t\t\t\t\t\tEnd If\n\t\t\t\t\tNext\n\t\t\t\t\tIf m_makedocs\n\t\t\t\t\t\t'For instmod = EachIn m_instmap.ValueEnumerator()\n\t\t\t\t\t\t'\tmxModUtils.DocMods(instmod.GetID())\n\t\t\t\t\t\t'Next\n\t\t\t\t\t\t' Can't build docs for individual modules yet\n\t\t\t\t\t\tmxModUtils.DocMods()\n\t\t\t\t\tEnd If\n\t\t\t\tElse\n\t\t\t\t\tlogger.LogMessage(_s(\"message.skipping.install\"))\n\t\t\t\tEnd If\n\t\t\tEnd If\n\t\tElse\n\t\t\tlogger.LogMessage(_s(\"arg.install.nomodulestoinstall\"))\n\t\t\tIf m_unmanagedmap.Count()\n\t\t\t\tlogger.LogMessage(_s(\"arg.install.modulestoskip\"))\n\t\t\t\tLocal a:String\n\t\t\t\tFor Local instmod:mxInstModule = EachIn m_unmanagedmap.ValueEnumerator()\n\t\t\t\t\ta:+instmod.GetVerID() + \" \"\n\t\t\t\tNext\n\t\t\t\ta = a[..a.Length - 1]\n\t\t\t\tlogger.LogMessage(\"~t\" + a)\n\t\t\tEnd If\n\t\tEnd If\n\tEnd Method\n\t\nEnd Type\n\nRem\n\tbbdoc: Maximus install info module.\n\tabout: This type is used for temporary install information on modules.\nEnd Rem\nType mxInstModule\n\t\n\tField m_id:String\n\tField m_version:mxModuleVersion\n\tField m_module:mxModule\n\t\n\tRem\n\t\tbbdoc: Create a new mxInstModule.\n\t\treturns: Itself.\n\tEnd Rem\n\tMethod Create:mxInstModule(verid:String, modul:mxModule)\n\t\tSetID(mxModUtils.GetIDFromVerID(verid))\n\t\tSetModule(modul)\n\t\tReturn Self\n\tEnd Method\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the modid to be installed.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetID(id:String)\n\t\tm_id = id\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the modid to be installed.\n\t\treturns: The modid to be installed.\n\tEnd Rem\n\tMethod GetID:String()\n\t\tReturn m_id\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the version from the given versioned-module name (e.g. \"foo.bar\/1.02\").\n\t\treturns: True if the version was set, or False if the version could not be found (was not found).\n\t\tabout: The latest version will be set if the given id is Null (or if it isn't versioned (e.g. \"foo.bar\", would result in the latest version being selected)).\n\tEnd Rem\n\tMethod SetVersionFromVerID:Int(verid:String)\n\t\tReturn SetVersionFromName(mxModUtils.GetVersionFromVerID(verid))\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the version to be installed from the given version name (e.g. \"1.02\").\n\t\treturns: True if the version was set, or False if the version could not be set (was not found).\n\t\tabout: The latest version will be set if the given name is Null.\n\tEnd Rem\n\tMethod SetVersionFromName:Int(name:String)\n\t\tIf Not name\n\t\t\tSetVersion(Null) ' Set the latest version (the version wasn't forced)\n\t\t\tReturn True\n\t\tElse\n\t\t\tLocal ver:mxModuleVersion = m_module.GetVersionWithName(name)\n\t\t\tIf ver\n\t\t\t\tSetVersion(ver)\n\t\t\t\tReturn True\n\t\t\tEnd If\n\t\tEnd If\n\t\tReturn False\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the install version.\n\t\treturns: Nothing.\n\t\tabout: If the given value is Null, it will be automatically set to the latest (non-development) version.\n\tEnd Rem\n\tMethod SetVersion(version:mxModuleVersion)\n\t\tm_version = version\n\t\tIf Not m_version\n\t\t\tm_version = m_module.GetLatestVersion()\n\t\tEnd If\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the install version.\n\t\treturns: The version to be installed.\n\tEnd Rem\n\tMethod GetVersion:mxModuleVersion()\n\t\tReturn m_version\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the module to be installed.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetModule(modul:mxModule)\n\t\tm_module = modul\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the module to be installed.\n\t\treturns: The module to be installed.\n\tEnd Rem\n\tMethod GetModule:mxModule()\n\t\tReturn m_module\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the module's scope.\n\t\treturns: The module's scope.\n\tEnd Rem\n\tMethod GetModuleScope:String()\n\t\tReturn mxModUtils.GetScopeFromID(m_id)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the module's name.\n\t\treturns: The module's name.\n\tEnd Rem\n\tMethod GetModuleName:String()\n\t\tReturn mxModUtils.GetNameFromID(m_id)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the versioned-module id.\n\t\treturns: The exact module to be installed (e.g. \"foo.bar\/1.02\").\n\tEnd Rem\n\tMethod GetVerID:String()\n\t\tReturn m_id + \"\/\" + m_version.GetName()\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the name of the version to be installed.\n\t\treturns: The name of the version to be installed.\n\tEnd Rem\n\tMethod GetVersionName:String()\n\t\tReturn m_version.GetName()\n\tEnd Method\n\t\n'#end region Field accessors\n\t\n\tRem\n\t\tbbdoc: Check the dependency compliance of the current module set.\n\t\treturns: Null if all dependencies are matched by existing modules, or a list of module ids that are not yet installed.\n\tEnd Rem\n\tMethod CheckCompliance:TListEx()\n\t\tReturn m_version.GetDependencies().CheckCompliance()\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Fetch the source archive for the version to be installed.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod FetchSourceArchive()\n\t\tm_version.FetchSourceArchive()\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Unpack the version's archive.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod Unpack()\n\t\tLocal archivepath:String = m_version.GetTemporaryFilePath()\n\t\tLocal zreader:ZipReader = New ZipReader\n\t\tlogger.LogMessage(_s(\"message.unpacking\", [archivepath]))\n\t\tIf zreader.OpenZip(archivepath)\n\t\t\tLocal filename:String, outputpath:String\n\t\t\tLocal basepath:String = mainapp.m_modpath + \"\/\" + mxModUtils.GetScopeFromID(m_id) + \".mod\/\"\n\t\t\tFor Local fileinfo:SZipFileEntry = EachIn zreader.m_zipFileList.FileList\n\t\t\t\tfilename = fileinfo.zipFileName\n\t\t\t\toutputpath = basepath + filename\n\t\t\t\t'DebugLog(\"Zip outputpath: ~q\" + outputpath + \"~q\")\n\t\t\t\tIf filename[filename.Length - 1] = 47 ' \"\/\"\n\t\t\t\t\tCreateDir(outputpath, True)\n\t\t\t\tElse\n\t\t\t\t\tIf CreateFileExplicitly(outputpath)\n\t\t\t\t\t\tzreader.ExtractFileToDisk(filename, outputpath, False)\n\t\t\t\t\tElse\n\t\t\t\t\t\tzreader.CloseZip()\n\t\t\t\t\t\tThrowError(_s(\"error.writeperms\", [outputpath]))\n\t\t\t\t\tEnd If\n\t\t\t\tEnd If\n\t\t\tNext\n\t\t\tzreader.CloseZip()\n\n\t\t\tLocal metafile:mxMetaFile = New mxMetaFile.Create(basepath + GetModuleName() + \".mod\/meta.maximus\")\n\t\t\tmetafile.SetMetaData(GetModuleScope(), GetModuleName(), GetVersionName())\n\t\t\tmetafile.Save()\n\t\tElse\n\t\t\tThrowError(_s(\"error.install.openarchive\", [archivepath]))\n\t\tEnd If\n\tEnd Method\n\t\nEnd Type\n\n","old_contents":"\nRem\n\tbbdoc: Maximus 'install' argument implementation.\nEnd Rem\nType mxInstallImpl Extends dArgumentImplementation\n\t\n\tField m_instmap:dObjectMap\n\tField m_depcheckmap:dObjectMap\n\tField m_unmanagedmap:dObjectMap\n\tField m_nobuild:Int = False, m_nounpack:Int = False, m_keeptemp:Int = False\n\tField m_nothreaded:Int = False, m_makedocs:Int = False, m_forceinstall:Int = False\n\t\n\tMethod New()\n\t\tinit([\"install\"])\n\t\tm_instmap = New dObjectMap\n\t\tm_depcheckmap = New dObjectMap\n\t\tm_unmanagedmap = New dObjectMap\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Check the current arguments for errors (according to the specific implementation).\n\t\treturns: Nothing.\n\t\tabout: This method will throw an error if the arguments are invalid.\n\tEnd Rem\n\tMethod CheckArgs()\n\t\tIf GetArgumentCount() = 0\n\t\t\tThrowCommonError(mxCmdErrors.REQUIRESPARAMS, m_args.GetName())\n\t\tEnd If\n\t\tCheckOptions()\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get a string describing the typical usage of the argument.\n\t\treturns: A string describing the typical usage of the argument.\n\tEnd Rem\n\tMethod GetUsage:String()\n\t\tReturn _s(\"arg.install.usage\")\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Execute the implementation's operation.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod Execute()\n\t\tm_instmap.Clear()\n\t\tm_depcheckmap.Clear()\n\t\tm_unmanagedmap.Clear()\n\t\tIf mainapp.m_sourceshandler\n\t\t\tLocal nfounds:dObjectMap = New dObjectMap\n\t\t\tFor Local svar:dStringVariable = EachIn m_args\n\t\t\t\tLocal verid:String = svar.Get(), modid:String = mxModUtils.GetIDFromVerID(verid)\n\t\t\t\tLocal modul:mxModule = mainapp.m_sourceshandler.GetModuleWithID(modid)\n\t\t\t\tIf modul\n\t\t\t\t\tLocal instmod:mxInstModule = New mxInstModule.Create(verid, modul)\n\t\t\t\t\tIf instmod.SetVersionFromVerID(verid)\n\t\t\t\t\t\tm_instmap._Insert(modid, instmod)\n\t\t\t\t\tElse\n\t\t\t\t\t\tThrowError(_s(\"arg.install.notfound.version\", [modid, mxModUtils.GetVersionFromVerID(verid)]))\n\t\t\t\t\tEnd If\n\t\t\t\tElse\n\t\t\t\t\tnfounds._Insert(modid, modid)\n\t\t\t\tEnd If\n\t\t\tNext\n\t\t\tIf nfounds.Count() > 0\n\t\t\t\tlogger.LogError(_s(\"arg.install.notfound.instmods\"))\n\t\t\t\tLocal a:String\n\t\t\t\tFor Local b:String = EachIn nfounds.ValueEnumerator()\n\t\t\t\t\ta:+ b + \" \"\n\t\t\t\tNext\n\t\t\t\ta = a[..a.Length - 1]\n\t\t\t\tlogger.LogMessage(\"~t\" + a)\n\t\t\t\tReturn\n\t\t\tEnd If\n\t\t\tIf CheckDependencies()\n\t\t\t\t'Make sure we only install\/update managed modules\n\t\t\t\tIf CheckVersions()\n\t\t\t\t\tDoInstall()\n\t\t\t\tEnd If\n\t\t\tEnd If\n\t\tElse\n\t\t\tThrowError(_s(\"error.install.nosources\"))\n\t\tEnd If\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Check the options given to the command.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod CheckOptions()\n\t\tm_nobuild = False; m_nounpack = False; m_keeptemp = False\n\t\tm_nothreaded = False; m_makedocs = False\n\t\tFor Local opt:dIdentifier = EachIn m_args\n\t\t\tSelect opt.GetName().ToLower()\n\t\t\t\tCase \"-nobuild\" m_nobuild = True\n\t\t\t\tCase \"-nounpack\" m_nounpack = True\n\t\t\t\tCase \"-keeptemp\" m_keeptemp = True\n\t\t\t\tCase \"-nothreaded\" m_nothreaded = True\n\t\t\t\tCase \"-makedocs\" m_makedocs = True\n\t\t\t\tCase \"-force\" m_forceinstall = True\n\t\t\t\tDefault ThrowCommonError(mxOptErrors.UNKNOWN, opt.GetName())\n\t\t\tEnd Select\n\t\tNext\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Check for version conflictions and warn the user.\n\t\treturns: True if the installtion should continue, or False if the user halted the operation.\n\tEnd Rem\n\tMethod CheckVersions:Int()\n\t\tFor Local instmod:mxInstModule = EachIn m_instmap.ValueEnumerator()\n\t\t\tLocal ver:String = mxModUtils.GetInstalledVersionFromVerID(instmod.GetVerID())\n\t\t\t'Make sure we skip unmanaged modules\n\t\t\tIf ver = \"unmanaged\"\n\t\t\t\tm_instmap._Remove(instmod.GetID())\n\t\t\t\tm_unmanagedmap._Insert(instmod.GetID(), instmod)\n\t\t\tEnd If\n\t\tNext\n\t\tReturn True\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Check the dependencies for the modules to be installed.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod CheckDependencies:Int()\n\t\tLocal addlist:TListEx, nfounds:dObjectMap = New dObjectMap\n\t\tFor Local instmod:mxInstModule = EachIn m_instmap.ValueEnumerator()\n\t\t\tCheckModuleDependencies(instmod, nfounds)\n\t\tNext\n\t\tIf nfounds.Count() > 0\n\t\t\tlogger.LogError(_s(\"arg.install.notfound.instdeps\"))\n\t\t\tLocal a:String\n\t\t\tFor Local b:String = EachIn nfounds.ValueEnumerator()\n\t\t\t\ta:+ b + \" \"\n\t\t\tNext\n\t\t\ta = a[..a.Length - 1]\n\t\t\tlogger.LogMessage(\"~t\" + a)\n\t\t\tIf m_forceinstall\n\t\t\t\tm_nobuild = True\n\t\t\t\tLocal resp:String = Input(_s(\"arg.install.missingdeps\") + \" \").ToLower()\n\t\t\t\tIf resp = \"y\" Or resp = \"yes\"\n\t\t\t\t\tReturn True\n\t\t\t\tEnd If\n\t\t\tEnd If\n\t\t\tReturn False\n\t\tEnd If\n\t\tReturn True\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Check the dependencies for the given module and adapt the install list accordingly.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod CheckModuleDependencies(instmod:mxInstModule, nfounds:dObjectMap)\n\t\tLocal addlist:TListEx = instmod.CheckCompliance()\n\t\tIf addlist\n\t\t\tFor Local modid:String = EachIn addlist\n\t\t\t\tIf Not m_depcheckmap._Contains(modid)\n\t\t\t\t\tLocal dmodul:mxModule = mainapp.m_sourceshandler.GetModuleWithID(modid)\n\t\t\t\t\tm_depcheckmap._Insert(modid, modid)\n\t\t\t\t\tIf dmodul\n\t\t\t\t\t\tIf Not m_instmap._Contains(modid)\n\t\t\t\t\t\t\tLocal dinstmod:mxInstModule = New mxInstModule.Create(modid, dmodul)\n\t\t\t\t\t\t\tIf instmod.GetVersionName().ToLower() = \"dev\"\n\t\t\t\t\t\t\t\tdinstmod.SetVersionFromName(\"dev\")\n\t\t\t\t\t\t\tElse\n\t\t\t\t\t\t\t\tdinstmod.SetVersion(Null)\n\t\t\t\t\t\t\tEnd If\n\t\t\t\t\t\t\tm_instmap._Insert(modid, dinstmod)\n\t\t\t\t\t\t\tCheckModuleDependencies(dinstmod, nfounds)\n\t\t\t\t\t\tEnd If\n\t\t\t\t\tElse\n\t\t\t\t\t\tnfounds._Insert(modid, modid)\n\t\t\t\t\tEnd If\n\t\t\t\tEnd If\n\t\t\tNext\n\t\tEnd If\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Do the actual installing.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod DoInstall()\n\t\tIf m_instmap.Count() > 0\n\t\t\tLocal a:String, instmod:mxInstModule\n\n\t\t\tIf m_unmanagedmap.Count()\n\t\t\t\tlogger.LogMessage(_s(\"arg.install.modulestoskip\"))\n\t\t\t\tFor instmod = EachIn m_unmanagedmap.ValueEnumerator()\n\t\t\t\t\ta:+instmod.GetVerID() + \" \"\n\t\t\t\tNext\n\t\t\t\ta = a[..a.Length - 1]\n\t\t\t\tlogger.LogMessage(\"~t\" + a)\n\t\t\t\ta = \"\"\n\t\t\tEnd If\n\n\t\t\tlogger.LogMessage(_s(\"arg.install.modulestoinstall\"))\n\t\t\tFor instmod = EachIn m_instmap.ValueEnumerator()\n\t\t\t\ta:+ instmod.GetVerID() + \" \"\n\t\t\tNext\n\t\t\ta = a[..a.Length - 1]\n\t\t\tlogger.LogMessage(\"~t\" + a)\n\t\t\tLocal resp:String = Input(_s(\"arg.install.continuewithinstall\") + \" \").ToLower()\n\t\t\tIf resp = \"y\" Or resp = \"yes\"\n\t\t\t\tFor instmod = EachIn m_instmap.ValueEnumerator()\n\t\t\t\t\tinstmod.FetchSourceArchive()\n\t\t\t\tNext\n\t\t\t\tIf Not m_nounpack\n\t\t\t\t\tFor instmod = EachIn m_instmap.ValueEnumerator()\n\t\t\t\t\t\tinstmod.Unpack()\n\t\t\t\t\tNext\n\t\t\t\tElse\n\t\t\t\t\tlogger.LogMessage(_s(\"message.skipping.unpack\"))\n\t\t\t\tEnd If\n\t\t\t\tIf Not m_keeptemp Then DeleteDir(\"tmp\/\", True)\n\t\t\t\tIf Not m_nobuild\n\t\t\t\t\tLocal scopes:dObjectMap = New dObjectMap\n\t\t\t\t\tFor instmod = EachIn m_instmap.ValueEnumerator()\n\t\t\t\t\t\tscopes._Insert(instmod.GetModuleScope(), instmod.GetModuleScope())\n\t\t\t\t\tNext\n\t\t\t\t\tFor Local scope:String = EachIn scopes.ValueEnumerator()\n\t\t\t\t\t\tIf mxBMKUtils.MakeMods(scope, m_nothreaded ~ 1) <> 0\n\t\t\t\t\t\t\tThrowError(_s(\"error.install.build\", [scope]))\n\t\t\t\t\t\tEnd If\n\t\t\t\t\tNext\n\t\t\t\t\tIf m_makedocs\n\t\t\t\t\t\t'For instmod = EachIn m_instmap.ValueEnumerator()\n\t\t\t\t\t\t'\tmxModUtils.DocMods(instmod.GetID())\n\t\t\t\t\t\t'Next\n\t\t\t\t\t\t' Can't build docs for individual modules yet\n\t\t\t\t\t\tmxModUtils.DocMods()\n\t\t\t\t\tEnd If\n\t\t\t\tElse\n\t\t\t\t\tlogger.LogMessage(_s(\"message.skipping.install\"))\n\t\t\t\tEnd If\n\t\t\tEnd If\n\t\tElse\n\t\t\tlogger.LogMessage(_s(\"arg.install.nomodulestoinstall\"))\n\t\t\tIf m_unmanagedmap.Count()\n\t\t\t\tlogger.LogMessage(_s(\"arg.install.modulestoskip\"))\n\t\t\t\tLocal a:String\n\t\t\t\tFor Local instmod:mxInstModule = EachIn m_unmanagedmap.ValueEnumerator()\n\t\t\t\t\ta:+instmod.GetVerID() + \" \"\n\t\t\t\tNext\n\t\t\t\ta = a[..a.Length - 1]\n\t\t\t\tlogger.LogMessage(\"~t\" + a)\n\t\t\tEnd If\n\t\tEnd If\n\tEnd Method\n\t\nEnd Type\n\nRem\n\tbbdoc: Maximus install info module.\n\tabout: This type is used for temporary install information on modules.\nEnd Rem\nType mxInstModule\n\t\n\tField m_id:String\n\tField m_version:mxModuleVersion\n\tField m_module:mxModule\n\t\n\tRem\n\t\tbbdoc: Create a new mxInstModule.\n\t\treturns: Itself.\n\tEnd Rem\n\tMethod Create:mxInstModule(verid:String, modul:mxModule)\n\t\tSetID(mxModUtils.GetIDFromVerID(verid))\n\t\tSetModule(modul)\n\t\tReturn Self\n\tEnd Method\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the modid to be installed.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetID(id:String)\n\t\tm_id = id\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the modid to be installed.\n\t\treturns: The modid to be installed.\n\tEnd Rem\n\tMethod GetID:String()\n\t\tReturn m_id\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the version from the given versioned-module name (e.g. \"foo.bar\/1.02\").\n\t\treturns: True if the version was set, or False if the version could not be found (was not found).\n\t\tabout: The latest version will be set if the given id is Null (or if it isn't versioned (e.g. \"foo.bar\", would result in the latest version being selected)).\n\tEnd Rem\n\tMethod SetVersionFromVerID:Int(verid:String)\n\t\tReturn SetVersionFromName(mxModUtils.GetVersionFromVerID(verid))\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the version to be installed from the given version name (e.g. \"1.02\").\n\t\treturns: True if the version was set, or False if the version could not be set (was not found).\n\t\tabout: The latest version will be set if the given name is Null.\n\tEnd Rem\n\tMethod SetVersionFromName:Int(name:String)\n\t\tIf Not name\n\t\t\tSetVersion(Null) ' Set the latest version (the version wasn't forced)\n\t\t\tReturn True\n\t\tElse\n\t\t\tLocal ver:mxModuleVersion = m_module.GetVersionWithName(name)\n\t\t\tIf ver\n\t\t\t\tSetVersion(ver)\n\t\t\t\tReturn True\n\t\t\tEnd If\n\t\tEnd If\n\t\tReturn False\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the install version.\n\t\treturns: Nothing.\n\t\tabout: If the given value is Null, it will be automatically set to the latest (non-development) version.\n\tEnd Rem\n\tMethod SetVersion(version:mxModuleVersion)\n\t\tm_version = version\n\t\tIf Not m_version\n\t\t\tm_version = m_module.GetLatestVersion()\n\t\tEnd If\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the install version.\n\t\treturns: The version to be installed.\n\tEnd Rem\n\tMethod GetVersion:mxModuleVersion()\n\t\tReturn m_version\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the module to be installed.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetModule(modul:mxModule)\n\t\tm_module = modul\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the module to be installed.\n\t\treturns: The module to be installed.\n\tEnd Rem\n\tMethod GetModule:mxModule()\n\t\tReturn m_module\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the module's scope.\n\t\treturns: The module's scope.\n\tEnd Rem\n\tMethod GetModuleScope:String()\n\t\tReturn mxModUtils.GetScopeFromID(m_id)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the module's name.\n\t\treturns: The module's name.\n\tEnd Rem\n\tMethod GetModuleName:String()\n\t\tReturn mxModUtils.GetNameFromID(m_id)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the versioned-module id.\n\t\treturns: The exact module to be installed (e.g. \"foo.bar\/1.02\").\n\tEnd Rem\n\tMethod GetVerID:String()\n\t\tReturn m_id + \"\/\" + m_version.GetName()\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the name of the version to be installed.\n\t\treturns: The name of the version to be installed.\n\tEnd Rem\n\tMethod GetVersionName:String()\n\t\tReturn m_version.GetName()\n\tEnd Method\n\t\n'#end region Field accessors\n\t\n\tRem\n\t\tbbdoc: Check the dependency compliance of the current module set.\n\t\treturns: Null if all dependencies are matched by existing modules, or a list of module ids that are not yet installed.\n\tEnd Rem\n\tMethod CheckCompliance:TListEx()\n\t\tReturn m_version.GetDependencies().CheckCompliance()\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Fetch the source archive for the version to be installed.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod FetchSourceArchive()\n\t\tm_version.FetchSourceArchive()\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Unpack the version's archive.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod Unpack()\n\t\tLocal archivepath:String = m_version.GetTemporaryFilePath()\n\t\tLocal zreader:ZipReader = New ZipReader\n\t\tlogger.LogMessage(_s(\"message.unpacking\", [archivepath]))\n\t\tIf zreader.OpenZip(archivepath)\n\t\t\tLocal filename:String, outputpath:String\n\t\t\tLocal basepath:String = mainapp.m_modpath + \"\/\" + mxModUtils.GetScopeFromID(m_id) + \".mod\/\"\n\t\t\tFor Local fileinfo:SZipFileEntry = EachIn zreader.m_zipFileList.FileList\n\t\t\t\tfilename = fileinfo.zipFileName\n\t\t\t\toutputpath = basepath + filename\n\t\t\t\t'DebugLog(\"Zip outputpath: ~q\" + outputpath + \"~q\")\n\t\t\t\tIf filename[filename.Length - 1] = 47 ' \"\/\"\n\t\t\t\t\tCreateDir(outputpath, True)\n\t\t\t\tElse\n\t\t\t\t\tIf CreateFileExplicitly(outputpath)\n\t\t\t\t\t\tzreader.ExtractFileToDisk(filename, outputpath, False)\n\t\t\t\t\tElse\n\t\t\t\t\t\tzreader.CloseZip()\n\t\t\t\t\t\tThrowError(_s(\"error.writeperms\", [outputpath]))\n\t\t\t\t\tEnd If\n\t\t\t\tEnd If\n\t\t\tNext\n\t\t\tzreader.CloseZip()\n\n\t\t\tLocal metafile:mxMetaFile = New mxMetaFile.Create(basepath + GetModuleName() + \".mod\/meta.maximus\")\n\t\t\tmetafile.SetMetaData(GetModuleScope(), GetModuleName(), GetVersionName())\n\t\t\tmetafile.Save()\n\t\tElse\n\t\t\tThrowError(_s(\"error.install.openarchive\", [archivepath]))\n\t\tEnd If\n\tEnd Method\n\t\nEnd Type\n\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"d70c9b2f31d6e69249df4d5dd8cbf88f68d40ce5","subject":"Now also compiles under Linux, as iconv is available by default.","message":"Now also compiles under Linux, as iconv is available by default.","repos":"Htbaa\/xmlrpc.mod,Htbaa\/xmlrpc.mod,Htbaa\/xmlrpc.mod,Htbaa\/xmlrpc.mod,Htbaa\/xmlrpc.mod","old_file":"xmlrpc.bmx","new_file":"xmlrpc.bmx","new_contents":"SuperStrict\n\nRem\n\tbbdoc: htbaapub.xmlrpc\nEndRem\nModule htbaapub.xmlrpc\nModuleInfo \"Name: htbaapub.xmlrpc\"\nModuleInfo \"Version: 1.0\"\nModuleInfo \"Author: Christiaan Kras\"\nModuleInfo \"Git repository: http:\/\/github.com\/Htbaa\/htbaapub.mod\/<\/a>\"\nModuleInfo \"XMLRPC-EPI: http:\/\/xmlrpc-epi.sourceforge.net\/<\/a>\"\nModuleInfo \"Expat: http:\/\/expat.sourceforge.net\/<\/a>\"\nModuleInfo \"iconv: http:\/\/gnuwin32.sourceforge.net\/packages\/libiconv.htm<\/a>\"\nModuleInfo \"iconv-win32: http:\/\/www.zlatkovic.com\/pub\/libxml<\/a>\"\n\nImport brl.blitz\nImport brl.basic\nImport brl.map\nImport brl.reflection\nImport brl.socket\n\nImport \"src\/expat-2.0.1\/src\/*.h\"\nModuleInfo \"CC_OPTS: -DHAVE_EXPAT_CONFIG_H\"\n?ppc\n\tModuleInfo \"CC_OPTS: -DWORDS_BIGENDIAN\"\n?\n\nImport \"src\/expat-2.0.1\/src\/xmlparse.c\"\nImport \"src\/expat-2.0.1\/src\/xmlrole.c\"\nImport \"src\/expat-2.0.1\/src\/xmltok.c\"\nImport \"src\/expat-2.0.1\/src\/xmltok_impl.c\"\nImport \"src\/expat-2.0.1\/src\/xmltok_ns.c\"\n\nImport \"src\/xmlrpc-epi-0.54\/src\/*.h\"\nImport \"glue.c\"\n\n?Win32\n\tImport \"win32.cpp\"\n\tModuleInfo \"LD_OPTS: -L%PWD%\/src\/iconv-1.9.2.win32\/lib\"\n\tImport \"src\/iconv-1.9.2.win32\/include\/*.h\"\n?\n\nImport \"src\/xmlrpc-epi-0.54\/src\/xmlrpc.c\"\nImport \"src\/xmlrpc-epi-0.54\/src\/base64.c\"\nImport \"src\/xmlrpc-epi-0.54\/src\/encodings.c\"\nImport \"src\/xmlrpc-epi-0.54\/src\/queue.c\"\nImport \"src\/xmlrpc-epi-0.54\/src\/simplestring.c\"\nImport \"src\/xmlrpc-epi-0.54\/src\/system_methods.c\"\nImport \"src\/xmlrpc-epi-0.54\/src\/xml_element.c\"\nImport \"src\/xmlrpc-epi-0.54\/src\/xml_to_dandarpc.c\"\nImport \"src\/xmlrpc-epi-0.54\/src\/xml_to_soap.c\"\nImport \"src\/xmlrpc-epi-0.54\/src\/xml_to_xmlrpc.c\"\nImport \"src\/xmlrpc-epi-0.54\/src\/xmlrpc_introspection.c\"\n\nInclude \"wrapper.bmx\"\nInclude \"datatypes.bmx\"\nInclude \"response.bmx\"\nInclude \"transport.bmx\"\nInclude \"client.bmx\"\nInclude \"server.bmx\"\n\nRem\n\tbbdoc: General XML-RPC Exception\nEnd Rem\nType TXMLRPC_Exception\n\tField message:String\n\tRem\n\t\tbbdoc: Set message for exception\n\tEnd Rem\n\tMethod Create:TXMLRPC_Exception(message:String)\n\t\tSelf.message = message\n\t\tReturn Self\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Return exception message\n\tEnd Rem\n\tMethod ToString:String()\n\t\tReturn Self.message\n\tEnd Method\nEnd Type\n\nRem\n\tbbdoc: Parameters to be passed to the XML-RPC server when using TXMLRPC_Client.Call()\nEnd Rem\nType TXMLRPC_Call_Parameters\n\tField vector:Byte Ptr\n\n\tRem\n\t\tbbdoc: Create a TXMLRPC_Call_Parameters object.\n\t\tabout: vectorType can be: xmlrpc_vector_none, xmlrpc_vector_array, xmlrpc_vector_mixed or xmlrpc_vector_struct\n\tEnd Rem\n\tFunction Create:TXMLRPC_Call_Parameters(vectorType:Int = xmlrpc_vector_mixed)\n\t\tLocal parameters:TXMLRPC_Call_Parameters = New TXMLRPC_Call_Parameters\n\t\tparameters.vector = XMLRPC_CreateVector(Null, vectorType)\n\t\tReturn parameters\n\tEnd Function\n\n\tRem\n\t\tbbdoc: Append string value\n\tEnd Rem\n\tMethod AppendString:Int(id:String, s:String)\n\t\tReturn XMLRPC_VectorAppendString(Self.vector, id, s)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Append Base64 value. Just pass a string, it'll be BASE64 encoded for you\n\tEnd Rem\n\tMethod AppendBase64:Int(id:String, s:String)\n\t\tReturn XMLRPC_VectorAppendBase64(Self.vector, id, s)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Append UNIX timestmap value\n\tEnd Rem\n\tMethod AppendDateTime:Int(id:String, time:Long)\n\t\tReturn XMLRPC_VectorAppendDateTime(Self.vector, id, time)\n\tEnd Method\n\n\tRem\n\t\tbbdoc: Append datetime in ISO8601 format\n\tEnd Rem\n\tMethod AppendDateTime_ISO8601:Int(id:String, s:String)\n\t\tReturn XMLRPC_VectorAppendDateTime_ISO8601(Self.vector, id, s)\n\tEnd Method\n\n\tRem\n\t\tbbdoc: Append double value\n\tEnd Rem\n\tMethod AppendDouble:Int(id:String, f:Double)\n\t\tReturn XMLRPC_VectorAppendDouble(Self.vector, id, f)\n\tEnd Method\n\n\tRem\n\t\tbbdoc: Append integer value\n\tEnd Rem\n\tMethod AppendInt:Int(id:String, i:Int)\n\t\tReturn XMLRPC_VectorAppendInt(Self.vector, id, i)\n\tEnd Method\n\n\tRem\n\t\tbbdoc: Append boolean value\n\tEnd Rem\n\tMethod AppendBoolean:Int(id:String, i:Byte)\n\t\tReturn XMLRPC_VectorAppendBoolean(Self.vector, id, i)\n\tEnd Method\nEnd Type\n","old_contents":"SuperStrict\n\nRem\n\tbbdoc: htbaapub.xmlrpc\nEndRem\nModule htbaapub.xmlrpc\nModuleInfo \"Name: htbaapub.xmlrpc\"\nModuleInfo \"Version: 1.0\"\nModuleInfo \"Author: Christiaan Kras\"\nModuleInfo \"Git repository: http:\/\/github.com\/Htbaa\/htbaapub.mod\/<\/a>\"\nModuleInfo \"XMLRPC-EPI: http:\/\/xmlrpc-epi.sourceforge.net\/<\/a>\"\nModuleInfo \"Expat: http:\/\/expat.sourceforge.net\/<\/a>\"\nModuleInfo \"iconv: http:\/\/gnuwin32.sourceforge.net\/packages\/libiconv.htm<\/a>\"\nModuleInfo \"iconv-win32: http:\/\/www.zlatkovic.com\/pub\/libxml<\/a>\"\n\nImport brl.blitz\nImport brl.basic\nImport brl.map\nImport brl.reflection\nImport brl.socket\n\nImport \"src\/expat-2.0.1\/src\/*.h\"\nModuleInfo \"CC_OPTS: -DHAVE_EXPAT_CONFIG_H\"\n?ppc\n\tModuleInfo \"CC_OPTS: -DWORDS_BIGENDIAN\"\n?\n\nImport \"src\/expat-2.0.1\/src\/xmlparse.c\"\nImport \"src\/expat-2.0.1\/src\/xmlrole.c\"\nImport \"src\/expat-2.0.1\/src\/xmltok.c\"\nImport \"src\/expat-2.0.1\/src\/xmltok_impl.c\"\nImport \"src\/expat-2.0.1\/src\/xmltok_ns.c\"\n\nImport \"src\/xmlrpc-epi-0.54\/src\/*.h\"\nImport \"glue.c\"\n\n?Win32\n\tImport \"win32.cpp\"\n\tModuleInfo \"LD_OPTS: -L%PWD%\/src\/iconv-1.9.2.win32\/lib\"\n\tImport \"src\/iconv-1.9.2.win32\/include\/*.h\"\n?\n\nImport \"-liconv\"\n\nImport \"src\/xmlrpc-epi-0.54\/src\/xmlrpc.c\"\nImport \"src\/xmlrpc-epi-0.54\/src\/base64.c\"\nImport \"src\/xmlrpc-epi-0.54\/src\/encodings.c\"\nImport \"src\/xmlrpc-epi-0.54\/src\/queue.c\"\nImport \"src\/xmlrpc-epi-0.54\/src\/simplestring.c\"\nImport \"src\/xmlrpc-epi-0.54\/src\/system_methods.c\"\nImport \"src\/xmlrpc-epi-0.54\/src\/xml_element.c\"\nImport \"src\/xmlrpc-epi-0.54\/src\/xml_to_dandarpc.c\"\nImport \"src\/xmlrpc-epi-0.54\/src\/xml_to_soap.c\"\nImport \"src\/xmlrpc-epi-0.54\/src\/xml_to_xmlrpc.c\"\nImport \"src\/xmlrpc-epi-0.54\/src\/xmlrpc_introspection.c\"\n\nInclude \"wrapper.bmx\"\nInclude \"datatypes.bmx\"\nInclude \"response.bmx\"\nInclude \"transport.bmx\"\nInclude \"client.bmx\"\nInclude \"server.bmx\"\n\nRem\n\tbbdoc: General XML-RPC Exception\nEnd Rem\nType TXMLRPC_Exception\n\tField message:String\n\tRem\n\t\tbbdoc: Set message for exception\n\tEnd Rem\n\tMethod Create:TXMLRPC_Exception(message:String)\n\t\tSelf.message = message\n\t\tReturn Self\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Return exception message\n\tEnd Rem\n\tMethod ToString:String()\n\t\tReturn Self.message\n\tEnd Method\nEnd Type\n\nRem\n\tbbdoc: Parameters to be passed to the XML-RPC server when using TXMLRPC_Client.Call()\nEnd Rem\nType TXMLRPC_Call_Parameters\n\tField vector:Byte Ptr\n\n\tRem\n\t\tbbdoc: Create a TXMLRPC_Call_Parameters object.\n\t\tabout: vectorType can be: xmlrpc_vector_none, xmlrpc_vector_array, xmlrpc_vector_mixed or xmlrpc_vector_struct\n\tEnd Rem\n\tFunction Create:TXMLRPC_Call_Parameters(vectorType:Int = xmlrpc_vector_mixed)\n\t\tLocal parameters:TXMLRPC_Call_Parameters = New TXMLRPC_Call_Parameters\n\t\tparameters.vector = XMLRPC_CreateVector(Null, vectorType)\n\t\tReturn parameters\n\tEnd Function\n\n\tRem\n\t\tbbdoc: Append string value\n\tEnd Rem\n\tMethod AppendString:Int(id:String, s:String)\n\t\tReturn XMLRPC_VectorAppendString(Self.vector, id, s)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Append Base64 value. Just pass a string, it'll be BASE64 encoded for you\n\tEnd Rem\n\tMethod AppendBase64:Int(id:String, s:String)\n\t\tReturn XMLRPC_VectorAppendBase64(Self.vector, id, s)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Append UNIX timestmap value\n\tEnd Rem\n\tMethod AppendDateTime:Int(id:String, time:Long)\n\t\tReturn XMLRPC_VectorAppendDateTime(Self.vector, id, time)\n\tEnd Method\n\n\tRem\n\t\tbbdoc: Append datetime in ISO8601 format\n\tEnd Rem\n\tMethod AppendDateTime_ISO8601:Int(id:String, s:String)\n\t\tReturn XMLRPC_VectorAppendDateTime_ISO8601(Self.vector, id, s)\n\tEnd Method\n\n\tRem\n\t\tbbdoc: Append double value\n\tEnd Rem\n\tMethod AppendDouble:Int(id:String, f:Double)\n\t\tReturn XMLRPC_VectorAppendDouble(Self.vector, id, f)\n\tEnd Method\n\n\tRem\n\t\tbbdoc: Append integer value\n\tEnd Rem\n\tMethod AppendInt:Int(id:String, i:Int)\n\t\tReturn XMLRPC_VectorAppendInt(Self.vector, id, i)\n\tEnd Method\n\n\tRem\n\t\tbbdoc: Append boolean value\n\tEnd Rem\n\tMethod AppendBoolean:Int(id:String, i:Byte)\n\t\tReturn XMLRPC_VectorAppendBoolean(Self.vector, id, i)\n\tEnd Method\nEnd Type\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"965b21d7be3477b57032e41403fb63b2f7c2b1cd","subject":"can't be null","message":"can't be null\n","repos":"Leushenko\/blue-moon","old_file":"bluetable.bmx","new_file":"bluetable.bmx","new_contents":"\n' Blue Moon\n' Lua-table implementation\n' uses simple linear probing for collision resolution and a shockingly naive reallocator\n\n\nSuperStrict\n\nImport \"blueallocator.bmx\"\n\n\nPrivate\nExtern\n\tFunction frexp:Double(d:Double, Exp:Int Ptr) = \"frexp\"\nEnd Extern\nPublic\n\nType BlueTable Final\n\tFunction Get:Long(tbl:Byte Ptr, key:Long)\n\t\tLocal tag:Int = Int Ptr(Varptr(key))[1], idx:Int\n\t\t\n\t\tIf tag = BlueTypeTag.NANBOX | BlueTypeTag.STR\t'string - common case\n\t\t\tidx = Int Ptr(Int(key))[1]\n\t\tElseIf tag & BlueTypeTag.NANBOX_CHK <> BlueTypeTag.NANBOX\t'number\n\t\t\tLocal d:Double ; Long Ptr(Varptr(d))[0] = key ; idx = Abs Int(d)\n\t\t\tIf d = idx\t'int key\n\t\t\t\tLocal arr:Byte Ptr = Byte Ptr Ptr(tbl)[3]\n\t\t\t\tIf arr And idx < Int Ptr(arr)[-1] Then Return Long Ptr(arr)[idx]\t'if this is nil, it won't be in the hash part anyway\n\t\t\tElse\n\t\t\t\td = frexp(d, Varptr(idx)) * ($7fffffff - 1024)\t'INT_MAX - DBL_MAX_EXP\n\t\t\t\tidx = Abs(idx) + Int(d)\n\t\t\tEndIf\n\t\tElseIf tag = BlueTypeTag.NANBOX | BlueTypeTag.NIL\t'nil -> nil\n\t\t\tReturn key\n\t\tElse\t'pointer (needs improvement)\n\t\t\tidx = Int(key) Shr 3\n\t\tEndIf\n\t\t\n\t\tLocal hashpart:Byte Ptr = Byte Ptr Ptr(tbl)[2]\n\t\tIf hashpart\n\t\t\tLocal hsize:Int = 1 Shl Int Ptr(hashpart)[-1]\n\t\t\tidx = idx & (hsize - 1)\t'apparently this is faster than Mod\n\t\t\tFor Local i:Int = idx Until hsize\t'naive linear probe\n\t\t\t\tIf Long Ptr(hashpart)[2 * i] = key Then Return Long Ptr(hashpart)[2 * i + 1]\n\t\t\tNext\n\t\t\tFor Local i:Int = 0 Until idx\t'yep\n\t\t\t\tIf Long Ptr(hashpart)[2 * i] = key Then Return Long Ptr(hashpart)[2 * i + 1]\n\t\t\tNext\n\t\tEndIf\n\t\t\n\t\tLocal ret:Long ; Int Ptr(Varptr(ret))[1] = BlueTypeTag.NANBOX | BlueTypeTag.NIL\t'why can't i shift longs?\n\t\tReturn ret\n\tEnd Function\n\t\n\tFunction Set(mem:BlueVMMemory, tbl:Byte Ptr, key:Long, val:Long)\n\t\tLocal tag:Int = Int Ptr(Varptr(key))[1], idx:Int, slot:Long Ptr = Null\n\t\t\n\t\tIf tag = BlueTypeTag.NANBOX | BlueTypeTag.NIL Then Return\t'nil is not a valid key\n\t\t\n\t\tIf tag & BlueTypeTag.NANBOX_CHK <> BlueTypeTag.NANBOX\t'if key is an int and less than arraylength\n\t\t\tLocal d:Double ; Long Ptr(Varptr(d))[0] = key ; idx = Abs Int(d)\n\t\t\tIf d = idx\n\t\t\t\tLocal arraypart:Byte Ptr = Byte Ptr Ptr(tbl)[3]\n\t\t\t\tIf arraypart <> Null And idx < Int Ptr(arraypart)[-1] Then slot = Long Ptr(arraypart) + idx\n\t\t\tEndIf\n\t\tEndIf\n\t\tIf slot = Null\t'elsewise if hashcount < hashsize\n\t\t\tLocal hashpart:Byte Ptr = Byte Ptr Ptr(tbl)[2]\n\t\t\tIf hashpart <> Null\n\t\t\t\tLocal hsize:Int = 1 Shl Int Ptr(hashpart)[-1]\n\t\t\t\tIf Int Ptr(hashpart)[-2] < hsize\t'there's a slot free somewhere\n\t\t\t\t\t\n\t\t\t\t\tIf tag = BlueTypeTag.NANBOX | BlueTypeTag.STR\t'string - common case\n\t\t\t\t\t\tidx = Int Ptr(Int(key))[1]\n\t\t\t\t\tElseIf tag & BlueTypeTag.NANBOX_CHK <> BlueTypeTag.NANBOX\t'non-integer\n\t\t\t\t\t\tLocal d:Double ; Long Ptr(Varptr(d))[0] = key\n\t\t\t\t\t\td = frexp(d, Varptr(idx)) * ($7fffffff - 1024)\t'INT_MAX - DBL_MAX_EXP\n\t\t\t\t\t\tidx = Abs(idx) + Int(d)\n\t\t\t\t\tElse\t'pointer\n\t\t\t\t\t\tidx = Int(key) Shr 3\n\t\t\t\t\tEndIf\n\t\t\t\t\t\n\t\t\t\t\tidx = idx & (hsize - 1)\t'fastmod\n\t\t\t\t\tFor Local i:Int = idx Until hsize\n\t\t\t\t\t\tIf Long Ptr(hashpart)[2 * i] = key Then slot = Long Ptr(hashpart) + (2 * i + 1)\n\t\t\t\t\tNext\n\t\t\t\t\tFor Local i:Int = 0 Until idx\n\t\t\t\t\t\tIf Long Ptr(hashpart)[2 * i] = key Then slot = Long Ptr(hashpart) + (2 * i + 1)\n\t\t\t\t\tNext\n\t\t\t\t\t\n\t\t\t\tEndIf\n\t\t\tEndIf\n\t\t\tIf slot Then Int Ptr(hashpart)[-2] :+ 1\t'no write barrier needed (not pointer)\n\t\tEndIf\n\t\t\n\t\tIf slot = Null\n\t\t\tResize(mem, tbl, key) ; Set mem, tbl, key, val\n\t\tElse\n\t\t\tmem.Write(slot, val)\n\t\tEndIf\n\tEnd Function\n\t\n\tFunction Resize(mem:BlueVMMemory, tbl:Byte Ptr, key:Long)\n\t\tLocal hashpart:Byte Ptr = Byte Ptr Ptr(tbl)[2], arraypart:Byte Ptr = Byte Ptr Ptr(tbl)[3]\n\t\tConst NILTAG:Int = BlueTypeTag.NANBOX | BlueTypeTag.NIL\n\t\t\n\t\tLocal asize:Int = 0, tsize:Int = 0, numcount:Int[32]\n\t\tIf arraypart\t'compute new array size\n\t\t\tIf Int Ptr(arraypart)[1] <> NILTAG Then numcount[0] = 1\n\t\t\tLocal cell:Int = 1, cellp2:Int = 2 ^ cell\n\t\t\tFor Local i:Int = 1 Until Int Ptr(arraypart)[-1]\n\t\t\t\tIf i >= cellp2 Then cell :+ 1 ; cellp2 = 2 ^ cell\n\t\t\t\tIf Int Ptr(arraypart)[i * 2 + 1] <> NILTAG Then numcount[cell] :+ 1\n\t\t\tNext\n\t\tEndIf\n\t\tIf hashpart\n\t\t\tFor Local i:Int = 0 Until Int Ptr(hashpart)[-2]\n\t\t\t\tLocal tag2:Int = Int Ptr(hashpart)[i * 4 + 1]\n\t\t\t\tIf tag2 & BlueTypeTag.NANBOX_CHK <> BlueTypeTag.NANBOX\n\t\t\t\t\tLocal d:Double = Double Ptr(hashpart)[i * 2]\n\t\t\t\t\tIf d = Abs Int(d) Then numcount[Ceil(Log(d + 1) \/ Log(2))] :+ 1 Else tsize :+ 1\n\t\t\t\tElse\n\t\t\t\t\ttsize :+ 1\t'get started on new table size\n\t\t\t\tEndIf\n\t\t\tNext\n\t\tEndIf\n\t\tLocal tag:Int = Int Ptr(Varptr(key))[1]\t'add key to the appropriate one\n\t\tIf tag & BlueTypeTag.NANBOX_CHK <> BlueTypeTag.NANBOX\n\t\t\tLocal d:Double = Double Ptr(Varptr(key))[0]\n\t\t\tIf d = Abs Int(d) Then numcount[Ceil(Log(d + 1) \/ Log(2))] :+ 1 Else tsize :+ 1\n\t\tElse\n\t\t\ttsize :+ 1\n\t\tEndIf\n\t\tFor Local i:Int = 0 Until 32\t'tally up\n\t\t\tIf i Then numcount[i] :+ numcount[i - 1]\n\t\t\tIf numcount[i] > 2 ^ i \/ 2 Then asize = 2 ^ i\n\t\tNext\n\t\t\n\t\tIf arraypart <> Null\t'complete new table size with any discarded array elements\n\t\t\tFor Local i:Int = asize Until Int Ptr(arraypart)[-1]\n\t\t\t\tIf Int Ptr(arraypart)[i * 2 + 1] <> NILTAG Then tsize :+ 1\n\t\t\tNext\n\t\tEndIf\n\t\t\n\t\tLocal newarray:Byte Ptr = Null, newtable:Byte Ptr = Null\t'allocate and copy\n\t\tIf asize\n\t\t\tnewarray = mem.AllocObject(asize * 8 + 8, BlueTypeTag.ARR) + 8\n\t\t\tFor Local i:Int = 0 Until asize\n\t\t\t\tInt Ptr(newarray)[i * 2 + 1] = NILTAG\n\t\t\tNext\n\t\t\tInt Ptr(newarray)[-1] = asize ; Byte Ptr Ptr(tbl)[3] = newarray\n\t\tElse\n\t\t\tInt Ptr(tbl)[3] = 0\n\t\tEndIf\n\t\tIf tsize\n\t\t\tnewtable = mem.AllocObject(2 ^ tsize * 16 + 8, BlueTypeTag.HASH)\n\t\t\tFor Local i:Int = 0 Until 2 ^ tsize * 2\n\t\t\t\tInt Ptr(newtable)[i * 2 + 1] = NILTAG\n\t\t\tNext\n\t\t\tInt Ptr(newtable)[-1] = tsize ; Byte Ptr Ptr(tbl)[2] = newtable\n\t\tElse\n\t\t\tInt Ptr(tbl)[2] = 0\n\t\tEndIf\n\t\t\n\t\tIf arraypart\n\t\t\tFor Local i:Int = 0 Until Int Ptr(arraypart)[-1]\t'reinsert values\n\t\t\t\tLocal key:Long ; Double Ptr(Varptr(key))[0] = i\n\t\t\t\tSet mem, tbl, key,Long Ptr(arraypart)[i]\n\t\t\tNext\n\t\tEndIf\n\t\tIf hashpart\n\t\t\tFor Local i:Int = 0 Until Int Ptr(hashpart)[-1]\n\t\t\t\tSet mem, tbl, Long Ptr(hashpart)[i * 2], Long Ptr(hashpart)[i * 2 + 1]\n\t\t\tNext\n\t\tEndIf\n\tEnd Function\nEnd Type\n\n","old_contents":"\n' Blue Moon\n' Lua-table implementation\n' uses simple linear probing for collision resolution and a shockingly naive reallocator\n\n\nSuperStrict\n\nImport \"blueallocator.bmx\"\n\n\nPrivate\nExtern\n\tFunction frexp:Double(d:Double, Exp:Int Ptr) = \"frexp\"\nEnd Extern\nPublic\n\nType BlueTable Final\n\tFunction Get:Long(tbl:Byte Ptr, key:Long)\n\t\tLocal tag:Int = Int Ptr(Varptr(key))[1], idx:Int\n\t\t\n\t\tIf tag = BlueTypeTag.NANBOX | BlueTypeTag.STR\t'string - common case\n\t\t\tidx = Int Ptr(Int(key))[1]\n\t\tElseIf tag & BlueTypeTag.NANBOX_CHK <> BlueTypeTag.NANBOX\t'number\n\t\t\tLocal d:Double ; Long Ptr(Varptr(d))[0] = key ; idx = Abs Int(d)\n\t\t\tIf d = idx\t'int key\n\t\t\t\tLocal arr:Byte Ptr = Byte Ptr Ptr(tbl)[3]\n\t\t\t\tIf arr And idx < Int Ptr(arr)[-1] Then Return Long Ptr(arr)[idx]\t'if this is nil, it won't be in the hash part anyway\n\t\t\tElse\n\t\t\t\td = frexp(d, Varptr(idx)) * ($7fffffff - 1024)\t'INT_MAX - DBL_MAX_EXP\n\t\t\t\tidx = Abs(idx) + Int(d)\n\t\t\tEndIf\n\t\tElseIf tag = BlueTypeTag.NANBOX | BlueTypeTag.NIL\t'nil -> nil\n\t\t\tReturn key\n\t\tElse\t'pointer (needs improvement)\n\t\t\tidx = Int(key) Shr 3\n\t\tEndIf\n\t\t\n\t\tLocal hashpart:Byte Ptr = Byte Ptr Ptr(tbl)[2]\n\t\tIf hashpart\n\t\t\tLocal hsize:Int = 1 Shl Int Ptr(hashpart)[-1]\n\t\t\tidx = idx & (hsize - 1)\t'apparently this is faster than Mod\n\t\t\tFor Local i:Int = idx Until hsize\t'naive linear probe\n\t\t\t\tIf Long Ptr(hashpart)[2 * i] = key Then Return Long Ptr(hashpart)[2 * i + 1]\n\t\t\tNext\n\t\t\tFor Local i:Int = 0 Until idx\t'yep\n\t\t\t\tIf Long Ptr(hashpart)[2 * i] = key Then Return Long Ptr(hashpart)[2 * i + 1]\n\t\t\tNext\n\t\tEndIf\n\t\t\n\t\tLocal ret:Long ; Int Ptr(Varptr(ret))[1] = BlueTypeTag.NANBOX | BlueTypeTag.NIL\t'why can't i shift longs?\n\t\tReturn ret\n\tEnd Function\n\t\n\tFunction Set(mem:BlueVMMemory, tbl:Byte Ptr, key:Long, val:Long)\n\t\tLocal tag:Int = Int Ptr(Varptr(key))[1], idx:Int, slot:Long Ptr = Null\n\t\t\n\t\tIf tag = BlueTypeTag.NANBOX | BlueTypeTag.NIL Then Return\t'nil is not a valid key\n\t\t\n\t\tIf tag & BlueTypeTag.NANBOX_CHK <> BlueTypeTag.NANBOX\t'if key is an int and less than arraylength\n\t\t\tLocal d:Double ; Long Ptr(Varptr(d))[0] = key ; idx = Abs Int(d)\n\t\t\tIf d = idx\n\t\t\t\tLocal arraypart:Byte Ptr = Byte Ptr Ptr(tbl)[3]\n\t\t\t\tIf arraypart <> Null And idx < Int Ptr(arraypart)[-1] Then slot = Long Ptr(arraypart) + idx\n\t\t\tEndIf\n\t\tEndIf\n\t\tIf slot = Null\t'elsewise if hashcount < hashsize\n\t\t\tLocal hashpart:Byte Ptr = Byte Ptr Ptr(tbl)[2]\n\t\t\tIf hashpart <> Null\n\t\t\t\tLocal hsize:Int = 1 Shl Int Ptr(hashpart)[-1]\n\t\t\t\tIf Int Ptr(hashpart)[-2] < hsize\t'there's a slot free somewhere\n\t\t\t\t\t\n\t\t\t\t\tIf tag = BlueTypeTag.NANBOX | BlueTypeTag.STR\t'string - common case\n\t\t\t\t\t\tidx = Int Ptr(Int(key))[1]\n\t\t\t\t\tElseIf tag & BlueTypeTag.NANBOX_CHK <> BlueTypeTag.NANBOX\t'non-integer\n\t\t\t\t\t\tLocal d:Double ; Long Ptr(Varptr(d))[0] = key\n\t\t\t\t\t\td = frexp(d, Varptr(idx)) * ($7fffffff - 1024)\t'INT_MAX - DBL_MAX_EXP\n\t\t\t\t\t\tidx = Abs(idx) + Int(d)\n\t\t\t\t\tElse\t'pointer\n\t\t\t\t\t\tidx = Int(key) Shr 3\n\t\t\t\t\tEndIf\n\t\t\t\t\t\n\t\t\t\t\tidx = idx & (hsize - 1)\t'fastmod\n\t\t\t\t\tFor Local i:Int = idx Until hsize\n\t\t\t\t\t\tIf Long Ptr(hashpart)[2 * i] = key Then slot = Long Ptr(hashpart) + (2 * i + 1)\n\t\t\t\t\tNext\n\t\t\t\t\tFor Local i:Int = 0 Until idx\n\t\t\t\t\t\tIf Long Ptr(hashpart)[2 * i] = key Then slot = Long Ptr(hashpart) + (2 * i + 1)\n\t\t\t\t\tNext\n\t\t\t\t\t\n\t\t\t\tEndIf\n\t\t\tEndIf\n\t\tEndIf\n\t\t\n\t\tIf slot = Null\n\t\t\tResize(mem, tbl, key) ; Set Null, tbl, key, val\n\t\tElse\n\t\t\tmem.Write(slot, val)\n\t\tEndIf\n\tEnd Function\n\t\n\tFunction Resize(mem:BlueVMMemory, tbl:Byte Ptr, key:Long)\n\t\tLocal hashpart:Byte Ptr = Byte Ptr Ptr(tbl)[2], arraypart:Byte Ptr = Byte Ptr Ptr(tbl)[3]\n\t\tConst NILTAG:Int = BlueTypeTag.NANBOX | BlueTypeTag.NIL\n\t\t\n\t\tLocal asize:Int = 0, tsize:Int = 0, numcount:Int[32]\n\t\tIf arraypart\t'compute new array size\n\t\t\tIf Int Ptr(arraypart)[1] <> NILTAG Then numcount[0] = 1\n\t\t\tLocal cell:Int = 1, cellp2:Int = 2 ^ cell\n\t\t\tFor Local i:Int = 1 Until Int Ptr(arraypart)[-1]\n\t\t\t\tIf i >= cellp2 Then cell :+ 1 ; cellp2 = 2 ^ cell\n\t\t\t\tIf Int Ptr(arraypart)[i * 2 + 1] <> NILTAG Then numcount[cell] :+ 1\n\t\t\tNext\n\t\tEndIf\n\t\tIf hashpart\n\t\t\tFor Local i:Int = 0 Until Int Ptr(hashpart)[-2]\n\t\t\t\tLocal tag2:Int = Int Ptr(hashpart)[i * 4 + 1]\n\t\t\t\tIf tag2 & BlueTypeTag.NANBOX_CHK <> BlueTypeTag.NANBOX\n\t\t\t\t\tLocal d:Double = Double Ptr(hashpart)[i * 2]\n\t\t\t\t\tIf d = Abs Int(d) Then numcount[Ceil(Log(d + 1) \/ Log(2))] :+ 1 Else tsize :+ 1\n\t\t\t\tElse\n\t\t\t\t\ttsize :+ 1\t'get started on new table size\n\t\t\t\tEndIf\n\t\t\tNext\n\t\tEndIf\n\t\tLocal tag:Int = Int Ptr(Varptr(key))[1]\t'add key to the appropriate one\n\t\tIf tag & BlueTypeTag.NANBOX_CHK <> BlueTypeTag.NANBOX\n\t\t\tLocal d:Double = Double Ptr(Varptr(key))[0]\n\t\t\tIf d = Abs Int(d) Then numcount[Ceil(Log(d + 1) \/ Log(2))] :+ 1 Else tsize :+ 1\n\t\tElse\n\t\t\ttsize :+ 1\n\t\tEndIf\n\t\tFor Local i:Int = 0 Until 32\t'tally up\n\t\t\tIf i Then numcount[i] :+ numcount[i - 1]\n\t\t\tIf numcount[i] > 2 ^ i \/ 2 Then asize = 2 ^ i\n\t\tNext\n\t\t\n\t\tIf arraypart <> Null\t'complete new table size with any discarded array elements\n\t\t\tFor Local i:Int = asize Until Int Ptr(arraypart)[-1]\n\t\t\t\tIf Int Ptr(arraypart)[i * 2 + 1] <> NILTAG Then tsize :+ 1\n\t\t\tNext\n\t\tEndIf\n\t\t\n\t\tLocal newarray:Byte Ptr = Null, newtable:Byte Ptr = Null\t'allocate and copy\n\t\tIf asize\n\t\t\tnewarray = mem.AllocObject(asize * 8 + 8, BlueTypeTag.ARR) + 8\n\t\t\tFor Local i:Int = 0 Until asize\n\t\t\t\tInt Ptr(newarray)[i * 2 + 1] = NILTAG\n\t\t\tNext\n\t\t\tInt Ptr(newarray)[-1] = asize ; Byte Ptr Ptr(tbl)[3] = newarray\n\t\tElse\n\t\t\tInt Ptr(tbl)[3] = 0\n\t\tEndIf\n\t\tIf tsize\n\t\t\ttsize = 2 ^ tsize\n\t\t\tnewtable = mem.AllocObject(tsize * 16 + 8, BlueTypeTag.HASH)\n\t\t\tFor Local i:Int = 0 Until tsize * 2\n\t\t\t\tInt Ptr(newtable)[i * 2 + 1] = NILTAG\n\t\t\tNext\n\t\t\tInt Ptr(newtable)[-1] = tsize ; Byte Ptr Ptr(tbl)[2] = newtable\n\t\tElse\n\t\t\tInt Ptr(tbl)[2] = 0\n\t\tEndIf\n\t\t\n\t\tFor Local i:Int = 0 Until Int Ptr(arraypart)[-1]\t'reinsert values\n\t\t\tSet Null, tbl, Double(i),Long Ptr(arraypart)[i]\n\t\tNext\n\t\tFor Local i:Int = 0 Until Int Ptr(hashpart)[-1]\n\t\t\tSet Null, tbl, Long Ptr(hashpart)[i * 2], Long Ptr(hashpart)[i * 2 + 1]\t'Null used here as a sentinel (it should not be used again, so...)\n\t\tNext\n\tEnd Function\nEnd Type\n\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"56b576de28aedd51ecd821a9bafd663b569114f5","subject":"Changed default resolution to 640x480 to match the other targets (HTML5, Flash and GLFW)","message":"Changed default resolution to 640x480 to match the other targets (HTML5, Flash and GLFW)\n","repos":"swoolcock\/diddy,swoolcock\/diddy,swoolcock\/diddy,swoolcock\/diddy,swoolcock\/diddy","old_file":"monkeymax\/targets\/bmax\/MonkeyGame.bmx","new_file":"monkeymax\/targets\/bmax\/MonkeyGame.bmx","new_contents":"SuperStrict\r\n\r\nGlobal _errStack:TList = New TList;\r\nGlobal _errInfo:String=\"\";\r\n\r\nGraphics 640, 480\r\n\r\nbbInit();\r\nbbMain();\r\n\r\n'${TRANSCODE_BEGIN}\r\n'${TRANSCODE_END}\r\n","old_contents":"SuperStrict\r\n\r\nGlobal _errStack:TList = New TList;\r\nGlobal _errInfo:String=\"\";\r\n\r\nGraphics 800, 600\r\n\r\nbbInit();\r\nbbMain();\r\n\r\n'${TRANSCODE_BEGIN}\r\n'${TRANSCODE_END}\r\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"217abcc46cd1605f0f382fd3d76ca9153b436721","subject":"Fix for bmk check on Windows","message":"Fix for bmk check on Windows\n","repos":"maximos\/maximus","old_file":"maximus.bmx","new_file":"maximus.bmx","new_contents":"\nSuperStrict\n\nFramework brl.blitz\nImport brl.standardio\nImport brl.maxutil\nImport brl.ramstream\n\n' We have to import this for BMax 1.39 on Linux because of a dependency issue in brl.system\n' http:\/\/blitzbasic.com\/Community\/posts.php?topic=90547\n?Linux\nImport brl.glgraphics\n?\n\nImport bah.volumes\nImport gman.zipengine\nImport htbaapub.rest\n\nImport duct.variables\nImport duct.objectmap\nImport duct.json\nImport duct.locale\nImport duct.argparser\nImport duct.time\n\nIncbin \"locales\/en.loc\"\n\nInclude \"src\/logger.bmx\"\nInclude \"src\/errors.bmx\"\nInclude \"src\/config.bmx\"\nInclude \"src\/dependencies.bmx\"\nInclude \"src\/module.bmx\"\nInclude \"src\/sources.bmx\"\nInclude \"src\/utils.bmx\"\nInclude \"src\/arghandler.bmx\"\nInclude \"src\/impl\/help.bmx\"\nInclude \"src\/impl\/version.bmx\"\nInclude \"src\/impl\/modpath.bmx\"\nInclude \"src\/impl\/install.bmx\"\nInclude \"src\/impl\/update.bmx\"\nInclude \"src\/impl\/list.bmx\"\n\nGlobal logger:mxLogger = New mxLogger\nGlobal mainapp:mxApp\nNew mxApp.Create(AppArgs[1..]) ' Skip the first element because it is the program's location\nmainapp.Run()\n\nRem\n\tbbdoc: Maximus app.\n\tabout: This handles the basic flow of the program (initiation, parsing, command calling, exiting..)\nEnd Rem\nType mxApp\n\t\n\tConst c_version:String = \"0.01\"\n\tConst c_configfile:String = \"maximus.config\"\n\t\n\tField m_apppath:String\n\tField m_maxpath:String, m_binpath:String, m_modpath:String\n\t\n\tField m_confighandler:mxConfigHandler\n\tField m_defaultlocale:dLocale, m_locale:dLocale\n\tField m_sourcesfile:String = \"sources\", m_sourcesurl:String = \"http:\/\/maximus.htbaa.com\/module\/sources\/json\"\n\tField m_useragent:String\n\tField m_autoupdatesources:Int = True\n\t\n\tField m_args:dIdentifier\n\tField m_arghandler:mxArgumentHandler\n\tField m_sourceshandler:mxSourcesHandler\n\t\n\tField m_updateimpl:mxUpdateImpl\n\tField m_sourcesupdated:Int\n\t\n\tRem\n\t\tbbdoc: Create a new mxApp.\n\t\treturns: Itself.\n\tEnd Rem\n\tMethod Create:mxApp(args:String[])\n\t\tmainapp = Self\n\t\tSetArgs(args)\n\t\tOnInit()\n\t\tReturn Self\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Called when the application is created.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod OnInit()\n\t\tm_apppath = GetUserAppDir() + \"\/\"\n\t\t?Linux\n\t\tm_apppath:+ \".maximus\/\"\n\t\t?Not Linux\n\t\tm_apppath:+ \"maximus\/\"\n\t\t?\n\t\tIf FileType(m_apppath) = FILETYPE_NONE\n\t\t\tIf Not CreateDir(m_apppath, False)\n\t\t\t\tThrowError(_s(\"error.createperms\", [m_apppath]))\n\t\t\tEnd If\n\t\tEnd If\n\t\tChangeDir(m_apppath)\n\t\tm_confighandler = New mxConfigHandler.Create(m_apppath + c_configfile)\n\t\tm_confighandler.LoadDefaultLocale()\n\t\tm_confighandler.Load()\n\t\tIf Not m_maxpath\n\t\t\tTry\n\t\t\t\tSetMaxPath(BlitzMaxPath())\n\t\t\tCatch e:Object\n\t\t\t\tThrowError(_s(\"error.notfound.maxenv\"))\n\t\t\tEnd Try\n\t\tEnd If\n\t\tIf Not m_modpath Then SetModPath(m_maxpath + \"\/mod\", False)\n\t\tm_arghandler = New mxArgumentHandler\n\t\tm_arghandler.AddArgImpl(New mxHelpImpl)\n\t\tm_arghandler.AddArgImpl(New mxVersionImpl)\n\t\tm_arghandler.AddArgImpl(New mxModPathImpl)\n\t\tm_arghandler.AddArgImpl(New mxInstallImpl)\n\t\tm_updateimpl = New mxUpdateImpl\n\t\tm_arghandler.AddArgImpl(m_updateimpl)\n\t\tm_arghandler.AddArgImpl(New mxListImpl)\n\t\tUpdateSources()\n\t\tm_sourceshandler = New mxSourcesHandler.FromFile(m_apppath + m_sourcesfile)\n\t\tIf m_sourceshandler = Null\n\t\t\t' Don't throw an error here, the user may be updating the sources (an error will occur otherwise)\n\t\t\tlogger.LogWarning(_s(\"error.load.sources.file\", [m_apppath + m_sourcesfile]))\n\t\tEnd If\n\t\tLocal os:String\n\t\t?Win32\n\t\t\tos = \"Windows\"\n\t\t?Linux\n\t\t\tos = \"Linux\"\n\t\t?MacOS\n\t\t\tos = \"MacOS\"\n\t\t?\n\t\tm_useragent = \"Maximus\/\" + c_version + \" (\" + os + \"; \" + m_locale.GetName() + \")\"\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Called when the application is ended (this includes #ThrowError calls).\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod OnExit()\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Run the application.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod Run()\n\t\tLocal argimpl:mxArgumentImplementation, isopt:Int\n\t\tFor Local arg:dIdentifier = EachIn m_args.GetValues()\n\t\t\targimpl = m_arghandler.GetArgImplFromAlias(arg.GetName())\n\t\t\tisopt = (arg.GetName()[0] = 45)\n\t\t\tIf argimpl <> Null\n\t\t\t\tIf isopt = True\n\t\t\t\t\targimpl.SetCallConvention(mxCallConvention.OPTION)\n\t\t\t\t\targimpl.SetArgs(arg)\n\t\t\t\t\targimpl.CheckArgs()\n\t\t\t\t\targimpl.Execute()\n\t\t\t\tElse\n\t\t\t\t\targimpl.SetCallConvention(mxCallConvention.COMMAND)\n\t\t\t\t\targimpl.SetArgs(arg)\n\t\t\t\t\targimpl.CheckArgs()\n\t\t\t\t\targimpl.Execute()\n\t\t\t\t\tExit\n\t\t\t\tEnd If\n\t\t\tElse\n\t\t\t\tIf isopt = True\n\t\t\t\t\tThrowCommonError(mxOptErrors.UNKNOWN, arg.GetName())\n\t\t\t\tElse\n\t\t\t\t\tThrowCommonError(mxCmdErrors.UNKNOWN, arg.GetName())\n\t\t\t\tEnd If\n\t\t\tEnd If\n\t\tNext\n\t\tOnExit()\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Update the sources list.\n\t\treturns: Nothing.\n\t\tabout: Updates when: the sources file is greater than 23 hours old; the sources file does not exist.\n\tEnd Rem\n\tMethod UpdateSources()\n\t\tIf m_autoupdatesources And Not m_sourcesupdated\n\t\t\tLocal ctime:dTime, ftime:dTime\n\t\t\tctime = New dTime.CreateFromCurrent()\n\t\t\tftime = New dTime.CreateFromFile(m_apppath + m_sourcesfile)\n\t\t\t'DebugLog(\"Auto-update file time: c\" + ctime.Get() + \" | \" + ftime.Get() + \", hours: \" + (ctime.Get() - ftime.Get()) \/ 3600)\n\t\t\tIf Not ftime Or (ctime.Get() - ftime.Get()) \/ 3600 > 23\n\t\t\t\tlogger.LogMessage(_s(\"arg.update.autoupdate\"))\n\t\t\t\tm_updateimpl.SetCallConvention(mxCallConvention.COMMAND)\n\t\t\t\tm_updateimpl.SetArgs(New dIdentifier.Create())\n\t\t\t\tm_updateimpl.CheckArgs()\n\t\t\t\tm_updateimpl.Execute()\n\t\t\tEnd If\n\t\tEnd If\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the application's arguments.\n\t\treturns: Nothing.\n\t\tabout: NOTE: This will resolve to '--help' if the given args are Null.\n\tEnd Rem\n\tMethod SetArgs(args:String[])\n\t\tIf args = Null\n\t\t\targs = [\"--help\"]\n\t\tEnd If\n\t\tm_args = dArgParser.ParseArray(args, False, 1)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the module path.\n\t\treturns: Nothing.\n\t\tabout: This will throw an error if the module path could not be found.\n\tEnd Rem\n\tMethod SetModPath(modpath:String, logchange:Int = True)\n\t\tm_modpath = FixPathEnding(modpath, True)\n\t\tIf FileType(m_modpath) = FILETYPE_DIR\n\t\t\tIf logchange = True Then logger.LogMessage(_s(\"message.setmodpath\", [m_modpath]))\n\t\tElse\n\t\t\tThrowError(_s(\"error.notfound.modpath\", [m_modpath]))\n\t\tEnd If\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the path to the BlitzMax installation.\n\t\treturns: Nothing.\n\t\tabout: This will throw an error if the path could not be found.\n\tEnd Rem\n\tMethod SetMaxPath(maxpath:String)\n\t\tm_maxpath = FixPathEnding(maxpath, True)\n\t\tm_binpath = m_maxpath + \"\/bin\"\n\t\tLocal bmk:String\n\t\t?Win32\n\t\t\tbmk = \"\/bmk.exe\"\n\t\t?Not Win32\n\t\t\tbmk = \"\/bmk\"\n\t\t?\n\t\tIf FileType(m_maxpath) = FILETYPE_NONE\n\t\t\tThrowError(_s(\"error.notfound.maxpath\", [m_maxpath]))\n\t\tElse If FileType(m_binpath + bmk) = FILETYPE_NONE\n\t\t\tThrowError(_s(\"error.notfound.bmk\", [m_binpath + bmk]))\n\t\tEnd If\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the sources url.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetSourcesUrl(url:String)\n\t\tm_sourcesurl = url\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the sources file.\n\t\treturns: Nothing.\n\t\tabout: NOTE: This will throw an error if the path is Null (and, later, a warning will be logged if the path does not exist).\n\tEnd Rem\n\tMethod SetSourcesFile(file:String)\n\t\tIf file = Null\n\t\t\tThrowError(_s(\"error.sources.setfile\"))\n\t\tEnd If\n\t\tm_sourcesfile = file\n\tEnd Method\n\t\nEnd Type\n\nRem\n\tbbdoc: Throw an error (terminating the application).\n\treturns: Nothing.\nEnd Rem\nFunction ThrowError(error:String)\n\tlogger.LogError(error)\n\tmainapp.OnExit()\n\tEnd\nEnd Function\n\nRem\n\tbbdoc: Get the localized text for the given identifier.\n\treturns: The translated text.\nEnd Rem\nFunction _s:String(iden:String, extra:String[] = Null)\n\tGlobal replacer:TTextReplacer = New TTextReplacer\n\tLocal ltext:dLocalizedText\n\tIf mainapp.m_locale <> Null Then ltext = mainapp.m_locale.TextFromStructureL(iden)\n\tIf ltext = Null Then ltext = mainapp.m_defaultlocale.TextFromStructureL(iden)\n\tIf ltext <> Null\n\t\treplacer.SetString(ltext.GetValue())\n\t\treplacer.AutoReplacements(\"{\", \"}\")\n\t\tIf extra <> Null\n\t\t\tLocal i:Int\n\t\t\tFor Local rep:TTextReplacement = EachIn replacer.GetList()\n\t\t\t\tIf i > extra.Length Then Exit\n\t\t\t\trep.SetReplacement(extra[i])\n\t\t\t\ti:+ 1\n\t\t\tNext\n\t\tEnd If\n\t\tReturn replacer.DoReplacements()\n\tElse\n\t\tDebugLog(\"Failed to find localized text from structure: ~q\" + iden + \"~q\")\n\tEnd If\nEnd Function\n\n","old_contents":"\nSuperStrict\n\nFramework brl.blitz\nImport brl.standardio\nImport brl.maxutil\nImport brl.ramstream\n\n' We have to import this for BMax 1.39 on Linux because of a dependency issue in brl.system\n' http:\/\/blitzbasic.com\/Community\/posts.php?topic=90547\n?Linux\nImport brl.glgraphics\n?\n\nImport bah.volumes\nImport gman.zipengine\nImport htbaapub.rest\n\nImport duct.variables\nImport duct.objectmap\nImport duct.json\nImport duct.locale\nImport duct.argparser\nImport duct.time\n\nIncbin \"locales\/en.loc\"\n\nInclude \"src\/logger.bmx\"\nInclude \"src\/errors.bmx\"\nInclude \"src\/config.bmx\"\nInclude \"src\/dependencies.bmx\"\nInclude \"src\/module.bmx\"\nInclude \"src\/sources.bmx\"\nInclude \"src\/utils.bmx\"\nInclude \"src\/arghandler.bmx\"\nInclude \"src\/impl\/help.bmx\"\nInclude \"src\/impl\/version.bmx\"\nInclude \"src\/impl\/modpath.bmx\"\nInclude \"src\/impl\/install.bmx\"\nInclude \"src\/impl\/update.bmx\"\nInclude \"src\/impl\/list.bmx\"\n\nGlobal logger:mxLogger = New mxLogger\nGlobal mainapp:mxApp\nNew mxApp.Create(AppArgs[1..]) ' Skip the first element because it is the program's location\nmainapp.Run()\n\nRem\n\tbbdoc: Maximus app.\n\tabout: This handles the basic flow of the program (initiation, parsing, command calling, exiting..)\nEnd Rem\nType mxApp\n\t\n\tConst c_version:String = \"0.01\"\n\tConst c_configfile:String = \"maximus.config\"\n\t\n\tField m_apppath:String\n\tField m_maxpath:String, m_binpath:String, m_modpath:String\n\t\n\tField m_confighandler:mxConfigHandler\n\tField m_defaultlocale:dLocale, m_locale:dLocale\n\tField m_sourcesfile:String = \"sources\", m_sourcesurl:String = \"http:\/\/maximus.htbaa.com\/module\/sources\/json\"\n\tField m_useragent:String\n\tField m_autoupdatesources:Int = True\n\t\n\tField m_args:dIdentifier\n\tField m_arghandler:mxArgumentHandler\n\tField m_sourceshandler:mxSourcesHandler\n\t\n\tField m_updateimpl:mxUpdateImpl\n\tField m_sourcesupdated:Int\n\t\n\tRem\n\t\tbbdoc: Create a new mxApp.\n\t\treturns: Itself.\n\tEnd Rem\n\tMethod Create:mxApp(args:String[])\n\t\tmainapp = Self\n\t\tSetArgs(args)\n\t\tOnInit()\n\t\tReturn Self\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Called when the application is created.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod OnInit()\n\t\tm_apppath = GetUserAppDir() + \"\/\"\n\t\t?Linux\n\t\tm_apppath:+ \".maximus\/\"\n\t\t?Not Linux\n\t\tm_apppath:+ \"maximus\/\"\n\t\t?\n\t\tIf FileType(m_apppath) = FILETYPE_NONE\n\t\t\tIf Not CreateDir(m_apppath, False)\n\t\t\t\tThrowError(_s(\"error.createperms\", [m_apppath]))\n\t\t\tEnd If\n\t\tEnd If\n\t\tChangeDir(m_apppath)\n\t\tm_confighandler = New mxConfigHandler.Create(m_apppath + c_configfile)\n\t\tm_confighandler.LoadDefaultLocale()\n\t\tm_confighandler.Load()\n\t\tIf Not m_maxpath\n\t\t\tTry\n\t\t\t\tSetMaxPath(BlitzMaxPath())\n\t\t\tCatch e:Object\n\t\t\t\tThrowError(_s(\"error.notfound.maxenv\"))\n\t\t\tEnd Try\n\t\tEnd If\n\t\tIf Not m_modpath Then SetModPath(m_maxpath + \"\/mod\", False)\n\t\tm_arghandler = New mxArgumentHandler\n\t\tm_arghandler.AddArgImpl(New mxHelpImpl)\n\t\tm_arghandler.AddArgImpl(New mxVersionImpl)\n\t\tm_arghandler.AddArgImpl(New mxModPathImpl)\n\t\tm_arghandler.AddArgImpl(New mxInstallImpl)\n\t\tm_updateimpl = New mxUpdateImpl\n\t\tm_arghandler.AddArgImpl(m_updateimpl)\n\t\tm_arghandler.AddArgImpl(New mxListImpl)\n\t\tUpdateSources()\n\t\tm_sourceshandler = New mxSourcesHandler.FromFile(m_apppath + m_sourcesfile)\n\t\tIf m_sourceshandler = Null\n\t\t\t' Don't throw an error here, the user may be updating the sources (an error will occur otherwise)\n\t\t\tlogger.LogWarning(_s(\"error.load.sources.file\", [m_apppath + m_sourcesfile]))\n\t\tEnd If\n\t\tLocal os:String\n\t\t?Win32\n\t\t\tos = \"Windows\"\n\t\t?Linux\n\t\t\tos = \"Linux\"\n\t\t?MacOS\n\t\t\tos = \"MacOS\"\n\t\t?\n\t\tm_useragent = \"Maximus\/\" + c_version + \" (\" + os + \"; \" + m_locale.GetName() + \")\"\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Called when the application is ended (this includes #ThrowError calls).\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod OnExit()\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Run the application.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod Run()\n\t\tLocal argimpl:mxArgumentImplementation, isopt:Int\n\t\tFor Local arg:dIdentifier = EachIn m_args.GetValues()\n\t\t\targimpl = m_arghandler.GetArgImplFromAlias(arg.GetName())\n\t\t\tisopt = (arg.GetName()[0] = 45)\n\t\t\tIf argimpl <> Null\n\t\t\t\tIf isopt = True\n\t\t\t\t\targimpl.SetCallConvention(mxCallConvention.OPTION)\n\t\t\t\t\targimpl.SetArgs(arg)\n\t\t\t\t\targimpl.CheckArgs()\n\t\t\t\t\targimpl.Execute()\n\t\t\t\tElse\n\t\t\t\t\targimpl.SetCallConvention(mxCallConvention.COMMAND)\n\t\t\t\t\targimpl.SetArgs(arg)\n\t\t\t\t\targimpl.CheckArgs()\n\t\t\t\t\targimpl.Execute()\n\t\t\t\t\tExit\n\t\t\t\tEnd If\n\t\t\tElse\n\t\t\t\tIf isopt = True\n\t\t\t\t\tThrowCommonError(mxOptErrors.UNKNOWN, arg.GetName())\n\t\t\t\tElse\n\t\t\t\t\tThrowCommonError(mxCmdErrors.UNKNOWN, arg.GetName())\n\t\t\t\tEnd If\n\t\t\tEnd If\n\t\tNext\n\t\tOnExit()\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Update the sources list.\n\t\treturns: Nothing.\n\t\tabout: Updates when: the sources file is greater than 23 hours old; the sources file does not exist.\n\tEnd Rem\n\tMethod UpdateSources()\n\t\tIf m_autoupdatesources And Not m_sourcesupdated\n\t\t\tLocal ctime:dTime, ftime:dTime\n\t\t\tctime = New dTime.CreateFromCurrent()\n\t\t\tftime = New dTime.CreateFromFile(m_apppath + m_sourcesfile)\n\t\t\t'DebugLog(\"Auto-update file time: c\" + ctime.Get() + \" | \" + ftime.Get() + \", hours: \" + (ctime.Get() - ftime.Get()) \/ 3600)\n\t\t\tIf Not ftime Or (ctime.Get() - ftime.Get()) \/ 3600 > 23\n\t\t\t\tlogger.LogMessage(_s(\"arg.update.autoupdate\"))\n\t\t\t\tm_updateimpl.SetCallConvention(mxCallConvention.COMMAND)\n\t\t\t\tm_updateimpl.SetArgs(New dIdentifier.Create())\n\t\t\t\tm_updateimpl.CheckArgs()\n\t\t\t\tm_updateimpl.Execute()\n\t\t\tEnd If\n\t\tEnd If\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the application's arguments.\n\t\treturns: Nothing.\n\t\tabout: NOTE: This will resolve to '--help' if the given args are Null.\n\tEnd Rem\n\tMethod SetArgs(args:String[])\n\t\tIf args = Null\n\t\t\targs = [\"--help\"]\n\t\tEnd If\n\t\tm_args = dArgParser.ParseArray(args, False, 1)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the module path.\n\t\treturns: Nothing.\n\t\tabout: This will throw an error if the module path could not be found.\n\tEnd Rem\n\tMethod SetModPath(modpath:String, logchange:Int = True)\n\t\tm_modpath = FixPathEnding(modpath, True)\n\t\tIf FileType(m_modpath) = FILETYPE_DIR\n\t\t\tIf logchange = True Then logger.LogMessage(_s(\"message.setmodpath\", [m_modpath]))\n\t\tElse\n\t\t\tThrowError(_s(\"error.notfound.modpath\", [m_modpath]))\n\t\tEnd If\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the path to the BlitzMax installation.\n\t\treturns: Nothing.\n\t\tabout: This will throw an error if the path could not be found.\n\tEnd Rem\n\tMethod SetMaxPath(maxpath:String)\n\t\tm_maxpath = FixPathEnding(maxpath, True)\n\t\tm_binpath = m_maxpath + \"\/bin\"\n\t\tIf FileType(m_maxpath) = FILETYPE_NONE\n\t\t\tThrowError(_s(\"error.notfound.maxpath\", [m_maxpath]))\n\t\tElse If FileType(m_binpath + \"\/bmk\") = FILETYPE_NONE\n\t\t\tThrowError(_s(\"error.notfound.bmk\", [m_binpath + \"\/bmk\"]))\n\t\tEnd If\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the sources url.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetSourcesUrl(url:String)\n\t\tm_sourcesurl = url\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the sources file.\n\t\treturns: Nothing.\n\t\tabout: NOTE: This will throw an error if the path is Null (and, later, a warning will be logged if the path does not exist).\n\tEnd Rem\n\tMethod SetSourcesFile(file:String)\n\t\tIf file = Null\n\t\t\tThrowError(_s(\"error.sources.setfile\"))\n\t\tEnd If\n\t\tm_sourcesfile = file\n\tEnd Method\n\t\nEnd Type\n\nRem\n\tbbdoc: Throw an error (terminating the application).\n\treturns: Nothing.\nEnd Rem\nFunction ThrowError(error:String)\n\tlogger.LogError(error)\n\tmainapp.OnExit()\n\tEnd\nEnd Function\n\nRem\n\tbbdoc: Get the localized text for the given identifier.\n\treturns: The translated text.\nEnd Rem\nFunction _s:String(iden:String, extra:String[] = Null)\n\tGlobal replacer:TTextReplacer = New TTextReplacer\n\tLocal ltext:dLocalizedText\n\tIf mainapp.m_locale <> Null Then ltext = mainapp.m_locale.TextFromStructureL(iden)\n\tIf ltext = Null Then ltext = mainapp.m_defaultlocale.TextFromStructureL(iden)\n\tIf ltext <> Null\n\t\treplacer.SetString(ltext.GetValue())\n\t\treplacer.AutoReplacements(\"{\", \"}\")\n\t\tIf extra <> Null\n\t\t\tLocal i:Int\n\t\t\tFor Local rep:TTextReplacement = EachIn replacer.GetList()\n\t\t\t\tIf i > extra.Length Then Exit\n\t\t\t\trep.SetReplacement(extra[i])\n\t\t\t\ti:+ 1\n\t\t\tNext\n\t\tEnd If\n\t\tReturn replacer.DoReplacements()\n\tElse\n\t\tDebugLog(\"Failed to find localized text from structure: ~q\" + iden + \"~q\")\n\tEnd If\nEnd Function\n\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"e40fd772aabfdf532f9956c86c68ac955b9ef6a4","subject":"Version 0.04","message":"Version 0.04\n","repos":"Htbaa\/zmq.mod,Htbaa\/zmq.mod","old_file":"zmq.bmx","new_file":"zmq.bmx","new_contents":"Rem\n\tCopyright (c) 2012 Christiaan Kras\n\t\n\tPermission is hereby granted, free of charge, to any person obtaining a copy\n\tof this software and associated documentation files (the \"Software\"), to deal\n\tin the Software without restriction, including without limitation the rights\n\tto use, copy, modify, merge, publish, distribute, sublicense, and\/or sell\n\tcopies of the Software, and to permit persons to whom the Software is\n\tfurnished to do so, subject to the following conditions:\n\t\n\tThe above copyright notice and this permission notice shall be included in\n\tall copies or substantial portions of the Software.\n\t\n\tTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n\tIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n\tFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n\tAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n\tLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n\tOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n\tTHE SOFTWARE.\nEnd Rem\n\nSuperStrict\n\nRem\n\tbbdoc: htbaapub.zmq\n\tabout: This module is still an early work in progress. If you run into any\n\tbugs please report them at https:\/\/github.com\/Htbaa\/zmq.mod\/issues<\/a>.\nEndRem\nModule htbaapub.zmq\nModuleInfo \"Name: htbaapub.zmq\"\nModuleInfo \"Description: A wrapper for ZeroMQ\"\nModuleInfo \"Version: 0.04\"\nModuleInfo \"License: MIT\"\nModuleInfo \"Author: Christiaan Kras\"\nModuleInfo \"ZeroMQ: http:\/\/www.zeromq.org<\/a>\"\nModuleInfo \"ZeroMQ License: LGPL (see contents of .\/zeromq)\"\nModuleInfo \"Git repository: https:\/\/github.com\/Htbaa\/zmq.mod\/<\/a>\"\nModuleInfo \"Issues: https:\/\/github.com\/Htbaa\/zmq.mod\/issues<\/a>\"\nModuleInfo \"ZeroMQ Windows binaries: http:\/\/www.zeromq.org\/distro:microsoft-windows<\/a>\"\nModuleInfo \"History: 0.04\"\nModuleInfo \"History: Updated to ZMQ 2.2.0\"\nModuleInfo \"History: Updated example1 to reflect API changes\"\nModuleInfo \"History: Improved test coverage\"\nModuleInfo \"History: 0.03\"\nModuleInfo \"History: Fixed message data corruption for first sent message (gh-3)\"\nModuleInfo \"History: Added TZMQ_Message.CreateFromString to create messages from a String. The TZMQ_Message.Create signature has also changed to accept a Byte Ptr and a length\"\nModuleInfo \"History: Fixed potential memory leak in TZMQ_Socket.Send when an exception would be raised\"\nModuleInfo \"History: Added TZMQ_Socket_Exception and TZMQ_Message_Exception\"\nModuleInfo \"History: Added a couple of unit tests (bah.maxunit required)\"\nModuleInfo \"History: 0.02\"\nModuleInfo \"History: Added more examples; Hello World server and client\"\nModuleInfo \"History: Added more examples; Weather Update server and client\"\nModuleInfo \"History: TZMQ_Socket.SetSockOpt() now properly sets options\"\nModuleInfo \"History: TZMQ_Message.Close() now properly frees up memory\"\nModuleInfo \"History: 0.01\"\nModuleInfo \"History: First release of htbaapub.zmq using ZMQ 2.1.11. No support yet for input\/output multiplexing with zmq_poll()\"\n\n?Linux\n\tImport \"-lzmq\"\n?Win32\n\tImport \"zeromq\/lib\/libzmq-v100-mt.lib\"\n?\n\nImport \"glue.c\"\nInclude \"exception.bmx\"\nInclude \"constants.bmx\"\nInclude \"context.bmx\"\nInclude \"socket.bmx\"\nInclude \"message.bmx\"\n\n'Glue\/Helper functions\nExtern \"C\"\n\n\tRem\n\t\tbbdoc: Create an empty zmq_message_t struct\n\t\treturns: Returns a pointer to a new zmq_message_t struct\n\tEnd Rem\n\tFunction bmx_zmq_message_t:Byte Ptr()\n\n\tRem\n\t\tbbdoc: Create a zmq_message_t struct with preset data\n\t\treturns: Returns a pointer to a new zmq_message_t struct with given data\n\tEnd Rem\n\tFunction bmx_zmq_new_message:Byte Ptr(str$z)\n\t\n\tRem\n\t\tbbdoc: Alias for free(), for cleaning up data structures\n\tEnd Rem\n\tFunction bmx_zmq_free(msg:Byte Ptr)\nEnd Extern\n\n'ZeroMQ functions\nExtern\n\tFunction zmq_version(major:Int Var, minor:Int Var, patch:Int Var)\n\n\tFunction zmq_init:Byte Ptr(io_threads:Int)\n\tFunction zmq_term:Int(context:Byte Ptr)\n\t\n\tFunction zmq_errno:Int()\n\tFunction zmq_strerror$z(errnum:Int)\n\t\n\tFunction zmq_socket:Byte Ptr(context:Byte Ptr, socket_type:Int)\n\tFunction zmq_close:Int(s:Byte Ptr)\n\tFunction zmq_setsockopt:Int(s:Byte Ptr, option:Int, optval$z, length:Int)\n\tFunction zmq_getsockopt:Int(s:Byte Ptr, option:Int, optval:Byte Ptr, length:Int Var)\n\t'ZMQ_EXPORT Int zmq_getsockopt (void *s, Int option, void *optval, size_t *optvallen);\n\tFunction zmq_bind(s:Byte Ptr, addr$z)\n\tFunction zmq_connect:Int(s:Byte Ptr, addr$z)\n\tFunction zmq_send:Int(s:Byte Ptr, msg:Byte Ptr, flags:Int)\n\tFunction zmq_recv:Int(s:Byte Ptr, msg:Byte Ptr, flags:Int)\n\n\tFunction zmq_msg_init:Int(msg:Byte Ptr)\n\tFunction zmq_msg_init_size:Int(msg:Byte Ptr, size:Long)\n\tFunction zmq_msg_init_data:Int(msg:Byte Ptr, data:Byte Ptr, size:Long, ffn:Byte Ptr, hint:Byte Ptr)\n\tFunction zmq_msg_close:Int(msg:Byte Ptr)\n\tFunction zmq_msg_move:Int(dest:Byte Ptr, src:Byte Ptr)\n\tFunction zmq_msg_copy:Int(dest:Byte Ptr, src:Byte Ptr)\n\tFunction zmq_msg_data:Byte Ptr(msg:Byte Ptr)\n\tFunction zmq_msg_size:Int(msg:Byte Ptr)\n\t\n\tFunction zmq_poll:Int(items:Byte Ptr, nitems:Int, timeout:Long)\n\t\n\tFunction zmq_device:Int(device:Int, insocket:Byte Ptr, outsocket:Byte Ptr)\nEnd Extern\n\nRem\n\tbbdoc: General ZMQ functions\nEnd Rem\nType TZMQ\n\n\tRem\n\t\tbbdoc: Get ZMQ Version\n\t\treturns: String\n\tEnd Rem\n\tFunction Version:String()\n\t\tLocal major:Int, minor:Int, patch:Int\n\t\tzmq_version(major, minor, patch)\n\t\tReturn major + \".\" + minor + \".\" + patch\n\tEnd Function\n\n\tRem\n\t\tbbdoc: Get current ZMQ error descriptions\n\t\treturns: String\n\tEnd Rem\n\tFunction Error:String()\n\t\tReturn zmq_strerror( TZMQ.ErrorNumber() )\n\tEnd Function\n\n\tRem\n\t\tbbdoc: Get current ZMQ error number\n\t\treturns: Int\n\tEnd Rem\n\tFunction ErrorNumber:Int()\n\t\tReturn zmq_errno()\n\tEnd Function\nEnd Type","old_contents":"Rem\n\tCopyright (c) 2012 Christiaan Kras\n\t\n\tPermission is hereby granted, free of charge, to any person obtaining a copy\n\tof this software and associated documentation files (the \"Software\"), to deal\n\tin the Software without restriction, including without limitation the rights\n\tto use, copy, modify, merge, publish, distribute, sublicense, and\/or sell\n\tcopies of the Software, and to permit persons to whom the Software is\n\tfurnished to do so, subject to the following conditions:\n\t\n\tThe above copyright notice and this permission notice shall be included in\n\tall copies or substantial portions of the Software.\n\t\n\tTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n\tIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n\tFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n\tAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n\tLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n\tOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n\tTHE SOFTWARE.\nEnd Rem\n\nSuperStrict\n\nRem\n\tbbdoc: htbaapub.zmq\n\tabout: This module is still an early work in progress. If you run into any\n\tbugs please report them at https:\/\/github.com\/Htbaa\/zmq.mod\/issues<\/a>.\nEndRem\nModule htbaapub.zmq\nModuleInfo \"Name: htbaapub.zmq\"\nModuleInfo \"Description: A wrapper for ZeroMQ\"\nModuleInfo \"Version: 0.03\"\nModuleInfo \"License: MIT\"\nModuleInfo \"Author: Christiaan Kras\"\nModuleInfo \"ZeroMQ: http:\/\/www.zeromq.org<\/a>\"\nModuleInfo \"ZeroMQ License: LGPL (see contents of .\/zeromq)\"\nModuleInfo \"Git repository: https:\/\/github.com\/Htbaa\/zmq.mod\/<\/a>\"\nModuleInfo \"Issues: https:\/\/github.com\/Htbaa\/zmq.mod\/issues<\/a>\"\nModuleInfo \"ZeroMQ Windows binaries: http:\/\/www.zeromq.org\/distro:microsoft-windows<\/a>\"\nModuleInfo \"History: Updated to ZMQ 2.2.0\"\nModuleInfo \"History: Updated example1 to reflect API changes\"\nModuleInfo \"History: Improved test coverage\"\nModuleInfo \"History: 0.03\"\nModuleInfo \"History: Fixed message data corruption for first sent message (gh-3)\"\nModuleInfo \"History: Added TZMQ_Message.CreateFromString to create messages from a String. The TZMQ_Message.Create signature has also changed to accept a Byte Ptr and a length\"\nModuleInfo \"History: Fixed potential memory leak in TZMQ_Socket.Send when an exception would be raised\"\nModuleInfo \"History: Added TZMQ_Socket_Exception and TZMQ_Message_Exception\"\nModuleInfo \"History: Added a couple of unit tests (bah.maxunit required)\"\nModuleInfo \"History: 0.02\"\nModuleInfo \"History: Added more examples; Hello World server and client\"\nModuleInfo \"History: Added more examples; Weather Update server and client\"\nModuleInfo \"History: TZMQ_Socket.SetSockOpt() now properly sets options\"\nModuleInfo \"History: TZMQ_Message.Close() now properly frees up memory\"\nModuleInfo \"History: 0.01\"\nModuleInfo \"History: First release of htbaapub.zmq using ZMQ 2.1.11. No support yet for input\/output multiplexing with zmq_poll()\"\n\n?Linux\n\tImport \"-lzmq\"\n?Win32\n\tImport \"zeromq\/lib\/libzmq-v100-mt.lib\"\n?\n\nImport \"glue.c\"\nInclude \"exception.bmx\"\nInclude \"constants.bmx\"\nInclude \"context.bmx\"\nInclude \"socket.bmx\"\nInclude \"message.bmx\"\n\n'Glue\/Helper functions\nExtern \"C\"\n\n\tRem\n\t\tbbdoc: Create an empty zmq_message_t struct\n\t\treturns: Returns a pointer to a new zmq_message_t struct\n\tEnd Rem\n\tFunction bmx_zmq_message_t:Byte Ptr()\n\n\tRem\n\t\tbbdoc: Create a zmq_message_t struct with preset data\n\t\treturns: Returns a pointer to a new zmq_message_t struct with given data\n\tEnd Rem\n\tFunction bmx_zmq_new_message:Byte Ptr(str$z)\n\t\n\tRem\n\t\tbbdoc: Alias for free(), for cleaning up data structures\n\tEnd Rem\n\tFunction bmx_zmq_free(msg:Byte Ptr)\nEnd Extern\n\n'ZeroMQ functions\nExtern\n\tFunction zmq_version(major:Int Var, minor:Int Var, patch:Int Var)\n\n\tFunction zmq_init:Byte Ptr(io_threads:Int)\n\tFunction zmq_term:Int(context:Byte Ptr)\n\t\n\tFunction zmq_errno:Int()\n\tFunction zmq_strerror$z(errnum:Int)\n\t\n\tFunction zmq_socket:Byte Ptr(context:Byte Ptr, socket_type:Int)\n\tFunction zmq_close:Int(s:Byte Ptr)\n\tFunction zmq_setsockopt:Int(s:Byte Ptr, option:Int, optval$z, length:Int)\n\tFunction zmq_getsockopt:Int(s:Byte Ptr, option:Int, optval:Byte Ptr, length:Int Var)\n\t'ZMQ_EXPORT Int zmq_getsockopt (void *s, Int option, void *optval, size_t *optvallen);\n\tFunction zmq_bind(s:Byte Ptr, addr$z)\n\tFunction zmq_connect:Int(s:Byte Ptr, addr$z)\n\tFunction zmq_send:Int(s:Byte Ptr, msg:Byte Ptr, flags:Int)\n\tFunction zmq_recv:Int(s:Byte Ptr, msg:Byte Ptr, flags:Int)\n\n\tFunction zmq_msg_init:Int(msg:Byte Ptr)\n\tFunction zmq_msg_init_size:Int(msg:Byte Ptr, size:Long)\n\tFunction zmq_msg_init_data:Int(msg:Byte Ptr, data:Byte Ptr, size:Long, ffn:Byte Ptr, hint:Byte Ptr)\n\tFunction zmq_msg_close:Int(msg:Byte Ptr)\n\tFunction zmq_msg_move:Int(dest:Byte Ptr, src:Byte Ptr)\n\tFunction zmq_msg_copy:Int(dest:Byte Ptr, src:Byte Ptr)\n\tFunction zmq_msg_data:Byte Ptr(msg:Byte Ptr)\n\tFunction zmq_msg_size:Int(msg:Byte Ptr)\n\t\n\tFunction zmq_poll:Int(items:Byte Ptr, nitems:Int, timeout:Long)\n\t\n\tFunction zmq_device:Int(device:Int, insocket:Byte Ptr, outsocket:Byte Ptr)\nEnd Extern\n\nRem\n\tbbdoc: General ZMQ functions\nEnd Rem\nType TZMQ\n\n\tRem\n\t\tbbdoc: Get ZMQ Version\n\t\treturns: String\n\tEnd Rem\n\tFunction Version:String()\n\t\tLocal major:Int, minor:Int, patch:Int\n\t\tzmq_version(major, minor, patch)\n\t\tReturn major + \".\" + minor + \".\" + patch\n\tEnd Function\n\n\tRem\n\t\tbbdoc: Get current ZMQ error descriptions\n\t\treturns: String\n\tEnd Rem\n\tFunction Error:String()\n\t\tReturn zmq_strerror( TZMQ.ErrorNumber() )\n\tEnd Function\n\n\tRem\n\t\tbbdoc: Get current ZMQ error number\n\t\treturns: Int\n\tEnd Rem\n\tFunction ErrorNumber:Int()\n\t\tReturn zmq_errno()\n\tEnd Function\nEnd Type","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"2daafd7d3df4194d14a48df99a911c5475ed58bc","subject":"b3dloader now can load from TBB3DChunk","message":"b3dloader now can load from TBB3DChunk\n","repos":"kfprimm\/maxb3d,kfprimm\/maxb3d","old_file":"b3dloader.mod\/b3dloader.bmx","new_file":"b3dloader.mod\/b3dloader.bmx","new_contents":"\nStrict\n\nRem\n\tbbdoc: Blitz3D model loader for MaxB3D\nEnd Rem\nModule MaxB3D.B3DLoader\nModuleInfo \"Author: Kevin Primm\"\nModuleInfo \"License: MIT\"\n\nImport MaxB3D.Core\nImport MaxB3D.BoneAnimator\nImport Prime.libB3D\n\nType TMeshLoaderB3D Extends TMeshLoader\n\tField _mesh:TMesh\n\t\n\tMethod Run(mesh:TMesh,stream:TStream,url:Object)\n\t\tLocal model:TBB3DChunk = TBB3DChunk(url)\t\t\n\t\tIf model=Null model = TBB3DChunk.Load(stream)\n\t\tIf model=Null Return False\t\n\t\t\n\t\tLocal olddir$=CurrentDir()\n\t\tIf String(url) ChangeDir(ExtractDir(String(url)))\n\t\t\n\t\tLocal texture:TTexture[model.texs.length]\n\t\tLocal brush:TBrush[model.brus.length]\n\t\t\n\t\tFor Local i=0 To texture.length-1\n\t\t\tLocal chunk:TTEXSChunk=model.texs[i]\t\t\t\n\t\t\ttexture[i]=_currentworld.AddTexture(chunk.file,chunk.flags)\n\t\t\tIf texture[i]\n\t\t\t\ttexture[i].SetBlend chunk.blend\n\t\t\t\ttexture[i].SetPosition chunk.x_pos,chunk.y_pos\n\t\t\t\ttexture[i].SetScale chunk.x_scale,chunk.y_scale\n\t\t\t\ttexture[i].SetRotation chunk.rotation*(180.0\/Pi)\n\t\t\t\tIf chunk.flags&65536 texture[i].SetCoords 1\n\t\t\tEndIf\n\t\tNext\n\t\t\n\t\tFor Local i=0 To brush.length-1\n\t\t\tLocal chunk:TBRUSChunk=model.brus[i]\n\t\t\tbrush[i]=_currentworld.AddBrush()\n\t\t\tbrush[i].SetName chunk.name\n\t\t\tbrush[i].SetColor chunk.red*255,chunk.green*255,chunk.blue*255;brush[i].SetAlpha chunk.alpha\n\t\t\tbrush[i].SetShine chunk.shininess\n\t\t\tbrush[i].SetBlend chunk.blend;brush[i].SetFX chunk.fx\n\t\t\tFor Local j=0 To chunk.n_texs-1\n\t\t\t\tIf chunk.texture_id[j]>-1 brush[i].SetTexture texture[chunk.texture_id[j]],j\n\t\t\tNext\n\t\tNext\t\t\n\t\tChangeDir olddir\n\t\t\n\t\t' model.dump StandardIOStream\n\t\t \n\t\tIf model.node\n\t\t\tParseNode model.node,mesh,brush,mesh\n\t\t\tReturn True\n\t\tEndIf\n\t\tReturn False\n\tEnd Method\n\t\n\tMethod ParseNode(node:TNODEChunk,parent:TEntity,brush:TBrush[],entity:TEntity=Null)\n\t\tLocal meshchunk:TMESHChunk=TMESHChunk(node.kind),bonechunk:TBONEChunk=TBONEChunk(node.kind)\n\t\t\t\t\n\t\tSelect node.kind\n\t\tCase Null\n\t\t\tentity=_currentworld.AddPivot(parent)\n\t\tCase meshchunk\t\t\t\n\t\t\tIf entity=Null entity=_currentworld.AddMesh(\"\/\/empty\",parent)\n\t\t\tLocal mesh:TMesh=TMesh(entity)\n\t\t\tmesh._animator=New TBoneAnimator\n\t\t\t_mesh=mesh\n\t\t\t\n\t\t\tIf meshchunk.brush_id>-1 entity.SetBrush brush[meshchunk.brush_id]\n\t\t\t\n\t\t\tLocal vrts:TVRTSChunk=meshchunk.vrts\n\t\t\tLocal vertsurface:TSurface=New TSurface\n\t\t\tvertsurface.Resize(vrts.xyz.length\/3,0)\n\t\t\t\n\t\t\tFor Local i=0 To vertsurface.CountVertices()-1\n\t\t\t\tvertsurface.SetCoords i,vrts.xyz[i*3+0],vrts.xyz[i*3+1],vrts.xyz[i*3+2]\n\t\t\t\tIf vrts.nxyz vertsurface.SetNormal i,vrts.nxyz[i*3+0],vrts.nxyz[i*3+1],vrts.nxyz[i*3+2]\n\t\t\t\tIf vrts.rgba vertsurface.SetColor i,vrts.rgba[i*4+0]*255,vrts.rgba[i*4+1]*255,vrts.rgba[i*4+2]*255,vrts.rgba[i*4+3]\n\t\t\t\tIf vrts.SetSize()>1 \n\t\t\t\t\tFor Local j=0 To vrts.SetCount()-1\n\t\t\t\t\t\tvertsurface.SetTexCoords i,1-vrts.tex_coords[i][j,0],vrts.tex_coords[i][j,1],j\n\t\t\t\t\tNext\n\t\t\t\tEndIf\n\t\t\tNext\n\t\t\t\n\t\t\tFor Local i=0 To meshchunk.tris.length-1\n\t\t\t\tLocal tri:TTRISChunk=meshchunk.tris[i]\n\t\t\t\tLocal surface:TSurface=vertsurface.Copy()\n\t\t\t\tsurface.Resize(-1,tri.vertex_id.length\/3)\n\t\t\t\tIf tri.brush_id>-1 surface.SetBrush brush[tri.brush_id]\n\t\t\t\tFor Local t=0 To surface.CountTriangles()-1\n\t\t\t\t\tsurface.SetTriangle t,tri.vertex_id[t*3+0],tri.vertex_id[t*3+1],tri.vertex_id[t*3+2]\n\t\t\t\tNext\n\t\t\t\tIf vrts.nxyz=Null surface.UpdateNormals\t\t\t\n\t\t\t\tmesh.AppendSurface surface\n\t\t\tNext\n\t\tCase bonechunk\n\t\t\tentity=_currentworld.AddBone(parent)\n\t\t\tLocal bone:TBone=TBone(entity)\n\t\t\t\n\t\t\tFor Local surface:TSurface=EachIn _mesh._surfaces\n\t\t\t\tbone.AddSurface surface\n\t\t\t\tFor Local i=0 To bonechunk.vertex_id.length-1\n\t\t\t\t\tbone.AddVertex surface,bonechunk.vertex_id[i],bonechunk.weight[i]\n\t\t\t\tNext\n\t\t\tNext\t\t\t\n\t\t\t\n\t\t\tLocal ident_matrix:TMatrix=TMatrix.Identity()\n\t\t\tFor Local chunk:TKEYSChunk=EachIn node.keys\n\t\t\t\tLocal keys:TAnimKey[chunk.frame.length]\n\t\t\t\tLocal pos#[]=chunk.position,rot#[]=chunk.rotation,scl#[]=chunk.scale\n\t\t\t\tFor Local i=0 To chunk.frame.length-1\n\t\t\t\t\tLocal bonekey:TBoneKey=New TBoneKey\n\t\t\t\t\t\n\t\t\t\t\tIf pos.length>0 bonekey._px=pos[i*3+0];bonekey._py=pos[i*3+1];bonekey._pz=pos[i*3+2]\n\t\t\t\t\tIf rot.length>0 bonekey._rw=rot[i*4+0];bonekey._rx=rot[i*4+1];bonekey._ry=rot[i*4+2];bonekey._rz=rot[i*4+3]\n\t\t\t\t\tIf scl.length>0 bonekey._sx=scl[i*3+0];bonekey._sy=scl[i*3+1];bonekey._sz=scl[i*3+2]\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\tLocal key:TAnimKey=New TAnimKey\n\t\t\t\t\tkey._frame=chunk.frame[i]\n\t\t\t\t\tkey._object=bonekey\n\t\t\t\t\tkeys[i]=key\n\t\t\t\tNext\n\t\t\t\tTBoneAnimator(_mesh._animator).AddBone bone,keys\n\t\t\tNext\n\t\tDefault\n\t\t\tentity=_currentworld.AddPivot(parent)\n\t\tEnd Select\t\t\n\t\t\n\t\tentity.SetName node.name\n\t\tentity.SetPosition node.position[0],node.position[1],node.position[2]\n\t\tLocal pitch#,yaw#,roll#\n\t\tTQuaternion.Euler node.rotation[0],node.rotation[1],node.rotation[2],node.rotation[3],pitch,yaw,roll\n\t\tentity.SetRotation pitch,yaw,roll\n\t\tentity.SetScale node.scale[0],node.scale[1],node.scale[2]\n\t\t\n\t\tFor Local child:TNODEChunk=EachIn node.node\n\t\t\tParseNode child,entity,brush\n\t\tNext\n\t\tIf TMesh(entity) If TBoneAnimator(TMesh(entity)._animator)._root=Null TMesh(entity)._animator=Null\n\t\tIf TBone(entity) TBone(entity)._start_matrix=entity.GetMatrix()\n\tEnd Method\n\t\n\tMethod Info$()\n\t\tReturn \"Blitz3D|b3d\"\n\tEnd Method\n\tMethod ModuleName$()\n\t\tReturn \"b3dloader\"\n\tEnd Method\nEnd Type\nNew TMeshLoaderB3D\n","old_contents":"\nStrict\n\nRem\n\tbbdoc: Blitz3D model loader for MaxB3D\nEnd Rem\nModule MaxB3D.B3DLoader\nModuleInfo \"Author: Kevin Primm\"\nModuleInfo \"License: MIT\"\n\nImport MaxB3D.Core\nImport MaxB3D.BoneAnimator\nImport Prime.libB3D\n\nType TMeshLoaderB3D Extends TMeshLoader\n\tField _mesh:TMesh\n\t\n\tMethod Run(mesh:TMesh,stream:TStream,url:Object)\n\t\tLocal model:TBB3DChunk=TBB3DChunk.Load(url)\n\t\tIf model=Null Return False\t\n\t\t\n\t\tLocal olddir$=CurrentDir()\n\t\tIf String(url) ChangeDir(ExtractDir(String(url)))\n\t\t\n\t\tLocal texture:TTexture[model.texs.length]\n\t\tLocal brush:TBrush[model.brus.length]\n\t\t\n\t\tFor Local i=0 To texture.length-1\n\t\t\tLocal chunk:TTEXSChunk=model.texs[i]\t\t\t\n\t\t\ttexture[i]=_currentworld.AddTexture(chunk.file,chunk.flags)\n\t\t\tIf texture[i]\n\t\t\t\ttexture[i].SetBlend chunk.blend\n\t\t\t\ttexture[i].SetPosition chunk.x_pos,chunk.y_pos\n\t\t\t\ttexture[i].SetScale chunk.x_scale,chunk.y_scale\n\t\t\t\ttexture[i].SetRotation chunk.rotation*(180.0\/Pi)\n\t\t\t\tIf chunk.flags&65536 texture[i].SetCoords 1\n\t\t\tEndIf\n\t\tNext\n\t\t\n\t\tFor Local i=0 To brush.length-1\n\t\t\tLocal chunk:TBRUSChunk=model.brus[i]\n\t\t\tbrush[i]=_currentworld.AddBrush()\n\t\t\tbrush[i].SetName chunk.name\n\t\t\tbrush[i].SetColor chunk.red*255,chunk.green*255,chunk.blue*255;brush[i].SetAlpha chunk.alpha\n\t\t\tbrush[i].SetShine chunk.shininess\n\t\t\tbrush[i].SetBlend chunk.blend;brush[i].SetFX chunk.fx\n\t\t\tFor Local j=0 To chunk.n_texs-1\n\t\t\t\tIf chunk.texture_id[j]>-1 brush[i].SetTexture texture[chunk.texture_id[j]],j\n\t\t\tNext\n\t\tNext\t\t\n\t\tChangeDir olddir\n\t\t\n\t\t' model.dump StandardIOStream\n\t\t \n\t\tIf model.node\n\t\t\tParseNode model.node,mesh,brush,mesh\n\t\t\tReturn True\n\t\tEndIf\n\t\tReturn False\n\tEnd Method\n\t\n\tMethod ParseNode(node:TNODEChunk,parent:TEntity,brush:TBrush[],entity:TEntity=Null)\n\t\tLocal meshchunk:TMESHChunk=TMESHChunk(node.kind),bonechunk:TBONEChunk=TBONEChunk(node.kind)\n\t\t\t\t\n\t\tSelect node.kind\n\t\tCase Null\n\t\t\tentity=_currentworld.AddPivot(parent)\n\t\tCase meshchunk\t\t\t\n\t\t\tIf entity=Null entity=_currentworld.AddMesh(\"\/\/empty\",parent)\n\t\t\tLocal mesh:TMesh=TMesh(entity)\n\t\t\tmesh._animator=New TBoneAnimator\n\t\t\t_mesh=mesh\n\t\t\t\n\t\t\tIf meshchunk.brush_id>-1 entity.SetBrush brush[meshchunk.brush_id]\n\t\t\t\n\t\t\tLocal vrts:TVRTSChunk=meshchunk.vrts\n\t\t\tLocal vertsurface:TSurface=New TSurface\n\t\t\tvertsurface.Resize(vrts.xyz.length\/3,0)\n\t\t\t\n\t\t\tFor Local i=0 To vertsurface.CountVertices()-1\n\t\t\t\tvertsurface.SetCoords i,vrts.xyz[i*3+0],vrts.xyz[i*3+1],vrts.xyz[i*3+2]\n\t\t\t\tIf vrts.nxyz vertsurface.SetNormal i,vrts.nxyz[i*3+0],vrts.nxyz[i*3+1],vrts.nxyz[i*3+2]\n\t\t\t\tIf vrts.rgba vertsurface.SetColor i,vrts.rgba[i*4+0]*255,vrts.rgba[i*4+1]*255,vrts.rgba[i*4+2]*255,vrts.rgba[i*4+3]\n\t\t\t\tIf vrts.SetSize()>1 \n\t\t\t\t\tFor Local j=0 To vrts.SetCount()-1\n\t\t\t\t\t\tvertsurface.SetTexCoords i,1-vrts.tex_coords[i][j,0],vrts.tex_coords[i][j,1],j\n\t\t\t\t\tNext\n\t\t\t\tEndIf\n\t\t\tNext\n\t\t\t\n\t\t\tFor Local i=0 To meshchunk.tris.length-1\n\t\t\t\tLocal tri:TTRISChunk=meshchunk.tris[i]\n\t\t\t\tLocal surface:TSurface=vertsurface.Copy()\n\t\t\t\tsurface.Resize(-1,tri.vertex_id.length\/3)\n\t\t\t\tIf tri.brush_id>-1 surface.SetBrush brush[tri.brush_id]\n\t\t\t\tFor Local t=0 To surface.CountTriangles()-1\n\t\t\t\t\tsurface.SetTriangle t,tri.vertex_id[t*3+0],tri.vertex_id[t*3+1],tri.vertex_id[t*3+2]\n\t\t\t\tNext\n\t\t\t\tIf vrts.nxyz=Null surface.UpdateNormals\t\t\t\n\t\t\t\tmesh.AppendSurface surface\n\t\t\tNext\n\t\tCase bonechunk\n\t\t\tentity=_currentworld.AddBone(parent)\n\t\t\tLocal bone:TBone=TBone(entity)\n\t\t\t\n\t\t\tFor Local surface:TSurface=EachIn _mesh._surfaces\n\t\t\t\tbone.AddSurface surface\n\t\t\t\tFor Local i=0 To bonechunk.vertex_id.length-1\n\t\t\t\t\tbone.AddVertex surface,bonechunk.vertex_id[i],bonechunk.weight[i]\n\t\t\t\tNext\n\t\t\tNext\t\t\t\n\t\t\t\n\t\t\tLocal ident_matrix:TMatrix=TMatrix.Identity()\n\t\t\tFor Local chunk:TKEYSChunk=EachIn node.keys\n\t\t\t\tLocal keys:TAnimKey[chunk.frame.length]\n\t\t\t\tLocal pos#[]=chunk.position,rot#[]=chunk.rotation,scl#[]=chunk.scale\n\t\t\t\tFor Local i=0 To chunk.frame.length-1\n\t\t\t\t\tLocal bonekey:TBoneKey=New TBoneKey\n\t\t\t\t\t\n\t\t\t\t\tIf pos.length>0 bonekey._px=pos[i*3+0];bonekey._py=pos[i*3+1];bonekey._pz=pos[i*3+2]\n\t\t\t\t\tIf rot.length>0 bonekey._rw=rot[i*4+0];bonekey._rx=rot[i*4+1];bonekey._ry=rot[i*4+2];bonekey._rz=rot[i*4+3]\n\t\t\t\t\tIf scl.length>0 bonekey._sx=scl[i*3+0];bonekey._sy=scl[i*3+1];bonekey._sz=scl[i*3+2]\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\tLocal key:TAnimKey=New TAnimKey\n\t\t\t\t\tkey._frame=chunk.frame[i]\n\t\t\t\t\tkey._object=bonekey\n\t\t\t\t\tkeys[i]=key\n\t\t\t\tNext\n\t\t\t\tTBoneAnimator(_mesh._animator).AddBone bone,keys\n\t\t\tNext\n\t\tDefault\n\t\t\tentity=_currentworld.AddPivot(parent)\n\t\tEnd Select\t\t\n\t\t\n\t\tentity.SetName node.name\n\t\tentity.SetPosition node.position[0],node.position[1],node.position[2]\n\t\tLocal pitch#,yaw#,roll#\n\t\tTQuaternion.Euler node.rotation[0],node.rotation[1],node.rotation[2],node.rotation[3],pitch,yaw,roll\n\t\tentity.SetRotation pitch,yaw,roll\n\t\tentity.SetScale node.scale[0],node.scale[1],node.scale[2]\n\t\t\n\t\tFor Local child:TNODEChunk=EachIn node.node\n\t\t\tParseNode child,entity,brush\n\t\tNext\n\t\tIf TMesh(entity) If TBoneAnimator(TMesh(entity)._animator)._root=Null TMesh(entity)._animator=Null\n\t\tIf TBone(entity) TBone(entity)._start_matrix=entity.GetMatrix()\n\tEnd Method\n\t\n\tMethod Info$()\n\t\tReturn \"Blitz3D|b3d\"\n\tEnd Method\n\tMethod ModuleName$()\n\t\tReturn \"b3dloader\"\n\tEnd Method\nEnd Type\nNew TMeshLoaderB3D\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"2fed8f4f3ccd189183e0e110cb3464e43227057e","subject":"Added missing BlitzMax Diddy Functions for MonkeyMax","message":"Added missing BlitzMax Diddy Functions for MonkeyMax\n","repos":"swoolcock\/diddy,swoolcock\/diddy,swoolcock\/diddy,swoolcock\/diddy,swoolcock\/diddy","old_file":"monkeymax\/modules\/diddy\/native\/diddy.bmax.bmx","new_file":"monkeymax\/modules\/diddy\/native\/diddy.bmax.bmx","new_contents":"Type diddy\r\n\tFunction systemMillisecs:Float()\r\n\t\tReturn Millisecs()\r\n\tEndFunction\r\n\t\r\n\tFunction flushKeys:Int()\r\n\t\tBlitzMaxFlushKeys()\r\n\tEndFunction\r\n\t\r\n\tFunction getUpdateRate:Int()\r\n\t\tReturn app.updateRate;\r\n\tEndFunction\r\n\t\r\n\tFunction showMouse:Int()\r\n\t\tBlitzMaxShowMouse()\r\n\tEndFunction\r\n\t\r\n\tFunction hideMouse:Int()\r\n\t\tBlitzMaxHideMouse()\r\n\tEndFunction\r\n\t\r\n\tFunction setGraphics(w:int, h:int, fullScreen:Int = False)\r\n\t\tlocal d% = 0\r\n\t\tif fullScreen then d = 32\r\n\t\tGraphics w, h, d, 60\r\n\tEndFunction\r\n\t\r\n\tFunction setMouse(x:Int, y:Int)\r\n\t\tMoveMouse(x, y)\r\n\tEndFunction\r\n\t\r\n\tFunction showKeyboard()\r\n\tEndFunction\r\n\t\r\n\tFunction launchBrowser(address:String, windowName:String)\r\n\tEndFunction\r\n\t\r\n\tFunction launchEmail(email:String, subject:String, text:String)\r\n\tEndFunction\r\n\t\r\n\tFunction realMod:Float( value:Float, amount:Float )\r\n\t\tReturn value Mod amount;\r\n\tEndFunction\r\n\t\r\n\tFunction startVibrate(millisecs:int)\r\n\tEndFunction\r\n\t\r\n\tFunction stopVibrate()\r\n\tEndFunction\r\n\t\r\n\tFunction getDayOfMonth:Int()\r\n\t\tLocal date$ = CurrentDate()\r\n\t\tReturn Int(date[..2])\r\n\tEndFunction\r\n\t\r\n\tFunction getDayOfWeek:Int()\r\n\t\tReturn 0\r\n\tEndFunction\r\n\t\r\n\tFunction getMonth:Int()\r\n\t\tLocal date$ = CurrentDate()\r\n\t\tReturn (Instr(\"JANFEBMARAPRMAYJUNJULAUGSEPOCTNOVDEC\", date$[3..6].ToUpper(), 1) \/ 3) + 1\r\n\tEndFunction\r\n\t\r\n\tFunction getYear:Int()\r\n\t\tLocal date$ = CurrentDate()\r\n\t\tReturn Int(date[date.length - 4..]);\r\n\tEndFunction\r\n\t\r\n\tFunction getHours:Int()\r\n\t\tLocal time$ = CurrentTime()\r\n\t\tReturn Int(time[..2])\r\n\tEndFunction\r\n\t\r\n\tFunction getMinutes:Int()\r\n\t\tLocal time$ = CurrentTime()\r\n\t\tReturn Int(time[3..5])\r\n\tEndFunction\r\n\t\r\n\tFunction getSeconds:Int()\r\n\t\tLocal time$ = CurrentTime()\r\n\t\tReturn Int(time[6..8])\r\n\tEndFunction\r\n\t\r\n\tFunction getMilliSeconds:Int()\r\n\t\tReturn Millisecs()\r\n\tEndFunction\r\n\t\r\n\tFunction startGps()\r\n\tEndFunction\r\n\t\r\n\tFunction getLatitiude:String()\r\n\t\tReturn \"\"\r\n\tEndFunction\r\n\t\r\n\tFunction getLongitude:String()\r\n\t\tReturn \"\"\r\n\tEndFunction\r\n\r\n\tFunction showAlertDialog(title:String, message:String)\r\n\tEndFunction\r\n\t\r\n\tFunction getInputString:String()\r\n\t\tReturn \"\";\r\n\tEndFunction\r\n\t\r\n\tFunction getPixel:Int( x:int, y:int )\r\n'\t\tunsigned char pix[4];\r\n'\t\tglReadPixels(x, app->graphics->height-y ,1 ,1 ,GL_RGBA ,GL_UNSIGNED_BYTE ,pix);\r\n'\t\treturn (pix[3]<<24) | (pix[0]<<16) | (pix[1]<<8) | pix[2];\r\n\t\tReturn 0\r\n\tEndFunction\r\n\t\r\nEndType\r\n\r\nFunction BlitzMaxFlushKeys()\r\n\tFlushKeys()\r\nEndFunction\r\n\r\nFunction BlitzMaxShowMouse()\r\n\tShowMouse()\r\nEndFunction\r\n\r\nFunction BlitzMaxHideMouse()\r\n\tHideMouse()\r\nEndFunction\r\n\r\n","old_contents":"Type diddy\r\n\tFunction systemMillisecs:Float()\r\n\t\treturn Millisecs()\r\n\tEndFunction\r\n\r\n\tFunction realMod:Float( value:Float, amount:Float )\r\n\t\treturn value Mod amount;\r\n\tEndFunction\r\n\t\r\n\tFunction getYear:Int()\r\n\t\treturn 2012;\r\n\tEndFunction\r\nEndType\r\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"e2ef69ddf3e7a5210b37fa2b51f46917aedc8ced","subject":"Really fixed String slicing ;)","message":"Really fixed String slicing ;)\n\n--HG--\nextra : convert_revision : svn%3Ae934d3cd-0d57-f34a-94d0-9e8d31ae1c29\/trunk%40391\n","repos":"programmerby\/diddy-mirror,programmerby\/diddy-mirror,programmerby\/diddy-mirror,programmerby\/diddy-mirror","old_file":"monkeymax\/modules\/monkey\/native\/lang.bmx","new_file":"monkeymax\/modules\/monkey\/native\/lang.bmx","new_contents":"' ***** Start lang.bmx ******\r\nGlobal D2R:Float=0.017453292519943295;\r\nGlobal R2D:Float=57.29577951308232;\r\n\r\nFunction pushErr()\r\n\t_errStack.AddLast( _errInfo );\r\nEndFunction\r\n\r\nFunction popErr()\r\n\t_errInfo=String(_errStack.ValueAtIndex(_errStack.Count()-1))\r\n\t_errStack.RemoveLast();\r\nEndFunction\r\n\r\nFunction error( err:String )\r\n\tIf err = \"\" Then\r\n\t\tEnd\r\n\tElse\r\n\t\tRuntimeError err;\r\n\tEndIf\r\nEndFunction\r\n\r\nFunction resize_string_array:String[]( arr:String[], leng:Int )\r\n\tLocal i:Int = arr.length;\r\n\tarr = arr[0..leng];\r\n\tIf( leng<=i ) Return arr;\r\n\tWhile( i le\r\n\t\tfrom = le\r\n\tEndIf\r\n\tIf term <= 0\r\n\t\tterm :+ le\r\n\tElse If term > le\r\n\t\tterm = le\r\n\tEndIf\r\n\r\n\tIf term <= from Return arr\r\n\tReturn Mid(arr, from + 1, term - from)\r\n\r\nEndFunction\r\n\r\n' ***** End lang.bmx ******\r\n\r\n\r\n","old_contents":"' ***** Start lang.bmx ******\r\nGlobal D2R:Float=0.017453292519943295;\r\nGlobal R2D:Float=57.29577951308232;\r\n\r\nFunction pushErr()\r\n\t_errStack.AddLast( _errInfo );\r\nEndFunction\r\n\r\nFunction popErr()\r\n\t_errInfo=String(_errStack.ValueAtIndex(_errStack.Count()-1))\r\n\t_errStack.RemoveLast();\r\nEndFunction\r\n\r\nFunction error( err:String )\r\n\tIf err = \"\" Then\r\n\t\tEnd\r\n\tElse\r\n\t\tRuntimeError err;\r\n\tEndIf\r\nEndFunction\r\n\r\nFunction resize_string_array:String[]( arr:String[], leng:Int )\r\n\tLocal i:Int = arr.length;\r\n\tarr = arr[0..leng];\r\n\tIf( leng<=i ) Return arr;\r\n\tWhile( i le\r\n\t\tfrom = le\r\n\tEndIf\r\n\tIf term <= 0\r\n\t\tterm :+ le\r\n\tElse If term > le\r\n\t\tterm = le\r\n\tEndIf\r\n\r\n\tIf term <= from Return arr\r\n\tReturn Mid(arr, from, term-from)\r\n\r\nEndFunction\r\n\r\n' ***** End lang.bmx ******\r\n\r\n\r\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"07195b40b31e9446e94d05c9c41788e11a9098d7","subject":"Fixed rotation conversion in MaxB3D.B3DLoader","message":"Fixed rotation conversion in MaxB3D.B3DLoader\n","repos":"kfprimm\/maxb3d,kfprimm\/maxb3d","old_file":"b3dloader.mod\/b3dloader.bmx","new_file":"b3dloader.mod\/b3dloader.bmx","new_contents":"\nStrict\n\nRem\n\tbbdoc: Blitz3D model loader for MaxB3D\nEnd Rem\nModule MaxB3D.B3DLoader\nModuleInfo \"Author: Kevin Primm\"\nModuleInfo \"License: MIT\"\n\nImport MaxB3D.Core\nImport MaxB3D.BoneAnimator\nImport Prime.libB3D\n\nType TMeshLoaderB3D Extends TMeshLoader\n\tField _mesh:TMesh\n\t\n\tMethod Run(mesh:TMesh,stream:TStream,url:Object)\n\t\tLocal model:TBB3DChunk=TBB3DChunk.Load(url)\n\t\tIf model=Null Return False\t\n\t\t\n\t\tLocal olddir$=CurrentDir()\n\t\tIf String(url) ChangeDir(ExtractDir(String(url)))\n\t\t\n\t\tLocal texture:TTexture[model.texs.length]\n\t\tLocal brush:TBrush[model.brus.length]\n\t\t\n\t\tFor Local i=0 To texture.length-1\n\t\t\tLocal chunk:TTEXSChunk=model.texs[i]\t\t\t\n\t\t\ttexture[i]=_currentworld.AddTexture(chunk.file,chunk.flags)\n\t\t\tIf texture[i]\n\t\t\t\ttexture[i].SetBlend chunk.blend\n\t\t\t\ttexture[i].SetPosition chunk.x_pos,chunk.y_pos\n\t\t\t\ttexture[i].SetScale chunk.x_scale,chunk.y_scale\n\t\t\t\ttexture[i].SetRotation chunk.rotation*(180.0\/Pi)\n\t\t\tEndIf\n\t\tNext\n\t\t\n\t\tFor Local i=0 To brush.length-1\n\t\t\tLocal chunk:TBRUSChunk=model.brus[i]\n\t\t\tbrush[i]=_currentworld.AddBrush()\n\t\t\tbrush[i].SetName chunk.name\n\t\t\tbrush[i].SetColor chunk.red*255,chunk.green*255,chunk.blue*255;brush[i].SetAlpha chunk.alpha\n\t\t\tbrush[i].SetShine chunk.shininess\n\t\t\tbrush[i].SetBlend chunk.blend;brush[i].SetFX chunk.fx\n\t\t\tFor Local j=0 To chunk.n_texs-1\n\t\t\t\tIf chunk.texture_id[j]>-1 brush[i].SetTexture texture[chunk.texture_id[j]],j\n\t\t\tNext\n\t\tNext\t\t\n\t\tChangeDir olddir\n\t\t\n\t\t' model.dump StandardIOStream\n\t\t \n\t\tIf model.node\n\t\t\tParseNode model.node,mesh,brush,mesh\n\t\t\tReturn True\n\t\tEndIf\n\t\tReturn False\n\tEnd Method\n\t\n\tMethod ParseNode(node:TNODEChunk,parent:TEntity,brush:TBrush[],entity:TEntity=Null)\n\t\tLocal meshchunk:TMESHChunk=TMESHChunk(node.kind),bonechunk:TBONEChunk=TBONEChunk(node.kind)\n\t\t\t\t\n\t\tSelect node.kind\n\t\tCase Null\n\t\t\tentity=_currentworld.AddPivot(parent)\n\t\tCase meshchunk\t\t\t\n\t\t\tIf entity=Null entity=_currentworld.AddMesh(\"*null*\",parent)\n\t\t\tLocal mesh:TMesh=TMesh(entity)\n\t\t\tmesh._animator=New TBoneAnimator\n\t\t\t_mesh=mesh\n\t\t\t\n\t\t\tIf meshchunk.brush_id>-1 entity.SetBrush brush[meshchunk.brush_id]\n\t\t\t\n\t\t\tLocal vrts:TVRTSChunk=meshchunk.vrts\n\t\t\tLocal vertsurface:TSurface=New TSurface\n\t\t\tvertsurface.Resize(vrts.xyz.length\/3,0)\n\t\t\t\n\t\t\tFor Local i=0 To vertsurface.CountVertices()-1\n\t\t\t\tvertsurface.SetCoords i,vrts.xyz[i*3+0],vrts.xyz[i*3+1],vrts.xyz[i*3+2]\n\t\t\t\tIf vrts.nxyz vertsurface.SetNormal i,vrts.nxyz[i*3+0],vrts.nxyz[i*3+1],vrts.nxyz[i*3+2]\n\t\t\t\tIf vrts.rgba vertsurface.SetColor i,vrts.rgba[i*4+0]*255,vrts.rgba[i*4+1]*255,vrts.rgba[i*4+2]*255,vrts.rgba[i*4+3]\n\t\t\t\tFor Local j=0 To vrts.SetCount()-1\n\t\t\t\t\tLocal u#,v#\n\t\t\t\t\tIf vrts.SetSize()>1 u=vrts.tex_coords[i][j,0];v=vrts.tex_coords[i][j,1]\n\t\t\t\t\tvertsurface.SetTexCoords i,1-u,v\n\t\t\t\tNext\n\t\t\tNext\n\t\t\t\n\t\t\tFor Local i=0 To meshchunk.tris.length-1\n\t\t\t\tLocal tri:TTRISChunk=meshchunk.tris[i]\n\t\t\t\tLocal surface:TSurface=vertsurface.Copy()\n\t\t\t\tsurface.Resize(-1,tri.vertex_id.length\/3)\n\t\t\t\tIf tri.brush_id>-1 surface.SetBrush brush[tri.brush_id]\n\t\t\t\tFor Local t=0 To surface.CountTriangles()-1\n\t\t\t\t\tsurface.SetTriangle t,tri.vertex_id[t*3+0],tri.vertex_id[t*3+1],tri.vertex_id[t*3+2]\n\t\t\t\tNext\n\t\t\t\tIf vrts.nxyz=Null surface.UpdateNormals\t\t\t\n\t\t\t\tmesh.AppendSurface surface\n\t\t\tNext\n\t\tCase bonechunk\n\t\t\tentity=_currentworld.AddBone(parent)\n\t\t\tLocal bone:TBone=TBone(entity)\n\t\t\t\n\t\t\tFor Local surface:TSurface=EachIn _mesh._surfaces\n\t\t\t\tbone.AddSurface surface\n\t\t\t\tFor Local i=0 To bonechunk.vertex_id.length-1\n\t\t\t\t\tbone.AddVertex surface,bonechunk.vertex_id[i],bonechunk.weight[i]\n\t\t\t\tNext\n\t\t\tNext\t\t\t\n\t\t\t\n\t\t\tLocal ident_matrix:TMatrix=TMatrix.Identity()\n\t\t\tFor Local chunk:TKEYSChunk=EachIn node.keys\n\t\t\t\tLocal keys:TAnimKey[chunk.frame.length]\n\t\t\t\tLocal pos#[]=chunk.position,rot#[]=chunk.rotation,scl#[]=chunk.scale\n\t\t\t\tFor Local i=0 To chunk.frame.length-1\n\t\t\t\t\tLocal bonekey:TBoneKey=New TBoneKey\n\t\t\t\t\t\n\t\t\t\t\tIf pos.length>0 bonekey._px=pos[i*3+0];bonekey._py=pos[i*3+1];bonekey._pz=pos[i*3+2]\n\t\t\t\t\tIf rot.length>0 bonekey._rw=rot[i*4+0];bonekey._rx=rot[i*4+1];bonekey._ry=rot[i*4+2];bonekey._rz=rot[i*4+3]\n\t\t\t\t\tIf scl.length>0 bonekey._sx=scl[i*3+0];bonekey._sy=scl[i*3+1];bonekey._sz=scl[i*3+2]\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\tLocal key:TAnimKey=New TAnimKey\n\t\t\t\t\tkey._frame=chunk.frame[i]\n\t\t\t\t\tkey._object=bonekey\n\t\t\t\t\tkeys[i]=key\n\t\t\t\tNext\n\t\t\t\tTBoneAnimator(_mesh._animator).AddBone bone,keys\n\t\t\tNext\n\t\tDefault\n\t\t\tentity=_currentworld.AddPivot(parent)\n\t\tEnd Select\t\t\n\t\t\n\t\tentity.SetName node.name\n\t\tentity.SetPosition node.position[0],node.position[1],node.position[2]\n\t\tLocal pitch#,yaw#,roll#\n\t\tTQuaternion.Euler node.rotation[0],node.rotation[1],node.rotation[2],node.rotation[3],pitch,yaw,roll\n\t\tentity.SetRotation pitch,yaw,roll\n\t\tentity.SetScale node.scale[0],node.scale[1],node.scale[2]\n\t\t\n\t\tFor Local child:TNODEChunk=EachIn node.node\n\t\t\tParseNode child,entity,brush\n\t\tNext\n\t\tIf TMesh(entity) If TBoneAnimator(TMesh(entity)._animator)._root=Null TMesh(entity)._animator=Null\n\t\tIf TBone(entity) TBone(entity)._start_matrix=entity.GetMatrix()\n\tEnd Method\n\t\n\tMethod Info$()\n\t\tReturn \"Blitz3D|b3d\"\n\tEnd Method\n\tMethod ModuleName$()\n\t\tReturn \"b3dloader\"\n\tEnd Method\nEnd Type\nNew TMeshLoaderB3D\n","old_contents":"\nStrict\n\nRem\n\tbbdoc: Blitz3D model loader for MaxB3D\nEnd Rem\nModule MaxB3D.B3DLoader\nModuleInfo \"Author: Kevin Primm\"\nModuleInfo \"License: MIT\"\n\nImport MaxB3D.Core\nImport MaxB3D.BoneAnimator\nImport Prime.libB3D\n\nType TMeshLoaderB3D Extends TMeshLoader\n\tField _mesh:TMesh\n\t\n\tMethod Run(mesh:TMesh,stream:TStream,url:Object)\n\t\tLocal model:TBB3DChunk=TBB3DChunk.Load(url)\n\t\tIf model=Null Return False\t\n\t\t\n\t\tLocal olddir$=CurrentDir()\n\t\tIf String(url) ChangeDir(ExtractDir(String(url)))\n\t\t\n\t\tLocal texture:TTexture[model.texs.length]\n\t\tLocal brush:TBrush[model.brus.length]\n\t\t\n\t\tFor Local i=0 To texture.length-1\n\t\t\tLocal chunk:TTEXSChunk=model.texs[i]\t\t\t\n\t\t\ttexture[i]=_currentworld.AddTexture(chunk.file,chunk.flags)\n\t\t\tIf texture[i]\n\t\t\t\ttexture[i].SetBlend chunk.blend\n\t\t\t\ttexture[i].SetPosition chunk.x_pos,chunk.y_pos\n\t\t\t\ttexture[i].SetScale chunk.x_scale,chunk.y_scale\n\t\t\t\ttexture[i].SetRotation chunk.rotation\n\t\t\tEndIf\n\t\tNext\n\t\t\n\t\tFor Local i=0 To brush.length-1\n\t\t\tLocal chunk:TBRUSChunk=model.brus[i]\n\t\t\tbrush[i]=_currentworld.AddBrush()\n\t\t\tbrush[i].SetName chunk.name\n\t\t\tbrush[i].SetColor chunk.red*255,chunk.green*255,chunk.blue*255;brush[i].SetAlpha chunk.alpha\n\t\t\tbrush[i].SetShine chunk.shininess\n\t\t\tbrush[i].SetBlend chunk.blend;brush[i].SetFX chunk.fx\n\t\t\tFor Local j=0 To chunk.n_texs-1\n\t\t\t\tIf chunk.texture_id[j]>-1 brush[i].SetTexture texture[chunk.texture_id[j]],j\n\t\t\tNext\n\t\tNext\t\t\n\t\tChangeDir olddir\n\t\t\n\t\t' model.dump StandardIOStream\n\t\t \n\t\tIf model.node\n\t\t\tParseNode model.node,mesh,brush,mesh\n\t\t\tReturn True\n\t\tEndIf\n\t\tReturn False\n\tEnd Method\n\t\n\tMethod ParseNode(node:TNODEChunk,parent:TEntity,brush:TBrush[],entity:TEntity=Null)\n\t\tLocal meshchunk:TMESHChunk=TMESHChunk(node.kind),bonechunk:TBONEChunk=TBONEChunk(node.kind)\n\t\t\t\t\n\t\tSelect node.kind\n\t\tCase Null\n\t\t\tentity=_currentworld.AddPivot(parent)\n\t\tCase meshchunk\t\t\t\n\t\t\tIf entity=Null entity=_currentworld.AddMesh(\"*null*\",parent)\n\t\t\tLocal mesh:TMesh=TMesh(entity)\n\t\t\tmesh._animator=New TBoneAnimator\n\t\t\t_mesh=mesh\n\t\t\t\n\t\t\tIf meshchunk.brush_id>-1 entity.SetBrush brush[meshchunk.brush_id]\n\t\t\t\n\t\t\tLocal vrts:TVRTSChunk=meshchunk.vrts\n\t\t\tLocal vertsurface:TSurface=New TSurface\n\t\t\tvertsurface.Resize(vrts.xyz.length\/3,0)\n\t\t\t\n\t\t\tFor Local i=0 To vertsurface.CountVertices()-1\n\t\t\t\tvertsurface.SetCoords i,vrts.xyz[i*3+0],vrts.xyz[i*3+1],vrts.xyz[i*3+2]\n\t\t\t\tIf vrts.nxyz vertsurface.SetNormal i,vrts.nxyz[i*3+0],vrts.nxyz[i*3+1],vrts.nxyz[i*3+2]\n\t\t\t\tIf vrts.rgba vertsurface.SetColor i,vrts.rgba[i*4+0]*255,vrts.rgba[i*4+1]*255,vrts.rgba[i*4+2]*255,vrts.rgba[i*4+3]\n\t\t\t\tFor Local j=0 To vrts.SetCount()-1\n\t\t\t\t\tLocal u#,v#\n\t\t\t\t\tIf vrts.SetSize()>1 u=vrts.tex_coords[i][j,0];v=vrts.tex_coords[i][j,1]\n\t\t\t\t\tvertsurface.SetTexCoords i,1-u,v\n\t\t\t\tNext\n\t\t\tNext\n\t\t\t\n\t\t\tFor Local i=0 To meshchunk.tris.length-1\n\t\t\t\tLocal tri:TTRISChunk=meshchunk.tris[i]\n\t\t\t\tLocal surface:TSurface=vertsurface.Copy()\n\t\t\t\tsurface.Resize(-1,tri.vertex_id.length\/3)\n\t\t\t\tIf tri.brush_id>-1 surface.SetBrush brush[tri.brush_id]\n\t\t\t\tFor Local t=0 To surface.CountTriangles()-1\n\t\t\t\t\tsurface.SetTriangle t,tri.vertex_id[t*3+0],tri.vertex_id[t*3+1],tri.vertex_id[t*3+2]\n\t\t\t\tNext\n\t\t\t\tIf vrts.nxyz=Null surface.UpdateNormals\t\t\t\n\t\t\t\tmesh.AppendSurface surface\n\t\t\tNext\n\t\tCase bonechunk\n\t\t\tentity=_currentworld.AddBone(parent)\n\t\t\tLocal bone:TBone=TBone(entity)\n\t\t\t\n\t\t\tFor Local surface:TSurface=EachIn _mesh._surfaces\n\t\t\t\tbone.AddSurface surface\n\t\t\t\tFor Local i=0 To bonechunk.vertex_id.length-1\n\t\t\t\t\tbone.AddVertex surface,bonechunk.vertex_id[i],bonechunk.weight[i]\n\t\t\t\tNext\n\t\t\tNext\t\t\t\n\t\t\t\n\t\t\tLocal ident_matrix:TMatrix=TMatrix.Identity()\n\t\t\tFor Local chunk:TKEYSChunk=EachIn node.keys\n\t\t\t\tLocal keys:TAnimKey[chunk.frame.length]\n\t\t\t\tLocal pos#[]=chunk.position,rot#[]=chunk.rotation,scl#[]=chunk.scale\n\t\t\t\tFor Local i=0 To chunk.frame.length-1\n\t\t\t\t\tLocal bonekey:TBoneKey=New TBoneKey\n\t\t\t\t\t\n\t\t\t\t\tIf pos.length>0 bonekey._px=pos[i*3+0];bonekey._py=pos[i*3+1];bonekey._pz=pos[i*3+2]\n\t\t\t\t\tIf rot.length>0 bonekey._rw=rot[i*4+0];bonekey._rx=rot[i*4+1];bonekey._ry=rot[i*4+2];bonekey._rz=rot[i*4+3]\n\t\t\t\t\tIf scl.length>0 bonekey._sx=scl[i*3+0];bonekey._sy=scl[i*3+1];bonekey._sz=scl[i*3+2]\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\tLocal key:TAnimKey=New TAnimKey\n\t\t\t\t\tkey._frame=chunk.frame[i]\n\t\t\t\t\tkey._object=bonekey\n\t\t\t\t\tkeys[i]=key\n\t\t\t\tNext\n\t\t\t\tTBoneAnimator(_mesh._animator).AddBone bone,keys\n\t\t\tNext\n\t\tDefault\n\t\t\tentity=_currentworld.AddPivot(parent)\n\t\tEnd Select\t\t\n\t\t\n\t\tentity.SetName node.name\n\t\tentity.SetPosition node.position[0],node.position[1],node.position[2]\n\t\tLocal pitch#,yaw#,roll#\n\t\tTQuaternion.Euler node.rotation[0],node.rotation[1],node.rotation[2],node.rotation[3],pitch,yaw,roll\n\t\tentity.SetRotation pitch,yaw,roll\n\t\tentity.SetScale node.scale[0],node.scale[1],node.scale[2]\n\t\t\n\t\tFor Local child:TNODEChunk=EachIn node.node\n\t\t\tParseNode child,entity,brush\n\t\tNext\n\t\tIf TMesh(entity) If TBoneAnimator(TMesh(entity)._animator)._root=Null TMesh(entity)._animator=Null\n\t\tIf TBone(entity) TBone(entity)._start_matrix=entity.GetMatrix()\n\tEnd Method\n\t\n\tMethod Info$()\n\t\tReturn \"Blitz3D|b3d\"\n\tEnd Method\n\tMethod ModuleName$()\n\t\tReturn \"b3dloader\"\n\tEnd Method\nEnd Type\nNew TMeshLoaderB3D\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"8f13d57a041621628e057d024b77f02978ad6f10","subject":"extremely minimal library implementation","message":"extremely minimal library implementation\n","repos":"Leushenko\/blue-moon","old_file":"bluelibrary.bmx","new_file":"bluelibrary.bmx","new_contents":"\n' Blue Moon\n' Basic Lua library\n\n' this is the minimal \"standard library\", designed to be loaded into a VM on start\n' most of this doesn't use the convenience interface so as to keep overhead down\n\n' for now this is an Include rather than Import lib due to recursive dependency\n' we'll fix that later\n\nRem\nSuperStrict\n\nImport \"blueerror.bmx\"\nImport \"bluevm.bmx\"\nImport \"bluetable.bmx\"\nEnd Rem\n\nType BlueBasicLibrary\n\tFunction _Load(vm:BlueVM, _ENV:BlueLuaVal)\n\t\t_ENV.Set(\"_G\", _ENV)\n\t\t_ENV.Set(\"getmetatable\", vm.ValueFromFunction(getmetatable))\n\t\t_ENV.Set(\"rawget\", vm.ValueFromFunction(rawget))\n\t\t_ENV.Set(\"rawset\", vm.ValueFromFunction(rawset))\n\t\t_ENV.Set(\"setmetatable\", vm.ValueFromFunction(setmetatable))\n\t\t_ENV.Set(\"_VERSION\", vm.mem.AllocConstant(_VERSION.Length, Short Ptr(_VERSION))\n\tEnd Function\n\t\n\t'assert\n\t'collectgarbage\n\t'dofile\n\t'error\n\tFunction getmetatable:Int(vm:BlueVM, argc:Int, argv:Long Ptr, retv:Long Ptr)\n\t\tIf argc < 1 Then vm.Error(\"not enough arguments to getmetatable: expecting object(1)\")\n\t\tLocal tag:Int = Int Ptr(argv)[1]\n\t\tIf tag = BlueTypeTag.TBLBOX Or tag = BlueTypeTag.USRBOX\n\t\t\tLocal meta:Int = Int Ptr Ptr(argv)[0][0]\n\t\t\tIf meta\n\t\t\t\tInt Ptr(retv)[1] = BlueTypeTag.TBLBOX\n\t\t\t\tInt Ptr(retv)[0] = meta\n\t\t\tElse\n\t\t\t\tretv[0] = vm.mem.NIL\n\t\t\tEndIf\n\t\tElse\n\t\t\tretv[0] = vm.mem.NIL\n\t\tEndIf\n\t\tReturn 1\n\tEnd Function\n\t'ipairs\n\t'load\n\t'loadfile\n\t'next\n\t'pairs\n\t'pcall\n\t'print\n\t'rawequal\n\tFunction rawget:Int(vm:BlueVM, argc:Int, argv:Long Ptr, retv:Long Ptr)\n\t\tIf argc < 2 Then vm.Error(\"not enough arguments to rawget: expecting table(1) and key(2)\")\n\t\tLocal tag:Int = Int Ptr(argv)[1]\n\t\tIf tag = BlueTypeTag.TBLBOX\n\t\t\tretv[0] = BlueTable.RawGet(Byte Ptr Ptr(argv)[0], argv[1])\n\t\tElse\n\t\t\tvm.Error(\"argument (1) to rawget must be a table\")\n\t\tEndIf\n\t\tReturn 1\n\tEnd Function\n\t'rawlen\n\tFunction rawset:Int(vm:BlueVM, argc:Int, argv:Long Ptr, retv:Long Ptr)\n\t\tIf argc < 3 Then vm.Error(\"not enough arguments to rawset: expecting table(1), key(2), value(3)\")\n\t\tLocal tag:Int = Int Ptr(argv)[1]\n\t\tIf tag = BlueTypeTag.TBLBOX\n\t\t\tBlueTable.RawSet(vm.mem, Byte Ptr Ptr(argv)[0], argv[1], argv[2])\n\t\t\tretv[0] = argv[0]\n\t\tElse\n\t\t\tvm.Error(\"argument (1) to rawset must be a table\")\n\t\tEndIf\n\t\tReturn 1\n\tEnd Function\n\t'select\n\tFunction setmetatable:Int(vm:BlueVM, argc:Int, argv:Long Ptr, retv:Long Ptr)\n\t\tIf argc < 2 Then vm.Error(\"not enough arguments to setmetatable: expecting object(1) and metatable(2)\")\n\t\tLocal tag:Int = Int Ptr(argv)[1]\n\t\tIf tag = BlueTypeTag.TBLBOX Or tag = BlueTypeTag.USRBOX\n\t\t\t'check if existing metatable has __metatable field and error if so\n\t\t\ttag = Int Ptr(argv + 1)[1]\n\t\t\tIf tag <> BlueTypeTag.TBLBOX Then vm.Error(\"argument (2) to setmetatable must be a table\")\n\t\t\t'apply finalizer tag\n\t\t\t'apply weakness flag\n\t\t\tInt Ptr Ptr(argv)[0][0] = Int Ptr(argv + 1)[0]\n\t\tEndIf\n\t\tretv[0] = argv[0]\t'manual doesn't say it's an error to not be a table\n\t\tReturn 1\n\tEnd Function\n\t'tonumber\n\t'tostring\n\t'type\n\tConst _VERSION:String = \"Lua 5.3 (incomplete)\"\n\t'xpcall\nEnd Type\n\n","old_contents":"\n' Blue Moon\n' Basic Lua library\n\n' this is the minimal \"standard library\", designed to be loaded into a VM on start\n' most of this doesn't use the convenience interface so as to keep overhead down\n\n' for now this is an Include rather than Import lib due to recursive dependency\n' we'll fix that later\n\nRem\nSuperStrict\n\nImport \"blueerror.bmx\"\nImport \"bluevm.bmx\"\nImport \"bluetable.bmx\"\nEnd Rem\n\nType BlueBasicLibrary\n\tFunction _Load(_ENV:Byte Ptr)\n\tEnd Function\n\t\n\tFunction getmetatable()\n\tEnd Function\n\tFunction setmetatable()\n\tEnd Function\n\t\nEnd Type\n\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"44ba2a23cbce6ed2934a6ae5b96f926cb1981ebf","subject":"Now saving metafile when installing a module","message":"Now saving metafile when installing a module\n\nrefs gh-1\n","repos":"maximos\/maximus","old_file":"src\/impl\/install.bmx","new_file":"src\/impl\/install.bmx","new_contents":"\nRem\n\tbbdoc: Maximus 'install' argument implementation.\nEnd Rem\nType mxInstallImpl Extends dArgumentImplementation\n\t\n\tField m_instmap:dObjectMap\n\tField m_depcheckmap:dObjectMap\n\tField m_nobuild:Int = False, m_nounpack:Int = False, m_keeptemp:Int = False\n\tField m_nothreaded:Int = False, m_makedocs:Int = False, m_forceinstall:Int = False\n\t\n\tMethod New()\n\t\tinit([\"install\"])\n\t\tm_instmap = New dObjectMap\n\t\tm_depcheckmap = New dObjectMap\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Check the current arguments for errors (according to the specific implementation).\n\t\treturns: Nothing.\n\t\tabout: This method will throw an error if the arguments are invalid.\n\tEnd Rem\n\tMethod CheckArgs()\n\t\tIf GetArgumentCount() = 0\n\t\t\tThrowCommonError(mxCmdErrors.REQUIRESPARAMS, m_args.GetName())\n\t\tEnd If\n\t\tCheckOptions()\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get a string describing the typical usage of the argument.\n\t\treturns: A string describing the typical usage of the argument.\n\tEnd Rem\n\tMethod GetUsage:String()\n\t\tReturn _s(\"arg.install.usage\")\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Execute the implementation's operation.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod Execute()\n\t\tm_instmap.Clear()\n\t\tm_depcheckmap.Clear()\n\t\tIf mainapp.m_sourceshandler\n\t\t\tLocal nfounds:dObjectMap = New dObjectMap\n\t\t\tFor Local svar:dStringVariable = EachIn m_args\n\t\t\t\tLocal verid:String = svar.Get(), modid:String = mxModUtils.GetIDFromVerID(verid)\n\t\t\t\tLocal modul:mxModule = mainapp.m_sourceshandler.GetModuleWithID(modid)\n\t\t\t\tIf modul\n\t\t\t\t\tLocal instmod:mxInstModule = New mxInstModule.Create(verid, modul)\n\t\t\t\t\tIf instmod.SetVersionFromVerID(verid)\n\t\t\t\t\t\tm_instmap._Insert(modid, instmod)\n\t\t\t\t\tElse\n\t\t\t\t\t\tThrowError(_s(\"arg.install.notfound.version\", [modid, mxModUtils.GetVersionFromVerID(verid)]))\n\t\t\t\t\tEnd If\n\t\t\t\tElse\n\t\t\t\t\tnfounds._Insert(modid, modid)\n\t\t\t\tEnd If\n\t\t\tNext\n\t\t\tIf nfounds.Count() > 0\n\t\t\t\tlogger.LogError(_s(\"arg.install.notfound.instmods\"))\n\t\t\t\tLocal a:String\n\t\t\t\tFor Local b:String = EachIn nfounds.ValueEnumerator()\n\t\t\t\t\ta:+ b + \" \"\n\t\t\t\tNext\n\t\t\t\ta = a[..a.Length - 1]\n\t\t\t\tlogger.LogMessage(\"~t\" + a)\n\t\t\t\tReturn\n\t\t\tEnd If\n\t\t\tIf CheckDependencies()\n\t\t\t\tIf CheckVersions()\n\t\t\t\t\tDoInstall()\n\t\t\t\tEnd If\n\t\t\tEnd If\n\t\tElse\n\t\t\tThrowError(_s(\"error.install.nosources\"))\n\t\tEnd If\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Check the options given to the command.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod CheckOptions()\n\t\tm_nobuild = False; m_nounpack = False; m_keeptemp = False\n\t\tm_nothreaded = False; m_makedocs = False\n\t\tFor Local opt:dIdentifier = EachIn m_args\n\t\t\tSelect opt.GetName().ToLower()\n\t\t\t\tCase \"-nobuild\" m_nobuild = True\n\t\t\t\tCase \"-nounpack\" m_nounpack = True\n\t\t\t\tCase \"-keeptemp\" m_keeptemp = True\n\t\t\t\tCase \"-nothreaded\" m_nothreaded = True\n\t\t\t\tCase \"-makedocs\" m_makedocs = True\n\t\t\t\tCase \"-force\" m_forceinstall = True\n\t\t\t\tDefault ThrowCommonError(mxOptErrors.UNKNOWN, opt.GetName())\n\t\t\tEnd Select\n\t\tNext\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Check for version conflictions and warn the user.\n\t\treturns: True if the installtion should continue, or False if the user halted the operation.\n\tEnd Rem\n\tMethod CheckVersions:Int()\n\t\t'For Local instmod:mxInstModule = EachIn m_instmap.ValueEnumerator()\n\t\t'\t' TODO\n\t\t'Next\n\t\tReturn True\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Check the dependencies for the modules to be installed.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod CheckDependencies:Int()\n\t\tLocal addlist:TListEx, nfounds:dObjectMap = New dObjectMap\n\t\tFor Local instmod:mxInstModule = EachIn m_instmap.ValueEnumerator()\n\t\t\tCheckModuleDependencies(instmod, nfounds)\n\t\tNext\n\t\tIf nfounds.Count() > 0\n\t\t\tlogger.LogError(_s(\"arg.install.notfound.instdeps\"))\n\t\t\tLocal a:String\n\t\t\tFor Local b:String = EachIn nfounds.ValueEnumerator()\n\t\t\t\ta:+ b + \" \"\n\t\t\tNext\n\t\t\ta = a[..a.Length - 1]\n\t\t\tlogger.LogMessage(\"~t\" + a)\n\t\t\tIf m_forceinstall\n\t\t\t\tm_nobuild = True\n\t\t\t\tLocal resp:String = Input(_s(\"arg.install.missingdeps\") + \" \").ToLower()\n\t\t\t\tIf resp = \"y\" Or resp = \"yes\"\n\t\t\t\t\tReturn True\n\t\t\t\tEnd If\n\t\t\tEnd If\n\t\t\tReturn False\n\t\tEnd If\n\t\tReturn True\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Check the dependencies for the given module and adapt the install list accordingly.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod CheckModuleDependencies(instmod:mxInstModule, nfounds:dObjectMap)\n\t\tLocal addlist:TListEx = instmod.CheckCompliance()\n\t\tIf addlist\n\t\t\tFor Local modid:String = EachIn addlist\n\t\t\t\tIf Not m_depcheckmap._Contains(modid)\n\t\t\t\t\tLocal dmodul:mxModule = mainapp.m_sourceshandler.GetModuleWithID(modid)\n\t\t\t\t\tm_depcheckmap._Insert(modid, modid)\n\t\t\t\t\tIf dmodul\n\t\t\t\t\t\tIf Not m_instmap._Contains(modid)\n\t\t\t\t\t\t\tLocal dinstmod:mxInstModule = New mxInstModule.Create(modid, dmodul)\n\t\t\t\t\t\t\tIf instmod.GetVersionName().ToLower() = \"dev\"\n\t\t\t\t\t\t\t\tdinstmod.SetVersionFromName(\"dev\")\n\t\t\t\t\t\t\tElse\n\t\t\t\t\t\t\t\tdinstmod.SetVersion(Null)\n\t\t\t\t\t\t\tEnd If\n\t\t\t\t\t\t\tm_instmap._Insert(modid, dinstmod)\n\t\t\t\t\t\t\tCheckModuleDependencies(dinstmod, nfounds)\n\t\t\t\t\t\tEnd If\n\t\t\t\t\tElse\n\t\t\t\t\t\tnfounds._Insert(modid, modid)\n\t\t\t\t\tEnd If\n\t\t\t\tEnd If\n\t\t\tNext\n\t\tEnd If\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Do the actual installing.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod DoInstall()\n\t\tIf m_instmap.Count() > 0\n\t\t\tLocal a:String, instmod:mxInstModule\n\t\t\tlogger.LogMessage(_s(\"arg.install.modulestoinstall\"))\n\t\t\tFor instmod = EachIn m_instmap.ValueEnumerator()\n\t\t\t\ta:+ instmod.GetVerID() + \" \"\n\t\t\tNext\n\t\t\ta = a[..a.Length - 1]\n\t\t\tlogger.LogMessage(\"~t\" + a)\n\t\t\tLocal resp:String = Input(_s(\"arg.install.continuewithinstall\") + \" \").ToLower()\n\t\t\tIf resp = \"y\" Or resp = \"yes\"\n\t\t\t\tFor instmod = EachIn m_instmap.ValueEnumerator()\n\t\t\t\t\tinstmod.FetchSourceArchive()\n\t\t\t\tNext\n\t\t\t\tIf Not m_nounpack\n\t\t\t\t\tFor instmod = EachIn m_instmap.ValueEnumerator()\n\t\t\t\t\t\tinstmod.Unpack()\n\t\t\t\t\tNext\n\t\t\t\tElse\n\t\t\t\t\tlogger.LogMessage(_s(\"message.skipping.unpack\"))\n\t\t\t\tEnd If\n\t\t\t\tIf Not m_keeptemp Then DeleteDir(\"tmp\/\", True)\n\t\t\t\tIf Not m_nobuild\n\t\t\t\t\tLocal scopes:dObjectMap = New dObjectMap\n\t\t\t\t\tFor instmod = EachIn m_instmap.ValueEnumerator()\n\t\t\t\t\t\tscopes._Insert(instmod.GetModuleScope(), instmod.GetModuleScope())\n\t\t\t\t\tNext\n\t\t\t\t\tFor Local scope:String = EachIn scopes.ValueEnumerator()\n\t\t\t\t\t\tIf mxBMKUtils.MakeMods(scope, m_nothreaded ~ 1) <> 0\n\t\t\t\t\t\t\tThrowError(_s(\"error.install.build\", [scope]))\n\t\t\t\t\t\tEnd If\n\t\t\t\t\tNext\n\t\t\t\t\tIf m_makedocs\n\t\t\t\t\t\t'For instmod = EachIn m_instmap.ValueEnumerator()\n\t\t\t\t\t\t'\tmxModUtils.DocMods(instmod.GetID())\n\t\t\t\t\t\t'Next\n\t\t\t\t\t\t' Can't build docs for individual modules yet\n\t\t\t\t\t\tmxModUtils.DocMods()\n\t\t\t\t\tEnd If\n\t\t\t\tElse\n\t\t\t\t\tlogger.LogMessage(_s(\"message.skipping.install\"))\n\t\t\t\tEnd If\n\t\t\tEnd If\n\t\tElse\n\t\t\tlogger.LogMessage(_s(\"arg.install.nomodulestoinstall\"))\n\t\tEnd If\n\tEnd Method\n\t\nEnd Type\n\nRem\n\tbbdoc: Maximus install info module.\n\tabout: This type is used for temporary install information on modules.\nEnd Rem\nType mxInstModule\n\t\n\tField m_id:String\n\tField m_version:mxModuleVersion\n\tField m_module:mxModule\n\t\n\tRem\n\t\tbbdoc: Create a new mxInstModule.\n\t\treturns: Itself.\n\tEnd Rem\n\tMethod Create:mxInstModule(verid:String, modul:mxModule)\n\t\tSetID(mxModUtils.GetIDFromVerID(verid))\n\t\tSetModule(modul)\n\t\tReturn Self\n\tEnd Method\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the modid to be installed.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetID(id:String)\n\t\tm_id = id\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the modid to be installed.\n\t\treturns: The modid to be installed.\n\tEnd Rem\n\tMethod GetID:String()\n\t\tReturn m_id\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the version from the given versioned-module name (e.g. \"foo.bar\/1.02\").\n\t\treturns: True if the version was set, or False if the version could not be found (was not found).\n\t\tabout: The latest version will be set if the given id is Null (or if it isn't versioned (e.g. \"foo.bar\", would result in the latest version being selected)).\n\tEnd Rem\n\tMethod SetVersionFromVerID:Int(verid:String)\n\t\tReturn SetVersionFromName(mxModUtils.GetVersionFromVerID(verid))\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the version to be installed from the given version name (e.g. \"1.02\").\n\t\treturns: True if the version was set, or False if the version could not be set (was not found).\n\t\tabout: The latest version will be set if the given name is Null.\n\tEnd Rem\n\tMethod SetVersionFromName:Int(name:String)\n\t\tIf Not name\n\t\t\tSetVersion(Null) ' Set the latest version (the version wasn't forced)\n\t\t\tReturn True\n\t\tElse\n\t\t\tLocal ver:mxModuleVersion = m_module.GetVersionWithName(name)\n\t\t\tIf ver\n\t\t\t\tSetVersion(ver)\n\t\t\t\tReturn True\n\t\t\tEnd If\n\t\tEnd If\n\t\tReturn False\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the install version.\n\t\treturns: Nothing.\n\t\tabout: If the given value is Null, it will be automatically set to the latest (non-development) version.\n\tEnd Rem\n\tMethod SetVersion(version:mxModuleVersion)\n\t\tm_version = version\n\t\tIf Not m_version\n\t\t\tm_version = m_module.GetLatestVersion()\n\t\tEnd If\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the install version.\n\t\treturns: The version to be installed.\n\tEnd Rem\n\tMethod GetVersion:mxModuleVersion()\n\t\tReturn m_version\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the module to be installed.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetModule(modul:mxModule)\n\t\tm_module = modul\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the module to be installed.\n\t\treturns: The module to be installed.\n\tEnd Rem\n\tMethod GetModule:mxModule()\n\t\tReturn m_module\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the module's scope.\n\t\treturns: The module's scope.\n\tEnd Rem\n\tMethod GetModuleScope:String()\n\t\tReturn mxModUtils.GetScopeFromID(m_id)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the module's name.\n\t\treturns: The module's name.\n\tEnd Rem\n\tMethod GetModuleName:String()\n\t\tReturn mxModUtils.GetNameFromID(m_id)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the versioned-module id.\n\t\treturns: The exact module to be installed (e.g. \"foo.bar\/1.02\").\n\tEnd Rem\n\tMethod GetVerID:String()\n\t\tReturn m_id + \"\/\" + m_version.GetName()\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the name of the version to be installed.\n\t\treturns: The name of the version to be installed.\n\tEnd Rem\n\tMethod GetVersionName:String()\n\t\tReturn m_version.GetName()\n\tEnd Method\n\t\n'#end region Field accessors\n\t\n\tRem\n\t\tbbdoc: Check the dependency compliance of the current module set.\n\t\treturns: Null if all dependencies are matched by existing modules, or a list of module ids that are not yet installed.\n\tEnd Rem\n\tMethod CheckCompliance:TListEx()\n\t\tReturn m_version.GetDependencies().CheckCompliance()\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Fetch the source archive for the version to be installed.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod FetchSourceArchive()\n\t\tm_version.FetchSourceArchive()\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Unpack the version's archive.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod Unpack()\n\t\tLocal archivepath:String = m_version.GetTemporaryFilePath()\n\t\tLocal zreader:ZipReader = New ZipReader\n\t\tlogger.LogMessage(_s(\"message.unpacking\", [archivepath]))\n\t\tIf zreader.OpenZip(archivepath)\n\t\t\tLocal filename:String, outputpath:String\n\t\t\tLocal basepath:String = mainapp.m_modpath + \"\/\" + mxModUtils.GetScopeFromID(m_id) + \".mod\/\"\n\t\t\tFor Local fileinfo:SZipFileEntry = EachIn zreader.m_zipFileList.FileList\n\t\t\t\tfilename = fileinfo.zipFileName\n\t\t\t\toutputpath = basepath + filename\n\t\t\t\t'DebugLog(\"Zip outputpath: ~q\" + outputpath + \"~q\")\n\t\t\t\tIf filename[filename.Length - 1] = 47 ' \"\/\"\n\t\t\t\t\tCreateDir(outputpath, True)\n\t\t\t\tElse\n\t\t\t\t\tIf CreateFileExplicitly(outputpath)\n\t\t\t\t\t\tzreader.ExtractFileToDisk(filename, outputpath, False)\n\t\t\t\t\tElse\n\t\t\t\t\t\tzreader.CloseZip()\n\t\t\t\t\t\tThrowError(_s(\"error.writeperms\", [outputpath]))\n\t\t\t\t\tEnd If\n\t\t\t\tEnd If\n\t\t\tNext\n\t\t\tzreader.CloseZip()\n\n\t\t\tLocal metafile:mxMetaFile = New mxMetaFile.Create(basepath + GetModuleName() + \".mod\/meta.maximus\")\n\t\t\tmetafile.SetMetaData(GetModuleScope(), GetModuleName(), GetVersionName())\n\t\t\tmetafile.Save()\n\t\tElse\n\t\t\tThrowError(_s(\"error.install.openarchive\", [archivepath]))\n\t\tEnd If\n\tEnd Method\n\t\nEnd Type\n\n","old_contents":"\nRem\n\tbbdoc: Maximus 'install' argument implementation.\nEnd Rem\nType mxInstallImpl Extends dArgumentImplementation\n\t\n\tField m_instmap:dObjectMap\n\tField m_depcheckmap:dObjectMap\n\tField m_nobuild:Int = False, m_nounpack:Int = False, m_keeptemp:Int = False\n\tField m_nothreaded:Int = False, m_makedocs:Int = False, m_forceinstall:Int = False\n\t\n\tMethod New()\n\t\tinit([\"install\"])\n\t\tm_instmap = New dObjectMap\n\t\tm_depcheckmap = New dObjectMap\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Check the current arguments for errors (according to the specific implementation).\n\t\treturns: Nothing.\n\t\tabout: This method will throw an error if the arguments are invalid.\n\tEnd Rem\n\tMethod CheckArgs()\n\t\tIf GetArgumentCount() = 0\n\t\t\tThrowCommonError(mxCmdErrors.REQUIRESPARAMS, m_args.GetName())\n\t\tEnd If\n\t\tCheckOptions()\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get a string describing the typical usage of the argument.\n\t\treturns: A string describing the typical usage of the argument.\n\tEnd Rem\n\tMethod GetUsage:String()\n\t\tReturn _s(\"arg.install.usage\")\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Execute the implementation's operation.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod Execute()\n\t\tm_instmap.Clear()\n\t\tm_depcheckmap.Clear()\n\t\tIf mainapp.m_sourceshandler\n\t\t\tLocal nfounds:dObjectMap = New dObjectMap\n\t\t\tFor Local svar:dStringVariable = EachIn m_args\n\t\t\t\tLocal verid:String = svar.Get(), modid:String = mxModUtils.GetIDFromVerID(verid)\n\t\t\t\tLocal modul:mxModule = mainapp.m_sourceshandler.GetModuleWithID(modid)\n\t\t\t\tIf modul\n\t\t\t\t\tLocal instmod:mxInstModule = New mxInstModule.Create(verid, modul)\n\t\t\t\t\tIf instmod.SetVersionFromVerID(verid)\n\t\t\t\t\t\tm_instmap._Insert(modid, instmod)\n\t\t\t\t\tElse\n\t\t\t\t\t\tThrowError(_s(\"arg.install.notfound.version\", [modid, mxModUtils.GetVersionFromVerID(verid)]))\n\t\t\t\t\tEnd If\n\t\t\t\tElse\n\t\t\t\t\tnfounds._Insert(modid, modid)\n\t\t\t\tEnd If\n\t\t\tNext\n\t\t\tIf nfounds.Count() > 0\n\t\t\t\tlogger.LogError(_s(\"arg.install.notfound.instmods\"))\n\t\t\t\tLocal a:String\n\t\t\t\tFor Local b:String = EachIn nfounds.ValueEnumerator()\n\t\t\t\t\ta:+ b + \" \"\n\t\t\t\tNext\n\t\t\t\ta = a[..a.Length - 1]\n\t\t\t\tlogger.LogMessage(\"~t\" + a)\n\t\t\t\tReturn\n\t\t\tEnd If\n\t\t\tIf CheckDependencies()\n\t\t\t\tIf CheckVersions()\n\t\t\t\t\tDoInstall()\n\t\t\t\tEnd If\n\t\t\tEnd If\n\t\tElse\n\t\t\tThrowError(_s(\"error.install.nosources\"))\n\t\tEnd If\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Check the options given to the command.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod CheckOptions()\n\t\tm_nobuild = False; m_nounpack = False; m_keeptemp = False\n\t\tm_nothreaded = False; m_makedocs = False\n\t\tFor Local opt:dIdentifier = EachIn m_args\n\t\t\tSelect opt.GetName().ToLower()\n\t\t\t\tCase \"-nobuild\" m_nobuild = True\n\t\t\t\tCase \"-nounpack\" m_nounpack = True\n\t\t\t\tCase \"-keeptemp\" m_keeptemp = True\n\t\t\t\tCase \"-nothreaded\" m_nothreaded = True\n\t\t\t\tCase \"-makedocs\" m_makedocs = True\n\t\t\t\tCase \"-force\" m_forceinstall = True\n\t\t\t\tDefault ThrowCommonError(mxOptErrors.UNKNOWN, opt.GetName())\n\t\t\tEnd Select\n\t\tNext\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Check for version conflictions and warn the user.\n\t\treturns: True if the installtion should continue, or False if the user halted the operation.\n\tEnd Rem\n\tMethod CheckVersions:Int()\n\t\t'For Local instmod:mxInstModule = EachIn m_instmap.ValueEnumerator()\n\t\t'\t' TODO\n\t\t'Next\n\t\tReturn True\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Check the dependencies for the modules to be installed.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod CheckDependencies:Int()\n\t\tLocal addlist:TListEx, nfounds:dObjectMap = New dObjectMap\n\t\tFor Local instmod:mxInstModule = EachIn m_instmap.ValueEnumerator()\n\t\t\tCheckModuleDependencies(instmod, nfounds)\n\t\tNext\n\t\tIf nfounds.Count() > 0\n\t\t\tlogger.LogError(_s(\"arg.install.notfound.instdeps\"))\n\t\t\tLocal a:String\n\t\t\tFor Local b:String = EachIn nfounds.ValueEnumerator()\n\t\t\t\ta:+ b + \" \"\n\t\t\tNext\n\t\t\ta = a[..a.Length - 1]\n\t\t\tlogger.LogMessage(\"~t\" + a)\n\t\t\tIf m_forceinstall\n\t\t\t\tm_nobuild = True\n\t\t\t\tLocal resp:String = Input(_s(\"arg.install.missingdeps\") + \" \").ToLower()\n\t\t\t\tIf resp = \"y\" Or resp = \"yes\"\n\t\t\t\t\tReturn True\n\t\t\t\tEnd If\n\t\t\tEnd If\n\t\t\tReturn False\n\t\tEnd If\n\t\tReturn True\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Check the dependencies for the given module and adapt the install list accordingly.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod CheckModuleDependencies(instmod:mxInstModule, nfounds:dObjectMap)\n\t\tLocal addlist:TListEx = instmod.CheckCompliance()\n\t\tIf addlist\n\t\t\tFor Local modid:String = EachIn addlist\n\t\t\t\tIf Not m_depcheckmap._Contains(modid)\n\t\t\t\t\tLocal dmodul:mxModule = mainapp.m_sourceshandler.GetModuleWithID(modid)\n\t\t\t\t\tm_depcheckmap._Insert(modid, modid)\n\t\t\t\t\tIf dmodul\n\t\t\t\t\t\tIf Not m_instmap._Contains(modid)\n\t\t\t\t\t\t\tLocal dinstmod:mxInstModule = New mxInstModule.Create(modid, dmodul)\n\t\t\t\t\t\t\tIf instmod.GetVersionName().ToLower() = \"dev\"\n\t\t\t\t\t\t\t\tdinstmod.SetVersionFromName(\"dev\")\n\t\t\t\t\t\t\tElse\n\t\t\t\t\t\t\t\tdinstmod.SetVersion(Null)\n\t\t\t\t\t\t\tEnd If\n\t\t\t\t\t\t\tm_instmap._Insert(modid, dinstmod)\n\t\t\t\t\t\t\tCheckModuleDependencies(dinstmod, nfounds)\n\t\t\t\t\t\tEnd If\n\t\t\t\t\tElse\n\t\t\t\t\t\tnfounds._Insert(modid, modid)\n\t\t\t\t\tEnd If\n\t\t\t\tEnd If\n\t\t\tNext\n\t\tEnd If\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Do the actual installing.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod DoInstall()\n\t\tIf m_instmap.Count() > 0\n\t\t\tLocal a:String, instmod:mxInstModule\n\t\t\tlogger.LogMessage(_s(\"arg.install.modulestoinstall\"))\n\t\t\tFor instmod = EachIn m_instmap.ValueEnumerator()\n\t\t\t\ta:+ instmod.GetVerID() + \" \"\n\t\t\tNext\n\t\t\ta = a[..a.Length - 1]\n\t\t\tlogger.LogMessage(\"~t\" + a)\n\t\t\tLocal resp:String = Input(_s(\"arg.install.continuewithinstall\") + \" \").ToLower()\n\t\t\tIf resp = \"y\" Or resp = \"yes\"\n\t\t\t\tFor instmod = EachIn m_instmap.ValueEnumerator()\n\t\t\t\t\tinstmod.FetchSourceArchive()\n\t\t\t\tNext\n\t\t\t\tIf Not m_nounpack\n\t\t\t\t\tFor instmod = EachIn m_instmap.ValueEnumerator()\n\t\t\t\t\t\tinstmod.Unpack()\n\t\t\t\t\tNext\n\t\t\t\tElse\n\t\t\t\t\tlogger.LogMessage(_s(\"message.skipping.unpack\"))\n\t\t\t\tEnd If\n\t\t\t\tIf Not m_keeptemp Then DeleteDir(\"tmp\/\", True)\n\t\t\t\tIf Not m_nobuild\n\t\t\t\t\tLocal scopes:dObjectMap = New dObjectMap\n\t\t\t\t\tFor instmod = EachIn m_instmap.ValueEnumerator()\n\t\t\t\t\t\tscopes._Insert(instmod.GetModuleScope(), instmod.GetModuleScope())\n\t\t\t\t\tNext\n\t\t\t\t\tFor Local scope:String = EachIn scopes.ValueEnumerator()\n\t\t\t\t\t\tIf mxBMKUtils.MakeMods(scope, m_nothreaded ~ 1) <> 0\n\t\t\t\t\t\t\tThrowError(_s(\"error.install.build\", [scope]))\n\t\t\t\t\t\tEnd If\n\t\t\t\t\tNext\n\t\t\t\t\tIf m_makedocs\n\t\t\t\t\t\t'For instmod = EachIn m_instmap.ValueEnumerator()\n\t\t\t\t\t\t'\tmxModUtils.DocMods(instmod.GetID())\n\t\t\t\t\t\t'Next\n\t\t\t\t\t\t' Can't build docs for individual modules yet\n\t\t\t\t\t\tmxModUtils.DocMods()\n\t\t\t\t\tEnd If\n\t\t\t\tElse\n\t\t\t\t\tlogger.LogMessage(_s(\"message.skipping.install\"))\n\t\t\t\tEnd If\n\t\t\tEnd If\n\t\tElse\n\t\t\tlogger.LogMessage(_s(\"arg.install.nomodulestoinstall\"))\n\t\tEnd If\n\tEnd Method\n\t\nEnd Type\n\nRem\n\tbbdoc: Maximus install info module.\n\tabout: This type is used for temporary install information on modules.\nEnd Rem\nType mxInstModule\n\t\n\tField m_id:String\n\tField m_version:mxModuleVersion\n\tField m_module:mxModule\n\t\n\tRem\n\t\tbbdoc: Create a new mxInstModule.\n\t\treturns: Itself.\n\tEnd Rem\n\tMethod Create:mxInstModule(verid:String, modul:mxModule)\n\t\tSetID(mxModUtils.GetIDFromVerID(verid))\n\t\tSetModule(modul)\n\t\tReturn Self\n\tEnd Method\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the modid to be installed.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetID(id:String)\n\t\tm_id = id\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the modid to be installed.\n\t\treturns: The modid to be installed.\n\tEnd Rem\n\tMethod GetID:String()\n\t\tReturn m_id\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the version from the given versioned-module name (e.g. \"foo.bar\/1.02\").\n\t\treturns: True if the version was set, or False if the version could not be found (was not found).\n\t\tabout: The latest version will be set if the given id is Null (or if it isn't versioned (e.g. \"foo.bar\", would result in the latest version being selected)).\n\tEnd Rem\n\tMethod SetVersionFromVerID:Int(verid:String)\n\t\tReturn SetVersionFromName(mxModUtils.GetVersionFromVerID(verid))\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the version to be installed from the given version name (e.g. \"1.02\").\n\t\treturns: True if the version was set, or False if the version could not be set (was not found).\n\t\tabout: The latest version will be set if the given name is Null.\n\tEnd Rem\n\tMethod SetVersionFromName:Int(name:String)\n\t\tIf Not name\n\t\t\tSetVersion(Null) ' Set the latest version (the version wasn't forced)\n\t\t\tReturn True\n\t\tElse\n\t\t\tLocal ver:mxModuleVersion = m_module.GetVersionWithName(name)\n\t\t\tIf ver\n\t\t\t\tSetVersion(ver)\n\t\t\t\tReturn True\n\t\t\tEnd If\n\t\tEnd If\n\t\tReturn False\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the install version.\n\t\treturns: Nothing.\n\t\tabout: If the given value is Null, it will be automatically set to the latest (non-development) version.\n\tEnd Rem\n\tMethod SetVersion(version:mxModuleVersion)\n\t\tm_version = version\n\t\tIf Not m_version\n\t\t\tm_version = m_module.GetLatestVersion()\n\t\tEnd If\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the install version.\n\t\treturns: The version to be installed.\n\tEnd Rem\n\tMethod GetVersion:mxModuleVersion()\n\t\tReturn m_version\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the module to be installed.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetModule(modul:mxModule)\n\t\tm_module = modul\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the module to be installed.\n\t\treturns: The module to be installed.\n\tEnd Rem\n\tMethod GetModule:mxModule()\n\t\tReturn m_module\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the module's scope.\n\t\treturns: The module's scope.\n\tEnd Rem\n\tMethod GetModuleScope:String()\n\t\tReturn mxModUtils.GetScopeFromID(m_id)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the module's name.\n\t\treturns: The module's name.\n\tEnd Rem\n\tMethod GetModuleName:String()\n\t\tReturn mxModUtils.GetNameFromID(m_id)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the versioned-module id.\n\t\treturns: The exact module to be installed (e.g. \"foo.bar\/1.02\").\n\tEnd Rem\n\tMethod GetVerID:String()\n\t\tReturn m_id + \"\/\" + m_version.GetName()\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the name of the version to be installed.\n\t\treturns: The name of the version to be installed.\n\tEnd Rem\n\tMethod GetVersionName:String()\n\t\tReturn m_version.GetName()\n\tEnd Method\n\t\n'#end region Field accessors\n\t\n\tRem\n\t\tbbdoc: Check the dependency compliance of the current module set.\n\t\treturns: Null if all dependencies are matched by existing modules, or a list of module ids that are not yet installed.\n\tEnd Rem\n\tMethod CheckCompliance:TListEx()\n\t\tReturn m_version.GetDependencies().CheckCompliance()\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Fetch the source archive for the version to be installed.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod FetchSourceArchive()\n\t\tm_version.FetchSourceArchive()\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Unpack the version's archive.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod Unpack()\n\t\tLocal archivepath:String = m_version.GetTemporaryFilePath()\n\t\tLocal zreader:ZipReader = New ZipReader\n\t\tlogger.LogMessage(_s(\"message.unpacking\", [archivepath]))\n\t\tIf zreader.OpenZip(archivepath)\n\t\t\tLocal filename:String, outputpath:String\n\t\t\tFor Local fileinfo:SZipFileEntry = EachIn zreader.m_zipFileList.FileList\n\t\t\t\tfilename = fileinfo.zipFileName\n\t\t\t\toutputpath = mainapp.m_modpath + \"\/\" + mxModUtils.GetScopeFromID(m_id) + \".mod\/\" + filename\n\t\t\t\t'DebugLog(\"Zip outputpath: ~q\" + outputpath + \"~q\")\n\t\t\t\tIf filename[filename.Length - 1] = 47 ' \"\/\"\n\t\t\t\t\tCreateDir(outputpath, True)\n\t\t\t\tElse\n\t\t\t\t\tIf CreateFileExplicitly(outputpath)\n\t\t\t\t\t\tzreader.ExtractFileToDisk(filename, outputpath, False)\n\t\t\t\t\tElse\n\t\t\t\t\t\tzreader.CloseZip()\n\t\t\t\t\t\tThrowError(_s(\"error.writeperms\", [outputpath]))\n\t\t\t\t\tEnd If\n\t\t\t\tEnd If\n\t\t\tNext\n\t\t\tzreader.CloseZip()\n\t\tElse\n\t\t\tThrowError(_s(\"error.install.openarchive\", [archivepath]))\n\t\tEnd If\n\tEnd Method\n\t\nEnd Type\n\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"02f1c1e37c3aff0484f96d9f93acf7bfaa2238ed","subject":"Played with collisions.","message":"Played with collisions.\n","repos":"kfprimm\/maxb3d,kfprimm\/maxb3d","old_file":"b3dcollision.mod\/b3dcollision.bmx","new_file":"b3dcollision.mod\/b3dcollision.bmx","new_contents":"\nStrict\n\nRem\n\tbbdoc: Provides Blitz3D-style collision detection\/handling.\nEnd Rem\nModule MaxB3D.B3DCollision\nModuleInfo \"Author: Kevin Primm\"\nModuleInfo \"License: MIT\"\n\nImport MaxB3D.Core\n\nType TB3DCollisionDriver Extends TCollisionDriver\n\tMethod Update(config:TWorldConfig, speed#)\n\t\tGlobal c_vec_a:Byte Ptr=C_CreateVecObject(0.0,0.0,0.0)\n\t\tGlobal c_vec_b:Byte Ptr=C_CreateVecObject(0.0,0.0,0.0)\n\t\tGlobal c_vec_radius:Byte Ptr=C_CreateVecObject(0.0,0.0,0.0)\n\t\t\t\t\t\t\t\n\t\tGlobal c_vec_i:Byte Ptr=C_CreateVecObject(0.0,0.0,0.0)\n\t\tGlobal c_vec_j:Byte Ptr=C_CreateVecObject(0.0,0.0,0.0)\n\t\tGlobal c_vec_k:Byte Ptr=C_CreateVecObject(0.0,0.0,0.0)\n\t\n\t\tGlobal c_mat:Byte Ptr=C_CreateMatrixObject(c_vec_i,c_vec_j,c_vec_k)\n\t\t\t\t\t\n\t\tGlobal c_vec_v:Byte Ptr=C_CreateVecObject(0.0,0.0,0.0)\n\t\t\n\t\tGlobal c_tform:Byte Ptr=C_CreateTFormObject(c_mat,c_vec_v)\n\t\tFor Local i=0 To MAX_COLLISION_TYPES-1\n\t\t\tIf config.CollisionType[i]=Null Then Continue\n\t\t\tFor Local entity:TEntity=EachIn config.CollisionType[i]\n\t\t\t\tentity._collision=Null\n\t\t\n\t\t\t\tIf entity.GetVisible()=False Continue\n\t\t\t\t\n\t\t\t\tLocal x#,y#,z#\n\t\t\t\tentity.GetPosition x,y,z,True\n\t\t\t\tC_UpdateVecObject(c_vec_a,x,y,z)\n\t\t\t\tC_UpdateVecObject(c_vec_b,entity._oldx,entity._oldy,entity._oldz)\n\t\t\t\tC_UpdateVecObject(c_vec_radius,entity._radiusx,entity._radiusy,entity._radiusx)\n\t\n\t\t\t\tLocal c_col_info:Byte Ptr=C_CreateCollisionInfoObject(c_vec_a,c_vec_b,c_vec_radius)\t\n\t\t\t\tLocal c_coll:Byte Ptr=Null\n\t\n\t\t\t\tLocal response\n\t\t\t\tRepeat\t\n\t\t\t\t\tLocal hit=False\t\t\n\t\t\t\t\tc_coll=C_CreateCollisionObject()\t\n\t\t\t\t\tLocal entity2_hit:TEntity=Null\t\t\t\t\t\n\t\t\t\t\tFor Local col_pair:TCollisionPair=EachIn config.CollisionPairs\t\t\t\t\t\n\t\t\t\t\t\tIf col_pair.src=i\n\t\t\t\t\t\t\tIf config.CollisionType[col_pair.dest]=Null Then Continue\n\t\t\t\t\t\t\n\t\t\t\t\t\t\tFor Local entity2:TEntity=EachIn config.CollisionType[col_pair.dest]\n\t\t\t\t\t\t\t\tIf entity2.GetVisible()=False Then Continue\t\t\t\t\n\t\t\t\t\t\t\t\tIf entity=entity2 Then Continue\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\tIf QuickCheck(entity,entity2)=False Then Continue\n\t\t\t\n\t\t\t\t\t\t\t\tC_UpdateVecObject(c_vec_i,entity2._matrix._m[0,0],entity2._matrix._m[0,1],-entity2._matrix._m[0,2])\n\t\t\t\t\t\t\t\tC_UpdateVecObject(c_vec_j,entity2._matrix._m[1,0],entity2._matrix._m[1,1],-entity2._matrix._m[1,2])\n\t\t\t\t\t\t\t\tC_UpdateVecObject(c_vec_k,-entity2._matrix._m[2,0],-entity2._matrix._m[2,1],entity2._matrix._m[2,2])\n\t\t\t\t\t\t\n\t\t\t\t\t\t\t\tC_UpdateMatrixObject(c_mat,c_vec_i,c_vec_j,c_vec_k)\n\t\t\t\t\t\t\t\tC_UpdateVecObject(c_vec_v,entity2._matrix._m[3,0],entity2._matrix._m[3,1],entity2._matrix._m[3,2])\n\t\t\t\t\t\t\t\tC_UpdateTFormObject(c_tform,c_mat,c_vec_v)\n\t\t\t\n\t\t\t\t\t\t\t\tIf col_pair.methd<>COLLISION_METHOD_POLYGON\n\t\t\t\t\t\t\t\t\tC_UpdateCollisionInfoObject(c_col_info,entity2._radiusx,entity2._boxx,entity2._boxy,entity2._boxz,entity2._boxx+entity2._boxwidth,entity2._boxy+entity2._boxheight,entity2._boxz+entity2._boxdepth)\n\t\t\t\t\t\t\t\tEndIf\n\t\t\t\t\t\n\t\t\t\t\t\t\t\tLocal tree:Byte Ptr\n\t\t\t\t\t\t\t\tIf TMesh(entity2)<>Null tree=TMesh(entity2).TreeCheck()\n\t\t\t\n\t\t\t\t\t\t\t\thit=C_CollisionDetect(c_col_info,c_coll,c_tform,tree,col_pair.methd)\n\t\t\t\n\t\t\t\t\t\t\t\tIf hit Then entity2_hit=entity2;response=col_pair.response\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tNext\t\t\t\t\t\t\n\t\t\t\t\t\tEndIf\t\t\t\t\t\n\t\t\t\t\tNext\n\t\t\t\t\t\n\t\t\t\t\tIf entity2_hit<>Null\t\t\n\t\t\t\t\t\tLocal collision:TCollision=New TCollision\n\t\t\t\t\t\tcollision.x=C_CollisionX()\n\t\t\t\t\t\tcollision.y=C_CollisionY()\n\t\t\t\t\t\tcollision.z=C_CollisionZ()\n\t\t\t\t\t\tcollision.nx=C_CollisionNX()\n\t\t\t\t\t\tcollision.ny=C_CollisionNY()\n\t\t\t\t\t\tcollision.nz=C_CollisionNZ()\n\t\t\t\t\t\tcollision.entity=entity2_hit\n\t\t\t\t\t\tcollision.triangle=C_CollisionTriangle()\t\t\t\t\t\t\n\t\t\t\t\t\tIf TMesh(entity2_hit)<>Null collision.surface=C_CollisionSurface()\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\tentity._collision=entity._collision[..entity._collision.length+1]\n\t\t\t\t\t\tentity._collision[entity._collision.length-1]=collision\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\tIf C_CollisionResponse(c_col_info,c_coll,response)=False Then Exit\t\t\t\t\t\t\n\t\t\t\t\tElse\t\t\t\t\n\t\t\t\t\t\tExit\t\t\t\t\t\t\t\t\n\t\t\t\t\tEndIf\t\t\t\t\n\t\t\t\t\tC_DeleteCollisionObject(c_coll)\t\t\t\t\t\t\t\t\t\n\t\t\t\tForever\n\t\n\t\t\t\tC_DeleteCollisionObject(c_coll)\t\n\t\t\t\tIf C_CollisionFinal(c_col_info) entity.SetPosition(C_CollisionPosX(),C_CollisionPosY(),C_CollisionPosZ(),True)\t\t\n\t\t\t\tC_DeleteCollisionInfoObject(c_col_info)\t\t\n\t\t\t\tentity.GetPosition entity._oldx,entity._oldy,entity._oldz,True\n\t\t\tNext\t\t\t\t\t\t\t\t\t\t\n\t\tNext\t\n\tEnd Method\n\t\n\tFunction QuickCheck(entity:TEntity,entity2:TEntity)\n\t\tLocal x#,y#,z#\n\t\tentity.GetPosition x,y,z,True\n\t\tIf entity._oldx=x And entity._oldy=y And entity._oldz=z Return False\n\t\tReturn True\t\n\tEnd Function\nEnd Type\n\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction B3DCollisionDriver:TB3DCollisionDriver()\n\tGlobal _driver:TB3DCollisionDriver=New TB3DCollisionDriver\n\tReturn _driver\t\nEnd Function\n\nB3DCollisionDriver()\n","old_contents":"\nStrict\n\nRem\n\tbbdoc: Provides Blitz3D-style collision detection\/handling.\nEnd Rem\nModule MaxB3D.B3DCollision\nModuleInfo \"Author: Kevin Primm\"\nModuleInfo \"License: MIT\"\n\nImport MaxB3D.Core\n\nType TB3DCollisionDriver Extends TCollisionDriver\n\tMethod Update(config:TWorldConfig, speed#)\n\t\tGlobal c_vec_a:Byte Ptr=C_CreateVecObject(0.0,0.0,0.0)\n\t\tGlobal c_vec_b:Byte Ptr=C_CreateVecObject(0.0,0.0,0.0)\n\t\tGlobal c_vec_radius:Byte Ptr=C_CreateVecObject(0.0,0.0,0.0)\n\t\t\t\t\t\t\t\n\t\tGlobal c_vec_i:Byte Ptr=C_CreateVecObject(0.0,0.0,0.0)\n\t\tGlobal c_vec_j:Byte Ptr=C_CreateVecObject(0.0,0.0,0.0)\n\t\tGlobal c_vec_k:Byte Ptr=C_CreateVecObject(0.0,0.0,0.0)\n\t\n\t\tGlobal c_mat:Byte Ptr=C_CreateMatrixObject(c_vec_i,c_vec_j,c_vec_k)\n\t\t\t\t\t\n\t\tGlobal c_vec_v:Byte Ptr=C_CreateVecObject(0.0,0.0,0.0)\n\t\t\n\t\tGlobal c_tform:Byte Ptr=C_CreateTFormObject(c_mat,c_vec_v)\n\t\tFor Local i=0 To MAX_COLLISION_TYPES-1\n\t\t\tIf config.CollisionType[i]=Null Then Continue\n\t\t\tFor Local entity:TEntity=EachIn config.CollisionType[i]\n\t\t\t\tentity._collision=Null\n\t\t\n\t\t\t\tIf entity.GetVisible()=False Continue\n\t\t\t\t\n\t\t\t\tLocal x#,y#,z#\n\t\t\t\tentity.GetPosition x,y,z,True\n\t\t\t\tC_UpdateVecObject(c_vec_a,x,y,z)\n\t\t\t\tC_UpdateVecObject(c_vec_b,entity._oldx,entity._oldy,entity._oldz)\n\t\t\t\tC_UpdateVecObject(c_vec_radius,entity._radiusx,entity._radiusy,entity._radiusx)\n\t\n\t\t\t\tLocal c_col_info:Byte Ptr=C_CreateCollisionInfoObject(c_vec_a,c_vec_b,c_vec_radius)\t\n\t\t\t\tLocal c_coll:Byte Ptr=Null\n\t\n\t\t\t\tLocal response\n\t\t\t\tRepeat\t\n\t\t\t\t\tLocal hit=False\t\t\n\t\t\t\t\tc_coll=C_CreateCollisionObject()\t\n\t\t\t\t\tLocal entity2_hit:TEntity=Null\t\t\t\t\t\n\t\t\t\t\tFor Local col_pair:TCollisionPair=EachIn config.CollisionPairs\t\t\t\t\t\n\t\t\t\t\t\tIf col_pair.src=i\n\t\t\t\t\t\t\tIf config.CollisionType[col_pair.dest]=Null Then Continue\n\t\t\t\t\t\t\n\t\t\t\t\t\t\tFor Local entity2:TEntity=EachIn config.CollisionType[col_pair.dest]\n\t\t\t\t\t\t\t\tIf entity2.GetVisible()=False Then Continue\t\t\t\t\n\t\t\t\t\t\t\t\tIf entity=entity2 Then Continue\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\tIf QuickCheck(entity,entity2)=False Then Continue\n\t\t\t\n\t\t\t\t\t\t\t\tC_UpdateVecObject(c_vec_i,entity2._matrix._m[0,0],entity2._matrix._m[0,1],-entity2._matrix._m[0,2])\n\t\t\t\t\t\t\t\tC_UpdateVecObject(c_vec_j,entity2._matrix._m[1,0],entity2._matrix._m[1,1],-entity2._matrix._m[1,2])\n\t\t\t\t\t\t\t\tC_UpdateVecObject(c_vec_k,-entity2._matrix._m[2,0],-entity2._matrix._m[2,1],entity2._matrix._m[2,2])\n\t\t\t\t\t\t\n\t\t\t\t\t\t\t\tC_UpdateMatrixObject(c_mat,c_vec_i,c_vec_j,c_vec_k)\n\t\t\t\t\t\t\t\tC_UpdateVecObject(c_vec_v,entity2._matrix._m[3,0],entity2._matrix._m[3,1],-entity2._matrix._m[3,2])\n\t\t\t\t\t\t\t\tC_UpdateTFormObject(c_tform,c_mat,c_vec_v)\n\t\t\t\n\t\t\t\t\t\t\t\tIf col_pair.methd<>COLLISION_METHOD_POLYGON\n\t\t\t\t\t\t\t\t\tC_UpdateCollisionInfoObject(c_col_info,entity2._radiusx,entity2._boxx,entity2._boxy,entity2._boxz,entity2._boxx+entity2._boxwidth,entity2._boxy+entity2._boxheight,entity2._boxz+entity2._boxdepth)\n\t\t\t\t\t\t\t\tEndIf\n\t\t\t\t\t\n\t\t\t\t\t\t\t\tLocal tree:Byte Ptr\n\t\t\t\t\t\t\t\tIf TMesh(entity2)<>Null tree=TMesh(entity2).TreeCheck()\n\t\t\t\n\t\t\t\t\t\t\t\thit=C_CollisionDetect(c_col_info,c_coll,c_tform,tree,col_pair.methd)\n\t\t\t\n\t\t\t\t\t\t\t\tIf hit Then entity2_hit=entity2;response=col_pair.response\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tNext\t\t\t\t\t\t\n\t\t\t\t\t\tEndIf\t\t\t\t\t\n\t\t\t\t\tNext\n\t\t\t\t\t\n\t\t\t\t\tIf entity2_hit<>Null\t\t\n\t\t\t\t\t\tLocal collision:TCollision=New TCollision\n\t\t\t\t\t\tcollision.x=C_CollisionX()\n\t\t\t\t\t\tcollision.y=C_CollisionY()\n\t\t\t\t\t\tcollision.z=C_CollisionZ()\n\t\t\t\t\t\tcollision.nx=C_CollisionNX()\n\t\t\t\t\t\tcollision.ny=C_CollisionNY()\n\t\t\t\t\t\tcollision.nz=C_CollisionNZ()\n\t\t\t\t\t\tcollision.entity=entity2_hit\n\t\t\t\t\t\tcollision.triangle=C_CollisionTriangle()\t\t\t\t\t\t\n\t\t\t\t\t\tIf TMesh(entity2_hit)<>Null collision.surface=C_CollisionSurface()\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\tentity._collision=entity._collision[..entity._collision.length+1]\n\t\t\t\t\t\tentity._collision[entity._collision.length-1]=collision\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\tIf C_CollisionResponse(c_col_info,c_coll,response)=False Then Exit\t\t\t\t\t\t\n\t\t\t\t\tElse\t\t\t\t\n\t\t\t\t\t\tExit\t\t\t\t\t\t\t\t\n\t\t\t\t\tEndIf\t\t\t\t\n\t\t\t\t\tC_DeleteCollisionObject(c_coll)\t\t\t\t\t\t\t\t\t\n\t\t\t\tForever\n\t\n\t\t\t\tC_DeleteCollisionObject(c_coll)\t\n\t\t\t\tIf C_CollisionFinal(c_col_info) entity.SetPosition(C_CollisionPosX(),C_CollisionPosY(),C_CollisionPosZ(),True)\t\t\n\t\t\t\tC_DeleteCollisionInfoObject(c_col_info)\t\t\n\t\t\t\tentity.GetPosition entity._oldx,entity._oldy,entity._oldz,True\n\t\t\tNext\t\t\t\t\t\t\t\t\t\t\n\t\tNext\t\n\tEnd Method\n\t\n\tFunction QuickCheck(entity:TEntity,entity2:TEntity)\n\t\tLocal x#,y#,z#\n\t\tentity.GetPosition x,y,z,True\n\t\tIf entity._oldx=x And entity._oldy=y And entity._oldz=z Return False\n\t\tReturn True\t\n\tEnd Function\nEnd Type\n\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction B3DCollisionDriver:TB3DCollisionDriver()\n\tGlobal _driver:TB3DCollisionDriver=New TB3DCollisionDriver\n\tReturn _driver\t\nEnd Function\n\nB3DCollisionDriver()","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"90e91c1f70b32816fce30b57e7d7d7aa241c4363","subject":"Reset all install options before setting them","message":"Reset all install options before setting them\n\nrefs gh-17, gh-18\n","repos":"maximos\/maximus","old_file":"src\/impl\/install.bmx","new_file":"src\/impl\/install.bmx","new_contents":"\nRem\n\tbbdoc: Maximus 'install' argument implementation.\nEnd Rem\nType mxInstallImpl Extends dArgumentImplementation\n\t\n\tField m_instmap:dObjectMap\n\tField m_depcheckmap:dObjectMap\n\tField m_unmanagedmap:dObjectMap\n\tField m_nobuild:Int = False, m_nounpack:Int = False, m_keeptemp:Int = False\n\tField m_nothreaded:Int = False, m_makedocs:Int = False, m_forceinstall:Int = False\n\tField m_overwriteunmanaged:Int = False\n\t\n\tMethod New()\n\t\tinit([\"install\"])\n\t\tm_instmap = New dObjectMap\n\t\tm_depcheckmap = New dObjectMap\n\t\tm_unmanagedmap = New dObjectMap\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Check the current arguments for errors (according to the specific implementation).\n\t\treturns: Nothing.\n\t\tabout: This method will throw an error if the arguments are invalid.\n\tEnd Rem\n\tMethod CheckArgs()\n\t\tIf GetArgumentCount() = 0\n\t\t\tThrowCommonError(mxCmdErrors.REQUIRESPARAMS, m_args.GetName())\n\t\tEnd If\n\t\tCheckOptions()\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get a string describing the typical usage of the argument.\n\t\treturns: A string describing the typical usage of the argument.\n\tEnd Rem\n\tMethod GetUsage:String()\n\t\tReturn _s(\"arg.install.usage\")\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Execute the implementation's operation.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod Execute()\n\t\tm_instmap.Clear()\n\t\tm_depcheckmap.Clear()\n\t\tm_unmanagedmap.Clear()\n\t\tIf mainapp.m_sourceshandler\n\t\t\tLocal nfounds:dObjectMap = New dObjectMap\n\t\t\tFor Local svar:dStringVariable = EachIn m_args\n\t\t\t\tLocal verid:String = svar.Get(), modid:String = mxModUtils.GetIDFromVerID(verid)\n\t\t\t\tLocal modul:mxModule = mainapp.m_sourceshandler.GetModuleWithID(modid)\n\t\t\t\tIf modul\n\t\t\t\t\tLocal instmod:mxInstModule = New mxInstModule.Create(verid, modul)\n\t\t\t\t\tIf instmod.SetVersionFromVerID(verid)\n\t\t\t\t\t\tm_instmap._Insert(modid, instmod)\n\t\t\t\t\tElse\n\t\t\t\t\t\tThrowError(_s(\"arg.install.notfound.version\", [modid, mxModUtils.GetVersionFromVerID(verid)]))\n\t\t\t\t\tEnd If\n\t\t\t\tElse\n\t\t\t\t\tnfounds._Insert(modid, modid)\n\t\t\t\tEnd If\n\t\t\tNext\n\t\t\tIf nfounds.Count() > 0\n\t\t\t\tlogger.LogError(_s(\"arg.install.notfound.instmods\"))\n\t\t\t\tLocal a:String\n\t\t\t\tFor Local b:String = EachIn nfounds.ValueEnumerator()\n\t\t\t\t\ta:+ b + \" \"\n\t\t\t\tNext\n\t\t\t\ta = a[..a.Length - 1]\n\t\t\t\tlogger.LogMessage(\"~t\" + a)\n\t\t\t\tReturn\n\t\t\tEnd If\n\t\t\tIf CheckDependencies()\n\t\t\t\t'Make sure we only install\/update managed modules\n\t\t\t\tIf CheckVersions()\n\t\t\t\t\tDoInstall()\n\t\t\t\tEnd If\n\t\t\tEnd If\n\t\tElse\n\t\t\tThrowError(_s(\"error.install.nosources\"))\n\t\tEnd If\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Check the options given to the command.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod CheckOptions()\n\t\tm_nobuild = False; m_nounpack = False; m_keeptemp = False\n\t\tm_nothreaded = False; m_makedocs = False; m_forceinstall = False; m_overwriteunmanaged = False\n\t\tFor Local opt:dIdentifier = EachIn m_args\n\t\t\tSelect opt.GetName().ToLower()\n\t\t\t\tCase \"-nobuild\" m_nobuild = True\n\t\t\t\tCase \"-nounpack\" m_nounpack = True\n\t\t\t\tCase \"-keeptemp\" m_keeptemp = True\n\t\t\t\tCase \"-nothreaded\" m_nothreaded = True\n\t\t\t\tCase \"-makedocs\" m_makedocs = True\n\t\t\t\tCase \"-force\" m_forceinstall = True\n\t\t\t\tCase \"-overwriteunmanaged\" m_overwriteunmanaged = True\n\t\t\t\tDefault ThrowCommonError(mxOptErrors.UNKNOWN, opt.GetName())\n\t\t\tEnd Select\n\t\tNext\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Check for version conflictions and warn the user.\n\t\treturns: True if the installtion should continue, or False if the user halted the operation.\n\tEnd Rem\n\tMethod CheckVersions:Int()\n\t\tFor Local instmod:mxInstModule = EachIn m_instmap.ValueEnumerator()\n\t\t\tLocal ver:String = mxModUtils.GetInstalledVersionFromVerID(instmod.GetVerID())\n\t\t\t'Make sure we skip unmanaged modules\n\t\t\tIf ver = \"unmanaged\"\n\t\t\t\tIf Not m_overwriteunmanaged Then m_instmap._Remove(instmod.GetID())\n\t\t\t\tm_unmanagedmap._Insert(instmod.GetID(), instmod)\n\t\t\tEnd If\n\t\tNext\n\t\tReturn True\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Check the dependencies for the modules to be installed.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod CheckDependencies:Int()\n\t\tLocal nfounds:dObjectMap = New dObjectMap\n\t\tFor Local instmod:mxInstModule = EachIn m_instmap.ValueEnumerator()\n\t\t\tCheckModuleDependencies(instmod, nfounds)\n\t\tNext\n\t\tIf nfounds.Count() > 0\n\t\t\tlogger.LogError(_s(\"arg.install.notfound.instdeps\"))\n\t\t\tLocal a:String\n\t\t\tFor Local b:String = EachIn nfounds.ValueEnumerator()\n\t\t\t\ta:+ b + \" \"\n\t\t\tNext\n\t\t\ta = a[..a.Length - 1]\n\t\t\tlogger.LogMessage(\"~t\" + a)\n\t\t\tIf m_forceinstall\n\t\t\t\tm_nobuild = True\n\t\t\t\tIf mainapp.m_userinput.Confirm(_s(\"arg.install.missingdeps\"))\n\t\t\t\t\tReturn True\n\t\t\t\tEnd If\n\t\t\tEnd If\n\t\t\tReturn False\n\t\tEnd If\n\t\tReturn True\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Check the dependencies for the given module and adapt the install list accordingly.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod CheckModuleDependencies(instmod:mxInstModule, nfounds:dObjectMap)\n\t\tLocal addlist:TListEx = instmod.CheckCompliance()\n\t\tIf addlist\n\t\t\tFor Local modid:String = EachIn addlist\n\t\t\t\tIf Not m_depcheckmap._Contains(modid)\n\t\t\t\t\tLocal dmodul:mxModule = mainapp.m_sourceshandler.GetModuleWithID(modid)\n\t\t\t\t\tm_depcheckmap._Insert(modid, modid)\n\t\t\t\t\tIf dmodul\n\t\t\t\t\t\tIf Not m_instmap._Contains(modid)\n\t\t\t\t\t\t\tLocal dinstmod:mxInstModule = New mxInstModule.Create(modid, dmodul)\n\t\t\t\t\t\t\tIf instmod.GetVersionName().ToLower() = \"dev\"\n\t\t\t\t\t\t\t\tdinstmod.SetVersionFromName(\"dev\")\n\t\t\t\t\t\t\tElse\n\t\t\t\t\t\t\t\tdinstmod.SetVersion(Null)\n\t\t\t\t\t\t\tEnd If\n\t\t\t\t\t\t\tm_instmap._Insert(modid, dinstmod)\n\t\t\t\t\t\t\tCheckModuleDependencies(dinstmod, nfounds)\n\t\t\t\t\t\tEnd If\n\t\t\t\t\tElse\n\t\t\t\t\t\tnfounds._Insert(modid, modid)\n\t\t\t\t\tEnd If\n\t\t\t\tEnd If\n\t\t\tNext\n\t\tEnd If\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Do the actual installing.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod DoInstall()\n\t\tIf m_instmap.Count() > 0\n\t\t\tLocal a:String, instmod:mxInstModule\n\n\t\t\tIf m_unmanagedmap.Count()\n\t\t\t\tIf m_overwriteunmanaged\n\t\t\t\t\tlogger.LogMessage(_s(\"arg.install.modulestooverwrite\"))\n\t\t\t\tElse\n\t\t\t\t\tlogger.LogMessage(_s(\"arg.install.modulestoskip\"))\n\t\t\t\tEnd If\n\t\t\t\tFor instmod = EachIn m_unmanagedmap.ValueEnumerator()\n\t\t\t\t\ta:+instmod.GetVerID() + \" \"\n\t\t\t\tNext\n\t\t\t\ta = a[..a.Length - 1]\n\t\t\t\tlogger.LogMessage(\"~t\" + a)\n\t\t\t\ta = \"\"\n\t\t\tEnd If\n\n\t\t\tlogger.LogMessage(_s(\"arg.install.modulestoinstall\"))\n\t\t\tFor instmod = EachIn m_instmap.ValueEnumerator()\n\t\t\t\ta:+ instmod.GetVerID() + \" \"\n\t\t\tNext\n\t\t\ta = a[..a.Length - 1]\n\t\t\tlogger.LogMessage(\"~t\" + a)\n\t\t\tIf mainapp.m_userinput.Confirm(_s(\"arg.install.continuewithinstall\"))\n\t\t\t\tFor instmod = EachIn m_instmap.ValueEnumerator()\n\t\t\t\t\tinstmod.FetchSourceArchive()\n\t\t\t\tNext\n\t\t\t\tIf Not m_nounpack\n\t\t\t\t\tFor instmod = EachIn m_instmap.ValueEnumerator()\n\t\t\t\t\t\tinstmod.Unpack()\n\t\t\t\t\tNext\n\t\t\t\tElse\n\t\t\t\t\tlogger.LogMessage(_s(\"message.skipping.unpack\"))\n\t\t\t\tEnd If\n\t\t\t\tIf Not m_keeptemp Then DeleteDir(\"tmp\/\", True)\n\t\t\t\tIf Not m_nobuild\n\t\t\t\t\tLocal scopes:dObjectMap = New dObjectMap\n\t\t\t\t\tFor instmod = EachIn m_instmap.ValueEnumerator()\n\t\t\t\t\t\tscopes._Insert(instmod.GetModuleScope(), instmod.GetModuleScope())\n\t\t\t\t\tNext\n\t\t\t\t\tFor Local scope:String = EachIn scopes.ValueEnumerator()\n\t\t\t\t\t\tIf mxBMKUtils.MakeMods(scope, m_nothreaded ~ 1) <> 0\n\t\t\t\t\t\t\tThrowError(_s(\"error.install.build\", [scope]))\n\t\t\t\t\t\tEnd If\n\t\t\t\t\tNext\n\t\t\t\t\tIf m_makedocs\n\t\t\t\t\t\t'For instmod = EachIn m_instmap.ValueEnumerator()\n\t\t\t\t\t\t'\tmxModUtils.DocMods(instmod.GetID())\n\t\t\t\t\t\t'Next\n\t\t\t\t\t\t' Can't build docs for individual modules yet\n\t\t\t\t\t\tmxModUtils.DocMods()\n\t\t\t\t\tEnd If\n\t\t\t\tElse\n\t\t\t\t\tlogger.LogMessage(_s(\"message.skipping.install\"))\n\t\t\t\tEnd If\n\t\t\tEnd If\n\t\tElse\n\t\t\tlogger.LogMessage(_s(\"arg.install.nomodulestoinstall\"))\n\t\t\tIf m_unmanagedmap.Count()\n\t\t\t\tlogger.LogMessage(_s(\"arg.install.modulestoskip\"))\n\t\t\t\tLocal a:String\n\t\t\t\tFor Local instmod:mxInstModule = EachIn m_unmanagedmap.ValueEnumerator()\n\t\t\t\t\ta:+instmod.GetVerID() + \" \"\n\t\t\t\tNext\n\t\t\t\ta = a[..a.Length - 1]\n\t\t\t\tlogger.LogMessage(\"~t\" + a)\n\t\t\tEnd If\n\t\tEnd If\n\tEnd Method\n\t\nEnd Type\n\nRem\n\tbbdoc: Maximus install info module.\n\tabout: This type is used for temporary install information on modules.\nEnd Rem\nType mxInstModule\n\t\n\tField m_id:String\n\tField m_version:mxModuleVersion\n\tField m_module:mxModule\n\t\n\tRem\n\t\tbbdoc: Create a new mxInstModule.\n\t\treturns: Itself.\n\tEnd Rem\n\tMethod Create:mxInstModule(verid:String, modul:mxModule)\n\t\tSetID(mxModUtils.GetIDFromVerID(verid))\n\t\tSetModule(modul)\n\t\tReturn Self\n\tEnd Method\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the modid to be installed.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetID(id:String)\n\t\tm_id = id\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the modid to be installed.\n\t\treturns: The modid to be installed.\n\tEnd Rem\n\tMethod GetID:String()\n\t\tReturn m_id\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the version from the given versioned-module name (e.g. \"foo.bar\/1.02\").\n\t\treturns: True if the version was set, or False if the version could not be found (was not found).\n\t\tabout: The latest version will be set if the given id is Null (or if it isn't versioned (e.g. \"foo.bar\", would result in the latest version being selected)).\n\tEnd Rem\n\tMethod SetVersionFromVerID:Int(verid:String)\n\t\tReturn SetVersionFromName(mxModUtils.GetVersionFromVerID(verid))\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the version to be installed from the given version name (e.g. \"1.02\").\n\t\treturns: True if the version was set, or False if the version could not be set (was not found).\n\t\tabout: The latest version will be set if the given name is Null.\n\tEnd Rem\n\tMethod SetVersionFromName:Int(name:String)\n\t\tIf Not name\n\t\t\tSetVersion(Null) ' Set the latest version (the version wasn't forced)\n\t\t\tReturn True\n\t\tElse\n\t\t\tLocal ver:mxModuleVersion = m_module.GetVersionWithName(name)\n\t\t\tIf ver\n\t\t\t\tSetVersion(ver)\n\t\t\t\tReturn True\n\t\t\tEnd If\n\t\tEnd If\n\t\tReturn False\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the install version.\n\t\treturns: Nothing.\n\t\tabout: If the given value is Null, it will be automatically set to the latest (non-development) version.\n\tEnd Rem\n\tMethod SetVersion(version:mxModuleVersion)\n\t\tm_version = version\n\t\tIf Not m_version\n\t\t\tm_version = m_module.GetLatestVersion()\n\t\tEnd If\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the install version.\n\t\treturns: The version to be installed.\n\tEnd Rem\n\tMethod GetVersion:mxModuleVersion()\n\t\tReturn m_version\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the module to be installed.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetModule(modul:mxModule)\n\t\tm_module = modul\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the module to be installed.\n\t\treturns: The module to be installed.\n\tEnd Rem\n\tMethod GetModule:mxModule()\n\t\tReturn m_module\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the module's scope.\n\t\treturns: The module's scope.\n\tEnd Rem\n\tMethod GetModuleScope:String()\n\t\tReturn mxModUtils.GetScopeFromID(m_id)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the module's name.\n\t\treturns: The module's name.\n\tEnd Rem\n\tMethod GetModuleName:String()\n\t\tReturn mxModUtils.GetNameFromID(m_id)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the versioned-module id.\n\t\treturns: The exact module to be installed (e.g. \"foo.bar\/1.02\").\n\tEnd Rem\n\tMethod GetVerID:String()\n\t\tReturn m_id + \"\/\" + m_version.GetName()\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the name of the version to be installed.\n\t\treturns: The name of the version to be installed.\n\tEnd Rem\n\tMethod GetVersionName:String()\n\t\tReturn m_version.GetName()\n\tEnd Method\n\t\n'#end region Field accessors\n\t\n\tRem\n\t\tbbdoc: Check the dependency compliance of the current module set.\n\t\treturns: Null if all dependencies are matched by existing modules, or a list of module ids that are not yet installed.\n\tEnd Rem\n\tMethod CheckCompliance:TListEx()\n\t\tReturn m_version.GetDependencies().CheckCompliance()\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Fetch the source archive for the version to be installed.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod FetchSourceArchive()\n\t\tm_version.FetchSourceArchive()\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Unpack the version's archive.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod Unpack()\n\t\tLocal archivepath:String = m_version.GetTemporaryFilePath()\n\t\tLocal zreader:ZipReader = New ZipReader\n\t\tlogger.LogMessage(_s(\"message.unpacking\", [archivepath]))\n\t\tIf zreader.OpenZip(archivepath)\n\t\t\tLocal filename:String, outputpath:String\n\t\t\tLocal basepath:String = mainapp.m_modpath + \"\/\" + mxModUtils.GetScopeFromID(m_id) + \".mod\/\"\n\t\t\tDeleteDir(mxModUtils.ModulePath(m_id), True)\n\t\t\tFor Local fileinfo:SZipFileEntry = EachIn zreader.m_zipFileList.FileList\n\t\t\t\tfilename = fileinfo.zipFileName\n\t\t\t\toutputpath = basepath + filename\n\t\t\t\t'DebugLog(\"Zip outputpath: ~q\" + outputpath + \"~q\")\n\t\t\t\tIf filename[filename.Length - 1] = 47 ' \"\/\"\n\t\t\t\t\tCreateDir(outputpath, True)\n\t\t\t\tElse\n\t\t\t\t\tIf CreateFileExplicitly(outputpath)\n\t\t\t\t\t\tzreader.ExtractFileToDisk(filename, outputpath, False)\n\t\t\t\t\tElse\n\t\t\t\t\t\tzreader.CloseZip()\n\t\t\t\t\t\tThrowError(_s(\"error.writeperms\", [outputpath]))\n\t\t\t\t\tEnd If\n\t\t\t\tEnd If\n\t\t\tNext\n\t\t\tzreader.CloseZip()\n\n\t\t\tLocal metafile:mxMetaFile = New mxMetaFile.Create(basepath + GetModuleName() + \".mod\/meta.maximus\")\n\t\t\tmetafile.SetMetaData(GetModuleScope(), GetModuleName(), GetVersionName())\n\t\t\tmetafile.Save()\n\t\tElse\n\t\t\tThrowError(_s(\"error.install.openarchive\", [archivepath]))\n\t\tEnd If\n\tEnd Method\n\t\nEnd Type\n\n","old_contents":"\nRem\n\tbbdoc: Maximus 'install' argument implementation.\nEnd Rem\nType mxInstallImpl Extends dArgumentImplementation\n\t\n\tField m_instmap:dObjectMap\n\tField m_depcheckmap:dObjectMap\n\tField m_unmanagedmap:dObjectMap\n\tField m_nobuild:Int = False, m_nounpack:Int = False, m_keeptemp:Int = False\n\tField m_nothreaded:Int = False, m_makedocs:Int = False, m_forceinstall:Int = False\n\tField m_overwriteunmanaged:Int = False\n\t\n\tMethod New()\n\t\tinit([\"install\"])\n\t\tm_instmap = New dObjectMap\n\t\tm_depcheckmap = New dObjectMap\n\t\tm_unmanagedmap = New dObjectMap\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Check the current arguments for errors (according to the specific implementation).\n\t\treturns: Nothing.\n\t\tabout: This method will throw an error if the arguments are invalid.\n\tEnd Rem\n\tMethod CheckArgs()\n\t\tIf GetArgumentCount() = 0\n\t\t\tThrowCommonError(mxCmdErrors.REQUIRESPARAMS, m_args.GetName())\n\t\tEnd If\n\t\tCheckOptions()\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get a string describing the typical usage of the argument.\n\t\treturns: A string describing the typical usage of the argument.\n\tEnd Rem\n\tMethod GetUsage:String()\n\t\tReturn _s(\"arg.install.usage\")\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Execute the implementation's operation.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod Execute()\n\t\tm_instmap.Clear()\n\t\tm_depcheckmap.Clear()\n\t\tm_unmanagedmap.Clear()\n\t\tIf mainapp.m_sourceshandler\n\t\t\tLocal nfounds:dObjectMap = New dObjectMap\n\t\t\tFor Local svar:dStringVariable = EachIn m_args\n\t\t\t\tLocal verid:String = svar.Get(), modid:String = mxModUtils.GetIDFromVerID(verid)\n\t\t\t\tLocal modul:mxModule = mainapp.m_sourceshandler.GetModuleWithID(modid)\n\t\t\t\tIf modul\n\t\t\t\t\tLocal instmod:mxInstModule = New mxInstModule.Create(verid, modul)\n\t\t\t\t\tIf instmod.SetVersionFromVerID(verid)\n\t\t\t\t\t\tm_instmap._Insert(modid, instmod)\n\t\t\t\t\tElse\n\t\t\t\t\t\tThrowError(_s(\"arg.install.notfound.version\", [modid, mxModUtils.GetVersionFromVerID(verid)]))\n\t\t\t\t\tEnd If\n\t\t\t\tElse\n\t\t\t\t\tnfounds._Insert(modid, modid)\n\t\t\t\tEnd If\n\t\t\tNext\n\t\t\tIf nfounds.Count() > 0\n\t\t\t\tlogger.LogError(_s(\"arg.install.notfound.instmods\"))\n\t\t\t\tLocal a:String\n\t\t\t\tFor Local b:String = EachIn nfounds.ValueEnumerator()\n\t\t\t\t\ta:+ b + \" \"\n\t\t\t\tNext\n\t\t\t\ta = a[..a.Length - 1]\n\t\t\t\tlogger.LogMessage(\"~t\" + a)\n\t\t\t\tReturn\n\t\t\tEnd If\n\t\t\tIf CheckDependencies()\n\t\t\t\t'Make sure we only install\/update managed modules\n\t\t\t\tIf CheckVersions()\n\t\t\t\t\tDoInstall()\n\t\t\t\tEnd If\n\t\t\tEnd If\n\t\tElse\n\t\t\tThrowError(_s(\"error.install.nosources\"))\n\t\tEnd If\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Check the options given to the command.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod CheckOptions()\n\t\tm_nobuild = False; m_nounpack = False; m_keeptemp = False\n\t\tm_nothreaded = False; m_makedocs = False\n\t\tFor Local opt:dIdentifier = EachIn m_args\n\t\t\tSelect opt.GetName().ToLower()\n\t\t\t\tCase \"-nobuild\" m_nobuild = True\n\t\t\t\tCase \"-nounpack\" m_nounpack = True\n\t\t\t\tCase \"-keeptemp\" m_keeptemp = True\n\t\t\t\tCase \"-nothreaded\" m_nothreaded = True\n\t\t\t\tCase \"-makedocs\" m_makedocs = True\n\t\t\t\tCase \"-force\" m_forceinstall = True\n\t\t\t\tCase \"-overwriteunmanaged\" m_overwriteunmanaged = True\n\t\t\t\tDefault ThrowCommonError(mxOptErrors.UNKNOWN, opt.GetName())\n\t\t\tEnd Select\n\t\tNext\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Check for version conflictions and warn the user.\n\t\treturns: True if the installtion should continue, or False if the user halted the operation.\n\tEnd Rem\n\tMethod CheckVersions:Int()\n\t\tFor Local instmod:mxInstModule = EachIn m_instmap.ValueEnumerator()\n\t\t\tLocal ver:String = mxModUtils.GetInstalledVersionFromVerID(instmod.GetVerID())\n\t\t\t'Make sure we skip unmanaged modules\n\t\t\tIf ver = \"unmanaged\"\n\t\t\t\tIf Not m_overwriteunmanaged Then m_instmap._Remove(instmod.GetID())\n\t\t\t\tm_unmanagedmap._Insert(instmod.GetID(), instmod)\n\t\t\tEnd If\n\t\tNext\n\t\tReturn True\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Check the dependencies for the modules to be installed.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod CheckDependencies:Int()\n\t\tLocal nfounds:dObjectMap = New dObjectMap\n\t\tFor Local instmod:mxInstModule = EachIn m_instmap.ValueEnumerator()\n\t\t\tCheckModuleDependencies(instmod, nfounds)\n\t\tNext\n\t\tIf nfounds.Count() > 0\n\t\t\tlogger.LogError(_s(\"arg.install.notfound.instdeps\"))\n\t\t\tLocal a:String\n\t\t\tFor Local b:String = EachIn nfounds.ValueEnumerator()\n\t\t\t\ta:+ b + \" \"\n\t\t\tNext\n\t\t\ta = a[..a.Length - 1]\n\t\t\tlogger.LogMessage(\"~t\" + a)\n\t\t\tIf m_forceinstall\n\t\t\t\tm_nobuild = True\n\t\t\t\tIf mainapp.m_userinput.Confirm(_s(\"arg.install.missingdeps\"))\n\t\t\t\t\tReturn True\n\t\t\t\tEnd If\n\t\t\tEnd If\n\t\t\tReturn False\n\t\tEnd If\n\t\tReturn True\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Check the dependencies for the given module and adapt the install list accordingly.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod CheckModuleDependencies(instmod:mxInstModule, nfounds:dObjectMap)\n\t\tLocal addlist:TListEx = instmod.CheckCompliance()\n\t\tIf addlist\n\t\t\tFor Local modid:String = EachIn addlist\n\t\t\t\tIf Not m_depcheckmap._Contains(modid)\n\t\t\t\t\tLocal dmodul:mxModule = mainapp.m_sourceshandler.GetModuleWithID(modid)\n\t\t\t\t\tm_depcheckmap._Insert(modid, modid)\n\t\t\t\t\tIf dmodul\n\t\t\t\t\t\tIf Not m_instmap._Contains(modid)\n\t\t\t\t\t\t\tLocal dinstmod:mxInstModule = New mxInstModule.Create(modid, dmodul)\n\t\t\t\t\t\t\tIf instmod.GetVersionName().ToLower() = \"dev\"\n\t\t\t\t\t\t\t\tdinstmod.SetVersionFromName(\"dev\")\n\t\t\t\t\t\t\tElse\n\t\t\t\t\t\t\t\tdinstmod.SetVersion(Null)\n\t\t\t\t\t\t\tEnd If\n\t\t\t\t\t\t\tm_instmap._Insert(modid, dinstmod)\n\t\t\t\t\t\t\tCheckModuleDependencies(dinstmod, nfounds)\n\t\t\t\t\t\tEnd If\n\t\t\t\t\tElse\n\t\t\t\t\t\tnfounds._Insert(modid, modid)\n\t\t\t\t\tEnd If\n\t\t\t\tEnd If\n\t\t\tNext\n\t\tEnd If\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Do the actual installing.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod DoInstall()\n\t\tIf m_instmap.Count() > 0\n\t\t\tLocal a:String, instmod:mxInstModule\n\n\t\t\tIf m_unmanagedmap.Count()\n\t\t\t\tIf m_overwriteunmanaged\n\t\t\t\t\tlogger.LogMessage(_s(\"arg.install.modulestooverwrite\"))\n\t\t\t\tElse\n\t\t\t\t\tlogger.LogMessage(_s(\"arg.install.modulestoskip\"))\n\t\t\t\tEnd If\n\t\t\t\tFor instmod = EachIn m_unmanagedmap.ValueEnumerator()\n\t\t\t\t\ta:+instmod.GetVerID() + \" \"\n\t\t\t\tNext\n\t\t\t\ta = a[..a.Length - 1]\n\t\t\t\tlogger.LogMessage(\"~t\" + a)\n\t\t\t\ta = \"\"\n\t\t\tEnd If\n\n\t\t\tlogger.LogMessage(_s(\"arg.install.modulestoinstall\"))\n\t\t\tFor instmod = EachIn m_instmap.ValueEnumerator()\n\t\t\t\ta:+ instmod.GetVerID() + \" \"\n\t\t\tNext\n\t\t\ta = a[..a.Length - 1]\n\t\t\tlogger.LogMessage(\"~t\" + a)\n\t\t\tIf mainapp.m_userinput.Confirm(_s(\"arg.install.continuewithinstall\"))\n\t\t\t\tFor instmod = EachIn m_instmap.ValueEnumerator()\n\t\t\t\t\tinstmod.FetchSourceArchive()\n\t\t\t\tNext\n\t\t\t\tIf Not m_nounpack\n\t\t\t\t\tFor instmod = EachIn m_instmap.ValueEnumerator()\n\t\t\t\t\t\tinstmod.Unpack()\n\t\t\t\t\tNext\n\t\t\t\tElse\n\t\t\t\t\tlogger.LogMessage(_s(\"message.skipping.unpack\"))\n\t\t\t\tEnd If\n\t\t\t\tIf Not m_keeptemp Then DeleteDir(\"tmp\/\", True)\n\t\t\t\tIf Not m_nobuild\n\t\t\t\t\tLocal scopes:dObjectMap = New dObjectMap\n\t\t\t\t\tFor instmod = EachIn m_instmap.ValueEnumerator()\n\t\t\t\t\t\tscopes._Insert(instmod.GetModuleScope(), instmod.GetModuleScope())\n\t\t\t\t\tNext\n\t\t\t\t\tFor Local scope:String = EachIn scopes.ValueEnumerator()\n\t\t\t\t\t\tIf mxBMKUtils.MakeMods(scope, m_nothreaded ~ 1) <> 0\n\t\t\t\t\t\t\tThrowError(_s(\"error.install.build\", [scope]))\n\t\t\t\t\t\tEnd If\n\t\t\t\t\tNext\n\t\t\t\t\tIf m_makedocs\n\t\t\t\t\t\t'For instmod = EachIn m_instmap.ValueEnumerator()\n\t\t\t\t\t\t'\tmxModUtils.DocMods(instmod.GetID())\n\t\t\t\t\t\t'Next\n\t\t\t\t\t\t' Can't build docs for individual modules yet\n\t\t\t\t\t\tmxModUtils.DocMods()\n\t\t\t\t\tEnd If\n\t\t\t\tElse\n\t\t\t\t\tlogger.LogMessage(_s(\"message.skipping.install\"))\n\t\t\t\tEnd If\n\t\t\tEnd If\n\t\tElse\n\t\t\tlogger.LogMessage(_s(\"arg.install.nomodulestoinstall\"))\n\t\t\tIf m_unmanagedmap.Count()\n\t\t\t\tlogger.LogMessage(_s(\"arg.install.modulestoskip\"))\n\t\t\t\tLocal a:String\n\t\t\t\tFor Local instmod:mxInstModule = EachIn m_unmanagedmap.ValueEnumerator()\n\t\t\t\t\ta:+instmod.GetVerID() + \" \"\n\t\t\t\tNext\n\t\t\t\ta = a[..a.Length - 1]\n\t\t\t\tlogger.LogMessage(\"~t\" + a)\n\t\t\tEnd If\n\t\tEnd If\n\tEnd Method\n\t\nEnd Type\n\nRem\n\tbbdoc: Maximus install info module.\n\tabout: This type is used for temporary install information on modules.\nEnd Rem\nType mxInstModule\n\t\n\tField m_id:String\n\tField m_version:mxModuleVersion\n\tField m_module:mxModule\n\t\n\tRem\n\t\tbbdoc: Create a new mxInstModule.\n\t\treturns: Itself.\n\tEnd Rem\n\tMethod Create:mxInstModule(verid:String, modul:mxModule)\n\t\tSetID(mxModUtils.GetIDFromVerID(verid))\n\t\tSetModule(modul)\n\t\tReturn Self\n\tEnd Method\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the modid to be installed.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetID(id:String)\n\t\tm_id = id\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the modid to be installed.\n\t\treturns: The modid to be installed.\n\tEnd Rem\n\tMethod GetID:String()\n\t\tReturn m_id\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the version from the given versioned-module name (e.g. \"foo.bar\/1.02\").\n\t\treturns: True if the version was set, or False if the version could not be found (was not found).\n\t\tabout: The latest version will be set if the given id is Null (or if it isn't versioned (e.g. \"foo.bar\", would result in the latest version being selected)).\n\tEnd Rem\n\tMethod SetVersionFromVerID:Int(verid:String)\n\t\tReturn SetVersionFromName(mxModUtils.GetVersionFromVerID(verid))\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the version to be installed from the given version name (e.g. \"1.02\").\n\t\treturns: True if the version was set, or False if the version could not be set (was not found).\n\t\tabout: The latest version will be set if the given name is Null.\n\tEnd Rem\n\tMethod SetVersionFromName:Int(name:String)\n\t\tIf Not name\n\t\t\tSetVersion(Null) ' Set the latest version (the version wasn't forced)\n\t\t\tReturn True\n\t\tElse\n\t\t\tLocal ver:mxModuleVersion = m_module.GetVersionWithName(name)\n\t\t\tIf ver\n\t\t\t\tSetVersion(ver)\n\t\t\t\tReturn True\n\t\t\tEnd If\n\t\tEnd If\n\t\tReturn False\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the install version.\n\t\treturns: Nothing.\n\t\tabout: If the given value is Null, it will be automatically set to the latest (non-development) version.\n\tEnd Rem\n\tMethod SetVersion(version:mxModuleVersion)\n\t\tm_version = version\n\t\tIf Not m_version\n\t\t\tm_version = m_module.GetLatestVersion()\n\t\tEnd If\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the install version.\n\t\treturns: The version to be installed.\n\tEnd Rem\n\tMethod GetVersion:mxModuleVersion()\n\t\tReturn m_version\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the module to be installed.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetModule(modul:mxModule)\n\t\tm_module = modul\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the module to be installed.\n\t\treturns: The module to be installed.\n\tEnd Rem\n\tMethod GetModule:mxModule()\n\t\tReturn m_module\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the module's scope.\n\t\treturns: The module's scope.\n\tEnd Rem\n\tMethod GetModuleScope:String()\n\t\tReturn mxModUtils.GetScopeFromID(m_id)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the module's name.\n\t\treturns: The module's name.\n\tEnd Rem\n\tMethod GetModuleName:String()\n\t\tReturn mxModUtils.GetNameFromID(m_id)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the versioned-module id.\n\t\treturns: The exact module to be installed (e.g. \"foo.bar\/1.02\").\n\tEnd Rem\n\tMethod GetVerID:String()\n\t\tReturn m_id + \"\/\" + m_version.GetName()\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the name of the version to be installed.\n\t\treturns: The name of the version to be installed.\n\tEnd Rem\n\tMethod GetVersionName:String()\n\t\tReturn m_version.GetName()\n\tEnd Method\n\t\n'#end region Field accessors\n\t\n\tRem\n\t\tbbdoc: Check the dependency compliance of the current module set.\n\t\treturns: Null if all dependencies are matched by existing modules, or a list of module ids that are not yet installed.\n\tEnd Rem\n\tMethod CheckCompliance:TListEx()\n\t\tReturn m_version.GetDependencies().CheckCompliance()\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Fetch the source archive for the version to be installed.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod FetchSourceArchive()\n\t\tm_version.FetchSourceArchive()\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Unpack the version's archive.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod Unpack()\n\t\tLocal archivepath:String = m_version.GetTemporaryFilePath()\n\t\tLocal zreader:ZipReader = New ZipReader\n\t\tlogger.LogMessage(_s(\"message.unpacking\", [archivepath]))\n\t\tIf zreader.OpenZip(archivepath)\n\t\t\tLocal filename:String, outputpath:String\n\t\t\tLocal basepath:String = mainapp.m_modpath + \"\/\" + mxModUtils.GetScopeFromID(m_id) + \".mod\/\"\n\t\t\tDeleteDir(mxModUtils.ModulePath(m_id), True)\n\t\t\tFor Local fileinfo:SZipFileEntry = EachIn zreader.m_zipFileList.FileList\n\t\t\t\tfilename = fileinfo.zipFileName\n\t\t\t\toutputpath = basepath + filename\n\t\t\t\t'DebugLog(\"Zip outputpath: ~q\" + outputpath + \"~q\")\n\t\t\t\tIf filename[filename.Length - 1] = 47 ' \"\/\"\n\t\t\t\t\tCreateDir(outputpath, True)\n\t\t\t\tElse\n\t\t\t\t\tIf CreateFileExplicitly(outputpath)\n\t\t\t\t\t\tzreader.ExtractFileToDisk(filename, outputpath, False)\n\t\t\t\t\tElse\n\t\t\t\t\t\tzreader.CloseZip()\n\t\t\t\t\t\tThrowError(_s(\"error.writeperms\", [outputpath]))\n\t\t\t\t\tEnd If\n\t\t\t\tEnd If\n\t\t\tNext\n\t\t\tzreader.CloseZip()\n\n\t\t\tLocal metafile:mxMetaFile = New mxMetaFile.Create(basepath + GetModuleName() + \".mod\/meta.maximus\")\n\t\t\tmetafile.SetMetaData(GetModuleScope(), GetModuleName(), GetVersionName())\n\t\t\tmetafile.Save()\n\t\tElse\n\t\t\tThrowError(_s(\"error.install.openarchive\", [archivepath]))\n\t\tEnd If\n\tEnd Method\n\t\nEnd Type\n\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"82d0a5d0ee31342249164ed1c8120e2aeaccf904","subject":"Added Max path-getting (and error checking). Added SetArgs method to mxApp to handle Null arguments. Changed how mainapp was set to avoid a few errors.","message":"Added Max path-getting (and error checking). Added SetArgs method to mxApp to handle Null arguments. Changed how mainapp was set to avoid a few errors.\n","repos":"maximos\/maximus","old_file":"maximus.bmx","new_file":"maximus.bmx","new_contents":"\nRem\nCopyright (c) 2010 Tim Howard\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and\/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\nEnd Rem\n\nSuperStrict\n\nFramework brl.blitz\nImport brl.standardio\nImport brl.maxutil\nImport cower.jonk\nImport duct.objectmap\n\nInclude \"src\/logger.bmx\"\nInclude \"src\/errors.bmx\"\nInclude \"src\/arghandler.bmx\"\nInclude \"src\/impl\/help.bmx\"\nInclude \"src\/impl\/version.bmx\"\nInclude \"src\/sources.bmx\"\n\nGlobal logger:mxLogger = New mxLogger\nGlobal mainapp:mxApp\nNew mxApp.Create(AppArgs[1..]) ' Skip the first element because it is the program's location\nmainapp.Run()\n\nRem\n\tbbdoc: Maximus app.\n\tabout: This handles the basic flow of the program (initiation, parsing, command calling, exiting..)\nEnd Rem\nType mxApp\n\t\n\tConst c_version:String = \"0.01\"\n\t\n\tField m_maxpath:String\n\t\n\tField m_args:String[]\n\tField m_arghandler:mxArgumentHandler\n\t\n\tRem\n\t\tbbdoc: Create a new mxApp.\n\t\treturns: The new mxApp.\n\tEnd Rem\n\tMethod Create:mxApp(args:String[])\n\t\tmainapp = Self\n\t\tSetArgs(args)\n\t\tOnInit()\n\t\tReturn Self\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Called when the application is created.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod OnInit()\n\t\tTry\n\t\t\tm_maxpath = BlitzMaxPath()\n\t\tCatch e:Object\n\t\t\tThrowError(\"Unable to determine the path to BlitzMax!~nHave you set the 'BMXPATH' environment variable?\")\n\t\tEnd Try\n\t\tm_arghandler = New mxArgumentHandler\n\t\tm_arghandler.AddArgImpl(New mxHelpImpl)\n\t\tm_arghandler.AddArgImpl(New mxVersionImpl)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Called when the application is ended (this includes #ThrowError calls).\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod OnExit()\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Run the application.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod Run()\n\t\tLocal argimpl:mxArgumentImplementation\n\t\tLocal i:Int, arg:String, isopt:Int\n\t\tFor i = 0 To m_args.Length - 1\n\t\t\targ = m_args[i]\n\t\t\targimpl = m_arghandler.GetArgImplFromAlias(arg)\n\t\t\tisopt = arg.StartsWith(\"-\")\n\t\t\tIf argimpl <> Null\n\t\t\t\tIf isopt = True\n\t\t\t\t\targimpl.SetArgs(Null)\n\t\t\t\t\targimpl.SetCallConvention(mxCallConvention.OPTION)\n\t\t\t\t\targimpl.Execute()\n\t\t\t\tElse ' Must be a command (leaving out parameters for options, as that would get really complicated)\n\t\t\t\t\targimpl.SetCallConvention(mxCallConvention.COMMAND)\n\t\t\t\t\tParseCommandArgs(argimpl, m_args[i + 1..])\n\t\t\t\t\targimpl.Execute()\n\t\t\t\t\tExit\n\t\t\t\tEnd If\n\t\t\tElse\n\t\t\t\tIf isopt = True\n\t\t\t\t\tThrowCommonError(mxOptErrors.UNKNOWN, arg)\n\t\t\t\tElse\n\t\t\t\t\tThrowCommonError(mxCmdErrors.UNKNOWN, arg)\n\t\t\t\tEnd If\n\t\t\tEnd If\n\t\tNext\n\t\tOnExit()\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Parse command arguments.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod ParseCommandArgs(argimpl:mxArgumentImplementation, args:String[])\n\t\t' This will need to be parsed eventually, but for now..\n\t\targimpl.SetArgs(args)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the application's arguments.\n\t\treturns: Nothing.\n\t\tabout: NOTE: This will resolve to '--help' if the given args are Null.\n\tEnd Rem\n\tMethod SetArgs(args:String[])\n\t\tIf args = Null\n\t\t\targs = [\"--help\"]\n\t\tEnd If\n\t\tm_args = args\n\tEnd Method\n\t\nEnd Type\n\nRem\n\tbbdoc: Throw an error (terminating the application).\n\treturns: Nothing.\nEnd Rem\nFunction ThrowError(error:String)\n\tlogger.LogError(error)\n\tmainapp.OnExit()\n\tEnd\nEnd Function\n\n","old_contents":"\nRem\nCopyright (c) 2010 Tim Howard\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and\/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\nEnd Rem\n\nSuperStrict\n\nFramework brl.blitz\nImport brl.standardio\nImport cower.jonk\nImport duct.objectmap\n\nInclude \"src\/logger.bmx\"\nInclude \"src\/errors.bmx\"\nInclude \"src\/arghandler.bmx\"\nInclude \"src\/impl\/help.bmx\"\nInclude \"src\/impl\/version.bmx\"\nInclude \"src\/sources.bmx\"\n\nGlobal logger:mxLogger = New mxLogger\nGlobal mainapp:mxApp = New mxApp.Create(AppArgs[1..]) ' Skip the first element because it is the program's location\nmainapp.Run()\n\nRem\n\tbbdoc: Maximus app.\n\tabout: This handles the basic flow of the program (initiation, parsing, command calling, exiting..)\nEnd Rem\nType mxApp\n\t\n\tConst c_version:String = \"0.01\"\n\t\n\tField m_args:String[]\n\tField m_arghandler:mxArgumentHandler\n\t\n\tRem\n\t\tbbdoc: Create a new mxApp.\n\t\treturns: The new mxApp.\n\tEnd Rem\n\tMethod Create:mxApp(args:String[])\n\t\tm_args = args\n\t\tOnInit()\n\t\tReturn Self\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Called when the application is created.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod OnInit()\n\t\tm_arghandler = New mxArgumentHandler\n\t\tm_arghandler.AddArgImpl(New mxHelpImpl)\n\t\tm_arghandler.AddArgImpl(New mxVersionImpl)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Called when the application is ended (this includes #ThrowError calls).\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod OnExit()\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Run the application.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod Run()\n\t\tLocal argimpl:mxArgumentImplementation\n\t\tLocal i:Int, arg:String, isopt:Int\n\t\tFor i = 0 To m_args.Length - 1\n\t\t\targ = m_args[i]\n\t\t\targimpl = m_arghandler.GetArgImplFromAlias(arg)\n\t\t\tisopt = arg.StartsWith(\"-\")\n\t\t\tIf argimpl <> Null\n\t\t\t\tIf isopt = True\n\t\t\t\t\targimpl.SetArgs(Null)\n\t\t\t\t\targimpl.SetCallConvention(mxCallConvention.OPTION)\n\t\t\t\t\targimpl.Execute()\n\t\t\t\tElse ' Must be a command (leaving out parameters for options, as that would get really complicated)\n\t\t\t\t\targimpl.SetCallConvention(mxCallConvention.COMMAND)\n\t\t\t\t\tParseCommandArgs(argimpl, m_args[i + 1..])\n\t\t\t\t\targimpl.Execute()\n\t\t\t\t\tExit\n\t\t\t\tEnd If\n\t\t\tElse\n\t\t\t\tIf isopt = True\n\t\t\t\t\tThrowCommonError(mxOptErrors.UNKNOWN, arg)\n\t\t\t\tElse\n\t\t\t\t\tThrowCommonError(mxCmdErrors.UNKNOWN, arg)\n\t\t\t\tEnd If\n\t\t\tEnd If\n\t\tNext\n\t\tOnExit()\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Parse command arguments.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod ParseCommandArgs(argimpl:mxArgumentImplementation, args:String[])\n\t\t' This will need to be parsed eventually, but for now..\n\t\targimpl.SetArgs(args)\n\tEnd Method\n\t\nEnd Type\n\nRem\n\tbbdoc: Throw an error (terminating the application).\n\treturns: Nothing.\nEnd Rem\nFunction ThrowError(error:String)\n\tlogger.LogError(error)\n\tmainapp.OnExit()\n\tEnd\nEnd Function\n\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"84d40d373b140a4fbe6ead578f0dda77141730eb","subject":"Fixed some memory bugs when an empty array was returned fromm the server","message":"Fixed some memory bugs when an empty array was returned fromm the server\n\nCloses gh-4\nCloses gh-5\n","repos":"Htbaa\/xmlrpc.mod,Htbaa\/xmlrpc.mod,Htbaa\/xmlrpc.mod,Htbaa\/xmlrpc.mod,Htbaa\/xmlrpc.mod","old_file":"response.bmx","new_file":"response.bmx","new_contents":"Rem\n\tbbdoc: Exception for TXMLRPC_Response_Data\nEnd Rem\nType TXMLRPC_Response_Data_Exception Extends TXMLRPC_Exception\nEnd Type\n\nRem\n\tbbdoc: Data returned from XML-RPC server\nEnd Rem\nType TXMLRPC_Response_Data\n\tRem\n\t\tbbdoc: This field contains all data returned from a response. If a response value was given an ID it can be accessed by its ID. If not it can be accessed with an ID of 0..inf\n\tEnd Rem\n\tField data:TMap\n\t\n\tRem\n\t\tbbdoc: Create a TXMLRPC_Response_Data object by passing the response XML message and the output options.\n\tEnd Rem\n\tMethod Create:TXMLRPC_Response_Data(xmlMessage:String, options:Byte Ptr)\n\t\tLocal message:Byte Ptr = xmlMessage.ToCString()\n\t\tLocal request:Byte Ptr = XMLRPC_REQUEST_FromXML(message, 0, options)\n\n\t\tLocal el:Byte Ptr = XMLRPC_RequestGetData(request)\n\t\t\n\t\tSelf.data = TXMLRPC_Response_Data.IterateVector(el)\n\t\t\n\t\tMemFree(message)\n\n\t\tXMLRPC_RequestFree(request, 0)\n\t\tXMLRPC_Free(el)\n\t\t\t\t\n\t\tReturn Self\n\tEnd Method\n\n\tRem\n\t\tbbdoc: Iterate over an XMLRPC vector and add it to a TMap. Private function\n\tEnd Rem\t\n\tFunction IterateVector:TMap(el:Byte Ptr)\n\t\tLocal data:TMap = New TMap\n\n\t\tIf el\n\t\t\tIf XMLRPC_VectorSize(el) = 0\n\t\t\t\tLocal cStr:Byte Ptr = XMLRPC_GetValueID(el)\n\t\t\t\tLocal id:String = \"0\"\n\t\t\t\tIf cStr\n\t\t\t\t\tid = String.FromCString(cStr)\n\t\t\t\t\tXMLRPC_Free(cstr)\n\t\t\t\tEnd If\n\n\t\t\t\tdata.Insert(id, TXMLRPC_Value_Abstract.XMLRPC_To_BlizMax(el))\n\t\t\tElse\n\t\t\t\t'Rewind vector\n\t\t\t\tLocal itr:Byte Ptr = XMLRPC_VectorRewind(el)\n\t\t\t\tIf itr\n\t\t\t\t\tLocal dataCounter:Int = 0\n\t\t\t\t\tWhile itr\n\t\t\t\t\t\tLocal cStr:Byte Ptr = XMLRPC_GetValueID(itr)\n\t\t\t\t\t\tLocal id:String = String.FromCString(cStr)\n\t\t\t\t\t\t\n\t\t\t\t\t\tIf id.Length = 0\n\t\t\t\t\t\t\tid = String.FromInt(dataCounter)\n\t\t\t\t\t\t\tdataCounter:+1\n\t\t\t\t\t\tEnd If\n\t\n\t\t\t\t\t\tdata.Insert(id, TXMLRPC_Value_Abstract.XMLRPC_To_BlizMax(itr))\n\t\t\t\t\t\tXMLRPC_Free(cStr)\n\t\n\t\t\t\t\t\t'Next element\n\t\t\t\t\t\titr = XMLRPC_VectorNext(el)\n\t\t\t\t\tWend\n\t\t\t\tEnd If\n\t\t\tEnd If\n\t\tEnd If\n\t\t\n\t\tReturn data\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Helper function to show what's inside the map\n\tEnd Rem\n\tFunction DebugData:String(map:TMap, pad:Int Var)\n\t\tLocal str:String\n\t\tLocal prefix:String\n\t\tFor Local i:Int = 0 To pad\n\t\t\tprefix:+\"-\"\n\t\tNext\n\t\t\n\t\tIf map\t\n\t\t\tFor Local val:TXMLRPC_Value_Abstract = EachIn map.Values()\n\t\t\t\tstr:+prefix + \" \" + TTypeId.ForObject(val).Name() + \" (\" + val.name + \") = \" + val.ToString() + \"~n\"\n\t\t\t\tIf TXMLRPC_Value_Collection(val)\n\t\t\t\t\tpad:+1\n\t\t\t\t\tstr:+TXMLRPC_Response_Data.DebugData(TXMLRPC_Value_Collection(val).data, pad) + \"~n\"\n\t\t\t\t\tpad:-1\n\t\t\t\tEnd If\n\t\t\tNext\n\t\tEnd If\n\t\tReturn str\n\tEnd Function\nEnd Type\n","old_contents":"Rem\n\tbbdoc: Exception for TXMLRPC_Response_Data\nEnd Rem\nType TXMLRPC_Response_Data_Exception Extends TXMLRPC_Exception\nEnd Type\n\nRem\n\tbbdoc: Data returned from XML-RPC server\nEnd Rem\nType TXMLRPC_Response_Data\n\tRem\n\t\tbbdoc: This field contains all data returned from a response. If a response value was given an ID it can be accessed by its ID. If not it can be accessed with an ID of 0..inf\n\tEnd Rem\n\tField data:TMap\n\t\n\tRem\n\t\tbbdoc: Create a TXMLRPC_Response_Data object by passing the response XML message and the output options.\n\tEnd Rem\n\tMethod Create:TXMLRPC_Response_Data(xmlMessage:String, options:Byte Ptr)\n\t\tLocal message:Byte Ptr = xmlMessage.ToCString()\n\t\tLocal request:Byte Ptr = XMLRPC_REQUEST_FromXML(message, 0, options)\n\n\t\tLocal el:Byte Ptr = XMLRPC_RequestGetData(request)\n\n\t\tSelf.data = TXMLRPC_Response_Data.IterateVector(el)\n\n\t\tMemFree(message)\n\t\t\n\t\tLocal freeIo:Int = 1\n\t\t'Apparently a unhandled memory exception error gets thrown when\n\t\t'xmlMessage only contained 1 value and XMLRPC_RequestFree also\n\t\t'frees the response data.\n\t\tIf Not XMLRPC_VectorRewind(el) Then freeIo = 0\n\t\t\n\t\tXMLRPC_RequestFree(request, freeIo)\n\t\t\n\t\tReturn Self\n\tEnd Method\n\n\tRem\n\t\tbbdoc: Iterate over an XMLRPC vector and add it to a TMap. Private function\n\tEnd Rem\t\n\tFunction IterateVector:TMap(el:Byte Ptr)\n\t\tLocal data:TMap = New TMap\n\n\t\tIf el\n\t\t\t'Rewind vector\n\t\t\tLocal itr:Byte Ptr = XMLRPC_VectorRewind(el)\n\t\t\tIf Not itr\n\t\t\t\tLocal cStr:Byte Ptr = XMLRPC_GetValueID(el)\n\t\t\t\tLocal id:String = \"0\"\n\t\t\t\tIf cStr\n\t\t\t\t\tid = String.FromCString(cStr)\n\t\t\t\t\tXMLRPC_Free(cstr)\n\t\t\t\tEnd If\n\n\t\t\t\tdata.Insert(id, TXMLRPC_Value_Abstract.XMLRPC_To_BlizMax(el))\n\t\t\tElse\n\t\t\t\tLocal dataCounter:Int = 0\n\t\t\t\tWhile itr\n\t\t\t\t\tLocal cStr:Byte Ptr = XMLRPC_GetValueID(itr)\n\t\t\t\t\tLocal id:String = String.FromCString(cStr)\n\t\t\t\t\t\n\t\t\t\t\tIf id.Length = 0\n\t\t\t\t\t\tid = String.FromInt(dataCounter)\n\t\t\t\t\t\tdataCounter:+1\n\t\t\t\t\tEnd If\n\n\t\t\t\t\tdata.Insert(id, TXMLRPC_Value_Abstract.XMLRPC_To_BlizMax(itr))\n\t\t\t\t\tXMLRPC_Free(cStr)\n\n\t\t\t\t\t'Next element\n\t\t\t\t\titr = XMLRPC_VectorNext(el)\n\t\t\t\tWend\n\t\t\tEnd If\n\t\tEnd If\n\t\t\n\t\tReturn data\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Helper function to show what's inside the map\n\tEnd Rem\n\tFunction DebugData:String(map:TMap, pad:Int Var)\n\t\tLocal str:String\n\t\tLocal prefix:String\n\t\tFor Local i:Int = 0 To pad\n\t\t\tprefix:+\"-\"\n\t\tNext\n\t\t\n\t\tIf map\t\n\t\t\tFor Local val:TXMLRPC_Value_Abstract = EachIn map.Values()\n\t\t\t\tstr:+prefix + \" \" + TTypeId.ForObject(val).Name() + \" (\" + val.name + \") = \" + val.ToString() + \"~n\"\n\t\t\t\tIf TXMLRPC_Value_Collection(val)\n\t\t\t\t\tpad:+1\n\t\t\t\t\tstr:+TXMLRPC_Response_Data.DebugData(TXMLRPC_Value_Collection(val).data, pad) + \"~n\"\n\t\t\t\t\tpad:-1\n\t\t\t\tEnd If\n\t\t\tNext\n\t\tEnd If\n\t\tReturn str\n\tEnd Function\nEnd Type\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"c7556513358aef88241024c4f37d1df845976b2f","subject":"Bumped version to 0.9.0","message":"Bumped version to 0.9.0\n","repos":"maximos\/maximus","old_file":"maximus.bmx","new_file":"maximus.bmx","new_contents":"\nSuperStrict\n\nFramework brl.blitz\nImport brl.standardio\nImport brl.maxutil\nImport brl.ramstream\n\nImport bah.volumes\nImport gman.zipengine\nImport htbaapub.rest\n\nImport duct.variables\nImport duct.objectmap\nImport duct.json\nImport duct.locale\nImport duct.clapp\nImport duct.time\n\nIncbin \"locales\/en.loc\"\n\nInclude \"src\/logger.bmx\"\nInclude \"src\/errors.bmx\"\nInclude \"src\/config.bmx\"\nInclude \"src\/dependencies.bmx\"\nInclude \"src\/module.bmx\"\nInclude \"src\/sources.bmx\"\nInclude \"src\/utils.bmx\"\nInclude \"src\/impl\/help.bmx\"\nInclude \"src\/impl\/version.bmx\"\nInclude \"src\/impl\/modpath.bmx\"\nInclude \"src\/impl\/install.bmx\"\nInclude \"src\/impl\/update.bmx\"\nInclude \"src\/impl\/list.bmx\"\n\nGlobal logger:mxLogger = New mxLogger\nGlobal mainapp:mxApp\nNew mxApp.Create() ' Skip the first element because it is the program's location\nmainapp.SetArgs(AppArgs[1..])\nmainapp.Run()\n\nRem\n\tbbdoc: Maximus app.\n\tabout: This handles the basic flow of the program (initiation, parsing, command calling, exiting..)\nEnd Rem\nType mxApp Extends dCLApp\n\t\n\tConst c_version:String = \"0.9.0\"\n\tConst c_configfile:String = \"maximus.config\"\n\t\n\tField m_apppath:String\n\tField m_maxpath:String, m_binpath:String, m_modpath:String\n\t\n\tField m_confighandler:mxConfigHandler\n\tField m_defaultlocale:dLocale, m_locale:dLocale\n\tField m_sourcesfile:String = \"sources\", m_sourcesurl:String = \"http:\/\/maximus.htbaa.com\/module\/sources\/json\"\n\tField m_useragent:String\n\tField m_autoupdatesources:Int = True\n\t\n\tField m_sourceshandler:mxSourcesHandler\n\t\n\tField m_updateimpl:mxUpdateImpl\n\tField m_sourcesupdated:Int\n\t\n\tRem\n\t\tbbdoc: Create a new mxApp.\n\t\treturns: Itself.\n\tEnd Rem\n\tMethod Create:mxApp()\n\t\tmainapp = Self\n\t\tSuper.Create()\n\t\tReturn Self\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Called when the application is created.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod OnInit()\n\t\tm_apppath = GetUserAppDir() + \"\/\"\n\t\t?Linux\n\t\tm_apppath:+ \".maximus\/\"\n\t\t?Not Linux\n\t\tm_apppath:+ \"maximus\/\"\n\t\t?\n\t\tIf FileType(m_apppath) = FILETYPE_NONE\n\t\t\tIf Not CreateDir(m_apppath, False)\n\t\t\t\tThrowError(_s(\"error.createperms\", [m_apppath]))\n\t\t\tEnd If\n\t\tEnd If\n\t\tChangeDir(m_apppath)\n\t\tm_confighandler = New mxConfigHandler.Create(m_apppath + c_configfile)\n\t\tm_confighandler.LoadDefaultLocale()\n\t\tm_confighandler.Load()\n\t\tIf Not m_maxpath\n\t\t\tTry\n\t\t\t\tSetMaxPath(BlitzMaxPath())\n\t\t\tCatch e:Object\n\t\t\t\tThrowError(_s(\"error.notfound.maxenv\"))\n\t\t\tEnd Try\n\t\tEnd If\n\t\tIf Not m_modpath Then SetModPath(m_maxpath + \"\/mod\", False)\n\t\tm_arghandler = New dArgumentHandler.Create()\n\t\tm_arghandler.AddArgImpl(New mxHelpImpl)\n\t\tm_arghandler.AddArgImpl(New mxVersionImpl)\n\t\tm_arghandler.AddArgImpl(New mxModPathImpl)\n\t\tm_arghandler.AddArgImpl(New mxInstallImpl)\n\t\tm_updateimpl = New mxUpdateImpl\n\t\tm_arghandler.AddArgImpl(m_updateimpl)\n\t\tm_arghandler.AddArgImpl(New mxListImpl)\n\t\tUpdateSources()\n\t\tm_sourceshandler = New mxSourcesHandler.FromFile(m_apppath + m_sourcesfile)\n\t\tIf Not m_sourceshandler\n\t\t\t' Don't throw an error here, the user may be updating the sources (an error will occur otherwise)\n\t\t\tlogger.LogWarning(_s(\"error.load.sources.file\", [m_apppath + m_sourcesfile]))\n\t\tEnd If\n\t\tLocal os:String\n\t\t?Win32\n\t\t\tos = \"Windows\"\n\t\t?Linux\n\t\t\tos = \"Linux\"\n\t\t?MacOS\n\t\t\tos = \"MacOS\"\n\t\t?\n\t\tm_useragent = \"Maximus\/\" + c_version + \" (\" + os + \"; \" + m_locale.GetName() + \")\"\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Called when the application is ended (this includes #ThrowError calls).\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod OnExit()\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Run the application.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod Run()\n\t\tLocal argimpl:dArgumentImplementation, isopt:Int\n\t\tFor Local arg:dIdentifier = EachIn m_arguments\n\t\t\targimpl = m_arghandler.GetArgImplWithAlias(arg.GetName())\n\t\t\tisopt = (arg.GetName()[0] = 45)\n\t\t\tIf argimpl\n\t\t\t\tIf isopt\n\t\t\t\t\targimpl.SetCallConvention(dCallConvention.OPTION)\n\t\t\t\t\targimpl.SetArgs(arg)\n\t\t\t\t\targimpl.CheckArgs()\n\t\t\t\t\targimpl.Execute()\n\t\t\t\tElse\n\t\t\t\t\targimpl.SetCallConvention(dCallConvention.COMMAND)\n\t\t\t\t\targimpl.SetArgs(arg)\n\t\t\t\t\targimpl.CheckArgs()\n\t\t\t\t\targimpl.Execute()\n\t\t\t\t\tExit\n\t\t\t\tEnd If\n\t\t\tElse\n\t\t\t\tIf isopt\n\t\t\t\t\tThrowCommonError(mxOptErrors.UNKNOWN, arg.GetName())\n\t\t\t\tElse\n\t\t\t\t\tThrowCommonError(mxCmdErrors.UNKNOWN, arg.GetName())\n\t\t\t\tEnd If\n\t\t\tEnd If\n\t\tNext\n\t\tRem\n\t\t' Test version snatching\n\t\tLocal time:Int = MilliSecs(), ver:String\n\t\tFor Local modid:String = EachIn mxModUtils.GetModules().KeyEnumerator()\n\t\t\tver = mxModUtils.GetInstalledVersionFromVerID(modid)\n\t\t\tIf ver And Not (ver = \"dev\")\n\t\t\t\tDebugLog(\"versioned-id: ~q\" + modid + \"\/\" + ver + \"~q\")\n\t\t\tElse If Not ver\n\t\t\t\tDebugLog(\"Failed to get version from \" + modid)\n\t\t\tEnd If\n\t\tNext\n\t\tDebugLog(\"timed: \" + mxModUtils.GetModules().Count() + \" modules in \" + (MilliSecs() - time) + \"ms\")\n\t\tEnd Rem\n\t\tOnExit()\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Update the sources list.\n\t\treturns: Nothing.\n\t\tabout: Updates when: the sources file is greater than 23 hours old; the sources file does not exist.\n\tEnd Rem\n\tMethod UpdateSources()\n\t\tIf m_autoupdatesources And Not m_sourcesupdated\n\t\t\tLocal ctime:dTime, ftime:dTime\n\t\t\tctime = New dTime.CreateFromCurrent()\n\t\t\tftime = New dTime.CreateFromFile(m_apppath + m_sourcesfile)\n\t\t\t'DebugLog(\"Auto-update file time: c\" + ctime.Get() + \" | \" + ftime.Get() + \", hours: \" + (ctime.Get() - ftime.Get()) \/ 3600)\n\t\t\tIf Not ftime Or (ctime.Get() - ftime.Get()) \/ 3600 > 23\n\t\t\t\tlogger.LogMessage(_s(\"arg.update.autoupdate\"))\n\t\t\t\tm_updateimpl.SetCallConvention(dCallConvention.COMMAND)\n\t\t\t\tm_updateimpl.SetArgs(New dIdentifier.Create())\n\t\t\t\tm_updateimpl.CheckArgs()\n\t\t\t\tm_updateimpl.Execute()\n\t\t\tEnd If\n\t\tEnd If\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the application's arguments.\n\t\treturns: Nothing.\n\t\tabout: NOTE: This will resolve to '--help' if the given args are Null.\n\tEnd Rem\n\tMethod SetArgs(args:String[])\n\t\tIf Not args\n\t\t\targs = [\"--help\"]\n\t\tEnd If\n\t\tParseArguments(args, False, 1)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the module path.\n\t\treturns: Nothing.\n\t\tabout: This will throw an error if the module path could not be found.\n\tEnd Rem\n\tMethod SetModPath(modpath:String, logchange:Int = True)\n\t\tm_modpath = FixPathEnding(modpath, True)\n\t\tIf FileType(m_modpath) = FILETYPE_DIR\n\t\t\tIf logchange Then logger.LogMessage(_s(\"message.setmodpath\", [m_modpath]))\n\t\tElse\n\t\t\tThrowError(_s(\"error.notfound.modpath\", [m_modpath]))\n\t\tEnd If\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the path to the BlitzMax installation.\n\t\treturns: Nothing.\n\t\tabout: This will throw an error if the path could not be found.\n\tEnd Rem\n\tMethod SetMaxPath(maxpath:String)\n\t\tm_maxpath = FixPathEnding(maxpath, True)\n\t\tm_binpath = m_maxpath + \"\/bin\"\n\t\tLocal bmk:String\n\t\t?Win32\n\t\t\tbmk = \"\/bmk.exe\"\n\t\t?Not Win32\n\t\t\tbmk = \"\/bmk\"\n\t\t?\n\t\tIf FileType(m_maxpath) = FILETYPE_NONE\n\t\t\tThrowError(_s(\"error.notfound.maxpath\", [m_maxpath]))\n\t\tElse If FileType(m_binpath + bmk) = FILETYPE_NONE\n\t\t\tThrowError(_s(\"error.notfound.bmk\", [m_binpath + bmk]))\n\t\tEnd If\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the sources url.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetSourcesUrl(url:String)\n\t\tm_sourcesurl = url\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the sources file.\n\t\treturns: Nothing.\n\t\tabout: NOTE: This will throw an error if the path is Null (and, later, a warning will be logged if the path does not exist).\n\tEnd Rem\n\tMethod SetSourcesFile(file:String)\n\t\tIf Not file\n\t\t\tThrowError(_s(\"error.sources.setfile\"))\n\t\tEnd If\n\t\tm_sourcesfile = file\n\tEnd Method\n\t\nEnd Type\n\nRem\n\tbbdoc: Throw an error (terminating the application).\n\treturns: Nothing.\nEnd Rem\nFunction ThrowError(error:String)\n\tlogger.LogError(error)\n\tmainapp.OnExit()\n\tEnd\nEnd Function\n\nRem\n\tbbdoc: Get the localized text for the given identifier.\n\treturns: The translated text.\nEnd Rem\nFunction _s:String(iden:String, extra:String[] = Null)\n\tGlobal replacer:dTextReplacer = New dTextReplacer\n\tLocal ltext:dLocalizedText\n\tIf mainapp.m_locale Then ltext = mainapp.m_locale.TextFromStructureL(iden)\n\tIf ltext Then ltext = mainapp.m_defaultlocale.TextFromStructureL(iden)\n\tIf ltext\n\t\treplacer.SetString(ltext.GetValue())\n\t\treplacer.AutoReplacements(\"{\", \"}\")\n\t\tIf extra\n\t\t\tLocal i:Int\n\t\t\tFor Local rep:dTextReplacement = EachIn replacer.GetList()\n\t\t\t\tIf i > extra.Length Then Exit\n\t\t\t\trep.SetReplacement(extra[i])\n\t\t\t\ti:+ 1\n\t\t\tNext\n\t\tEnd If\n\t\tReturn replacer.DoReplacements()\n\tElse\n\t\tDebugLog(\"Failed to find localized text from structure: ~q\" + iden + \"~q\")\n\tEnd If\n\tReturn Null\nEnd Function\n\n","old_contents":"\nSuperStrict\n\nFramework brl.blitz\nImport brl.standardio\nImport brl.maxutil\nImport brl.ramstream\n\nImport bah.volumes\nImport gman.zipengine\nImport htbaapub.rest\n\nImport duct.variables\nImport duct.objectmap\nImport duct.json\nImport duct.locale\nImport duct.clapp\nImport duct.time\n\nIncbin \"locales\/en.loc\"\n\nInclude \"src\/logger.bmx\"\nInclude \"src\/errors.bmx\"\nInclude \"src\/config.bmx\"\nInclude \"src\/dependencies.bmx\"\nInclude \"src\/module.bmx\"\nInclude \"src\/sources.bmx\"\nInclude \"src\/utils.bmx\"\nInclude \"src\/impl\/help.bmx\"\nInclude \"src\/impl\/version.bmx\"\nInclude \"src\/impl\/modpath.bmx\"\nInclude \"src\/impl\/install.bmx\"\nInclude \"src\/impl\/update.bmx\"\nInclude \"src\/impl\/list.bmx\"\n\nGlobal logger:mxLogger = New mxLogger\nGlobal mainapp:mxApp\nNew mxApp.Create() ' Skip the first element because it is the program's location\nmainapp.SetArgs(AppArgs[1..])\nmainapp.Run()\n\nRem\n\tbbdoc: Maximus app.\n\tabout: This handles the basic flow of the program (initiation, parsing, command calling, exiting..)\nEnd Rem\nType mxApp Extends dCLApp\n\t\n\tConst c_version:String = \"0.01\"\n\tConst c_configfile:String = \"maximus.config\"\n\t\n\tField m_apppath:String\n\tField m_maxpath:String, m_binpath:String, m_modpath:String\n\t\n\tField m_confighandler:mxConfigHandler\n\tField m_defaultlocale:dLocale, m_locale:dLocale\n\tField m_sourcesfile:String = \"sources\", m_sourcesurl:String = \"http:\/\/maximus.htbaa.com\/module\/sources\/json\"\n\tField m_useragent:String\n\tField m_autoupdatesources:Int = True\n\t\n\tField m_sourceshandler:mxSourcesHandler\n\t\n\tField m_updateimpl:mxUpdateImpl\n\tField m_sourcesupdated:Int\n\t\n\tRem\n\t\tbbdoc: Create a new mxApp.\n\t\treturns: Itself.\n\tEnd Rem\n\tMethod Create:mxApp()\n\t\tmainapp = Self\n\t\tSuper.Create()\n\t\tReturn Self\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Called when the application is created.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod OnInit()\n\t\tm_apppath = GetUserAppDir() + \"\/\"\n\t\t?Linux\n\t\tm_apppath:+ \".maximus\/\"\n\t\t?Not Linux\n\t\tm_apppath:+ \"maximus\/\"\n\t\t?\n\t\tIf FileType(m_apppath) = FILETYPE_NONE\n\t\t\tIf Not CreateDir(m_apppath, False)\n\t\t\t\tThrowError(_s(\"error.createperms\", [m_apppath]))\n\t\t\tEnd If\n\t\tEnd If\n\t\tChangeDir(m_apppath)\n\t\tm_confighandler = New mxConfigHandler.Create(m_apppath + c_configfile)\n\t\tm_confighandler.LoadDefaultLocale()\n\t\tm_confighandler.Load()\n\t\tIf Not m_maxpath\n\t\t\tTry\n\t\t\t\tSetMaxPath(BlitzMaxPath())\n\t\t\tCatch e:Object\n\t\t\t\tThrowError(_s(\"error.notfound.maxenv\"))\n\t\t\tEnd Try\n\t\tEnd If\n\t\tIf Not m_modpath Then SetModPath(m_maxpath + \"\/mod\", False)\n\t\tm_arghandler = New dArgumentHandler.Create()\n\t\tm_arghandler.AddArgImpl(New mxHelpImpl)\n\t\tm_arghandler.AddArgImpl(New mxVersionImpl)\n\t\tm_arghandler.AddArgImpl(New mxModPathImpl)\n\t\tm_arghandler.AddArgImpl(New mxInstallImpl)\n\t\tm_updateimpl = New mxUpdateImpl\n\t\tm_arghandler.AddArgImpl(m_updateimpl)\n\t\tm_arghandler.AddArgImpl(New mxListImpl)\n\t\tUpdateSources()\n\t\tm_sourceshandler = New mxSourcesHandler.FromFile(m_apppath + m_sourcesfile)\n\t\tIf Not m_sourceshandler\n\t\t\t' Don't throw an error here, the user may be updating the sources (an error will occur otherwise)\n\t\t\tlogger.LogWarning(_s(\"error.load.sources.file\", [m_apppath + m_sourcesfile]))\n\t\tEnd If\n\t\tLocal os:String\n\t\t?Win32\n\t\t\tos = \"Windows\"\n\t\t?Linux\n\t\t\tos = \"Linux\"\n\t\t?MacOS\n\t\t\tos = \"MacOS\"\n\t\t?\n\t\tm_useragent = \"Maximus\/\" + c_version + \" (\" + os + \"; \" + m_locale.GetName() + \")\"\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Called when the application is ended (this includes #ThrowError calls).\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod OnExit()\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Run the application.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod Run()\n\t\tLocal argimpl:dArgumentImplementation, isopt:Int\n\t\tFor Local arg:dIdentifier = EachIn m_arguments\n\t\t\targimpl = m_arghandler.GetArgImplWithAlias(arg.GetName())\n\t\t\tisopt = (arg.GetName()[0] = 45)\n\t\t\tIf argimpl\n\t\t\t\tIf isopt\n\t\t\t\t\targimpl.SetCallConvention(dCallConvention.OPTION)\n\t\t\t\t\targimpl.SetArgs(arg)\n\t\t\t\t\targimpl.CheckArgs()\n\t\t\t\t\targimpl.Execute()\n\t\t\t\tElse\n\t\t\t\t\targimpl.SetCallConvention(dCallConvention.COMMAND)\n\t\t\t\t\targimpl.SetArgs(arg)\n\t\t\t\t\targimpl.CheckArgs()\n\t\t\t\t\targimpl.Execute()\n\t\t\t\t\tExit\n\t\t\t\tEnd If\n\t\t\tElse\n\t\t\t\tIf isopt\n\t\t\t\t\tThrowCommonError(mxOptErrors.UNKNOWN, arg.GetName())\n\t\t\t\tElse\n\t\t\t\t\tThrowCommonError(mxCmdErrors.UNKNOWN, arg.GetName())\n\t\t\t\tEnd If\n\t\t\tEnd If\n\t\tNext\n\t\tRem\n\t\t' Test version snatching\n\t\tLocal time:Int = MilliSecs(), ver:String\n\t\tFor Local modid:String = EachIn mxModUtils.GetModules().KeyEnumerator()\n\t\t\tver = mxModUtils.GetInstalledVersionFromVerID(modid)\n\t\t\tIf ver And Not (ver = \"dev\")\n\t\t\t\tDebugLog(\"versioned-id: ~q\" + modid + \"\/\" + ver + \"~q\")\n\t\t\tElse If Not ver\n\t\t\t\tDebugLog(\"Failed to get version from \" + modid)\n\t\t\tEnd If\n\t\tNext\n\t\tDebugLog(\"timed: \" + mxModUtils.GetModules().Count() + \" modules in \" + (MilliSecs() - time) + \"ms\")\n\t\tEnd Rem\n\t\tOnExit()\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Update the sources list.\n\t\treturns: Nothing.\n\t\tabout: Updates when: the sources file is greater than 23 hours old; the sources file does not exist.\n\tEnd Rem\n\tMethod UpdateSources()\n\t\tIf m_autoupdatesources And Not m_sourcesupdated\n\t\t\tLocal ctime:dTime, ftime:dTime\n\t\t\tctime = New dTime.CreateFromCurrent()\n\t\t\tftime = New dTime.CreateFromFile(m_apppath + m_sourcesfile)\n\t\t\t'DebugLog(\"Auto-update file time: c\" + ctime.Get() + \" | \" + ftime.Get() + \", hours: \" + (ctime.Get() - ftime.Get()) \/ 3600)\n\t\t\tIf Not ftime Or (ctime.Get() - ftime.Get()) \/ 3600 > 23\n\t\t\t\tlogger.LogMessage(_s(\"arg.update.autoupdate\"))\n\t\t\t\tm_updateimpl.SetCallConvention(dCallConvention.COMMAND)\n\t\t\t\tm_updateimpl.SetArgs(New dIdentifier.Create())\n\t\t\t\tm_updateimpl.CheckArgs()\n\t\t\t\tm_updateimpl.Execute()\n\t\t\tEnd If\n\t\tEnd If\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the application's arguments.\n\t\treturns: Nothing.\n\t\tabout: NOTE: This will resolve to '--help' if the given args are Null.\n\tEnd Rem\n\tMethod SetArgs(args:String[])\n\t\tIf Not args\n\t\t\targs = [\"--help\"]\n\t\tEnd If\n\t\tParseArguments(args, False, 1)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the module path.\n\t\treturns: Nothing.\n\t\tabout: This will throw an error if the module path could not be found.\n\tEnd Rem\n\tMethod SetModPath(modpath:String, logchange:Int = True)\n\t\tm_modpath = FixPathEnding(modpath, True)\n\t\tIf FileType(m_modpath) = FILETYPE_DIR\n\t\t\tIf logchange Then logger.LogMessage(_s(\"message.setmodpath\", [m_modpath]))\n\t\tElse\n\t\t\tThrowError(_s(\"error.notfound.modpath\", [m_modpath]))\n\t\tEnd If\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the path to the BlitzMax installation.\n\t\treturns: Nothing.\n\t\tabout: This will throw an error if the path could not be found.\n\tEnd Rem\n\tMethod SetMaxPath(maxpath:String)\n\t\tm_maxpath = FixPathEnding(maxpath, True)\n\t\tm_binpath = m_maxpath + \"\/bin\"\n\t\tLocal bmk:String\n\t\t?Win32\n\t\t\tbmk = \"\/bmk.exe\"\n\t\t?Not Win32\n\t\t\tbmk = \"\/bmk\"\n\t\t?\n\t\tIf FileType(m_maxpath) = FILETYPE_NONE\n\t\t\tThrowError(_s(\"error.notfound.maxpath\", [m_maxpath]))\n\t\tElse If FileType(m_binpath + bmk) = FILETYPE_NONE\n\t\t\tThrowError(_s(\"error.notfound.bmk\", [m_binpath + bmk]))\n\t\tEnd If\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the sources url.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetSourcesUrl(url:String)\n\t\tm_sourcesurl = url\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the sources file.\n\t\treturns: Nothing.\n\t\tabout: NOTE: This will throw an error if the path is Null (and, later, a warning will be logged if the path does not exist).\n\tEnd Rem\n\tMethod SetSourcesFile(file:String)\n\t\tIf Not file\n\t\t\tThrowError(_s(\"error.sources.setfile\"))\n\t\tEnd If\n\t\tm_sourcesfile = file\n\tEnd Method\n\t\nEnd Type\n\nRem\n\tbbdoc: Throw an error (terminating the application).\n\treturns: Nothing.\nEnd Rem\nFunction ThrowError(error:String)\n\tlogger.LogError(error)\n\tmainapp.OnExit()\n\tEnd\nEnd Function\n\nRem\n\tbbdoc: Get the localized text for the given identifier.\n\treturns: The translated text.\nEnd Rem\nFunction _s:String(iden:String, extra:String[] = Null)\n\tGlobal replacer:dTextReplacer = New dTextReplacer\n\tLocal ltext:dLocalizedText\n\tIf mainapp.m_locale Then ltext = mainapp.m_locale.TextFromStructureL(iden)\n\tIf ltext Then ltext = mainapp.m_defaultlocale.TextFromStructureL(iden)\n\tIf ltext\n\t\treplacer.SetString(ltext.GetValue())\n\t\treplacer.AutoReplacements(\"{\", \"}\")\n\t\tIf extra\n\t\t\tLocal i:Int\n\t\t\tFor Local rep:dTextReplacement = EachIn replacer.GetList()\n\t\t\t\tIf i > extra.Length Then Exit\n\t\t\t\trep.SetReplacement(extra[i])\n\t\t\t\ti:+ 1\n\t\t\tNext\n\t\tEnd If\n\t\tReturn replacer.DoReplacements()\n\tElse\n\t\tDebugLog(\"Failed to find localized text from structure: ~q\" + iden + \"~q\")\n\tEnd If\n\tReturn Null\nEnd Function\n\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"7b133c494f945b79b049f0d84447f000c3933424","subject":"Corrected returns for the SetCommonFromVariable method.","message":"Corrected returns for the SetCommonFromVariable method.\n","repos":"maximos\/maximus","old_file":"src\/module.bmx","new_file":"src\/module.bmx","new_contents":"\nRem\n\tbbdoc: Maximus module base.\n\tabout: An abstract type for the similarities between module scopes and modules.\nEnd Rem\nType mxModuleBase Abstract\n\t\n\tField m_name:String, m_description:String\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the base's name.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetName(name:String)\n\t\tAssert name, \"(mxModuleBase.SetName) name cannot be Null!\"\n\t\tm_name = name\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the base's name.\n\t\treturns: The base's name.\n\tEnd Rem\n\tMethod GetName:String()\n\t\tReturn m_name\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the base's description.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetDescription(description:String)\n\t\tAssert description, \"(mxModuleBase.SetDescription) description cannot be Null!\"\n\t\tm_description = description\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the base's description.\n\t\treturns: The base's description.\n\tEnd Rem\n\tMethod GetDescription:String()\n\t\tReturn m_description\n\tEnd Method\n\t\n'#end region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set a common field from the given variable.\n\t\treturns: True if the given variable was handled, or False if it was not.\n\tEnd Rem\n\tMethod SetCommonFromVariable:Int(variable:dVariable)\n\t\tSelect variable.GetName().ToLower()\n\t\t\tCase \"desc\"\n\t\t\t\tSetDescription(variable.ValueAsString())\n\t\t\tDefault\n\t\t\t\tReturn False\n\t\tEnd Select\n\t\tReturn True\n\tEnd Method\n\t\nEnd Type\n\nRem\n\tbbdoc: Maximus module scope.\nEnd Rem\nType mxModuleScope Extends mxModuleBase\n\t\n\tField m_modules:dObjectMap\n\t\n\tMethod New()\n\t\tm_modules = New dObjectMap\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Add the given module to the scope.\n\t\treturns: True if the module was added, or False if it was not (the module is Null).\n\tEnd Rem\n\tMethod AddModule:Int(modul:mxModule)\n\t\tIf modul <> Null\n\t\t\tm_modules._Insert(modul.GetName(), modul)\n\t\t\tmodul.SetParent(Self)\n\t\t\tReturn True\n\t\tEnd If\n\t\tReturn False\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Check if the given module name is found in the scope.\n\t\treturns: True if the given module was found in the scope, or False if it was not.\n\tEnd Rem\n\tMethod HasModule:Int(modname:String)\n\t\tReturn m_modules._Contains(modname)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get a module with the given name.\n\t\treturns: The module with the given name, or Null if there is no module with the given name.\n\tEnd Rem\n\tMethod GetModuleWithName:mxModule(modname:String)\n\t\tReturn mxModule(m_modules._ValueByKey(modname))\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Load the given dJObject into the scope.\n\t\treturns: Itself, or Null if @root is Null.\n\tEnd Rem\n\tMethod FromJSON:mxModuleScope(root:dJObject)\n\t\tIf root <> Null\n\t\t\tSetName(root.GetName())\n\t\t\tFor Local variable:dVariable = EachIn root.GetValues()\n\t\t\t\tIf dJObject(variable)\n\t\t\t\t\tAddModule(New mxModule.FromJSON(dJObject(variable)))\n\t\t\t\tElse\n\t\t\t\t\tSetCommonFromVariable(variable)\n\t\t\t\tEnd If\n\t\t\tNext\n\t\t\tReturn Self\n\t\tEnd If\n\t\tReturn Null\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the module enumerator for the scope.\n\t\treturns: The module enumerator for the scope.\n\tEnd Rem\n\tMethod ModuleEnumerator:TMapEnumerator()\n\t\tReturn m_modules.ValueEnumerator()\n\tEnd Method\n\t\nEnd Type\n\nRem\n\tbbdoc: Maximus module.\nEnd Rem\nType mxModule Extends mxModuleBase\n\t\n\tField m_parent:mxModuleScope\n\tField m_versions:dObjectMap\n\t\n\tMethod New()\n\t\tm_versions = New dObjectMap\n\tEnd Method\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the module's parent.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetParent(parent:mxModuleScope)\n\t\tm_parent = parent\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the module's parent.\n\t\treturns: The module's parent.\n\tEnd Rem\n\tMethod GetParent:mxModuleScope()\n\t\tReturn m_parent\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the full name of the module (e.g. \"modscope.module\").\n\t\treturns: The full name of the module.\n\tEnd Rem\n\tMethod GetFullName:String()\n\t\tReturn m_parent.m_name + \".\" + m_name\n\tEnd Method\n\t\n'#end region Field accessors\n\t\n\tRem\n\t\tbbdoc: Add the given version to the module.\n\t\treturns: True if the version was added, or False if it was not (the version is Null).\n\tEnd Rem\n\tMethod AddVersion:Int(version:mxModuleVersion)\n\t\tIf version <> Null\n\t\t\tm_versions._Insert(version.GetName(), version)\n\t\t\tversion.SetParent(Self)\n\t\t\tReturn True\n\t\tEnd If\n\t\tReturn False\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Check if there is a version with the given name.\n\t\treturns: True if the version was found, or False if it was not.\n\tEnd Rem\n\tMethod HasVersion:Int(name:String)\n\t\tReturn m_versions._Contains(name)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get a version with the given name.\n\t\treturns: The version with the given name, or Null if there is no version with the given name.\n\tEnd Rem\n\tMethod GetVersionWithName:mxModuleVersion(name:String)\n\t\tReturn mxModuleVersion(m_versions._ValueByKey(name))\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the latest (non-dev if available) version for this module.\n\t\treturns: The latest version for this module.\n\t\tabout: The latest version will be returned, or the dev version if it is the only version.\n\tEnd Rem\n\tMethod GetLatestVersion:mxModuleVersion()\n\t\tLocal hver:mxModuleVersion\n\t\tFor Local ver:mxModuleVersion = EachIn VersionEnumerator()\n\t\t\tIf ver.GetName() <> \"dev\"\n\t\t\t\tIf hver = Null Or hver.Compare(ver) = 1\n\t\t\t\t\thver = ver\n\t\t\t\tEnd If\n\t\t\tEnd If\n\t\tNext\n\t\tIf hver = Null\n\t\t\thver = GetVersionWithName(\"dev\")\n\t\tEnd If\n\t\tReturn hver\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set a common field from the given variable.\n\t\treturns: True if the given variable was handled, or False if it was not.\n\tEnd Rem\n\tMethod SetCommonFromVariable:Int(variable:dVariable)\n\t\tIf Super.SetCommonFromVariable(variable) = True\n\t\t\tReturn True\n\t\tElse\n\t\t\tSelect variable.GetName().ToLower()\n\t\t\t\tCase \"versions\"\n\t\t\t\t\tFor Local jobj:dJObject = EachIn dJObject(variable).GetValues()\n\t\t\t\t\t\tAddVersion(New mxModuleVersion.FromJSON(jobj))\n\t\t\t\t\tNext\n\t\t\t\tDefault\n\t\t\t\t\tReturn False\n\t\t\tEnd Select\n\t\t\tReturn True\n\t\tEnd If\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Load the given dJObject into the module.\n\t\treturns: Itself, or Null if @root is Null.\n\tEnd Rem\n\tMethod FromJSON:mxModule(root:dJObject)\n\t\tIf root <> Null\n\t\t\tSetName(root.GetName())\n\t\t\tFor Local variable:dVariable = EachIn root.GetValues()\n\t\t\t\tSetCommonFromVariable(variable)\n\t\t\tNext\n\t\t\tReturn Self\n\t\tEnd If\n\t\tReturn Null\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the version enumerator for the module.\n\t\treturns: The version enumerator for the module.\n\tEnd Rem\n\tMethod VersionEnumerator:TMapEnumerator()\n\t\tReturn m_versions.ValueEnumerator()\n\tEnd Method\n\t\nEnd Type\n\nRem\n\tbbdoc: Maximus module version.\nEnd Rem\nType mxModuleVersion\n\t\n\tField m_parent:mxModule\n\tField m_name:String, m_url:String\n\tField m_dependencies:mxModuleDependencies\n\t\n\tMethod New()\n\t\tm_dependencies = New mxModuleDependencies\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Create a version.\n\t\treturns: Itself.\n\tEnd Rem\n\tMethod Create:mxModuleVersion(parent:mxModule, name:String, url:String)\n\t\tSetParent(parent)\n\t\tSetName(name)\n\t\tSetUrl(url)\n\t\tReturn Self\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Clone the version.\n\t\treturns: A clone of the version.\n\t\tabout: If @withdeps is True (default value), the dependencies will be added as well.\n\tEnd Rem\n\tMethod Clone:mxModuleVersion(withdeps:Int = True)\n\t\tLocal v:mxModuleVersion = New mxModuleVersion.Create(m_parent, m_name, m_url)\n\t\tFor Local dep:mxModuleDependency = EachIn DependencyEnumerator()\n\t\t\tv.m_dependencies.AddDependency(dep)\n\t\tNext\n\t\tReturn v\n\tEnd Method\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the version's parent.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetParent(parent:mxModule)\n\t\tm_parent = parent\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the version's parent.\n\t\treturns: The version's parent.\n\tEnd Rem\n\tMethod GetParent:mxModule()\n\t\tReturn m_parent\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the version's name.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetName(name:String)\n\t\tAssert name, \"(mxModuleVersion.SetName) name cannot be Null!\"\n\t\tm_name = name\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the version's name.\n\t\treturns: The version's name.\n\tEnd Rem\n\tMethod GetName:String()\n\t\tReturn m_name\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the version's url.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetUrl(url:String)\n\t\tAssert url, \"(mxModuleVersion.SetUrl) url cannot be Null!\"\n\t\tm_url = url\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the version's url.\n\t\treturns: The version's url.\n\tEnd Rem\n\tMethod GetUrl:String()\n\t\tReturn m_url\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the temporary fetch path for the version's source archive.\n\t\treturns: The temporary file path for the version's source archive.\n\tEnd Rem\n\tMethod GetTemporaryFilePath:String()\n\t\tReturn \"tmp\/\" + m_parent.GetFullName() + \"-\" + m_name + \".zip\"\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the version's dependencies.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetDependencies(dependencies:mxModuleDependencies)\n\t\tm_dependencies = dependencies\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the version's dependencies.\n\t\treturns: The version's dependencies.\n\tEnd Rem\n\tMethod GetDependencies:mxModuleDependencies()\n\t\tReturn m_dependencies\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the version parts for the version.\n\t\treturns: True if the version is development, in which case the parameters are both 0; or False, in which case the parameters are set accordingly.\n\tEnd Rem\n\tMethod GetVersionParts:Int(vmajor:String Var, vminor:String Var)\n\t\tIf m_name <> \"dev\"\n\t\t\tLocal i:Int = m_name.Find(\".\")\n\t\t\tIf i > -1\n\t\t\t\tvmajor = m_name[..i]\n\t\t\t\tvminor = m_name[i + 1..]\n\t\t\tElse\n\t\t\t\tvmajor = m_name ' I'm not sure what other version formats would be used, so I'm just playing a random card here\n\t\t\tEnd If\n\t\t\tReturn False\n\t\tEnd If\n\t\tReturn True\n\tEnd Method\n\t\n'#end region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set a common field from the given variable.\n\t\treturns: True if the given variable was handled, or False if it was not.\n\tEnd Rem\n\tMethod SetCommonFromVariable:Int(variable:dVariable)\n\t\tSelect variable.GetName().ToLower()\n\t\t\tCase \"url\"\n\t\t\t\tSetUrl(variable.ValueAsString())\n\t\t\tCase \"deps\"\n\t\t\t\tm_dependencies.FromJSON(dJArray(variable))\n\t\t\tDefault\n\t\t\t\tReturn False\n\t\tEnd Select\n\t\tReturn True\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Load the given dJObject into the version.\n\t\treturns: Itself, or Null if @root is Null.\n\tEnd Rem\n\tMethod FromJSON:mxModuleVersion(root:dJObject)\n\t\tIf root <> Null\n\t\t\tSetName(root.GetName())\n\t\t\tFor Local variable:dVariable = EachIn root.GetValues()\n\t\t\t\tSetCommonFromVariable(variable)\n\t\t\tNext\n\t\t\tReturn Self\n\t\tEnd If\n\t\tReturn Null\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the dependency enumerator for the version.\n\t\treturns: The dependency enumerator for the version.\n\tEnd Rem\n\tMethod DependencyEnumerator:TMapEnumerator()\n\t\tReturn m_dependencies.DependencyEnumerator()\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Compare the version with the given version.\n\t\treturns: 0 if the two versions are the same (same in version number alone), 1 if this version is greater than the given, or -1 if the given version is greater than this version.\n\tEnd Rem\n\tMethod Compare:Int(with:Object)\n\t\tLocal ver:mxModuleVersion = mxModuleVersion(with)\n\t\tIf ver <> Null\n\t\t\tIf m_name = ver.m_name\n\t\t\t\tReturn 0\n\t\t\tElse\n\t\t\t\tLocal smajor:String, sminor:String, wmajor:String, wminor:String\n\t\t\t\tLocal sdev:Int = GetVersionParts(smajor, sminor), wdev:Int = ver.GetVersionParts(wmajor, wminor)\n\t\t\t\tIf (sdev = True And wdev = True) Or (smajor = wmajor And sminor = wminor)\n\t\t\t\t\tReturn 0\n\t\t\t\tElse If smajor > wmajor\n\t\t\t\t\tReturn 1\n\t\t\t\tElse If smajor = wmajor\n\t\t\t\t\tIf sminor > wminor\n\t\t\t\t\t\tReturn 1\n\t\t\t\t\tElse\n\t\t\t\t\t\tReturn -1\n\t\t\t\t\tEnd If\n\t\t\t\tElse\n\t\t\t\t\tReturn -1\n\t\t\t\tEnd If\n\t\t\tEnd If\n\t\tEnd If\n\t\tReturn Super.Compare(with)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Fetch the version's source archive.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod FetchSourceArchive()\n\t\tLocal file:String = GetTemporaryFilePath()\n\t\tlogger.LogMessage(\"fetching: \" + GetUrl() + \" -> \" + file + \"~t\", False)\n\t\tIf FileType(file) = FILETYPE_NONE\n\t\t\tLocal stream:TStream = WriteFileExplicitly(file)\n\t\t\tIf stream <> Null\n\t\t\t\tLocal request:TRESTRequest = New TRESTRequest, response:TRESTResponse\n\t\t\t\trequest.SetProgressCallback(_ProgressCallback, New _mxProgressStore)\n\t\t\t\trequest.SetStream(stream)\n\t\t\t\tTry\n\t\t\t\t\tresponse = request.Call(GetUrl(), [\"User-Agent: \" + mainapp.m_useragent], \"GET\")\n\t\t\t\tCatch e:Object\n\t\t\t\t\tstream.Close()\n\t\t\t\t\tDeleteFile(file)\n\t\t\t\t\tlogger.LogMessage(\"\")\n\t\t\t\t\tThrowError(_s(\"error.fetch.archive\", [e.ToString()]))\n\t\t\t\tEnd Try\n\t\t\t\tstream.Close()\n\t\t\t\tIf response.responseCode = 200\n\t\t\t\t\tlogger.LogMessage(_s(\"message.fetch.done\", [String(response.responseCode)]))\n\t\t\t\tElse\n\t\t\t\t\tDeleteFile(file)\n\t\t\t\t\tlogger.LogMessage(\"\")\n\t\t\t\t\tThrowError(_s(\"error.fetch.archive\", [\"Bad response code: \" + String(response.responseCode)]))\n\t\t\t\tEnd If\n\t\t\tElse\n\t\t\t\tThrowError(_s(\"error.writeperms\", [file]))\n\t\t\tEnd If\n\t\tElse\n\t\t\tlogger.LogMessage(_s(\"message.fetch.alreadyfetched\"))\n\t\tEnd If\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Progress callback for source archive fetching.\n\t\treturns: Zero (no error).\n\tEnd Rem\n\tFunction _ProgressCallback:Int(data:Object, dltotal:Double, dlnow:Double, ultotal:Double, ulnow:Double)\n\t\tLocal store:_mxProgressStore = _mxProgressStore(data)\n\t\tLocal prog:Int = (dlnow \/ dltotal) * 100\n\t\tIf prog > store.m_progress + 5\n\t\t\tstore.m_progress = prog\n\t\t\tWriteStdOut(\".\")\n\t\tEnd If\n\t\tReturn 0\n\tEnd Function\n\t\nEnd Type\n\n","old_contents":"\nRem\n\tbbdoc: Maximus module base.\n\tabout: An abstract type for the similarities between module scopes and modules.\nEnd Rem\nType mxModuleBase Abstract\n\t\n\tField m_name:String, m_description:String\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the base's name.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetName(name:String)\n\t\tAssert name, \"(mxModuleBase.SetName) name cannot be Null!\"\n\t\tm_name = name\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the base's name.\n\t\treturns: The base's name.\n\tEnd Rem\n\tMethod GetName:String()\n\t\tReturn m_name\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the base's description.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetDescription(description:String)\n\t\tAssert description, \"(mxModuleBase.SetDescription) description cannot be Null!\"\n\t\tm_description = description\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the base's description.\n\t\treturns: The base's description.\n\tEnd Rem\n\tMethod GetDescription:String()\n\t\tReturn m_description\n\tEnd Method\n\t\n'#end region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set a common field from the given variable.\n\t\treturns: True if the given variable was handled, or False if it was not.\n\tEnd Rem\n\tMethod SetCommonFromVariable:Int(variable:dVariable)\n\t\tSelect variable.GetName().ToLower()\n\t\t\tCase \"desc\"\n\t\t\t\tSetDescription(variable.ValueAsString())\n\t\t\t\tReturn True\n\t\tEnd Select\n\t\tReturn False\n\tEnd Method\n\t\nEnd Type\n\nRem\n\tbbdoc: Maximus module scope.\nEnd Rem\nType mxModuleScope Extends mxModuleBase\n\t\n\tField m_modules:dObjectMap\n\t\n\tMethod New()\n\t\tm_modules = New dObjectMap\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Add the given module to the scope.\n\t\treturns: True if the module was added, or False if it was not (the module is Null).\n\tEnd Rem\n\tMethod AddModule:Int(modul:mxModule)\n\t\tIf modul <> Null\n\t\t\tm_modules._Insert(modul.GetName(), modul)\n\t\t\tmodul.SetParent(Self)\n\t\t\tReturn True\n\t\tEnd If\n\t\tReturn False\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Check if the given module name is found in the scope.\n\t\treturns: True if the given module was found in the scope, or False if it was not.\n\tEnd Rem\n\tMethod HasModule:Int(modname:String)\n\t\tReturn m_modules._Contains(modname)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get a module with the given name.\n\t\treturns: The module with the given name, or Null if there is no module with the given name.\n\tEnd Rem\n\tMethod GetModuleWithName:mxModule(modname:String)\n\t\tReturn mxModule(m_modules._ValueByKey(modname))\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Load the given dJObject into the scope.\n\t\treturns: Itself, or Null if @root is Null.\n\tEnd Rem\n\tMethod FromJSON:mxModuleScope(root:dJObject)\n\t\tIf root <> Null\n\t\t\tSetName(root.GetName())\n\t\t\tFor Local variable:dVariable = EachIn root.GetValues()\n\t\t\t\tIf dJObject(variable)\n\t\t\t\t\tAddModule(New mxModule.FromJSON(dJObject(variable)))\n\t\t\t\tElse\n\t\t\t\t\tSetCommonFromVariable(variable)\n\t\t\t\tEnd If\n\t\t\tNext\n\t\t\tReturn Self\n\t\tEnd If\n\t\tReturn Null\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the module enumerator for the scope.\n\t\treturns: The module enumerator for the scope.\n\tEnd Rem\n\tMethod ModuleEnumerator:TMapEnumerator()\n\t\tReturn m_modules.ValueEnumerator()\n\tEnd Method\n\t\nEnd Type\n\nRem\n\tbbdoc: Maximus module.\nEnd Rem\nType mxModule Extends mxModuleBase\n\t\n\tField m_parent:mxModuleScope\n\tField m_versions:dObjectMap\n\t\n\tMethod New()\n\t\tm_versions = New dObjectMap\n\tEnd Method\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the module's parent.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetParent(parent:mxModuleScope)\n\t\tm_parent = parent\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the module's parent.\n\t\treturns: The module's parent.\n\tEnd Rem\n\tMethod GetParent:mxModuleScope()\n\t\tReturn m_parent\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the full name of the module (e.g. \"modscope.module\").\n\t\treturns: The full name of the module.\n\tEnd Rem\n\tMethod GetFullName:String()\n\t\tReturn m_parent.m_name + \".\" + m_name\n\tEnd Method\n\t\n'#end region Field accessors\n\t\n\tRem\n\t\tbbdoc: Add the given version to the module.\n\t\treturns: True if the version was added, or False if it was not (the version is Null).\n\tEnd Rem\n\tMethod AddVersion:Int(version:mxModuleVersion)\n\t\tIf version <> Null\n\t\t\tm_versions._Insert(version.GetName(), version)\n\t\t\tversion.SetParent(Self)\n\t\t\tReturn True\n\t\tEnd If\n\t\tReturn False\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Check if there is a version with the given name.\n\t\treturns: True if the version was found, or False if it was not.\n\tEnd Rem\n\tMethod HasVersion:Int(name:String)\n\t\tReturn m_versions._Contains(name)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get a version with the given name.\n\t\treturns: The version with the given name, or Null if there is no version with the given name.\n\tEnd Rem\n\tMethod GetVersionWithName:mxModuleVersion(name:String)\n\t\tReturn mxModuleVersion(m_versions._ValueByKey(name))\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the latest (non-dev if available) version for this module.\n\t\treturns: The latest version for this module.\n\t\tabout: The latest version will be returned, or the dev version if it is the only version.\n\tEnd Rem\n\tMethod GetLatestVersion:mxModuleVersion()\n\t\tLocal hver:mxModuleVersion\n\t\tFor Local ver:mxModuleVersion = EachIn VersionEnumerator()\n\t\t\tIf ver.GetName() <> \"dev\"\n\t\t\t\tIf hver = Null Or hver.Compare(ver) = 1\n\t\t\t\t\thver = ver\n\t\t\t\tEnd If\n\t\t\tEnd If\n\t\tNext\n\t\tIf hver = Null\n\t\t\thver = GetVersionWithName(\"dev\")\n\t\tEnd If\n\t\tReturn hver\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set a common field from the given variable.\n\t\treturns: True if the given variable was handled, or False if it was not.\n\tEnd Rem\n\tMethod SetCommonFromVariable:Int(variable:dVariable)\n\t\tIf Super.SetCommonFromVariable(variable) = True\n\t\t\tReturn True\n\t\tElse\n\t\t\tSelect variable.GetName().ToLower()\n\t\t\t\tCase \"versions\"\n\t\t\t\t\tFor Local jobj:dJObject = EachIn dJObject(variable).GetValues()\n\t\t\t\t\t\tAddVersion(New mxModuleVersion.FromJSON(jobj))\n\t\t\t\t\tNext\n\t\t\tEnd Select\n\t\t\tReturn False\n\t\tEnd If\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Load the given dJObject into the module.\n\t\treturns: Itself, or Null if @root is Null.\n\tEnd Rem\n\tMethod FromJSON:mxModule(root:dJObject)\n\t\tIf root <> Null\n\t\t\tSetName(root.GetName())\n\t\t\tFor Local variable:dVariable = EachIn root.GetValues()\n\t\t\t\tSetCommonFromVariable(variable)\n\t\t\tNext\n\t\t\tReturn Self\n\t\tEnd If\n\t\tReturn Null\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the version enumerator for the module.\n\t\treturns: The version enumerator for the module.\n\tEnd Rem\n\tMethod VersionEnumerator:TMapEnumerator()\n\t\tReturn m_versions.ValueEnumerator()\n\tEnd Method\n\t\nEnd Type\n\nRem\n\tbbdoc: Maximus module version.\nEnd Rem\nType mxModuleVersion\n\t\n\tField m_parent:mxModule\n\tField m_name:String, m_url:String\n\tField m_dependencies:mxModuleDependencies\n\t\n\tMethod New()\n\t\tm_dependencies = New mxModuleDependencies\n\tEnd Method\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the version's parent.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetParent(parent:mxModule)\n\t\tm_parent = parent\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the version's parent.\n\t\treturns: The version's parent.\n\tEnd Rem\n\tMethod GetParent:mxModule()\n\t\tReturn m_parent\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the version's name.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetName(name:String)\n\t\tAssert name, \"(mxModuleVersion.SetName) name cannot be Null!\"\n\t\tm_name = name\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the version's name.\n\t\treturns: The version's name.\n\tEnd Rem\n\tMethod GetName:String()\n\t\tReturn m_name\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the version's url.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetUrl(url:String)\n\t\tAssert url, \"(mxModuleVersion.SetUrl) url cannot be Null!\"\n\t\tm_url = url\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the version's url.\n\t\treturns: The version's url.\n\tEnd Rem\n\tMethod GetUrl:String()\n\t\tReturn m_url\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the temporary fetch path for the version's source archive.\n\t\treturns: The temporary file path for the version's source archive.\n\tEnd Rem\n\tMethod GetTemporaryFilePath:String()\n\t\tReturn \"tmp\/\" + m_parent.GetFullName() + \"-\" + m_name + \".zip\"\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the version's dependencies.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetDependencies(dependencies:mxModuleDependencies)\n\t\tm_dependencies = dependencies\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the version's dependencies.\n\t\treturns: The version's dependencies.\n\tEnd Rem\n\tMethod GetDependencies:mxModuleDependencies()\n\t\tReturn m_dependencies\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the version parts for the version.\n\t\treturns: True if the version is development, in which case the parameters are both 0; or False, in which case the parameters are set accordingly.\n\tEnd Rem\n\tMethod GetVersionParts:Int(vmajor:String Var, vminor:String Var)\n\t\tIf m_name <> \"dev\"\n\t\t\tLocal i:Int = m_name.Find(\".\")\n\t\t\tIf i > -1\n\t\t\t\tvmajor = m_name[..i]\n\t\t\t\tvminor = m_name[i + 1..]\n\t\t\tElse\n\t\t\t\tvmajor = m_name ' I'm not sure what other version formats would be used, so I'm just playing a random card here\n\t\t\tEnd If\n\t\t\tReturn False\n\t\tEnd If\n\t\tReturn True\n\tEnd Method\n\t\n'#end region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set a common field from the given variable.\n\t\treturns: True if the given variable was handled, or False if it was not.\n\tEnd Rem\n\tMethod SetCommonFromVariable:Int(variable:dVariable)\n\t\tSelect variable.GetName().ToLower()\n\t\t\tCase \"url\"\n\t\t\t\tSetUrl(variable.ValueAsString())\n\t\t\tCase \"deps\"\n\t\t\t\tm_dependencies.FromJSON(dJArray(variable))\n\t\t\t\tReturn True\n\t\tEnd Select\n\t\tReturn False\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Load the given dJObject into the version.\n\t\treturns: Itself, or Null if @root is Null.\n\tEnd Rem\n\tMethod FromJSON:mxModuleVersion(root:dJObject)\n\t\tIf root <> Null\n\t\t\tSetName(root.GetName())\n\t\t\tFor Local variable:dVariable = EachIn root.GetValues()\n\t\t\t\tSetCommonFromVariable(variable)\n\t\t\tNext\n\t\t\tReturn Self\n\t\tEnd If\n\t\tReturn Null\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the dependency enumerator for the version.\n\t\treturns: The dependency enumerator for the version.\n\tEnd Rem\n\tMethod DependencyEnumerator:TMapEnumerator()\n\t\tReturn m_dependencies.DependencyEnumerator()\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Compare the version with the given version.\n\t\treturns: 0 if the two versions are the same (same in version number alone), 1 if this version is greater than the given, or -1 if the given version is greater than this version.\n\tEnd Rem\n\tMethod Compare:Int(with:Object)\n\t\tLocal ver:mxModuleVersion = mxModuleVersion(with)\n\t\tIf ver <> Null\n\t\t\tIf m_name = ver.m_name\n\t\t\t\tReturn 0\n\t\t\tElse\n\t\t\t\tLocal smajor:String, sminor:String, wmajor:String, wminor:String\n\t\t\t\tLocal sdev:Int = GetVersionParts(smajor, sminor), wdev:Int = ver.GetVersionParts(wmajor, wminor)\n\t\t\t\tIf (sdev = True And wdev = True) Or (smajor = wmajor And sminor = wminor)\n\t\t\t\t\tReturn 0\n\t\t\t\tElse If smajor > wmajor\n\t\t\t\t\tReturn 1\n\t\t\t\tElse If smajor = wmajor\n\t\t\t\t\tIf sminor > wminor\n\t\t\t\t\t\tReturn 1\n\t\t\t\t\tElse\n\t\t\t\t\t\tReturn -1\n\t\t\t\t\tEnd If\n\t\t\t\tElse\n\t\t\t\t\tReturn -1\n\t\t\t\tEnd If\n\t\t\tEnd If\n\t\tEnd If\n\t\tReturn 0\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Fetch the version's source archive.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod FetchSourceArchive()\n\t\tLocal file:String = GetTemporaryFilePath()\n\t\tlogger.LogMessage(\"fetching: \" + GetUrl() + \" -> \" + file + \"~t\", False)\n\t\tIf FileType(file) = FILETYPE_NONE\n\t\t\tLocal stream:TStream = WriteFileExplicitly(file)\n\t\t\tIf stream <> Null\n\t\t\t\tLocal request:TRESTRequest = New TRESTRequest, response:TRESTResponse\n\t\t\t\trequest.SetProgressCallback(_ProgressCallback, New _mxProgressStore)\n\t\t\t\trequest.SetStream(stream)\n\t\t\t\tTry\n\t\t\t\t\tresponse = request.Call(GetUrl(), [\"User-Agent: \" + mainapp.m_useragent], \"GET\")\n\t\t\t\tCatch e:Object\n\t\t\t\t\tstream.Close()\n\t\t\t\t\tDeleteFile(file)\n\t\t\t\t\tlogger.LogMessage(\"\")\n\t\t\t\t\tThrowError(_s(\"error.fetch.archive\", [e.ToString()]))\n\t\t\t\tEnd Try\n\t\t\t\tstream.Close()\n\t\t\t\tIf response.responseCode = 200\n\t\t\t\t\tlogger.LogMessage(_s(\"message.fetch.done\", [String(response.responseCode)]))\n\t\t\t\tElse\n\t\t\t\t\tDeleteFile(file)\n\t\t\t\t\tlogger.LogMessage(\"\")\n\t\t\t\t\tThrowError(_s(\"error.fetch.archive\", [\"Bad response code: \" + String(response.responseCode)]))\n\t\t\t\tEnd If\n\t\t\tElse\n\t\t\t\tThrowError(_s(\"error.writeperms\", [file]))\n\t\t\tEnd If\n\t\tElse\n\t\t\tlogger.LogMessage(_s(\"message.fetch.alreadyfetched\"))\n\t\tEnd If\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Progress callback for source archive fetching.\n\t\treturns: Zero (no error).\n\tEnd Rem\n\tFunction _ProgressCallback:Int(data:Object, dltotal:Double, dlnow:Double, ultotal:Double, ulnow:Double)\n\t\tLocal store:_mxProgressStore = _mxProgressStore(data)\n\t\tLocal prog:Int = (dlnow \/ dltotal) * 100\n\t\tIf prog > store.m_progress + 5\n\t\t\tstore.m_progress = prog\n\t\t\tWriteStdOut(\".\")\n\t\tEnd If\n\t\tReturn 0\n\tEnd Function\n\t\nEnd Type\n\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"34f46cf6eea69d806e688abc584f11303fcbc46b","subject":"Modified driver parent system.","message":"Modified driver parent system.\n","repos":"kfprimm\/maxb3d,kfprimm\/maxb3d","old_file":"core.mod\/driver.bmx","new_file":"core.mod\/driver.bmx","new_contents":"\nStrict\n\nImport BRL.Max2D\nImport Prime.Max2DEx\nImport \"light.bmx\"\nImport \"camera.bmx\"\nImport \"mesh.bmx\"\nImport \"flat.bmx\"\nImport \"sprite.bmx\"\nImport \"terrain.bmx\"\nImport \"bspmodel.bmx\"\n\nPrivate\nFunction ModuleLog(message$)\n\tTMaxB3DLogger.Write \"core\/driver\",message\nEnd Function\n\nPublic\n\nType TMaxB3DShaderData\n\tField _projection:TMatrix\n'\tField _modelview:TMatrix\n\tField _modelviewproj:TMatrix\nEnd Type\n\nGlobal _creategraphicshook=AllocHookId()\n\nType TCaps\n\tField PointSprites\n\tField MaxPointSize#\n\t\n\tMethod CopyBase(caps:TCaps)\n\t\tPointSprites=caps.PointSprites\n\t\tMaxPointSize=caps.MaxPointSize\n\tEnd Method\nEnd Type\n\nType TMaxB3DDriver Extends TMax2DExDriver\n\tGlobal _configs:TWorldConfig[]\n\t\n\tField _texture:TTexture[8],_caps:TCaps\n\tField _prevwidth,_prevheight\n\tField _in_max2d=True\n\t\n\tMethod CreateGraphics:TGraphics( width,height,depth,hertz,flags )\n\t\tRunHooks _creategraphicshook,Null\n\t\tReturn Super.CreateGraphics(width,height,depth,hertz,flags)\n\tEnd Method\n\t\n\tMethod AttachGraphics:TGraphics( widget,flags )\n\t\tRunHooks _creategraphicshook,Null\n\t\tReturn Super.AttachGraphics(widget,flags)\n\tEnd Method\n\t\n\tMethod SetGraphics(g:TGraphics)\n\t\t_parent.SetGraphics(g)\n\t\t_current=g\n\t\tIf _prevwidth<>GraphicsWidth() Or _prevheight<>GraphicsHeight()\n\t\t\tFor Local config:TWorldConfig = EachIn _configs\n\t\t\t\tconfig.Width=GraphicsWidth()\n\t\t\t\tconfig.Height=GraphicsHeight()\n\t\t\tNext\n\t\t\tScaleViewports\t\n\t\t\t_prevwidth=GraphicsWidth();_prevheight=GraphicsHeight()\n\t\tEndIf\n\t\tGlobal firsttime=True\n\t\tIf firsttime\n\t\t\t_caps=GetCaps()\n\t\t\tfirsttime=False\n\t\tEndIf\n\tEnd Method\n\t\n\tMethod MakeBuffer:TBuffer(src:Object,width,height,flags) Abstract\n\t\n\tMethod TextureBuffer:TBuffer(texture:TTexture,frame=0,flags=BUFFER_COLOR)\n\t\tReturn MakeBuffer(texture._frame[frame],texture._width,texture._height,flags)\n\tEnd Method\n\t\n\tMethod SetBuffer(buffer:TBuffer)\n\t\tFor Local config:TWorldConfig = EachIn _configs\n\t\t\tconfig.Width=buffer._width\n\t\t\tconfig.Height=buffer._height\t\t\t\n\t\tNext\n\t\tReturn TMax2DExDriver(_parent).SetBuffer(buffer)\n\tEnd Method\n\t\n\tMethod BackBuffer:TBuffer()\n\t\tReturn TMax2DExDriver(_parent).BackBuffer()\n\tEnd Method\n\n\tMethod GetCaps:TCaps() Abstract\n\t\n\tMethod SetMax2D(enable) Abstract\n\t\n\tMethod DoMax2D()\n\t\tIf Not _in_max2d\n\t\t\t_in_max2d=True\n\t\t\tSetMax2D True\n\t\tEndIf\n\tEnd Method\n\tMethod EndMax2D()\n\t\tIf _in_max2d\n\t\t\t_in_max2d=False\n\t\t\tSetMax2D False\n\t\tEndIf\n\tEnd Method\n\t\n\tMethod Abbr$() Abstract\n\tMethod SetBrush(brush:TBrush,hasalpha,config:TWorldConfig) Abstract\n\tMethod SetCamera(camera:TCamera,config:TWorldConfig) Abstract\n\tMethod SetLight(light:TLight,index) Abstract\t\n\t\n\tMethod BeginEntityRender(entity:TEntity) Abstract\n\tMethod EndEntityRender(entity:TEntity) Abstract\n\t\n\tMethod RenderSurface(surface:TSurfaceRes,brush:TBrush) Abstract\n\tMethod RenderFlat(plane:TFlat) Abstract\t\n\tMethod RenderSprite(sprite:TSprite) Abstract\n\tMethod RenderTerrain(terrain:TTerrain) Abstract\n\tMethod RenderBSPTree(tree:TBSPTree) Abstract\n\t\n\tMethod UpdateTextureRes:TTextureRes(frame:TTextureFrame,flags) Abstract\n\tMethod UpdateSurfaceRes:TSurfaceRes(surface:TSurface) Abstract\n\n\tMethod MergeSurfaceRes:TSurfaceRes(base:TSurface,animation:TSurface,data) Abstract\n\t\t\n\tMethod ScaleViewports()\n\t\tFor Local config:TWorldConfig = EachIn _configs\n\t\t\tFor Local camera:TCamera=EachIn config.List[WORLDLIST_CAMERA]\n\t\t\t\tLocal x,y,width,height\n\t\t\t\tcamera.GetViewport x,y,width,height\n\t\t\t\tLocal sx#=config.Width\/Float(_prevwidth),sy#=config.Height\/Float(_prevheight)\n\t\t\t\tIf width=0\n\t\t\t\t\twidth=GraphicsWidth()\n\t\t\t\tElse\n\t\t\t\t\tx:*sx;width:*sx\n\t\t\t\tEndIf\n\t\t\t\tIf height=0\n\t\t\t\t\theight=GraphicsHeight()\n\t\t\t\tElse\n\t\t\t\t\ty:*sy;height:*sy\n\t\t\t\tEndIf\n\t\t\t\tcamera.SetViewport x,y,width,height\n\t\t\tNext\n\t\tNext\n\tEnd Method\nEnd Type\n","old_contents":"\nStrict\n\nImport BRL.Max2D\nImport Prime.Max2DEx\nImport \"light.bmx\"\nImport \"camera.bmx\"\nImport \"mesh.bmx\"\nImport \"flat.bmx\"\nImport \"sprite.bmx\"\nImport \"terrain.bmx\"\nImport \"bspmodel.bmx\"\n\nPrivate\nFunction ModuleLog(message$)\n\tTMaxB3DLogger.Write \"core\/driver\",message\nEnd Function\n\nPublic\n\nType TMaxB3DShaderData\n\tField _projection:TMatrix\n'\tField _modelview:TMatrix\n\tField _modelviewproj:TMatrix\nEnd Type\n\nGlobal _creategraphicshook=AllocHookId()\n\nType TCaps\n\tField PointSprites\n\tField MaxPointSize#\n\t\n\tMethod CopyBase(caps:TCaps)\n\t\tPointSprites=caps.PointSprites\n\t\tMaxPointSize=caps.MaxPointSize\n\tEnd Method\nEnd Type\n\nType TMaxB3DDriver Extends TMax2DExDriver\n\tGlobal _parent:TMax2DExDriver\n\t\n\tField _texture:TTexture[8],_caps:TCaps\n\tField _prevwidth,_prevheight\n\tField _in_max2d=True\n\tField _configs:TWorldConfig[]\n\t\n\tMethod CreateGraphics:TGraphics( width,height,depth,hertz,flags )\n\t\tRunHooks _creategraphicshook,Null\n\t\tReturn Super.CreateGraphics(width,height,depth,hertz,flags)\n\tEnd Method\n\t\n\tMethod AttachGraphics:TGraphics( widget,flags )\n\t\tRunHooks _creategraphicshook,Null\n\t\tReturn Super.AttachGraphics(widget,flags)\n\tEnd Method\n\t\n\tMethod SetGraphics(g:TGraphics)\n\t\t_parent.SetGraphics(g)\n\t\t_current=g\n\t\tIf _prevwidth<>GraphicsWidth() Or _prevheight<>GraphicsHeight()\n\t\t\tFor Local config:TWorldConfig = EachIn _configs\n\t\t\t\tconfig.Width=GraphicsWidth()\n\t\t\t\tconfig.Height=GraphicsHeight()\n\t\t\tNext\n\t\t\tScaleViewports\t\n\t\t\t_prevwidth=GraphicsWidth();_prevheight=GraphicsHeight()\n\t\tEndIf\n\t\tGlobal firsttime=True\n\t\tIf firsttime\n\t\t\t_caps=GetCaps()\n\t\t\tfirsttime=False\n\t\tEndIf\n\tEnd Method\n\t\n\tMethod MakeBuffer:TBuffer(src:Object,width,height,flags) Abstract\n\t\n\tMethod TextureBuffer:TBuffer(texture:TTexture,frame=0,flags=BUFFER_COLOR)\n\t\tReturn MakeBuffer(texture._frame[frame],texture._width,texture._height,flags)\n\tEnd Method\n\t\n\tMethod SetBuffer(buffer:TBuffer)\n\t\tFor Local config:TWorldConfig = EachIn _configs\n\t\t\tconfig.Width=buffer._width\n\t\t\tconfig.Height=buffer._height\t\t\t\n\t\tNext\n\t\tReturn _parent.SetBuffer(buffer)\n\tEnd Method\n\t\n\tMethod BackBuffer:TBuffer()\n\t\tReturn _parent.BackBuffer()\n\tEnd Method\n\n\tMethod GetCaps:TCaps() Abstract\n\t\n\tMethod SetMax2D(enable) Abstract\n\t\n\tMethod DoMax2D()\n\t\tIf Not _in_max2d\n\t\t\t_in_max2d=True\n\t\t\tSetMax2D True\n\t\tEndIf\n\tEnd Method\n\tMethod EndMax2D()\n\t\tIf _in_max2d\n\t\t\t_in_max2d=False\n\t\t\tSetMax2D False\n\t\tEndIf\n\tEnd Method\n\t\n\tMethod Abbr$() Abstract\n\tMethod SetBrush(brush:TBrush,hasalpha,config:TWorldConfig) Abstract\n\tMethod SetCamera(camera:TCamera,config:TWorldConfig) Abstract\n\tMethod SetLight(light:TLight,index) Abstract\t\n\t\n\tMethod BeginEntityRender(entity:TEntity) Abstract\n\tMethod EndEntityRender(entity:TEntity) Abstract\n\t\n\tMethod RenderSurface(surface:TSurfaceRes,brush:TBrush) Abstract\n\tMethod RenderFlat(plane:TFlat) Abstract\t\n\tMethod RenderSprite(sprite:TSprite) Abstract\n\tMethod RenderTerrain(terrain:TTerrain) Abstract\n\tMethod RenderBSPTree(tree:TBSPTree) Abstract\n\t\n\tMethod UpdateTextureRes:TTextureRes(frame:TTextureFrame,flags) Abstract\n\tMethod UpdateSurfaceRes:TSurfaceRes(surface:TSurface) Abstract\n\n\tMethod MergeSurfaceRes:TSurfaceRes(base:TSurface,animation:TSurface,data) Abstract\n\t\t\n\tMethod ScaleViewports()\n\t\tFor Local config:TWorldConfig = EachIn _configs\n\t\t\tFor Local camera:TCamera=EachIn config.List[WORLDLIST_CAMERA]\n\t\t\t\tLocal x,y,width,height\n\t\t\t\tcamera.GetViewport x,y,width,height\n\t\t\t\tLocal sx#=config.Width\/Float(_prevwidth),sy#=config.Height\/Float(_prevheight)\n\t\t\t\tIf width=0\n\t\t\t\t\twidth=GraphicsWidth()\n\t\t\t\tElse\n\t\t\t\t\tx:*sx;width:*sx\n\t\t\t\tEndIf\n\t\t\t\tIf height=0\n\t\t\t\t\theight=GraphicsHeight()\n\t\t\t\tElse\n\t\t\t\t\ty:*sy;height:*sy\n\t\t\t\tEndIf\n\t\t\t\tcamera.SetViewport x,y,width,height\n\t\t\tNext\n\t\tNext\n\tEnd Method\nEnd Type\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"41158e4601c4daab540e3afc52d48f6d33a4dfc2","subject":"Fixed BlitzMax native code","message":"Fixed BlitzMax native code\n","repos":"devolonter\/flixel-monkey,devolonter\/flixel-monkey,devolonter\/flixel-monkey,devolonter\/flixel-monkey","old_file":"native\/flixel.bmax.bmx","new_file":"native\/flixel.bmax.bmx","new_contents":"\nType flixel\n\t\n\tFunction isMobile:Int()\n\t\tReturn False\n\tEnd Function\n\nEnd Type\n\nFunction resize_array_array_XYZRecord:bb_xyzrecord__1X_1Y_1Z_1Record[][] (arr:bb_xyzrecord__1X_1Y_1Z_1Record[][], leng:Int)\n\tLocal i:Int = arr.length\n\tarr = arr[..leng]\n\t\n\tIf( leng<=i ) Return arr\n\n\tFor Local l:Int = 0 Until Len(arr)\n\t\tarr[l] = arr[l][..leng]\n\tNext\n\t\n\tWhile( i\n\tField fields:TList\t\t\t' TList\n\tField constructor$\n\tField name$\n\t\n\t' Returns an LExposedType for a typeid - recommended to use this instead of creating a new LExposedType and initializing it\n\tFunction ForType:LExposedType(typeid:TTypeId)\n\t\tIf typeid = ObjectTypeId Or typeid = StringTypeId Or typeid._class = ArrayTypeId._class Then\n\t\t\tReturn Null\n\t\tEndIf\n\t\t\n\t\tLocal link:TLink = _exposedTypes.FindLink(typeid)\n\t\tIf link Then\n\t\t\tReturn LExposedType(link.Value())\n\t\tEndIf\n\t\tReturn New LExposedType.InitWithTypeID(typeid)\n\tEnd Function\n\t\n\t' Compares LExposedTypes based on the TTypeId associated with each LExposedType\n\tMethod Compare:Int(other:Object)\n\t\tLocal ot:LExposedType = LExposedType(other)\n\t\tIf other = Null Then\n\t\t\tReturn 1\n\t\tElseIf TTypeId(other) Then\n\t\t\tReturn typeid.Compare(other)\n\t\tElseIf other And Not ot Then\n\t\t\tThrow \"Invalid type to compare LExposedType against\"\n\t\tElse\n\t\t\tReturn typeid.Compare(ot.typeid)\n\t\tEndIf\n\tEnd Method\n\t\n\t' Returns a list of exposed types to iterate over\n\tFunction EnumTypes:TList()\n\t\tReturn _exposedTypes.Copy()\n\tEnd Function\n\t\n\t' Initializes an LExposedType with information for the type passed\n\t' The object returned may not be the one you originally sent the initialize message to\n\t' If there is already an instance for this type, that instance will be returned instead\n\t' of proceeding with intialization\n\tMethod InitWithTypeID:LExposedType(tid:TTypeId)\n\t\tIf tid = ObjectTypeId Or typeid = StringTypeId Or typeid._class = ArrayTypeId._class Then\n\t\t\tReturn Null\n\t\tEndIf\n\t\t\n\t\tLocal lnk:TLink = _exposedTypes.FindLink(tid)\n\t\tIf lnk Then\n\t\t\tReturn LExposedType(lnk.Value())\n\t\tEndIf\n\t\t\n\t\texposed = typeid.Metadata(LUGI_META_EXPOSE).ToInt()>0\n\t\tstatic = typeid.Metadata(LUGI_META_STATIC).ToInt()>0\n\t\tnoclass = typeid.Metadata(LUGI_META_NOCLASS).ToInt()>0\n\t\thidefields = typeid.Metadata(LUGI_META_HIDEFIELDS).ToInt()>0\n\t\tnonew = typeid.Metadata(LUGI_META_DISABLECONSTRUCTOR).ToInt()>0\n\t\t\n\t\tname = typeid.Metadata(LUGI_META_RENAME).Trim()\n\t\tIf Not name Then\n\t\t\tname = typeid.Name()\n\t\tEndIf\n\t\t\n\t\tIf Not (nonew Or (static and noclass)) Then\n\t\t\tconstructor = typeid.Metadata(LUGI_META_CONSTRUCTOR).Trim()\n\t\t\tIf Not constructor Then\n\t\t\t\t' Force New[A-Z_].* as default\n\t\t\t\tconstructor = \"New\"+name[0..1].ToUpper()+name[1..]\n\t\t\tEndIf\n\t\tEndIf\n\t\t\n\t\t__initMethods\n\t\t__initFields\n\t\t\n\t\t_exposedTypes.AddLast(Self)\n\t\t\n\t\tReturn Self\n\tEnd Method\n\t\n\tMethod PreInitBlock:String()\n\t\tLocal outs$=\"\"\n\t\t\n\t\tIf Not (static And noclass) Then\n\t\t\tFor Local m:LExposedMethod = EachIn methods\n\t\t\t\tLocal initString$ = m.PreInitBlock()\n\t\t\t\tIf initString Then\n\t\t\t\t\touts :+ \"~t\" + initString + \"~n\"\n\t\t\t\tEndIf\n\t\t\tNext\n\t\tEndIf\n\t\t\n\t\tIf Not noclass Then\n\t\t\tFor Local f:LExposedField = EachIn fields\n\t\t\t\tLocal initString$ = f.PreInitBlock()\n\t\t\t\tIf initString Then\n\t\t\t\t\touts :+ \"~t\" + initString + \"~n\"\n\t\t\t\tEndIf\n\t\t\tNext\n\t\tEndIf\n\t\t\n\t\tReturn outs\n\tEnd Method\n\t\n\tMethod PostInitBlock:String()\n\t\tIf Not (nonew Or (static And noclass)) Then\n\t\t\tReturn \t\"~tlua_pushlightuserdata lua_vm, Byte Ptr(TTypeId.ForName(~q\" + typeid.Name() + \"~q)._class)\" + ..\n\t\t\t\t\t\"~tlua_pushcclosure lua_vm, p_lugi_new_object, 1\"\n\t\tElseIf static And Not noclass Then\n\t\t\tReturn\t\"~t\"\n\t\tEndIf\n\tEnd Method\n\t\n\tMethod MethodImplementations:String()\n\t\tLocal m:LExposedMethod\n\t\tLocal outs$\n\t\tLocal instMethod% = Not (static And noclass)\n\t\tLocal block$\n\t\t\n\t\tFor m = EachIn methods\n\t\t\tblock = m.Implementation(instMethod)\n\t\t\tIf block Then\n\t\t\t\touts :+ \"~n~n\"+block\n\t\t\tEndIf\n\t\tNext\n\t\t\n\t\tReturn outs\n\tEnd Method\n\t\n\tMethod _exposedInParent:Int(m:TMethod)\n\t\tLocal name$ = m.Name().ToLower()\n\t\t\n\t\tLocal typ:TTypeId = typeid.SuperType()\n\t\tWhile typ\n\t\t\t\n\t\tWend\n\tEnd Method\n\t\n\tMethod __initMethods()\n\t\tmethods = New TList\n\t\t\n\t\tIf Not exposed Then\n\t\t\tReturn\n\t\tEndIf\n\t\t\n\t\t' Build list of exposed methods\n\t\tFor Local m:TMethod = EachIn typeid.Methods()\n\t\t\t\n\t\tNext\n\tEnd Method\n\t\n\tMethod __initFields()\n\t\tfields = New TList\n\t\t\n\t\tIf Not exposed Or hidefields Then\n\t\t\tReturn\n\t\tEndIf\n\t\t\n\t\tFor Local f:TField = EachIn typeid.Fields()\n\t\t\t\n\t\tNext\n\tEnd Method\nEnd Type\n\n' Builds up the information for all types\nFunction BuildTypeInfo()\nEnd Function\n\nPrivate\n\n' Recursively creates the information for types\nFunction _buildTypeInfo(types:TList)\n\t' Iterate over types and load data for them\n\tFor Local tid:TTypeId = EachIn types\n\t\tNew LExposedType.InitWithTypeID(tid)\n\t\t_buildTypeInfo(tid.DerivedTypes())\n\tNext\nEnd Function\n","old_contents":"SuperStrict\n\nImport \"field.bmx\"\nImport \"method.bmx\"\nImport \"metadata.bmx\"\n\nImport Brl.LinkedList\n\nPrivate\n\nGlobal _exposedTypes:TList = New TList\n\nPublic\n\nType LExposedType\n\tField exposed%\n\tField static%\n\tField noclass%\n\tField hidefields%\n\tField nonew%\n\t\n\tField typeid:TTypeId\n\tField methods:TList\t\t\t' TList\n\tField fields:TList\t\t\t' TList\n\tField constructor$\n\tField name$\n\t\n\t' Returns an LExposedType for a typeid - recommended to use this instead of creating a new LExposedType and initializing it\n\tFunction ForType:LExposedType(typeid:TTypeId)\n\t\tIf typeid = ObjectTypeId Or typeid = StringTypeId Or typeid._class = ArrayTypeId._class Then\n\t\t\tReturn Null\n\t\tEndIf\n\t\t\n\t\tLocal link:TLink = _exposedTypes.FindLink(typeid)\n\t\tIf link Then\n\t\t\tReturn LExposedType(link.Value())\n\t\tEndIf\n\t\tReturn New LExposedType.InitWithTypeID(typeid)\n\tEnd Function\n\t\n\t' Compares LExposedTypes based on the TTypeId associated with each LExposedType\n\tMethod Compare:Int(other:Object)\n\t\tReturn typeid.Compare(LExposedType(other).typeid)\n\tEnd Method\n\t\n\t' Returns a list of exposed types to iterate over\n\tFunction EnumTypes:TList()\n\t\tReturn _exposedTypes.Copy()\n\tEnd Function\n\t\n\t' Initializes an LExposedType with information for the type passed\n\t' The object returned may not be the one you originally sent the initialize message to\n\t' If there is already an instance for this type, that instance will be returned instead\n\t' of proceeding with intialization\n\tMethod InitWithTypeID:LExposedType(tid:TTypeId)\n\t\tIf tid = ObjectTypeId Or typeid = StringTypeId Or typeid._class = ArrayTypeId._class Then\n\t\t\tReturn Null\n\t\tEndIf\n\t\t\n\t\tLocal lnk:TLink = _exposedTypes.FindLink(tid)\n\t\tIf lnk Then\n\t\t\tReturn LExposedType(lnk.Value())\n\t\tEndIf\n\t\t\n\t\texposed = typeid.Metadata(LUGI_META_EXPOSE).ToInt()>0\n\t\tstatic = typeid.Metadata(LUGI_META_STATIC).ToInt()>0\n\t\tnoclass = typeid.Metadata(LUGI_META_NOCLASS).ToInt()>0\n\t\thidefields = typeid.Metadata(LUGI_META_HIDEFIELDS).ToInt()>0\n\t\tnonew = typeid.Metadata(LUGI_META_DISABLECONSTRUCTOR).ToInt()>0\n\t\t\n\t\tname = typeid.Metadata(LUGI_META_RENAME).Trim()\n\t\tIf Not name Then\n\t\t\tname = typeid.Name()\n\t\tEndIf\n\t\t\n\t\tIf Not (nonew Or (static and noclass)) Then\n\t\t\tconstructor = typeid.Metadata(LUGI_META_CONSTRUCTOR).Trim()\n\t\t\tIf Not constructor Then\n\t\t\t\t' Force New[A-Z_].* as default\n\t\t\t\tconstructor = \"New\"+name[0..1].ToUpper()+name[1..]\n\t\t\tEndIf\n\t\tEndIf\n\t\t\n\t\t__initMethods\n\t\t__initFields\n\t\t\n\t\t_exposedTypes.AddLast(Self)\n\t\t\n\t\tReturn Self\n\tEnd Method\n\t\n\tMethod PreInitBlock:String()\n\t\tLocal outs$=\"\"\n\t\t\n\t\tIf Not (static And noclass) Then\n\t\t\tFor Local m:LExposedMethod = EachIn methods\n\t\t\t\tLocal initString$ = m.PreInitBlock()\n\t\t\t\tIf initString Then\n\t\t\t\t\touts :+ \"~t\" + initString + \"~n\"\n\t\t\t\tEndIf\n\t\t\tNext\n\t\tEndIf\n\t\t\n\t\tIf Not noclass Then\n\t\t\tFor Local f:LExposedField = EachIn fields\n\t\t\t\tLocal initString$ = f.PreInitBlock()\n\t\t\t\tIf initString Then\n\t\t\t\t\touts :+ \"~t\" + initString + \"~n\"\n\t\t\t\tEndIf\n\t\t\tNext\n\t\tEndIf\n\t\t\n\t\tReturn outs\n\tEnd Method\n\t\n\tMethod PostInitBlock:String()\n\t\tIf Not (nonew Or (static And noclass)) Then\n\t\t\tReturn \t\"~tlua_pushlightuserdata lua_vm, Byte Ptr(TTypeId.ForName(~q\" + typeid.Name() + \"~q)._class)\" + ..\n\t\t\t\t\t\"~tlua_pushcclosure lua_vm, p_lugi_new_object, 1\"\n\t\tElseIf static And Not noclass Then\n\t\t\tReturn\t\"~t\"\n\t\tEndIf\n\tEnd Method\n\t\n\tMethod MethodImplementations:String()\n\t\tLocal m:LExposedMethod\n\t\tLocal outs$\n\t\tLocal instMethod% = Not (static And noclass)\n\t\tLocal block$\n\t\t\n\t\tFor m = EachIn methods\n\t\t\tblock = m.Implementation(instMethod)\n\t\t\tIf block Then\n\t\t\t\touts :+ \"~n~n\"+block\n\t\t\tEndIf\n\t\tNext\n\t\t\n\t\tReturn outs\n\tEnd Method\n\t\n\tMethod _exposedInParent:Int(m:TMethod)\n\t\tLocal name$ = m.Name().ToLower()\n\t\t\n\t\tLocal typ:TTypeId = typeid.SuperType()\n\t\tWhile typ\n\t\t\t\n\t\tWend\n\tEnd Method\n\t\n\tMethod __initMethods()\n\t\tmethods = New TList\n\t\t\n\t\tIf Not exposed Then\n\t\t\tReturn\n\t\tEndIf\n\t\t\n\t\t' Build list of exposed methods\n\t\tFor Local m:TMethod = EachIn typeid.Methods()\n\t\t\t\n\t\tNext\n\tEnd Method\n\t\n\tMethod __initFields()\n\t\tfields = New TList\n\t\t\n\t\tIf Not exposed Or hidefields Then\n\t\t\tReturn\n\t\tEndIf\n\t\t\n\t\tFor Local f:TField = EachIn typeid.Fields()\n\t\t\t\n\t\tNext\n\tEnd Method\nEnd Type\n\n' Builds up the information for all types\nFunction BuildTypeInfo()\nEnd Function\n\nPrivate\n\n' Recursively creates the information for types\nFunction _buildTypeInfo(types:TList)\n\t' Iterate over types and load data for them\n\tFor Local tid:TTypeId = EachIn types\n\t\tNew LExposedType.InitWithTypeID(tid)\n\t\t_buildTypeInfo(tid.DerivedTypes())\n\tNext\nEnd Function\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"ac7362704fb2b5f1e8a857536b8c8199c7dbe707","subject":"Fixed Win32 build issue.","message":"Fixed Win32 build issue.\n","repos":"kfprimm\/maxb3d,kfprimm\/maxb3d","old_file":"d3d9driver.mod\/d3d9driver.bmx","new_file":"d3d9driver.mod\/d3d9driver.bmx","new_contents":"\nStrict\n\nRem\n\tbbdoc: Direct3D 9 renderer for MaxB3D\nEnd Rem\nModule MaxB3D.D3D9Driver\nModuleInfo \"Author: Kevin Primm\"\nModuleInfo \"License: MIT\"\n\nImport MaxB3D.Core\nImport Prime.D3D9Max2DEx\nImport Prime.DirectXEx\n\n?Win32\n\nImport \"d3d9.cpp\"\n\nPrivate \n\nExtern \"C\"\n\tFunction maxb3dD3D9VertexElements:Byte Ptr()'=\"_maxb3dD3D9VertexElements@0\"\nEnd Extern\n\nFunction GetD3D9MaxB3DVertexDecl:IDirect3DVertexDeclaration9(d3ddev:IDirect3DDevice9)\n\tGlobal decl:IDirect3DVertexDeclaration9,dev:IDirect3DDevice9\n\tIf decl=Null Or dev<>d3ddev\n\t\tAssert d3ddev.CreateVertexDeclaration(maxb3dD3D9VertexElements(),decl)=D3D_OK,\"Failed to create vertex declaration.\"\n\t\tdev=d3ddev\n\tEndIf\n\tReturn decl\nEnd Function\n\nFunction Pow2Size( n )\n\tLocal t=1\n\tWhile tNull\n\t\t\t_d3ddev=TD3D9Graphics(TMax2DGraphics(g)._graphics).GetDirect3DDevice()\n\t\t\tEndMax2D\n\t\tEndIf\n\tEnd Method\n\t\t\n\tMethod MakeBuffer:TBuffer(src:Object,width,height,flags)\n\t\tReturn _parent.MakeBuffer(src,width,height,flags)\n\tEnd Method\n\t\n\tMethod GetCaps:TCaps()\n\t\tLocal caps:TCaps=New TCaps\n\t\tReturn caps\n\tEnd Method\n\t\n\tMethod Abbr$()\n\t\tReturn \"d3d9\"\n\tEnd Method\n\t\n\tMethod SetMax2D(enable)\n\t\tIf enable\n\t\t\tGlobal identity:TMatrix=TMatrix.Identity()\n\t\t\tLocal width=GraphicsWidth(),height=GraphicsHeight()\n\t\t\tLocal matrix#[]=[..\n\t\t\t2.0\/width,0.0,0.0,0.0,..\n\t\t\t 0.0,-2.0\/height,0.0,0.0,..\n\t\t\t 0.0,0.0,1.0,0.0,..\n\t\t\t -1-(1.0\/width),1+(1.0\/height),1.0,1.0]\n\t\t\t\n\t\t\t_d3ddev.SetTransform D3DTS_PROJECTION,matrix\n\t\t\t_d3ddev.SetTransform D3DTS_WORLD,identity.ToPtr()\n\t\t\t_d3ddev.SetTransform D3DTS_VIEW,identity.ToPtr()\n\t\t\t_d3ddev.SetTransform D3DTS_TEXTURE0,identity.ToPtr()\n\t\t\t\n\t\t\t_d3ddev.SetVertexDeclaration Null\n\t\t\t_d3ddev.SetIndices Null\n\t\t\t_d3ddev.SetFVF D3DFVF_XYZ|D3DFVF_DIFFUSE|D3DFVF_TEX1\n\t\t\t\n\t\t\t_d3ddev.SetRenderState D3DRS_LIGHTING,False\n\t\t\t_d3ddev.SetRenderState D3DRS_ZENABLE,False\n\t\t\t_d3ddev.SetRenderState D3DRS_SCISSORTESTENABLE,_viewporton\t\t\n\t\t\t\n\t\t\t_d3ddev.SetRenderState D3DRS_ALPHATESTENABLE,True\n\t\t\t\n\t\t\t_d3ddev.SetRenderState D3DRS_WRAP0, 0\n\t\t\t\n\t\t\t_d3ddev.SetRenderState D3DRS_FOGENABLE,False\n\t\t\t\n\t\t\tFor Local i=2 To 7\n\t\t\t\t_d3ddev.SetTexture i,Null\n\t\t\tNext\n\t\t\t\n\t\t\t_d3ddev.SetTextureStageState 0,D3DTSS_COLOROP,D3DTOP_MODULATE\n\t\t\t_d3ddev.SetTextureStageState 0,D3DTSS_ALPHAOP,D3DTOP_MODULATE\n\t\t\t\n\t\t\t_d3ddev.SetRenderState D3DRS_CULLMODE,D3DCULL_NONE\n\t\t\t_d3ddev.SetRenderState D3DRS_FILLMODE,D3DFILL_SOLID\n\t\tElse\n\t\t\t_d3ddev.SetRenderState D3DRS_ZENABLE,True\n\t\t\t_d3ddev.SetRenderState D3DRS_ZWRITEENABLE,True\n\t\n\t\t\t_d3ddev.GetRenderState D3DRS_SCISSORTESTENABLE,_viewporton\n\t\t\t_d3ddev.SetRenderState D3DRS_SCISSORTESTENABLE,True\n\t\t\t\n\t\t\t_d3ddev.SetRenderState D3DRS_LIGHTING,True\n\t\t\t_d3ddev.SetRenderState D3DRS_NORMALIZENORMALS,True\n\t\t\t_d3ddev.SetRenderState D3DRS_AMBIENT,D3DCOLOR_RGB(WorldConfig.AmbientRed,WorldConfig.AmbientGreen,WorldConfig.AmbientBlue)\n\t\t\t_d3ddev.SetRenderState D3DRS_COLORVERTEX, True\n\t\t\t_d3ddev.SetRenderState D3DRS_DIFFUSEMATERIALSOURCE,D3DMCS_MATERIAL\n\t\t\t\n\t\t\t_d3ddev.SetRenderState D3DRS_SHADEMODE,D3DSHADE_GOURAUD\n\t\t\t\n\t\t\t'_d3ddev.SetRenderState D3DRS_ALPHAREF, 1\n\t\t\t'_d3ddev.SetRenderState D3DRS_ALPHAFUNC, D3DCMP_GREATEREQUAL\n\t\t\t\t\t\n\t\t\t_d3ddev.SetRenderState D3DRS_CULLMODE,D3DCULL_CW\t\n\t\tEndIf\t\n\tEnd Method\n\t\n\tMethod SetCamera(camera:TCamera)\n\t\tLocal clearflags\t\t\n\t\tIf camera._clsmode&CLSMODE_COLOR clearflags:|D3DCLEAR_TARGET\n\t\tIf camera._clsmode&CLSMODE_DEPTH clearflags:|D3DCLEAR_ZBUFFER\n\n\t\tLocal viewport[]=[camera._viewx,camera._viewy,camera._viewwidth-camera._viewx,camera._viewheight-camera._viewy]\n\t\t_d3ddev.SetScissorRect viewport\n\t\t_d3ddev.Clear(1,viewport,clearflags,D3DCOLOR_XRGB(camera._brush._r*255,camera._brush._g*255,camera._brush._b*255),1.0,0)\n\t\t\n\t\tSelect camera._fogmode\n\t\tCase FOGMODE_LINEAR\n\t\t\t_d3ddev.SetRenderState D3DRS_FOGENABLE,True\n\t\t\t_d3ddev.SetRenderState D3DRS_FOGSTART,Int(Varptr camera._fognear)\n\t\t\t_d3ddev.SetRenderState D3DRS_FOGEND,Int(Varptr camera._fogfar)\n\t\tDefault\n\t\t\t_d3ddev.SetRenderState D3DRS_FOGENABLE,False\n\t\tEnd Select\n\t\t\n\t\tLocal ratio#=(Float(camera._viewwidth)\/camera._viewheight)\t\t\n\t\tLocal proj_matrix:TMatrix=TMatrix.PerspectiveFovRH(ATan((1.0\/(camera._zoom*ratio)))*2.0,ratio#,Max(0,camera._near-0.396250010),camera._far) ' Ugly hack. Real cause needs investigation.\n\t\tproj_matrix=TMatrix.Scale(-1,1,-1).Multiply(proj_matrix)\n\t\t_d3ddev.SetTransform D3DTS_PROJECTION,proj_matrix.ToPtr()\n\t\t\n\t\tLocal matrix:TMatrix=camera._matrix.Inverse()\n\t\t_d3ddev.SetTransform D3DTS_VIEW,matrix.ToPtr()\n\t\t\n\t\tcamera._lastmodelview=matrix\n\t\tcamera._lastprojection=proj_matrix\n\t\t\n\t\tcamera._lastviewport[0]=camera._viewx\n\t\tcamera._lastviewport[1]=camera._viewy\n\t\tcamera._lastviewport[2]=camera._viewwidth\n\t\tcamera._lastviewport[3]=camera._viewheight\n\t\t\n\t\tcamera._lastfrustum=TFrustum.Extract(camera._lastmodelview,camera._lastprojection)\n\tEnd Method\n\t\n\tMethod SetLight(light:TLight,index)\n\t\tIf light=Null \n\t\t\t_d3ddev.LightEnable index,False\n\t\t\tReturn\n\t\tEndIf\n\t\t\n\t\tLocal brush:TBrush=light._brush\n\n\t\tGlobal d3dlight:D3DLIGHT9=New D3DLIGHT9\n\t\td3dlight.Type_=D3DLIGHT_DIRECTIONAL \n\t\td3dlight.Diffuse_r=brush._r;d3dlight.Diffuse_g=brush._g;d3dlight.Diffuse_b=brush._b;d3dlight.Diffuse_a=brush._a\n\t\t'd3dlight.Ambient_r=WorldConfig.AmbientRed\/255.0;d3dlight.Ambient_g=WorldConfig.AmbientGreen\/255.0;d3dlight.Ambient_b=WorldConfig.AmbientBlue\/255.0;d3dlight.Ambient_a=1.0\n\t\t\n\t\td3dlight.Direction_x=0.0;d3dlight.Direction_y=0.0;d3dlight.Direction_z=1.0\n\t\t\t\t\n\t\tLocal matrix:TMatrix=light._matrix\n\t\tmatrix.TransformVec3 d3dlight.Direction_x,d3dlight.Direction_y,d3dlight.Direction_z\n\t\tmatrix.GetPosition d3dlight.Position_x,d3dlight.Position_y,d3dlight.Position_z\t\t\n\t\t\n\t\td3dlight.Range=light._range\t\t\n\t\t\n\t\t_d3ddev.SetLight index,d3dlight\n\t\t_d3ddev.LightEnable index,True\n\tEnd Method\n\t\n\tMethod SetBrush(brush:TBrush,hasalpha)\n\t\t_d3ddev.SetRenderState D3DRS_ALPHATESTENABLE,False\n\t\t\n\t\tLocal alpha_blending = (brush._fx&FX_FORCEALPHA Or hasalpha)>0\n\t\t_d3ddev.SetRenderState D3DRS_ALPHABLENDENABLE,alpha_blending \n\t\t_d3ddev.SetRenderState D3DRS_ZWRITEENABLE,Not alpha_blending \n\t\t\n\t\tIf brush._fx&FX_FULLBRIGHT\n\t\t\t_d3ddev.SetRenderState D3DRS_AMBIENT,$ffffffff\n\t\tElse\n\t\t\t_d3ddev.SetRenderState D3DRS_AMBIENT,D3DCOLOR_RGB(WorldConfig.AmbientRed,WorldConfig.AmbientGreen,WorldConfig.AmbientBlue)\n\t\tEndIf\n\t\t\n\t\tIf brush._fx&FX_NOCULLING\n\t\t\t_d3ddev.SetRenderState D3DRS_CULLMODE,D3DCULL_NONE\n\t\tElse\n\t\t\t_d3ddev.SetRenderState D3DRS_CULLMODE,D3DCULL_CW\n\t\tEndIf\n\t\t\n\t\tIf brush._fx&FX_WIREFRAME Or WorldConfig.Wireframe\n\t\t\t_d3ddev.SetRenderState D3DRS_FILLMODE,D3DFILL_WIREFRAME\n\t\tElse\n\t\t\t_d3ddev.SetRenderState D3DRS_FILLMODE,D3DFILL_SOLID\n\t\tEndIf\n\t\t\n\t\tLocal material:D3DMATERIAL9 = New D3DMATERIAL9\n\t\tmaterial.Diffuse_r=brush._r;material.Diffuse_g=brush._g;material.Diffuse_b=brush._b;material.Diffuse_a=brush._a\n\t\tmaterial.Ambient_r=brush._r;material.Ambient_g=brush._g;material.Ambient_b=brush._b;material.Ambient_a=brush._a\n\n\t\t_d3ddev.SetMaterial material\n\t\t\n\t\tFor Local i=0 To 7\n\t\t\tLocal texture:TTexture=brush._texture[i]\n\t\t\tIf texture=Null Or texture._blend=BLEND_NONE \n\t\t\t\t_d3ddev.SetTexture i,Null\n\t\t\t\tContinue\n\t\t\tEndIf\n\t\t\t\n\t\t\t_d3ddev.SetTexture i,UpdateTextureRes(texture._frame[brush._textureframe[i]],texture._flags)._tex\n\n\t\t\tLocal matrix:TMatrix=TMatrix.Identity()\n\t\t\t'matrix._m[0,0]=-texture._sx\n\t\t\t'matrix._m[1,1]=texture._sy\n\t\t\tmatrix=TMatrix.YawPitchRoll(0,0,-texture._r).Multiply(matrix)\n\t\t\tmatrix=TMatrix.Scale(-texture._sx,texture._sy,1).Multiply(matrix)\n\t\t\tmatrix._m[2,0]=-texture._px\n\t\t\tmatrix._m[2,1]=-texture._py\n\t\t\t\n\t\t\t_d3ddev.SetTransform D3DTS_TEXTURE0+i,matrix.ToPtr()\n\n\t\t\t_d3ddev.SetTextureStageState i,D3DTSS_TEXTURETRANSFORMFLAGS,D3DTTFF_COUNT2\n\t\t\t\n\t\t\t_d3ddev.SetSamplerState i,D3DSAMP_MAGFILTER,D3DTEXF_LINEAR\n\t\t\t_d3ddev.SetSamplerState i,D3DSAMP_MINFILTER,D3DTEXF_LINEAR\n\t\t\t\t\t\t\n\t\t\t_d3ddev.SetRenderState D3DRS_ALPHATESTENABLE, texture._flags&TEXTURE_ALPHA\t\t\t\n\t\t\t\n\t\t\tIf texture._flags&TEXTURE_MIPMAP\t\t\t\t\n\t\t\t\t_d3ddev.SetSamplerState i,D3DSAMP_MIPFILTER,D3DTEXF_LINEAR\n\t\t\tElse\n\t\t\t\t_d3ddev.SetSamplerState i,D3DSAMP_MIPFILTER,D3DTEXF_NONE\n\t\t\tEndIf\n\t\t\t\n\t\t\tIf texture._flags&TEXTURE_CLAMPU\n\t\t\t\t_d3ddev.SetSamplerState i,D3DSAMP_ADDRESSU,D3DTADDRESS_CLAMP\n\t\t\tElse\n\t\t\t\t_d3ddev.SetSamplerState i,D3DSAMP_ADDRESSU,D3DTADDRESS_WRAP\n\t\t\tEndIf\n\t\t\t\n\t\t\tIf texture._flags&TEXTURE_CLAMPV\n\t\t\t\t_d3ddev.SetSamplerState i,D3DSAMP_ADDRESSU,D3DTADDRESS_CLAMP\n\t\t\tElse\n\t\t\t\t_d3ddev.SetSamplerState i,D3DSAMP_ADDRESSV,D3DTADDRESS_WRAP\n\t\t\tEndIf\n\t\t\t\n\t\t\tIf texture._flags&TEXTURE_SPHEREMAP\n\t\t\t\t_d3ddev.SetTextureStageState i,D3DTSS_TEXCOORDINDEX,D3DTSS_TCI_SPHEREMAP\n\t\t\tElse\n\t\t\t\t_d3ddev.SetTextureStageState i,D3DTSS_TEXCOORDINDEX,texture._coords\n\t\t\tEndIf\n\t\t\t\n\t\t\t'_d3ddev.SetTextureStageState i,D3DTSS_COLOROP,D3DTOP_SELECTARG1\n\t\t\t'_d3ddev.SetTextureStageState i,D3DTSS_ALPHAOP,D3DTOP_SELECTARG2\n\t\t\t\n\t\t\tSelect texture._blend\n\t\t\tCase BLEND_ALPHA\n\t\t\t\t'glTexEnvf(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_DECAL)\n\t\t\tCase BLEND_MULTIPLY\n\t\t\t\t_d3ddev.SetTextureStageState i,D3DTSS_COLOROP,D3DTOP_MODULATE\n\t\t\t\t_d3ddev.SetTextureStageState i,D3DTSS_ALPHAOP,D3DTOP_MODULATE\n\t\t\tCase BLEND_ADD\n\t\t\t\t_d3ddev.SetTextureStageState i,D3DTSS_COLOROP,D3DTOP_ADD\n\t\t\t\t_d3ddev.SetTextureStageState i,D3DTSS_ALPHAOP,D3DTOP_ADD\n\t\t\tCase BLEND_DOT3\n\t\t\t\t_d3ddev.SetTextureStageState i,D3DTSS_COLOROP,D3DTOP_DOTPRODUCT3\n\t\t\t\t_d3ddev.SetTextureStageState i,D3DTSS_ALPHAOP,D3DTOP_DOTPRODUCT3\n\t\t\tCase BLEND_MULTIPLY2\n\t\t\t\t_d3ddev.SetTextureStageState i,D3DTSS_COLOROP,D3DTOP_MODULATE2X\n\t\t\t\t_d3ddev.SetTextureStageState i,D3DTSS_ALPHAOP,D3DTOP_MODULATE2X\n\t\t\tDefault\n\t\t\t\t_d3ddev.SetTextureStageState i,D3DTSS_COLOROP,D3DTOP_MODULATE\n\t\t\t\t_d3ddev.SetTextureStageState i,D3DTSS_ALPHAOP,D3DTOP_MODULATE\n\t\t\tEnd Select\t\t\t\n\t\tNext\n\tEnd Method\n\t\n\tMethod RenderSurface(resource:TSurfaceRes,brush:TBrush)\n\t\tLocal res:TD3D9SurfaceRes=TD3D9SurfaceRes(resource)\n\t\t\n\t\t_d3ddev.SetFVF 0\n\t\t_d3ddev.SetVertexDeclaration GetD3D9MaxB3DVertexDecl(_d3ddev)\n\t\t_d3ddev.SetStreamSource 0,res._pos,0,12\n\t\t_d3ddev.SetStreamSource 1,res._nml,0,12\n\t\t_d3ddev.SetStreamSource 2,res._clr,0,16\n\t\t_d3ddev.SetStreamSource 3,res._tex[0],0,8\n\t\t_d3ddev.SetIndices res._tri\n\t\t_d3ddev.DrawIndexedPrimitive D3DPT_TRIANGLELIST,0,0,res._vertexcnt,0,res._trianglecnt\n\n\t\tReturn res._trianglecnt\n\tEnd Method\n\t\n\tMethod RenderSprite(sprite:TSprite)\t\n\t\tGlobal _data#[]=[ -1.0, 1.0,0.0, 0.0,0.0,1.0, 0.0,0.0, ..\n\t\t 1.0, 1.0,0.0, 0.0,0.0,1.0, 1.0,0.0, ..\n\t\t -1.0,-1.0,0.0, 0.0,0.0,1.0, 0.0,1.0, ..\n\t\t 1.0,-1.0,0.0, 0.0,0.0,1.0, 1.0,1.0 ]\n\t\t\n\t\t_d3ddev.SetVertexDeclaration Null\n\t\t_d3ddev.SetFVF D3DFVF_XYZ|D3DFVF_NORMAL|D3DFVF_TEX1\n\t\t_d3ddev.DrawPrimitiveUP D3DPT_TRIANGLESTRIP,2,_data,8*4\n\tEnd Method\n\t\n\tMethod BeginEntityRender(entity:TEntity)\n\t\t_d3ddev.SetTransform D3DTS_WORLD,entity.GetMatrix(True).ToPtr()\n\tEnd Method\n\t\n\tMethod EndEntityRender(entity:TEntity)\n\tEnd Method\n\t\n\tMethod RenderFlat(flat:TFlat)\n\t\tLocal x#,y#,z#\n\t\tflat.GetScale x,y,z,True\n\n\t\tGlobal _data#[]=[ -1.0,0.0, 1.0, 0.0,1.0,0.0, 0.0,0.0, ..\n\t\t 1.0,0.0, 1.0, 0.0,1.0,0.0, x,0.0, ..\n\t\t -1.0,0.0,-1.0, 0.0,1.0,0.0, 0.0, z, ..\n\t\t 1.0,0.0,-1.0, 0.0,1.0,0.0, x, z ]\t\t\n\t\t\n\t\t_d3ddev.SetVertexDeclaration Null\n\t\t_d3ddev.SetFVF D3DFVF_XYZ|D3DFVF_NORMAL|D3DFVF_TEX1\n\t\t_d3ddev.DrawPrimitiveUP D3DPT_TRIANGLESTRIP,2,_data,8*4\n\tEnd Method\n\t\n\tMethod RenderTerrain(terrain:TTerrain)\n\tEnd Method\n\t\n\tMethod RenderBSPTree(tree:TBSPTree)\n\t\tLocal node:TBSPNode=tree.Node\n\t\tIf node=Null Return\n\t\tLocal triangles\n\t\ttriangles:+RenderBSPTree(node.In)\n\t\t\n\t\t_d3ddev.SetVertexDeclaration Null\n\t\t_d3ddev.SetFVF D3DFVF_XYZ|D3DFVF_NORMAL|D3DFVF_TEX1\n\t\t\t\t\n\t\tFor Local poly:TBSPPolygon=EachIn node.On\n\t\t\tLocal ptA:TVector=poly.Point[0],v0\n\t\t\tLocal trianglecnt=poly.Count()-2\n\t\t\tLocal data#[trianglecnt*24],dataptr:Float Ptr=data\n\t\t\tFor Local i=0 To trianglecnt-1\n\t\t\t\tLocal ptB:TVector=poly.Point[i+1],ptC:TVector=poly.Point[i+2]\n\t\t\t\tdata[i*24+00]=ptA.x;data[i*24+01]=ptA.y;data[i*24+02]=ptA.z;data[i*24+03]=poly.Plane.x;data[i*24+04]=poly.Plane.y;\tdata[i*24+05]=poly.Plane.z;data[i*24+06]=0.0;data[i*24+07]=0.0\n\t\t\t\tdata[i*24+08]=ptB.x;data[i*24+09]=ptB.y;data[i*24+10]=ptB.z;data[i*24+11]=poly.Plane.x;data[i*24+12]=poly.Plane.y;\tdata[i*24+13]=poly.Plane.z;data[i*24+14]=0.0;data[i*24+15]=0.0\n\t\t\t\tdata[i*24+16]=ptC.x;data[i*24+17]=ptC.y;data[i*24+18]=ptC.z;data[i*24+19]=poly.Plane.x;data[i*24+20]=poly.Plane.y;data[i*24+21]=poly.Plane.z;data[i*24+22]=0.0;data[i*24+23]=0.0\n\t\t\tNext\n\t\t\t_d3ddev.DrawPrimitiveUP D3DPT_TRIANGLELIST,trianglecnt,data,8*4\n\t\t\ttriangles:+trianglecnt\n\t\tNext\n\t\t\t\t\n\t\ttriangles:+RenderBSPTree(node.Out)\n\t\tReturn triangles\n\tEnd Method\n\t\n\tMethod UpdateTextureRes:TD3D9TextureRes(frame:TTextureFrame,flags)\n\t\tLocal res:TD3D9TextureRes=TD3D9TextureRes(frame._res)\n\t\tIf res And frame._updateres=False Return res\n\n\t\tIf res=Null res=New TD3D9TextureRes\n\t\tframe._res=res\n\t\t\n\t\tLocal pixmap:TPixmap=frame._pixmap\n\t\tLocal tex_width=Pow2Size(pixmap.width),tex_height=Pow2Size(pixmap.height)\n\t\tpixmap=ConvertPixmap(ResizePixmap(pixmap,tex_width,tex_height),PF_BGRA8888)\n\t\tIf res._tex=Null Assert _d3ddev.CreateTexture(tex_width,tex_height,(flags & TEXTURE_MIPMAP)=0,D3DUSAGE_AUTOGENMIPMAP,D3DFMT_A8R8G8B8,D3DPOOL_MANAGED,res._tex,Null)=D3D_OK\n\t\t\n\t\tLocal rect:D3DLOCKED_RECT=New D3DLOCKED_RECT \n\t\tres._tex.LockRect 0,rect,Null,0\n\t\tMemCopy rect.pBits,pixmap.pixels,pixmap.width*pixmap.height*4\n\t\tres._tex.UnlockRect 0\n\t\t\n\t\tframe._updateres=False\n\t\t\t\t\n\t\tReturn res\n\tEnd Method\n\t\n\tMethod UpdateSurfaceRes:TD3D9SurfaceRes(surface:TSurface)\n\t\tLocal res:TD3D9SurfaceRes=TD3D9SurfaceRes(surface._res)\n\t\tIf res=Null res=New TD3D9SurfaceRes;surface._reset=-1\n\t\t\n\t\tIf surface._reset=0 Return res\t\t\n\t\tIf surface._reset=-1 surface._reset=1|2|4|8|16|32|64|128|256\n\n\t\tIf surface._reset&1 And surface._vertexpos UploadVertexData res._pos,surface._vertexpos\n\t\tIf surface._reset&2 And surface._vertexnml UploadVertexData res._nml,surface._vertexnml\n\t\tIf surface._reset&4 And surface._vertexclr UploadVertexData res._clr,surface._vertexclr\n\t\tIf surface._reset&8 And surface._triangle\n\t\t\tIf res._tri=Null _d3ddev.CreateIndexBuffer(surface._triangle.length*4,0,D3DFMT_INDEX32,D3DPOOL_MANAGED,res._tri,Null)\n\t\t\tLocal dataptr:Byte Ptr\n\t\t\tAssert res._tri.Lock(0,0,dataptr,0)=D3D_OK,\"Failed to lock index buffer.\"\n\t\t\tMemCopy dataptr,surface._triangle,surface._triangle.length*4\t\t\n\t\t\tres._tri.Unlock()\n\t\tEndIf\n\t\t\n\t\tFor Local i=0 To surface._vertextex.length-1\n\t\t\tIf surface._reset&Int(2^(4+i)) UploadVertexData res._tex[i],surface._vertextex[i]\n\t\tNext\n\t\t\n\t\tres._trianglecnt=surface._trianglecnt\n\t\tres._vertexcnt=surface._vertexcnt\n\t\t\n\t\tsurface._reset=0\n\t\tsurface._res=res\n\t\t\n\t\tReturn res\n\tEnd Method\n\n\tMethod MergeSurfaceRes:TSurfaceRes(base:TSurface,animation:TSurface,data)\n\t\tIf animation=Null Return UpdateSurfaceRes(base)\n\t\tLocal base_res:TD3D9SurfaceRes=UpdateSurfaceRes(base)\n\t\tLocal anim_res:TD3D9SurfaceRes=UpdateSurfaceRes(animation)\n\t\tLocal res:TD3D9SurfaceRes=base_res.Copy()\n\t\tres._pos=anim_res._pos\n\t\tReturn res\n\tEnd Method\n\t\n\tMethod UploadVertexData(buffer:IDirect3DVertexBuffer9 Var,data#[])\n\t\tIf buffer=Null _d3ddev.CreateVertexBuffer(data.length*4,0,0,D3DPOOL_MANAGED,buffer,Null)\n\t\tLocal dataptr:Byte Ptr\n\t\tAssert buffer.Lock(0,0,dataptr,0)=D3D_OK,\"Failed to lock vertex buffer.\"\n\t\tMemCopy dataptr,data,data.length*4\t\t\n\t\tbuffer.Unlock()\n\tEnd Method\n\t\nEnd Type\n\nType TD3D9TextureRes Extends TTextureRes\n\tField _tex:IDirect3DTexture9\nEnd Type\n\nType TD3D9SurfaceRes Extends TSurfaceRes\n\tField _pos:IDirect3DVertexBuffer9\n\tField _nml:IDirect3DVertexBuffer9\n\tField _clr:IDirect3DVertexBuffer9\n\tField _tri:IDirect3DIndexBuffer9\n\tField _tex:IDirect3DVertexBuffer9[8]\n\t\n\tMethod Copy:TD3D9SurfaceRes()\n\t\tLocal res:TD3D9SurfaceRes=New TD3D9SurfaceRes\n\t\tres._vertexcnt=_vertexcnt;res._trianglecnt=_trianglecnt\n\t\tres._pos=_pos;res._nml=_nml;res._clr=_clr;res._tri=_tri;\n\t\tFor Local i=0 To 7\n\t\t\tres._tex[i]=_tex[i]\n\t\tNext\n\t\tReturn res\n\tEnd Method\nEnd Type\n\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction D3D9MaxB3DDriver:TD3D9MaxB3DDriver()\n\tIf D3D9Max2DDriver()\n\t\tGlobal driver:TD3D9MaxB3DDriver=New TD3D9MaxB3DDriver\n\t\tdriver._parent=D3D9Max2DExDriver()\n\t\tReturn driver\n\tEnd If\nEnd Function\n\nRem\n\tbbdoc: Utility function that sets the MaxB3D D3D9 driver and calls Graphics.\nEnd Rem\nFunction D3D9Graphics3D:TGraphics(width,height,depth=0,hertz=0,flags=0)\n\tSetGraphicsDriver D3D9MaxB3DDriver(),GRAPHICS_BACKBUFFER|GRAPHICS_DEPTHBUFFER\n\tReturn Graphics(width,height,depth,hertz,flags)\nEnd Function\n\nLocal driver:TD3D9MaxB3DDriver=D3D9MaxB3DDriver()\nIf driver SetGraphicsDriver driver,GRAPHICS_BACKBUFFER|GRAPHICS_DEPTHBUFFER\n\n?\n","old_contents":"\nStrict\n\nRem\n\tbbdoc: Direct3D 9 renderer for MaxB3D\nEnd Rem\nModule MaxB3D.D3D9Driver\nModuleInfo \"Author: Kevin Primm\"\nModuleInfo \"License: MIT\"\n\nImport MaxB3D.Core\nImport Prime.D3D9Max2DEx\nImport Prime.DirectXEx\n\n?Win32\n\nImport \"d3d9.cpp\"\n\nPrivate \n\nExtern \"C\"\n\tFunction maxb3dD3D9VertexElements:Byte Ptr()'=\"_maxb3dD3D9VertexElements@0\"\nEnd Extern\n\nFunction GetD3D9MaxB3DVertexDecl:IDirect3DVertexDeclaration9(d3ddev:IDirect3DDevice9)\n\tGlobal decl:IDirect3DVertexDeclaration9,dev:IDirect3DDevice9\n\tIf decl=Null Or dev<>d3ddev\n\t\tAssert d3ddev.CreateVertexDeclaration(maxb3dD3D9VertexElements(),decl)=D3D_OK,\"Failed to create vertex declaration.\"\n\t\tdev=d3ddev\n\tEndIf\n\tReturn decl\nEnd Function\n\nFunction Pow2Size( n )\n\tLocal t=1\n\tWhile tNull\n\t\t\t_d3ddev=TD3D9Graphics(TMax2DGraphics(g)._graphics).GetDirect3DDevice()\n\t\t\tEndMax2D\n\t\tEndIf\n\tEnd Method\n\t\t\n\tMethod MakeBuffer:TBuffer(src:Object,width,height,flags)\n\t\tReturn _parent.MakeBuffer(src,width,height,flags)\n\tEnd Method\n\t\n\tMethod GetCaps:TCaps()\n\t\tLocal caps:TCaps=New TCaps\n\t\tReturn caps\n\tEnd Method\n\t\n\tMethod Abbr$()\n\t\tReturn \"d3d9\"\n\tEnd Method\n\t\n\tMethod SetMax2D(enable)\n\t\tIf enable\n\t\t\tGlobal identity:TMatrix=TMatrix.Identity()\n\t\t\tLocal width=GraphicsWidth(),height=GraphicsHeight()\n\t\t\tLocal matrix#[]=[..\n\t\t\t2.0\/width,0.0,0.0,0.0,..\n\t\t\t 0.0,-2.0\/height,0.0,0.0,..\n\t\t\t 0.0,0.0,1.0,0.0,..\n\t\t\t -1-(1.0\/width),1+(1.0\/height),1.0,1.0]\n\t\t\t\n\t\t\t_d3ddev.SetTransform D3DTS_PROJECTION,matrix\n\t\t\t_d3ddev.SetTransform D3DTS_WORLD,identity.ToPtr()\n\t\t\t_d3ddev.SetTransform D3DTS_VIEW,identity.ToPtr()\n\t\t\t_d3ddev.SetTransform D3DTS_TEXTURE0,identity.ToPtr()\n\t\t\t\n\t\t\t_d3ddev.SetVertexDeclaration Null\n\t\t\t_d3ddev.SetIndices Null\n\t\t\t_d3ddev.SetFVF D3DFVF_XYZ|D3DFVF_DIFFUSE|D3DFVF_TEX1\n\t\t\t\n\t\t\t_d3ddev.SetRenderState D3DRS_LIGHTING,False\n\t\t\t_d3ddev.SetRenderState D3DRS_ZENABLE,False\n\t\t\t_d3ddev.SetRenderState D3DRS_SCISSORTESTENABLE,_viewporton\t\t\n\t\t\t\n\t\t\t_d3ddev.SetRenderState D3DRS_ALPHATESTENABLE,True\n\t\t\t\n\t\t\t_d3ddev.SetRenderState D3DRS_WRAP0, 0\n\t\t\t\n\t\t\t_d3ddev.SetRenderState D3DRS_FOGENABLE,False\n\t\t\t\n\t\t\tFor Local i=2 To 7\n\t\t\t\t_d3ddev.SetTexture i,Null\n\t\t\tNext\n\t\t\t\n\t\t\t_d3ddev.SetTextureStageState 0,D3DTSS_COLOROP,D3DTOP_MODULATE\n\t\t\t_d3ddev.SetTextureStageState 0,D3DTSS_ALPHAOP,D3DTOP_MODULATE\n\t\t\t\n\t\t\t_d3ddev.SetRenderState D3DRS_CULLMODE,D3DCULL_NONE\n\t\t\t_d3ddev.SetRenderState D3DRS_FILLMODE,D3DFILL_SOLID\n\t\tElse\n\t\t\t_d3ddev.SetRenderState D3DRS_ZENABLE,True\n\t\t\t_d3ddev.SetRenderState D3DRS_ZWRITEENABLE,True\n\t\n\t\t\t_d3ddev.GetRenderState D3DRS_SCISSORTESTENABLE,_viewporton\n\t\t\t_d3ddev.SetRenderState D3DRS_SCISSORTESTENABLE,True\n\t\t\t\n\t\t\t_d3ddev.SetRenderState D3DRS_LIGHTING,True\n\t\t\t_d3ddev.SetRenderState D3DRS_NORMALIZENORMALS,True\n\t\t\t_d3ddev.SetRenderState D3DRS_AMBIENT,D3DCOLOR_RGB(WorldConfig.AmbientRed,WorldConfig.AmbientGreen,WorldConfig.AmbientBlue)\n\t\t\t_d3ddev.SetRenderState D3DRS_COLORVERTEX, True\n\t\t\t_d3ddev.SetRenderState D3DRS_DIFFUSEMATERIALSOURCE,D3DMCS_MATERIAL\n\t\t\t\n\t\t\t_d3ddev.SetRenderState D3DRS_SHADEMODE,D3DSHADE_GOURAUD\n\t\t\t\n\t\t\t'_d3ddev.SetRenderState D3DRS_ALPHAREF, 1\n\t\t\t'_d3ddev.SetRenderState D3DRS_ALPHAFUNC, D3DCMP_GREATEREQUAL\n\t\t\t\t\t\n\t\t\t_d3ddev.SetRenderState D3DRS_CULLMODE,D3DCULL_CW\t\n\t\tEndIf\t\n\tEnd Method\n\t\n\tMethod SetCamera(camera:TCamera)\n\t\tLocal clearflags\t\t\n\t\tIf camera._clsmode&CLSMODE_COLOR clearflags:|D3DCLEAR_TARGET\n\t\tIf camera._clsmode&CLSMODE_DEPTH clearflags:|D3DCLEAR_ZBUFFER\n\n\t\tLocal viewport[]=[camera._viewx,camera._viewy,camera._viewwidth-camera._viewx,camera._viewheight-camera._viewy]\n\t\t_d3ddev.SetScissorRect viewport\n\t\t_d3ddev.Clear(1,viewport,clearflags,D3DCOLOR_XRGB(camera._brush._r*255,camera._brush._g*255,camera._brush._b*255),1.0,0)\n\t\t\n\t\tSelect camera._fogmode\n\t\tCase FOGMODE_LINEAR\n\t\t\t_d3ddev.SetRenderState D3DRS_FOGENABLE,True\n\t\t\t_d3ddev.SetRenderState D3DRS_FOGSTART,Int(Varptr camera._fognear)\n\t\t\t_d3ddev.SetRenderState D3DRS_FOGEND,Int(Varptr camera._fogfar)\n\t\tDefault\n\t\t\t_d3ddev.SetRenderState D3DRS_FOGENABLE,False\n\t\tEnd Select\n\t\t\n\t\tLocal ratio#=(Float(camera._viewwidth)\/camera._viewheight)\t\t\n\t\tLocal proj_matrix:TMatrix=TMatrix.PerspectiveFovRH(ATan((1.0\/(camera._zoom*ratio)))*2.0,ratio#,Max(0,camera._near-0.396250010),camera._far) ' Ugly hack. Real cause needs investigation.\n\t\tproj_matrix=TMatrix.Scale(-1,1,-1).Multiply(proj_matrix)\n\t\t_d3ddev.SetTransform D3DTS_PROJECTION,proj_matrix.ToPtr()\n\t\t\n\t\tLocal matrix:TMatrix=camera._matrix.Inverse()\n\t\t_d3ddev.SetTransform D3DTS_VIEW,matrix.ToPtr()\n\t\t\n\t\tcamera._lastmodelview=matrix\n\t\tcamera._lastprojection=proj_matrix\n\t\t\n\t\tcamera._lastviewport[0]=camera._viewx\n\t\tcamera._lastviewport[1]=camera._viewy\n\t\tcamera._lastviewport[2]=camera._viewwidth\n\t\tcamera._lastviewport[3]=camera._viewheight\n\t\t\n\t\tcamera._lastfrustum=TFrustum.Extract(camera._lastmodelview,camera._lastprojection)\n\tEnd Method\n\t\n\tMethod SetLight(light:TLight,index)\n\t\tIf light=Null \n\t\t\t_d3ddev.LightEnable index,False\n\t\t\tReturn\n\t\tEndIf\n\t\t\n\t\tLocal brush:TBrush=light._brush\n\n\t\tGlobal d3dlight:D3DLIGHT9=New D3DLIGHT9\n\t\td3dlight.Type_=D3DLIGHT_DIRECTIONAL \n\t\td3dlight.Diffuse_r=brush._r;d3dlight.Diffuse_g=brush._g;d3dlight.Diffuse_b=brush._b;d3dlight.Diffuse_a=brush._a\n\t\t'd3dlight.Ambient_r=WorldConfig.AmbientRed\/255.0;d3dlight.Ambient_g=WorldConfig.AmbientGreen\/255.0;d3dlight.Ambient_b=WorldConfig.AmbientBlue\/255.0;d3dlight.Ambient_a=1.0\n\t\t\n\t\td3dlight.Direction_x=0.0;d3dlight.Direction_y=0.0;d3dlight.Direction_z=1.0\n\t\t\t\t\n\t\tLocal matrix:TMatrix=light._matrix\n\t\tmatrix.TransformVec3 d3dlight.Direction_x,d3dlight.Direction_y,d3dlight.Direction_z\n\t\tmatrix.GetPosition d3dlight.Position_x,d3dlight.Position_y,d3dlight.Position_z\t\t\n\t\t\n\t\td3dlight.Range=light._range\t\t\n\t\t\n\t\t_d3ddev.SetLight index,d3dlight\n\t\t_d3ddev.LightEnable index,True\n\tEnd Method\n\t\n\tMethod SetBrush(brush:TBrush,hasalpha)\n\t\t_d3ddev.SetRenderState D3DRS_ALPHATESTENABLE,False\n\t\t\n\t\tLocal alpha_blending = (brush._fx&FX_FORCEALPHA Or hasalpha)>0\n\t\t_d3ddev.SetRenderState D3DRS_ALPHABLENDENABLE,alpha_blending \n\t\t_d3ddev.SetRenderState D3DRS_ZWRITEENABLE,Not alpha_blending \n\t\t\n\t\tIf brush._fx&FX_FULLBRIGHT\n\t\t\t_d3ddev.SetRenderState D3DRS_AMBIENT,$ffffffff\n\t\tElse\n\t\t\t_d3ddev.SetRenderState D3DRS_AMBIENT,D3DCOLOR_RGB(WorldConfig.AmbientRed,WorldConfig.AmbientGreen,WorldConfig.AmbientBlue)\n\t\tEndIf\n\t\t\n\t\tIf brush._fx&FX_NOCULLING\n\t\t\t_d3ddev.SetRenderState D3DRS_CULLMODE,D3DCULL_NONE\n\t\tElse\n\t\t\t_d3ddev.SetRenderState D3DRS_CULLMODE,D3DCULL_CW\n\t\tEndIf\n\t\t\n\t\tIf brush._fx&FX_WIREFRAME Or WorldConfig.Wireframe\n\t\t\t_d3ddev.SetRenderState D3DRS_FILLMODE,D3DFILL_WIREFRAME\n\t\tElse\n\t\t\t_d3ddev.SetRenderState D3DRS_FILLMODE,D3DFILL_SOLID\n\t\tEndIf\n\t\t\n\t\tLocal material:D3DMATERIAL9 = New D3DMATERIAL9\n\t\tmaterial.Diffuse_r=brush._r;material.Diffuse_g=brush._g;material.Diffuse_b=brush._b;material.Diffuse_a=brush._a\n\t\tmaterial.Ambient_r=brush._r;material.Ambient_g=brush._g;material.Ambient_b=brush._b;material.Ambient_a=brush._a\n\n\t\t_d3ddev.SetMaterial material\n\t\t\n\t\tFor Local i=0 To 7\n\t\t\tLocal texture:TTexture=brush._texture[i]\n\t\t\tIf texture=Null Or texture._blend=BLEND_NONE \n\t\t\t\t_d3ddev.SetTexture i,Null\n\t\t\t\tContinue\n\t\t\tEndIf\n\t\t\t\n\t\t\t_d3ddev.SetTexture i,UpdateTextureRes(texture._frame[brush._textureframe[i]],texture._flags)._tex\n\n\t\t\tLocal matrix:TMatrix=TMatrix.Identity()\n\t\t\t'matrix._m[0,0]=-texture._sx\n\t\t\t'matrix._m[1,1]=texture._sy\n\t\t\tmatrix=TMatrix.YawPitchRoll(0,0,-texture._r).Multiply(matrix)\n\t\t\tmatrix=TMatrix.Scale(-texture._sx,texture._sy,1).Multiply(matrix)\n\t\t\tmatrix._m[2,0]=-texture._px\n\t\t\tmatrix._m[2,1]=-texture._py\n\t\t\t\n\t\t\t_d3ddev.SetTransform D3DTS_TEXTURE0+i,matrix.ToPtr()\n\n\t\t\t_d3ddev.SetTextureStageState i,D3DTSS_TEXTURETRANSFORMFLAGS,D3DTTFF_COUNT2\n\t\t\t\n\t\t\t_d3ddev.SetSamplerState i,D3DSAMP_MAGFILTER,D3DTEXF_LINEAR\n\t\t\t_d3ddev.SetSamplerState i,D3DSAMP_MINFILTER,D3DTEXF_LINEAR\n\t\t\t\t\t\t\n\t\t\t_d3ddev.SetRenderState D3DRS_ALPHATESTENABLE, texture._flags&TEXTURE_ALPHA\t\t\t\n\t\t\t\n\t\t\tIf texture._flags&TEXTURE_MIPMAP\t\t\t\t\n\t\t\t\t_d3ddev.SetSamplerState i,D3DSAMP_MIPFILTER,D3DTEXF_LINEAR\n\t\t\tElse\n\t\t\t\t_d3ddev.SetSamplerState i,D3DSAMP_MIPFILTER,D3DTEXF_NONE\n\t\t\tEndIf\n\t\t\t\n\t\t\tIf texture._flags&TEXTURE_CLAMPU\n\t\t\t\t_d3ddev.SetSamplerState i,D3DSAMP_ADDRESSU,D3DTADDRESS_CLAMP\n\t\t\tElse\n\t\t\t\t_d3ddev.SetSamplerState i,D3DSAMP_ADDRESSU,D3DTADDRESS_WRAP\n\t\t\tEndIf\n\t\t\t\n\t\t\tIf texture._flags&TEXTURE_CLAMPV\n\t\t\t\t_d3ddev.SetSamplerState i,D3DSAMP_ADDRESSU,D3DTADDRESS_CLAMP\n\t\t\tElse\n\t\t\t\t_d3ddev.SetSamplerState i,D3DSAMP_ADDRESSV,D3DTADDRESS_WRAP\n\t\t\tEndIf\n\t\t\t\n\t\t\tIf texture._flags&TEXTURE_SPHMAP\n\t\t\t\t_d3ddev.SetTextureStageState i,D3DTSS_TEXCOORDINDEX,D3DTSS_TCI_SPHEREMAP\n\t\t\tElse\n\t\t\t\t_d3ddev.SetTextureStageState i,D3DTSS_TEXCOORDINDEX,texture._coords\n\t\t\tEndIf\n\t\t\t\n\t\t\t'_d3ddev.SetTextureStageState i,D3DTSS_COLOROP,D3DTOP_SELECTARG1\n\t\t\t'_d3ddev.SetTextureStageState i,D3DTSS_ALPHAOP,D3DTOP_SELECTARG2\n\t\t\t\n\t\t\tSelect texture._blend\n\t\t\tCase BLEND_ALPHA\n\t\t\t\t'glTexEnvf(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_DECAL)\n\t\t\tCase BLEND_MULTIPLY\n\t\t\t\t_d3ddev.SetTextureStageState i,D3DTSS_COLOROP,D3DTOP_MODULATE\n\t\t\t\t_d3ddev.SetTextureStageState i,D3DTSS_ALPHAOP,D3DTOP_MODULATE\n\t\t\tCase BLEND_ADD\n\t\t\t\t_d3ddev.SetTextureStageState i,D3DTSS_COLOROP,D3DTOP_ADD\n\t\t\t\t_d3ddev.SetTextureStageState i,D3DTSS_ALPHAOP,D3DTOP_ADD\n\t\t\tCase BLEND_DOT3\n\t\t\t\t_d3ddev.SetTextureStageState i,D3DTSS_COLOROP,D3DTOP_DOTPRODUCT3\n\t\t\t\t_d3ddev.SetTextureStageState i,D3DTSS_ALPHAOP,D3DTOP_DOTPRODUCT3\n\t\t\tCase BLEND_MULTIPLY2\n\t\t\t\t_d3ddev.SetTextureStageState i,D3DTSS_COLOROP,D3DTOP_MODULATE2X\n\t\t\t\t_d3ddev.SetTextureStageState i,D3DTSS_ALPHAOP,D3DTOP_MODULATE2X\n\t\t\tDefault\n\t\t\t\t_d3ddev.SetTextureStageState i,D3DTSS_COLOROP,D3DTOP_MODULATE\n\t\t\t\t_d3ddev.SetTextureStageState i,D3DTSS_ALPHAOP,D3DTOP_MODULATE\n\t\t\tEnd Select\t\t\t\n\t\tNext\n\tEnd Method\n\t\n\tMethod RenderSurface(resource:TSurfaceRes,brush:TBrush)\n\t\tLocal res:TD3D9SurfaceRes=TD3D9SurfaceRes(resource)\n\t\t\n\t\t_d3ddev.SetFVF 0\n\t\t_d3ddev.SetVertexDeclaration GetD3D9MaxB3DVertexDecl(_d3ddev)\n\t\t_d3ddev.SetStreamSource 0,res._pos,0,12\n\t\t_d3ddev.SetStreamSource 1,res._nml,0,12\n\t\t_d3ddev.SetStreamSource 2,res._clr,0,16\n\t\t_d3ddev.SetStreamSource 3,res._tex[0],0,8\n\t\t_d3ddev.SetIndices res._tri\n\t\t_d3ddev.DrawIndexedPrimitive D3DPT_TRIANGLELIST,0,0,res._vertexcnt,0,res._trianglecnt\n\n\t\tReturn res._trianglecnt\n\tEnd Method\n\t\n\tMethod RenderSprite(sprite:TSprite)\t\n\t\tGlobal _data#[]=[ -1.0, 1.0,0.0, 0.0,0.0,1.0, 0.0,0.0, ..\n\t\t 1.0, 1.0,0.0, 0.0,0.0,1.0, 1.0,0.0, ..\n\t\t -1.0,-1.0,0.0, 0.0,0.0,1.0, 0.0,1.0, ..\n\t\t 1.0,-1.0,0.0, 0.0,0.0,1.0, 1.0,1.0 ]\n\t\t\n\t\t_d3ddev.SetVertexDeclaration Null\n\t\t_d3ddev.SetFVF D3DFVF_XYZ|D3DFVF_NORMAL|D3DFVF_TEX1\n\t\t_d3ddev.DrawPrimitiveUP D3DPT_TRIANGLESTRIP,2,_data,8*4\n\tEnd Method\n\t\n\tMethod BeginEntityRender(entity:TEntity)\n\t\t_d3ddev.SetTransform D3DTS_WORLD,entity.GetMatrix(True).ToPtr()\n\tEnd Method\n\t\n\tMethod EndEntityRender(entity:TEntity)\n\tEnd Method\n\t\n\tMethod RenderFlat(flat:TFlat)\n\t\tLocal x#,y#,z#\n\t\tflat.GetScale x,y,z,True\n\n\t\tGlobal _data#[]=[ -1.0,0.0, 1.0, 0.0,1.0,0.0, 0.0,0.0, ..\n\t\t 1.0,0.0, 1.0, 0.0,1.0,0.0, x,0.0, ..\n\t\t -1.0,0.0,-1.0, 0.0,1.0,0.0, 0.0, z, ..\n\t\t 1.0,0.0,-1.0, 0.0,1.0,0.0, x, z ]\t\t\n\t\t\n\t\t_d3ddev.SetVertexDeclaration Null\n\t\t_d3ddev.SetFVF D3DFVF_XYZ|D3DFVF_NORMAL|D3DFVF_TEX1\n\t\t_d3ddev.DrawPrimitiveUP D3DPT_TRIANGLESTRIP,2,_data,8*4\n\tEnd Method\n\t\n\tMethod RenderTerrain(terrain:TTerrain)\n\tEnd Method\n\t\n\tMethod RenderBSPTree(tree:TBSPTree)\n\t\tLocal node:TBSPNode=tree.Node\n\t\tIf node=Null Return\n\t\tLocal triangles\n\t\ttriangles:+RenderBSPTree(node.In)\n\t\t\n\t\t_d3ddev.SetVertexDeclaration Null\n\t\t_d3ddev.SetFVF D3DFVF_XYZ|D3DFVF_NORMAL|D3DFVF_TEX1\n\t\t\t\t\n\t\tFor Local poly:TBSPPolygon=EachIn node.On\n\t\t\tLocal ptA:TVector=poly.Point[0],v0\n\t\t\tLocal trianglecnt=poly.Count()-2\n\t\t\tLocal data#[trianglecnt*24],dataptr:Float Ptr=data\n\t\t\tFor Local i=0 To trianglecnt-1\n\t\t\t\tLocal ptB:TVector=poly.Point[i+1],ptC:TVector=poly.Point[i+2]\n\t\t\t\tdata[i*24+00]=ptA.x;data[i*24+01]=ptA.y;data[i*24+02]=ptA.z;data[i*24+03]=poly.Plane.x;data[i*24+04]=poly.Plane.y;\tdata[i*24+05]=poly.Plane.z;data[i*24+06]=0.0;data[i*24+07]=0.0\n\t\t\t\tdata[i*24+08]=ptB.x;data[i*24+09]=ptB.y;data[i*24+10]=ptB.z;data[i*24+11]=poly.Plane.x;data[i*24+12]=poly.Plane.y;\tdata[i*24+13]=poly.Plane.z;data[i*24+14]=0.0;data[i*24+15]=0.0\n\t\t\t\tdata[i*24+16]=ptC.x;data[i*24+17]=ptC.y;data[i*24+18]=ptC.z;data[i*24+19]=poly.Plane.x;data[i*24+20]=poly.Plane.y;data[i*24+21]=poly.Plane.z;data[i*24+22]=0.0;data[i*24+23]=0.0\n\t\t\tNext\n\t\t\t_d3ddev.DrawPrimitiveUP D3DPT_TRIANGLELIST,trianglecnt,data,8*4\n\t\t\ttriangles:+trianglecnt\n\t\tNext\n\t\t\t\t\n\t\ttriangles:+RenderBSPTree(node.Out)\n\t\tReturn triangles\n\tEnd Method\n\t\n\tMethod UpdateTextureRes:TD3D9TextureRes(frame:TTextureFrame,flags)\n\t\tLocal res:TD3D9TextureRes=TD3D9TextureRes(frame._res)\n\t\tIf res And frame._updateres=False Return res\n\n\t\tIf res=Null res=New TD3D9TextureRes\n\t\tframe._res=res\n\t\t\n\t\tLocal pixmap:TPixmap=frame._pixmap\n\t\tLocal tex_width=Pow2Size(pixmap.width),tex_height=Pow2Size(pixmap.height)\n\t\tpixmap=ConvertPixmap(ResizePixmap(pixmap,tex_width,tex_height),PF_BGRA8888)\n\t\tIf res._tex=Null Assert _d3ddev.CreateTexture(tex_width,tex_height,(flags & TEXTURE_MIPMAP)=0,D3DUSAGE_AUTOGENMIPMAP,D3DFMT_A8R8G8B8,D3DPOOL_MANAGED,res._tex,Null)=D3D_OK\n\t\t\n\t\tLocal rect:D3DLOCKED_RECT=New D3DLOCKED_RECT \n\t\tres._tex.LockRect 0,rect,Null,0\n\t\tMemCopy rect.pBits,pixmap.pixels,pixmap.width*pixmap.height*4\n\t\tres._tex.UnlockRect 0\n\t\t\n\t\tframe._updateres=False\n\t\t\t\t\n\t\tReturn res\n\tEnd Method\n\t\n\tMethod UpdateSurfaceRes:TD3D9SurfaceRes(surface:TSurface)\n\t\tLocal res:TD3D9SurfaceRes=TD3D9SurfaceRes(surface._res)\n\t\tIf res=Null res=New TD3D9SurfaceRes;surface._reset=-1\n\t\t\n\t\tIf surface._reset=0 Return res\t\t\n\t\tIf surface._reset=-1 surface._reset=1|2|4|8|16|32|64|128|256\n\n\t\tIf surface._reset&1 And surface._vertexpos UploadVertexData res._pos,surface._vertexpos\n\t\tIf surface._reset&2 And surface._vertexnml UploadVertexData res._nml,surface._vertexnml\n\t\tIf surface._reset&4 And surface._vertexclr UploadVertexData res._clr,surface._vertexclr\n\t\tIf surface._reset&8 And surface._triangle\n\t\t\tIf res._tri=Null _d3ddev.CreateIndexBuffer(surface._triangle.length*4,0,D3DFMT_INDEX32,D3DPOOL_MANAGED,res._tri,Null)\n\t\t\tLocal dataptr:Byte Ptr\n\t\t\tAssert res._tri.Lock(0,0,dataptr,0)=D3D_OK,\"Failed to lock index buffer.\"\n\t\t\tMemCopy dataptr,surface._triangle,surface._triangle.length*4\t\t\n\t\t\tres._tri.Unlock()\n\t\tEndIf\n\t\t\n\t\tFor Local i=0 To surface._vertextex.length-1\n\t\t\tIf surface._reset&Int(2^(4+i)) UploadVertexData res._tex[i],surface._vertextex[i]\n\t\tNext\n\t\t\n\t\tres._trianglecnt=surface._trianglecnt\n\t\tres._vertexcnt=surface._vertexcnt\n\t\t\n\t\tsurface._reset=0\n\t\tsurface._res=res\n\t\t\n\t\tReturn res\n\tEnd Method\n\n\tMethod MergeSurfaceRes:TSurfaceRes(base:TSurface,animation:TSurface,data)\n\t\tIf animation=Null Return UpdateSurfaceRes(base)\n\t\tLocal base_res:TD3D9SurfaceRes=UpdateSurfaceRes(base)\n\t\tLocal anim_res:TD3D9SurfaceRes=UpdateSurfaceRes(animation)\n\t\tLocal res:TD3D9SurfaceRes=base_res.Copy()\n\t\tres._pos=anim_res._pos\n\t\tReturn res\n\tEnd Method\n\t\n\tMethod UploadVertexData(buffer:IDirect3DVertexBuffer9 Var,data#[])\n\t\tIf buffer=Null _d3ddev.CreateVertexBuffer(data.length*4,0,0,D3DPOOL_MANAGED,buffer,Null)\n\t\tLocal dataptr:Byte Ptr\n\t\tAssert buffer.Lock(0,0,dataptr,0)=D3D_OK,\"Failed to lock vertex buffer.\"\n\t\tMemCopy dataptr,data,data.length*4\t\t\n\t\tbuffer.Unlock()\n\tEnd Method\n\t\nEnd Type\n\nType TD3D9TextureRes Extends TTextureRes\n\tField _tex:IDirect3DTexture9\nEnd Type\n\nType TD3D9SurfaceRes Extends TSurfaceRes\n\tField _pos:IDirect3DVertexBuffer9\n\tField _nml:IDirect3DVertexBuffer9\n\tField _clr:IDirect3DVertexBuffer9\n\tField _tri:IDirect3DIndexBuffer9\n\tField _tex:IDirect3DVertexBuffer9[8]\n\t\n\tMethod Copy:TD3D9SurfaceRes()\n\t\tLocal res:TD3D9SurfaceRes=New TD3D9SurfaceRes\n\t\tres._vertexcnt=_vertexcnt;res._trianglecnt=_trianglecnt\n\t\tres._pos=_pos;res._nml=_nml;res._clr=_clr;res._tri=_tri;\n\t\tFor Local i=0 To 7\n\t\t\tres._tex[i]=_tex[i]\n\t\tNext\n\t\tReturn res\n\tEnd Method\nEnd Type\n\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction D3D9MaxB3DDriver:TD3D9MaxB3DDriver()\n\tIf D3D9Max2DDriver()\n\t\tGlobal driver:TD3D9MaxB3DDriver=New TD3D9MaxB3DDriver\n\t\tdriver._parent=D3D9Max2DExDriver()\n\t\tReturn driver\n\tEnd If\nEnd Function\n\nRem\n\tbbdoc: Utility function that sets the MaxB3D D3D9 driver and calls Graphics.\nEnd Rem\nFunction D3D9Graphics3D:TGraphics(width,height,depth=0,hertz=0,flags=0)\n\tSetGraphicsDriver D3D9MaxB3DDriver(),GRAPHICS_BACKBUFFER|GRAPHICS_DEPTHBUFFER\n\tReturn Graphics(width,height,depth,hertz,flags)\nEnd Function\n\nLocal driver:TD3D9MaxB3DDriver=D3D9MaxB3DDriver()\nIf driver SetGraphicsDriver driver,GRAPHICS_BACKBUFFER|GRAPHICS_DEPTHBUFFER\n\n?\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"e37e99e3eecfdc3ae6b92b7747ba505046ef927c","subject":"prep for cleanup","message":"prep for cleanup\n","repos":"Leushenko\/blue-moon","old_file":"bluejit.bmx","new_file":"bluejit.bmx","new_contents":"\n' Blue Moon\n' JIT engine\/opcodes\n\n' this is the core of the runtime: the machine code generator and opcodes\n' it's a halfway blend between JIT and interpreter: a basic JIT generates machine code\n' for \"unrolled\" interpreter loops, theoretically (ha!) providing a speed boost\n' it can also \"inline\" selected operations, coming closer to being a true JIT\n\n' for now this is an Include rather than Import lib due to recursive dependency\n' we'll fix that later\n\nRem\nSuperStrict\n\nImport \"blueerror.bmx\"\nImport \"bluevm.bmx\"\nImport etc etc...\nEnd Rem\n\n'Private\t'may need to rename and open these (in the shared interface?)\nExtern\n\tType Stack\n\t\tField retIP:Byte Ptr, prevBase:Stack, varp:Long Ptr, func:Bytecode, _:Long Ptr, argv:Long Ptr, retv:Long Ptr, argc:Short, retc:Short\n\tEnd Type\n\tType Bytecode\n\t\tField mcode:Byte Ptr, idMod:Int, kcount:Int, pcount:Int, upvars:Int, frameSz:Int, icount:Int, vm:Byte Ptr\n\tEnd Type\nEnd Extern\n'Public\n\nType BlueJIT Final\n\tConst PROLOGUESZ:Int = 25, ISIZE:Int = 5\n\t\n\tGlobal opTbl:Int(s:Stack, b:Bytecode, r:Byte Ptr)[], opc:BlueOpcode\n\tGlobal Prologue:Int[] = [ ..\n\t\t$90, $90, ..\n\t\t$8b, $44, $24, $04, .. 'mov 4(%esp), %eax\n\t\t$89, $44, $24, $f4, .. 'mov %eax, -12(%esp)\n\t\t$c7, $44, $24, $f8, $FF, $FF, $FF, $FF, .. 'movl ########, -8(%esp)\n\t\t$89, $64, $24, $fc, .. 'mov %esp, -4(%esp)\n\t\t$83, $ec, $0c.. 'sub $12, %esp\n\t]\n\t\n\tFunction Compile:Byte Ptr(vm:BlueVM, ins:Byte Ptr, icount:Int, bytecode:Bytecode)\n\t\t?Not x86\n\t\tRuntimeError \"The Blue Moon JIT does not support your platform (x86-32 only at this time)\"\n\t\t?\n\t\tAssert SizeOf(0:Long) = SizeOf(0:Double) And SizeOf(0:Int) = 4 And SizeOf(0:Long) = 8 And SizeOf(Byte Ptr(0)) = 4, ..\n\t\t\t\"assumptions about platform datatype sizes are invalid\"\n\t\t\n\t\tIf opTbl = Null Then InitOpTbl()\n\t\t\n\t\t' compute executable code size\n\t\tLocal codesize:Int = PROLOGUESZ, opPos:Int[icount]\t'since sizes are irregular, looking up offsets is easiest\n\t\tFor Local i:Int = 0 Until icount\n\t\t\topPos[i] = codesize\t'finalized below\n\t\t\tSelect ins[i * 8]\n\t\t\t\tCase opc.SETTAB, opc.GETTAB\n\t\t\t\t\tcodesize :+ ISIZE * 2\n\t\t\t\tDefault\n\t\t\t\t\tcodesize :+ ISIZE\n\t\t\tEnd Select\n\t\tNext\n\t\t\n\t\t' allocate executable space\n\t\tLocal code:Byte Ptr = vm.mem.AllocCodeBlock(codesize)\n\t\t\n\t\t'finalize op offsets se we can look them up\n\t\tFor Local i:Int = 0 Until icount\n\t\t\topPos[i] :+ Int(code)\t'direct to executable space\n\t\tNext\n\t\t\n\t\t' emplace prologue (used for calling in from native only)\n\t\tFor Local p:Int = 0 Until PROLOGUESZ\n\t\t\tcode[p] = Prologue[p]\n\t\tNext\n\t\tByte Ptr Ptr(code + 14)[0] = Byte Ptr(bytecode)\t'replace the ########\n\t\t\n\t\t' epilogue (shared location per-vm, probably already set)\n\t\tvm.mem.returnToNative[0] = $c30cc483\t'add $12, %esp ; ret - i.e. restore the stack to normal\n\t\t\n\t\tLocal ktable:Long Ptr = Long Ptr(ins + 8 * bytecode.icount + 8 * bytecode.upvars)\t'constant table\n\t\t\n\t\t' generate machine code!\n\t\tFor Local i:Int = 0 Until icount\t'emplace opcode calls and supporting bytecode data\n\t\t\tLocal codep:Byte Ptr = Byte Ptr(opPos[i]), bytecodep:Byte Ptr = Byte Ptr(Int(codep) + vm.mem.PAGESZ)\n\t\t\tLocal bi:Int = i * 8, op:Int = ins[bi], ip:Int Ptr = Int Ptr(ins + bi), func:Byte Ptr = opTbl[op]\n\t\t\t\n\t\t\tcodep[0] = $e8\t'call\n\t\t\tByte Ptr Ptr(codep + 1)[0] = func - Int(codep + ISIZE)\n\t\t\t\n\t\t\tbytecodep[0] = ins[bi + 1] ; bytecodep[1] = ins[bi + 2]\t'used by most, may get overwritten\n\t\t\t\n\t\t\tSelect op\n\t\t\t\tCase opc.LOADSI, opc.CLOSURE, opc.RET, opc.POSTCALL\n\t\t\t\t\tInt Ptr(bytecodep + 1)[0] = ip[1]\n\t\t\t\t\t\n\t\t\t\tCase opc.LOADK\n\t\t\t\t\tLong Ptr Ptr(bytecodep + 1)[0] = ktable + ip[1]\n\t\t\t\t\t\n\t\t\t\tCase opc.SETTABSI, opc.GETTABSI\n\t\t\t\t\tShort Ptr(bytecodep)[1] = ip[1]\n\t\t\t\t\t\n\t\t\t\tCase opc.SETTAB, opc.GETTAB\n\t\t\t\t\tcodep[ISIZE] = $90 ; Int Ptr(codep + ISIZE + 1)[0] = $90909090\t'nops; the space is needed in the bytecode\n\t\t\t\t\tLong Ptr Ptr(bytecodep + 2)[0] = ktable + ip[1]\n\t\t\t\t\tLong Ptr Ptr(bytecodep + 2)[1] = Null\t'inline cache space\n\t\t\t\t\t\n\t\t\t\tCase opc.GETUPV\n\t\t\t\t\tIf Int Ptr(ins + icount * 8)[2 * bytecodep[1]] = -1\n\t\t\t\t\t\tByte Ptr Ptr(codep + 1)[0] = Byte Ptr(BlueJIT.GETENV) - Int(codep + ISIZE)\n\t\t\t\t\t\tByte Ptr Ptr(bytecodep + 1)[0] = Varptr(vm._ENV.val)\t'note: doesn't allow _ENV to be changed from Max\n\t\t\t\t\tEndIf\n\t\t\t\t\t\n\t\t\t\tCase opc.CALL\n\t\t\t\t\tShort Ptr(bytecodep)[1] = ip[1]\n\t\t\t\t\t\n\t\t\t\tCase opc.JIF, opc.JNOT\n\t\t\t\t\tInt Ptr(bytecodep + 1)[0] = opPos[i + ip[1]]\n\t\t\t\t\t\n\t\t\t\tCase opc.JMP\n\t\t\t\t\tcodep[0] = $e9\t'use a true jump\n\t\t\t\t\tInt Ptr(codep + 1)[0] = opPos[i + ip[1]] - (opPos[i] + ISIZE)\n\t\t\t\t\t\n\t\t\t\tDefault\t'binary operations A = B op C\n\t\t\t\t\tbytecodep[2] = ip[1]\n\t\t\tEnd Select\n\t\tNext\n\t\t\n\t\tReturn code\n\tEnd Function\n\t\n\t\n\tConst STACKFRAME_INC:Int = BlueVMMemory.STACKFRAMESZ + 4, BYTECODE_INC:Int = BlueVMMemory.BYTECODESZ + 4\n\tConst IP_OFFSET:Int = BlueVMMemory.PAGESZ - ISIZE\n\t\n\t\n\t'note: extern vars must take into account the vtbl offset, so that converting from a typed pointer can be a simple cast (faster)\t\n\t\n\tFunction MOV(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"MOV \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tvarp[rp[0]] = varp[rp[1]]\n\tEnd Function\n\tFunction GETLC(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction SETLC(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"SETLC \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal convert:BlueVM(p:Byte Ptr) = Byte Ptr(Identity), vm:BlueVM = convert(bc.vm)\n\t\tvm.mem.Write(Long Ptr Ptr(varp + rp[0])[0][0], varp[rp[1]])\t'unlikely but technically possible to need this\n\tEnd Function\n\tFunction LOADK(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"LOADK \/\/\"\n\t\tLocal rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET, varp:Long Ptr = stk.varp + rp[0], kp:Long Ptr = Long Ptr Ptr(rp + 1)[0]\n\t\tvarp[0] = kp[0]\n\tEnd Function\n\tFunction LOADSI(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"LOADSI \/\/\"\n\t\tLocal rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal val:Int = Int Ptr(rp + 1)[0]\n\t\tDouble Ptr(stk.varp)[rp[0]] = Double(val)\n\tEnd Function\n\tFunction LOADBOOL(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"LOADBOOL \/\/\"\n\t\tLocal rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET, vp:Int Ptr = Int Ptr(stk.varp + rp[0])\n\t\tvp[1] = BlueTypeTag.NANBOX | BlueTypeTag.BOOL\n\t\tvp[0] = Int Ptr(rp + 1)[0]\n\tEnd Function\n\tFunction LOADNIL(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"LOADNIL \/\/\"\n\t\tLocal rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tInt Ptr(stk.varp + rp[0])[1] = BlueTypeTag.NANBOX | BlueTypeTag.NIL\n\tEnd Function\n\t\n\tFunction GETTAB(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t\tPrint \"GETTAB \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET, kp:Long Ptr = Long Ptr Ptr(rp + 2)[0]\n\t\tLocal tabp:Byte Ptr = Byte Ptr Ptr(varp + rp[1])[0]\n\t\t'type check\n\t\tPrint \" tag: \" + Bin(Int Ptr(kp)[1])\n\t\tLocal keyslot:Long Ptr = Null, slot:Long Ptr = BlueTable.GetSlot(tabp, kp[0], Varptr(keyslot))\n\t\tPrint \" slot: \" + Hex(Int(slot))\n\t\tIf (slot = Null) Or (keyslot[0] <> kp[0])\t'not in table; invoke metamethod\n\t\t\t'if keyslot == 1 then it's invalid\n\t\t\tDebugStop\n\t\tElse\n\t\t\tvarp[rp[0]] = slot[0]\n\t\tEndIf\n\tEnd Function\n\tFunction GETTABSI(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction SETTAB(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t\tPrint \"SETTAB \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET, kp:Long Ptr = Long Ptr Ptr(rp + 2)[0]\n\t\tLocal tabp:Byte Ptr = Byte Ptr Ptr(varp + rp[0])[0]\n\t\tPrint \" tag: \" + Bin(Int Ptr(kp)[1])\n\t\tLocal keyslot:Long Ptr = Null, slot:Long Ptr = BlueTable.GetSlot(tabp, kp[0], Varptr(keyslot))\n\t\tPrint \" slot: \" + Hex(Int(slot))\n\t\tIf (slot = Null) Or (keyslot[0] <> kp[0])\t'not in table; invoke metamethod or rawset\n\t\t\t'if keyslot == 1 then it's invalid\n\t\t\tLocal convert:BlueVM(p:Byte Ptr) = Byte Ptr(Identity), vm:BlueVM = convert(bc.vm)\n\t\t\tBlueTable.RawSet(vm.mem, tabp, kp[0], varp[rp[1]])\n\t\tElse\n\t\t\tslot[0] = varp[rp[1]]\n\t\tEndIf\n\tEnd Function\n\tFunction SETTABSI(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t\tPrint \"SETTABSI \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal convert:BlueVM(p:Byte Ptr) = Byte Ptr(Identity), vm:BlueVM = convert(bc.vm)\n\t\tLocal tabp:Byte Ptr = varp + rp[0]\n\t\tPrint \" \" + Short Ptr(rp)[1]\n\t\tLocal key:Long ; Double Ptr(Varptr(key))[0] = Short Ptr(rp)[1]\n\t\tBlueTable.RawSet(vm.mem, Byte Ptr Ptr(tabp)[0], key, varp[rp[1]])\n\tEnd Function\n\tFunction GETTABI(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t\tPrint \"GETTABI \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal tabp:Byte Ptr = varp + rp[1]\n\t\tPrint \" tag: \" + Bin(Int Ptr(varp + rp[2])[1])\n\t\tLocal val:Long = BlueTable.RawGet(Byte Ptr Ptr(tabp)[0], varp[rp[2]])\n\t\tvarp[rp[0]] = val\n\tEnd Function\n\tFunction SETTABI(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t\tPrint \"SETTABI \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal convert:BlueVM(p:Byte Ptr) = Byte Ptr(Identity), vm:BlueVM = convert(bc.vm)\n\t\tLocal tabp:Byte Ptr = varp + rp[0]\n\t\tPrint \" \" + Double Ptr(varp)[rp[2]] + \" \" + Double Ptr(varp)[rp[1]]\n\t\tPrint \" tag: \" + Bin(Int Ptr(varp + rp[2])[1])\n\t\tBlueTable.RawSet(vm.mem, Byte Ptr Ptr(tabp)[0], varp[rp[2]], varp[rp[1]])\n\tEnd Function\n\tFunction GETUPV(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t\tPrint \"GETUPV \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tPrint \" \" + rp[0] + \" \" + rp[1] + \" \" + rp[2]\n\t\tDebugStop\n\t\tLocal upvp:Byte Ptr Ptr = Byte Ptr Ptr(Byte Ptr(stk) + STACKFRAME_INC), valp:Long Ptr = Long Ptr(upvp[rp[1]])\n\t\tvarp[rp[0]] = valp[0]\n\tEnd Function\n\tFunction GETENV(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\t'\"unlisted\" instruction: GETUPV for _ENV is translated into this at load-time\n\t\tPrint \"GETENV \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tPrint \" \" + rp[0] + \" \" + Hex(Int Ptr(rp + 1)[0])\n\t\t'need a type check\n\t\tvarp[rp[0]] = Long Ptr Ptr(rp + 1)[0][0]\n\tEnd Function\n\tFunction SETUPV(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction NEWTAB(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t\tPrint \"NEWTAB \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal convert:BlueVM(p:Byte Ptr) = Byte Ptr(Identity), vm:BlueVM = convert(bc.vm)\n\t\tLocal tab:Byte Ptr = vm.mem.AllocTable(Null)\n\t\tLocal d:Int Ptr = Int Ptr(varp + rp[0])\n\t\td[0] = Int(tab) ; d[1] = BlueTypeTag.NANBOX | BlueTypeTag.TBL\n\tEnd Function\n\tFunction CLOSURE(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"CLOSURE \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal convert:BlueVM(p:Byte Ptr) = Byte Ptr(Identity), vm:BlueVM = convert(bc.vm)\n\t\tLocal d:Int Ptr = Int Ptr(varp + rp[0])\n\t\tLocal cbytecode:Bytecode = vm.funIndex[Int Ptr(rp + 1)[0]], upvp:Int Ptr = Int Ptr(Byte Ptr(cbytecode) + BYTECODE_INC + 8 * cbytecode.icount)\n\t\tLocal closure:Byte Ptr = vm.mem.AllocClosure(cbytecode, cbytecode.upvars)\t'upvars is always even (alignment)\n\t\t\n\t\t'get upvalues off the stack\n\t\tFor Local u:Int = 0 Until cbytecode.upvars\n\t\t\tIf upvp[2 * u]\n\t\t\t\tByte Ptr Ptr(closure)[2 + u] = Byte Ptr Ptr(Byte Ptr(stk) + STACKFRAME_INC)[upvp[2 * u + 1]]\n\t\t\tElse\n\t\t\t\tByte Ptr Ptr(closure)[2 + u] = Byte Ptr Ptr(varp + upvp[2 * u + 1])[0]\n\t\t\tEndIf\n\t\tNext\n\t\t\n\t\td[0] = Int(closure) ; d[1] = BlueTypeTag.NANBOX | BlueTypeTag.FUN\n\tEnd Function\n\tFunction NEWUPV(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"NEWUPV \/\/\"\n\t\tLocal rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal convert:BlueVM(p:Byte Ptr) = Byte Ptr(Identity), vm:BlueVM = convert(bc.vm)\n\t\tLocal upv:Byte Ptr = vm.mem.AllocObject(8, BlueTypeTag.UPV), d:Int Ptr = Int Ptr(stk.varp + rp[0])\n\t\tLong Ptr(upv)[0] = Long Ptr(d)[0]\t'promote a value if it existed (useful for parameters)\n\t\td[0] = Int(upv) ; d[1] = BlueTypeTag.NANBOX | BlueTypeTag.UPV\n\tEnd Function\n\t\n\tFunction ADD(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t\tPrint \"ADD \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal d:Double Ptr = Double Ptr(varp + rp[0])\n\t\tLocal r:Int Ptr = Int Ptr(varp + rp[1]), l:Int Ptr = Int Ptr(varp + rp[2])\n\t\tIf l[1] & BlueTypeTag.NANBOX_CHK = BlueTypeTag.NANBOX Or r[1] & BlueTypeTag.NANBOX_CHK = BlueTypeTag.NANBOX\n\t\t\tDebugStop\n\t\tElse\n\t\t\tPrint \" \" + Double Ptr(l)[0] + \" \" + Double Ptr(r)[0]\n\t\t\td[0] = Double Ptr(l)[0] + Double Ptr(r)[0]\n\t\tEndIf\n\tEnd Function\n\tFunction SUB(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction MUL(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction DIV(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction NMOD(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction POW(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction CAT(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction IDIV(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction BAND(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction BOR(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction BXOR(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction BSHL(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction BSHR(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction UNM(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction LNOT(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction ALEN(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction BNOT(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction UNP(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction EQ(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"EQ \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = (Byte Ptr Ptr(retptr) - 4)[0] + IP_OFFSET\n\t\tLocal r:Double = Double Ptr(varp)[rp[1]]\n\t\tLocal l:Double = Double Ptr(varp)[rp[2]]\n\t\tInt Ptr(varp + rp[0])[0] = l = r\n\tEnd Function\n\tFunction LT(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction LEQ(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\t\n\tFunction JMP(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t\tRuntimeError \"wait, why are we here?\"\n\tEnd Function\n\tFunction JIF(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"JIF \/\/\"\n\t\tLocal rp:Byte Ptr = (Byte Ptr Ptr(retptr) - 4)[0] + IP_OFFSET\n\t\tIf Int Ptr(stk.varp + rp[0])[0]\n\t\t\tLocal target:Int = Int Ptr(rp + 1)[0]\n\t\t\tInt Ptr(retptr)[-4] = target\n\t\tEndIf\n\tEnd Function\n\tFunction JNOT(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction CALL(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"CALL \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal fp:Int Ptr = Int Ptr(varp + rp[0])\n\t\tIf Not PrepareCall(fp, stk, rp, varp, retptr)\t'PrepareCall sets everything up so there's nothing else to do to make the call happen\n\t\t\t'__call metamethod\n\t\tEndIf\n\tEnd Function\n\tFunction TCALL(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction RET:Byte Ptr(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"RET \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp\n\t\tLocal rp0:Byte Ptr = Byte Ptr Ptr(retptr)[-4], rp:Byte Ptr = rp0 + IP_OFFSET\n\t\t\n\t\tLocal oldStk:Stack = stk.prevBase\n\t\tLocal retv:Long Ptr = varp + rp[0]\n\t\tIf oldStk\n\t\t\toldStk.retv = retv\n\t\t\toldStk.retc = Int Ptr(rp + 1)[0]\n\t\t\tByte Ptr Ptr(retptr)[-4] = stk.retIP\n\t\t\tByte Ptr Ptr(retptr)[-3] = Byte Ptr(oldStk)\n\t\t\tByte Ptr Ptr(retptr)[-2] = Byte Ptr(oldStk.func) + BYTECODE_INC\n\t\tElse\t'return to native code\n\t\t\tLocal codePage:Byte Ptr = Byte Ptr(Int(rp0) & ((Int(2^12)-1) Shl 20))\n\t\t\tByte Ptr Ptr(retptr)[-4] = codePage + 4\n\t\t\tReturn retv\n\t\tEndIf\n\tEnd Function\n\tFunction RETVA(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction POSTCALL(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"POSTCALL \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp\n\t\tLocal rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\t\n\t\tFor Local r:Int = 0 Until Min(Int Ptr(rp + 1)[0], stk.retc)\n\t\t\t(varp + rp[0])[r] = stk.retv[r]\n\t\t'\tPrint \" return \" + r + \": \" + Double Ptr(stk.retv)[r]\n\t\tNext\n\t\t'nil the rest\n\tEnd Function\n\tFunction VARARG(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction VAINIT(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction CALLINIT(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\t\n\t\n\tFunction PrepareCall:Int(fp:Int Ptr, stk:Stack, rp:Byte Ptr, varp:Long Ptr, retptr:Byte Ptr)\n\t\tIf fp[1] = BlueTypeTag.NANBOX | BlueTypeTag.FUN\n\t\t\tLocal newStk0:Stack ; Byte Ptr Ptr(Varptr(newStk0))[0] = Byte Ptr(stk) + stk.func.frameSz\n\t\t\tLocal newStk:Stack = newStk0\t'micro-opt: newStk0 can't be a register because of the unwieldy conversion\n\t\t\t\n\t\t\tnewStk.retIP = Byte Ptr Ptr(retptr)[-4]\n\t\t\tnewStk.prevBase = stk\n\t\t\tLocal closure:Byte Ptr = Byte Ptr(fp[0])\n\t\t\tLocal newBC:Bytecode = Bytecode Ptr(closure)[0]\n\t\t\tLocal voff:Int = STACKFRAME_INC + 4 * newBC.upvars\n\t\t\tnewStk.varp = Long Ptr(Byte Ptr(newStk) + voff)\n\t\t\tnewStk.func = newBC\n\t\t\t\n\t\t\tLocal argc_actual:Int = Short Ptr(rp)[1], argc_required:Int = newBC.pcount\n\t\t'\tLocal argc_min:Int ; If argc_actual < argc_required Then argc_min = argc_actual Else argc_min = argc_required\n\t\t\tLocal argc_min:Int = argc_actual - argc_required ; argc_min = (argc_min & (argc_min Shr 31)) + argc_required 'branchless 32-bit Min\n\t\t\t\n\t\t\tLocal argv:Long Ptr = varp + rp[1], destv:Long Ptr = newStk.varp\n\t\t\tFor Local a:Int = 0 Until argc_min\n\t\t\t\tdestv[a] = argv[a]\n\t\t\t'\tPrint \" arg \" + a + \": \" + argv[a]\n\t\t\tNext\n\t\t\tFor Local a:Int = argc_min Until argc_required\t'nil any unfilled parameters\n\t\t\t\tInt Ptr(destv + a)[1] = BlueTypeTag.NANBOX | BlueTypeTag.NIL\n\t\t\tNext\n\t\t\tnewStk.argv = argv + argc_min\t'argv should be to the varargs (if any)\n\t\t\tnewStk.argc = argc_actual - argc_min\t'argc is the number of varargs\n\t\t\t\n\t\t\tLocal destup:Byte Ptr Ptr = Byte Ptr Ptr(Byte Ptr(newStk) + STACKFRAME_INC)\n\t\t\tLocal upv:Byte Ptr Ptr = Byte Ptr Ptr(closure + 8)\n\t\t\tFor Local up:Int = 0 Until newBC.upvars\t'emplace upvars\n\t\t\t\tdestup[up] = upv[up]\n\t\t\t'\tPrint \" upv \" + up + \": \" + destv[up]\n\t\t\t'\tPrint \" val: \" + Double Ptr Ptr(Byte Ptr Ptr(closure) + 2 + up)[0][0]\n\t\t\tNext\n\t\t\t\n\t\t\t'note that the following OVERWRITE THE PARAMETERS (in release mode), so no touching stk from here on\n\t\t\tByte Ptr Ptr(retptr)[-4] = newBC.mcode\n\t\t\tByte Ptr Ptr(retptr)[-3] = Byte Ptr(newStk)\n\t\t\tByte Ptr Ptr(retptr)[-2] = Byte Ptr(newBC) + BYTECODE_INC\n\t\t\t\n\t\tElseIf fp[1] = BlueTypeTag.NANBOX | BlueTypeTag.NATFUN\t'native call\n\t\t\tLocal fun:Int(vm:BlueVM, ac:Int, av:Long Ptr, rv:Long Ptr) = Byte Ptr(fp[0])\n\t\t\tLocal argc:Int = Short Ptr(rp)[1], argv:Long Ptr = varp + rp[1], retv:Long Ptr = Long Ptr(Byte Ptr(stk) + stk.func.frameSz)\n\t\t\tLocal convert:BlueVM(p:Byte Ptr) = Byte Ptr(Identity), vm:BlueVM = convert(stk.func.vm)\n\t\t\tstk.retc = fun(vm, argc, argv, retv)\n\t\t\tstk.retv = retv\n\t\tElse\n\t\t\tReturn False\t'not a function; take appropriate action\n\t\tEndIf\n\t\tReturn True\t'all good and will auto-call when the caller returns\n\tEnd Function\n\t\n\tFunction InitOpTbl()\n\t\topc = New BlueOpcode\n\t\topTbl = [MOV, GETLC, SETLC, LOADK, LOADSI, LOADBOOL, LOADNIL, ..\n\t\t\tGETTAB, GETTABSI, SETTAB, SETTABSI, GETTABI, SETTABI, GETUPV, SETUPV, ..\n\t\t\tNEWTAB, CLOSURE, NEWUPV, ..\n\t\t\tADD, SUB, MUL, DIV, NMOD, POW, CAT, ..\n\t\t\tIDIV, BAND, BOR, BXOR, BSHL, BSHR, ..\n\t\t\tUNM, LNOT, ALEN, BNOT, UNP, ..\n\t\t\tEQ, LT, LEQ, ..\n\t\t\tJMP, JIF, JNOT, CALL, TCALL, RETVA, RETVA, ..\t'not a mistake: RET doesn't fit but we need the spacer\n\t\t\tPOSTCALL, VARARG, VAINIT, CALLINIT]\n\t\t\n\t\topTbl[opc.RET] = Byte Ptr(RET)\n\tEnd Function\n\t\n\tFunction Identity:Byte Ptr(b:Byte Ptr)\n\t\tReturn b\n\tEnd Function\n\tFunction PointerToExtType:Byte Ptr(p:Byte Ptr)\t'horrible pointer abuse (increment down so we can ignore the nonexistent vtbl)\n\t\tReturn p - SizeOf(Byte Ptr(0))\n\tEnd Function\n\tGlobal BPtoS:Stack(p:Byte Ptr) = Byte Ptr(BlueJIT.PointerToExtType)\nEnd Type\n\n","old_contents":"\n' Blue Moon\n' JIT engine\/opcodes\n\n' this is the core of the runtime: the machine code generator and opcodes\n' it's a halfway blend between JIT and interpreter: a basic JIT generates machine code\n' for \"unrolled\" interpreter loops, theoretically (ha!) providing a speed boost\n' it can also \"inline\" selected operations, coming closer to being a true JIT\n\n' for now this is an Include rather than Import lib due to recursive dependency\n' we'll fix that later\n\nRem\nSuperStrict\n\nImport \"blueerror.bmx\"\nImport \"bluevm.bmx\"\nImport etc etc...\nEnd Rem\n\n'Private\t'may need to rename and open these (in the shared interface?)\nExtern\n\tType Stack\n\t\tField retIP:Byte Ptr, prevBase:Stack, varp:Long Ptr, func:Bytecode, _:Long Ptr, argv:Long Ptr, retv:Long Ptr, argc:Short, retc:Short\n\tEnd Type\n\tType Bytecode\n\t\tField mcode:Byte Ptr, idMod:Int, kcount:Int, pcount:Int, upvars:Int, frameSz:Int, icount:Int, vm:Byte Ptr\n\tEnd Type\nEnd Extern\n'Public\n\nType BlueJIT Final\n\tConst PROLOGUESZ:Int = 25, ISIZE:Int = 5\n\t\n\tGlobal opTbl:Int(s:Stack, b:Bytecode, r:Byte Ptr)[], opc:BlueOpcode\n\tGlobal Prologue:Int[] = [ ..\n\t\t$90, $90, ..\n\t\t$8b, $44, $24, $04, .. 'mov 4(%esp), %eax\n\t\t$89, $44, $24, $f4, .. 'mov %eax, -12(%esp)\n\t\t$c7, $44, $24, $f8, $FF, $FF, $FF, $FF, .. 'movl ########, -8(%esp)\n\t\t$89, $64, $24, $fc, .. 'mov %esp, -4(%esp)\n\t\t$83, $ec, $0c.. 'sub $12, %esp\n\t]\n\t\n\tFunction Compile:Byte Ptr(vm:BlueVM, ins:Byte Ptr, icount:Int, bytecode:Bytecode)\n\t\t?Not x86\n\t\tRuntimeError \"The Blue Moon JIT does not support your platform (x86-32 only at this time)\"\n\t\t?\n\t\tAssert SizeOf(0:Long) = SizeOf(0:Double) And SizeOf(0:Int) = 4 And SizeOf(0:Long) = 8 And SizeOf(Byte Ptr(0)) = 4, ..\n\t\t\t\"assumptions about platform datatype sizes are invalid\"\n\t\t\n\t\tIf opTbl = Null Then InitOpTbl()\n\t\t\n\t\t' compute executable code size\n\t\tLocal codesize:Int = PROLOGUESZ, opPos:Int[icount]\t'since sizes are irregular, looking up offsets is easiest\n\t\tFor Local i:Int = 0 Until icount\n\t\t\topPos[i] = codesize\t'finalized below\n\t\t\tSelect ins[i * 8]\n\t\t\t\tCase opc.SETTAB, opc.GETTAB\n\t\t\t\t\tcodesize :+ ISIZE * 2\n\t\t\t\tDefault\n\t\t\t\t\tcodesize :+ ISIZE\n\t\t\tEnd Select\n\t\tNext\n\t\t\n\t\t' allocate executable space\n\t\tLocal code:Byte Ptr = vm.mem.AllocCodeBlock(codesize)\n\t\t\n\t\t'finalize op offsets se we can look them up\n\t\tFor Local i:Int = 0 Until icount\n\t\t\topPos[i] :+ Int(code)\t'direct to executable space\n\t\tNext\n\t\t\n\t\t' emplace prologue (used for calling in from native only)\n\t\tFor Local p:Int = 0 Until PROLOGUESZ\n\t\t\tcode[p] = Prologue[p]\n\t\tNext\n\t\tByte Ptr Ptr(code + 14)[0] = Byte Ptr(bytecode)\t'replace the ########\n\t\t\n\t\t' epilogue (shared location per-vm, probably already set)\n\t\tvm.mem.returnToNative[0] = $c30cc483\t'add $12, %esp ; ret - i.e. restore the stack to normal\n\t\t\n\t\tLocal ktable:Long Ptr = Long Ptr(ins + 8 * bytecode.icount + 8 * bytecode.upvars)\t'constant table\n\t\t\n\t\t' generate machine code!\n\t\tFor Local i:Int = 0 Until icount\t'emplace opcode calls and supporting bytecode data\n\t\t\tLocal codep:Byte Ptr = Byte Ptr(opPos[i]), bytecodep:Byte Ptr = Byte Ptr(Int(codep) + vm.mem.PAGESZ)\n\t\t\tLocal bi:Int = i * 8, op:Int = ins[bi], ip:Int Ptr = Int Ptr(ins + bi), func:Byte Ptr = opTbl[op]\n\t\t\t\n\t\t\tcodep[0] = $e8\t'call\n\t\t\tByte Ptr Ptr(codep + 1)[0] = func - Int(codep + ISIZE)\n\t\t\t\n\t\t\tbytecodep[0] = ins[bi + 1] ; bytecodep[1] = ins[bi + 2]\t'used by most, may get overwritten\n\t\t\t\n\t\t\tSelect op\n\t\t\t\tCase opc.LOADSI, opc.CLOSURE, opc.RET, opc.POSTCALL\n\t\t\t\t\tInt Ptr(bytecodep + 1)[0] = ip[1]\n\t\t\t\t\t\n\t\t\t\tCase opc.LOADK\n\t\t\t\t\tLong Ptr Ptr(bytecodep + 1)[0] = ktable + ip[1]\n\t\t\t\t\t\n\t\t\t\tCase opc.SETTABSI, opc.GETTABSI\n\t\t\t\t\tShort Ptr(bytecodep)[1] = ip[1]\n\t\t\t\t\t\n\t\t\t\tCase opc.SETTAB, opc.GETTAB\n\t\t\t\t\tcodep[ISIZE] = $90 ; Int Ptr(codep + ISIZE + 1)[0] = $90909090\t'nops; the space is needed in the bytecode\n\t\t\t\t\tLong Ptr Ptr(bytecodep + 2)[0] = ktable + ip[1]\n\t\t\t\t\tLong Ptr Ptr(bytecodep + 2)[1] = Null\t'inline cache space\n\t\t\t\t\t\n\t\t\t\tCase opc.GETUPV\n\t\t\t\t\tIf Int Ptr(ins + icount * 8)[2 * bytecodep[1]] = -1\n\t\t\t\t\t\tByte Ptr Ptr(codep + 1)[0] = Byte Ptr(BlueJIT.GETENV) - Int(codep + ISIZE)\n\t\t\t\t\t\tByte Ptr Ptr(bytecodep + 1)[0] = Varptr(vm._ENV.val)\t'note: doesn't allow _ENV to be changed from Max\n\t\t\t\t\tEndIf\n\t\t\t\t\t\n\t\t\t\tCase opc.CALL\n\t\t\t\t\tShort Ptr(bytecodep)[1] = ip[1]\n\t\t\t\t\t\n\t\t\t\tCase opc.JIF, opc.JNOT\n\t\t\t\t\tInt Ptr(bytecodep + 1)[0] = opPos[i + ip[1]]\n\t\t\t\t\t\n\t\t\t\tCase opc.JMP\n\t\t\t\t\tcodep[0] = $e9\t'use a true jump\n\t\t\t\t\tInt Ptr(codep + 1)[0] = opPos[i + ip[1]] - (opPos[i] + ISIZE)\n\t\t\t\t\t\n\t\t\t\tDefault\t'binary operations A = B op C\n\t\t\t\t\tbytecodep[2] = ip[1]\n\t\t\tEnd Select\n\t\tNext\n\t\t\n\t\tReturn code\n\tEnd Function\n\t\n\t\n\tConst STACKFRAME_INC:Int = BlueVMMemory.STACKFRAMESZ + 4, BYTECODE_INC:Int = BlueVMMemory.BYTECODESZ + 4\n\tConst IP_OFFSET:Int = BlueVMMemory.PAGESZ - ISIZE\n\t\n\t\n\t'note: extern vars must take into account the vtbl offset, so that converting from a typed pointer can be a simple cast (faster)\t\n\t\n\tFunction MOV(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"MOV \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tvarp[rp[0]] = varp[rp[1]]\t'assigning through Double is unsafe as it can corrupt the bit pattern\n\tEnd Function\n\tFunction GETLC(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction SETLC(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"SETLC \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\t'add a write barrier here\n\t\tLong Ptr Ptr(varp + rp[0])[0][0] = varp[rp[1]]\n\tEnd Function\n\tFunction LOADK(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"LOADK \/\/\"\n\t\tLocal rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET, varp:Long Ptr = stk.varp + rp[0], kp:Long Ptr = Long Ptr Ptr(rp + 1)[0]\n\t\tvarp[0] = kp[0]\n\tEnd Function\n\tFunction LOADSI(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"LOADSI \/\/\"\n\t\tLocal rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal val:Int = Int Ptr(rp + 1)[0]\n\t\tDouble Ptr(stk.varp)[rp[0]] = Double(val)\n\tEnd Function\n\tFunction LOADBOOL(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"LOADBOOL \/\/\"\n\t\tLocal rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET, vp:Int Ptr = Int Ptr(stk.varp + rp[0])\n\t\tvp[1] = BlueTypeTag.NANBOX | BlueTypeTag.BOOL\n\t\tvp[0] = Int Ptr(rp + 1)[0]\n\tEnd Function\n\tFunction LOADNIL(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"LOADNIL \/\/\"\n\t\tLocal rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tInt Ptr(stk.varp + rp[0])[1] = BlueTypeTag.NANBOX | BlueTypeTag.NIL\n\tEnd Function\n\t\n\tFunction GETTAB(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t\tPrint \"GETTAB \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET, kp:Long Ptr = Long Ptr Ptr(rp + 2)[0]\n\t\tLocal tabp:Byte Ptr = Byte Ptr Ptr(varp + rp[1])[0]\n\t\t'type check\n\t\tPrint \" tag: \" + Bin(Int Ptr(kp)[1])\n\t\tLocal keyslot:Long Ptr = Null, slot:Long Ptr = BlueTable.GetSlot(tabp, kp[0], Varptr(keyslot))\n\t\tPrint \" slot: \" + Hex(Int(slot))\n\t\tIf (slot = Null) Or (keyslot[0] <> kp[0])\t'not in table; invoke metamethod\n\t\t\t'if keyslot == 1 then it's invalid\n\t\t\tDebugStop\n\t\tElse\n\t\t\tvarp[rp[0]] = slot[0]\n\t\tEndIf\n\tEnd Function\n\tFunction GETTABSI(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction SETTAB(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t\tPrint \"SETTAB \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET, kp:Long Ptr = Long Ptr Ptr(rp + 2)[0]\n\t\tLocal tabp:Byte Ptr = Byte Ptr Ptr(varp + rp[0])[0]\n\t\tPrint \" tag: \" + Bin(Int Ptr(kp)[1])\n\t\tLocal keyslot:Long Ptr = Null, slot:Long Ptr = BlueTable.GetSlot(tabp, kp[0], Varptr(keyslot))\n\t\tPrint \" slot: \" + Hex(Int(slot))\n\t\tIf (slot = Null) Or (keyslot[0] <> kp[0])\t'not in table; invoke metamethod or rawset\n\t\t\t'if keyslot == 1 then it's invalid\n\t\t\tLocal convert:BlueVM(p:Byte Ptr) = Byte Ptr(Identity), vm:BlueVM = convert(bc.vm)\n\t\t\tBlueTable.RawSet(vm.mem, tabp, kp[0], varp[rp[1]])\n\t\tElse\n\t\t\tslot[0] = varp[rp[1]]\n\t\tEndIf\n\tEnd Function\n\tFunction SETTABSI(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t\tPrint \"SETTABSI \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal convert:BlueVM(p:Byte Ptr) = Byte Ptr(Identity), vm:BlueVM = convert(bc.vm)\n\t\tLocal tabp:Byte Ptr = varp + rp[0]\n\t\tPrint \" \" + Short Ptr(rp)[1]\n\t\tLocal key:Long ; Double Ptr(Varptr(key))[0] = Short Ptr(rp)[1]\n\t\tBlueTable.RawSet(vm.mem, Byte Ptr Ptr(tabp)[0], key, varp[rp[1]])\n\tEnd Function\n\tFunction GETTABI(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t\tPrint \"GETTABI \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal tabp:Byte Ptr = varp + rp[1]\n\t\tPrint \" tag: \" + Bin(Int Ptr(varp + rp[2])[1])\n\t\tLocal val:Long = BlueTable.RawGet(Byte Ptr Ptr(tabp)[0], varp[rp[2]])\n\t\tLocal v:Double = Double Ptr(Varptr(val))[0]\n\t\tPrint \" \" + v\n\t\tvarp[rp[0]] = val\n\tEnd Function\n\tFunction SETTABI(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t\tPrint \"SETTABI \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal convert:BlueVM(p:Byte Ptr) = Byte Ptr(Identity), vm:BlueVM = convert(bc.vm)\n\t\tLocal tabp:Byte Ptr = varp + rp[0]\n\t\tPrint \" \" + Double Ptr(varp)[rp[2]] + \" \" + Double Ptr(varp)[rp[1]]\n\t\tPrint \" tag: \" + Bin(Int Ptr(varp + rp[2])[1])\n\t\tBlueTable.RawSet(vm.mem, Byte Ptr Ptr(tabp)[0], varp[rp[2]], varp[rp[1]])\n\tEnd Function\n\tFunction GETUPV(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t\tPrint \"GETUPV \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tPrint \" \" + rp[0] + \" \" + rp[1] + \" \" + rp[2]\n\t\tDebugStop\n\t\tLocal upvp:Byte Ptr Ptr = Byte Ptr Ptr(Byte Ptr(stk) + STACKFRAME_INC), valp:Long Ptr = Long Ptr(upvp[rp[1]])\n\t\tvarp[rp[0]] = valp[0]\n\tEnd Function\n\tFunction GETENV(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\t'\"unlisted\" instruction: GETUPV for _ENV is translated into this at load-time\n\t\tPrint \"GETENV \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tPrint \" \" + rp[0] + \" \" + Hex(Int Ptr(rp + 1)[0])\n\t\t'need a type check\n\t\tvarp[rp[0]] = Long Ptr Ptr(rp + 1)[0][0]\n\tEnd Function\n\tFunction SETUPV(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction NEWTAB(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t\tPrint \"NEWTAB \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal convert:BlueVM(p:Byte Ptr) = Byte Ptr(Identity), vm:BlueVM = convert(bc.vm)\n\t\tLocal tab:Byte Ptr = vm.mem.AllocTable(Null)\n\t\tLocal d:Int Ptr = Int Ptr(varp + rp[0])\n\t\td[0] = Int(tab) ; d[1] = BlueTypeTag.NANBOX | BlueTypeTag.TBL\n\tEnd Function\n\tFunction CLOSURE(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"CLOSURE \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal convert:BlueVM(p:Byte Ptr) = Byte Ptr(Identity), vm:BlueVM = convert(bc.vm)\n\t\tLocal d:Int Ptr = Int Ptr(varp + rp[0])\n\t\tLocal cbytecode:Bytecode = vm.funIndex[Int Ptr(rp + 1)[0]], upvp:Int Ptr = Int Ptr(Byte Ptr(cbytecode) + BYTECODE_INC + 8 * cbytecode.icount)\n\t\tLocal closure:Byte Ptr = vm.mem.AllocClosure(cbytecode, cbytecode.upvars)\t'upvars is always even (alignment)\n\t\t\n\t\t'get upvalues off the stack\n\t\tFor Local u:Int = 0 Until cbytecode.upvars\n\t\t\tIf upvp[2 * u]\n\t\t\t\tByte Ptr Ptr(closure)[2 + u] = Byte Ptr Ptr(Byte Ptr(stk) + STACKFRAME_INC)[upvp[2 * u + 1]]\n\t\t\tElse\n\t\t\t\tByte Ptr Ptr(closure)[2 + u] = Byte Ptr Ptr(varp + upvp[2 * u + 1])[0]\n\t\t\tEndIf\n\t\tNext\n\t\t\n\t\td[0] = Int(closure) ; d[1] = BlueTypeTag.NANBOX | BlueTypeTag.FUN\n\tEnd Function\n\tFunction NEWUPV(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"NEWUPV \/\/\"\n\t\tLocal rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal convert:BlueVM(p:Byte Ptr) = Byte Ptr(Identity), vm:BlueVM = convert(bc.vm)\n\t\tLocal upv:Byte Ptr = vm.mem.AllocObject(8, BlueTypeTag.UPV), d:Int Ptr = Int Ptr(stk.varp + rp[0])\n\t\tLong Ptr(upv)[0] = Long Ptr(d)[0]\t'promote a value if it existed (useful for parameters)\n\t\td[0] = Int(upv) ; d[1] = BlueTypeTag.NANBOX | BlueTypeTag.UPV\n\tEnd Function\n\t\n\tFunction ADD(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t\tPrint \"ADD \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal d:Double Ptr = Double Ptr(varp + rp[0])\n\t\tLocal r:Int Ptr = Int Ptr(varp + rp[1]), l:Int Ptr = Int Ptr(varp + rp[2])\n\t\tIf l[1] & BlueTypeTag.NANBOX_CHK = BlueTypeTag.NANBOX Or r[1] & BlueTypeTag.NANBOX_CHK = BlueTypeTag.NANBOX\n\t\t\tDebugStop\n\t\tElse\n\t\t\tPrint \" \" + Double Ptr(l)[0] + \" \" + Double Ptr(r)[0]\n\t\t\td[0] = Double Ptr(l)[0] + Double Ptr(r)[0]\n\t\tEndIf\n\tEnd Function\n\tFunction SUB(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction MUL(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction DIV(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction NMOD(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction POW(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction CAT(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction IDIV(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction BAND(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction BOR(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction BXOR(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction BSHL(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction BSHR(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction UNM(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction LNOT(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction ALEN(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction BNOT(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction UNP(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction EQ(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"EQ \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = (Byte Ptr Ptr(retptr) - 4)[0] + IP_OFFSET\n\t\tLocal r:Double = Double Ptr(varp)[rp[1]]\n\t\tLocal l:Double = Double Ptr(varp)[rp[2]]\n\t\tInt Ptr(varp + rp[0])[0] = l = r\n\tEnd Function\n\tFunction LT(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction LEQ(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\t\n\tFunction JMP(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t\tRuntimeError \"wait, why are we here?\"\n\tEnd Function\n\tFunction JIF(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"JIF \/\/\"\n\t\tLocal rp:Byte Ptr = (Byte Ptr Ptr(retptr) - 4)[0] + IP_OFFSET\n\t\tIf Int Ptr(stk.varp + rp[0])[0]\n\t\t\tLocal target:Int = Int Ptr(rp + 1)[0]\n\t\t\tInt Ptr(retptr)[-4] = target\n\t\tEndIf\n\tEnd Function\n\tFunction JNOT(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction CALL(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"CALL \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal fp:Int Ptr = Int Ptr(varp + rp[0])\n\t\tIf Not PrepareCall(fp, stk, rp, varp, retptr)\t'PrepareCall sets everything up so there's nothing else to do to make the call happen\n\t\t\t'__call metamethod\n\t\tEndIf\n\tEnd Function\n\tFunction TCALL(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction RET:Byte Ptr(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"RET \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp\n\t\tLocal rp0:Byte Ptr = Byte Ptr Ptr(retptr)[-4], rp:Byte Ptr = rp0 + IP_OFFSET\n\t\t\n\t\tLocal oldStk:Stack = stk.prevBase\n\t\tLocal retv:Long Ptr = varp + rp[0]\n\t\tIf oldStk\n\t\t\toldStk.retv = retv\n\t\t\toldStk.retc = Int Ptr(rp + 1)[0]\n\t\t\tByte Ptr Ptr(retptr)[-4] = stk.retIP\n\t\t\tByte Ptr Ptr(retptr)[-3] = Byte Ptr(oldStk)\n\t\t\tByte Ptr Ptr(retptr)[-2] = Byte Ptr(oldStk.func) + BYTECODE_INC\n\t\tElse\t'return to native code\n\t\t\tLocal codePage:Byte Ptr = Byte Ptr(Int(rp0) & ((Int(2^12)-1) Shl 20))\n\t\t\tByte Ptr Ptr(retptr)[-4] = codePage + 4\n\t\t\tReturn retv\n\t\tEndIf\n\tEnd Function\n\tFunction RETVA(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction POSTCALL(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"POSTCALL \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp\n\t\tLocal rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\t\n\t\tFor Local r:Int = 0 Until Min(Int Ptr(rp + 1)[0], stk.retc)\n\t\t\t(varp + rp[0])[r] = stk.retv[r]\n\t\t'\tPrint \" return \" + r + \": \" + Double Ptr(stk.retv)[r]\n\t\tNext\n\t\t'nil the rest\n\tEnd Function\n\tFunction VARARG(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction VAINIT(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction CALLINIT(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\t\n\t\n\tFunction PrepareCall:Int(fp:Int Ptr, stk:Stack, rp:Byte Ptr, varp:Long Ptr, retptr:Byte Ptr)\n\t\tIf fp[1] = BlueTypeTag.NANBOX | BlueTypeTag.FUN\n\t\t\tLocal newStk0:Stack ; Byte Ptr Ptr(Varptr(newStk0))[0] = Byte Ptr(stk) + stk.func.frameSz\n\t\t\tLocal newStk:Stack = newStk0\t'micro-opt: newStk0 can't be a register because of the unwieldy conversion\n\t\t\t\n\t\t\tnewStk.retIP = Byte Ptr Ptr(retptr)[-4]\n\t\t\tnewStk.prevBase = stk\n\t\t\tLocal closure:Byte Ptr = Byte Ptr(fp[0])\n\t\t\tLocal newBC:Bytecode = Bytecode Ptr(closure)[0]\n\t\t\tLocal voff:Int = STACKFRAME_INC + 4 * newBC.upvars\n\t\t\tnewStk.varp = Long Ptr(Byte Ptr(newStk) + voff)\n\t\t\tnewStk.func = newBC\n\t\t\t\n\t\t\tLocal argc_actual:Int = Short Ptr(rp)[1], argc_required:Int = newBC.pcount\n\t\t'\tLocal argc_min:Int ; If argc_actual < argc_required Then argc_min = argc_actual Else argc_min = argc_required\n\t\t\tLocal argc_min:Int = argc_actual - argc_required ; argc_min = (argc_min & (argc_min Shr 31)) + argc_required 'branchless 32-bit Min\n\t\t\t\n\t\t\tLocal argv:Long Ptr = varp + rp[1], destv:Long Ptr = newStk.varp\n\t\t\tFor Local a:Int = 0 Until argc_min\n\t\t\t\tdestv[a] = argv[a]\n\t\t\t'\tPrint \" arg \" + a + \": \" + argv[a]\n\t\t\tNext\n\t\t\tFor Local a:Int = argc_min Until argc_required\t'nil any unfilled parameters\n\t\t\t\tInt Ptr(destv + a)[1] = BlueTypeTag.NANBOX | BlueTypeTag.NIL\n\t\t\tNext\n\t\t\tnewStk.argv = argv + argc_min\t'argv should be to the varargs (if any)\n\t\t\tnewStk.argc = argc_actual - argc_min\t'argc is the number of varargs\n\t\t\t\n\t\t\tLocal destup:Byte Ptr Ptr = Byte Ptr Ptr(Byte Ptr(newStk) + STACKFRAME_INC)\n\t\t\tLocal upv:Byte Ptr Ptr = Byte Ptr Ptr(closure + 8)\n\t\t\tFor Local up:Int = 0 Until newBC.upvars\t'emplace upvars\n\t\t\t\tdestup[up] = upv[up]\n\t\t\t'\tPrint \" upv \" + up + \": \" + destv[up]\n\t\t\t'\tPrint \" val: \" + Double Ptr Ptr(Byte Ptr Ptr(closure) + 2 + up)[0][0]\n\t\t\tNext\n\t\t\t\n\t\t\t'note that the following OVERWRITE THE PARAMETERS (in release mode), so no touching stk from here on\n\t\t\tByte Ptr Ptr(retptr)[-4] = newBC.mcode\n\t\t\tByte Ptr Ptr(retptr)[-3] = Byte Ptr(newStk)\n\t\t\tByte Ptr Ptr(retptr)[-2] = Byte Ptr(newBC) + BYTECODE_INC\n\t\t\t\n\t\tElseIf fp[1] = BlueTypeTag.NANBOX | BlueTypeTag.NATFUN\t'native call\n\t\t\tLocal fun:Int(vm:BlueVM, ac:Int, av:Long Ptr, rv:Long Ptr) = Byte Ptr(fp[0])\n\t\t\tLocal argc:Int = Short Ptr(rp)[1], argv:Long Ptr = varp + rp[1], retv:Long Ptr = Long Ptr(Byte Ptr(stk) + stk.func.frameSz)\n\t\t\tLocal convert:BlueVM(p:Byte Ptr) = Byte Ptr(Identity), vm:BlueVM = convert(stk.func.vm)\n\t\t\tstk.retc = fun(vm, argc, argv, retv)\n\t\t\tstk.retv = retv\n\t\tElse\n\t\t\tReturn False\t'not a function; take appropriate action\n\t\tEndIf\n\t\tReturn True\t'all good and will auto-call when the caller returns\n\tEnd Function\n\t\n\tFunction InitOpTbl()\n\t\topc = New BlueOpcode\n\t\topTbl = [MOV, GETLC, SETLC, LOADK, LOADSI, LOADBOOL, LOADNIL, ..\n\t\t\tGETTAB, GETTABSI, SETTAB, SETTABSI, GETTABI, SETTABI, GETUPV, SETUPV, ..\n\t\t\tNEWTAB, CLOSURE, NEWUPV, ..\n\t\t\tADD, SUB, MUL, DIV, NMOD, POW, CAT, ..\n\t\t\tIDIV, BAND, BOR, BXOR, BSHL, BSHR, ..\n\t\t\tUNM, LNOT, ALEN, BNOT, UNP, ..\n\t\t\tEQ, LT, LEQ, ..\n\t\t\tJMP, JIF, JNOT, CALL, TCALL, RETVA, RETVA, ..\t'not a mistake: RET doesn't fit but we need the spacer\n\t\t\tPOSTCALL, VARARG, VAINIT, CALLINIT]\n\t\t\n\t\topTbl[opc.RET] = Byte Ptr(RET)\n\tEnd Function\n\t\n\tFunction Identity:Byte Ptr(b:Byte Ptr)\n\t\tReturn b\n\tEnd Function\n\tFunction PointerToExtType:Byte Ptr(p:Byte Ptr)\t'horrible pointer abuse (increment down so we can ignore the nonexistent vtbl)\n\t\tReturn p - SizeOf(Byte Ptr(0))\n\tEnd Function\n\tGlobal BPtoS:Stack(p:Byte Ptr) = Byte Ptr(BlueJIT.PointerToExtType)\nEnd Type\n\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"757bbf4b4ddf3fcdad75dde5a134ce9d5a5a3f72","subject":"MonkeyMax - Added OnSuspend\/OnResume for gxtkAudio","message":"MonkeyMax - Added OnSuspend\/OnResume for gxtkAudio\n","repos":"swoolcock\/diddy,swoolcock\/diddy,swoolcock\/diddy,swoolcock\/diddy,swoolcock\/diddy","old_file":"monkeymax\/modules\/mojo\/native\/mojo.bmax.bmx","new_file":"monkeymax\/modules\/mojo\/native\/mojo.bmax.bmx","new_contents":"' ***** Start mojo.bmax.bmx ******\r\n\r\nGlobal app:gxtkApp\r\n\r\nType gxtkApp\r\n\tField ginput:gxtkInput\r\n\tField gaudio:gxtkAudio\r\n\tField ggraphics:gxtkGraphics\r\n\r\n\tField dead:Int=0\r\n\tField suspended:Int=0\r\n\tField vloading:Int=0\r\n\tField maxloading:Int=0\r\n\tField updateRate:Int=0\r\n\tField nextUpdate:Float=0\r\n\tField updatePeriod:Float=0\r\n\tField startMillis:Float=0\r\n\t\r\n\tMethod New()' gxtkApp()\r\n\t\tapp=Self\r\n\t\tggraphics=New gxtkGraphics\r\n\tEndMethod\r\n\t\r\n\tMethod Setup()\r\n\t\tginput=New gxtkInput\r\n\t\tgaudio=New gxtkAudio\r\n\r\n\t\tbb_input__1Set_1Input_1Device(ginput)\r\n\t\tbb_audio__1Set_1Audio_1Device(gaudio)\r\n\t\t\r\n\t\tstartMillis=BlitzMaxMillisecs()\r\n\t\t\r\n\t\tSetFrameRate( 0 )\r\n\t\t\r\n\t\tInvokeOnCreate()\r\n\t\tInvokeOnRender()\r\n\t\tUpdate()\r\n\tEndMethod\r\n\t\r\n\tMethod Update()\r\n\t\tWhile Not AppTerminate()\r\n\t\t\tIf Not updatePeriod return\r\n\t\t\tLocal updates:Int = 0\r\n\t\t\t\r\n\t\t\tRepeat\r\n\t\t\t\tnextUpdate:+updatePeriod\r\n\t\t\t\tInvokeOnUpdate()\r\n\t\t\t\tIf Not updatePeriod Then Exit\r\n\t\t\t\tIf nextUpdate>BlitzMaxMillisecs() Then Exit\r\n\t\t\t\tupdates:+1\r\n\t\t\t\tIf updates = 7 Then\r\n\t\t\t\t\tnextUpdate = BlitzMaxMillisecs()\r\n\t\t\t\t\tExit\r\n\t\t\t\tEndIf\r\n\t\t\tForever\r\n\t\t\tInvokeOnRender()\r\n\t\t\tLocal del:Int = nextUpdate - BlitzMaxMillisecs()\r\n\t\t\tIf del < 1 Then del = 1\r\n\t\t\tDelay(del)\r\n\t\tWend\r\n\tEndMethod\r\n\t\r\n\tMethod InvokeOnCreate()\r\n\t\tIf dead Return\r\n\t\tdead = 1\r\n\t\tOnCreate()\r\n\t\tdead = 0\r\n\tEndMethod\r\n\r\n\tMethod InvokeOnUpdate()\r\n\t\tIf dead Or suspended Or Not updateRate Or vloading Return\r\n\t\tOnUpdate()\r\n\tEndMethod\r\n\t\r\n\tMethod InvokeOnRender()\r\n\t\tIf dead Or suspended Return\r\n\t\tggraphics.BeginRender()\r\n\t\tIf vloading\r\n\t\t\tOnLoading()\r\n\t\tElse\r\n\t\t\tOnRender()\r\n\t\tEndIf\r\n\t\tggraphics.EndRender()\r\n\tEndMethod\r\n\t\r\n\t\r\n\tMethod SetFrameRate( fps:Int )\r\n\t\tIf fps\r\n\t\t\tupdatePeriod=1000.0\/fps\r\n\t\t\tnextUpdate=BlitzMaxMillisecs() +updatePeriod\r\n\t\tElse\r\n\t\t\tupdatePeriod=0\r\n\t\tEndIf\r\n\tEndMethod\r\n\r\n\tMethod LoadState:String()\r\n'\t\tvar file:SharedObject=SharedObject.getLocal( \"gxtkapp\" );\r\n'\t\tvar state:String=file.data.state;\r\n'\t\tfile.close();\r\n'\t\tif( state ) return state;\r\n\t\tReturn \"\"\r\n\tEndMethod\r\n\t\r\n\tMethod SaveState:Int( state:String )\r\n'\t\tvar file:SharedObject=SharedObject.getLocal( \"gxtkapp\" );\r\n'\t\tfile.data.state=state;\r\n'\t\tfile.close();\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod LoadString:String( path:String )\r\n\t\tpath = \"data\/\" + path\r\n\t\tTry\r\n\t\t\tReturn LoadText( path )\r\n\t\tCatch ReadFail:Object\r\n\t\t\tReturn Null\r\n\t\tEndTry\r\n\tEndMethod\r\n\t\r\n\t' ***** GXTK API *****\r\n\t\r\n\tMethod GraphicsDevice:gxtkGraphics()\r\n\t\tReturn ggraphics\r\n\tEndMethod\r\n\r\n\tMethod InputDevice:gxtkInput()\r\n\t\tReturn ginput\r\n\tEndMethod\r\n\r\n\tMethod AudioDevice:gxtkAudio()\r\n\t\tReturn gaudio\r\n\tEndMethod\r\n\r\n\tMethod SetUpdateRate:Int(hertz:Int)\r\n\t\tupdateRate = hertz\r\n\t\tIf Not vloading Then SetFrameRate(updateRate)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod MilliSecs:Int()\r\n\t\tReturn BlitzMaxMillisecs() - startMillis\r\n\tEndMethod\r\n\t\r\n\tMethod Loading:Int()\r\n\t\tReturn vloading\r\n\tEndMethod\r\n\r\n\tMethod OnCreate:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod OnUpdate:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod OnSuspend:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod OnResume:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod OnRender:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod OnLoading:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkGraphics\r\n\tField gmode:Int = 1\r\n\tField ix:Float=1,iy:Float,jx:Float,jy:Float=1,tx:Float,ty:Float\r\n\tField sx:Float=1,sy:Float=1,rot:Float=0\r\n\t\r\n\tMethod Mode:Int()\r\n\t\tReturn gmode\r\n\tEndMethod\r\n\t\r\n\tMethod Cls:Int(r:Int = 0, g:Int = 0, b:Int = 0)\r\n\t\tBlitzMaxCls(r, g, b)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawPoint:Int(x:Float, y:Float)\r\n\t\tLocal nx:Float = TransX(x,y)\r\n\t\tLocal ny:Float = TransY(x,y)\r\n\t\tPlot nx, ny\r\n\tEndMethod\r\n\t\r\n\tMethod LoadSurface:gxtkSurface(path:String)\r\n\t\tLocal image:TImage = LoadImage(\"data\/\"+path)\r\n\t\tIf image Then\r\n\t\t\tLocal gs:gxtkSurface = New gxtkSurface\r\n\t\t\tgs.setImage(image)\r\n\t\t\tReturn gs\r\n\t\tEndIf\r\n\t\tReturn Null\r\n\tEndMethod\r\n\t\r\n\tMethod BeginRender()\r\n\tEndMethod\r\n\t\r\n\tMethod EndRender()\r\n\t\tFlip\r\n\tEndMethod\r\n\t\r\n\tMethod SetColor:Int(r:Int, g:Int, b:Int)\r\n\t\tBlitzMaxSetColor(r, g, b)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod SetAlpha:Int(a:Float)\r\n\t\tBlitzMaxSetAlpha(a)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod SetBlend:Int(blend:Int)\r\n\t\tBlitzMaxSetBlend(blend)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod Width:Int()\r\n\t\tReturn GraphicsWidth()\r\n\tEndMethod\r\n\t\r\n\tMethod Height:Int()\r\n\t\tReturn GraphicsHeight()\r\n\tEndMethod\r\n\t\r\n\tMethod SetScissor:Int(x:Int, y:Int, w:Int, h:Int)\r\n\t\tSetViewport(x, y, w, h) ' NOT TESTED!\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod TransX:Float(x:Float, y:Float)\r\n\t\tReturn ix*x + jx*y + tx\r\n\tEndMethod\r\n\t\r\n\tMethod TransY:Float(x:Float, y:Float)\r\n\t\tReturn iy*x + jy*y + ty\r\n\tEndMethod\r\n\t\r\n\tMethod SetMatrix:Int(ix:Float,iy:Float,jx:Float,jy:Float,tx:Float,ty:Float)\r\n\t\tSelf.ix = ix ; Self.iy = iy\r\n\t\tSelf.jx = jx ; Self.jy = jy\r\n\t\tSelf.tx = tx ; Self.ty = ty\r\n\t\tsx = Sqr(ix*ix+iy*iy)\r\n\t\tsy = Sqr(jx*jx+jy*jy)\r\n\t\trot = Atan2( iy, ix )\r\n\t\tIf ix < 0 Then\r\n\t\t\tsx = -sx\r\n\t\t\trot :+ 180\r\n\t\tEndIf\r\n\t\tIf jy < 0 Then sy = -sy\r\n\t\tSetTransform( rot, sx, sy )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawSurface:Int(surface:gxtkSurface,x:Float,y:Float)\r\n\t\tLocal nx:Float = TransX(x,y)\r\n\t\tLocal ny:Float = TransY(x,y)\r\n\t\tDrawImage(surface.image, nx, ny, 0)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawSurface2:Int(surface:gxtkSurface,x:Float,y:Float, srcx:Int, srcy:Int, srcw:Int, srch:Int )\r\n\t\tLocal nx:Float = TransX(x,y)\r\n\t\tLocal ny:Float = TransY(x,y)\r\n\t\tDrawSubImageRect(surface.image, nx, ny, srcw, srch, srcx, srcy, srcw, srch)\t\t\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawLine:Int( x1:Float,y1:Float,x2:Float,y2:Float )\r\n\t\tLocal nx1:Float = TransX(x1,y1)\r\n\t\tLocal ny1:Float = TransY(x1,y1)\r\n\t\tLocal nx2:Float = TransX(x2,y2)\r\n\t\tLocal ny2:Float = TransY(x2,y2)\r\n\t\t' Need to reset transform so that BlitzMax doesn't try to apply rotation\r\n\t\tSetTransform( 0, 1, 1 )\r\n\t\tBlitzMaxDrawLine(nx1, ny1, nx2, ny2)\r\n\t\tSetTransform( rot, sx, sy )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawOval:Int( x:Float, y:Float, w:Float, h:Float )\r\n\t\tLocal nx:Float = TransX(x,y)\r\n\t\tLocal ny:Float = TransY(x,y)\r\n\t\tBlitzMaxDrawOval(nx, ny, w, h)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawPoly:Int(vertices:Float[])\r\n\t\t' setting the origin to use the current rotation translation\r\n\t\tSetOrigin(TransX(0,0), TransY(0,0))\r\n\t\tBlitzMaxDrawPoly( vertices )\r\n\t\tSetOrigin(0, 0)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawRect:Int( x:Float, y:Float, w:Float, h:Float )\r\n\t\tLocal nx:Float = TransX(x,y)\r\n\t\tLocal ny:Float = TransY(x,y)\r\n\t\tBlitzMaxDrawRect(nx, ny, w, h)\r\n\t\tReturn 0\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkInput\r\n\tMethod MouseX:Float()\r\n\t\tReturn BRL.PolledInput.MouseX()\r\n\tEndMethod\r\n\r\n\tMethod MouseY:Float()\r\n\t\tReturn BRL.PolledInput.MouseY()\r\n\tEndMethod\r\n\t\r\n\tMethod KeyDown:Int( key:Int )\r\n\t\tif( key = 384 ) key = 1 ' change TOUCH0 to MOUSE_LMB\r\n\r\n\t\tIf( key >= 1 And key <= 3 )\r\n\t\t\tReturn BRL.PolledInput.MouseDown( key )\r\n\t\tEndIf\r\n\t\tIf key < 256\r\n\t\t\tReturn BRL.PolledInput.KeyDown( key )\r\n\t\tElse\r\n\t\t\tReturn 0\r\n\t\tEndIf\r\n\tEndMethod\r\n\r\n\tMethod KeyHit:Int( key:Int )\r\n\t\tif( key = 384 ) key = 1 ' change TOUCH0 to MOUSE_LMB\r\n\t\tIf( key >= 1 And key <= 3 )\r\n\t\t\tReturn BRL.PolledInput.MouseHit( key )\r\n\t\tEndIf\r\n\t\tIf key < 256\r\n\t\t\tReturn BRL.PolledInput.KeyHit( key )\r\n\t\tElse\r\n\t\t\tReturn 0\r\n\t\tEndIf\r\n\tEndMethod\r\n\r\n\tMethod GetChar:Int()\r\n\t\tReturn BRL.PolledInput.GetChar()\r\n\tEndMethod\r\n\r\n\tMethod JoyX:Int( index:Int )\r\n\t\tReturn Pub.FreeJoy.JoyX( index )\r\n\tEndMethod\r\n\r\n\tMethod JoyY:Int( index:Int )\r\n\t\tReturn Pub.FreeJoy.JoyY( index )\r\n\tEndMethod\r\n\r\n\tMethod JoyZ:Int( index:Int )\r\n\t\tReturn Pub.FreeJoy.JoyZ( index )\r\n\tEndMethod\r\n\r\n\tMethod TouchX:Float( index:Int )\r\n\t\tReturn BRL.PolledInput.MouseX()\r\n\tEndMethod\r\n\r\n\tMethod TouchY:Float( index:Int )\r\n\t\tReturn BRL.PolledInput.MouseY()\r\n\tEndMethod\r\n\t\r\n\tMethod AccelX:Int()\r\n\t\treturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod AccelY:Int()\r\n\t\treturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod AccelZ:Int()\r\n\t\treturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod SetKeyboardEnabled:Int( enabled:int )\r\n\t\tReturn 0\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkChannel\r\n\tField channel:TChannel\t' null then not playing\r\n\tField sample:gxtkSample\r\n\tField loops:int\r\n\t'Field transform:SoundTransform=new SoundTransform()\r\n\t'Field pausepos:Number\r\n\tField state:int\r\n\t\r\n\tMethod New()\r\n\t\tchannel = New TChannel\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkAudio\r\n\tField amusicState:Int = 0\r\n\tField channels:gxtkChannel[] = New gxtkChannel[33]\r\n\tConst MUSIC_CHANNEL:Int = 32\r\n\tField music:gxtkSample\r\n\t\r\n\tMethod New()\r\n\t\tFor local i:Int = 0 To 33 - 1\r\n\t\t\tchannels[i] = New gxtkChannel\r\n\t\t\tchannels[i].channel = AllocChannel()\r\n\t\tNext\r\n\tEndMethod\r\n\t\r\n\tMethod OnSuspend()\r\n\t\tFor Local i:Int = 0 To 33 - 1\r\n\t\t\tLocal chan:gxtkChannel = channels[i]\r\n\t\t\tIf chan.state = 1 Then\r\n\t\t\t\tchan.channel.SetPaused(True)\r\n\t\t\tEndIf\r\n\t\tNext\r\n\tEnd Method\r\n\r\n\tMethod OnResume()\r\n\t\tFor Local i:Int = 0 To 33 - 1\r\n\t\t\tLocal chan:gxtkChannel = channels[i]\r\n\t\t\tIf chan.state = 1 Then\r\n\t\t\t\tchan.channel.SetPaused(False)\r\n\t\t\tEndIf\r\n\t\tNext\r\n\tEnd Method\r\n\t\r\n\tMethod MusicState:Int()\r\n\t\t' Monkey Docs: \t0 if the music is currently stopped\r\n\t\t'\t\t\t\t1 if the music is currently playing\r\n\t\t'\t\t\t\t-1 if the music state cannot be determined\r\n\r\n\t\tLocal chan:gxtkChannel = channels[MUSIC_CHANNEL]\r\n\t\tIf chan.channel <> Null Then\r\n\t\t\tIf ChannelPlaying(chan.channel) Then Return 1 Else Return 0\r\n\t\tEndIf\r\n\t\t\r\n\t\tReturn -1\r\n\tEndMethod\r\n\t\r\n\tMethod PlayMusic:Int( path:String, flags:Int )\r\n\t\tStopMusic()\r\n\t\tmusic = LoadSample( path )\r\n\t\tIf Not music Then Return -1\r\n\t\t\r\n\t\tPlaySample(music, MUSIC_CHANNEL, flags)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod StopMusic:Int()\r\n\t\tStopChannel( MUSIC_CHANNEL )\r\n\t\t\r\n\t\tIf music Then\r\n\t\t\tmusic.Discard()\r\n\t\t\tmusic = null\r\n\t\tEndIf\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod ChannelState:int( channel:int )\r\n\t\t' Monkey Docs: \t0 if the channel is currently stopped\r\n\t\t'\t\t\t\t1 if the channel is currently playing\r\n\t\t'\t\t\t\t2 if the channel is currently paused\r\n\t\t'\t\t\t\t-1 if the channel state cannot be determined\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tIf chan.channel <> Null Then\r\n\t\t\tIf ChannelPlaying(chan.channel) Then Return 1 Else Return 0\r\n\t\tEndIf\r\n\t\t\r\n\t\tReturn -1\r\n\tEndMethod\r\n\t\r\n\tMethod StopChannel( channel:Int )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\t\r\n\t\tIf chan.state <> 0\r\n\t\t\tchan.channel.Stop()\r\n\t\t\tchan.channel=null\r\n\t\t\tchan.sample=null\r\n\t\t\tchan.state=0\r\n\t\tEndIf\r\n\tEndMethod\r\n\t\r\n\tMethod PauseChannel:Int( channel:Int)\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tchan.channel.SetPaused(True)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod ResumeChannel:Int( channel:Int)\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tchan.channel.SetPaused(False)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod PlaySample( sound:gxtkSample, channel:Int, flags:Int )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tIf chan.state <> 0 Then chan.channel.SetPaused(True)\r\n\t\t\r\n\t\tchan.sample = sound\r\n\t\tchan.loops = flags\r\n\t\tchan.state = 1\r\n\t\t\r\n\t\t' if looping, we need to reload the sound with the looping flag\r\n\t\tIf flags <> sound.loop\r\n\t\t\tLocal smp:TSound = LoadSound(sound.path, flags)\r\n\t\t\tsound.setSound(smp)\r\n\t\t\tsound.loop = flags\r\n\t\tEndIf\r\n\t\r\n\t\tPlaySound( sound.sound, chan.channel )\r\n\tEndMethod\r\n\r\n\tMethod SetPan( channel:Int, pan:Float )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tchan.channel.SetPan(pan)\r\n\tEndMethod\r\n\r\n\tMethod SetRate( channel:Int, rate:Float )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tchan.channel.SetRate(rate)\r\n\tEndMethod\r\n\r\n\tMethod PauseMusic:Int()\r\n\t\tLocal chan:gxtkChannel = channels[MUSIC_CHANNEL]\r\n\t\tchan.channel.SetPaused(True)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod ResumeMusic:Int()\r\n\t\tLocal chan:gxtkChannel = channels[MUSIC_CHANNEL]\r\n\t\tchan.channel.SetPaused(False)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod SetMusicVolume:Int( volume:Float )\r\n\t\tSetVolume( MUSIC_CHANNEL, volume )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod SetVolume:Int( channel:Int, volume:Float )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tchan.channel.SetVolume(volume)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod LoadSample:gxtkSample( path:String )\r\n\t\tLocal extension:String = ExtractExt( path)\r\n\t\tIf extension = \"ogg\" Or extension = \"wav\" Then\r\n\t\t\tLocal sound:TSound = LoadSound(\"data\/\"+path)\r\n\t\t\tIf sound Then\r\n\t\t\t\tLocal gs:gxtkSample = New gxtkSample\r\n\t\t\t\tgs.setSound(sound)\r\n\t\t\t\tgs.path = \"data\/\"+path\r\n\t\t\t\tReturn gs\r\n\t\t\tEndIf\r\n\t\tElse\r\n\t\t\tRuntimeError \"BlitzMax can only use ogg and wav file formats\"\r\n\t\tEndIf\r\n\t\tReturn Null\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkSample\r\n\tField sound:TSound\r\n\tField path:String\r\n\tField loop:Int\r\n\t\r\n\tMethod setSound(sound:TSound)\r\n\t\tSelf.sound = sound\r\n\tEndMethod\r\n\t\r\n\tMethod Discard()\r\n\t\tSelf.sound = null\r\n\tEndMethod\r\nEndType\r\n\r\nFunction BlitzMaxDrawPoly:Int(vertices:Float[])\r\n\tDrawPoly vertices\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxDrawRect:Int( x:Float, y:Float, w:Float, h:Float )\r\n\tDrawRect x, y, w, h\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxDrawOval:Int( x:Float, y:Float, w:Float, h:Float )\r\n\tDrawOval x, y, w, h\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxDrawLine:Int( x1:Float,y1:Float,x2:Float,y2:Float )\r\n\tDrawLine x1, y1, x2, y2\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxMillisecs:Int()\r\n\tReturn MilliSecs()\r\nEndFunction\r\n\r\nFunction BlitzMaxSetColor(r:Int, g:Int, b:Int)\r\n\tSetColor(r, g, b)\r\nEndFunction\r\n\r\nFunction BlitzMaxSetBlend(blend:Int)\r\n\tSelect blend\r\n\t\tCase 0\r\n\t\t\tSetBlend( ALPHABLEND )\r\n\t\tCase 1\r\n\t\t\tSetBlend( LIGHTBLEND )\r\n\tEnd Select\r\nEndFunction\r\n\r\nFunction BlitzMaxSetAlpha(a:Float)\r\n\tSetAlpha(a)\r\nEndFunction\r\n\r\nFunction BlitzMaxCls(r:Int = 0, g:Int = 0, b:Int = 0)\r\n\tSetClsColor(r, g, b)\r\n\tCls\r\nEndFunction\r\n\r\nType gxtkSurface\r\n\tField w:Int, h:Int\r\n\tField image:TImage\r\n\t\r\n\tMethod setImage(image:TImage)\r\n\t\tSelf.image = image\r\n\tEndMethod\r\n\t\r\n\tMethod Width:Int()\r\n\t\tReturn image.Width\r\n\tEndMethod\r\n\t\r\n\tMethod Height:Int()\r\n\t\tReturn image.Height\r\n\tEndMethod\r\n\t\r\n\tMethod Discard()\r\n\tEndMethod\r\nEndType\r\n\r\n' ***** End mojo.bmax.bmx ******\r\n\r\n","old_contents":"' ***** Start mojo.bmax.bmx ******\r\n\r\nGlobal app:gxtkApp\r\n\r\nType gxtkApp\r\n\tField ginput:gxtkInput\r\n\tField gaudio:gxtkAudio\r\n\tField ggraphics:gxtkGraphics\r\n\r\n\tField dead:Int=0\r\n\tField suspended:Int=0\r\n\tField vloading:Int=0\r\n\tField maxloading:Int=0\r\n\tField updateRate:Int=0\r\n\tField nextUpdate:Float=0\r\n\tField updatePeriod:Float=0\r\n\tField startMillis:Float=0\r\n\t\r\n\tMethod New()' gxtkApp()\r\n\t\tapp=Self\r\n\t\tggraphics=New gxtkGraphics\r\n\tEndMethod\r\n\t\r\n\tMethod Setup()\r\n\t\tginput=New gxtkInput\r\n\t\tgaudio=New gxtkAudio\r\n\r\n\t\tbb_input__1Set_1Input_1Device(ginput)\r\n\t\tbb_audio__1Set_1Audio_1Device(gaudio)\r\n\t\t\r\n\t\tstartMillis=BlitzMaxMillisecs()\r\n\t\t\r\n\t\tSetFrameRate( 0 )\r\n\t\t\r\n\t\tInvokeOnCreate()\r\n\t\tInvokeOnRender()\r\n\t\tUpdate()\r\n\tEndMethod\r\n\t\r\n\tMethod Update()\r\n\t\tWhile Not AppTerminate()\r\n\t\t\tIf Not updatePeriod return\r\n\t\t\tLocal updates:Int = 0\r\n\t\t\t\r\n\t\t\tRepeat\r\n\t\t\t\tnextUpdate:+updatePeriod\r\n\t\t\t\tInvokeOnUpdate()\r\n\t\t\t\tIf Not updatePeriod Then Exit\r\n\t\t\t\tIf nextUpdate>BlitzMaxMillisecs() Then Exit\r\n\t\t\t\tupdates:+1\r\n\t\t\t\tIf updates = 7 Then\r\n\t\t\t\t\tnextUpdate = BlitzMaxMillisecs()\r\n\t\t\t\t\tExit\r\n\t\t\t\tEndIf\r\n\t\t\tForever\r\n\t\t\tInvokeOnRender()\r\n\t\t\tLocal del:Int = nextUpdate - BlitzMaxMillisecs()\r\n\t\t\tIf del < 1 Then del = 1\r\n\t\t\tDelay(del)\r\n\t\tWend\r\n\tEndMethod\r\n\t\r\n\tMethod InvokeOnCreate()\r\n\t\tIf dead Return\r\n\t\tdead = 1\r\n\t\tOnCreate()\r\n\t\tdead = 0\r\n\tEndMethod\r\n\r\n\tMethod InvokeOnUpdate()\r\n\t\tIf dead Or suspended Or Not updateRate Or vloading Return\r\n\t\tOnUpdate()\r\n\tEndMethod\r\n\t\r\n\tMethod InvokeOnRender()\r\n\t\tIf dead Or suspended Return\r\n\t\tggraphics.BeginRender()\r\n\t\tIf vloading\r\n\t\t\tOnLoading()\r\n\t\tElse\r\n\t\t\tOnRender()\r\n\t\tEndIf\r\n\t\tggraphics.EndRender()\r\n\tEndMethod\r\n\t\r\n\t\r\n\tMethod SetFrameRate( fps:Int )\r\n\t\tIf fps\r\n\t\t\tupdatePeriod=1000.0\/fps\r\n\t\t\tnextUpdate=BlitzMaxMillisecs() +updatePeriod\r\n\t\tElse\r\n\t\t\tupdatePeriod=0\r\n\t\tEndIf\r\n\tEndMethod\r\n\r\n\tMethod LoadState:String()\r\n'\t\tvar file:SharedObject=SharedObject.getLocal( \"gxtkapp\" );\r\n'\t\tvar state:String=file.data.state;\r\n'\t\tfile.close();\r\n'\t\tif( state ) return state;\r\n\t\tReturn \"\"\r\n\tEndMethod\r\n\t\r\n\tMethod SaveState:Int( state:String )\r\n'\t\tvar file:SharedObject=SharedObject.getLocal( \"gxtkapp\" );\r\n'\t\tfile.data.state=state;\r\n'\t\tfile.close();\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod LoadString:String( path:String )\r\n\t\tpath = \"data\/\" + path\r\n\t\tTry\r\n\t\t\tReturn LoadText( path )\r\n\t\tCatch ReadFail:Object\r\n\t\t\tReturn Null\r\n\t\tEndTry\r\n\tEndMethod\r\n\t\r\n\t' ***** GXTK API *****\r\n\t\r\n\tMethod GraphicsDevice:gxtkGraphics()\r\n\t\tReturn ggraphics\r\n\tEndMethod\r\n\r\n\tMethod InputDevice:gxtkInput()\r\n\t\tReturn ginput\r\n\tEndMethod\r\n\r\n\tMethod AudioDevice:gxtkAudio()\r\n\t\tReturn gaudio\r\n\tEndMethod\r\n\r\n\tMethod SetUpdateRate:Int(hertz:Int)\r\n\t\tupdateRate = hertz\r\n\t\tIf Not vloading Then SetFrameRate(updateRate)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod MilliSecs:Int()\r\n\t\tReturn BlitzMaxMillisecs() - startMillis\r\n\tEndMethod\r\n\t\r\n\tMethod Loading:Int()\r\n\t\tReturn vloading\r\n\tEndMethod\r\n\r\n\tMethod OnCreate:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod OnUpdate:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod OnSuspend:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod OnResume:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod OnRender:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod OnLoading:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkGraphics\r\n\tField gmode:Int = 1\r\n\tField ix:Float=1,iy:Float,jx:Float,jy:Float=1,tx:Float,ty:Float\r\n\tField sx:Float=1,sy:Float=1,rot:Float=0\r\n\t\r\n\tMethod Mode:Int()\r\n\t\tReturn gmode\r\n\tEndMethod\r\n\t\r\n\tMethod Cls:Int(r:Int = 0, g:Int = 0, b:Int = 0)\r\n\t\tBlitzMaxCls(r, g, b)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawPoint:Int(x:Float, y:Float)\r\n\t\tLocal nx:Float = TransX(x,y)\r\n\t\tLocal ny:Float = TransY(x,y)\r\n\t\tPlot nx, ny\r\n\tEndMethod\r\n\t\r\n\tMethod LoadSurface:gxtkSurface(path:String)\r\n\t\tLocal image:TImage = LoadImage(\"data\/\"+path)\r\n\t\tIf image Then\r\n\t\t\tLocal gs:gxtkSurface = New gxtkSurface\r\n\t\t\tgs.setImage(image)\r\n\t\t\tReturn gs\r\n\t\tEndIf\r\n\t\tReturn Null\r\n\tEndMethod\r\n\t\r\n\tMethod BeginRender()\r\n\tEndMethod\r\n\t\r\n\tMethod EndRender()\r\n\t\tFlip\r\n\tEndMethod\r\n\t\r\n\tMethod SetColor:Int(r:Int, g:Int, b:Int)\r\n\t\tBlitzMaxSetColor(r, g, b)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod SetAlpha:Int(a:Float)\r\n\t\tBlitzMaxSetAlpha(a)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod SetBlend:Int(blend:Int)\r\n\t\tBlitzMaxSetBlend(blend)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod Width:Int()\r\n\t\tReturn GraphicsWidth()\r\n\tEndMethod\r\n\t\r\n\tMethod Height:Int()\r\n\t\tReturn GraphicsHeight()\r\n\tEndMethod\r\n\t\r\n\tMethod SetScissor:Int(x:Int, y:Int, w:Int, h:Int)\r\n\t\tSetViewport(x, y, w, h) ' NOT TESTED!\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod TransX:Float(x:Float, y:Float)\r\n\t\tReturn ix*x + jx*y + tx\r\n\tEndMethod\r\n\t\r\n\tMethod TransY:Float(x:Float, y:Float)\r\n\t\tReturn iy*x + jy*y + ty\r\n\tEndMethod\r\n\t\r\n\tMethod SetMatrix:Int(ix:Float,iy:Float,jx:Float,jy:Float,tx:Float,ty:Float)\r\n\t\tSelf.ix = ix ; Self.iy = iy\r\n\t\tSelf.jx = jx ; Self.jy = jy\r\n\t\tSelf.tx = tx ; Self.ty = ty\r\n\t\tsx = Sqr(ix*ix+iy*iy)\r\n\t\tsy = Sqr(jx*jx+jy*jy)\r\n\t\trot = Atan2( iy, ix )\r\n\t\tIf ix < 0 Then\r\n\t\t\tsx = -sx\r\n\t\t\trot :+ 180\r\n\t\tEndIf\r\n\t\tIf jy < 0 Then sy = -sy\r\n\t\tSetTransform( rot, sx, sy )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawSurface:Int(surface:gxtkSurface,x:Float,y:Float)\r\n\t\tLocal nx:Float = TransX(x,y)\r\n\t\tLocal ny:Float = TransY(x,y)\r\n\t\tDrawImage(surface.image, nx, ny, 0)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawSurface2:Int(surface:gxtkSurface,x:Float,y:Float, srcx:Int, srcy:Int, srcw:Int, srch:Int )\r\n\t\tLocal nx:Float = TransX(x,y)\r\n\t\tLocal ny:Float = TransY(x,y)\r\n\t\tDrawSubImageRect(surface.image, nx, ny, srcw, srch, srcx, srcy, srcw, srch)\t\t\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawLine:Int( x1:Float,y1:Float,x2:Float,y2:Float )\r\n\t\tLocal nx1:Float = TransX(x1,y1)\r\n\t\tLocal ny1:Float = TransY(x1,y1)\r\n\t\tLocal nx2:Float = TransX(x2,y2)\r\n\t\tLocal ny2:Float = TransY(x2,y2)\r\n\t\t' Need to reset transform so that BlitzMax doesn't try to apply rotation\r\n\t\tSetTransform( 0, 1, 1 )\r\n\t\tBlitzMaxDrawLine(nx1, ny1, nx2, ny2)\r\n\t\tSetTransform( rot, sx, sy )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawOval:Int( x:Float, y:Float, w:Float, h:Float )\r\n\t\tLocal nx:Float = TransX(x,y)\r\n\t\tLocal ny:Float = TransY(x,y)\r\n\t\tBlitzMaxDrawOval(nx, ny, w, h)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawPoly:Int(vertices:Float[])\r\n\t\t' setting the origin to use the current rotation translation\r\n\t\tSetOrigin(TransX(0,0), TransY(0,0))\r\n\t\tBlitzMaxDrawPoly( vertices )\r\n\t\tSetOrigin(0, 0)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawRect:Int( x:Float, y:Float, w:Float, h:Float )\r\n\t\tLocal nx:Float = TransX(x,y)\r\n\t\tLocal ny:Float = TransY(x,y)\r\n\t\tBlitzMaxDrawRect(nx, ny, w, h)\r\n\t\tReturn 0\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkInput\r\n\tMethod MouseX:Float()\r\n\t\tReturn BRL.PolledInput.MouseX()\r\n\tEndMethod\r\n\r\n\tMethod MouseY:Float()\r\n\t\tReturn BRL.PolledInput.MouseY()\r\n\tEndMethod\r\n\t\r\n\tMethod KeyDown:Int( key:Int )\r\n\t\tif( key = 384 ) key = 1 ' change TOUCH0 to MOUSE_LMB\r\n\r\n\t\tIf( key >= 1 And key <= 3 )\r\n\t\t\tReturn BRL.PolledInput.MouseDown( key )\r\n\t\tEndIf\r\n\t\tIf key < 256\r\n\t\t\tReturn BRL.PolledInput.KeyDown( key )\r\n\t\tElse\r\n\t\t\tReturn 0\r\n\t\tEndIf\r\n\tEndMethod\r\n\r\n\tMethod KeyHit:Int( key:Int )\r\n\t\tif( key = 384 ) key = 1 ' change TOUCH0 to MOUSE_LMB\r\n\t\tIf( key >= 1 And key <= 3 )\r\n\t\t\tReturn BRL.PolledInput.MouseHit( key )\r\n\t\tEndIf\r\n\t\tIf key < 256\r\n\t\t\tReturn BRL.PolledInput.KeyHit( key )\r\n\t\tElse\r\n\t\t\tReturn 0\r\n\t\tEndIf\r\n\tEndMethod\r\n\r\n\tMethod GetChar:Int()\r\n\t\tReturn BRL.PolledInput.GetChar()\r\n\tEndMethod\r\n\r\n\tMethod JoyX:Int( index:Int )\r\n\t\tReturn Pub.FreeJoy.JoyX( index )\r\n\tEndMethod\r\n\r\n\tMethod JoyY:Int( index:Int )\r\n\t\tReturn Pub.FreeJoy.JoyY( index )\r\n\tEndMethod\r\n\r\n\tMethod JoyZ:Int( index:Int )\r\n\t\tReturn Pub.FreeJoy.JoyZ( index )\r\n\tEndMethod\r\n\r\n\tMethod TouchX:Float( index:Int )\r\n\t\tReturn BRL.PolledInput.MouseX()\r\n\tEndMethod\r\n\r\n\tMethod TouchY:Float( index:Int )\r\n\t\tReturn BRL.PolledInput.MouseY()\r\n\tEndMethod\r\n\t\r\n\tMethod AccelX:Int()\r\n\t\treturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod AccelY:Int()\r\n\t\treturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod AccelZ:Int()\r\n\t\treturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod SetKeyboardEnabled:Int( enabled:int )\r\n\t\tReturn 0\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkChannel\r\n\tField channel:TChannel\t' null then not playing\r\n\tField sample:gxtkSample\r\n\tField loops:int\r\n\t'Field transform:SoundTransform=new SoundTransform()\r\n\t'Field pausepos:Number\r\n\tField state:int\r\n\t\r\n\tMethod New()\r\n\t\tchannel = New TChannel\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkAudio\r\n\tField amusicState:Int = 0\r\n\tField channels:gxtkChannel[] = New gxtkChannel[33]\r\n\tConst MUSIC_CHANNEL:Int = 32\r\n\tField music:gxtkSample\r\n\t\r\n\tMethod New()\r\n\t\tFor local i:Int = 0 To 33 - 1\r\n\t\t\tchannels[i] = New gxtkChannel\r\n\t\t\tchannels[i].channel = AllocChannel()\r\n\t\tNext\r\n\tEndMethod\r\n\t\r\n\tMethod MusicState:Int()\r\n\t\t' Monkey Docs: \t0 if the music is currently stopped\r\n\t\t'\t\t\t\t1 if the music is currently playing\r\n\t\t'\t\t\t\t-1 if the music state cannot be determined\r\n\r\n\t\tLocal chan:gxtkChannel = channels[MUSIC_CHANNEL]\r\n\t\tIf chan.channel <> Null Then\r\n\t\t\tIf ChannelPlaying(chan.channel) Then Return 1 Else Return 0\r\n\t\tEndIf\r\n\t\t\r\n\t\tReturn -1\r\n\tEndMethod\r\n\t\r\n\tMethod PlayMusic:Int( path:String, flags:Int )\r\n\t\tStopMusic()\r\n\t\tmusic = LoadSample( path )\r\n\t\tIf Not music Then Return -1\r\n\t\t\r\n\t\tPlaySample(music, MUSIC_CHANNEL, flags)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod StopMusic:Int()\r\n\t\tStopChannel( MUSIC_CHANNEL )\r\n\t\t\r\n\t\tIf music Then\r\n\t\t\tmusic.Discard()\r\n\t\t\tmusic = null\r\n\t\tEndIf\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod ChannelState:int( channel:int )\r\n\t\t' Monkey Docs: \t0 if the channel is currently stopped\r\n\t\t'\t\t\t\t1 if the channel is currently playing\r\n\t\t'\t\t\t\t2 if the channel is currently paused\r\n\t\t'\t\t\t\t-1 if the channel state cannot be determined\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tIf chan.channel <> Null Then\r\n\t\t\tIf ChannelPlaying(chan.channel) Then Return 1 Else Return 0\r\n\t\tEndIf\r\n\t\t\r\n\t\tReturn -1\r\n\tEndMethod\r\n\t\r\n\tMethod StopChannel( channel:Int )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\t\r\n\t\tIf chan.state <> 0\r\n\t\t\tchan.channel.Stop()\r\n\t\t\tchan.channel=null\r\n\t\t\tchan.sample=null\r\n\t\t\tchan.state=0\r\n\t\tEndIf\r\n\tEndMethod\r\n\t\r\n\tMethod PauseChannel:Int( channel:Int)\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tchan.channel.SetPaused(True)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod ResumeChannel:Int( channel:Int)\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tchan.channel.SetPaused(False)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod PlaySample( sound:gxtkSample, channel:Int, flags:Int )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tIf chan.state <> 0 Then chan.channel.SetPaused(True)\r\n\t\t\r\n\t\tchan.sample = sound\r\n\t\tchan.loops = flags\r\n\t\tchan.state = 1\r\n\t\t\r\n\t\t' if looping, we need to reload the sound with the looping flag\r\n\t\tIf flags <> sound.loop\r\n\t\t\tLocal smp:TSound = LoadSound(sound.path, flags)\r\n\t\t\tsound.setSound(smp)\r\n\t\t\tsound.loop = flags\r\n\t\tEndIf\r\n\t\r\n\t\tPlaySound( sound.sound, chan.channel )\r\n\tEndMethod\r\n\r\n\tMethod SetPan( channel:Int, pan:Float )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tchan.channel.SetPan(pan)\r\n\tEndMethod\r\n\r\n\tMethod SetRate( channel:Int, rate:Float )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tchan.channel.SetRate(rate)\r\n\tEndMethod\r\n\r\n\tMethod PauseMusic:Int()\r\n\t\tLocal chan:gxtkChannel = channels[MUSIC_CHANNEL]\r\n\t\tchan.channel.SetPaused(True)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod ResumeMusic:Int()\r\n\t\tLocal chan:gxtkChannel = channels[MUSIC_CHANNEL]\r\n\t\tchan.channel.SetPaused(False)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod SetMusicVolume:Int( volume:Float )\r\n\t\tSetVolume( MUSIC_CHANNEL, volume )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod SetVolume:Int( channel:Int, volume:Float )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tchan.channel.SetVolume(volume)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod LoadSample:gxtkSample( path:String )\r\n\t\tLocal extension:String = ExtractExt( path)\r\n\t\tIf extension = \"ogg\" Or extension = \"wav\" Then\r\n\t\t\tLocal sound:TSound = LoadSound(\"data\/\"+path)\r\n\t\t\tIf sound Then\r\n\t\t\t\tLocal gs:gxtkSample = New gxtkSample\r\n\t\t\t\tgs.setSound(sound)\r\n\t\t\t\tgs.path = \"data\/\"+path\r\n\t\t\t\tReturn gs\r\n\t\t\tEndIf\r\n\t\tElse\r\n\t\t\tRuntimeError \"BlitzMax can only use ogg and wav file formats\"\r\n\t\tEndIf\r\n\t\tReturn Null\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkSample\r\n\tField sound:TSound\r\n\tField path:String\r\n\tField loop:Int\r\n\t\r\n\tMethod setSound(sound:TSound)\r\n\t\tSelf.sound = sound\r\n\tEndMethod\r\n\t\r\n\tMethod Discard()\r\n\t\tSelf.sound = null\r\n\tEndMethod\r\nEndType\r\n\r\nFunction BlitzMaxDrawPoly:Int(vertices:Float[])\r\n\tDrawPoly vertices\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxDrawRect:Int( x:Float, y:Float, w:Float, h:Float )\r\n\tDrawRect x, y, w, h\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxDrawOval:Int( x:Float, y:Float, w:Float, h:Float )\r\n\tDrawOval x, y, w, h\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxDrawLine:Int( x1:Float,y1:Float,x2:Float,y2:Float )\r\n\tDrawLine x1, y1, x2, y2\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxMillisecs:Int()\r\n\tReturn MilliSecs()\r\nEndFunction\r\n\r\nFunction BlitzMaxSetColor(r:Int, g:Int, b:Int)\r\n\tSetColor(r, g, b)\r\nEndFunction\r\n\r\nFunction BlitzMaxSetBlend(blend:Int)\r\n\tSelect blend\r\n\t\tCase 0\r\n\t\t\tSetBlend( ALPHABLEND )\r\n\t\tCase 1\r\n\t\t\tSetBlend( LIGHTBLEND )\r\n\tEnd Select\r\nEndFunction\r\n\r\nFunction BlitzMaxSetAlpha(a:Float)\r\n\tSetAlpha(a)\r\nEndFunction\r\n\r\nFunction BlitzMaxCls(r:Int = 0, g:Int = 0, b:Int = 0)\r\n\tSetClsColor(r, g, b)\r\n\tCls\r\nEndFunction\r\n\r\nType gxtkSurface\r\n\tField w:Int, h:Int\r\n\tField image:TImage\r\n\t\r\n\tMethod setImage(image:TImage)\r\n\t\tSelf.image = image\r\n\tEndMethod\r\n\t\r\n\tMethod Width:Int()\r\n\t\tReturn image.Width\r\n\tEndMethod\r\n\t\r\n\tMethod Height:Int()\r\n\t\tReturn image.Height\r\n\tEndMethod\r\n\t\r\n\tMethod Discard()\r\n\tEndMethod\r\nEndType\r\n\r\n' ***** End mojo.bmax.bmx ******\r\n\r\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"b9ee756806728ab1f4e6b6b2db02558ed4c91e37","subject":"Wrapped LoadText with a Try\/Catch to return Null","message":"Wrapped LoadText with a Try\/Catch to return Null\n\n--HG--\nextra : convert_revision : svn%3Ae934d3cd-0d57-f34a-94d0-9e8d31ae1c29\/trunk%40395\n","repos":"programmerby\/diddy-mirror,programmerby\/diddy-mirror,programmerby\/diddy-mirror,programmerby\/diddy-mirror","old_file":"monkeymax\/modules\/mojo\/native\/mojo.bmax.bmx","new_file":"monkeymax\/modules\/mojo\/native\/mojo.bmax.bmx","new_contents":"' ***** Start mojo.bmax.bmx ******\r\n\r\nGlobal app:gxtkApp\r\n\r\nType gxtkApp\r\n\tField ginput:gxtkInput\r\n\tField gaudio:gxtkAudio\r\n\tField ggraphics:gxtkGraphics\r\n\r\n\tField dead:Int=0\r\n\tField suspended:Int=0\r\n\tField vloading:Int=0\r\n\tField maxloading:Int=0\r\n\tField updateRate:Int=0\r\n\tField nextUpdate:Float=0\r\n\tField updatePeriod:Float=0\r\n\tField startMillis:Float=0\r\n\t\r\n\tMethod New()' gxtkApp()\r\n\t\tapp=Self\r\n\t\tggraphics=New gxtkGraphics\r\n\tEndMethod\r\n\t\r\n\tMethod Setup()\r\n\t\tginput=New gxtkInput\r\n\t\tgaudio=New gxtkAudio\r\n\r\n\t\tbb_input__1Set_1Input_1Device(ginput)\r\n\t\tbb_audio__1Set_1Audio_1Device(gaudio)\r\n\t\t\r\n\t\tstartMillis=BlitzMaxMillisecs()\r\n\t\t\r\n\t\tSetFrameRate( 0 )\r\n\t\t\r\n\t\tInvokeOnCreate()\r\n\t\tInvokeOnRender()\r\n\t\tUpdate()\r\n\tEndMethod\r\n\t\r\n\tMethod Update()\r\n\t\tWhile Not AppTerminate()\r\n\t\t\tIf Not updatePeriod return\r\n\t\t\tLocal updates:Int = 0\r\n\t\t\t\r\n\t\t\tRepeat\r\n\t\t\t\tnextUpdate:+updatePeriod\r\n\t\t\t\tInvokeOnUpdate()\r\n\t\t\t\tIf Not updatePeriod Then Exit\r\n\t\t\t\tIf nextUpdate>BlitzMaxMillisecs() Then Exit\r\n\t\t\t\tupdates:+1\r\n\t\t\t\tIf updates = 7 Then\r\n\t\t\t\t\tnextUpdate = BlitzMaxMillisecs()\r\n\t\t\t\t\tExit\r\n\t\t\t\tEndIf\r\n\t\t\tForever\r\n\t\t\tInvokeOnRender()\r\n\t\t\tLocal del:Int = nextUpdate - BlitzMaxMillisecs()\r\n\t\t\tIf del < 1 Then del = 1\r\n\t\t\tDelay(del)\r\n\t\tWend\r\n\tEndMethod\r\n\t\r\n\tMethod InvokeOnCreate()\r\n\t\tIf dead Return\r\n\t\tdead = 1\r\n\t\tOnCreate()\r\n\t\tdead = 0\r\n\tEndMethod\r\n\r\n\tMethod InvokeOnUpdate()\r\n\t\tIf dead Or suspended Or Not updateRate Or vloading Return\r\n\t\tOnUpdate()\r\n\tEndMethod\r\n\t\r\n\tMethod InvokeOnRender()\r\n\t\tIf dead Or suspended Return\r\n\t\tggraphics.BeginRender()\r\n\t\tIf vloading\r\n\t\t\tOnLoading()\r\n\t\tElse\r\n\t\t\tOnRender()\r\n\t\tEndIf\r\n\t\tggraphics.EndRender()\r\n\tEndMethod\r\n\t\r\n\t\r\n\tMethod SetFrameRate( fps:Int )\r\n\t\tIf fps\r\n\t\t\tupdatePeriod=1000.0\/fps\r\n\t\t\tnextUpdate=BlitzMaxMillisecs() +updatePeriod\r\n\t\tElse\r\n\t\t\tupdatePeriod=0\r\n\t\tEndIf\r\n\tEndMethod\r\n\r\n\tMethod LoadState:String()\r\n'\t\tvar file:SharedObject=SharedObject.getLocal( \"gxtkapp\" );\r\n'\t\tvar state:String=file.data.state;\r\n'\t\tfile.close();\r\n'\t\tif( state ) return state;\r\n\t\tReturn \"\"\r\n\tEndMethod\r\n\t\r\n\tMethod SaveState:Int( state:String )\r\n'\t\tvar file:SharedObject=SharedObject.getLocal( \"gxtkapp\" );\r\n'\t\tfile.data.state=state;\r\n'\t\tfile.close();\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod LoadString:String( path:String )\r\n\t\tpath = \"data\/\" + path\r\n\t\tTry\r\n\t\t\tReturn LoadText( path )\r\n\t\tCatch ReadFail:Object\r\n\t\t\tReturn Null\r\n\t\tEndTry\r\n\tEndMethod\r\n\t\r\n\t' ***** GXTK API *****\r\n\t\r\n\tMethod GraphicsDevice:gxtkGraphics()\r\n\t\tReturn ggraphics\r\n\tEndMethod\r\n\r\n\tMethod InputDevice:gxtkInput()\r\n\t\tReturn ginput\r\n\tEndMethod\r\n\r\n\tMethod AudioDevice:gxtkAudio()\r\n\t\tReturn gaudio\r\n\tEndMethod\r\n\r\n\tMethod SetUpdateRate:Int(hertz:Int)\r\n\t\tupdateRate = hertz\r\n\t\tIf Not vloading Then SetFrameRate(updateRate)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod MilliSecs:Int()\r\n\t\tReturn BlitzMaxMillisecs() - startMillis\r\n\tEndMethod\r\n\t\r\n\tMethod Loading:Int()\r\n\t\tReturn vloading\r\n\tEndMethod\r\n\r\n\tMethod OnCreate:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod OnUpdate:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod OnSuspend:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod OnResume:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod OnRender:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod OnLoading:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkGraphics\r\n\tField gmode:Int = 1\r\n\tField ix:Float=1,iy:Float,jx:Float,jy:Float=1,tx:Float,ty:Float\r\n\tField sx:Float=1,sy:Float=1,rot:Float=0\r\n\t\r\n\tMethod Mode:Int()\r\n\t\tReturn gmode\r\n\tEndMethod\r\n\t\r\n\tMethod Cls:Int(r:Int = 0, g:Int = 0, b:Int = 0)\r\n\t\tBlitzMaxCls(r, g, b)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawPoint:Int(x:Float, y:Float)\r\n\t\tLocal nx:Float = TransX(x,y)\r\n\t\tLocal ny:Float = TransY(x,y)\r\n\t\tPlot nx, ny\r\n\tEndMethod\r\n\t\r\n\tMethod LoadSurface:gxtkSurface(path:String)\r\n\t\tLocal image:TImage = LoadImage(\"data\/\"+path)\r\n\t\tIf image Then\r\n\t\t\tLocal gs:gxtkSurface = New gxtkSurface\r\n\t\t\tgs.setImage(image)\r\n\t\t\tReturn gs\r\n\t\tEndIf\r\n\t\tReturn Null\r\n\tEndMethod\r\n\t\r\n\tMethod BeginRender()\r\n\tEndMethod\r\n\t\r\n\tMethod EndRender()\r\n\t\tFlip\r\n\tEndMethod\r\n\t\r\n\tMethod SetColor:Int(r:Int, g:Int, b:Int)\r\n\t\tBlitzMaxSetColor(r, g, b)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod SetAlpha:Int(a:Float)\r\n\t\tBlitzMaxSetAlpha(a)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod SetBlend:Int(blend:Int)\r\n\t\tBlitzMaxSetBlend(blend)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod Width:Int()\r\n\t\tReturn GraphicsWidth()\r\n\tEndMethod\r\n\t\r\n\tMethod Height:Int()\r\n\t\tReturn GraphicsHeight()\r\n\tEndMethod\r\n\t\r\n\tMethod SetScissor:Int(x:Int, y:Int, w:Int, h:Int)\r\n\t\tSetViewport(x, y, w, h) ' NOT TESTED!\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod TransX:Float(x:Float, y:Float)\r\n\t\tReturn ix*x + jx*y + tx\r\n\tEndMethod\r\n\t\r\n\tMethod TransY:Float(x:Float, y:Float)\r\n\t\tReturn iy*x + jy*y + ty\r\n\tEndMethod\r\n\t\r\n\tMethod SetMatrix:Int(ix:Float,iy:Float,jx:Float,jy:Float,tx:Float,ty:Float)\r\n\t\tSelf.ix = ix ; Self.iy = iy\r\n\t\tSelf.jx = jx ; Self.jy = jy\r\n\t\tSelf.tx = tx ; Self.ty = ty\r\n\t\tsx = Sqr(ix*ix+iy*iy)\r\n\t\tsy = Sqr(jx*jx+jy*jy)\r\n\t\trot = Atan2( iy, ix )\r\n\t\tIf ix < 0 Then\r\n\t\t\tsx = -sx\r\n\t\t\trot :+ 180\r\n\t\tEndIf\r\n\t\tIf jy < 0 Then sy = -sy\r\n\t\tSetTransform( rot, sx, sy )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawSurface:Int(surface:gxtkSurface,x:Float,y:Float)\r\n\t\tLocal nx:Float = TransX(x,y)\r\n\t\tLocal ny:Float = TransY(x,y)\r\n\t\tDrawImage(surface.image, nx, ny, 0)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawSurface2:Int(surface:gxtkSurface,x:Float,y:Float, srcx:Int, srcy:Int, srcw:Int, srch:Int )\r\n\t\tLocal nx:Float = TransX(x,y)\r\n\t\tLocal ny:Float = TransY(x,y)\r\n\t\tDrawSubImageRect(surface.image, nx, ny, srcw, srch, srcx, srcy, srcw, srch)\t\t\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawLine:Int( x1:Float,y1:Float,x2:Float,y2:Float )\r\n\t\tLocal nx1:Float = TransX(x1,y1)\r\n\t\tLocal ny1:Float = TransY(x1,y1)\r\n\t\tLocal nx2:Float = TransX(x2,y2)\r\n\t\tLocal ny2:Float = TransY(x2,y2)\r\n\t\t' Need to reset transform so that BlitzMax doesn't try to apply rotation\r\n\t\tSetTransform( 0, 1, 1 )\r\n\t\tBlitzMaxDrawLine(nx1, ny1, nx2, ny2)\r\n\t\tSetTransform( rot, sx, sy )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawOval:Int( x:Float, y:Float, w:Float, h:Float )\r\n\t\tLocal nx:Float = TransX(x,y)\r\n\t\tLocal ny:Float = TransY(x,y)\r\n\t\tBlitzMaxDrawOval(nx, ny, w, h)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawPoly:Int(vertices:Float[])\r\n\t\t' setting the origin to use the current rotation translation\r\n\t\tSetOrigin(TransX(0,0), TransY(0,0))\r\n\t\tBlitzMaxDrawPoly( vertices )\r\n\t\tSetOrigin(0, 0)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawRect:Int( x:Float, y:Float, w:Float, h:Float )\r\n\t\tLocal nx:Float = TransX(x,y)\r\n\t\tLocal ny:Float = TransY(x,y)\r\n\t\tBlitzMaxDrawRect(nx, ny, w, h)\r\n\t\tReturn 0\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkInput\r\n\tMethod MouseX:Float()\r\n\t\tReturn BRL.PolledInput.MouseX()\r\n\tEndMethod\r\n\r\n\tMethod MouseY:Float()\r\n\t\tReturn BRL.PolledInput.MouseY()\r\n\tEndMethod\r\n\t\r\n\tMethod KeyDown:Int( key:Int )\r\n\t\tif( key = 384 ) key = 1 ' change TOUCH0 to MOUSE_LMB\r\n\r\n\t\tIf( key >= 1 And key <= 3 )\r\n\t\t\tReturn BRL.PolledInput.MouseDown( key )\r\n\t\tEndIf\r\n\t\tIf key < 256\r\n\t\t\tReturn BRL.PolledInput.KeyDown( key )\r\n\t\tElse\r\n\t\t\tReturn 0\r\n\t\tEndIf\r\n\tEndMethod\r\n\r\n\tMethod KeyHit:Int( key:Int )\r\n\t\tif( key = 384 ) key = 1 ' change TOUCH0 to MOUSE_LMB\r\n\t\tIf( key >= 1 And key <= 3 )\r\n\t\t\tReturn BRL.PolledInput.MouseHit( key )\r\n\t\tEndIf\r\n\t\tIf key < 256\r\n\t\t\tReturn BRL.PolledInput.KeyHit( key )\r\n\t\tElse\r\n\t\t\tReturn 0\r\n\t\tEndIf\r\n\tEndMethod\r\n\r\n\tMethod GetChar:Int()\r\n\t\tReturn BRL.PolledInput.GetChar()\r\n\tEndMethod\r\n\r\n\tMethod JoyX:Int( index:Int )\r\n\t\tReturn Pub.FreeJoy.JoyX( index )\r\n\tEndMethod\r\n\r\n\tMethod JoyY:Int( index:Int )\r\n\t\tReturn Pub.FreeJoy.JoyY( index )\r\n\tEndMethod\r\n\r\n\tMethod JoyZ:Int( index:Int )\r\n\t\tReturn Pub.FreeJoy.JoyZ( index )\r\n\tEndMethod\r\n\r\n\tMethod TouchX:Float( index:Int )\r\n\t\tReturn BRL.PolledInput.MouseX()\r\n\tEndMethod\r\n\r\n\tMethod TouchY:Float( index:Int )\r\n\t\tReturn BRL.PolledInput.MouseY()\r\n\tEndMethod\r\n\t\r\n\tMethod AccelX:Int()\r\n\t\treturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod AccelY:Int()\r\n\t\treturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod AccelZ:Int()\r\n\t\treturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod SetKeyboardEnabled:Int( enabled:int )\r\n\t\tReturn 0\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkChannel\r\n\tField channel:TChannel\t' null then not playing\r\n\tField sample:gxtkSample\r\n\tField loops:int\r\n\t'Field transform:SoundTransform=new SoundTransform()\r\n\t'Field pausepos:Number\r\n\tField state:int\r\n\t\r\n\tMethod New()\r\n\t\tchannel = New TChannel\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkAudio\r\n\tField amusicState:Int = 0\r\n\tField channels:gxtkChannel[] = New gxtkChannel[33]\r\n\t\r\n\tMethod New()\r\n\t\tFor local i:Int = 0 To 33 - 1\r\n\t\t\tchannels[i] = New gxtkChannel\r\n\t\tNext\r\n\tEndMethod\r\n\t\r\n\tMethod MusicState:Int()\r\n'\t\tIf( musicState = 1 And music.isPlaying() = False )\r\n'\t\t\tmusicState = 0;\r\n'\t\tEndif\r\n\t\tReturn amusicState\r\n\tEndMethod\r\n\t\r\n\tMethod PlayMusic:Int( path:String, flags:Int )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod ChannelState:int( channel:int )\r\n\t\tReturn -1\r\n\tEndMethod\r\n\t\r\n\tMethod StopMusic()\r\n\tEndMethod\r\n\t\r\n\tMethod StopChannel( channel:Int )\r\n\tEndMethod\r\n\r\n\tMethod PlaySample( sound:gxtkSample, channel:Int, flags:Int )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\t\r\n\t\t'If chan.state <> 0 Then chan.channel.Stop() <-- this crashes after the first play!?\r\n\t\t\r\n\t\tchan.sample = sound\r\n\t\t'chan.loops = flags ? 0x7fffffff : 0;\r\n\t\t'chan.channel = sample.sound.play( 0,chan.loops,chan.transform );\r\n\t\t'chan.channel = sound\r\n\t\tchan.state=1\r\n\t\r\n\t\tPlaySound( sound.sound, chan.channel )\r\n\tEndMethod\r\n\r\n\tMethod SetPan( channel:Int, pan:Float )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tchan.channel.SetPan(pan)\r\n\tEndMethod\r\n\r\n\tMethod SetRate( channel:Int, rate:Float )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tchan.channel.SetRate(rate)\r\n\tEndMethod\r\n\r\n\tMethod PauseMusic:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod ResumeMusic:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod SetMusicVolume:Int( volume:Float )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod SetVolume:Int( channel:Int, volume:Float )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tchan.channel.SetVolume(volume)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod LoadSample:gxtkSample( path:String )\r\n\t\tLocal extension:String = ExtractExt( path)\r\n\t\tIf extension = \"ogg\" Or extension = \"wav\" Then\r\n\t\t\tLocal sound:TSound = LoadSound(\"data\/\"+path)\r\n\t\t\tIf sound Then\r\n\t\t\t\tLocal gs:gxtkSample = New gxtkSample\r\n\t\t\t\tgs.setSound(sound)\r\n\t\t\t\tReturn gs\r\n\t\t\tEndIf\r\n\t\tElse\r\n\t\t\tRuntimeError \"BlitzMax can only use ogg and wav file formats\"\r\n\t\tEndIf\r\n\t\tReturn Null\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkSample\r\n\tField sound:TSound\r\n\t\r\n\tMethod setSound(sound:TSound)\r\n\t\tSelf.sound = sound\r\n\tEndMethod\r\n\t\r\n\tMethod Discard()\r\n\t\tSelf.sound = null\r\n\tEndMethod\r\nEndType\r\n\r\nFunction BlitzMaxDrawPoly:Int(vertices:Float[])\r\n\tDrawPoly vertices\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxDrawRect:Int( x:Float, y:Float, w:Float, h:Float )\r\n\tDrawRect x, y, w, h\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxDrawOval:Int( x:Float, y:Float, w:Float, h:Float )\r\n\tDrawOval x, y, w, h\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxDrawLine:Int( x1:Float,y1:Float,x2:Float,y2:Float )\r\n\tDrawLine x1, y1, x2, y2\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxMillisecs:Int()\r\n\tReturn MilliSecs()\r\nEndFunction\r\n\r\nFunction BlitzMaxSetColor(r:Int, g:Int, b:Int)\r\n\tSetColor(r, g, b)\r\nEndFunction\r\n\r\nFunction BlitzMaxSetBlend(blend:Int)\r\n\tSelect blend\r\n\t\tCase 0\r\n\t\t\tSetBlend( ALPHABLEND )\r\n\t\tCase 1\r\n\t\t\tSetBlend( LIGHTBLEND )\r\n\tEnd Select\r\nEndFunction\r\n\r\nFunction BlitzMaxSetAlpha(a:Float)\r\n\tSetAlpha(a)\r\nEndFunction\r\n\r\nFunction BlitzMaxCls(r:Int = 0, g:Int = 0, b:Int = 0)\r\n\tSetClsColor(r, g, b)\r\n\tCls\r\nEndFunction\r\n\r\nType gxtkSurface\r\n\tField w:Int, h:Int\r\n\tField image:TImage\r\n\t\r\n\tMethod setImage(image:TImage)\r\n\t\tSelf.image = image\r\n\tEndMethod\r\n\t\r\n\tMethod Width:Int()\r\n\t\tReturn image.Width\r\n\tEndMethod\r\n\t\r\n\tMethod Height:Int()\r\n\t\tReturn image.Height\r\n\tEndMethod\r\n\t\r\n\tMethod Discard()\r\n\tEndMethod\r\nEndType\r\n\r\n' ***** End mojo.bmax.bmx ******\r\n\r\n","old_contents":"' ***** Start mojo.bmax.bmx ******\r\n\r\nGlobal app:gxtkApp\r\n\r\nType gxtkApp\r\n\tField ginput:gxtkInput\r\n\tField gaudio:gxtkAudio\r\n\tField ggraphics:gxtkGraphics\r\n\r\n\tField dead:Int=0\r\n\tField suspended:Int=0\r\n\tField vloading:Int=0\r\n\tField maxloading:Int=0\r\n\tField updateRate:Int=0\r\n\tField nextUpdate:Float=0\r\n\tField updatePeriod:Float=0\r\n\tField startMillis:Float=0\r\n\t\r\n\tMethod New()' gxtkApp()\r\n\t\tapp=Self\r\n\t\tggraphics=New gxtkGraphics\r\n\tEndMethod\r\n\t\r\n\tMethod Setup()\r\n\t\tginput=New gxtkInput\r\n\t\tgaudio=New gxtkAudio\r\n\r\n\t\tbb_input__1Set_1Input_1Device(ginput)\r\n\t\tbb_audio__1Set_1Audio_1Device(gaudio)\r\n\t\t\r\n\t\tstartMillis=BlitzMaxMillisecs()\r\n\t\t\r\n\t\tSetFrameRate( 0 )\r\n\t\t\r\n\t\tInvokeOnCreate()\r\n\t\tInvokeOnRender()\r\n\t\tUpdate()\r\n\tEndMethod\r\n\t\r\n\tMethod Update()\r\n\t\tWhile Not AppTerminate()\r\n\t\t\tIf Not updatePeriod return\r\n\t\t\tLocal updates:Int = 0\r\n\t\t\t\r\n\t\t\tRepeat\r\n\t\t\t\tnextUpdate:+updatePeriod\r\n\t\t\t\tInvokeOnUpdate()\r\n\t\t\t\tIf Not updatePeriod Then Exit\r\n\t\t\t\tIf nextUpdate>BlitzMaxMillisecs() Then Exit\r\n\t\t\t\tupdates:+1\r\n\t\t\t\tIf updates = 7 Then\r\n\t\t\t\t\tnextUpdate = BlitzMaxMillisecs()\r\n\t\t\t\t\tExit\r\n\t\t\t\tEndIf\r\n\t\t\tForever\r\n\t\t\tInvokeOnRender()\r\n\t\t\tLocal del:Int = nextUpdate - BlitzMaxMillisecs()\r\n\t\t\tIf del < 1 Then del = 1\r\n\t\t\tDelay(del)\r\n\t\tWend\r\n\tEndMethod\r\n\t\r\n\tMethod InvokeOnCreate()\r\n\t\tIf dead Return\r\n\t\tdead = 1\r\n\t\tOnCreate()\r\n\t\tdead = 0\r\n\tEndMethod\r\n\r\n\tMethod InvokeOnUpdate()\r\n\t\tIf dead Or suspended Or Not updateRate Or vloading Return\r\n\t\tOnUpdate()\r\n\tEndMethod\r\n\t\r\n\tMethod InvokeOnRender()\r\n\t\tIf dead Or suspended Return\r\n\t\tggraphics.BeginRender()\r\n\t\tIf vloading\r\n\t\t\tOnLoading()\r\n\t\tElse\r\n\t\t\tOnRender()\r\n\t\tEndIf\r\n\t\tggraphics.EndRender()\r\n\tEndMethod\r\n\t\r\n\t\r\n\tMethod SetFrameRate( fps:Int )\r\n\t\tIf fps\r\n\t\t\tupdatePeriod=1000.0\/fps\r\n\t\t\tnextUpdate=BlitzMaxMillisecs() +updatePeriod\r\n\t\tElse\r\n\t\t\tupdatePeriod=0\r\n\t\tEndIf\r\n\tEndMethod\r\n\r\n\tMethod LoadState:String()\r\n'\t\tvar file:SharedObject=SharedObject.getLocal( \"gxtkapp\" );\r\n'\t\tvar state:String=file.data.state;\r\n'\t\tfile.close();\r\n'\t\tif( state ) return state;\r\n\t\tReturn \"\"\r\n\tEndMethod\r\n\t\r\n\tMethod SaveState:Int( state:String )\r\n'\t\tvar file:SharedObject=SharedObject.getLocal( \"gxtkapp\" );\r\n'\t\tfile.data.state=state;\r\n'\t\tfile.close();\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod LoadString:String( path:String )\r\n\t\tpath = \"data\/\" + path\r\n\t\tReturn LoadText( path )\r\n\tEndMethod\r\n\t\r\n\t' ***** GXTK API *****\r\n\t\r\n\tMethod GraphicsDevice:gxtkGraphics()\r\n\t\tReturn ggraphics\r\n\tEndMethod\r\n\r\n\tMethod InputDevice:gxtkInput()\r\n\t\tReturn ginput\r\n\tEndMethod\r\n\r\n\tMethod AudioDevice:gxtkAudio()\r\n\t\tReturn gaudio\r\n\tEndMethod\r\n\r\n\tMethod SetUpdateRate:Int(hertz:Int)\r\n\t\tupdateRate = hertz\r\n\t\tIf Not vloading Then SetFrameRate(updateRate)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod MilliSecs:Int()\r\n\t\tReturn BlitzMaxMillisecs() - startMillis\r\n\tEndMethod\r\n\t\r\n\tMethod Loading:Int()\r\n\t\tReturn vloading\r\n\tEndMethod\r\n\r\n\tMethod OnCreate:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod OnUpdate:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod OnSuspend:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod OnResume:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod OnRender:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod OnLoading:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkGraphics\r\n\tField gmode:Int = 1\r\n\tField ix:Float=1,iy:Float,jx:Float,jy:Float=1,tx:Float,ty:Float\r\n\tField sx:Float=1,sy:Float=1,rot:Float=0\r\n\t\r\n\tMethod Mode:Int()\r\n\t\tReturn gmode\r\n\tEndMethod\r\n\t\r\n\tMethod Cls:Int(r:Int = 0, g:Int = 0, b:Int = 0)\r\n\t\tBlitzMaxCls(r, g, b)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawPoint:Int(x:Float, y:Float)\r\n\t\tLocal nx:Float = TransX(x,y)\r\n\t\tLocal ny:Float = TransY(x,y)\r\n\t\tPlot nx, ny\r\n\tEndMethod\r\n\t\r\n\tMethod LoadSurface:gxtkSurface(path:String)\r\n\t\tLocal image:TImage = LoadImage(\"data\/\"+path)\r\n\t\tIf image Then\r\n\t\t\tLocal gs:gxtkSurface = New gxtkSurface\r\n\t\t\tgs.setImage(image)\r\n\t\t\tReturn gs\r\n\t\tEndIf\r\n\t\tReturn Null\r\n\tEndMethod\r\n\t\r\n\tMethod BeginRender()\r\n\tEndMethod\r\n\t\r\n\tMethod EndRender()\r\n\t\tFlip\r\n\tEndMethod\r\n\t\r\n\tMethod SetColor:Int(r:Int, g:Int, b:Int)\r\n\t\tBlitzMaxSetColor(r, g, b)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod SetAlpha:Int(a:Float)\r\n\t\tBlitzMaxSetAlpha(a)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod SetBlend:Int(blend:Int)\r\n\t\tBlitzMaxSetBlend(blend)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod Width:Int()\r\n\t\tReturn GraphicsWidth()\r\n\tEndMethod\r\n\t\r\n\tMethod Height:Int()\r\n\t\tReturn GraphicsHeight()\r\n\tEndMethod\r\n\t\r\n\tMethod SetScissor:Int(x:Int, y:Int, w:Int, h:Int)\r\n\t\tSetViewport(x, y, w, h) ' NOT TESTED!\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod TransX:Float(x:Float, y:Float)\r\n\t\tReturn ix*x + jx*y + tx\r\n\tEndMethod\r\n\t\r\n\tMethod TransY:Float(x:Float, y:Float)\r\n\t\tReturn iy*x + jy*y + ty\r\n\tEndMethod\r\n\t\r\n\tMethod SetMatrix:Int(ix:Float,iy:Float,jx:Float,jy:Float,tx:Float,ty:Float)\r\n\t\tSelf.ix = ix ; Self.iy = iy\r\n\t\tSelf.jx = jx ; Self.jy = jy\r\n\t\tSelf.tx = tx ; Self.ty = ty\r\n\t\tsx = Sqr(ix*ix+iy*iy)\r\n\t\tsy = Sqr(jx*jx+jy*jy)\r\n\t\trot = Atan2( iy, ix )\r\n\t\tIf ix < 0 Then\r\n\t\t\tsx = -sx\r\n\t\t\trot :+ 180\r\n\t\tEndIf\r\n\t\tIf jy < 0 Then sy = -sy\r\n\t\tSetTransform( rot, sx, sy )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawSurface:Int(surface:gxtkSurface,x:Float,y:Float)\r\n\t\tLocal nx:Float = TransX(x,y)\r\n\t\tLocal ny:Float = TransY(x,y)\r\n\t\tDrawImage(surface.image, nx, ny, 0)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawSurface2:Int(surface:gxtkSurface,x:Float,y:Float, srcx:Int, srcy:Int, srcw:Int, srch:Int )\r\n\t\tLocal nx:Float = TransX(x,y)\r\n\t\tLocal ny:Float = TransY(x,y)\r\n\t\tDrawSubImageRect(surface.image, nx, ny, srcw, srch, srcx, srcy, srcw, srch)\t\t\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawLine:Int( x1:Float,y1:Float,x2:Float,y2:Float )\r\n\t\tLocal nx1:Float = TransX(x1,y1)\r\n\t\tLocal ny1:Float = TransY(x1,y1)\r\n\t\tLocal nx2:Float = TransX(x2,y2)\r\n\t\tLocal ny2:Float = TransY(x2,y2)\r\n\t\t' Need to reset transform so that BlitzMax doesn't try to apply rotation\r\n\t\tSetTransform( 0, 1, 1 )\r\n\t\tBlitzMaxDrawLine(nx1, ny1, nx2, ny2)\r\n\t\tSetTransform( rot, sx, sy )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawOval:Int( x:Float, y:Float, w:Float, h:Float )\r\n\t\tLocal nx:Float = TransX(x,y)\r\n\t\tLocal ny:Float = TransY(x,y)\r\n\t\tBlitzMaxDrawOval(nx, ny, w, h)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawPoly:Int(vertices:Float[])\r\n\t\t' setting the origin to use the current rotation translation\r\n\t\tSetOrigin(TransX(0,0), TransY(0,0))\r\n\t\tBlitzMaxDrawPoly( vertices )\r\n\t\tSetOrigin(0, 0)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawRect:Int( x:Float, y:Float, w:Float, h:Float )\r\n\t\tLocal nx:Float = TransX(x,y)\r\n\t\tLocal ny:Float = TransY(x,y)\r\n\t\tBlitzMaxDrawRect(nx, ny, w, h)\r\n\t\tReturn 0\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkInput\r\n\tMethod MouseX:Float()\r\n\t\tReturn BRL.PolledInput.MouseX()\r\n\tEndMethod\r\n\r\n\tMethod MouseY:Float()\r\n\t\tReturn BRL.PolledInput.MouseY()\r\n\tEndMethod\r\n\t\r\n\tMethod KeyDown:Int( key:Int )\r\n\t\tif( key = 384 ) key = 1 ' change TOUCH0 to MOUSE_LMB\r\n\r\n\t\tIf( key >= 1 And key <= 3 )\r\n\t\t\tReturn BRL.PolledInput.MouseDown( key )\r\n\t\tEndIf\r\n\t\tIf key < 256\r\n\t\t\tReturn BRL.PolledInput.KeyDown( key )\r\n\t\tElse\r\n\t\t\tReturn 0\r\n\t\tEndIf\r\n\tEndMethod\r\n\r\n\tMethod KeyHit:Int( key:Int )\r\n\t\tif( key = 384 ) key = 1 ' change TOUCH0 to MOUSE_LMB\r\n\t\tIf( key >= 1 And key <= 3 )\r\n\t\t\tReturn BRL.PolledInput.MouseHit( key )\r\n\t\tEndIf\r\n\t\tIf key < 256\r\n\t\t\tReturn BRL.PolledInput.KeyHit( key )\r\n\t\tElse\r\n\t\t\tReturn 0\r\n\t\tEndIf\r\n\tEndMethod\r\n\r\n\tMethod GetChar:Int()\r\n\t\tReturn BRL.PolledInput.GetChar()\r\n\tEndMethod\r\n\r\n\tMethod JoyX:Int( index:Int )\r\n\t\tReturn Pub.FreeJoy.JoyX( index )\r\n\tEndMethod\r\n\r\n\tMethod JoyY:Int( index:Int )\r\n\t\tReturn Pub.FreeJoy.JoyY( index )\r\n\tEndMethod\r\n\r\n\tMethod JoyZ:Int( index:Int )\r\n\t\tReturn Pub.FreeJoy.JoyZ( index )\r\n\tEndMethod\r\n\r\n\tMethod TouchX:Float( index:Int )\r\n\t\tReturn BRL.PolledInput.MouseX()\r\n\tEndMethod\r\n\r\n\tMethod TouchY:Float( index:Int )\r\n\t\tReturn BRL.PolledInput.MouseY()\r\n\tEndMethod\r\n\t\r\n\tMethod AccelX:Int()\r\n\t\treturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod AccelY:Int()\r\n\t\treturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod AccelZ:Int()\r\n\t\treturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod SetKeyboardEnabled:Int( enabled:int )\r\n\t\tReturn 0\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkChannel\r\n\tField channel:TChannel\t' null then not playing\r\n\tField sample:gxtkSample\r\n\tField loops:int\r\n\t'Field transform:SoundTransform=new SoundTransform()\r\n\t'Field pausepos:Number\r\n\tField state:int\r\n\t\r\n\tMethod New()\r\n\t\tchannel = New TChannel\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkAudio\r\n\tField amusicState:Int = 0\r\n\tField channels:gxtkChannel[] = New gxtkChannel[33]\r\n\t\r\n\tMethod New()\r\n\t\tFor local i:Int = 0 To 33 - 1\r\n\t\t\tchannels[i] = New gxtkChannel\r\n\t\tNext\r\n\tEndMethod\r\n\t\r\n\tMethod MusicState:Int()\r\n'\t\tIf( musicState = 1 And music.isPlaying() = False )\r\n'\t\t\tmusicState = 0;\r\n'\t\tEndif\r\n\t\tReturn amusicState\r\n\tEndMethod\r\n\t\r\n\tMethod PlayMusic:Int( path:String, flags:Int )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod ChannelState:int( channel:int )\r\n\t\tReturn -1\r\n\tEndMethod\r\n\t\r\n\tMethod StopMusic()\r\n\tEndMethod\r\n\t\r\n\tMethod StopChannel( channel:Int )\r\n\tEndMethod\r\n\r\n\tMethod PlaySample( sound:gxtkSample, channel:Int, flags:Int )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\t\r\n\t\t'If chan.state <> 0 Then chan.channel.Stop() <-- this crashes after the first play!?\r\n\t\t\r\n\t\tchan.sample = sound\r\n\t\t'chan.loops = flags ? 0x7fffffff : 0;\r\n\t\t'chan.channel = sample.sound.play( 0,chan.loops,chan.transform );\r\n\t\t'chan.channel = sound\r\n\t\tchan.state=1\r\n\t\r\n\t\tPlaySound( sound.sound, chan.channel )\r\n\tEndMethod\r\n\r\n\tMethod SetPan( channel:Int, pan:Float )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tchan.channel.SetPan(pan)\r\n\tEndMethod\r\n\r\n\tMethod SetRate( channel:Int, rate:Float )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tchan.channel.SetRate(rate)\r\n\tEndMethod\r\n\r\n\tMethod PauseMusic:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod ResumeMusic:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod SetMusicVolume:Int( volume:Float )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod SetVolume:Int( channel:Int, volume:Float )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tchan.channel.SetVolume(volume)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod LoadSample:gxtkSample( path:String )\r\n\t\tLocal extension:String = ExtractExt( path)\r\n\t\tIf extension = \"ogg\" Or extension = \"wav\" Then\r\n\t\t\tLocal sound:TSound = LoadSound(\"data\/\"+path)\r\n\t\t\tIf sound Then\r\n\t\t\t\tLocal gs:gxtkSample = New gxtkSample\r\n\t\t\t\tgs.setSound(sound)\r\n\t\t\t\tReturn gs\r\n\t\t\tEndIf\r\n\t\tElse\r\n\t\t\tRuntimeError \"BlitzMax can only use ogg and wav file formats\"\r\n\t\tEndIf\r\n\t\tReturn Null\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkSample\r\n\tField sound:TSound\r\n\t\r\n\tMethod setSound(sound:TSound)\r\n\t\tSelf.sound = sound\r\n\tEndMethod\r\n\t\r\n\tMethod Discard()\r\n\t\tSelf.sound = null\r\n\tEndMethod\r\nEndType\r\n\r\nFunction BlitzMaxDrawPoly:Int(vertices:Float[])\r\n\tDrawPoly vertices\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxDrawRect:Int( x:Float, y:Float, w:Float, h:Float )\r\n\tDrawRect x, y, w, h\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxDrawOval:Int( x:Float, y:Float, w:Float, h:Float )\r\n\tDrawOval x, y, w, h\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxDrawLine:Int( x1:Float,y1:Float,x2:Float,y2:Float )\r\n\tDrawLine x1, y1, x2, y2\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxMillisecs:Int()\r\n\tReturn MilliSecs()\r\nEndFunction\r\n\r\nFunction BlitzMaxSetColor(r:Int, g:Int, b:Int)\r\n\tSetColor(r, g, b)\r\nEndFunction\r\n\r\nFunction BlitzMaxSetBlend(blend:Int)\r\n\tSelect blend\r\n\t\tCase 0\r\n\t\t\tSetBlend( ALPHABLEND )\r\n\t\tCase 1\r\n\t\t\tSetBlend( LIGHTBLEND )\r\n\tEnd Select\r\nEndFunction\r\n\r\nFunction BlitzMaxSetAlpha(a:Float)\r\n\tSetAlpha(a)\r\nEndFunction\r\n\r\nFunction BlitzMaxCls(r:Int = 0, g:Int = 0, b:Int = 0)\r\n\tSetClsColor(r, g, b)\r\n\tCls\r\nEndFunction\r\n\r\nType gxtkSurface\r\n\tField w:Int, h:Int\r\n\tField image:TImage\r\n\t\r\n\tMethod setImage(image:TImage)\r\n\t\tSelf.image = image\r\n\tEndMethod\r\n\t\r\n\tMethod Width:Int()\r\n\t\tReturn image.Width\r\n\tEndMethod\r\n\t\r\n\tMethod Height:Int()\r\n\t\tReturn image.Height\r\n\tEndMethod\r\n\t\r\n\tMethod Discard()\r\n\tEndMethod\r\nEndType\r\n\r\n' ***** End mojo.bmax.bmx ******\r\n\r\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"c02dff6ad1f18c49c40511c6c0811c144b3de313","subject":"Changelog update","message":"Changelog update\n","repos":"Htbaa\/zmq.mod,Htbaa\/zmq.mod","old_file":"zmq.bmx","new_file":"zmq.bmx","new_contents":"Rem\n\tCopyright (c) 2012 Christiaan Kras\n\t\n\tPermission is hereby granted, free of charge, to any person obtaining a copy\n\tof this software and associated documentation files (the \"Software\"), to deal\n\tin the Software without restriction, including without limitation the rights\n\tto use, copy, modify, merge, publish, distribute, sublicense, and\/or sell\n\tcopies of the Software, and to permit persons to whom the Software is\n\tfurnished to do so, subject to the following conditions:\n\t\n\tThe above copyright notice and this permission notice shall be included in\n\tall copies or substantial portions of the Software.\n\t\n\tTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n\tIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n\tFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n\tAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n\tLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n\tOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n\tTHE SOFTWARE.\nEnd Rem\n\nSuperStrict\n\nRem\n\tbbdoc: htbaapub.zmq\n\tabout: This module is still an early work in progress. If you run into any\n\tbugs please report them at https:\/\/github.com\/Htbaa\/zmq.mod\/issues<\/a>.\nEndRem\nModule htbaapub.zmq\nModuleInfo \"Name: htbaapub.zmq\"\nModuleInfo \"Description: A wrapper for ZeroMQ\"\nModuleInfo \"Version: 0.03\"\nModuleInfo \"License: MIT\"\nModuleInfo \"Author: Christiaan Kras\"\nModuleInfo \"ZeroMQ: http:\/\/www.zeromq.org<\/a>\"\nModuleInfo \"ZeroMQ License: LGPL (see contents of .\/zeromq)\"\nModuleInfo \"Git repository: https:\/\/github.com\/Htbaa\/zmq.mod\/<\/a>\"\nModuleInfo \"Issues: https:\/\/github.com\/Htbaa\/zmq.mod\/issues<\/a>\"\nModuleInfo \"History: Improved test coverage\"\nModuleInfo \"History: 0.03\"\nModuleInfo \"History: Fixed message data corruption for first sent message (gh-3)\"\nModuleInfo \"History: Added TZMQ_Message.CreateFromString to create messages from a String. The TZMQ_Message.Create signature has also changed to accept a Byte Ptr and a length\"\nModuleInfo \"History: Fixed potential memory leak in TZMQ_Socket.Send when an exception would be raised\"\nModuleInfo \"History: Added TZMQ_Socket_Exception and TZMQ_Message_Exception\"\nModuleInfo \"History: Added a couple of unit tests (bah.maxunit required)\"\nModuleInfo \"History: 0.02\"\nModuleInfo \"History: Added more examples; Hello World server and client\"\nModuleInfo \"History: Added more examples; Weather Update server and client\"\nModuleInfo \"History: TZMQ_Socket.SetSockOpt() now properly sets options\"\nModuleInfo \"History: TZMQ_Message.Close() now properly frees up memory\"\nModuleInfo \"History: 0.01\"\nModuleInfo \"History: First release of htbaapub.zmq using ZMQ 2.1.11. No support yet for input\/output multiplexing with zmq_poll()\"\n\n?Linux\n\tImport \"-lzmq\"\n?Win32\n\tImport \"zeromq\/lib\/libzmq.dll.a\"\n?\n\nImport \"glue.c\"\nInclude \"exception.bmx\"\nInclude \"constants.bmx\"\nInclude \"context.bmx\"\nInclude \"socket.bmx\"\nInclude \"message.bmx\"\n\n'Glue\/Helper functions\nExtern \"C\"\n\n\tRem\n\t\tbbdoc: Create an empty zmq_message_t struct\n\t\treturns: Returns a pointer to a new zmq_message_t struct\n\tEnd Rem\n\tFunction bmx_zmq_message_t:Byte Ptr()\n\n\tRem\n\t\tbbdoc: Create a zmq_message_t struct with preset data\n\t\treturns: Returns a pointer to a new zmq_message_t struct with given data\n\tEnd Rem\n\tFunction bmx_zmq_new_message:Byte Ptr(str$z)\n\t\n\tRem\n\t\tbbdoc: Alias for free(), for cleaning up data structures\n\tEnd Rem\n\tFunction bmx_zmq_free(msg:Byte Ptr)\nEnd Extern\n\n'ZeroMQ functions\nExtern\n\tFunction zmq_version(major:Int Var, minor:Int Var, patch:Int Var)\n\n\tFunction zmq_init:Byte Ptr(io_threads:Int)\n\tFunction zmq_term:Int(context:Byte Ptr)\n\t\n\tFunction zmq_errno:Int()\n\tFunction zmq_strerror$z(errnum:Int)\n\t\n\tFunction zmq_socket:Byte Ptr(context:Byte Ptr, socket_type:Int)\n\tFunction zmq_close:Int(s:Byte Ptr)\n\tFunction zmq_setsockopt:Int(s:Byte Ptr, option:Int, optval$z, length:Int)\n\tFunction zmq_getsockopt:Int(s:Byte Ptr, option:Int, optval:Byte Ptr, length:Int Var)\n\t'ZMQ_EXPORT Int zmq_getsockopt (void *s, Int option, void *optval, size_t *optvallen);\n\tFunction zmq_bind(s:Byte Ptr, addr$z)\n\tFunction zmq_connect:Int(s:Byte Ptr, addr$z)\n\tFunction zmq_send:Int(s:Byte Ptr, msg:Byte Ptr, flags:Int)\n\tFunction zmq_recv:Int(s:Byte Ptr, msg:Byte Ptr, flags:Int)\n\n\tFunction zmq_msg_init:Int(msg:Byte Ptr)\n\tFunction zmq_msg_init_size:Int(msg:Byte Ptr, size:Long)\n\tFunction zmq_msg_init_data:Int(msg:Byte Ptr, data:Byte Ptr, size:Long, ffn:Byte Ptr, hint:Byte Ptr)\n\tFunction zmq_msg_close:Int(msg:Byte Ptr)\n\tFunction zmq_msg_move:Int(dest:Byte Ptr, src:Byte Ptr)\n\tFunction zmq_msg_copy:Int(dest:Byte Ptr, src:Byte Ptr)\n\tFunction zmq_msg_data:Byte Ptr(msg:Byte Ptr)\n\tFunction zmq_msg_size:Int(msg:Byte Ptr)\n\t\n\tFunction zmq_poll:Int(items:Byte Ptr, nitems:Int, timeout:Long)\n\t\n\tFunction zmq_device:Int(device:Int, insocket:Byte Ptr, outsocket:Byte Ptr)\nEnd Extern\n\nRem\n\tbbdoc: General ZMQ functions\nEnd Rem\nType TZMQ\n\n\tRem\n\t\tbbdoc: Get ZMQ Version\n\t\treturns: String\n\tEnd Rem\n\tFunction Version:String()\n\t\tLocal major:Int, minor:Int, patch:Int\n\t\tzmq_version(major, minor, patch)\n\t\tReturn major + \".\" + minor + \".\" + patch\n\tEnd Function\n\n\tRem\n\t\tbbdoc: Get current ZMQ error descriptions\n\t\treturns: String\n\tEnd Rem\n\tFunction Error:String()\n\t\tReturn zmq_strerror( TZMQ.ErrorNumber() )\n\tEnd Function\n\n\tRem\n\t\tbbdoc: Get current ZMQ error number\n\t\treturns: Int\n\tEnd Rem\n\tFunction ErrorNumber:Int()\n\t\tReturn zmq_errno()\n\tEnd Function\nEnd Type","old_contents":"Rem\n\tCopyright (c) 2012 Christiaan Kras\n\t\n\tPermission is hereby granted, free of charge, to any person obtaining a copy\n\tof this software and associated documentation files (the \"Software\"), to deal\n\tin the Software without restriction, including without limitation the rights\n\tto use, copy, modify, merge, publish, distribute, sublicense, and\/or sell\n\tcopies of the Software, and to permit persons to whom the Software is\n\tfurnished to do so, subject to the following conditions:\n\t\n\tThe above copyright notice and this permission notice shall be included in\n\tall copies or substantial portions of the Software.\n\t\n\tTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n\tIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n\tFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n\tAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n\tLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n\tOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n\tTHE SOFTWARE.\nEnd Rem\n\nSuperStrict\n\nRem\n\tbbdoc: htbaapub.zmq\n\tabout: This module is still an early work in progress. If you run into any\n\tbugs please report them at https:\/\/github.com\/Htbaa\/zmq.mod\/issues<\/a>.\nEndRem\nModule htbaapub.zmq\nModuleInfo \"Name: htbaapub.zmq\"\nModuleInfo \"Description: A wrapper for ZeroMQ\"\nModuleInfo \"Version: 0.03\"\nModuleInfo \"License: MIT\"\nModuleInfo \"Author: Christiaan Kras\"\nModuleInfo \"ZeroMQ: http:\/\/www.zeromq.org<\/a>\"\nModuleInfo \"ZeroMQ License: LGPL (see contents of .\/zeromq)\"\nModuleInfo \"Git repository: https:\/\/github.com\/Htbaa\/zmq.mod\/<\/a>\"\nModuleInfo \"Issues: https:\/\/github.com\/Htbaa\/zmq.mod\/issues<\/a>\"\nModuleInfo \"History: 0.03\"\nModuleInfo \"History: Fixed message data corruption for first sent message (gh-3)\"\nModuleInfo \"History: Added TZMQ_Message.CreateFromString to create messages from a String. The TZMQ_Message.Create signature has also changed to accept a Byte Ptr and a length\"\nModuleInfo \"History: Fixed potential memory leak in TZMQ_Socket.Send when an exception would be raised\"\nModuleInfo \"History: Added TZMQ_Socket_Exception and TZMQ_Message_Exception\"\nModuleInfo \"History: Added a couple of unit tests (bah.maxunit required)\"\nModuleInfo \"History: 0.02\"\nModuleInfo \"History: Added more examples; Hello World server and client\"\nModuleInfo \"History: Added more examples; Weather Update server and client\"\nModuleInfo \"History: TZMQ_Socket.SetSockOpt() now properly sets options\"\nModuleInfo \"History: TZMQ_Message.Close() now properly frees up memory\"\nModuleInfo \"History: 0.01\"\nModuleInfo \"History: First release of htbaapub.zmq using ZMQ 2.1.11. No support yet for input\/output multiplexing with zmq_poll()\"\n\n?Linux\n\tImport \"-lzmq\"\n?Win32\n\tImport \"zeromq\/lib\/libzmq.dll.a\"\n?\n\nImport \"glue.c\"\nInclude \"exception.bmx\"\nInclude \"constants.bmx\"\nInclude \"context.bmx\"\nInclude \"socket.bmx\"\nInclude \"message.bmx\"\n\n'Glue\/Helper functions\nExtern \"C\"\n\n\tRem\n\t\tbbdoc: Create an empty zmq_message_t struct\n\t\treturns: Returns a pointer to a new zmq_message_t struct\n\tEnd Rem\n\tFunction bmx_zmq_message_t:Byte Ptr()\n\n\tRem\n\t\tbbdoc: Create a zmq_message_t struct with preset data\n\t\treturns: Returns a pointer to a new zmq_message_t struct with given data\n\tEnd Rem\n\tFunction bmx_zmq_new_message:Byte Ptr(str$z)\n\t\n\tRem\n\t\tbbdoc: Alias for free(), for cleaning up data structures\n\tEnd Rem\n\tFunction bmx_zmq_free(msg:Byte Ptr)\nEnd Extern\n\n'ZeroMQ functions\nExtern\n\tFunction zmq_version(major:Int Var, minor:Int Var, patch:Int Var)\n\n\tFunction zmq_init:Byte Ptr(io_threads:Int)\n\tFunction zmq_term:Int(context:Byte Ptr)\n\t\n\tFunction zmq_errno:Int()\n\tFunction zmq_strerror$z(errnum:Int)\n\t\n\tFunction zmq_socket:Byte Ptr(context:Byte Ptr, socket_type:Int)\n\tFunction zmq_close:Int(s:Byte Ptr)\n\tFunction zmq_setsockopt:Int(s:Byte Ptr, option:Int, optval$z, length:Int)\n\tFunction zmq_getsockopt:Int(s:Byte Ptr, option:Int, optval:Byte Ptr, length:Int Var)\n\t'ZMQ_EXPORT Int zmq_getsockopt (void *s, Int option, void *optval, size_t *optvallen);\n\tFunction zmq_bind(s:Byte Ptr, addr$z)\n\tFunction zmq_connect:Int(s:Byte Ptr, addr$z)\n\tFunction zmq_send:Int(s:Byte Ptr, msg:Byte Ptr, flags:Int)\n\tFunction zmq_recv:Int(s:Byte Ptr, msg:Byte Ptr, flags:Int)\n\n\tFunction zmq_msg_init:Int(msg:Byte Ptr)\n\tFunction zmq_msg_init_size:Int(msg:Byte Ptr, size:Long)\n\tFunction zmq_msg_init_data:Int(msg:Byte Ptr, data:Byte Ptr, size:Long, ffn:Byte Ptr, hint:Byte Ptr)\n\tFunction zmq_msg_close:Int(msg:Byte Ptr)\n\tFunction zmq_msg_move:Int(dest:Byte Ptr, src:Byte Ptr)\n\tFunction zmq_msg_copy:Int(dest:Byte Ptr, src:Byte Ptr)\n\tFunction zmq_msg_data:Byte Ptr(msg:Byte Ptr)\n\tFunction zmq_msg_size:Int(msg:Byte Ptr)\n\t\n\tFunction zmq_poll:Int(items:Byte Ptr, nitems:Int, timeout:Long)\n\t\n\tFunction zmq_device:Int(device:Int, insocket:Byte Ptr, outsocket:Byte Ptr)\nEnd Extern\n\nRem\n\tbbdoc: General ZMQ functions\nEnd Rem\nType TZMQ\n\n\tRem\n\t\tbbdoc: Get ZMQ Version\n\t\treturns: String\n\tEnd Rem\n\tFunction Version:String()\n\t\tLocal major:Int, minor:Int, patch:Int\n\t\tzmq_version(major, minor, patch)\n\t\tReturn major + \".\" + minor + \".\" + patch\n\tEnd Function\n\n\tRem\n\t\tbbdoc: Get current ZMQ error descriptions\n\t\treturns: String\n\tEnd Rem\n\tFunction Error:String()\n\t\tReturn zmq_strerror( TZMQ.ErrorNumber() )\n\tEnd Function\n\n\tRem\n\t\tbbdoc: Get current ZMQ error number\n\t\treturns: Int\n\tEnd Rem\n\tFunction ErrorNumber:Int()\n\t\tReturn zmq_errno()\n\tEnd Function\nEnd Type","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"88d205b0a0555fef59dc632e299415bf7ca97ca7","subject":"Wrapped another XMLRPC-EPI function, XMLRPC_GetVectoryType()","message":"Wrapped another XMLRPC-EPI function, XMLRPC_GetVectoryType()\n","repos":"Htbaa\/xmlrpc.mod,Htbaa\/xmlrpc.mod,Htbaa\/xmlrpc.mod,Htbaa\/xmlrpc.mod,Htbaa\/xmlrpc.mod","old_file":"wrapper.bmx","new_file":"wrapper.bmx","new_contents":"'XMLRPC_REQUEST_TYPE\nConst xmlrpc_request_none:Int = 0\nConst xmlrpc_request_call:Int = 1\nConst xmlrpc_request_response:Int = 2\n\n'XMLRPC_VERSION\nConst xmlrpc_version_none:Int = 0\nConst xmlrpc_version_1_0:Int = 1\nConst xmlrpc_version_simple:Int = 2\nConst xmlrpc_version_danda:Int = 2\nConst xmlrpc_version_soap_1_1:Int = 3\n\n'XMLRPC_VECTOR_TYPE\nConst xmlrpc_vector_none:Int = 0\nConst xmlrpc_vector_array:Int = 1\nConst xmlrpc_vector_mixed:Int = 2\nConst xmlrpc_vector_struct:Int = 3\n\n'XMLRPC_VALUE_TYPE\nConst xmlrpc_none:Int = 0\nConst xmlrpc_empty:Int = 1\nConst xmlrpc_base64:Int = 2\nConst xmlrpc_boolean:Int = 3\nConst xmlrpc_datetime:Int = 4\nConst xmlrpc_double:Int = 5\nConst xmlrpc_int:Int = 6\nConst xmlrpc_string:Int = 7\nConst xmlrpc_vector:Int = 8\n\n'XMLRPC_VALUE_TYPE_EASY\nConst xmlrpc_type_none:Int = 0\nConst xmlrpc_type_empty:Int = 1\nConst xmlrpc_type_base64:Int = 2\nConst xmlrpc_type_boolean:Int = 3\nConst xmlrpc_type_datetime:Int = 4\nConst xmlrpc_type_double:Int = 5\nConst xmlrpc_type_int:Int = 6\nConst xmlrpc_type_string:Int = 7\nConst xmlrpc_type_array:Int = 8\nConst xmlrpc_type_mixed:Int = 9\nConst xmlrpc_type_struct:Int = 10\n\n'XMLRPC_ERROR_CODE\nConst xmlrpc_error_none:Int = 0\nConst xmlrpc_error_parse_xml_syntax:Int = -32700\nConst xmlrpc_error_parse_unknown_encoding:Int = -32701\nConst xmlrpc_error_parse_bad_encoding:Int = -32702\nConst xmlrpc_error_invalid_xmlrpc:Int = -32600\nConst xmlrpc_error_unknown_method:Int = -32601\nConst xmlrpc_error_invalid_params:Int = -32602\nConst xmlrpc_error_internal_server:Int = -32603\nConst xmlrpc_error_application:Int = -32500\nConst xmlrpc_error_system:Int = -32400\nConst xmlrpc_error_transport:Int = -32300\n\n'XMLRPC_SERVER_VALIDATION\nConst validation_none:Int = 0\nConst validation_all:Int = 1\nConst validation_if_defined:Int = 2\n\n'XMLRPC_CASE_COMPARISON\nConst xmlrpc_case_insensitive:Int = 0\nConst xmlrpc_case_sensitive:Int = 1\n\n'XMLRPC_CASE\nConst xmlrpc_case_exact:Int = 0\nConst xmlrpc_case_lower:Int = 1\nConst xmlrpc_case_upper:Int = 2\n\nExtern\n\tFunction XMLRPC_Create_STRUCT_XMLRPC_REQUEST_OUTPUT_OPTIONS:Byte Ptr(version:Int)\n'\tFunction XMLRPC_Delete_Request_Output_Options(options:Byte Ptr)\nEnd Extern\n\nExtern \"C\"\n\n\tFunction XMLRPC_RequestNew:Byte Ptr()\n\tFunction XMLRPC_RequestFree(request:Byte Ptr, bFreeIO:Int)\n\tFunction XMLRPC_RequestSetMethodName:Byte Ptr(request:Byte Ptr, methodName:Byte Ptr)\n\tFunction XMLRPC_RequestGetMethodName:Byte Ptr(request:Byte Ptr)\n\tFunction XMLRPC_RequestSetRequestType:Int(request:Byte Ptr, iType:Int)\n\tFunction XMLRPC_RequestGetRequestType:Int(request:Byte Ptr)\n\tFunction XMLRPC_RequestSetData:Byte Ptr(request:Byte Ptr, data:Byte Ptr)\n\tFunction XMLRPC_RequestGetData:Byte Ptr(request:Byte Ptr)\n\n\tFunction XMLRPC_REQUEST_ToXML:Byte Ptr(request:Byte Ptr, buf_len:Byte Ptr)\n\tFunction XMLRPC_REQUEST_FromXML:Byte Ptr(in_buf:Byte Ptr, length:Int, in_options:Byte Ptr)\n\tFunction XMLRPC_VALUE_ToXML:Byte Ptr(val:Int, buf_len:Byte Ptr)\n\tFunction XMLRPC_VALUE_FromXML:Byte Ptr(in_buf:Byte Ptr, length:Int, in_options:Byte Ptr)\n\n\tFunction XMLRPC_RequestSetOutputOptions:Byte Ptr(request:Byte Ptr, output:Byte Ptr)\n\tFunction XMLRPC_RequestGetOutputOptions:Byte Ptr(request:Byte Ptr)\n\n\tFunction XMLRPC_CreateVector:Byte Ptr(id:String, iType:Int)\n\tFunction XMLRPC_AddValueToVector:Int(target:Byte Ptr, source:Byte Ptr)\n\tFunction XMLRPC_VectorSize:Int(value:Byte Ptr)\n\tFunction XMLRPC_VectorRewind:Byte Ptr(value:Byte Ptr)\n\tFunction XMLRPC_VectorNext:Byte Ptr(value:Byte Ptr)\n\t\n\tFunction XMLRPC_CreateValueBoolean:Byte Ptr(id:Byte Ptr, truth:Int)\n\tFunction XMLRPC_CreateValueBase64:Byte Ptr(id:Byte Ptr, s:Byte Ptr, length:Int)\n\tFunction XMLRPC_CreateValueDateTime:Byte Ptr(id:Byte Ptr, time:Long)\n\tFunction XMLRPC_CreateValueDateTime_ISO8601:Byte Ptr(id:Byte Ptr, s:Byte Ptr)\n\tFunction XMLRPC_CreateValueDouble:Byte Ptr(id:Byte Ptr, f:Double)\n\tFunction XMLRPC_CreateValueInt:Byte Ptr(id:Byte Ptr, i:Int)\n\tFunction XMLRPC_CreateValueEmpty:Byte Ptr()\n\tFunction XMLRPC_CreateValueString:Byte Ptr(id:Byte Ptr, s:Byte Ptr, length:Int)\n\n\tFunction XMLRPC_RequestSetError:Int(request:Byte Ptr, error:Int)\n\tFunction XMLRPC_RequestGetError:Int(request:Byte Ptr)\n\n\tFunction XMLRPC_VectorGetValueWithID_Case:Byte Ptr(vector:Byte Ptr, id:Byte Ptr, id_case:Int)\n\t\n\tFunction XMLRPC_GetValueType:Int(v:Byte Ptr)\n\t'XMLRPC_VALUE_TYPE_EASY XMLRPC_GetValueTypeEasy(XMLRPC_VALUE v);\n\tFunction XMLRPC_GetVectorType:Int(v:Byte Ptr)\n\t\n\tFunction XMLRPC_GetValueString:Byte Ptr(value:Byte Ptr)\n\tFunction XMLRPC_GetValueStringLen:Int(value:Byte Ptr)\n\tFunction XMLRPC_GetValueInt:Int(value:Byte Ptr)\n\tFunction XMLRPC_GetValueBoolean:Int(value:Byte Ptr)\n\tFunction XMLRPC_GetValueDouble:Double(value:Byte Ptr)\n\tFunction XMLRPC_GetValueBase64:Byte Ptr(value:Byte Ptr)\n\tFunction XMLRPC_GetValueDateTime:Long(value:Byte Ptr)\n\tFunction XMLRPC_GetValueDateTime_ISO8601:Byte Ptr(value:Byte Ptr)\n\tFunction XMLRPC_GetValueID:Byte Ptr(value:Byte Ptr)\n\t\n\tFunction XMLRPC_ValueIsFault:Int(value:Byte Ptr)\n\tFunction XMLRPC_ResponseIsFault(response:Byte Ptr)\n\tFunction XMLRPC_GetValueFaultCode:Int(value:Byte Ptr)\n\tFunction XMLRPC_GetResponseFaultCode:Int(response:Byte Ptr)\n\tFunction XMLRPC_GetValueFaultString:Byte Ptr(value:Byte Ptr)\n\tFunction XMLRPC_GetResponseFaultString:Byte Ptr(response:Byte Ptr)\n\tFunction XMLRPC_Free(mem:Byte Ptr)\n\tFunction XMLRPC_GetVersionString:Byte Ptr()\nRem\n\n\nXMLRPC_VALUE XMLRPC_UtilityCreateFault(int fault_code, const char* fault_string);\n\n\/* Get Values *\/\n#define XMLRPC_VectorGetStringWithID(vector, id) XMLRPC_GetValueString(XMLRPC_VectorGetValueWithID(vector, id))\n#define XMLRPC_VectorGetBase64WithID(vector, id) XMLRPC_GetValueBase64(XMLRPC_VectorGetValueWithID(vector, id))\n#define XMLRPC_VectorGetDateTimeWithID(vector, id) XMLRPC_GetValueDateTime(XMLRPC_VectorGetValueWithID(vector, id))\n#define XMLRPC_VectorGetDoubleWithID(vector, id) XMLRPC_GetValueDouble(XMLRPC_VectorGetValueWithID(vector, id))\n#define XMLRPC_VectorGetIntWithID(vector, id) XMLRPC_GetValueInt(XMLRPC_VectorGetValueWithID(vector, id))\n#define XMLRPC_VectorGetBooleanWithID(vector, id) XMLRPC_GetValueBoolean(XMLRPC_VectorGetValueWithID(vector, id))\nEndrem\nEnd Extern\n\nFunction XMLRPC_VectorGetValueWithID:Byte Ptr(vector:Byte Ptr, id:String)\n\tReturn XMLRPC_VectorGetValueWithID_Case(vector, id.ToCString(), xmlrpc_case_sensitive)\nEnd Function\n\nFunction XMLRPC_VectorAppendString:Int(vector:Byte Ptr, id:String, s:String, length:Int = 0)\n\tReturn XMLRPC_AddValueToVector(vector, XMLRPC_CreateValueString(id.ToCString(), s.ToCString(), length))\nEnd Function\n\nFunction XMLRPC_VectorAppendBase64:Int(vector:Byte Ptr, id:String, s:String, length:Int = 0)\n\tReturn XMLRPC_AddValueToVector(vector, XMLRPC_CreateValueBase64(id.ToCString(), s.ToCString(), length))\nEnd Function\n\nFunction XMLRPC_VectorAppendDateTime:Int(vector:Byte Ptr, id:Byte Ptr, time:Long)\n\tReturn XMLRPC_AddValueToVector(vector, XMLRPC_CreateValueDateTime(id, time))\nEnd Function\n\nFunction XMLRPC_VectorAppendDateTime_ISO8601:Int(vector:Byte Ptr, id:String, s:String)\n\tReturn XMLRPC_AddValueToVector(vector, XMLRPC_CreateValueDateTime_ISO8601(id.ToCString(), s.ToCString()))\nEnd Function\n\nFunction XMLRPC_VectorAppendDouble:Int(vector:Byte Ptr, id:String, f:Double)\n\tReturn XMLRPC_AddValueToVector(vector, XMLRPC_CreateValueDouble(id.ToCString(), f))\nEnd Function\n\nFunction XMLRPC_VectorAppendInt:Int(vector:Byte Ptr, id:String, i:Int)\n\tReturn XMLRPC_AddValueToVector(vector, XMLRPC_CreateValueInt(id.ToCString(), i))\nEnd Function\n\nFunction XMLRPC_VectorAppendBoolean:Int(vector:Byte Ptr, id:String, i:Int)\n\tReturn XMLRPC_AddValueToVector(vector, XMLRPC_CreateValueBoolean(id.ToCString(), i))\nEnd Function\nrem\n\/****s* VALUE\/XMLRPC_REQUEST_INPUT_OPTIONS\n * NAME\n * XMLRPC_REQUEST_INPUT_OPTIONS\n * NOTES\n * Defines options for reading in xml data\n * SEE ALSO\n * XMLRPC_VERSION\n * XML_ELEM_INPUT_OPTIONS\n * XMLRPC_REQUEST_From_XML ()\n * SOURCE\n *\/\ntypedef struct _xmlrpc_request_input_options {\n STRUCT_XML_ELEM_INPUT_OPTIONS xml_elem_opts; \/* xml_element specific output options *\/\n} STRUCT_XMLRPC_REQUEST_INPUT_OPTIONS, *XMLRPC_REQUEST_INPUT_OPTIONS;\n\/******\/\n\n\/****s* VALUE\/XMLRPC_ERROR\n * NAME\n * XMLRPC_ERROR\n * NOTES\n * For the reporting and handling of errors\n * SOURCE\n *\/\ntypedef struct _xmlrpc_error {\n XMLRPC_ERROR_CODE code;\n STRUCT_XML_ELEM_ERROR xml_elem_error; \/* xml_element errors (parser errors) *\/\n} STRUCT_XMLRPC_ERROR, *XMLRPC_ERROR;\n\/******\/\nendrem\n\n\nRem\n\tString conversion stuff below. Shamelessly stolen from Brucey :-)\nEnd Rem\n\nExtern\n\tFunction _strlen:Int(s:Byte Ptr) = \"strlen\"\nEnd Extern\n\n' Convert from Max to UTF8\nFunction convertISO8859toUTF8:String(text:String)\n\tIf Not text Then\n\t\tReturn \"\"\n\tEnd If\n\t\n\tLocal l:Int = text.length\n\tIf l = 0 Then\n\t\tReturn \"\"\n\tEnd If\n\t\n\tLocal count:Int = 0\n\tLocal s:Byte[] = New Byte[l * 3]\n\t\n\tFor Local i:Int = 0 Until l\n\t\tLocal char:Int = text[i]\n\n\t\tIf char < 128 Then\n\t\t\ts[count] = char\n\t\t\tcount:+ 1\n\t\t\tContinue\n\t\tElse If char<2048\n\t\t\ts[count] = char\/64 | 192\n\t\t\tcount:+ 1\n\t\t\ts[count] = char Mod 64 | 128\n\t\t\tcount:+ 1\n\t\t\tContinue\n\t\tElse\n\t\t\ts[count] = char\/4096 | 224\n\t\t\tcount:+ 1\n\t\t\ts[count] = char\/64 Mod 64 | 128\n\t\t\tcount:+ 1\n\t\t\ts[count] = char Mod 64 | 128\n\t\t\tcount:+ 1\n\t\t\tContinue\n\t\tEndIf\n\t\t\n\tNext\n\n\tReturn String.fromBytes(s, count)\nEnd Function\n\n' Convert from UTF8 to Max\nFunction convertUTF8toISO8859:String(s:Byte Ptr)\n\n\tLocal l:Int = _strlen(s)\n\n\tLocal b:Short[] = New Short[l]\n\tLocal bc:Int = -1\n\tLocal c:Int\n\tLocal d:Int\n\tLocal e:Int\n\tFor Local i:Int = 0 Until l\n\n\t\tbc:+1\n\t\tc = s[i]\n\t\tIf c<128 \n\t\t\tb[bc] = c\n\t\t\tContinue\n\t\tEnd If\n\t\ti:+1\n\t\td=s[i]\n\t\tIf c<224 \n\t\t\tb[bc] = (c-192)*64+(d-128)\n\t\t\tContinue\n\t\tEnd If\n\t\ti:+1\n\t\te = s[i]\n\t\tIf c < 240 \n\t\t\tb[bc] = (c-224)*4096+(d-128)*64+(e-128)\n\t\t\tIf b[bc] = 8233 Then\n\t\t\t\tb[bc] = 10\n\t\t\tEnd If\n\t\t\tContinue\n\t\tEnd If\n\tNext\n\n\tReturn String.fromshorts(b, bc + 1)\nEnd Function\n\nFunction sizedUTF8toISO8859:String(s:Byte Ptr, size:Int)\n\n\tLocal l:Int = size\n\tLocal b:Short[] = New Short[l]\n\tLocal bc:Int = -1\n\tLocal c:Int\n\tLocal d:Int\n\tLocal e:Int\n\tFor Local i:Int = 0 Until l\n\n\t\tc = s[i]\n\t\tIf c = 0 Continue\n\n\t\tbc:+1\n\t\tIf c<128\n\t\t\tb[bc] = c\n\t\t\tContinue\n\t\tEnd If\n\t\ti:+1\n\t\td=s[i]\n\t\tIf c<224 \n\t\t\tb[bc] = (c-192)*64+(d-128)\n\t\t\tContinue\n\t\tEnd If\n\t\ti:+1\n\t\te = s[i]\n\t\tIf c < 240 \n\t\t\tb[bc] = (c-224)*4096+(d-128)*64+(e-128)\n\t\t\tIf b[bc] = 8233 Then\n\t\t\t\tb[bc] = 10\n\t\t\tEnd If\n\t\t\tContinue\n\t\tEnd If\n\tNext\n\n\tReturn String.fromshorts(b, bc + 1)\nEnd Function","old_contents":"'XMLRPC_REQUEST_TYPE\nConst xmlrpc_request_none:Int = 0\nConst xmlrpc_request_call:Int = 1\nConst xmlrpc_request_response:Int = 2\n\n'XMLRPC_VERSION\nConst xmlrpc_version_none:Int = 0\nConst xmlrpc_version_1_0:Int = 1\nConst xmlrpc_version_simple:Int = 2\nConst xmlrpc_version_danda:Int = 2\nConst xmlrpc_version_soap_1_1:Int = 3\n\n'XMLRPC_VECTOR_TYPE\nConst xmlrpc_vector_none:Int = 0\nConst xmlrpc_vector_array:Int = 1\nConst xmlrpc_vector_mixed:Int = 2\nConst xmlrpc_vector_struct:Int = 3\n\n'XMLRPC_VALUE_TYPE\nConst xmlrpc_none:Int = 0\nConst xmlrpc_empty:Int = 1\nConst xmlrpc_base64:Int = 2\nConst xmlrpc_boolean:Int = 3\nConst xmlrpc_datetime:Int = 4\nConst xmlrpc_double:Int = 5\nConst xmlrpc_int:Int = 6\nConst xmlrpc_string:Int = 7\nConst xmlrpc_vector:Int = 8\n\n'XMLRPC_VALUE_TYPE_EASY\nConst xmlrpc_type_none:Int = 0\nConst xmlrpc_type_empty:Int = 1\nConst xmlrpc_type_base64:Int = 2\nConst xmlrpc_type_boolean:Int = 3\nConst xmlrpc_type_datetime:Int = 4\nConst xmlrpc_type_double:Int = 5\nConst xmlrpc_type_int:Int = 6\nConst xmlrpc_type_string:Int = 7\nConst xmlrpc_type_array:Int = 8\nConst xmlrpc_type_mixed:Int = 9\nConst xmlrpc_type_struct:Int = 10\n\n'XMLRPC_ERROR_CODE\nConst xmlrpc_error_none:Int = 0\nConst xmlrpc_error_parse_xml_syntax:Int = -32700\nConst xmlrpc_error_parse_unknown_encoding:Int = -32701\nConst xmlrpc_error_parse_bad_encoding:Int = -32702\nConst xmlrpc_error_invalid_xmlrpc:Int = -32600\nConst xmlrpc_error_unknown_method:Int = -32601\nConst xmlrpc_error_invalid_params:Int = -32602\nConst xmlrpc_error_internal_server:Int = -32603\nConst xmlrpc_error_application:Int = -32500\nConst xmlrpc_error_system:Int = -32400\nConst xmlrpc_error_transport:Int = -32300\n\n'XMLRPC_SERVER_VALIDATION\nConst validation_none:Int = 0\nConst validation_all:Int = 1\nConst validation_if_defined:Int = 2\n\n'XMLRPC_CASE_COMPARISON\nConst xmlrpc_case_insensitive:Int = 0\nConst xmlrpc_case_sensitive:Int = 1\n\n'XMLRPC_CASE\nConst xmlrpc_case_exact:Int = 0\nConst xmlrpc_case_lower:Int = 1\nConst xmlrpc_case_upper:Int = 2\n\nExtern\n\tFunction XMLRPC_Create_STRUCT_XMLRPC_REQUEST_OUTPUT_OPTIONS:Byte Ptr(version:Int)\n'\tFunction XMLRPC_Delete_Request_Output_Options(options:Byte Ptr)\nEnd Extern\n\nExtern \"C\"\n\n\tFunction XMLRPC_RequestNew:Byte Ptr()\n\tFunction XMLRPC_RequestFree(request:Byte Ptr, bFreeIO:Int)\n\tFunction XMLRPC_RequestSetMethodName:Byte Ptr(request:Byte Ptr, methodName:Byte Ptr)\n\tFunction XMLRPC_RequestGetMethodName:Byte Ptr(request:Byte Ptr)\n\tFunction XMLRPC_RequestSetRequestType:Int(request:Byte Ptr, iType:Int)\n\tFunction XMLRPC_RequestGetRequestType:Int(request:Byte Ptr)\n\tFunction XMLRPC_RequestSetData:Byte Ptr(request:Byte Ptr, data:Byte Ptr)\n\tFunction XMLRPC_RequestGetData:Byte Ptr(request:Byte Ptr)\n\n\tFunction XMLRPC_REQUEST_ToXML:Byte Ptr(request:Byte Ptr, buf_len:Byte Ptr)\n\tFunction XMLRPC_REQUEST_FromXML:Byte Ptr(in_buf:Byte Ptr, length:Int, in_options:Byte Ptr)\n\tFunction XMLRPC_VALUE_ToXML:Byte Ptr(val:Int, buf_len:Byte Ptr)\n\tFunction XMLRPC_VALUE_FromXML:Byte Ptr(in_buf:Byte Ptr, length:Int, in_options:Byte Ptr)\n\n\tFunction XMLRPC_RequestSetOutputOptions:Byte Ptr(request:Byte Ptr, output:Byte Ptr)\n\tFunction XMLRPC_RequestGetOutputOptions:Byte Ptr(request:Byte Ptr)\n\n\tFunction XMLRPC_CreateVector:Byte Ptr(id:String, iType:Int)\n\tFunction XMLRPC_AddValueToVector:Int(target:Byte Ptr, source:Byte Ptr)\n\tFunction XMLRPC_VectorSize:Int(value:Byte Ptr)\n\tFunction XMLRPC_VectorRewind:Byte Ptr(value:Byte Ptr)\n\tFunction XMLRPC_VectorNext:Byte Ptr(value:Byte Ptr)\n\t\n\tFunction XMLRPC_CreateValueBoolean:Byte Ptr(id:Byte Ptr, truth:Int)\n\tFunction XMLRPC_CreateValueBase64:Byte Ptr(id:Byte Ptr, s:Byte Ptr, length:Int)\n\tFunction XMLRPC_CreateValueDateTime:Byte Ptr(id:Byte Ptr, time:Long)\n\tFunction XMLRPC_CreateValueDateTime_ISO8601:Byte Ptr(id:Byte Ptr, s:Byte Ptr)\n\tFunction XMLRPC_CreateValueDouble:Byte Ptr(id:Byte Ptr, f:Double)\n\tFunction XMLRPC_CreateValueInt:Byte Ptr(id:Byte Ptr, i:Int)\n\tFunction XMLRPC_CreateValueEmpty:Byte Ptr()\n\tFunction XMLRPC_CreateValueString:Byte Ptr(id:Byte Ptr, s:Byte Ptr, length:Int)\n\n\tFunction XMLRPC_RequestSetError:Int(request:Byte Ptr, error:Int)\n\tFunction XMLRPC_RequestGetError:Int(request:Byte Ptr)\n\n\tFunction XMLRPC_VectorGetValueWithID_Case:Byte Ptr(vector:Byte Ptr, id:Byte Ptr, id_case:Int)\n\t\n\tFunction XMLRPC_GetValueType:Int(v:Byte Ptr)\n\t'XMLRPC_VALUE_TYPE_EASY XMLRPC_GetValueTypeEasy(XMLRPC_VALUE v);\n\t'XMLRPC_VECTOR_TYPE XMLRPC_GetVectorType(XMLRPC_VALUE v);\n\t\n\tFunction XMLRPC_GetValueString:Byte Ptr(value:Byte Ptr)\n\tFunction XMLRPC_GetValueStringLen:Int(value:Byte Ptr)\n\tFunction XMLRPC_GetValueInt:Int(value:Byte Ptr)\n\tFunction XMLRPC_GetValueBoolean:Int(value:Byte Ptr)\n\tFunction XMLRPC_GetValueDouble:Double(value:Byte Ptr)\n\tFunction XMLRPC_GetValueBase64:Byte Ptr(value:Byte Ptr)\n\tFunction XMLRPC_GetValueDateTime:Long(value:Byte Ptr)\n\tFunction XMLRPC_GetValueDateTime_ISO8601:Byte Ptr(value:Byte Ptr)\n\tFunction XMLRPC_GetValueID:Byte Ptr(value:Byte Ptr)\n\t\n\tFunction XMLRPC_ValueIsFault:Int(value:Byte Ptr)\n\tFunction XMLRPC_ResponseIsFault(response:Byte Ptr)\n\tFunction XMLRPC_GetValueFaultCode:Int(value:Byte Ptr)\n\tFunction XMLRPC_GetResponseFaultCode:Int(response:Byte Ptr)\n\tFunction XMLRPC_GetValueFaultString:Byte Ptr(value:Byte Ptr)\n\tFunction XMLRPC_GetResponseFaultString:Byte Ptr(response:Byte Ptr)\n\tFunction XMLRPC_Free(mem:Byte Ptr)\n\tFunction XMLRPC_GetVersionString:Byte Ptr()\nRem\n\n\nXMLRPC_VALUE XMLRPC_UtilityCreateFault(int fault_code, const char* fault_string);\n\n\/* Get Values *\/\n#define XMLRPC_VectorGetStringWithID(vector, id) XMLRPC_GetValueString(XMLRPC_VectorGetValueWithID(vector, id))\n#define XMLRPC_VectorGetBase64WithID(vector, id) XMLRPC_GetValueBase64(XMLRPC_VectorGetValueWithID(vector, id))\n#define XMLRPC_VectorGetDateTimeWithID(vector, id) XMLRPC_GetValueDateTime(XMLRPC_VectorGetValueWithID(vector, id))\n#define XMLRPC_VectorGetDoubleWithID(vector, id) XMLRPC_GetValueDouble(XMLRPC_VectorGetValueWithID(vector, id))\n#define XMLRPC_VectorGetIntWithID(vector, id) XMLRPC_GetValueInt(XMLRPC_VectorGetValueWithID(vector, id))\n#define XMLRPC_VectorGetBooleanWithID(vector, id) XMLRPC_GetValueBoolean(XMLRPC_VectorGetValueWithID(vector, id))\nEndrem\nEnd Extern\n\nFunction XMLRPC_VectorGetValueWithID:Byte Ptr(vector:Byte Ptr, id:String)\n\tReturn XMLRPC_VectorGetValueWithID_Case(vector, id.ToCString(), xmlrpc_case_sensitive)\nEnd Function\n\nFunction XMLRPC_VectorAppendString:Int(vector:Byte Ptr, id:String, s:String, length:Int = 0)\n\tReturn XMLRPC_AddValueToVector(vector, XMLRPC_CreateValueString(id.ToCString(), s.ToCString(), length))\nEnd Function\n\nFunction XMLRPC_VectorAppendBase64:Int(vector:Byte Ptr, id:String, s:String, length:Int = 0)\n\tReturn XMLRPC_AddValueToVector(vector, XMLRPC_CreateValueBase64(id.ToCString(), s.ToCString(), length))\nEnd Function\n\nFunction XMLRPC_VectorAppendDateTime:Int(vector:Byte Ptr, id:Byte Ptr, time:Long)\n\tReturn XMLRPC_AddValueToVector(vector, XMLRPC_CreateValueDateTime(id, time))\nEnd Function\n\nFunction XMLRPC_VectorAppendDateTime_ISO8601:Int(vector:Byte Ptr, id:String, s:String)\n\tReturn XMLRPC_AddValueToVector(vector, XMLRPC_CreateValueDateTime_ISO8601(id.ToCString(), s.ToCString()))\nEnd Function\n\nFunction XMLRPC_VectorAppendDouble:Int(vector:Byte Ptr, id:String, f:Double)\n\tReturn XMLRPC_AddValueToVector(vector, XMLRPC_CreateValueDouble(id.ToCString(), f))\nEnd Function\n\nFunction XMLRPC_VectorAppendInt:Int(vector:Byte Ptr, id:String, i:Int)\n\tReturn XMLRPC_AddValueToVector(vector, XMLRPC_CreateValueInt(id.ToCString(), i))\nEnd Function\n\nFunction XMLRPC_VectorAppendBoolean:Int(vector:Byte Ptr, id:String, i:Int)\n\tReturn XMLRPC_AddValueToVector(vector, XMLRPC_CreateValueBoolean(id.ToCString(), i))\nEnd Function\nrem\n\/****s* VALUE\/XMLRPC_REQUEST_INPUT_OPTIONS\n * NAME\n * XMLRPC_REQUEST_INPUT_OPTIONS\n * NOTES\n * Defines options for reading in xml data\n * SEE ALSO\n * XMLRPC_VERSION\n * XML_ELEM_INPUT_OPTIONS\n * XMLRPC_REQUEST_From_XML ()\n * SOURCE\n *\/\ntypedef struct _xmlrpc_request_input_options {\n STRUCT_XML_ELEM_INPUT_OPTIONS xml_elem_opts; \/* xml_element specific output options *\/\n} STRUCT_XMLRPC_REQUEST_INPUT_OPTIONS, *XMLRPC_REQUEST_INPUT_OPTIONS;\n\/******\/\n\n\/****s* VALUE\/XMLRPC_ERROR\n * NAME\n * XMLRPC_ERROR\n * NOTES\n * For the reporting and handling of errors\n * SOURCE\n *\/\ntypedef struct _xmlrpc_error {\n XMLRPC_ERROR_CODE code;\n STRUCT_XML_ELEM_ERROR xml_elem_error; \/* xml_element errors (parser errors) *\/\n} STRUCT_XMLRPC_ERROR, *XMLRPC_ERROR;\n\/******\/\nendrem\n\n\nRem\n\tString conversion stuff below. Shamelessly stolen from Brucey :-)\nEnd Rem\n\nExtern\n\tFunction _strlen:Int(s:Byte Ptr) = \"strlen\"\nEnd Extern\n\n' Convert from Max to UTF8\nFunction convertISO8859toUTF8:String(text:String)\n\tIf Not text Then\n\t\tReturn \"\"\n\tEnd If\n\t\n\tLocal l:Int = text.length\n\tIf l = 0 Then\n\t\tReturn \"\"\n\tEnd If\n\t\n\tLocal count:Int = 0\n\tLocal s:Byte[] = New Byte[l * 3]\n\t\n\tFor Local i:Int = 0 Until l\n\t\tLocal char:Int = text[i]\n\n\t\tIf char < 128 Then\n\t\t\ts[count] = char\n\t\t\tcount:+ 1\n\t\t\tContinue\n\t\tElse If char<2048\n\t\t\ts[count] = char\/64 | 192\n\t\t\tcount:+ 1\n\t\t\ts[count] = char Mod 64 | 128\n\t\t\tcount:+ 1\n\t\t\tContinue\n\t\tElse\n\t\t\ts[count] = char\/4096 | 224\n\t\t\tcount:+ 1\n\t\t\ts[count] = char\/64 Mod 64 | 128\n\t\t\tcount:+ 1\n\t\t\ts[count] = char Mod 64 | 128\n\t\t\tcount:+ 1\n\t\t\tContinue\n\t\tEndIf\n\t\t\n\tNext\n\n\tReturn String.fromBytes(s, count)\nEnd Function\n\n' Convert from UTF8 to Max\nFunction convertUTF8toISO8859:String(s:Byte Ptr)\n\n\tLocal l:Int = _strlen(s)\n\n\tLocal b:Short[] = New Short[l]\n\tLocal bc:Int = -1\n\tLocal c:Int\n\tLocal d:Int\n\tLocal e:Int\n\tFor Local i:Int = 0 Until l\n\n\t\tbc:+1\n\t\tc = s[i]\n\t\tIf c<128 \n\t\t\tb[bc] = c\n\t\t\tContinue\n\t\tEnd If\n\t\ti:+1\n\t\td=s[i]\n\t\tIf c<224 \n\t\t\tb[bc] = (c-192)*64+(d-128)\n\t\t\tContinue\n\t\tEnd If\n\t\ti:+1\n\t\te = s[i]\n\t\tIf c < 240 \n\t\t\tb[bc] = (c-224)*4096+(d-128)*64+(e-128)\n\t\t\tIf b[bc] = 8233 Then\n\t\t\t\tb[bc] = 10\n\t\t\tEnd If\n\t\t\tContinue\n\t\tEnd If\n\tNext\n\n\tReturn String.fromshorts(b, bc + 1)\nEnd Function\n\nFunction sizedUTF8toISO8859:String(s:Byte Ptr, size:Int)\n\n\tLocal l:Int = size\n\tLocal b:Short[] = New Short[l]\n\tLocal bc:Int = -1\n\tLocal c:Int\n\tLocal d:Int\n\tLocal e:Int\n\tFor Local i:Int = 0 Until l\n\n\t\tc = s[i]\n\t\tIf c = 0 Continue\n\n\t\tbc:+1\n\t\tIf c<128\n\t\t\tb[bc] = c\n\t\t\tContinue\n\t\tEnd If\n\t\ti:+1\n\t\td=s[i]\n\t\tIf c<224 \n\t\t\tb[bc] = (c-192)*64+(d-128)\n\t\t\tContinue\n\t\tEnd If\n\t\ti:+1\n\t\te = s[i]\n\t\tIf c < 240 \n\t\t\tb[bc] = (c-224)*4096+(d-128)*64+(e-128)\n\t\t\tIf b[bc] = 8233 Then\n\t\t\t\tb[bc] = 10\n\t\t\tEnd If\n\t\t\tContinue\n\t\tEnd If\n\tNext\n\n\tReturn String.fromshorts(b, bc + 1)\nEnd Function","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"880f215c6c0a4d970eb2d35064db658824ab31f3","subject":"ipc protocol not supported on Windows","message":"ipc protocol not supported on Windows\n","repos":"Htbaa\/zmq.mod,Htbaa\/zmq.mod","old_file":"examples\/wuserver.bmx","new_file":"examples\/wuserver.bmx","new_contents":"Rem\n\tWeather Update server\n\tBinds PUB socket to tcp:\/\/127.0.0.1:6000\n\tPublishes random weather updates\nEnd Rem\nSuperStrict\nImport htbaapub.zmq\n\nLocal context:TZMQ_Context = New TZMQ_Context.Create(1)\nLocal publisher:TZMQ_Socket = context.Socket(ZMQ_PUB)\npublisher.Bind(\"tcp:\/\/127.0.0.1:6000\")\n?Not Win32\npublisher.Bind(\"ipc:\/\/weather.ipc\")\n?\n\nRepeat\n\tLocal zipcode:Int = Rand(1, 100000)\n\tLocal temperature:Int = Rand(1,215) - 80\n\tLocal relhumidity:Int = Rand(1,50) + 10\n\tLocal update:String = \" \".Join([String(zipcode), String(temperature), String(relhumidity)])\n\tpublisher.Send(update)\nForever\n","old_contents":"Rem\n\tWeather Update server\n\tBinds PUB socket to tcp:\/\/127.0.0.1:6000\n\tPublishes random weather updates\nEnd Rem\nSuperStrict\nImport htbaapub.zmq\n\nLocal context:TZMQ_Context = New TZMQ_Context.Create(1)\nLocal publisher:TZMQ_Socket = context.Socket(ZMQ_PUB)\npublisher.Bind(\"tcp:\/\/127.0.0.1:6000\")\npublisher.Bind(\"ipc:\/\/weather.ipc\")\n\nRepeat\n\tLocal zipcode:Int = Rand(1, 100000)\n\tLocal temperature:Int = Rand(1,215) - 80\n\tLocal relhumidity:Int = Rand(1,50) + 10\n\tLocal update:String = \" \".Join([String(zipcode), String(temperature), String(relhumidity)])\n\tpublisher.Send(update)\nForever\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"0a3b62b9b32fa9044d019b586e5bffb60ec4d9a2","subject":"Changed Content-type in TXMLRPC_Transport_Http from application\/x-www-form-urlencoded to application\/octet-stream as some XML-RPC servers can be picky about it. Newline (\\r\\n) is now done in a more proper way as well.","message":"Changed Content-type in TXMLRPC_Transport_Http from application\/x-www-form-urlencoded to application\/octet-stream as some XML-RPC servers can be picky about it. Newline (\\r\\n) is now done in a more proper way as well.\n","repos":"Htbaa\/xmlrpc.mod,Htbaa\/xmlrpc.mod,Htbaa\/xmlrpc.mod,Htbaa\/xmlrpc.mod,Htbaa\/xmlrpc.mod","old_file":"transport.bmx","new_file":"transport.bmx","new_contents":"Rem\n\tbbdoc: Transport interface. Use this as a blueprint for any other transport layers\nEnd Rem\nType TXMLRPC_Transport_Interface Abstract\n\tRem\n\t\tbbdoc: Send request to XML-RPC server\n\tEnd Rem\n\tMethod DoRequest:String(message:String) Abstract\nEnd Type\n\nRem\n\tbbdoc: A Dummy transport type. Do not use, deprecated\nEnd Rem\nType TXMLRPC_Transport_Dummy Extends TXMLRPC_Transport_Interface\n\tMethod DoRequest:String(message:String)\n\t\tReturn message\n\tEnd Method\nEnd Type\n\nRem\n\tbbdoc: Exception for TXMLRPC_Transport_Http\nEnd Rem\nType TXMLRPC_Transport_Http_Exception Extends TXMLRPC_Exception\nEnd Type\n\nRem\n\tbbdoc: Simple HTTP transport\n\tabout: Needs HTTP error handling. Implementation is very simple at the moment. Only a simple HTTP request is possible. Authenticated pages or HTTPS isn't supported. For HTTPS, write your own.\nEnd Rem\nType TXMLRPC_Transport_Http Extends TXMLRPC_Transport_Interface\n\tField host:String\n\tField path:String\n\tField port:Int\n\n\tRem\n\t\tbbdoc: Set useragent for HTTP request.\n\t\tabout: This string will be used to identify the client with the XML-RPC server\n\tEnd rem\n\tField userAgent:String = \"htbaapub.mod\/xmlrpc.mod\"\n\t\n\tRem\n\t\tbbdoc: Create TXMLRPC_Transport_Http object\n\tEnd Rem\n\tMethod Create:TXMLRPC_Transport_Http(host:String, path:String, port:Int = 80)\n\t\tSelf.host = host\n\t\tSelf.path = path\n\t\tSelf.port = port\n\t\tReturn Self\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Send request over HTTP\n\tEnd Rem\n\tMethod DoRequest:String(message:String)\n\t\tLocal socket:TSocket = CreateTCPSocket()\n\t\t\n\t\tIf Not ConnectSocket(socket, HostIp(Self.host), Self.port)\n\t\t\tThrow New TXMLRPC_Transport_Http_Exception.Create(\"Couldn't open socket to \" + Self.host)\n\t\tEnd If\n\t\t\n\t\tLocal stream:TSocketStream = CreateSocketStream(socket)\n\t\t\n\t\tWriteLine(stream, \"POST \" + Self.path + \" HTTP\/1.0\")\n\t\tWriteLine(stream, \"Accept: *\/*\")\n\t\tWriteLine(stream, \"Host: \" + Self.host)\n\t\tWriteLine(stream, \"Content-type: application\/octet-stream\")\n\t\tWriteLine(stream, \"User-agent: \" + Self.userAgent)\n\t\tWriteLine(stream, \"Pragma: no-cache\")\n\t\tWriteLine(stream, \"Content-length: \" + message.Length)\n\t\tWriteLine(stream, \"Connection: keep-alive\")\n\t\tWriteLine(stream, \"\")\n\t\tWriteLine(stream, message)\n\n\t\tFlushStream(stream)\n\n\t\tLocal buffer:String\n\t\tWhile Not Eof(stream)\n\t\t\tLocal line:String = ReadLine(stream)\n\t\t\tbuffer:+line + \"~n\"\n\t\tWend\n\n\t\tCloseSocket(socket)\n\t\tReturn buffer\n\tEnd Method\nEnd Type\n","old_contents":"Rem\n\tbbdoc: Transport interface. Use this as a blueprint for any other transport layers\nEnd Rem\nType TXMLRPC_Transport_Interface Abstract\n\tRem\n\t\tbbdoc: Send request to XML-RPC server\n\tEnd Rem\n\tMethod DoRequest:String(message:String) Abstract\nEnd Type\n\nRem\n\tbbdoc: A Dummy transport type. Do not use, deprecated\nEnd Rem\nType TXMLRPC_Transport_Dummy Extends TXMLRPC_Transport_Interface\n\tMethod DoRequest:String(message:String)\n\t\tReturn message\n\tEnd Method\nEnd Type\n\nRem\n\tbbdoc: Exception for TXMLRPC_Transport_Http\nEnd Rem\nType TXMLRPC_Transport_Http_Exception Extends TXMLRPC_Exception\nEnd Type\n\nRem\n\tbbdoc: Simple HTTP transport\n\tabout: Needs HTTP error handling. Implementation is very simple at the moment. Only a simple HTTP request is possible. Authenticated pages or HTTPS isn't supported. For HTTPS, write your own.\nEnd Rem\nType TXMLRPC_Transport_Http Extends TXMLRPC_Transport_Interface\n\tField host:String\n\tField path:String\n\tField port:Int\n\n\tRem\n\t\tbbdoc: Set useragent for HTTP request.\n\t\tabout: This string will be used to identify the client with the XML-RPC server\n\tEnd rem\n\tField userAgent:String = \"htbaapub.mod\/xmlrpc.mod\"\n\t\n\tRem\n\t\tbbdoc: Create TXMLRPC_Transport_Http object\n\tEnd Rem\n\tMethod Create:TXMLRPC_Transport_Http(host:String, path:String, port:Int = 80)\n\t\tSelf.host = host\n\t\tSelf.path = path\n\t\tSelf.port = port\n\t\tReturn Self\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Send request over HTTP\n\tEnd Rem\n\tMethod DoRequest:String(message:String)\n\t\tLocal socket:TSocket = CreateTCPSocket()\n\t\t\n\t\tIf Not ConnectSocket(socket, HostIp(Self.host), Self.port)\n\t\t\tThrow New TXMLRPC_Transport_Http_Exception.Create(\"Couldn't open socket to \" + Self.host)\n\t\tEnd If\n\t\t\n\t\tLocal stream:TSocketStream = CreateSocketStream(socket)\n\n\t\tWriteLine(stream, \"POST \" + Self.path + \" HTTP\/1.0\")\n\t\tWriteLine(stream, \"Accept: *\/*\")\n\t\tWriteLine(stream, \"Host: \" + Self.host)\n\t\tWriteLine(stream, \"Content-type: application\/x-www-form-urlencoded\")\n\t\tWriteLine(stream, \"User-agent: \" + Self.userAgent)\n\t\tWriteLine(stream, \"Pragma: no-cache\")\n\t\tWriteLine(stream, \"Connection: keep-alive\")\n\t\tWriteLine(stream, \"Content-length: \" + message.Length + \"~n\")\n\n\t\tWriteLine(stream, message + \"~n~n\")\n\n\t\tFlushStream(stream)\n\n\t\tLocal buffer:String\n\t\tWhile Not Eof(stream)\n\t\t\tLocal line:String = ReadLine(stream)\n\t\t\tbuffer:+line + \"~n\"\n\t\tWend\n\n\t\tCloseSocket(socket)\n\t\tReturn buffer\n\tEnd Method\nEnd Type\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"f322f0f9ab5d885658222a2087b58399a2ed532c","subject":"Removing leftover DebugLog","message":"Removing leftover DebugLog\n","repos":"kfprimm\/maxb3d,kfprimm\/maxb3d","old_file":"primitives.mod\/primitives.bmx","new_file":"primitives.mod\/primitives.bmx","new_contents":"\nStrict\n\nRem\n\tbbdoc: Primitive mesh loader for MaxB3D.\nEnd Rem\nModule MaxB3D.Primitives\nModuleInfo \"Author: Kevin Primm\"\nModuleInfo \"License: MIT\"\n\nImport MaxB3D.Core\n\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction CreateCube:TMesh(parent:TEntity=Null)\n\tReturn _currentworld.AddMesh(\"\/\/cube\",parent)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction CreateCone:TMesh(segments=8,solid=True,parent:TEntity=Null)\n\tReturn _currentworld.AddMesh(\"\/\/cone(\"+segments+\",\"+solid+\")\",parent)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction CreateCylinder:TMesh(segments=8,solid=True,parent:TEntity=Null)\n\tReturn _currentworld.AddMesh(\"\/\/cylinder(\"+segments+\",\"+solid+\")\",parent)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction CreateSphere:TMesh(segments=8,parent:TEntity=Null)\n\tReturn _currentworld.AddMesh(\"\/\/sphere(\"+segments+\")\",parent)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction CreateTorus:TMesh(radius#,width#,segments,sides,parent:TEntity=Null)\n\tReturn _currentworld.AddMesh(\"\/\/torus(\"+radius+\",\"+width+\",\"+segments+\",\"+sides+\")\",parent)\nEnd Function\n\nType TMeshLoaderPrimitives Extends TMeshLoader\n\tMethod Run(mesh:TMesh,stream:TStream,url:Object)\n\t\tLocal str$=String(url)\n\t\tLocal params$[]=str[str.Find(\"(\")+1..str.FindLast(\")\")].Split(\",\")\n\t\t\n\t\tLocal name$ = str[str.Find(\"\/\/\")+2..]\n\t\tIf str.Find(\"(\") > -1 name = name[..name.Find(\"(\")]\n\n\t\tSelect name\n\t\tCase \"sphere\"\n\t\t\tLocal segments=Int(params[0])\n\t\t\tIf segments<2 Or segments>100 Then Return Null\n\t\t\t\n\t\t\t'Vertex count\n\t\t\t'((segments*2)*4) '2\n\t\t\t'((segments*2)*6)+((segments*2)*((segments-2)*4)) '>2\n\t\t\t\n\t\t\t'Triangle count\n\t\t\t'(segments*2)*2\n\t\t\t'(segments*2)*2+(segments*2)*(segments-2)*2\n\n\t\t\tLocal vertexcount=4*segments*(3+((segments-2)*2))\n\t\t\tLocal trianglecount=segments*4*(1+(segments-2))\n\t\t\tIf segments=2\n\t\t\t\tvertexcount=segments*8\n\t\t\t\ttrianglecount=segments*4\n\t\t\tEndIf\n\t\t\t\n\t\t\tLocal surface:TSurface=mesh.AddSurface(Null,vertexcount,trianglecount)\n\t\t\t\n\t\t\tLocal div#=Float(360.0\/(segments*2))\n\t\t\tLocal height#=1.0\n\t\t\tLocal upos#=1.0\n\t\t\tLocal udiv#=Float(1.0\/(segments*2))\n\t\t\tLocal vdiv#=Float(1.0\/segments)\n\t\t\tLocal RotAngle#=90\t\n\t\t\t\n\t\t\tIf segments=2\n\t\t\t\tFor Local i=1 To (segments*2)\n\t\t\t\t\tLocal np=(i-1)*4+0,sp=np+1\n\t\t\t\t\tsurface.SetCoords(np,0.0,height,0.0);surface.SetTexCoords(np,upos#-(udiv#\/2.0),0) 'northpole\t\t\t\t\t\n\t\t\t\t\tsurface.SetCoords(sp,0.0,-height,0.0);surface.SetTexCoords(sp,upos#-(udiv#\/2.0),1) 'southpole\n\t\t\t\t\tLocal XPos#=-Cos(RotAngle#)\n\t\t\t\t\tLocal ZPos#=Sin(RotAngle#)\n\t\t\t\t\tLocal v0=sp+1\n\t\t\t\t\tsurface.SetCoords(v0,XPos#,0,ZPos#)\n\t\t\t\t\tsurface.SetTexCoords(v0,upos#,0.5)\n\t\t\t\t\tRotAngle#=RotAngle#+div#\n\t\t\t\t\tIf RotAngle#>=360.0 Then RotAngle#=RotAngle#-360.0\n\t\t\t\t\tXPos#=-Cos(RotAngle#)\n\t\t\t\t\tZPos#=Sin(RotAngle#)\n\t\t\t\t\tupos#=upos#-udiv#\n\t\t\t\t\tLocal v1=v0+1\n\t\t\t\t\tsurface.SetCoords(v1,XPos#,0,ZPos#)\n\t\t\t\t\tsurface.SetTexCoords(v1,upos#,0.5)\n\t\t\t\t\t\n\t\t\t\t\tsurface.SetTriangle((i-1)*2+0,np,v0,v1)\n\t\t\t\t\tsurface.SetTriangle((i-1)*2+1,v1,v0,sp)\t\n\t\t\t\tNext\t\n\t\t\tElse\n\t\t\t\tFor Local i=1 To (segments*2)\t\n\t\t\t\t\tLocal np=(i-1)*6+0,sp=np+1\n\t\t\t\t\tsurface.SetCoords(np,0.0,height,0.0)\n\t\t\t\t\tsurface.SetTexCoords(np,upos#-(udiv#\/2.0),0)'northpole\n\t\t\t\t\tsurface.SetCoords(sp,0.0,-height,0.0)\n\t\t\t\t\tsurface.SetTexCoords(sp,upos#-(udiv#\/2.0),1)'southpole\n\t\t\t\t\t\n\t\t\t\t\tLocal YPos#=Cos(div#)\n\t\t\t\t\t\n\t\t\t\t\tLocal XPos#=-Cos(RotAngle#)*(Sin(div#))\n\t\t\t\t\tLocal ZPos#=Sin(RotAngle#)*(Sin(div#))\n\t\t\t\t\t\n\t\t\t\t\tLocal v0t=sp+1\n\t\t\t\t\tsurface.SetCoords(v0t,XPos#,YPos#,ZPos#)\n\t\t\t\t\tsurface.SetTexCoords(v0t,upos#,vdiv#)\n\t\t\t\t\tLocal v0b=v0t+1\n\t\t\t\t\tsurface.SetCoords(v0b,XPos#,-YPos#,ZPos#)\n\t\t\t\t\tsurface.SetTexCoords(v0b,upos#,1-vdiv#)\n\t\t\t\t\t\n\t\t\t\t\tRotAngle#=RotAngle#+div#\n\t\t\t\t\t\n\t\t\t\t\tXPos#=-Cos(RotAngle#)*(Sin(div#))\n\t\t\t\t\tZPos#=Sin(RotAngle#)*(Sin(div#))\n\t\t\t\t\t\n\t\t\t\t\tupos#=upos#-udiv#\n\t\t\t\n\t\t\t\t\tLocal v1t=v0b+1\n\t\t\t\t\tsurface.SetCoords(v1t,XPos#,YPos#,ZPos#)\n\t\t\t\t\tsurface.SetTexCoords(v1t,upos#,vdiv#)\n\t\t\t\t\tLocal v1b=v1t+1\n\t\t\t\t\tsurface.SetCoords(v1b,XPos#,-YPos#,ZPos#)\n\t\t\t\t\tsurface.SetTexCoords(v1b,upos#,1-vdiv#)\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\tsurface.SetTriangle((i-1)*2+0,np,v0t,v1t)\n\t\t\t\t\tsurface.SetTriangle((i-1)*2+1,v1b,v0b,sp)\t\t\t\t\t\n\t\t\t\tNext\n\t\t\t\n\t\t\t\tupos#=1.0\n\t\t\t\tRotAngle#=90\n\t\t\t\tFor Local i=1 To (segments*2)\n\t\t\t\t\n\t\t\t\t\tLocal mult#=1\n\t\t\t\t\tLocal YPos#=Cos(div#*(mult#))\n\t\t\t\t\tLocal YPos2#=Cos(div#*(mult#+1.0))\n\t\t\t\t\tLocal Thisvdiv#=vdiv#\n\t\t\t\t\tFor Local j=1 To (segments-2)\t\t\t\n\t\t\t\t\t\tLocal XPos#=-Cos(RotAngle#)*(Sin(div#*(mult#)))\n\t\t\t\t\t\tLocal ZPos#=Sin(RotAngle#)*(Sin(div#*(mult#)))\n\t\t\t\n\t\t\t\t\t\tLocal XPos2#=-Cos(RotAngle#)*(Sin(div#*(mult#+1.0)))\n\t\t\t\t\t\tLocal ZPos2#=Sin(RotAngle#)*(Sin(div#*(mult#+1.0)))\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\tLocal v0t=(segments*2)*6+((i-1)*(segments-2)*4)+((j-1)*4),v0b=v0t+1\n\t\t\t\t\t\tsurface.SetCoords(v0t,XPos#,YPos#,ZPos#)\n\t\t\t\t\t\tsurface.SetTexCoords(v0t,upos#,Thisvdiv#,0.0)\n\t\t\t\t\t\tsurface.SetCoords(v0b,XPos2#,YPos2#,ZPos2#)\t\t\t\t\t\t\n\t\t\t\t\t\tsurface.SetTexCoords(v0b,upos#,Thisvdiv#+vdiv#,0.0)\n\t\t\t\t\t\n\t\t\t\t\t\tLocal tempRotAngle#=RotAngle#+div#\n\t\t\t\t\t\n\t\t\t\t\t\tXPos#=-Cos(tempRotAngle#)*(Sin(div#*(mult#)))\n\t\t\t\t\t\tZPos#=Sin(tempRotAngle#)*(Sin(div#*(mult#)))\n\t\t\t\t\t\t\n\t\t\t\t\t\tXPos2#=-Cos(tempRotAngle#)*(Sin(div#*(mult#+1.0)))\n\t\t\t\t\t\tZPos2#=Sin(tempRotAngle#)*(Sin(div#*(mult#+1.0)))\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\tLocal temp_upos#=upos-udiv\n\t\t\t\n\t\t\t\t\t\tLocal v1t=v0b+1,v1b=v1t+1\n\t\t\t\t\t\tsurface.SetCoords(v1t,XPos,YPos,ZPos)\n\t\t\t\t\t\tsurface.SetTexCoords(v1t,temp_upos,Thisvdiv,0.0)\n\t\t\t\t\t\tsurface.SetCoords(v1b,XPos2,YPos2,ZPos2)\n\t\t\t\t\t\tsurface.SetTexCoords(v1b,temp_upos,Thisvdiv+vdiv,0.0)\n\t\t\t\t\t\t\n\t\t\t\t\t\tsurface.SetTriangle((segments*2)*2+((i-1)*(segments-2)*2)+((j-1)*2)+0,v1t,v0t,v0b)\n\t\t\t\t\t\tsurface.SetTriangle((segments*2)*2+((i-1)*(segments-2)*2)+((j-1)*2)+1,v1b,v1t,v0b)\n\t\t\t\t\t\t\n\t\t\t\t\t\tThisvdiv#=Thisvdiv#+vdiv#\t\t\t\n\t\t\t\t\t\tmult#=mult#+1\n\t\t\t\t\t\tYPos#=Cos(div#*(mult#))\n\t\t\t\t\t\tYPos2#=Cos(div#*(mult#+1.0))\n\t\t\t\t\t\n\t\t\t\t\tNext\n\t\t\t\t\tupos#=upos#-udiv#\n\t\t\t\t\tRotAngle#=RotAngle#+div#\n\t\t\t\tNext\n\t\t\tEndIf\t\t\t\n\t\t\t\n\t\t\tmesh.UpdateNormals() \n\t\t\t'mesh.ForEachSurfaceDo FlipNormals\n\t\t\tReturn True \n\t\tCase \"cylinder\"\n\t\t\tLocal ringsegments=0\n\t\t\t\n\t\t\tLocal segments=Int(params[0]),solid=Int(params[1])\n\t\t\t\t\n\t\t\tLocal tr,tl,br,bl\n\t\t\tLocal ts0,ts1,newts\n\t\t\tLocal bs0,bs1,newbs\n\t\t\tIf segments<3 Or segments>100 Then Return Null\n\t\t\tIf ringsegments<0 Or ringsegments>100 Then Return Null\n\t\t\t\n\t\t\tLocal surface:TSurface=mesh.AddSurface(Null,1000,1000)\n\t\t\tLocal solidsurface:TSurface\n\t\t\tIf solid=True\n\t\t\t\tsolidsurface=mesh.AddSurface(Null,1000,1000)\n\t\t\tEndIf\n\t\t\tLocal div#=Float(360.0\/(segments))\n\t\t\t\n\t\t\tLocal height#=1.0\n\t\t\tLocal ringSegmentHeight#=(height#*2.0)\/(ringsegments+1)\n\t\t\tLocal upos#=1.0\n\t\t\tLocal udiv#=Float(1.0\/(segments))\n\t\t\tLocal vpos#=1.0\n\t\t\tLocal vdiv#=Float(1.0\/(ringsegments+1))\n\t\t\t\n\t\t\tLocal SideRotAngle#=90\n\t\t\t\n\t\t\tLocal tRing[segments+1]\n\t\t\tLocal bRing[segments+1]\n\t\t\t\n\t\t\tIf solid=True\n\t\t\t\tLocal xpos#=-Cos(SideRotAngle#)\n\t\t\t\tLocal zpos#=Sin(SideRotAngle#)\n\t\t\t\n\t\t\t\tts0=solidsurface.AddVertex(xpos,height,zpos,xpos\/2.0+0.5,zpos\/2.0+0.5)\n\t\t\t\tbs0=solidsurface.AddVertex(xpos,-height,zpos,xpos\/2.0+0.5,zpos\/2.0+0.5)\n\t\t\t\t\n\t\t\t\tsolidsurface.SetTexCoords(ts0,xpos\/2.0+0.5,zpos\/2.0+0.5,0.0)\n\t\t\t\tsolidsurface.SetTexCoords(bs0,xpos\/2.0+0.5,zpos\/2.0+0.5,0.0)\n\t\t\t\n\t\t\t\tSideRotAngle=SideRotAngle+div\n\t\t\t\n\t\t\t\txpos#=-Cos(SideRotAngle#)\n\t\t\t\tzpos#=Sin(SideRotAngle#)\n\t\t\t\t\n\t\t\t\tts1=solidsurface.AddVertex(xpos#,height,zpos#,xpos#\/2.0+0.5,zpos#\/2.0+0.5)\n\t\t\t\tbs1=solidsurface.AddVertex(xpos#,-height,zpos#,xpos#\/2.0+0.5,zpos#\/2.0+0.5)\n\t\t\t\n\t\t\t\tsolidsurface.SetTexCoords(ts1,xpos#\/2.0+0.5,zpos#\/2.0+0.5,0.0)\n\t\t\t\tsolidsurface.SetTexCoords(bs1,xpos#\/2.0+0.5,zpos#\/2.0+0.5,0.0)\n\t\t\t\t\n\t\t\t\tFor Local i=1 To (segments-2)\n\t\t\t\t\tSideRotAngle#=SideRotAngle#+div#\n\t\t\t\n\t\t\t\t\txpos#=-Cos(SideRotAngle#)\n\t\t\t\t\tzpos#=Sin(SideRotAngle#)\n\t\t\t\t\t\n\t\t\t\t\tnewts=solidsurface.AddVertex(xpos#,height,zpos#,xpos#\/2.0+0.5,zpos#\/2.0+0.5)\n\t\t\t\t\tnewbs=solidsurface.AddVertex(xpos#,-height,zpos#,xpos#\/2.0+0.5,zpos#\/2.0+0.5)\n\t\t\t\t\t\n\t\t\t\t\tsolidsurface.SetTexCoords(newts,xpos#\/2.0+0.5,zpos#\/2.0+0.5,0.0)\n\t\t\t\t\tsolidsurface.SetTexCoords(newbs,xpos#\/2.0+0.5,zpos#\/2.0+0.5,0.0)\n\t\t\t\t\t\n\t\t\t\t\tsolidsurface.AddTriangle(ts0,ts1,newts)\n\t\t\t\t\tsolidsurface.AddTriangle(newbs,bs1,bs0)\n\t\t\t\t\n\t\t\t\t\tIf i<(segments-2)\n\t\t\t\t\t\tts1=newts\n\t\t\t\t\t\tbs1=newbs\n\t\t\t\t\tEndIf\n\t\t\t\tNext\n\t\t\tEndIf\n\t\t\t\n\t\t\tLocal thisHeight#=height#\n\t\t\t\n\t\t\tSideRotAngle#=90\n\t\t\tLocal xpos#=-Cos(SideRotAngle#)\n\t\t\tLocal zpos#=Sin(SideRotAngle#)\n\t\t\tLocal thisUPos#=upos#\n\t\t\tLocal thisVPos#=0\n\t\t\ttRing[0]=surface.AddVertex(xpos#,thisHeight,zpos#,thisUPos#,thisVPos#)\t\t\n\t\t\tsurface.SetTexCoords(tRing[0],thisUPos#,thisVPos#,0.0)\n\t\t\tFor Local i=0 To (segments-1)\n\t\t\t\tSideRotAngle#=SideRotAngle#+div#\n\t\t\t\txpos#=-Cos(SideRotAngle#)\n\t\t\t\tzpos#=Sin(SideRotAngle#)\n\t\t\t\tthisUPos#=thisUPos#-udiv#\n\t\t\t\ttRing[i+1]=surface.AddVertex(xpos#,thisHeight,zpos#,thisUPos#,thisVPos#)\n\t\t\t\tsurface.SetTexCoords(tRing[i+1],thisUPos#,thisVPos#,0.0)\n\t\t\tNext\t\n\t\t\t\n\t\t\tFor Local ring=0 To ringsegments\n\t\t\t\tLocal thisHeight=thisHeight-ringSegmentHeight#\n\t\t\t\t\n\t\t\t\tSideRotAngle#=90\n\t\t\t\txpos#=-Cos(SideRotAngle#)\n\t\t\t\tzpos#=Sin(SideRotAngle#)\n\t\t\t\tthisUPos#=upos#\n\t\t\t\tthisVPos#=thisVPos#+vdiv#\n\t\t\t\tbRing[0]=surface.AddVertex(xpos#,thisHeight,zpos#,thisUPos#,thisVPos#)\n\t\t\t\tsurface.SetTexCoords(bRing[0],thisUPos#,thisVPos#,0.0)\n\t\t\t\tFor Local i=0 To (segments-1)\n\t\t\t\t\tSideRotAngle#=SideRotAngle#+div#\n\t\t\t\t\txpos#=-Cos(SideRotAngle#)\n\t\t\t\t\tzpos#=Sin(SideRotAngle#)\n\t\t\t\t\tthisUPos#=thisUPos#-udiv#\n\t\t\t\t\tbRing[i+1]=surface.AddVertex(xpos#,thisHeight,zpos#,thisUPos#,thisVPos#)\n\t\t\t\t\tsurface.SetTexCoords(bRing[i+1],thisUPos#,thisVPos#,0.0)\n\t\t\t\tNext\n\t\t\t\t\n\t\t\t\tFor Local v=1 To (segments)\n\t\t\t\t\ttl=tRing[v]\n\t\t\t\t\ttr=tRing[v-1]\n\t\t\t\t\tbl=bRing[v]\n\t\t\t\t\tbr=bRing[v-1]\n\t\t\t\t\t\n\t\t\t\t\tsurface.AddTriangle(tl,tr,br)\n\t\t\t\t\tsurface.AddTriangle(bl,tl,br)\n\t\t\t\tNext\n\t\t\t\t\n\t\t\t\tFor Local v=0 To (segments)\n\t\t\t\t\ttRing[v]=bRing[v]\n\t\t\t\tNext\t\t\n\t\t\tNext\n\t\t\t\t\t\n\t\t\tmesh.UpdateNormals()\n\t\t\tReturn True\n\t\tCase \"cone\"\n\t\t\tLocal segments=Int(params[0]),solid=Int(params[1])\n\t\t\t\t\t\t\n\t\t\tIf segments<3 Or segments>100 Then Return Null\n\t\t\t\n\t\t\tLocal surface:TSurface=mesh.AddSurface(Null,1+segments*2,segments)\n\t\t\tLocal bottomsurface:TSurface\n\t\t\tIf solid bottomsurface=mesh.AddSurface(Null,1+segments,segments-1)\n\t\t\t\n\t\t\tLocal div#=Float(360.0\/(segments))\n\t\t\n\t\t\tLocal height#=1.0\n\t\t\tLocal upos#=1.0\n\t\t\tLocal udiv#=Float(1.0\/(segments))\n\t\t\tLocal angle#=90\t\n\t\t\n\t\t\tLocal xpos#=-Cos(angle)\n\t\t\tLocal zpos#=Sin(angle)\n\t\t\n\t\t\tsurface.SetCoords(0,0.0,height,0.0);surface.SetTexCoords(0,upos-(udiv\/2.0),0)\n\t\t\tsurface.SetCoords(1,xpos,-height,zpos);surface.SetTexCoords(1,upos,1)\n\t\t\n\t\t\tIf solid bottomsurface.SetCoords(0,xpos,-height,zpos);bottomsurface.SetTexCoords(0,xpos\/2.0+0.5,zpos\/2.0+0.5)\n\t\t\n\t\t\tangle:+div\n\t\t\n\t\t\txpos=-Cos(angle)\n\t\t\tzpos=Sin(angle)\n\t\t\t\t\t\t\n\t\t\tsurface.SetCoords(2,xpos,-height,zpos);surface.SetTexCoords(2,upos-udiv,1)\n\t\t\n\t\t\tIf solid bottomsurface.SetCoords(1,xpos,-height,zpos);bottomsurface.SetTexCoords(1,xpos\/2.0+0.5,zpos\/2.0+0.5)\n\t\t\t\n\t\t\tsurface.SetTriangle(0,2,0,1) 'br,top,bl\n\t\t\n\t\t\tFor Local i=1 To segments-1\n\t\t\t\tLocal v=1+(i*2)\n\t\t\t\tupos:-udiv\n\t\t\t\tsurface.SetCoords(v+0,0.0,height,0.0);surface.SetTexCoords(v+0,upos-(udiv\/2.0),0)\n\t\t\t\n\t\t\t\tangle:+div\n\t\t\n\t\t\t\txpos=-Cos(angle)\n\t\t\t\tzpos=Sin(angle)\n\t\t\t\t\n\t\t\t\tsurface.SetCoords(v+1,xpos,-height,zpos);surface.SetTexCoords(v+1,upos-udiv,1)\t\t\t\n\t\t\t\tsurface.SetTriangle(i,v+1,v+0,v-1)\n\t\t\t\t\n\t\t\t\tIf solid=True\n\t\t\t\t\tbottomsurface.SetCoords(i+1,xpos,-height,zpos);bottomsurface.SetTexCoords(i+1,xpos\/2.0+0.5,zpos\/2.0+0.5)\n\t\t\t\t\tbottomsurface.SetTriangle(i-1,i+1,i,0)\n\t\t\t\tEndIf\n\t\t\tNext\t\t\n\t\t\t\n\t\t\tmesh.UpdateNormals()\n\t\t\tReturn True\n\t\tCase \"cube\"\n\t\t\tLocal surface:TSurface=mesh.AddSurface(Null,24,12)\n\n\t\t\tFor Local i=0 To 3\n\t\t\t\tsurface.SetNormal(i,0,-1,0)\n\t\t\tNext\n\t\t\tsurface.SetCoords( 0, 1.0, 1.0,-1.0);surface.SetTexCoords( 0, 0.0, 0.0)\n\t\t\tsurface.SetCoords( 1,-1.0, 1.0,-1.0);surface.SetTexCoords( 1, 0.0, 1.0)\n\t\t\tsurface.SetCoords( 2,-1.0, 1.0, 1.0);surface.SetTexCoords( 2,-1.0, 1.0)\n\t\t\tsurface.SetCoords( 3, 1.0, 1.0, 1.0);surface.SetTexCoords( 3,-1.0, 0.0)\n\t\t\tsurface.SetTriangle( 0, 0, 1, 2)\n\t\t\tsurface.SetTriangle( 1, 3, 0, 2)\t\t\t\n\t\t\t\n\t\t\tFor Local i=4 To 7\n\t\t\t\tsurface.SetNormal(i,0,1,0)\n\t\t\tNext\n\t\t\tsurface.SetCoords( 4, 1.0,-1.0, 1.0);surface.SetTexCoords( 4, 0.0, 0.0)\n\t\t\tsurface.SetCoords( 5,-1.0,-1.0, 1.0);surface.SetTexCoords( 5, 0.0, 1.0)\n\t\t\tsurface.SetCoords( 6,-1.0,-1.0,-1.0);surface.SetTexCoords( 6,-1.0, 1.0)\n\t\t\tsurface.SetCoords( 7, 1.0,-1.0,-1.0);surface.SetTexCoords( 7,-1.0, 0.0)\n\t\t\tsurface.SetTriangle( 2, 4, 5, 6)\n\t\t\tsurface.SetTriangle( 3, 7, 4, 6)\t\n\t\t\t\n\t\t\tFor Local i=8 To 11\n\t\t\t\tsurface.SetNormal(i,0,0,-1)\n\t\t\tNext\n\t\t\tsurface.SetCoords( 8, 1.0, 1.0, 1.0);surface.SetTexCoords( 8,-1.0, 0.0)\n\t\t\tsurface.SetCoords( 9,-1.0, 1.0, 1.0);surface.SetTexCoords( 9, 0.0, 0.0)\n\t\t\tsurface.SetCoords(10,-1.0,-1.0, 1.0);surface.SetTexCoords(10, 0.0, 1.0)\n\t\t\tsurface.SetCoords(11, 1.0,-1.0, 1.0);surface.SetTexCoords(11,-1.0, 1.0)\n\t\t\tsurface.SetTriangle( 4,8 , 9,10)\n\t\t\tsurface.SetTriangle( 5,11, 8,10)\t\n\t\n\t\t\tFor Local i=12 To 15\n\t\t\t\tsurface.SetNormal(i,0,0,1)\n\t\t\tNext\n\t\t\tsurface.SetCoords(12, 1.0,-1.0,-1.0);surface.SetTexCoords(12, 0.0, 1.0)\n\t\t\tsurface.SetCoords(13,-1.0,-1.0,-1.0);surface.SetTexCoords(13,-1.0, 1.0)\n\t\t\tsurface.SetCoords(14,-1.0, 1.0,-1.0);surface.SetTexCoords(14,-1.0, 0.0)\n\t\t\tsurface.SetCoords(15, 1.0, 1.0,-1.0);surface.SetTexCoords(15, 0.0, 0.0)\n\t\t\tsurface.SetTriangle( 6,12,13,14)\n\t\t\tsurface.SetTriangle( 7,15,12,14)\t\n\t\t\t\n\t\t\tFor Local i=16 To 19\n\t\t\t\tsurface.SetNormal(i,1,0,0)\n\t\t\tNext\n\t\t\tsurface.SetCoords(16,-1.0, 1.0, 1.0);surface.SetTexCoords(16,-1.0, 0.0)\n\t\t\tsurface.SetCoords(17,-1.0, 1.0,-1.0);surface.SetTexCoords(17, 0.0, 0.0)\n\t\t\tsurface.SetCoords(18,-1.0,-1.0,-1.0);surface.SetTexCoords(18, 0.0, 1.0)\n\t\t\tsurface.SetCoords(19,-1.0,-1.0, 1.0);surface.SetTexCoords(19,-1.0, 1.0)\n\t\t\tsurface.SetTriangle( 8,16,17,18)\n\t\t\tsurface.SetTriangle( 9,19,16,18)\t\n\t\t\t\n\t\t\tFor Local i=20 To 23\n\t\t\t\tsurface.SetNormal(i,-1,0,0)\n\t\t\tNext\n\t\t\tsurface.SetCoords(20, 1.0, 1.0,-1.0);surface.SetTexCoords(20,-1.0, 0.0)\n\t\t\tsurface.SetCoords(21, 1.0, 1.0, 1.0);surface.SetTexCoords(21, 0.0, 0.0)\n\t\t\tsurface.SetCoords(22, 1.0,-1.0, 1.0);surface.SetTexCoords(22, 0.0, 1.0)\n\t\t\tsurface.SetCoords(23, 1.0,-1.0,-1.0);surface.SetTexCoords(23,-1.0, 1.0)\n\t\t\tsurface.SetTriangle(10,20,21,22)\n\t\t\tsurface.SetTriangle(11,23,20,22)\t\n\t\t\tReturn True\n\t\tCase \"torus\"\n\t\t\t'torrad#,torwidth#,segments,sides\n\t\t\tLocal torrad#=Float(params[0]),torwidth#=Float(params[1]),segments=Int(params[2]),sides=Int(params[3])\n\t\t\t\n\t\t\tLocal surface:TSurface=mesh.AddSurface(Null,segments*sides,segments*sides*2)\n\t\t\t\n\t\t\tLocal FATSTEP#=360.0\/sides\n\t\t\tLocal DEGSTEP#=360.0\/segments\n\t\t\t\n\t\t\tLocal radius#=0,x#=0,y#=0,z#=0\n\t\t\tFor Local f=0 To sides-1\n\t\t\t\tLocal fat#=FATSTEP*f\n\t\t\t\tradius = torrad + torwidth*Sin(fat)\n\t\t\t\tz=torwidth*Cos(fat)\n\t\t\t\tFor Local d=0 To segments-1\n\t\t\t\t\tLocal deg#=DEGSTEP*f\n\t\t\t\t\tx=radius*Cos(deg)\n\t\t\t\t\ty=radius*Sin(deg)\n\t\t\t\t\tsurface.SetCoords f*segments+d,x,y,z\n\t\t\t\t\tsurface.SetTexCoords f*segments+d,x,y\t\t\t\t\n\t\t\t\tNext\n\t\t\tNext\n\t\t\t\n\t\t\tFor Local v=0 To segments*sides-1\n\t\t\t\tLocal v0=v,v1=v+segments,v2=v+1,v3=v+1+segments\n\t\t\t\t\n\t\t\t\tIf v1>=segments*sides v1:-(segments*sides)\n\t\t\t\tIf v2>=segments*sides v2:-(segments*sides)\n\t\t\t\tIf v3>=segments*sides v3:-(segments*sides)\n\t\t\t\t\n\t\t\t\tsurface.SetTriangle v*2+0,v0,v1,v2\n\t\t\t\tsurface.SetTriangle v*2+1,v1,v3,v2\t\n\t\t\tNext\n\n\t\tDefault\n\t\t\tReturn False\n\t\tEnd Select\n\tEnd Method\n\t\n\tMethod Info$()\n\t\tReturn \"Primitives\"\n\tEnd Method\n\tMethod ModuleName$()\n\t\tReturn \"primitives\"\n\tEnd Method\n\n\t\n\tFunction FlipNormals(surface:TSurface)\n\t\tFor Local v=0 To surface._vertexcnt-1\n\t\t\tLocal nx#,ny#,nz#\n\t\t\tsurface.GetNormal(v,nx,ny,nz)\n\t\t\tsurface.SetNormal(v,-nx,-ny,-nz)\n\t\tNext\n\tEnd Function\t\nEnd Type\n\nNew TMeshLoaderPrimitives\n","old_contents":"\nStrict\n\nRem\n\tbbdoc: Primitive mesh loader for MaxB3D.\nEnd Rem\nModule MaxB3D.Primitives\nModuleInfo \"Author: Kevin Primm\"\nModuleInfo \"License: MIT\"\n\nImport MaxB3D.Core\n\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction CreateCube:TMesh(parent:TEntity=Null)\n\tReturn _currentworld.AddMesh(\"\/\/cube\",parent)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction CreateCone:TMesh(segments=8,solid=True,parent:TEntity=Null)\n\tReturn _currentworld.AddMesh(\"\/\/cone(\"+segments+\",\"+solid+\")\",parent)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction CreateCylinder:TMesh(segments=8,solid=True,parent:TEntity=Null)\n\tReturn _currentworld.AddMesh(\"\/\/cylinder(\"+segments+\",\"+solid+\")\",parent)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction CreateSphere:TMesh(segments=8,parent:TEntity=Null)\n\tReturn _currentworld.AddMesh(\"\/\/sphere(\"+segments+\")\",parent)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction CreateTorus:TMesh(radius#,width#,segments,sides,parent:TEntity=Null)\n\tReturn _currentworld.AddMesh(\"\/\/torus(\"+radius+\",\"+width+\",\"+segments+\",\"+sides+\")\",parent)\nEnd Function\n\nType TMeshLoaderPrimitives Extends TMeshLoader\n\tMethod Run(mesh:TMesh,stream:TStream,url:Object)\n\t\tLocal str$=String(url)\n\t\tLocal params$[]=str[str.Find(\"(\")+1..str.FindLast(\")\")].Split(\",\")\n\t\t\n\t\tLocal name$ = str[str.Find(\"\/\/\")+2..]\n\t\tIf str.Find(\"(\") > -1 name = name[..name.Find(\"(\")]\n\t\tDebugLog name\n\t\tSelect name\n\t\tCase \"sphere\"\n\t\t\tLocal segments=Int(params[0])\n\t\t\tIf segments<2 Or segments>100 Then Return Null\n\t\t\t\n\t\t\t'Vertex count\n\t\t\t'((segments*2)*4) '2\n\t\t\t'((segments*2)*6)+((segments*2)*((segments-2)*4)) '>2\n\t\t\t\n\t\t\t'Triangle count\n\t\t\t'(segments*2)*2\n\t\t\t'(segments*2)*2+(segments*2)*(segments-2)*2\n\n\t\t\tLocal vertexcount=4*segments*(3+((segments-2)*2))\n\t\t\tLocal trianglecount=segments*4*(1+(segments-2))\n\t\t\tIf segments=2\n\t\t\t\tvertexcount=segments*8\n\t\t\t\ttrianglecount=segments*4\n\t\t\tEndIf\n\t\t\t\n\t\t\tLocal surface:TSurface=mesh.AddSurface(Null,vertexcount,trianglecount)\n\t\t\t\n\t\t\tLocal div#=Float(360.0\/(segments*2))\n\t\t\tLocal height#=1.0\n\t\t\tLocal upos#=1.0\n\t\t\tLocal udiv#=Float(1.0\/(segments*2))\n\t\t\tLocal vdiv#=Float(1.0\/segments)\n\t\t\tLocal RotAngle#=90\t\n\t\t\t\n\t\t\tIf segments=2\n\t\t\t\tFor Local i=1 To (segments*2)\n\t\t\t\t\tLocal np=(i-1)*4+0,sp=np+1\n\t\t\t\t\tsurface.SetCoords(np,0.0,height,0.0);surface.SetTexCoords(np,upos#-(udiv#\/2.0),0) 'northpole\t\t\t\t\t\n\t\t\t\t\tsurface.SetCoords(sp,0.0,-height,0.0);surface.SetTexCoords(sp,upos#-(udiv#\/2.0),1) 'southpole\n\t\t\t\t\tLocal XPos#=-Cos(RotAngle#)\n\t\t\t\t\tLocal ZPos#=Sin(RotAngle#)\n\t\t\t\t\tLocal v0=sp+1\n\t\t\t\t\tsurface.SetCoords(v0,XPos#,0,ZPos#)\n\t\t\t\t\tsurface.SetTexCoords(v0,upos#,0.5)\n\t\t\t\t\tRotAngle#=RotAngle#+div#\n\t\t\t\t\tIf RotAngle#>=360.0 Then RotAngle#=RotAngle#-360.0\n\t\t\t\t\tXPos#=-Cos(RotAngle#)\n\t\t\t\t\tZPos#=Sin(RotAngle#)\n\t\t\t\t\tupos#=upos#-udiv#\n\t\t\t\t\tLocal v1=v0+1\n\t\t\t\t\tsurface.SetCoords(v1,XPos#,0,ZPos#)\n\t\t\t\t\tsurface.SetTexCoords(v1,upos#,0.5)\n\t\t\t\t\t\n\t\t\t\t\tsurface.SetTriangle((i-1)*2+0,np,v0,v1)\n\t\t\t\t\tsurface.SetTriangle((i-1)*2+1,v1,v0,sp)\t\n\t\t\t\tNext\t\n\t\t\tElse\n\t\t\t\tFor Local i=1 To (segments*2)\t\n\t\t\t\t\tLocal np=(i-1)*6+0,sp=np+1\n\t\t\t\t\tsurface.SetCoords(np,0.0,height,0.0)\n\t\t\t\t\tsurface.SetTexCoords(np,upos#-(udiv#\/2.0),0)'northpole\n\t\t\t\t\tsurface.SetCoords(sp,0.0,-height,0.0)\n\t\t\t\t\tsurface.SetTexCoords(sp,upos#-(udiv#\/2.0),1)'southpole\n\t\t\t\t\t\n\t\t\t\t\tLocal YPos#=Cos(div#)\n\t\t\t\t\t\n\t\t\t\t\tLocal XPos#=-Cos(RotAngle#)*(Sin(div#))\n\t\t\t\t\tLocal ZPos#=Sin(RotAngle#)*(Sin(div#))\n\t\t\t\t\t\n\t\t\t\t\tLocal v0t=sp+1\n\t\t\t\t\tsurface.SetCoords(v0t,XPos#,YPos#,ZPos#)\n\t\t\t\t\tsurface.SetTexCoords(v0t,upos#,vdiv#)\n\t\t\t\t\tLocal v0b=v0t+1\n\t\t\t\t\tsurface.SetCoords(v0b,XPos#,-YPos#,ZPos#)\n\t\t\t\t\tsurface.SetTexCoords(v0b,upos#,1-vdiv#)\n\t\t\t\t\t\n\t\t\t\t\tRotAngle#=RotAngle#+div#\n\t\t\t\t\t\n\t\t\t\t\tXPos#=-Cos(RotAngle#)*(Sin(div#))\n\t\t\t\t\tZPos#=Sin(RotAngle#)*(Sin(div#))\n\t\t\t\t\t\n\t\t\t\t\tupos#=upos#-udiv#\n\t\t\t\n\t\t\t\t\tLocal v1t=v0b+1\n\t\t\t\t\tsurface.SetCoords(v1t,XPos#,YPos#,ZPos#)\n\t\t\t\t\tsurface.SetTexCoords(v1t,upos#,vdiv#)\n\t\t\t\t\tLocal v1b=v1t+1\n\t\t\t\t\tsurface.SetCoords(v1b,XPos#,-YPos#,ZPos#)\n\t\t\t\t\tsurface.SetTexCoords(v1b,upos#,1-vdiv#)\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\tsurface.SetTriangle((i-1)*2+0,np,v0t,v1t)\n\t\t\t\t\tsurface.SetTriangle((i-1)*2+1,v1b,v0b,sp)\t\t\t\t\t\n\t\t\t\tNext\n\t\t\t\n\t\t\t\tupos#=1.0\n\t\t\t\tRotAngle#=90\n\t\t\t\tFor Local i=1 To (segments*2)\n\t\t\t\t\n\t\t\t\t\tLocal mult#=1\n\t\t\t\t\tLocal YPos#=Cos(div#*(mult#))\n\t\t\t\t\tLocal YPos2#=Cos(div#*(mult#+1.0))\n\t\t\t\t\tLocal Thisvdiv#=vdiv#\n\t\t\t\t\tFor Local j=1 To (segments-2)\t\t\t\n\t\t\t\t\t\tLocal XPos#=-Cos(RotAngle#)*(Sin(div#*(mult#)))\n\t\t\t\t\t\tLocal ZPos#=Sin(RotAngle#)*(Sin(div#*(mult#)))\n\t\t\t\n\t\t\t\t\t\tLocal XPos2#=-Cos(RotAngle#)*(Sin(div#*(mult#+1.0)))\n\t\t\t\t\t\tLocal ZPos2#=Sin(RotAngle#)*(Sin(div#*(mult#+1.0)))\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\tLocal v0t=(segments*2)*6+((i-1)*(segments-2)*4)+((j-1)*4),v0b=v0t+1\n\t\t\t\t\t\tsurface.SetCoords(v0t,XPos#,YPos#,ZPos#)\n\t\t\t\t\t\tsurface.SetTexCoords(v0t,upos#,Thisvdiv#,0.0)\n\t\t\t\t\t\tsurface.SetCoords(v0b,XPos2#,YPos2#,ZPos2#)\t\t\t\t\t\t\n\t\t\t\t\t\tsurface.SetTexCoords(v0b,upos#,Thisvdiv#+vdiv#,0.0)\n\t\t\t\t\t\n\t\t\t\t\t\tLocal tempRotAngle#=RotAngle#+div#\n\t\t\t\t\t\n\t\t\t\t\t\tXPos#=-Cos(tempRotAngle#)*(Sin(div#*(mult#)))\n\t\t\t\t\t\tZPos#=Sin(tempRotAngle#)*(Sin(div#*(mult#)))\n\t\t\t\t\t\t\n\t\t\t\t\t\tXPos2#=-Cos(tempRotAngle#)*(Sin(div#*(mult#+1.0)))\n\t\t\t\t\t\tZPos2#=Sin(tempRotAngle#)*(Sin(div#*(mult#+1.0)))\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\tLocal temp_upos#=upos-udiv\n\t\t\t\n\t\t\t\t\t\tLocal v1t=v0b+1,v1b=v1t+1\n\t\t\t\t\t\tsurface.SetCoords(v1t,XPos,YPos,ZPos)\n\t\t\t\t\t\tsurface.SetTexCoords(v1t,temp_upos,Thisvdiv,0.0)\n\t\t\t\t\t\tsurface.SetCoords(v1b,XPos2,YPos2,ZPos2)\n\t\t\t\t\t\tsurface.SetTexCoords(v1b,temp_upos,Thisvdiv+vdiv,0.0)\n\t\t\t\t\t\t\n\t\t\t\t\t\tsurface.SetTriangle((segments*2)*2+((i-1)*(segments-2)*2)+((j-1)*2)+0,v1t,v0t,v0b)\n\t\t\t\t\t\tsurface.SetTriangle((segments*2)*2+((i-1)*(segments-2)*2)+((j-1)*2)+1,v1b,v1t,v0b)\n\t\t\t\t\t\t\n\t\t\t\t\t\tThisvdiv#=Thisvdiv#+vdiv#\t\t\t\n\t\t\t\t\t\tmult#=mult#+1\n\t\t\t\t\t\tYPos#=Cos(div#*(mult#))\n\t\t\t\t\t\tYPos2#=Cos(div#*(mult#+1.0))\n\t\t\t\t\t\n\t\t\t\t\tNext\n\t\t\t\t\tupos#=upos#-udiv#\n\t\t\t\t\tRotAngle#=RotAngle#+div#\n\t\t\t\tNext\n\t\t\tEndIf\t\t\t\n\t\t\t\n\t\t\tmesh.UpdateNormals() \n\t\t\t'mesh.ForEachSurfaceDo FlipNormals\n\t\t\tReturn True \n\t\tCase \"cylinder\"\n\t\t\tLocal ringsegments=0\n\t\t\t\n\t\t\tLocal segments=Int(params[0]),solid=Int(params[1])\n\t\t\t\t\n\t\t\tLocal tr,tl,br,bl\n\t\t\tLocal ts0,ts1,newts\n\t\t\tLocal bs0,bs1,newbs\n\t\t\tIf segments<3 Or segments>100 Then Return Null\n\t\t\tIf ringsegments<0 Or ringsegments>100 Then Return Null\n\t\t\t\n\t\t\tLocal surface:TSurface=mesh.AddSurface(Null,1000,1000)\n\t\t\tLocal solidsurface:TSurface\n\t\t\tIf solid=True\n\t\t\t\tsolidsurface=mesh.AddSurface(Null,1000,1000)\n\t\t\tEndIf\n\t\t\tLocal div#=Float(360.0\/(segments))\n\t\t\t\n\t\t\tLocal height#=1.0\n\t\t\tLocal ringSegmentHeight#=(height#*2.0)\/(ringsegments+1)\n\t\t\tLocal upos#=1.0\n\t\t\tLocal udiv#=Float(1.0\/(segments))\n\t\t\tLocal vpos#=1.0\n\t\t\tLocal vdiv#=Float(1.0\/(ringsegments+1))\n\t\t\t\n\t\t\tLocal SideRotAngle#=90\n\t\t\t\n\t\t\tLocal tRing[segments+1]\n\t\t\tLocal bRing[segments+1]\n\t\t\t\n\t\t\tIf solid=True\n\t\t\t\tLocal xpos#=-Cos(SideRotAngle#)\n\t\t\t\tLocal zpos#=Sin(SideRotAngle#)\n\t\t\t\n\t\t\t\tts0=solidsurface.AddVertex(xpos,height,zpos,xpos\/2.0+0.5,zpos\/2.0+0.5)\n\t\t\t\tbs0=solidsurface.AddVertex(xpos,-height,zpos,xpos\/2.0+0.5,zpos\/2.0+0.5)\n\t\t\t\t\n\t\t\t\tsolidsurface.SetTexCoords(ts0,xpos\/2.0+0.5,zpos\/2.0+0.5,0.0)\n\t\t\t\tsolidsurface.SetTexCoords(bs0,xpos\/2.0+0.5,zpos\/2.0+0.5,0.0)\n\t\t\t\n\t\t\t\tSideRotAngle=SideRotAngle+div\n\t\t\t\n\t\t\t\txpos#=-Cos(SideRotAngle#)\n\t\t\t\tzpos#=Sin(SideRotAngle#)\n\t\t\t\t\n\t\t\t\tts1=solidsurface.AddVertex(xpos#,height,zpos#,xpos#\/2.0+0.5,zpos#\/2.0+0.5)\n\t\t\t\tbs1=solidsurface.AddVertex(xpos#,-height,zpos#,xpos#\/2.0+0.5,zpos#\/2.0+0.5)\n\t\t\t\n\t\t\t\tsolidsurface.SetTexCoords(ts1,xpos#\/2.0+0.5,zpos#\/2.0+0.5,0.0)\n\t\t\t\tsolidsurface.SetTexCoords(bs1,xpos#\/2.0+0.5,zpos#\/2.0+0.5,0.0)\n\t\t\t\t\n\t\t\t\tFor Local i=1 To (segments-2)\n\t\t\t\t\tSideRotAngle#=SideRotAngle#+div#\n\t\t\t\n\t\t\t\t\txpos#=-Cos(SideRotAngle#)\n\t\t\t\t\tzpos#=Sin(SideRotAngle#)\n\t\t\t\t\t\n\t\t\t\t\tnewts=solidsurface.AddVertex(xpos#,height,zpos#,xpos#\/2.0+0.5,zpos#\/2.0+0.5)\n\t\t\t\t\tnewbs=solidsurface.AddVertex(xpos#,-height,zpos#,xpos#\/2.0+0.5,zpos#\/2.0+0.5)\n\t\t\t\t\t\n\t\t\t\t\tsolidsurface.SetTexCoords(newts,xpos#\/2.0+0.5,zpos#\/2.0+0.5,0.0)\n\t\t\t\t\tsolidsurface.SetTexCoords(newbs,xpos#\/2.0+0.5,zpos#\/2.0+0.5,0.0)\n\t\t\t\t\t\n\t\t\t\t\tsolidsurface.AddTriangle(ts0,ts1,newts)\n\t\t\t\t\tsolidsurface.AddTriangle(newbs,bs1,bs0)\n\t\t\t\t\n\t\t\t\t\tIf i<(segments-2)\n\t\t\t\t\t\tts1=newts\n\t\t\t\t\t\tbs1=newbs\n\t\t\t\t\tEndIf\n\t\t\t\tNext\n\t\t\tEndIf\n\t\t\t\n\t\t\tLocal thisHeight#=height#\n\t\t\t\n\t\t\tSideRotAngle#=90\n\t\t\tLocal xpos#=-Cos(SideRotAngle#)\n\t\t\tLocal zpos#=Sin(SideRotAngle#)\n\t\t\tLocal thisUPos#=upos#\n\t\t\tLocal thisVPos#=0\n\t\t\ttRing[0]=surface.AddVertex(xpos#,thisHeight,zpos#,thisUPos#,thisVPos#)\t\t\n\t\t\tsurface.SetTexCoords(tRing[0],thisUPos#,thisVPos#,0.0)\n\t\t\tFor Local i=0 To (segments-1)\n\t\t\t\tSideRotAngle#=SideRotAngle#+div#\n\t\t\t\txpos#=-Cos(SideRotAngle#)\n\t\t\t\tzpos#=Sin(SideRotAngle#)\n\t\t\t\tthisUPos#=thisUPos#-udiv#\n\t\t\t\ttRing[i+1]=surface.AddVertex(xpos#,thisHeight,zpos#,thisUPos#,thisVPos#)\n\t\t\t\tsurface.SetTexCoords(tRing[i+1],thisUPos#,thisVPos#,0.0)\n\t\t\tNext\t\n\t\t\t\n\t\t\tFor Local ring=0 To ringsegments\n\t\t\t\tLocal thisHeight=thisHeight-ringSegmentHeight#\n\t\t\t\t\n\t\t\t\tSideRotAngle#=90\n\t\t\t\txpos#=-Cos(SideRotAngle#)\n\t\t\t\tzpos#=Sin(SideRotAngle#)\n\t\t\t\tthisUPos#=upos#\n\t\t\t\tthisVPos#=thisVPos#+vdiv#\n\t\t\t\tbRing[0]=surface.AddVertex(xpos#,thisHeight,zpos#,thisUPos#,thisVPos#)\n\t\t\t\tsurface.SetTexCoords(bRing[0],thisUPos#,thisVPos#,0.0)\n\t\t\t\tFor Local i=0 To (segments-1)\n\t\t\t\t\tSideRotAngle#=SideRotAngle#+div#\n\t\t\t\t\txpos#=-Cos(SideRotAngle#)\n\t\t\t\t\tzpos#=Sin(SideRotAngle#)\n\t\t\t\t\tthisUPos#=thisUPos#-udiv#\n\t\t\t\t\tbRing[i+1]=surface.AddVertex(xpos#,thisHeight,zpos#,thisUPos#,thisVPos#)\n\t\t\t\t\tsurface.SetTexCoords(bRing[i+1],thisUPos#,thisVPos#,0.0)\n\t\t\t\tNext\n\t\t\t\t\n\t\t\t\tFor Local v=1 To (segments)\n\t\t\t\t\ttl=tRing[v]\n\t\t\t\t\ttr=tRing[v-1]\n\t\t\t\t\tbl=bRing[v]\n\t\t\t\t\tbr=bRing[v-1]\n\t\t\t\t\t\n\t\t\t\t\tsurface.AddTriangle(tl,tr,br)\n\t\t\t\t\tsurface.AddTriangle(bl,tl,br)\n\t\t\t\tNext\n\t\t\t\t\n\t\t\t\tFor Local v=0 To (segments)\n\t\t\t\t\ttRing[v]=bRing[v]\n\t\t\t\tNext\t\t\n\t\t\tNext\n\t\t\t\t\t\n\t\t\tmesh.UpdateNormals()\n\t\t\tReturn True\n\t\tCase \"cone\"\n\t\t\tLocal segments=Int(params[0]),solid=Int(params[1])\n\t\t\t\t\t\t\n\t\t\tIf segments<3 Or segments>100 Then Return Null\n\t\t\t\n\t\t\tLocal surface:TSurface=mesh.AddSurface(Null,1+segments*2,segments)\n\t\t\tLocal bottomsurface:TSurface\n\t\t\tIf solid bottomsurface=mesh.AddSurface(Null,1+segments,segments-1)\n\t\t\t\n\t\t\tLocal div#=Float(360.0\/(segments))\n\t\t\n\t\t\tLocal height#=1.0\n\t\t\tLocal upos#=1.0\n\t\t\tLocal udiv#=Float(1.0\/(segments))\n\t\t\tLocal angle#=90\t\n\t\t\n\t\t\tLocal xpos#=-Cos(angle)\n\t\t\tLocal zpos#=Sin(angle)\n\t\t\n\t\t\tsurface.SetCoords(0,0.0,height,0.0);surface.SetTexCoords(0,upos-(udiv\/2.0),0)\n\t\t\tsurface.SetCoords(1,xpos,-height,zpos);surface.SetTexCoords(1,upos,1)\n\t\t\n\t\t\tIf solid bottomsurface.SetCoords(0,xpos,-height,zpos);bottomsurface.SetTexCoords(0,xpos\/2.0+0.5,zpos\/2.0+0.5)\n\t\t\n\t\t\tangle:+div\n\t\t\n\t\t\txpos=-Cos(angle)\n\t\t\tzpos=Sin(angle)\n\t\t\t\t\t\t\n\t\t\tsurface.SetCoords(2,xpos,-height,zpos);surface.SetTexCoords(2,upos-udiv,1)\n\t\t\n\t\t\tIf solid bottomsurface.SetCoords(1,xpos,-height,zpos);bottomsurface.SetTexCoords(1,xpos\/2.0+0.5,zpos\/2.0+0.5)\n\t\t\t\n\t\t\tsurface.SetTriangle(0,2,0,1) 'br,top,bl\n\t\t\n\t\t\tFor Local i=1 To segments-1\n\t\t\t\tLocal v=1+(i*2)\n\t\t\t\tupos:-udiv\n\t\t\t\tsurface.SetCoords(v+0,0.0,height,0.0);surface.SetTexCoords(v+0,upos-(udiv\/2.0),0)\n\t\t\t\n\t\t\t\tangle:+div\n\t\t\n\t\t\t\txpos=-Cos(angle)\n\t\t\t\tzpos=Sin(angle)\n\t\t\t\t\n\t\t\t\tsurface.SetCoords(v+1,xpos,-height,zpos);surface.SetTexCoords(v+1,upos-udiv,1)\t\t\t\n\t\t\t\tsurface.SetTriangle(i,v+1,v+0,v-1)\n\t\t\t\t\n\t\t\t\tIf solid=True\n\t\t\t\t\tbottomsurface.SetCoords(i+1,xpos,-height,zpos);bottomsurface.SetTexCoords(i+1,xpos\/2.0+0.5,zpos\/2.0+0.5)\n\t\t\t\t\tbottomsurface.SetTriangle(i-1,i+1,i,0)\n\t\t\t\tEndIf\n\t\t\tNext\t\t\n\t\t\t\n\t\t\tmesh.UpdateNormals()\n\t\t\tReturn True\n\t\tCase \"cube\"\n\t\t\tLocal surface:TSurface=mesh.AddSurface(Null,24,12)\n\n\t\t\tFor Local i=0 To 3\n\t\t\t\tsurface.SetNormal(i,0,-1,0)\n\t\t\tNext\n\t\t\tsurface.SetCoords( 0, 1.0, 1.0,-1.0);surface.SetTexCoords( 0, 0.0, 0.0)\n\t\t\tsurface.SetCoords( 1,-1.0, 1.0,-1.0);surface.SetTexCoords( 1, 0.0, 1.0)\n\t\t\tsurface.SetCoords( 2,-1.0, 1.0, 1.0);surface.SetTexCoords( 2,-1.0, 1.0)\n\t\t\tsurface.SetCoords( 3, 1.0, 1.0, 1.0);surface.SetTexCoords( 3,-1.0, 0.0)\n\t\t\tsurface.SetTriangle( 0, 0, 1, 2)\n\t\t\tsurface.SetTriangle( 1, 3, 0, 2)\t\t\t\n\t\t\t\n\t\t\tFor Local i=4 To 7\n\t\t\t\tsurface.SetNormal(i,0,1,0)\n\t\t\tNext\n\t\t\tsurface.SetCoords( 4, 1.0,-1.0, 1.0);surface.SetTexCoords( 4, 0.0, 0.0)\n\t\t\tsurface.SetCoords( 5,-1.0,-1.0, 1.0);surface.SetTexCoords( 5, 0.0, 1.0)\n\t\t\tsurface.SetCoords( 6,-1.0,-1.0,-1.0);surface.SetTexCoords( 6,-1.0, 1.0)\n\t\t\tsurface.SetCoords( 7, 1.0,-1.0,-1.0);surface.SetTexCoords( 7,-1.0, 0.0)\n\t\t\tsurface.SetTriangle( 2, 4, 5, 6)\n\t\t\tsurface.SetTriangle( 3, 7, 4, 6)\t\n\t\t\t\n\t\t\tFor Local i=8 To 11\n\t\t\t\tsurface.SetNormal(i,0,0,-1)\n\t\t\tNext\n\t\t\tsurface.SetCoords( 8, 1.0, 1.0, 1.0);surface.SetTexCoords( 8,-1.0, 0.0)\n\t\t\tsurface.SetCoords( 9,-1.0, 1.0, 1.0);surface.SetTexCoords( 9, 0.0, 0.0)\n\t\t\tsurface.SetCoords(10,-1.0,-1.0, 1.0);surface.SetTexCoords(10, 0.0, 1.0)\n\t\t\tsurface.SetCoords(11, 1.0,-1.0, 1.0);surface.SetTexCoords(11,-1.0, 1.0)\n\t\t\tsurface.SetTriangle( 4,8 , 9,10)\n\t\t\tsurface.SetTriangle( 5,11, 8,10)\t\n\t\n\t\t\tFor Local i=12 To 15\n\t\t\t\tsurface.SetNormal(i,0,0,1)\n\t\t\tNext\n\t\t\tsurface.SetCoords(12, 1.0,-1.0,-1.0);surface.SetTexCoords(12, 0.0, 1.0)\n\t\t\tsurface.SetCoords(13,-1.0,-1.0,-1.0);surface.SetTexCoords(13,-1.0, 1.0)\n\t\t\tsurface.SetCoords(14,-1.0, 1.0,-1.0);surface.SetTexCoords(14,-1.0, 0.0)\n\t\t\tsurface.SetCoords(15, 1.0, 1.0,-1.0);surface.SetTexCoords(15, 0.0, 0.0)\n\t\t\tsurface.SetTriangle( 6,12,13,14)\n\t\t\tsurface.SetTriangle( 7,15,12,14)\t\n\t\t\t\n\t\t\tFor Local i=16 To 19\n\t\t\t\tsurface.SetNormal(i,1,0,0)\n\t\t\tNext\n\t\t\tsurface.SetCoords(16,-1.0, 1.0, 1.0);surface.SetTexCoords(16,-1.0, 0.0)\n\t\t\tsurface.SetCoords(17,-1.0, 1.0,-1.0);surface.SetTexCoords(17, 0.0, 0.0)\n\t\t\tsurface.SetCoords(18,-1.0,-1.0,-1.0);surface.SetTexCoords(18, 0.0, 1.0)\n\t\t\tsurface.SetCoords(19,-1.0,-1.0, 1.0);surface.SetTexCoords(19,-1.0, 1.0)\n\t\t\tsurface.SetTriangle( 8,16,17,18)\n\t\t\tsurface.SetTriangle( 9,19,16,18)\t\n\t\t\t\n\t\t\tFor Local i=20 To 23\n\t\t\t\tsurface.SetNormal(i,-1,0,0)\n\t\t\tNext\n\t\t\tsurface.SetCoords(20, 1.0, 1.0,-1.0);surface.SetTexCoords(20,-1.0, 0.0)\n\t\t\tsurface.SetCoords(21, 1.0, 1.0, 1.0);surface.SetTexCoords(21, 0.0, 0.0)\n\t\t\tsurface.SetCoords(22, 1.0,-1.0, 1.0);surface.SetTexCoords(22, 0.0, 1.0)\n\t\t\tsurface.SetCoords(23, 1.0,-1.0,-1.0);surface.SetTexCoords(23,-1.0, 1.0)\n\t\t\tsurface.SetTriangle(10,20,21,22)\n\t\t\tsurface.SetTriangle(11,23,20,22)\t\n\t\t\tReturn True\n\t\tCase \"torus\"\n\t\t\t'torrad#,torwidth#,segments,sides\n\t\t\tLocal torrad#=Float(params[0]),torwidth#=Float(params[1]),segments=Int(params[2]),sides=Int(params[3])\n\t\t\t\n\t\t\tLocal surface:TSurface=mesh.AddSurface(Null,segments*sides,segments*sides*2)\n\t\t\t\n\t\t\tLocal FATSTEP#=360.0\/sides\n\t\t\tLocal DEGSTEP#=360.0\/segments\n\t\t\t\n\t\t\tLocal radius#=0,x#=0,y#=0,z#=0\n\t\t\tFor Local f=0 To sides-1\n\t\t\t\tLocal fat#=FATSTEP*f\n\t\t\t\tradius = torrad + torwidth*Sin(fat)\n\t\t\t\tz=torwidth*Cos(fat)\n\t\t\t\tFor Local d=0 To segments-1\n\t\t\t\t\tLocal deg#=DEGSTEP*f\n\t\t\t\t\tx=radius*Cos(deg)\n\t\t\t\t\ty=radius*Sin(deg)\n\t\t\t\t\tsurface.SetCoords f*segments+d,x,y,z\n\t\t\t\t\tsurface.SetTexCoords f*segments+d,x,y\t\t\t\t\n\t\t\t\tNext\n\t\t\tNext\n\t\t\t\n\t\t\tFor Local v=0 To segments*sides-1\n\t\t\t\tLocal v0=v,v1=v+segments,v2=v+1,v3=v+1+segments\n\t\t\t\t\n\t\t\t\tIf v1>=segments*sides v1:-(segments*sides)\n\t\t\t\tIf v2>=segments*sides v2:-(segments*sides)\n\t\t\t\tIf v3>=segments*sides v3:-(segments*sides)\n\t\t\t\t\n\t\t\t\tsurface.SetTriangle v*2+0,v0,v1,v2\n\t\t\t\tsurface.SetTriangle v*2+1,v1,v3,v2\t\n\t\t\tNext\n\n\t\tDefault\n\t\t\tReturn False\n\t\tEnd Select\n\tEnd Method\n\t\n\tMethod Info$()\n\t\tReturn \"Primitives\"\n\tEnd Method\n\tMethod ModuleName$()\n\t\tReturn \"primitives\"\n\tEnd Method\n\n\t\n\tFunction FlipNormals(surface:TSurface)\n\t\tFor Local v=0 To surface._vertexcnt-1\n\t\t\tLocal nx#,ny#,nz#\n\t\t\tsurface.GetNormal(v,nx,ny,nz)\n\t\t\tsurface.SetNormal(v,-nx,-ny,-nz)\n\t\tNext\n\tEnd Function\t\nEnd Type\n\nNew TMeshLoaderPrimitives\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"f93a7ba98ce4adfaeb47648bd6569c3303c1f2d7","subject":"Added more stub methods for MonkeyMax.","message":"Added more stub methods for MonkeyMax.\n\n--HG--\nextra : convert_revision : svn%3Ae934d3cd-0d57-f34a-94d0-9e8d31ae1c29\/trunk%40352\n","repos":"programmerby\/diddy-mirror,programmerby\/diddy-mirror,programmerby\/diddy-mirror,programmerby\/diddy-mirror","old_file":"monkeymax\/modules\/mojo\/native\/mojo.bmax.bmx","new_file":"monkeymax\/modules\/mojo\/native\/mojo.bmax.bmx","new_contents":"' ***** Start mojo.bmax.bmx ******\r\n\r\nGlobal app:gxtkApp\r\n\r\nType gxtkApp\r\n\tField ginput:gxtkInput\r\n\tField gaudio:gxtkAudio\r\n\tField ggraphics:gxtkGraphics\r\n\r\n\tField dead:Int=0\r\n\tField suspended:Int=0\r\n\tField vloading:Int=0\r\n\tField maxloading:Int=0\r\n\tField updateRate:Int=0\r\n\tField nextUpdate:Float=0\r\n\tField updatePeriod:Float=0\r\n\tField startMillis:Float=0\r\n\t\r\n\tMethod New()' gxtkApp()\r\n\t\tapp=Self\r\n\t\tggraphics=New gxtkGraphics\r\n\tEndMethod\r\n\t\r\n\tMethod Setup()\r\n\t\tginput=New gxtkInput\r\n\t\tgaudio=New gxtkAudio\r\n\r\n\t\tbb_input_SetInputDevice(ginput)\r\n\t\tbb_audio_SetAudioDevice(gaudio)\r\n\t\t\r\n\t\tstartMillis=BlitzMaxMillisecs()\r\n\t\t\r\n\t\tSetFrameRate( 0 )\r\n\t\t\r\n\t\tInvokeOnCreate()\r\n\t\tInvokeOnRender()\r\n\t\tUpdate()\r\n\tEndMethod\r\n\t\r\n\tMethod Update()\r\n\t\tWhile Not AppTerminate()\r\n\t\t\tLocal updates:Int = 0\r\n\t\t\t\r\n\t\t\tLocal cont:Int = 1\r\n\t\t\tWhile (cont)\r\n\t\t\t\tnextUpdate:+updatePeriod\r\n\t\t\t\tInvokeOnUpdate()\r\n\t\t\t\tIf Not updatePeriod Then cont = 0\r\n\t\t\t\tIf nextUpdate>BlitzMaxMillisecs() Then cont = 0\r\n\t\t\t\tupdates:+1\r\n\t\t\t\tIf updates = 7 Then\r\n\t\t\t\t\tnextUpdate = BlitzMaxMillisecs()\r\n\t\t\t\t\tcont = 0\r\n\t\t\t\tEndIf\r\n\t\t\tWend\r\n\t\t\tInvokeOnRender()\r\n\t\tWend\r\n\tEndMethod\r\n\t\r\n\tMethod InvokeOnCreate()\r\n\t\tIf dead Return\r\n\t\tdead = 1\r\n\t\tOnCreate()\r\n\t\tdead = 0\r\n\tEndMethod\r\n\r\n\tMethod InvokeOnUpdate()\r\n\t\tIf dead Or suspended Or Not updateRate Or vloading Return\r\n\t\tOnUpdate()\r\n\tEndMethod\r\n\t\r\n\tMethod InvokeOnRender()\r\n\t\tIf dead Or suspended Return\r\n\t\tggraphics.BeginRender()\r\n\t\tIf vloading\r\n\t\t\tOnLoading()\r\n\t\tElse\r\n\t\t\tOnRender()\r\n\t\tEndIf\r\n\t\tggraphics.EndRender()\r\n\tEndMethod\r\n\t\r\n\t\r\n\tMethod SetFrameRate( fps:Int )\r\n\t\tIf fps\r\n\t\t\tupdatePeriod=1000.0\/fps\r\n\t\t\tnextUpdate=BlitzMaxMillisecs() +updatePeriod\r\n\t\tElse\r\n\t\t\tupdatePeriod=0\r\n\t\tEndIf\r\n\tEndMethod\r\n\r\n\tMethod LoadState:String()\r\n'\t\tvar file:SharedObject=SharedObject.getLocal( \"gxtkapp\" );\r\n'\t\tvar state:String=file.data.state;\r\n'\t\tfile.close();\r\n'\t\tif( state ) return state;\r\n\t\tReturn \"\"\r\n\tEndMethod\r\n\t\r\n\tMethod SaveState:Int( state:String )\r\n'\t\tvar file:SharedObject=SharedObject.getLocal( \"gxtkapp\" );\r\n'\t\tfile.data.state=state;\r\n'\t\tfile.close();\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod LoadString:String( path:String )\r\n\t\tpath = \"data\/\" + path\r\n\t\tReturn LoadText( path )\r\n\tEndMethod\r\n\t\r\n\t' ***** GXTK API *****\r\n\t\r\n\tMethod GraphicsDevice:gxtkGraphics()\r\n\t\tReturn ggraphics\r\n\tEndMethod\r\n\r\n\tMethod InputDevice:gxtkInput()\r\n\t\tReturn ginput\r\n\tEndMethod\r\n\r\n\tMethod AudioDevice:gxtkAudio()\r\n\t\tReturn gaudio\r\n\tEndMethod\r\n\r\n\tMethod SetUpdateRate:Int(hertz:Int)\r\n\t\tupdateRate = hertz\r\n\t\tIf Not vloading Then SetFrameRate(updateRate)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod MilliSecs:Int()\r\n\t\tReturn BlitzMaxMillisecs() - startMillis\r\n\tEndMethod\r\n\t\r\n\tMethod Loading:Int()\r\n\t\tReturn vloading\r\n\tEndMethod\r\n\r\n\tMethod OnCreate:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod OnUpdate:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod OnSuspend:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod OnResume:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod OnRender:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod OnLoading:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkGraphics\r\n\tField gmode:Int = 1\r\n\r\n\tMethod Mode:Int()\r\n\t\tReturn gmode\r\n\tEndMethod\r\n\t\r\n\tMethod Cls:Int(r:Int = 0, g:Int = 0, b:Int = 0)\r\n\t\tBlitzMaxCls(r, g, b)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawPoint:Int(x:Float, y:Float)\r\n\t\tPlot x, y\r\n\tEndMethod\r\n\t\r\n\tMethod LoadSurface:gxtkSurface(path:String)\r\n\t\tLocal image:TImage = LoadImage(\"data\/\"+path)\r\n\t\tIf image Then\r\n\t\t\tLocal gs:gxtkSurface = New gxtkSurface\r\n\t\t\tgs.setImage(image)\r\n\t\t\tReturn gs\r\n\t\tEndIf\r\n\t\tReturn Null\r\n\tEndMethod\r\n\t\r\n\tMethod BeginRender()\r\n\tEndMethod\r\n\t\r\n\tMethod EndRender()\r\n\t\tFlip\r\n\tEndMethod\r\n\t\r\n\tMethod SetColor:Int(r:Int, g:Int, b:Int)\r\n\t\tBlitzMaxSetColor(r, g, b)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod SetAlpha:Int(a:Float)\r\n\t\tBlitzMaxSetAlpha(a)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod SetBlend:Int(blend:Int)\r\n\t\tBlitzMaxSetBlend(blend)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod Width:Int()\r\n\t\tReturn GraphicsWidth()\r\n\tEndMethod\r\n\t\r\n\tMethod Height:Int()\r\n\t\tReturn GraphicsHeight()\r\n\tEndMethod\r\n\t\r\n\tMethod SetScissor:Int(x:Int, y:Int, w:Int, h:Int)\r\n\t\tSetViewport(x, y, w, h) ' NOT TESTED!\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod SetMatrix:Int(ix:Float,iy:Float,jx:Float,jy:Float,tx:Float,ty:Float)\r\n\t\tLocal sx:Float = Sqr( (ix*ix) + (jx*jx) )\r\n\t\tLocal sy:Float = Sqr( (iy*iy) + (jy*jy) )\r\n\t\tLocal rot:Float = -Atan2( jx, ix )\r\n\t\tSetTransform( rot, sx, sy )\r\n\t\tSetOrigin( tx, ty )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawSurface:Int(surface:gxtkSurface,x:Float,y:Float)\r\n\t\tDrawImage(surface.image, x, y, 0)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawSurface2:Int(surface:gxtkSurface,x:Float,y:Float, srcx:Int, srcy:Int, srcw:Int, srch:Int )\r\n\t\tDrawSubImageRect(surface.image, x, y, srcw, srch, srcx, srcy, srcw, srch)\t\t\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawLine:Int( x1:Float,y1:Float,x2:Float,y2:Float )\r\n\t\tBlitzMaxDrawLine(x1, y1, x2, y2)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawOval:Int( x:Float, y:Float, w:Float, h:Float )\r\n\t\tBlitzMaxDrawOval(x, y, w, h)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawPoly:Int(vertices:Float[])\r\n\t\tBlitzMaxDrawPoly( vertices )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawRect:Int( x:Float, y:Float, w:Float, h:Float )\r\n\t\tBlitzMaxDrawRect(x, y, w, h)\r\n\t\tReturn 0\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkInput\r\n\tMethod MouseX:Float()\r\n\t\tReturn BRL.PolledInput.MouseX()\r\n\tEndMethod\r\n\r\n\tMethod MouseY:Float()\r\n\t\tReturn BRL.PolledInput.MouseY()\r\n\tEndMethod\r\n\t\r\n\tMethod KeyDown:Int( key:Int )\r\n\t\tIf( key >= 1 And key <= 3 )\r\n\t\t\tReturn BRL.PolledInput.MouseDown( key )\r\n\t\tEndIf\r\n\t\tReturn BRL.PolledInput.KeyDown( key )\r\n\tEndMethod\r\n\r\n\tMethod KeyHit:Int( key:Int )\r\n\t\tIf( key >= 1 And key <= 3 )\r\n\t\t\tReturn BRL.PolledInput.MouseHit( key )\r\n\t\tEndIf\r\n\t\tReturn BRL.PolledInput.KeyHit( key )\r\n\tEndMethod\r\n\r\n\tMethod GetChar:Int()\r\n\t\tReturn BRL.PolledInput.GetChar()\r\n\tEndMethod\r\n\r\n\tMethod JoyX:Int( index:Int )\r\n\t\tReturn Pub.FreeJoy.JoyX( index )\r\n\tEndMethod\r\n\r\n\tMethod JoyY:Int( index:Int )\r\n\t\tReturn Pub.FreeJoy.JoyY( index )\r\n\tEndMethod\r\n\r\n\tMethod JoyZ:Int( index:Int )\r\n\t\tReturn Pub.FreeJoy.JoyZ( index )\r\n\tEndMethod\r\n\r\n\tMethod TouchX:Float( index:Int )\r\n\t\tReturn BRL.PolledInput.MouseX()\r\n\tEndMethod\r\n\r\n\tMethod TouchY:Float( index:Int )\r\n\t\tReturn BRL.PolledInput.MouseY()\r\n\tEndMethod\r\n\t\r\n\tMethod AccelX:Int()\r\n\t\treturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod AccelY:Int()\r\n\t\treturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod AccelZ:Int()\r\n\t\treturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod SetKeyboardEnabled:Int( enabled:int )\r\n\t\tReturn 0\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkChannel\r\n\tField channel:TChannel\t' null then not playing\r\n\tField sample:gxtkSample\r\n\tField loops:int\r\n\t'Field transform:SoundTransform=new SoundTransform()\r\n\t'Field pausepos:Number\r\n\tField state:int\r\n\t\r\n\tMethod New()\r\n\t\tchannel = New TChannel\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkAudio\r\n\tField amusicState:Int = 0\r\n\tField channels:gxtkChannel[] = New gxtkChannel[33]\r\n\t\r\n\tMethod New()\r\n\t\tFor local i:Int = 0 To 33 - 1\r\n\t\t\tchannels[i] = New gxtkChannel\r\n\t\tNext\r\n\tEndMethod\r\n\t\r\n\tMethod MusicState:Int()\r\n'\t\tIf( musicState = 1 And music.isPlaying() = False )\r\n'\t\t\tmusicState = 0;\r\n'\t\tEndif\r\n\t\tReturn amusicState\r\n\tEndMethod\r\n\t\r\n\tMethod PlayMusic:Int( path:String, flags:Int )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod ChannelState:int( channel:int )\r\n\t\tReturn -1\r\n\tEndMethod\r\n\t\r\n\tMethod StopMusic()\r\n\tEndMethod\r\n\t\r\n\tMethod StopChannel( channel:Int )\r\n\tEndMethod\r\n\r\n\tMethod PlaySample( sound:gxtkSample, channel:Int, flags:Int )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\t\r\n\t\t'If chan.state <> 0 Then chan.channel.Stop() <-- this crashes after the first play!?\r\n\t\t\r\n\t\tchan.sample = sound\r\n\t\t'chan.loops = flags ? 0x7fffffff : 0;\r\n\t\t'chan.channel = sample.sound.play( 0,chan.loops,chan.transform );\r\n\t\t'chan.channel = sound\r\n\t\tchan.state=1\r\n\t\r\n\t\tPlaySound( sound.sound, chan.channel )\r\n\tEndMethod\r\n\r\n\tMethod SetPan( channel:Int, pan:Float )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tchan.channel.SetPan(pan)\r\n\tEndMethod\r\n\r\n\tMethod SetRate( channel:Int, rate:Float )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tchan.channel.SetRate(rate)\r\n\tEndMethod\r\n\r\n\tMethod PauseMusic:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod ResumeMusic:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod SetMusicVolume:Int( volume:Float )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod SetVolume:Int( channel:Int, volume:Float )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tchan.channel.SetVolume(volume)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod LoadSample:gxtkSample( path:String )\r\n\t\tLocal sound:TSound = LoadSound(\"data\/\"+path)\r\n\t\tIf sound Then\r\n\t\t\tLocal gs:gxtkSample = New gxtkSample\r\n\t\t\tgs.setSound(sound)\r\n\t\t\tReturn gs\r\n\t\tEndIf\r\n\t\tReturn Null\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkSample\r\n\tField sound:TSound\r\n\t\r\n\tMethod setSound(sound:TSound)\r\n\t\tSelf.sound = sound\r\n\tEndMethod\r\n\t\r\n\tMethod Discard()\r\n\t\tSelf.sound = null\r\n\tEndMethod\r\nEndType\r\n\r\nFunction BlitzMaxDrawPoly:Int(vertices:Float[])\r\n\tDrawPoly vertices\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxDrawRect:Int( x:Float, y:Float, w:Float, h:Float )\r\n\tDrawRect x, y, w, h\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxDrawOval:Int( x:Float, y:Float, w:Float, h:Float )\r\n\tDrawOval x, y, w, h\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxDrawLine:Int( x1:Float,y1:Float,x2:Float,y2:Float )\r\n\tDrawLine x1, y1, x2, y2\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxMillisecs:Int()\r\n\tReturn MilliSecs()\r\nEndFunction\r\n\r\nFunction BlitzMaxSetColor(r:Int, g:Int, b:Int)\r\n\tSetColor(r, g, b)\r\nEndFunction\r\n\r\nFunction BlitzMaxSetBlend(blend:Int)\r\n\tSelect blend\r\n\t\tCase 0\r\n\t\t\tSetBlend( ALPHABLEND )\r\n\t\tCase 1\r\n\t\t\tSetBlend( LIGHTBLEND )\r\n\tEnd Select\r\nEndFunction\r\n\r\nFunction BlitzMaxSetAlpha(a:Float)\r\n\tSetAlpha(a)\r\nEndFunction\r\n\r\nFunction BlitzMaxCls(r:Int = 0, g:Int = 0, b:Int = 0)\r\n\tSetClsColor(r, g, b)\r\n\tCls\r\nEndFunction\r\n\r\nType gxtkSurface\r\n\tField w:Int, h:Int\r\n\tField image:TImage\r\n\t\r\n\tMethod setImage(image:TImage)\r\n\t\tSelf.image = image\r\n\tEndMethod\r\n\t\r\n\tMethod Width:Int()\r\n\t\tReturn image.Width\r\n\tEndMethod\r\n\t\r\n\tMethod Height:Int()\r\n\t\tReturn image.Height\r\n\tEndMethod\r\n\t\r\n\tMethod Discard()\r\n\tEndMethod\r\nEndType\r\n\r\n' ***** End mojo.bmax.bmx ******\r\n\r\n","old_contents":"' ***** Start mojo.bmax.bmx ******\r\n\r\nGlobal app:gxtkApp;\r\n\r\nType gxtkApp\r\n\tField ginput:gxtkInput;\r\n\tField gaudio:gxtkAudio;\r\n\tField ggraphics:gxtkGraphics;\r\n\r\n\tField dead:Int=0;\r\n\tField suspended:Int=0;\r\n\tField vloading:Int=0;\r\n\tField maxloading:Int=0;\r\n\tField updateRate:Int=0;\r\n\tField nextUpdate:Float=0;\r\n\tField updatePeriod:Float=0;\r\n\tField startMillis:Float=0;\r\n\t\r\n\tMethod New()' gxtkApp()\r\n\t\tapp=Self;\r\n\t\tggraphics=New gxtkGraphics;\r\n\tEndMethod\r\n\t\r\n\tMethod Setup()\r\n\t\tginput=New gxtkInput;\r\n\t\tgaudio=New gxtkAudio;\r\n\r\n\t\tbb_input_SetInputDevice(ginput);\r\n\t\tbb_audio_SetAudioDevice(gaudio);\r\n\t\t\r\n\t\tstartMillis=BlitzMaxMillisecs()\r\n\t\t\r\n\t\tSetFrameRate( 0 );\r\n\t\t\r\n\t\tInvokeOnCreate();\r\n\t\tInvokeOnRender();\r\n\t\tUpdate()\r\n\tEndMethod\r\n\t\r\n\tMethod Update()\r\n\t\tWhile Not AppTerminate()\r\n\t\t\tLocal updates:Int = 0\r\n\t\t\t\r\n\t\t\tLocal cont:Int = 1\r\n\t\t\tWhile (cont)\r\n\t\t\t\tnextUpdate:+updatePeriod\r\n\t\t\t\tInvokeOnUpdate()\r\n\t\t\t\tIf Not updatePeriod Then cont = 0\r\n\t\t\t\tIf nextUpdate>BlitzMaxMillisecs() Then cont = 0\r\n\t\t\t\tupdates:+1\r\n\t\t\t\tIf updates = 7 Then\r\n\t\t\t\t\tnextUpdate = BlitzMaxMillisecs()\r\n\t\t\t\t\tcont = 0\r\n\t\t\t\tEndIf\r\n\t\t\tWend\r\n\t\t\tInvokeOnRender()\r\n\t\tWend\r\n\tEndMethod\r\n\t\r\n\tMethod InvokeOnCreate()\r\n\t\tIf dead Return\r\n\t\tdead = 1\r\n\t\tOnCreate()\r\n\t\tdead = 0\r\n\tEndMethod\r\n\r\n\tMethod InvokeOnUpdate()\r\n\t\tIf dead Or suspended Or Not updateRate Or vloading Return\r\n\t\tOnUpdate()\r\n\tEndMethod\r\n\t\r\n\tMethod InvokeOnRender()\r\n\t\tIf dead Or suspended Return\r\n\t\tggraphics.BeginRender()\r\n\t\tIf vloading\r\n\t\t\tOnLoading()\r\n\t\tElse\r\n\t\t\tOnRender()\r\n\t\tEndIf\r\n\t\tggraphics.EndRender()\r\n\tEndMethod\r\n\t\r\n\t\r\n\tMethod SetFrameRate( fps:Int )\r\n\t\tIf fps\r\n\t\t\tupdatePeriod=1000.0\/fps;\r\n\t\t\tnextUpdate=BlitzMaxMillisecs() +updatePeriod;\r\n\t\tElse\r\n\t\t\tupdatePeriod=0\r\n\t\tEndIf\r\n\tEndMethod\r\n\t\r\n\tMethod LoadString:String( path:String )\r\n\t\tpath = \"data\/\" + path;\r\n\t\tReturn LoadText( path )\r\n\tEndMethod\r\n\t\r\n\t' ***** GXTK API *****\r\n\t\r\n\tMethod GraphicsDevice:gxtkGraphics()\r\n\t\tReturn ggraphics\r\n\tEndMethod\r\n\r\n\tMethod InputDevice:gxtkInput()\r\n\t\tReturn ginput\r\n\tEndMethod\r\n\r\n\tMethod AudioDevice:gxtkAudio()\r\n\t\tReturn gaudio\r\n\tEndMethod\r\n\r\n\tMethod SetUpdateRate:Int(hertz:Int)\r\n\t\tupdateRate = hertz\r\n\t\tIf Not vloading Then SetFrameRate(updateRate)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod MilliSecs:Int()\r\n\t\tReturn BlitzMaxMillisecs() - startMillis\r\n\tEndMethod\r\n\t\r\n\tMethod Loading:Int()\r\n\t\tReturn vloading;\r\n\tEndMethod\r\n\r\n\tMethod OnCreate:Int()\r\n\t\tReturn 0;\r\n\tEndMethod\r\n\r\n\tMethod OnUpdate:Int()\r\n\t\tReturn 0;\r\n\tEndMethod\r\n\t\r\n\tMethod OnSuspend:Int()\r\n\t\tReturn 0;\r\n\tEndMethod\r\n\t\r\n\tMethod OnResume:Int()\r\n\t\tReturn 0;\r\n\tEndMethod\r\n\t\r\n\tMethod OnRender:Int()\r\n\t\tReturn 0;\r\n\tEndMethod\r\n\t\r\n\tMethod OnLoading:Int()\r\n\t\tReturn 0;\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkGraphics\r\n\tField gmode:Int = 1\r\n\r\n\tMethod Mode:Int()\r\n\t\tReturn gmode\r\n\tEndMethod\r\n\t\r\n\tMethod Cls:Int(r:Int = 0, g:Int = 0, b:Int = 0)\r\n\t\tBlitzMaxCls(r, g, b)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod LoadSurface:gxtkSurface(path:String)\r\n\t\tLocal image:TImage = LoadImage(\"data\/\"+path)\r\n\t\tIf image Then\r\n\t\t\tLocal gs:gxtkSurface = New gxtkSurface\r\n\t\t\tgs.setImage(image)\r\n\t\t\tReturn gs\r\n\t\tEndIf\r\n\t\tReturn Null\r\n\tEndMethod\r\n\t\r\n\tMethod BeginRender()\r\n\tEndMethod\r\n\t\r\n\tMethod EndRender()\r\n\t\tFlip\r\n\tEndMethod\r\n\t\r\n\tMethod SetColor:Int(r:Int, g:Int, b:Int)\r\n\t\tBlitzMaxSetColor(r, g, b)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod SetAlpha:Int(a:Float)\r\n\t\tBlitzMaxSetAlpha(a)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod SetBlend:Int(blend:Int)\r\n\t\tBlitzMaxSetBlend(blend)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod Width:Int()\r\n\t\tReturn GraphicsWidth()\r\n\tEndMethod\r\n\t\r\n\tMethod Height:Int()\r\n\t\tReturn GraphicsHeight()\r\n\tEndMethod\r\n\t\r\n\tMethod SetScissor:Int(x:Int, y:Int, w:Int, h:Int)\r\n\t\tSetViewport(x, y, w, h) ' NOT TESTED!\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod SetMatrix:Int(ix:Float,iy:Float,jx:Float,jy:Float,tx:Float,ty:Float)\r\n\t\tLocal sx:Float = Sqr( (ix*ix) + (jx*jx) )\r\n\t\tLocal sy:Float = Sqr( (iy*iy) + (jy*jy) )\r\n\t\tLocal rot:Float = -Atan2( jx, ix )\r\n\t\tSetTransform( rot, sx, sy )\r\n\t\tSetOrigin( tx, ty )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawSurface:Int(surface:gxtkSurface,x:Float,y:Float)\r\n\t\tDrawImage(surface.image, x, y, 0)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawSurface2:Int(surface:gxtkSurface,x:Float,y:Float, srcx:Int, srcy:Int, srcw:Int, srch:Int )\r\n\t\tDrawSubImageRect(surface.image, x, y, srcw, srch, srcx, srcy, srcw, srch)\t\t\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawLine:Int( x1:Float,y1:Float,x2:Float,y2:Float )\r\n\t\tBlitzMaxDrawLine(x1, y1, x2, y2)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawOval:Int( x:Float, y:Float, w:Float, h:Float )\r\n\t\tBlitzMaxDrawOval(x, y, w, h)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawPoly:Int(vertices:Float[])\r\n\t\tBlitzMaxDrawPoly( vertices )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawRect:Int( x:Float, y:Float, w:Float, h:Float )\r\n\t\tBlitzMaxDrawRect(x, y, w, h)\r\n\t\tReturn 0\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkInput\r\n\tMethod MouseX:Float()\r\n\t\tReturn BRL.PolledInput.MouseX()\r\n\tEndMethod\r\n\r\n\tMethod MouseY:Float()\r\n\t\tReturn BRL.PolledInput.MouseY()\r\n\tEndMethod\r\n\t\r\n\tMethod KeyDown:Int( key:Int )\r\n\t\tIf( key >= 1 And key <= 3 )\r\n\t\t\tReturn BRL.PolledInput.MouseDown( key )\r\n\t\tEndIf\r\n\t\tReturn BRL.PolledInput.KeyDown( key )\r\n\tEndMethod\r\n\r\n\tMethod KeyHit:Int( key:Int )\r\n\t\tIf( key >= 1 And key <= 3 )\r\n\t\t\tReturn BRL.PolledInput.MouseHit( key )\r\n\t\tEndIf\r\n\t\tReturn BRL.PolledInput.KeyHit( key )\r\n\tEndMethod\r\n\r\n\tMethod GetChar:Int()\r\n\t\tReturn BRL.PolledInput.GetChar()\r\n\tEndMethod\r\n\r\n\tMethod JoyX:Int( index:Int )\r\n\t\tReturn Pub.FreeJoy.JoyX( index )\r\n\tEndMethod\r\n\r\n\tMethod JoyY:Int( index:Int )\r\n\t\tReturn Pub.FreeJoy.JoyY( index )\r\n\tEndMethod\r\n\r\n\tMethod JoyZ:Int( index:Int )\r\n\t\tReturn Pub.FreeJoy.JoyZ( index )\r\n\tEndMethod\r\n\r\n\tMethod TouchX:Float( index:Int )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod TouchY:Float( index:Int )\r\n\t\tReturn 0\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkChannel\r\n\tField channel:TChannel\t' null then not playing\r\n\tField sample:gxtkSample\r\n\tField loops:int\r\n\t'Field transform:SoundTransform=new SoundTransform()\r\n\t'Field pausepos:Number\r\n\tField state:int\r\n\t\r\n\tMethod New()\r\n\t\tchannel = New TChannel\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkAudio\r\n\tField amusicState:Int = 0;\r\n\tField channels:gxtkChannel[] = New gxtkChannel[33];\r\n\t\r\n\tMethod New()\r\n\t\tFor local i:Int = 0 To 33 - 1\r\n\t\t\tchannels[i] = New gxtkChannel\r\n\t\tNext\r\n\tEndMethod\r\n\t\r\n\tMethod MusicState:Int()\r\n'\t\tIf( musicState = 1 And music.isPlaying() = False )\r\n'\t\t\tmusicState = 0;\r\n'\t\tEndif\r\n\t\tReturn amusicState;\r\n\tEndMethod\r\n\t\r\n\tMethod PlayMusic:Int( path:String, flags:Int )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod StopMusic()\r\n\tEndMethod\r\n\t\r\n\tMethod StopChannel( channel:Int )\r\n\tEndMethod\r\n\r\n\tMethod PlaySample( sound:gxtkSample, channel:Int, flags:Int )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\t\r\n\t\t'If chan.state <> 0 Then chan.channel.Stop() <-- this crashes after the first play!?\r\n\t\t\r\n\t\tchan.sample = sound\r\n\t\t'chan.loops = flags ? 0x7fffffff : 0;\r\n\t\t'chan.channel = sample.sound.play( 0,chan.loops,chan.transform );\r\n\t\t'chan.channel = sound\r\n\t\tchan.state=1\r\n\t\r\n\t\tPlaySound( sound.sound, chan.channel )\r\n\tEndMethod\r\n\r\n\tMethod SetPan( channel:Int, pan:Float )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tchan.channel.SetPan(pan)\r\n\tEndMethod\r\n\r\n\tMethod SetRate( channel:Int, rate:Float )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tchan.channel.SetRate(rate)\r\n\tEndMethod\r\n\r\n\tMethod SetMusicVolume:Int( volume:Float )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod SetVolume:Int( channel:Int, volume:Float )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tchan.channel.SetVolume(volume)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod LoadSample:gxtkSample( path:String )\r\n\t\tLocal sound:TSound = LoadSound(\"data\/\"+path)\r\n\t\tIf sound Then\r\n\t\t\tLocal gs:gxtkSample = New gxtkSample\r\n\t\t\tgs.setSound(sound)\r\n\t\t\tReturn gs\r\n\t\tEndIf\r\n\t\tReturn Null\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkSample\r\n\tField sound:TSound\r\n\t\r\n\tMethod setSound(sound:TSound)\r\n\t\tSelf.sound = sound\r\n\tEndMethod\r\n\t\r\n\tMethod Discard()\r\n\t\tSelf.sound = null\r\n\tEndMethod\r\nEndType\r\n\r\nFunction BlitzMaxDrawPoly:Int(vertices:Float[])\r\n\tDrawPoly vertices\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxDrawRect:Int( x:Float, y:Float, w:Float, h:Float )\r\n\tDrawRect x, y, w, h\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxDrawOval:Int( x:Float, y:Float, w:Float, h:Float )\r\n\tDrawOval x, y, w, h\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxDrawLine:Int( x1:Float,y1:Float,x2:Float,y2:Float )\r\n\tDrawLine x1, y1, x2, y2\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxMillisecs:Int()\r\n\tReturn MilliSecs()\r\nEndFunction\r\n\r\nFunction BlitzMaxSetColor(r:Int, g:Int, b:Int)\r\n\tSetColor(r, g, b)\r\nEndFunction\r\n\r\nFunction BlitzMaxSetBlend(blend:Int)\r\n\tSelect blend\r\n\t\tCase 0\r\n\t\t\tSetBlend( ALPHABLEND )\r\n\t\tCase 1\r\n\t\t\tSetBlend( LIGHTBLEND )\r\n\tEnd Select\r\nEndFunction\r\n\r\nFunction BlitzMaxSetAlpha(a:Float)\r\n\tSetAlpha(a)\r\nEndFunction\r\n\r\nFunction BlitzMaxCls(r:Int = 0, g:Int = 0, b:Int = 0)\r\n\tSetClsColor(r, g, b)\r\n\tCls\r\nEndFunction\r\n\r\nType gxtkSurface\r\n\tField w:Int, h:Int\r\n\tField image:TImage\r\n\t\r\n\tMethod setImage(image:TImage)\r\n\t\tSelf.image = image\r\n\tEndMethod\r\n\t\r\n\tMethod Width:Int()\r\n\t\tReturn image.Width\r\n\tEndMethod\r\n\t\r\n\tMethod Height:Int()\r\n\t\tReturn image.Height\r\n\tEndMethod\r\n\t\r\n\tMethod Discard()\r\n\tEndMethod\r\nEndType\r\n\r\n' ***** End mojo.bmax.bmx ******\r\n\r\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"da9e8643590f5f58c867464eab883a8bfb185e01","subject":"Added mxVersionObject to represent version numbers","message":"Added mxVersionObject to represent version numbers\n\nrefs gh-1\n","repos":"maximos\/maximus","old_file":"src\/module.bmx","new_file":"src\/module.bmx","new_contents":"\nRem\n\tbbdoc: Maximus module base.\n\tabout: An abstract type for the similarities between module scopes and modules.\nEnd Rem\nType mxModuleBase Abstract\n\t\n\tField m_name:String\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the base's name.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetName(name:String)\n\t\tAssert name, \"(mxModuleBase.SetName) name cannot be Null\"\n\t\tm_name = name\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the base's name.\n\t\treturns: The base's name.\n\tEnd Rem\n\tMethod GetName:String()\n\t\tReturn m_name\n\tEnd Method\n\t\n'#end region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set a common field from the given variable.\n\t\treturns: True if the given variable was handled, or False if it was not.\n\tEnd Rem\n\tMethod SetCommonFromVariable:Int(variable:dVariable)\n\t\tReturn False\n\tEnd Method\n\t\nEnd Type\n\nRem\n\tbbdoc: Maximus module scope.\nEnd Rem\nType mxModuleScope Extends mxModuleBase\n\t\n\tField m_modules:dObjectMap\n\t\n\tMethod New()\n\t\tm_modules = New dObjectMap\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Add the given module to the scope.\n\t\treturns: True if the module was added, or False if it was not (the module is Null).\n\tEnd Rem\n\tMethod AddModule:Int(modul:mxModule)\n\t\tIf modul\n\t\t\tm_modules._Insert(modul.GetName(), modul)\n\t\t\tmodul.SetParent(Self)\n\t\t\tReturn True\n\t\tEnd If\n\t\tReturn False\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Check if the given module name is found in the scope.\n\t\treturns: True if the given module was found in the scope, or False if it was not.\n\tEnd Rem\n\tMethod HasModule:Int(modname:String)\n\t\tReturn m_modules._Contains(modname)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get a module with the given name.\n\t\treturns: The module with the given name, or Null if there is no module with the given name.\n\tEnd Rem\n\tMethod GetModuleWithName:mxModule(modname:String)\n\t\tReturn mxModule(m_modules._ObjectWithKey(modname))\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Load the given dJObject into the scope.\n\t\treturns: Itself, or Null if @root is Null.\n\tEnd Rem\n\tMethod FromJSON:mxModuleScope(root:dJObject)\n\t\tIf root\n\t\t\tSetName(root.GetName())\n\t\t\tFor Local variable:dVariable = EachIn root\n\t\t\t\tIf dJObject(variable)\n\t\t\t\t\tAddModule(New mxModule.FromJSON(dJObject(variable)))\n\t\t\t\t'Else\n\t\t\t\t'\tSetCommonFromVariable(variable)\n\t\t\t\tEnd If\n\t\t\tNext\n\t\t\tReturn Self\n\t\tEnd If\n\t\tReturn Null\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the module enumerator for the scope.\n\t\treturns: The module enumerator for the scope.\n\tEnd Rem\n\tMethod ModuleEnumerator:TMapEnumerator()\n\t\tReturn m_modules.ValueEnumerator()\n\tEnd Method\n\t\nEnd Type\n\nRem\n\tbbdoc: Maximus module.\nEnd Rem\nType mxModule Extends mxModuleBase\n\t\n\tField m_parent:mxModuleScope\n\tField m_description:String\n\tField m_versions:dObjectMap\n\t\n\tMethod New()\n\t\tm_versions = New dObjectMap\n\tEnd Method\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the module's parent.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetParent(parent:mxModuleScope)\n\t\tm_parent = parent\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the module's parent.\n\t\treturns: The module's parent.\n\tEnd Rem\n\tMethod GetParent:mxModuleScope()\n\t\tReturn m_parent\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the full name of the module (e.g. \"modscope.module\").\n\t\treturns: The full name of the module.\n\tEnd Rem\n\tMethod GetFullName:String()\n\t\tReturn m_parent.m_name + \".\" + m_name\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the module's description.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetDescription(description:String)\n\t\tm_description = description\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the module's description.\n\t\treturns: The module's description.\n\tEnd Rem\n\tMethod GetDescription:String()\n\t\tReturn m_description\n\tEnd Method\n\t\n'#end region Field accessors\n\t\n\tRem\n\t\tbbdoc: Get the installed version of the module (if it is installed).\n\t\treturns: The version of the module that is installed, or Null if the module is not installed.\n\tEnd Rem\n\tMethod GetInstalledVersion:mxModuleVersion()\n\t\tLocal version:String = mxModUtils.GetInstalledVersionFromVerID(GetFullName())\n\t\tIf version\n\t\t\tReturn New mxModuleVersion.Create(Self, version, Null)\n\t\tEnd If\n\t\tReturn Null\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Add the given version to the module.\n\t\treturns: True if the version was added, or False if it was not (the version is Null).\n\tEnd Rem\n\tMethod AddVersion:Int(version:mxModuleVersion)\n\t\tIf version\n\t\t\tm_versions._Insert(version.GetName(), version)\n\t\t\tversion.SetParent(Self)\n\t\t\tReturn True\n\t\tEnd If\n\t\tReturn False\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Check if there is a version with the given name.\n\t\treturns: True if the version was found, or False if it was not.\n\tEnd Rem\n\tMethod HasVersion:Int(name:String)\n\t\tReturn m_versions._Contains(name)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get a version with the given name.\n\t\treturns: The version with the given name, or Null if there is no version with the given name.\n\tEnd Rem\n\tMethod GetVersionWithName:mxModuleVersion(name:String)\n\t\tReturn mxModuleVersion(m_versions._ObjectWithKey(name))\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the latest (non-dev if available) version for this module.\n\t\treturns: The latest version for this module.\n\t\tabout: The latest version will be returned, or the dev version if it is the only version.\n\tEnd Rem\n\tMethod GetLatestVersion:mxModuleVersion()\n\t\tLocal hver:mxModuleVersion\n\t\tFor Local ver:mxModuleVersion = EachIn VersionEnumerator()\n\t\t\tIf ver.GetName() <> \"dev\"\n\t\t\t\tIf Not hver Or ver.Compare(hver) = 1\n\t\t\t\t\thver = ver\n\t\t\t\tEnd If\n\t\t\tEnd If\n\t\tNext\n\t\tIf Not hver\n\t\t\thver = GetVersionWithName(\"dev\")\n\t\tEnd If\n\t\tReturn hver\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set a common field from the given variable.\n\t\treturns: True if the given variable was handled, or False if it was not.\n\tEnd Rem\n\tMethod SetCommonFromVariable:Int(variable:dVariable)\n\t\tIf Super.SetCommonFromVariable(variable)\n\t\t\tReturn True\n\t\tElse\n\t\t\tSelect variable.GetName().ToLower()\n\t\t\t\tCase \"desc\"\n\t\t\t\t\tSetDescription(dValueVariable(variable).ValueAsString())\n\t\t\t\tCase \"versions\"\n\t\t\t\t\tFor Local jobj:dJObject = EachIn dJObject(variable)\n\t\t\t\t\t\tAddVersion(New mxModuleVersion.FromJSON(jobj))\n\t\t\t\t\tNext\n\t\t\t\tDefault\n\t\t\t\t\tReturn False\n\t\t\tEnd Select\n\t\t\tReturn True\n\t\tEnd If\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Load the given dJObject into the module.\n\t\treturns: Itself, or Null if @root is Null.\n\tEnd Rem\n\tMethod FromJSON:mxModule(root:dJObject)\n\t\tIf root\n\t\t\tSetName(root.GetName())\n\t\t\tFor Local variable:dVariable = EachIn root\n\t\t\t\tSetCommonFromVariable(variable)\n\t\t\tNext\n\t\t\tReturn Self\n\t\tEnd If\n\t\tReturn Null\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the version enumerator for the module.\n\t\treturns: The version enumerator for the module.\n\tEnd Rem\n\tMethod VersionEnumerator:TMapEnumerator()\n\t\tReturn m_versions.ValueEnumerator()\n\tEnd Method\n\t\nEnd Type\n\nRem\n\tbbdoc: Maximus module version.\nEnd Rem\nType mxModuleVersion\n\t\n\tField m_parent:mxModule\n\tField m_name:String, m_url:String\n\tField m_dependencies:mxModuleDependencies\n\t\n\tMethod New()\n\t\tm_dependencies = New mxModuleDependencies\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Create a module version.\n\t\treturns: Itself.\n\tEnd Rem\n\tMethod Create:mxModuleVersion(parent:mxModule, name:String, url:String)\n\t\tSetParent(parent)\n\t\tSetName(name)\n\t\tSetUrl(url)\n\t\tReturn Self\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Clone the version.\n\t\treturns: A clone of the version.\n\t\tabout: If @withdeps is True (default value), the dependencies will be added as well.\n\tEnd Rem\n\tMethod Clone:mxModuleVersion(withdeps:Int = True)\n\t\tLocal v:mxModuleVersion = New mxModuleVersion.Create(m_parent, m_name, m_url)\n\t\tFor Local dep:mxModuleDependency = EachIn DependencyEnumerator()\n\t\t\tv.m_dependencies.AddDependency(dep)\n\t\tNext\n\t\tReturn v\n\tEnd Method\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the version's parent.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetParent(parent:mxModule)\n\t\tm_parent = parent\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the version's parent.\n\t\treturns: The version's parent.\n\tEnd Rem\n\tMethod GetParent:mxModule()\n\t\tReturn m_parent\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the version's name.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetName(name:String)\n\t\tAssert name, \"(mxModuleVersion.SetName) name cannot be Null!\"\n\t\tm_name = name\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the version's name.\n\t\treturns: The version's name.\n\tEnd Rem\n\tMethod GetName:String()\n\t\tReturn m_name\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the version's url.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetUrl(url:String)\n\t\t'Assert url, \"(mxModuleVersion.SetUrl) url cannot be Null!\"\n\t\tm_url = url\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the version's url.\n\t\treturns: The version's url.\n\tEnd Rem\n\tMethod GetUrl:String()\n\t\tReturn m_url\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the temporary fetch path for the version's source archive.\n\t\treturns: The temporary file path for the version's source archive.\n\tEnd Rem\n\tMethod GetTemporaryFilePath:String()\n\t\tReturn \"tmp\/\" + m_parent.GetFullName() + \"-\" + m_name + \".zip\"\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the version's dependencies.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetDependencies(dependencies:mxModuleDependencies)\n\t\tm_dependencies = dependencies\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the version's dependencies.\n\t\treturns: The version's dependencies.\n\tEnd Rem\n\tMethod GetDependencies:mxModuleDependencies()\n\t\tReturn m_dependencies\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the version parts for the version.\n\t\treturns: True if the version is development, in which case the parameters are both 0; or False, in which case the parameters are set accordingly.\n\tEnd Rem\n\tMethod GetVersionParts:Int(vmajor:String Var, vminor:String Var)\n\t\tIf m_name <> \"dev\"\n\t\t\tLocal i:Int = m_name.Find(\".\")\n\t\t\tIf i > -1\n\t\t\t\tvmajor = m_name[..i]\n\t\t\t\tvminor = m_name[i + 1..]\n\t\t\tElse\n\t\t\t\tvmajor = m_name ' I'm not sure what other version formats would be used, so I'm just playing a random card here\n\t\t\tEnd If\n\t\t\tReturn False\n\t\tEnd If\n\t\tReturn True\n\tEnd Method\n\t\n'#end region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set a common field from the given variable.\n\t\treturns: True if the given variable was handled, or False if it was not.\n\tEnd Rem\n\tMethod SetCommonFromVariable:Int(variable:dVariable)\n\t\tSelect variable.GetName().ToLower()\n\t\t\tCase \"url\"\n\t\t\t\tSetUrl(dValueVariable(variable).ValueAsString())\n\t\t\tCase \"deps\"\n\t\t\t\tm_dependencies.FromJSON(dJArray(variable))\n\t\t\tDefault\n\t\t\t\tReturn False\n\t\tEnd Select\n\t\tReturn True\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Load the given dJObject into the version.\n\t\treturns: Itself, or Null if @root is Null.\n\tEnd Rem\n\tMethod FromJSON:mxModuleVersion(root:dJObject)\n\t\tIf root\n\t\t\tSetName(root.GetName())\n\t\t\tFor Local variable:dVariable = EachIn root\n\t\t\t\tSetCommonFromVariable(variable)\n\t\t\tNext\n\t\t\tReturn Self\n\t\tEnd If\n\t\tReturn Null\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the dependency enumerator for the version.\n\t\treturns: The dependency enumerator for the version.\n\tEnd Rem\n\tMethod DependencyEnumerator:TMapEnumerator()\n\t\tReturn m_dependencies.DependencyEnumerator()\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Compare the version with the given version.\n\t\treturns: 0 if the two versions are the same (same in version number alone), 1 if this version is greater than the given, or -1 if the given version is greater than this version.\n\tEnd Rem\n\tMethod Compare:Int(with:Object)\n\t\tLocal ver:mxModuleVersion = mxModuleVersion(with)\n\t\tIf ver\n\t\t\tIf m_name = ver.m_name\n\t\t\t\tReturn 0\n\t\t\tElse\n\t\t\t\tLocal smajor:String, sminor:String, wmajor:String, wminor:String\n\t\t\t\tLocal sdev:Int = GetVersionParts(smajor, sminor), wdev:Int = ver.GetVersionParts(wmajor, wminor)\n\t\t\t\tIf (sdev And wdev) Or (smajor = wmajor And sminor = wminor)\n\t\t\t\t\tReturn 0\n\t\t\t\tElse If smajor > wmajor\n\t\t\t\t\tReturn 1\n\t\t\t\tElse If smajor = wmajor\n\t\t\t\t\tIf sminor > wminor\n\t\t\t\t\t\tReturn 1\n\t\t\t\t\tElse\n\t\t\t\t\t\tReturn -1\n\t\t\t\t\tEnd If\n\t\t\t\tElse\n\t\t\t\t\tReturn -1\n\t\t\t\tEnd If\n\t\t\tEnd If\n\t\tEnd If\n\t\tReturn Super.Compare(with)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Fetch the version's source archive.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod FetchSourceArchive()\n\t\tLocal file:String = GetTemporaryFilePath()\n\t\tlogger.LogMessage(\"fetching: \" + GetUrl() + \" -> \" + file + \" \", False)\n\t\tIf FileType(file) = FILETYPE_NONE\n\t\t\tLocal stream:TStream = WriteFileExplicitly(file)\n\t\t\tIf stream\n\t\t\t\tLocal request:TRESTRequest = New TRESTRequest, response:TRESTResponse\n\t\t\t\trequest.SetProgressCallback(_ProgressCallback, New _mxProgressStore)\n\t\t\t\trequest.SetStream(stream)\n\t\t\t\tTry\n\t\t\t\t\tresponse = request.Call(GetUrl(), [\"User-Agent: \" + mainapp.m_useragent], \"GET\")\n\t\t\t\tCatch e:Object\n\t\t\t\t\tstream.Close()\n\t\t\t\t\tDeleteFile(file)\n\t\t\t\t\tlogger.LogMessage(\"\")\n\t\t\t\t\tThrowError(_s(\"error.fetch.archive\", [e.ToString()]))\n\t\t\t\tEnd Try\n\t\t\t\tstream.Close()\n\t\t\t\tIf response.responseCode = 200\n\t\t\t\t\tlogger.LogMessage(_s(\"message.fetch.done\", [String(response.responseCode)]))\n\t\t\t\tElse\n\t\t\t\t\tDeleteFile(file)\n\t\t\t\t\tlogger.LogMessage(\"\")\n\t\t\t\t\tThrowError(_s(\"error.fetch.archive\", [\"Bad response code: \" + String(response.responseCode)]))\n\t\t\t\tEnd If\n\t\t\tElse\n\t\t\t\tThrowError(_s(\"error.writeperms\", [file]))\n\t\t\tEnd If\n\t\tElse\n\t\t\tlogger.LogMessage(_s(\"message.fetch.alreadyfetched\"))\n\t\tEnd If\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Progress callback for source archive fetching.\n\t\treturns: Zero (no error).\n\tEnd Rem\n\tFunction _ProgressCallback:Int(data:Object, dltotal:Double, dlnow:Double, ultotal:Double, ulnow:Double)\n\t\tLocal store:_mxProgressStore = _mxProgressStore(data)\n\t\tLocal prog:Int = (dlnow \/ dltotal) * 100\n\t\tIf prog > store.m_progress + 5\n\t\t\tstore.m_progress = prog\n\t\t\tWriteStdOut(\".\")\n\t\tEnd If\n\t\tReturn 0\n\tEnd Function\n\t\nEnd Type\n\nRem\n\tbbdoc: A object representing a version, not to be confused with mxModuleVersion\n\tabout: Supported formats are 1, 1.1 and 1.1.1.\n\tDo note that because the version is represented as a Double there's a change\n\tthe precision of the final number is off.\n\t\n\t1.1.2 Would be converted to 1.001002 but when converted to a Double it results\n\tin 1.0010019999999999.\n\t\n\t1.1.12 However would be converted to 1.001012 and when converted to a Double it\n\tresults in 1.0010120000000000.\n\t\n\tA version string of 'dev' will be represented as 99999\nEnd Rem\nType mxVersionObject\n\n\tField m_version:Double\n\n\tRem\n\t\tbbdoc: Parse a version string\n\t\treturns: Itself.\n\tEnd Rem\n\tMethod Parse:mxVersionObject(version:String)\n\t\tIf version = \"dev\"\n\t\t\tm_version = 99999\n\t\t\tReturn Self\n\t\tEnd If\n\n\t\tLocal parts:String[] = version.Split(\".\")\n\t\tLocal converted:String = parts[0]\n\t\tIf parts.Length > 1\n\t\t\tconverted:+\".\"\n\t\t\tFor Local part:String = EachIn parts[1..]\n\t\t\t\tWhile part.Length <> 3\n\t\t\t\t\tpart = \"0\" + part\n\t\t\t\tWEnd\n\t\t\t\tconverted:+part\n\t\t\tNext\n\n\t\t\t'Make sure we format to x.x.x\n\t\t\tIf parts.Length = 2\n\t\t\t\tconverted:+\"000\"\n\t\t\tEnd If\n\t\tEnd If\n\n\t\tm_version = converted.ToDouble()\n\t\tReturn Self\n\tEnd Method\n\n\tRem\n\t\tbbdoc: Compare version numbers\n\tEnd Rem\n\tMethod Compare:Int(withObject:Object)\n\t\tLocal version:mxVersionObject = mxVersionObject(withObject)\n\t\tIf version\n\t\t\tIf m_version = version.m_version\n\t\t\t\tReturn 0\n\t\t\tElse If m_version > version.m_version\n\t\t\t\tReturn 1\n\t\t\tElse If m_version < version.m_version\n\t\t\t\tReturn - 1\n\t\t\tEnd If\n\t\tEnd If\n\t\tReturn Super.Compare(withObject)\n\tEnd Method\nEnd Type\n\nRem\n\tbbdoc: Maximus metafile handler\nEnd Rem\nType mxMetaFile\n\n\tField m_metafile:String\n\tField m_scope:String\n\tField m_name:String\n\tField m_version:String\n\t\n\tRem\n\t\tbbdoc: Create a metafile handler.\n\t\treturns: Itself.\n\tEnd Rem\n\tMethod Create:mxMetaFile(metafile:String)\n\t\tSetMetaFile(metafile)\n\t\tReturn Self\n\tEnd Method\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the metafile file path.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetMetaFile(metafile:String)\n\t\tm_metafile = metafile\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the metafile path.\n\t\treturns: The metafile path.\n\tEnd Rem\n\tMethod GetMetaFile:String()\n\t\tReturn m_metafile\n\tEnd Method\n\t\n'#end region Field accessors\n\t\n\tRem\n\t\tbbdoc: Load the configuration.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod Load()\n\t\tIf FileType(GetMetaFile()) = FILETYPE_FILE\n\t\t\tTry\n\t\t\t\tLocal contents:String = LoadText(GetMetaFile()).Trim()\n\t\t\t\tLocal parts:String[] = contents.Split(\"\/\")\n\t\t\t\t\n\t\t\t\tIf parts.Length <> 2\n\t\t\t\t\tThrow _s(\"error.load.meta.invalid_format\") ;\n\t\t\t\tEnd If\n\t\t\t\t\n\t\t\t\tLocal modinfo:String[] = parts[0].Split(\".\")\n\t\t\t\tm_scope = modinfo[0]\n\t\t\t\tm_name = modinfo[1]\n\t\t\t\tm_version = parts[1]\n\t\t\tCatch e:Object\n\t\t\t\tlogger.LogError(_s(\"error.load.metafile.parse\", [GetMetaFile()]))\n\t\t\t\tlogger.LogError(_s(\"error.load.metafile.parse\", [e.ToString()]))\n\t\t\tEnd Try\n\t\tElse\n\t\t\tlogger.LogWarning(_s(\"error.load.metafile.notfound\", [GetMetaFile()]))\n\t\tEnd If\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Save the configuration\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod Save()\n\t\tIf m_scope.Length = 0 Or m_name.Length = 0 Or m_version.Length = 0\n\t\t\tThrowError(_s(\"error.save.metafile.incomplete\", [m_scope, m_name, m_version]))\n\t\tEnd If\n\t\t\n\t\tLocal stream:TStream = WriteFileExplicitly(GetMetaFile())\n\t\tstream.WriteString(m_scope + \".\" + m_name + \"\/\" + m_version)\n\t\tstream.Close\n\tEnd Method\nEnd Type\n","old_contents":"\nRem\n\tbbdoc: Maximus module base.\n\tabout: An abstract type for the similarities between module scopes and modules.\nEnd Rem\nType mxModuleBase Abstract\n\t\n\tField m_name:String\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the base's name.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetName(name:String)\n\t\tAssert name, \"(mxModuleBase.SetName) name cannot be Null\"\n\t\tm_name = name\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the base's name.\n\t\treturns: The base's name.\n\tEnd Rem\n\tMethod GetName:String()\n\t\tReturn m_name\n\tEnd Method\n\t\n'#end region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set a common field from the given variable.\n\t\treturns: True if the given variable was handled, or False if it was not.\n\tEnd Rem\n\tMethod SetCommonFromVariable:Int(variable:dVariable)\n\t\tReturn False\n\tEnd Method\n\t\nEnd Type\n\nRem\n\tbbdoc: Maximus module scope.\nEnd Rem\nType mxModuleScope Extends mxModuleBase\n\t\n\tField m_modules:dObjectMap\n\t\n\tMethod New()\n\t\tm_modules = New dObjectMap\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Add the given module to the scope.\n\t\treturns: True if the module was added, or False if it was not (the module is Null).\n\tEnd Rem\n\tMethod AddModule:Int(modul:mxModule)\n\t\tIf modul\n\t\t\tm_modules._Insert(modul.GetName(), modul)\n\t\t\tmodul.SetParent(Self)\n\t\t\tReturn True\n\t\tEnd If\n\t\tReturn False\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Check if the given module name is found in the scope.\n\t\treturns: True if the given module was found in the scope, or False if it was not.\n\tEnd Rem\n\tMethod HasModule:Int(modname:String)\n\t\tReturn m_modules._Contains(modname)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get a module with the given name.\n\t\treturns: The module with the given name, or Null if there is no module with the given name.\n\tEnd Rem\n\tMethod GetModuleWithName:mxModule(modname:String)\n\t\tReturn mxModule(m_modules._ObjectWithKey(modname))\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Load the given dJObject into the scope.\n\t\treturns: Itself, or Null if @root is Null.\n\tEnd Rem\n\tMethod FromJSON:mxModuleScope(root:dJObject)\n\t\tIf root\n\t\t\tSetName(root.GetName())\n\t\t\tFor Local variable:dVariable = EachIn root\n\t\t\t\tIf dJObject(variable)\n\t\t\t\t\tAddModule(New mxModule.FromJSON(dJObject(variable)))\n\t\t\t\t'Else\n\t\t\t\t'\tSetCommonFromVariable(variable)\n\t\t\t\tEnd If\n\t\t\tNext\n\t\t\tReturn Self\n\t\tEnd If\n\t\tReturn Null\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the module enumerator for the scope.\n\t\treturns: The module enumerator for the scope.\n\tEnd Rem\n\tMethod ModuleEnumerator:TMapEnumerator()\n\t\tReturn m_modules.ValueEnumerator()\n\tEnd Method\n\t\nEnd Type\n\nRem\n\tbbdoc: Maximus module.\nEnd Rem\nType mxModule Extends mxModuleBase\n\t\n\tField m_parent:mxModuleScope\n\tField m_description:String\n\tField m_versions:dObjectMap\n\t\n\tMethod New()\n\t\tm_versions = New dObjectMap\n\tEnd Method\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the module's parent.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetParent(parent:mxModuleScope)\n\t\tm_parent = parent\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the module's parent.\n\t\treturns: The module's parent.\n\tEnd Rem\n\tMethod GetParent:mxModuleScope()\n\t\tReturn m_parent\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the full name of the module (e.g. \"modscope.module\").\n\t\treturns: The full name of the module.\n\tEnd Rem\n\tMethod GetFullName:String()\n\t\tReturn m_parent.m_name + \".\" + m_name\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the module's description.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetDescription(description:String)\n\t\tm_description = description\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the module's description.\n\t\treturns: The module's description.\n\tEnd Rem\n\tMethod GetDescription:String()\n\t\tReturn m_description\n\tEnd Method\n\t\n'#end region Field accessors\n\t\n\tRem\n\t\tbbdoc: Get the installed version of the module (if it is installed).\n\t\treturns: The version of the module that is installed, or Null if the module is not installed.\n\tEnd Rem\n\tMethod GetInstalledVersion:mxModuleVersion()\n\t\tLocal version:String = mxModUtils.GetInstalledVersionFromVerID(GetFullName())\n\t\tIf version\n\t\t\tReturn New mxModuleVersion.Create(Self, version, Null)\n\t\tEnd If\n\t\tReturn Null\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Add the given version to the module.\n\t\treturns: True if the version was added, or False if it was not (the version is Null).\n\tEnd Rem\n\tMethod AddVersion:Int(version:mxModuleVersion)\n\t\tIf version\n\t\t\tm_versions._Insert(version.GetName(), version)\n\t\t\tversion.SetParent(Self)\n\t\t\tReturn True\n\t\tEnd If\n\t\tReturn False\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Check if there is a version with the given name.\n\t\treturns: True if the version was found, or False if it was not.\n\tEnd Rem\n\tMethod HasVersion:Int(name:String)\n\t\tReturn m_versions._Contains(name)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get a version with the given name.\n\t\treturns: The version with the given name, or Null if there is no version with the given name.\n\tEnd Rem\n\tMethod GetVersionWithName:mxModuleVersion(name:String)\n\t\tReturn mxModuleVersion(m_versions._ObjectWithKey(name))\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the latest (non-dev if available) version for this module.\n\t\treturns: The latest version for this module.\n\t\tabout: The latest version will be returned, or the dev version if it is the only version.\n\tEnd Rem\n\tMethod GetLatestVersion:mxModuleVersion()\n\t\tLocal hver:mxModuleVersion\n\t\tFor Local ver:mxModuleVersion = EachIn VersionEnumerator()\n\t\t\tIf ver.GetName() <> \"dev\"\n\t\t\t\tIf Not hver Or ver.Compare(hver) = 1\n\t\t\t\t\thver = ver\n\t\t\t\tEnd If\n\t\t\tEnd If\n\t\tNext\n\t\tIf Not hver\n\t\t\thver = GetVersionWithName(\"dev\")\n\t\tEnd If\n\t\tReturn hver\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set a common field from the given variable.\n\t\treturns: True if the given variable was handled, or False if it was not.\n\tEnd Rem\n\tMethod SetCommonFromVariable:Int(variable:dVariable)\n\t\tIf Super.SetCommonFromVariable(variable)\n\t\t\tReturn True\n\t\tElse\n\t\t\tSelect variable.GetName().ToLower()\n\t\t\t\tCase \"desc\"\n\t\t\t\t\tSetDescription(dValueVariable(variable).ValueAsString())\n\t\t\t\tCase \"versions\"\n\t\t\t\t\tFor Local jobj:dJObject = EachIn dJObject(variable)\n\t\t\t\t\t\tAddVersion(New mxModuleVersion.FromJSON(jobj))\n\t\t\t\t\tNext\n\t\t\t\tDefault\n\t\t\t\t\tReturn False\n\t\t\tEnd Select\n\t\t\tReturn True\n\t\tEnd If\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Load the given dJObject into the module.\n\t\treturns: Itself, or Null if @root is Null.\n\tEnd Rem\n\tMethod FromJSON:mxModule(root:dJObject)\n\t\tIf root\n\t\t\tSetName(root.GetName())\n\t\t\tFor Local variable:dVariable = EachIn root\n\t\t\t\tSetCommonFromVariable(variable)\n\t\t\tNext\n\t\t\tReturn Self\n\t\tEnd If\n\t\tReturn Null\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the version enumerator for the module.\n\t\treturns: The version enumerator for the module.\n\tEnd Rem\n\tMethod VersionEnumerator:TMapEnumerator()\n\t\tReturn m_versions.ValueEnumerator()\n\tEnd Method\n\t\nEnd Type\n\nRem\n\tbbdoc: Maximus module version.\nEnd Rem\nType mxModuleVersion\n\t\n\tField m_parent:mxModule\n\tField m_name:String, m_url:String\n\tField m_dependencies:mxModuleDependencies\n\t\n\tMethod New()\n\t\tm_dependencies = New mxModuleDependencies\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Create a module version.\n\t\treturns: Itself.\n\tEnd Rem\n\tMethod Create:mxModuleVersion(parent:mxModule, name:String, url:String)\n\t\tSetParent(parent)\n\t\tSetName(name)\n\t\tSetUrl(url)\n\t\tReturn Self\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Clone the version.\n\t\treturns: A clone of the version.\n\t\tabout: If @withdeps is True (default value), the dependencies will be added as well.\n\tEnd Rem\n\tMethod Clone:mxModuleVersion(withdeps:Int = True)\n\t\tLocal v:mxModuleVersion = New mxModuleVersion.Create(m_parent, m_name, m_url)\n\t\tFor Local dep:mxModuleDependency = EachIn DependencyEnumerator()\n\t\t\tv.m_dependencies.AddDependency(dep)\n\t\tNext\n\t\tReturn v\n\tEnd Method\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the version's parent.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetParent(parent:mxModule)\n\t\tm_parent = parent\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the version's parent.\n\t\treturns: The version's parent.\n\tEnd Rem\n\tMethod GetParent:mxModule()\n\t\tReturn m_parent\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the version's name.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetName(name:String)\n\t\tAssert name, \"(mxModuleVersion.SetName) name cannot be Null!\"\n\t\tm_name = name\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the version's name.\n\t\treturns: The version's name.\n\tEnd Rem\n\tMethod GetName:String()\n\t\tReturn m_name\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the version's url.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetUrl(url:String)\n\t\t'Assert url, \"(mxModuleVersion.SetUrl) url cannot be Null!\"\n\t\tm_url = url\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the version's url.\n\t\treturns: The version's url.\n\tEnd Rem\n\tMethod GetUrl:String()\n\t\tReturn m_url\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the temporary fetch path for the version's source archive.\n\t\treturns: The temporary file path for the version's source archive.\n\tEnd Rem\n\tMethod GetTemporaryFilePath:String()\n\t\tReturn \"tmp\/\" + m_parent.GetFullName() + \"-\" + m_name + \".zip\"\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the version's dependencies.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetDependencies(dependencies:mxModuleDependencies)\n\t\tm_dependencies = dependencies\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the version's dependencies.\n\t\treturns: The version's dependencies.\n\tEnd Rem\n\tMethod GetDependencies:mxModuleDependencies()\n\t\tReturn m_dependencies\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the version parts for the version.\n\t\treturns: True if the version is development, in which case the parameters are both 0; or False, in which case the parameters are set accordingly.\n\tEnd Rem\n\tMethod GetVersionParts:Int(vmajor:String Var, vminor:String Var)\n\t\tIf m_name <> \"dev\"\n\t\t\tLocal i:Int = m_name.Find(\".\")\n\t\t\tIf i > -1\n\t\t\t\tvmajor = m_name[..i]\n\t\t\t\tvminor = m_name[i + 1..]\n\t\t\tElse\n\t\t\t\tvmajor = m_name ' I'm not sure what other version formats would be used, so I'm just playing a random card here\n\t\t\tEnd If\n\t\t\tReturn False\n\t\tEnd If\n\t\tReturn True\n\tEnd Method\n\t\n'#end region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set a common field from the given variable.\n\t\treturns: True if the given variable was handled, or False if it was not.\n\tEnd Rem\n\tMethod SetCommonFromVariable:Int(variable:dVariable)\n\t\tSelect variable.GetName().ToLower()\n\t\t\tCase \"url\"\n\t\t\t\tSetUrl(dValueVariable(variable).ValueAsString())\n\t\t\tCase \"deps\"\n\t\t\t\tm_dependencies.FromJSON(dJArray(variable))\n\t\t\tDefault\n\t\t\t\tReturn False\n\t\tEnd Select\n\t\tReturn True\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Load the given dJObject into the version.\n\t\treturns: Itself, or Null if @root is Null.\n\tEnd Rem\n\tMethod FromJSON:mxModuleVersion(root:dJObject)\n\t\tIf root\n\t\t\tSetName(root.GetName())\n\t\t\tFor Local variable:dVariable = EachIn root\n\t\t\t\tSetCommonFromVariable(variable)\n\t\t\tNext\n\t\t\tReturn Self\n\t\tEnd If\n\t\tReturn Null\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the dependency enumerator for the version.\n\t\treturns: The dependency enumerator for the version.\n\tEnd Rem\n\tMethod DependencyEnumerator:TMapEnumerator()\n\t\tReturn m_dependencies.DependencyEnumerator()\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Compare the version with the given version.\n\t\treturns: 0 if the two versions are the same (same in version number alone), 1 if this version is greater than the given, or -1 if the given version is greater than this version.\n\tEnd Rem\n\tMethod Compare:Int(with:Object)\n\t\tLocal ver:mxModuleVersion = mxModuleVersion(with)\n\t\tIf ver\n\t\t\tIf m_name = ver.m_name\n\t\t\t\tReturn 0\n\t\t\tElse\n\t\t\t\tLocal smajor:String, sminor:String, wmajor:String, wminor:String\n\t\t\t\tLocal sdev:Int = GetVersionParts(smajor, sminor), wdev:Int = ver.GetVersionParts(wmajor, wminor)\n\t\t\t\tIf (sdev And wdev) Or (smajor = wmajor And sminor = wminor)\n\t\t\t\t\tReturn 0\n\t\t\t\tElse If smajor > wmajor\n\t\t\t\t\tReturn 1\n\t\t\t\tElse If smajor = wmajor\n\t\t\t\t\tIf sminor > wminor\n\t\t\t\t\t\tReturn 1\n\t\t\t\t\tElse\n\t\t\t\t\t\tReturn -1\n\t\t\t\t\tEnd If\n\t\t\t\tElse\n\t\t\t\t\tReturn -1\n\t\t\t\tEnd If\n\t\t\tEnd If\n\t\tEnd If\n\t\tReturn Super.Compare(with)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Fetch the version's source archive.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod FetchSourceArchive()\n\t\tLocal file:String = GetTemporaryFilePath()\n\t\tlogger.LogMessage(\"fetching: \" + GetUrl() + \" -> \" + file + \" \", False)\n\t\tIf FileType(file) = FILETYPE_NONE\n\t\t\tLocal stream:TStream = WriteFileExplicitly(file)\n\t\t\tIf stream\n\t\t\t\tLocal request:TRESTRequest = New TRESTRequest, response:TRESTResponse\n\t\t\t\trequest.SetProgressCallback(_ProgressCallback, New _mxProgressStore)\n\t\t\t\trequest.SetStream(stream)\n\t\t\t\tTry\n\t\t\t\t\tresponse = request.Call(GetUrl(), [\"User-Agent: \" + mainapp.m_useragent], \"GET\")\n\t\t\t\tCatch e:Object\n\t\t\t\t\tstream.Close()\n\t\t\t\t\tDeleteFile(file)\n\t\t\t\t\tlogger.LogMessage(\"\")\n\t\t\t\t\tThrowError(_s(\"error.fetch.archive\", [e.ToString()]))\n\t\t\t\tEnd Try\n\t\t\t\tstream.Close()\n\t\t\t\tIf response.responseCode = 200\n\t\t\t\t\tlogger.LogMessage(_s(\"message.fetch.done\", [String(response.responseCode)]))\n\t\t\t\tElse\n\t\t\t\t\tDeleteFile(file)\n\t\t\t\t\tlogger.LogMessage(\"\")\n\t\t\t\t\tThrowError(_s(\"error.fetch.archive\", [\"Bad response code: \" + String(response.responseCode)]))\n\t\t\t\tEnd If\n\t\t\tElse\n\t\t\t\tThrowError(_s(\"error.writeperms\", [file]))\n\t\t\tEnd If\n\t\tElse\n\t\t\tlogger.LogMessage(_s(\"message.fetch.alreadyfetched\"))\n\t\tEnd If\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Progress callback for source archive fetching.\n\t\treturns: Zero (no error).\n\tEnd Rem\n\tFunction _ProgressCallback:Int(data:Object, dltotal:Double, dlnow:Double, ultotal:Double, ulnow:Double)\n\t\tLocal store:_mxProgressStore = _mxProgressStore(data)\n\t\tLocal prog:Int = (dlnow \/ dltotal) * 100\n\t\tIf prog > store.m_progress + 5\n\t\t\tstore.m_progress = prog\n\t\t\tWriteStdOut(\".\")\n\t\tEnd If\n\t\tReturn 0\n\tEnd Function\n\t\nEnd Type\n\nRem\n\tbbdoc: Maximus metafile handler\nEnd Rem\nType mxMetaFile\n\n\tField m_metafile:String\n\tField m_scope:String\n\tField m_name:String\n\tField m_version:String\n\t\n\tRem\n\t\tbbdoc: Create a metafile handler.\n\t\treturns: Itself.\n\tEnd Rem\n\tMethod Create:mxMetaFile(metafile:String)\n\t\tSetMetaFile(metafile)\n\t\tReturn Self\n\tEnd Method\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the metafile file path.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetMetaFile(metafile:String)\n\t\tm_metafile = metafile\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the metafile path.\n\t\treturns: The metafile path.\n\tEnd Rem\n\tMethod GetMetaFile:String()\n\t\tReturn m_metafile\n\tEnd Method\n\t\n'#end region Field accessors\n\t\n\tRem\n\t\tbbdoc: Load the configuration.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod Load()\n\t\tIf FileType(GetMetaFile()) = FILETYPE_FILE\n\t\t\tTry\n\t\t\t\tLocal contents:String = LoadText(GetMetaFile()).Trim()\n\t\t\t\tLocal parts:String[] = contents.Split(\"\/\")\n\t\t\t\t\n\t\t\t\tIf parts.Length <> 2\n\t\t\t\t\tThrow _s(\"error.load.meta.invalid_format\") ;\n\t\t\t\tEnd If\n\t\t\t\t\n\t\t\t\tLocal modinfo:String[] = parts[0].Split(\".\")\n\t\t\t\tm_scope = modinfo[0]\n\t\t\t\tm_name = modinfo[1]\n\t\t\t\tm_version = parts[1]\n\t\t\tCatch e:Object\n\t\t\t\tlogger.LogError(_s(\"error.load.metafile.parse\", [GetMetaFile()]))\n\t\t\t\tlogger.LogError(_s(\"error.load.metafile.parse\", [e.ToString()]))\n\t\t\tEnd Try\n\t\tElse\n\t\t\tlogger.LogWarning(_s(\"error.load.metafile.notfound\", [GetMetaFile()]))\n\t\tEnd If\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Save the configuration\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod Save()\n\t\tIf m_scope.Length = 0 Or m_name.Length = 0 Or m_version.Length = 0\n\t\t\tThrowError(_s(\"error.save.metafile.incomplete\", [m_scope, m_name, m_version]))\n\t\tEnd If\n\t\t\n\t\tLocal stream:TStream = WriteFileExplicitly(GetMetaFile())\n\t\tstream.WriteString(m_scope + \".\" + m_name + \"\/\" + m_version)\n\t\tstream.Close\n\tEnd Method\nEnd Type\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"6da1726baa8b06cdba4d5d05993226b461cb03f2","subject":"Fixed major TSurface refresh bug.","message":"Fixed major TSurface refresh bug.\n","repos":"kfprimm\/maxb3d,kfprimm\/maxb3d","old_file":"core.mod\/surface.bmx","new_file":"core.mod\/surface.bmx","new_contents":"\nStrict\n\nImport MaxB3D.Math\nImport \"brush.bmx\"\n\nConst SURFACE_POS = 1\nConst SURFACE_NML = 2\nConst SURFACE_CLR = 4\nConst SURFACE_TEX = 8\nConst SURFACE_TRI = 16\nConst SURFACE_ALL = SURFACE_POS|SURFACE_NML|SURFACE_CLR|SURFACE_TEX|SURFACE_TRI\n\nType TSurface\n\tField _brush:TBrush=New TBrush\n\t\n\tField _vertexcnt,_trianglecnt\n\tField _vertexpos#[],_vertexnml#[],_vertexclr#[]\t\n\tField _vertextex#[][],_texcoordsize=-1\n\t\n\tField _triangle[]\n\t\n\tField _res:TSurfaceRes,_reset=-1\n\t\n\tField _resetbounds=True,_minx#,_miny#,_minz#,_maxx#,_maxy#,_maxz#\n\tField _boundsupdatedmsg:TMaxB3DMsg=New TMaxB3DMsg\n\t\n\tMethod Copy:TSurface(data=SURFACE_ALL)\n\t\tLocal surface:TSurface=New TSurface\n\t\tsurface._brush.Load(_brush)\n\t\tsurface._vertexcnt=_vertexcnt\t\t\n\t\tIf data&SURFACE_POS surface._vertexpos=_vertexpos[..]\n\t\tIf data&SURFACE_NML surface._vertexnml=_vertexnml[..]\n\t\tIf data&SURFACE_CLR surface._vertexclr=_vertexclr[..]\n\t\tIf data&SURFACE_TEX\n\t\t\tsurface._vertextex = New Float[][_texcoordsize]\n\t\t\tFor Local i=0 To _texcoordsize-1\n\t\t\t\tsurface._vertextex[i]=_vertextex[i][..]\n\t\t\tNext\n\t\t\tsurface._texcoordsize=_texcoordsize\n\t\tEndIf\n\t\tIf data&SURFACE_TRI surface._trianglecnt=_trianglecnt;surface._triangle=_triangle[..]\n\t\tReturn surface\n\tEnd Method\n\t\n\tMethod Resize(vertexcount,trianglecount)\n\t\tIf vertexcount>-1\n\t\t\t_vertexpos=_vertexpos[..vertexcount*3]\n\t\t\t_vertexnml=_vertexnml[..vertexcount*3]\n\t\t\t_vertexclr=_vertexclr[..vertexcount*4]\n\t\t\tFor Local i=_vertexcnt*4 To vertexcount*4-1\n\t\t\t\t_vertexclr[i]=1.0\n\t\t\tNext\n\t\t\tFor Local i=0 To _texcoordsize-1\n\t\t\t\t_vertextex[i]=_vertextex[i][..vertexcount*2]\n\t\t\tNext\n\t\t\t_vertexcnt=vertexcount\n\t\tEndIf\n\t\t\n\t\tIf trianglecount>-1\n\t\t\t_triangle=_triangle[..trianglecount*3]\n\t\t\t_trianglecnt=trianglecount\n\t\tEndIf\n\tEnd Method\n\t\n\tMethod GetSize(vertices Var,triangles Var)\n\t\tvertices=_vertexcnt\n\t\ttriangles=_trianglecnt\n\tEnd Method\n\n\tMethod AddVertex(x#,y#,z#,u#=0.0,v#=0.0)\n\t\tResize(_vertexcnt+1,-1)\n\t\tSetCoords(_vertexcnt-1,x,y,z)\n\t\tSetTexCoords(_vertexcnt-1,u,v)\n\t\tReturn _vertexcnt-1\n\tEnd Method\n\t\n\tMethod GetCoords(index,x# Var,y# Var,z# Var)\n\t\tx=_vertexpos[index*3+0]\n\t\ty=_vertexpos[index*3+1]\n\t\tz=_vertexpos[index*3+2]\n\tEnd Method\n\tMethod SetCoords(index,x#,y#,z#)\n\t\t_vertexpos[index*3+0]=x\n\t\t_vertexpos[index*3+1]=y\n\t\t_vertexpos[index*3+2]=z\t\t\n\t\t_reset:|1;_resetbounds=True\n\tEnd Method\n\t\n\tMethod GetNormal(index,nx# Var,ny# Var,nz# Var)\n\t\tnx=_vertexnml[index*3+0]*-1\n\t\tny=_vertexnml[index*3+1]*-1\n\t\tnz=_vertexnml[index*3+2]*-1\n\tEnd Method\n\tMethod SetNormal(index,nx#,ny#,nz#)\n\t\t_vertexnml[index*3+0]=nx*-1\n\t\t_vertexnml[index*3+1]=ny*-1\n\t\t_vertexnml[index*3+2]=nz*-1\n\t\t_reset:|2\n\tEnd Method\n\t\n\tMethod GetColor(index,red Var,green Var,blue Var,alpha# Var)\n\t\tred=_vertexclr[index*4+0]*255.0\n\t\tgreen=_vertexclr[index*4+1]*255.0\n\t\tblue=_vertexclr[index*4+2]*255.0\n\t\talpha=_vertexclr[index*4+3]\n\tEnd Method\n\tMethod SetColor(index,red,green,blue,alpha#)\n\t\t_vertexclr[index*4+0]=red\/255.0\n\t\t_vertexclr[index*4+1]=green\/255.0\n\t\t_vertexclr[index*4+2]=blue\/255.0\n\t\t_vertexclr[index*4+3]=alpha\n\t\t_reset:|4\n\tEnd Method\n\t\n\tMethod GetTexCoords(index,u# Var,v# Var,set=0)\n\t\tResizeTexSets set\n\t\tu=_vertextex[set][index*2+0]\n\t\tv=_vertextex[set][index*2+1]\n\tEnd Method\n\tMethod SetTexCoords(index,u#,v#,set=0)\n\t\tResizeTexSets set\n\t\t_vertextex[set][index*2+0]=u\n\t\t_vertextex[set][index*2+1]=v\n\t\t_reset:|Int(2^(4+set))\n\tEnd Method\n\t\n\tMethod ResizeTexSets(set)\n\t\tIf set+1>_texcoordsize\n\t\t\tLocal size=_vertextex.length\n\t\t\t_vertextex=_vertextex[..set+1]\t\t\t\n\t\t\tFor Local i=size To set\n\t\t\t\t_vertextex[i]=New Float[_vertexcnt*2]\n\t\t\tNext\t\n\t\t\t_texcoordsize=set+1\t\t\n\t\tEndIf\n\tEnd Method\n\t\n\tMethod AddTriangle(v0,v1,v2)\n\t\tResize(-1,_trianglecnt+1)\n\t\tSetTriangle _trianglecnt-1,v0,v1,v2\n\t\tReturn _trianglecnt-1\n\tEnd Method\n\t\n\tMethod GetTriangle(index,v0 Var,v1 Var,v2 Var)\n\t\tv0=_triangle[index*3+0]\n\t\tv1=_triangle[index*3+1]\n\t\tv2=_triangle[index*3+2]\n\tEnd Method\n\tMethod SetTriangle(index,v0,v1,v2)\n\t\t_triangle[index*3+0]=v0\n\t\t_triangle[index*3+1]=v1\n\t\t_triangle[index*3+2]=v2\n\t\t_reset:|8\n\tEnd Method\n\t\n\tMethod Flip()\n\t\tFor Local t=0 To _trianglecnt-1\n\t\t\tLocal v2=_triangle[t*3+2]\n\t\t\t_triangle[t*3+2]=_triangle[t*3+0]\n\t\t\t_triangle[t*3+0]=v2\t\t\t\n\t\tNext\n\t\tFor Local v=0 To _vertexcnt-1\n\t\t\t_vertexnml[(v*3)+0]:*-1\n\t\t\t_vertexnml[(v*3)+1]:*-1\n\t\t\t_vertexnml[(v*3)+2]:*-1\n\t\tNext\n\t\t_reset:|2|8\n\tEnd Method\n\t\n\tMethod Transform(matrix:TMatrix)\n\t\tFor Local i=0 To _vertexcnt-1\n\t\t\tmatrix.TransformVec3 _vertexpos[i*3+0],_vertexpos[i*3+1],_vertexpos[i*3+2]\n\t\t\t'matrix.TransformVector _vertexnml[i+0],_vertexnml[i+1],_vertexnml[i+2],w\n\t\tNext\n\t\t_reset:|1;_resetbounds=True\n\tEnd Method\n\t\n\tMethod UpdateBounds(force=False)\n\t\tIf Not _resetbounds And force=False Return\n\t\t_minx=999999999;_miny=999999999;_minz=999999999\n\t\t_maxx=-999999999;_maxy=-999999999;_maxz=-999999999\n\t\tFor Local v=0 To _vertexcnt-1\n\t\t\tLocal x#,y#,z#\n\t\t\tGetCoords v,x,y,z\t\t\t\t\n\t\t\t_minx=Min(x,_minx);_maxx=Max(x,_maxx)\n\t\t\t_miny=Min(y,_miny);_maxy=Max(y,_maxy)\n\t\t\t_minz=Min(z,_minz);_maxz=Max(z,_maxz)\n\t\tNext\n\t\t_boundsupdatedmsg.Run\n\t\t_resetbounds=False\n\tEnd Method\n\t\n\tMethod UpdateNormals(smoothing=True)\n\t\tIf smoothing\n\t\t\tC_UpdateNormals(_trianglecnt,_vertexcnt,_triangle,_vertexpos,_vertexnml)\n\t\tElse\n\t\t\tLocal face_normal:TVector[_trianglecnt],vertex_triangles[][_vertexcnt]\n\t\t\t\t\t\t\n\t\t\tFor Local i=0 To _trianglecnt-1\n\t\t\t\tLocal v0,v1,v2\n\t\t\t\tGetTriangle i,v0,v1,v2\n\t\t\t\t\n\t\t\t\tvertex_triangles[v0]:+[i]\n\t\t\t\tvertex_triangles[v1]:+[i]\n\t\t\t\tvertex_triangles[v2]:+[i]\n\t\t\t\t\n\t\t\t\tLocal a:TVector=New TVector,b:TVector=New TVector,c:TVector=New TVector\n\t\t\t\tGetCoords v0,a.x,a.y,a.z\n\t\t\t\tGetCoords v1,b.x,b.y,b.z\n\t\t\t\tGetCoords v2,c.x,c.y,c.z\n\t\t\t\t\n\t\t\t\tface_normal[i]=New TVector.FromTriangle(a,b,c)\t\n\t\t\tNext\n\t\n\t\t\tLocal normal:TVector=New TVector\n\t\t\tFor Local i=0 To _vertexcnt-1\n\t\t\t\tnormal.Create3(0,0,0)\n\t\t\t\tFor Local t=0 To vertex_triangles[i].length-1\n\t\t\t\t\tnormal=normal.Add(face_normal[vertex_triangles[i][t]])\t\t\n\t\t\t\tNext\n\t\t\t\tnormal.Normalize()\t\t\t\t\n\t\t\t\tSetNormal i,-normal.x,-normal.y,-normal.z\n\t\t\tNext\t\t\n\t\tEndIf\n\t\t_reset:|2\n\tEnd Method\n\t\n\tMethod SetTriangleNormal(index,nx#,ny#,nz#)\n\t\tLocal v0,v1,v2\n\t\tGetTriangle index,v0,v1,v2\n\t\tSetNormal v0,nx,ny,nz\n\t\tSetNormal v1,nx,ny,nz\n\t\tSetNormal v2,nx,ny,nz\n\tEnd Method\n\t\n\tMethod GetBrush:TBrush()\n\t\tReturn _brush.Copy()\n\tEnd Method\t\n\tMethod SetBrush(brush:TBrush)\n\t\t_brush.Load(brush)\n\tEnd Method\n\t\n\tMethod CountVertices()\n\t\tReturn _vertexcnt\n\tEnd Method\n\tMethod CountTriangles()\n\t\tReturn _trianglecnt\n\tEnd Method\n\t\n\tMethod IsEmpty()\n\t\tReturn _vertexcnt=0 And _trianglecnt=0\n\tEnd Method\n\t\t\n\tMethod HasAlpha()\n\t\tReturn _brush.HasAlpha()\n\tEnd Method\t\nEnd Type\n\nType TSurfaceRes Extends TDriverResource\n\tField _vertexcnt\n\tField _trianglecnt\n\t\n\tMethod Copy:TSurfaceRes() Abstract\nEnd Type\n\nType TMaxB3DMsg\n\tField _succ:TMaxB3DMsg\n\tField _context:Object\n\tField _func(context:Object)\n\t\n\tMethod Add(func(context:Object),context:Object)\n\t\tLocal msg:TMaxB3DMsg=Self\n\t\tWhile msg._succ\n\t\t\tmsg=msg._succ\n\t\tWend\n\t\tmsg._succ=New TMaxB3DMsg\n\t\tmsg._context=context\n\t\tmsg._func=func\n\tEnd Method\n\t\n\tMethod Run()\n\t\tLocal msg:TMaxB3DMsg=Self\n\t\tWhile msg\n\t\t\tIf msg._func msg._func(msg._context)\n\t\t\tmsg=msg._succ\n\t\tWend\n\tEnd Method\nEnd Type\n","old_contents":"\nStrict\n\nImport MaxB3D.Math\nImport \"brush.bmx\"\n\nConst SURFACE_POS = 1\nConst SURFACE_NML = 2\nConst SURFACE_CLR = 4\nConst SURFACE_TEX = 8\nConst SURFACE_TRI = 16\nConst SURFACE_ALL = SURFACE_POS|SURFACE_NML|SURFACE_CLR|SURFACE_TEX|SURFACE_TRI\n\nType TSurface\n\tField _brush:TBrush=New TBrush\n\t\n\tField _vertexcnt,_trianglecnt\n\tField _vertexpos#[],_vertexnml#[],_vertexclr#[]\t\n\tField _vertextex#[][],_texcoordsize=-1\n\t\n\tField _triangle[]\n\t\n\tField _res:TSurfaceRes,_reset=-1\n\t\n\tField _resetbounds=True,_minx#,_miny#,_minz#,_maxx#,_maxy#,_maxz#\n\tField _boundsupdatedmsg:TMaxB3DMsg=New TMaxB3DMsg\n\t\n\tMethod Copy:TSurface(data=SURFACE_ALL)\n\t\tLocal surface:TSurface=New TSurface\n\t\tsurface._brush.Load(_brush)\n\t\tsurface._vertexcnt=_vertexcnt\t\t\n\t\tIf data&SURFACE_POS surface._vertexpos=_vertexpos[..]\n\t\tIf data&SURFACE_NML surface._vertexnml=_vertexnml[..]\n\t\tIf data&SURFACE_CLR surface._vertexclr=_vertexclr[..]\n\t\tIf data&SURFACE_TEX\n\t\t\tsurface._vertextex = New Float[][_texcoordsize]\n\t\t\tFor Local i=0 To _texcoordsize-1\n\t\t\t\tsurface._vertextex[i]=_vertextex[i][..]\n\t\t\tNext\n\t\t\tsurface._texcoordsize=_texcoordsize\n\t\tEndIf\n\t\tIf data&SURFACE_TRI surface._trianglecnt=_trianglecnt;surface._triangle=_triangle[..]\n\t\tReturn surface\n\tEnd Method\n\t\n\tMethod Resize(vertexcount,trianglecount)\n\t\tIf vertexcount>-1\n\t\t\t_vertexpos=_vertexpos[..vertexcount*3]\n\t\t\t_vertexnml=_vertexnml[..vertexcount*3]\n\t\t\t_vertexclr=_vertexclr[..vertexcount*4]\n\t\t\tFor Local i=_vertexcnt*4 To vertexcount*4-1\n\t\t\t\t_vertexclr[i]=1.0\n\t\t\tNext\n\t\t\tFor Local i=0 To _texcoordsize-1\n\t\t\t\t_vertextex[i]=_vertextex[i][..vertexcount*2]\n\t\t\tNext\n\t\t\t_vertexcnt=vertexcount\n\t\tEndIf\n\t\t\n\t\tIf trianglecount>-1\n\t\t\t_triangle=_triangle[..trianglecount*3]\n\t\t\t_trianglecnt=trianglecount\n\t\tEndIf\n\tEnd Method\n\t\n\tMethod GetSize(vertices Var,triangles Var)\n\t\tvertices=_vertexcnt\n\t\ttriangles=_trianglecnt\n\tEnd Method\n\n\tMethod AddVertex(x#,y#,z#,u#=0.0,v#=0.0)\n\t\tResize(_vertexcnt+1,-1)\n\t\tSetCoords(_vertexcnt-1,x,y,z)\n\t\tSetTexCoords(_vertexcnt-1,u,v)\n\t\tReturn _vertexcnt-1\n\tEnd Method\n\t\n\tMethod GetCoords(index,x# Var,y# Var,z# Var)\n\t\tx=_vertexpos[index*3+0]\n\t\ty=_vertexpos[index*3+1]\n\t\tz=_vertexpos[index*3+2]\n\tEnd Method\n\tMethod SetCoords(index,x#,y#,z#)\n\t\t_vertexpos[index*3+0]=x\n\t\t_vertexpos[index*3+1]=y\n\t\t_vertexpos[index*3+2]=z\t\t\n\t\t_reset:|1;_resetbounds=True\n\tEnd Method\n\t\n\tMethod GetNormal(index,nx# Var,ny# Var,nz# Var)\n\t\tnx=_vertexnml[index*3+0]*-1\n\t\tny=_vertexnml[index*3+1]*-1\n\t\tnz=_vertexnml[index*3+2]*-1\n\tEnd Method\n\tMethod SetNormal(index,nx#,ny#,nz#)\n\t\t_vertexnml[index*3+0]=nx*-1\n\t\t_vertexnml[index*3+1]=ny*-1\n\t\t_vertexnml[index*3+2]=nz*-1\n\t\t_reset:|2\n\tEnd Method\n\t\n\tMethod GetColor(index,red Var,green Var,blue Var,alpha# Var)\n\t\tred=_vertexclr[index*4+0]*255.0\n\t\tgreen=_vertexclr[index*4+1]*255.0\n\t\tblue=_vertexclr[index*4+2]*255.0\n\t\talpha=_vertexclr[index*4+3]\n\tEnd Method\n\tMethod SetColor(index,red,green,blue,alpha#)\n\t\t_vertexclr[index*4+0]=red\/255.0\n\t\t_vertexclr[index*4+1]=green\/255.0\n\t\t_vertexclr[index*4+2]=blue\/255.0\n\t\t_vertexclr[index*4+3]=alpha\n\t\t_reset:|4\n\tEnd Method\n\t\n\tMethod GetTexCoords(index,u# Var,v# Var,set=0)\n\t\tResizeTexSets set\n\t\tu=_vertextex[set][index*2+0]\n\t\tv=_vertextex[set][index*2+1]\n\tEnd Method\n\tMethod SetTexCoords(index,u#,v#,set=0)\n\t\tResizeTexSets set\n\t\t_vertextex[set][index*2+0]=u\n\t\t_vertextex[set][index*2+1]=v\n\t\t_reset:|Int(2^(4+set))\n\tEnd Method\n\t\n\tMethod ResizeTexSets(set)\n\t\tIf set+1>_texcoordsize\n\t\t\tLocal size=_vertextex.length\n\t\t\t_vertextex=_vertextex[..set+1]\t\t\t\n\t\t\tFor Local i=size To set\n\t\t\t\t_vertextex[i]=New Float[_vertexcnt*2]\n\t\t\tNext\t\n\t\t\t_texcoordsize=set+1\t\t\n\t\tEndIf\n\tEnd Method\n\t\n\tMethod AddTriangle(v0,v1,v2)\n\t\tResize(-1,_trianglecnt+1)\n\t\tSetTriangle _trianglecnt-1,v0,v1,v2\n\t\tReturn _trianglecnt-1\n\tEnd Method\n\t\n\tMethod GetTriangle(index,v0 Var,v1 Var,v2 Var)\n\t\tv0=_triangle[index*3+0]\n\t\tv1=_triangle[index*3+1]\n\t\tv2=_triangle[index*3+2]\n\tEnd Method\n\tMethod SetTriangle(index,v0,v1,v2)\n\t\t_triangle[index*3+0]=v0\n\t\t_triangle[index*3+1]=v1\n\t\t_triangle[index*3+2]=v2\n\t\t_reset:|8\n\tEnd Method\n\t\n\tMethod Flip()\n\t\tFor Local t=0 To _trianglecnt-1\n\t\t\tLocal v2=_triangle[t*3+2]\n\t\t\t_triangle[t*3+2]=_triangle[t*3+0]\n\t\t\t_triangle[t*3+0]=v2\t\t\t\n\t\tNext\n\t\tFor Local v=0 To _vertexcnt-1\n\t\t\t_vertexnml[(v*3)+0]:*-1\n\t\t\t_vertexnml[(v*3)+1]:*-1\n\t\t\t_vertexnml[(v*3)+2]:*-1\n\t\tNext\n\t\t_reset:|2|8\n\tEnd Method\n\t\n\tMethod Transform(matrix:TMatrix)\n\t\tFor Local i=0 To _vertexcnt-1\n\t\t\tmatrix.TransformVec3 _vertexpos[i*3+0],_vertexpos[i*3+1],_vertexpos[i*3+2]\n\t\t\t'matrix.TransformVector _vertexnml[i+0],_vertexnml[i+1],_vertexnml[i+2],w\n\t\tNext\n\tEnd Method\n\t\n\tMethod UpdateBounds(force=False)\n\t\tIf Not _resetbounds And force=false Return\n\t\t_minx=999999999;_miny=999999999;_minz=999999999\n\t\t_maxx=-999999999;_maxy=-999999999;_maxz=-999999999\n\t\tFor Local v=0 To _vertexcnt-1\n\t\t\tLocal x#,y#,z#\n\t\t\tGetCoords v,x,y,z\t\t\t\t\n\t\t\t_minx=Min(x,_minx);_maxx=Max(x,_maxx)\n\t\t\t_miny=Min(y,_miny);_maxy=Max(y,_maxy)\n\t\t\t_minz=Min(z,_minz);_maxz=Max(z,_maxz)\n\t\tNext\n\t\t_boundsupdatedmsg.Run\n\t\t_resetbounds=False\n\tEnd Method\n\t\n\tMethod UpdateNormals(smoothing=True)\n\t\tIf smoothing\n\t\t\tC_UpdateNormals(_trianglecnt,_vertexcnt,_triangle,_vertexpos,_vertexnml)\n\t\tElse\n\t\t\tLocal face_normal:TVector[_trianglecnt],vertex_triangles[][_vertexcnt]\n\t\t\t\t\t\t\n\t\t\tFor Local i=0 To _trianglecnt-1\n\t\t\t\tLocal v0,v1,v2\n\t\t\t\tGetTriangle i,v0,v1,v2\n\t\t\t\t\n\t\t\t\tvertex_triangles[v0]:+[i]\n\t\t\t\tvertex_triangles[v1]:+[i]\n\t\t\t\tvertex_triangles[v2]:+[i]\n\t\t\t\t\n\t\t\t\tLocal a:TVector=New TVector,b:TVector=New TVector,c:TVector=New TVector\n\t\t\t\tGetCoords v0,a.x,a.y,a.z\n\t\t\t\tGetCoords v1,b.x,b.y,b.z\n\t\t\t\tGetCoords v2,c.x,c.y,c.z\n\t\t\t\t\n\t\t\t\tface_normal[i]=New TVector.FromTriangle(a,b,c)\t\n\t\t\tNext\n\t\n\t\t\tLocal normal:TVector=New TVector\n\t\t\tFor Local i=0 To _vertexcnt-1\n\t\t\t\tnormal.Create3(0,0,0)\n\t\t\t\tFor Local t=0 To vertex_triangles[i].length-1\n\t\t\t\t\tnormal=normal.Add(face_normal[vertex_triangles[i][t]])\t\t\n\t\t\t\tNext\n\t\t\t\tnormal.Normalize()\t\t\t\t\n\t\t\t\tSetNormal i,-normal.x,-normal.y,-normal.z\n\t\t\tNext\t\t\n\t\tEndIf\n\t\t_reset:|2\n\tEnd Method\n\t\n\tMethod SetTriangleNormal(index,nx#,ny#,nz#)\n\t\tLocal v0,v1,v2\n\t\tGetTriangle index,v0,v1,v2\n\t\tSetNormal v0,nx,ny,nz\n\t\tSetNormal v1,nx,ny,nz\n\t\tSetNormal v2,nx,ny,nz\n\tEnd Method\n\t\n\tMethod GetBrush:TBrush()\n\t\tReturn _brush.Copy()\n\tEnd Method\t\n\tMethod SetBrush(brush:TBrush)\n\t\t_brush.Load(brush)\n\tEnd Method\n\t\n\tMethod CountVertices()\n\t\tReturn _vertexcnt\n\tEnd Method\n\tMethod CountTriangles()\n\t\tReturn _trianglecnt\n\tEnd Method\n\t\n\tMethod IsEmpty()\n\t\tReturn _vertexcnt=0 And _trianglecnt=0\n\tEnd Method\n\t\t\n\tMethod HasAlpha()\n\t\tReturn _brush.HasAlpha()\n\tEnd Method\t\nEnd Type\n\nType TSurfaceRes Extends TDriverResource\n\tField _vertexcnt\n\tField _trianglecnt\n\t\n\tMethod Copy:TSurfaceRes() Abstract\nEnd Type\n\nType TMaxB3DMsg\n\tField _succ:TMaxB3DMsg\n\tField _context:Object\n\tField _func(context:Object)\n\t\n\tMethod Add(func(context:Object),context:Object)\n\t\tLocal msg:TMaxB3DMsg=Self\n\t\tWhile msg._succ\n\t\t\tmsg=msg._succ\n\t\tWend\n\t\tmsg._succ=New TMaxB3DMsg\n\t\tmsg._context=context\n\t\tmsg._func=func\n\tEnd Method\n\t\n\tMethod Run()\n\t\tLocal msg:TMaxB3DMsg=Self\n\t\tWhile msg\n\t\t\tIf msg._func msg._func(msg._context)\n\t\t\tmsg=msg._succ\n\t\tWend\n\tEnd Method\nEnd Type\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"9119f933791bc4a630582175d9eb43205c6ce208","subject":"lugi.bmx: * Fixed bug where InitWithTypeID would crash for all types because it was trying to access a null member of the LExposedType instance.","message":"lugi.bmx:\n* Fixed bug where InitWithTypeID would crash for all types because it was trying to access a null member of the LExposedType instance.","repos":"nilium\/lugi.mod,nilium\/lugi.mod","old_file":"Generator\/type.bmx","new_file":"Generator\/type.bmx","new_contents":"SuperStrict\n\nImport \"field.bmx\"\nImport \"method.bmx\"\nImport \"metadata.bmx\"\n\nImport Brl.LinkedList\n\nPrivate\n\nGlobal _exposedTypes:TList = New TList\n\nPublic\n\nType LExposedType\n\tField exposed%\n\tField static%\n\tField noclass%\n\tField hidefields%\n\tField nonew%\n\t\n\tField typeid:TTypeId\n\tField methods:TList\t\t\t' TList\n\tField fields:TList\t\t\t' TList\n\tField constructor$\n\tField name$\n\t\n\t' Returns an LExposedType for a typeid - recommended to use this instead of creating a new LExposedType and initializing it\n\tFunction ForType:LExposedType(typeid:TTypeId)\n\t\tIf typeid = ObjectTypeId Or typeid = StringTypeId Or typeid._class = ArrayTypeId._class Then\n\t\t\tReturn Null\n\t\tEndIf\n\t\t\n\t\tLocal link:TLink = _exposedTypes.FindLink(typeid)\n\t\tIf link Then\n\t\t\tReturn LExposedType(link.Value())\n\t\tEndIf\n\t\tReturn New LExposedType.InitWithTypeID(typeid)\n\tEnd Function\n\t\n\t' Compares LExposedTypes based on the TTypeId associated with each LExposedType\n\tMethod Compare:Int(other:Object)\n\t\tLocal ot:LExposedType = LExposedType(other)\n\t\tIf other = Null Then\n\t\t\tReturn 1\n\t\tElseIf TTypeId(other) Then\n\t\t\tReturn typeid.Compare(other)\n\t\tElseIf other And Not ot Then\n\t\t\tThrow \"Invalid type to compare LExposedType against\"\n\t\tElse\n\t\t\tReturn typeid.Compare(ot.typeid)\n\t\tEndIf\n\tEnd Method\n\t\n\t' Returns a list of exposed types to iterate over\n\tFunction EnumTypes:TList()\n\t\tReturn _exposedTypes.Copy()\n\tEnd Function\n\t\n\t' Initializes an LExposedType with information for the type passed\n\t' The object returned may not be the one you originally sent the initialize message to\n\t' If there is already an instance for this type, that instance will be returned instead\n\t' of proceeding with intialization\n\tMethod InitWithTypeID:LExposedType(tid:TTypeId)\n\t\tIf tid = ObjectTypeId Or tid = StringTypeId Or tid._class = ArrayTypeId._class Then\n\t\t\tReturn Null\n\t\tEndIf\n\t\t\n\t\tLocal lnk:TLink = _exposedTypes.FindLink(tid)\n\t\tIf lnk Then\n\t\t\tReturn LExposedType(lnk.Value())\n\t\tEndIf\n\t\t\n\t\texposed = typeid.Metadata(LUGI_META_EXPOSE).ToInt()>0\n\t\tstatic = typeid.Metadata(LUGI_META_STATIC).ToInt()>0\n\t\tnoclass = typeid.Metadata(LUGI_META_NOCLASS).ToInt()>0\n\t\thidefields = typeid.Metadata(LUGI_META_HIDEFIELDS).ToInt()>0\n\t\tnonew = typeid.Metadata(LUGI_META_DISABLECONSTRUCTOR).ToInt()>0\n\t\t\n\t\tname = typeid.Metadata(LUGI_META_RENAME).Trim()\n\t\tIf Not name Then\n\t\t\tname = typeid.Name()\n\t\tEndIf\n\t\t\n\t\tIf Not (nonew Or (static and noclass)) Then\n\t\t\tconstructor = typeid.Metadata(LUGI_META_CONSTRUCTOR).Trim()\n\t\t\tIf Not constructor Then\n\t\t\t\t' Force New[A-Z_].* as default\n\t\t\t\tconstructor = \"New\"+name[0..1].ToUpper()+name[1..]\n\t\t\tEndIf\n\t\tEndIf\n\t\t\n\t\t__initMethods\n\t\t__initFields\n\t\t\n\t\t_exposedTypes.AddLast(Self)\n\t\t\n\t\tReturn Self\n\tEnd Method\n\t\n\tMethod PreInitBlock:String()\n\t\tLocal outs$=\"\"\n\t\t\n\t\tIf Not (static And noclass) Then\n\t\t\tFor Local m:LExposedMethod = EachIn methods\n\t\t\t\tLocal initString$ = m.PreInitBlock()\n\t\t\t\tIf initString Then\n\t\t\t\t\touts :+ \"~t\" + initString + \"~n\"\n\t\t\t\tEndIf\n\t\t\tNext\n\t\tEndIf\n\t\t\n\t\tIf Not noclass Then\n\t\t\tFor Local f:LExposedField = EachIn fields\n\t\t\t\tLocal initString$ = f.PreInitBlock()\n\t\t\t\tIf initString Then\n\t\t\t\t\touts :+ \"~t\" + initString + \"~n\"\n\t\t\t\tEndIf\n\t\t\tNext\n\t\tEndIf\n\t\t\n\t\tReturn outs\n\tEnd Method\n\t\n\tMethod PostInitBlock:String()\n\t\tIf Not (nonew Or (static And noclass)) Then\n\t\t\tReturn \t\"~tlua_pushlightuserdata lua_vm, Byte Ptr(TTypeId.ForName(~q\" + typeid.Name() + \"~q)._class)\" + ..\n\t\t\t\t\t\"~tlua_pushcclosure lua_vm, p_lugi_new_object, 1\"\n\t\tElseIf static And Not noclass Then\n\t\t\tReturn\t\"~t\"\n\t\tEndIf\n\tEnd Method\n\t\n\tMethod MethodImplementations:String()\n\t\tLocal m:LExposedMethod\n\t\tLocal outs$\n\t\tLocal instMethod% = Not (static And noclass)\n\t\tLocal block$\n\t\t\n\t\tFor m = EachIn methods\n\t\t\tblock = m.Implementation(instMethod)\n\t\t\tIf block Then\n\t\t\t\touts :+ \"~n~n\"+block\n\t\t\tEndIf\n\t\tNext\n\t\t\n\t\tReturn outs\n\tEnd Method\n\t\n\tMethod _exposedInParent:Int(m:TMethod)\n\t\tLocal name$ = m.Name().ToLower()\n\t\t\n\t\tLocal typ:TTypeId = typeid.SuperType()\n\t\tWhile typ\n\t\t\t\n\t\tWend\n\tEnd Method\n\t\n\tMethod __initMethods()\n\t\tmethods = New TList\n\t\t\n\t\tIf Not exposed Then\n\t\t\tReturn\n\t\tEndIf\n\t\t\n\t\t' Build list of exposed methods\n\t\tFor Local m:TMethod = EachIn typeid.Methods()\n\t\t\t\n\t\tNext\n\tEnd Method\n\t\n\tMethod __initFields()\n\t\tfields = New TList\n\t\t\n\t\tIf Not exposed Or hidefields Then\n\t\t\tReturn\n\t\tEndIf\n\t\t\n\t\tFor Local f:TField = EachIn typeid.Fields()\n\t\t\t\n\t\tNext\n\tEnd Method\nEnd Type\n\n' Builds up the information for all types\nFunction BuildTypeInfo()\nEnd Function\n\nPrivate\n\n' Recursively creates the information for types\nFunction _buildTypeInfo(types:TList)\n\t' Iterate over types and load data for them\n\tFor Local tid:TTypeId = EachIn types\n\t\tNew LExposedType.InitWithTypeID(tid)\n\t\t_buildTypeInfo(tid.DerivedTypes())\n\tNext\nEnd Function\n","old_contents":"SuperStrict\n\nImport \"field.bmx\"\nImport \"method.bmx\"\nImport \"metadata.bmx\"\n\nImport Brl.LinkedList\n\nPrivate\n\nGlobal _exposedTypes:TList = New TList\n\nPublic\n\nType LExposedType\n\tField exposed%\n\tField static%\n\tField noclass%\n\tField hidefields%\n\tField nonew%\n\t\n\tField typeid:TTypeId\n\tField methods:TList\t\t\t' TList\n\tField fields:TList\t\t\t' TList\n\tField constructor$\n\tField name$\n\t\n\t' Returns an LExposedType for a typeid - recommended to use this instead of creating a new LExposedType and initializing it\n\tFunction ForType:LExposedType(typeid:TTypeId)\n\t\tIf typeid = ObjectTypeId Or typeid = StringTypeId Or typeid._class = ArrayTypeId._class Then\n\t\t\tReturn Null\n\t\tEndIf\n\t\t\n\t\tLocal link:TLink = _exposedTypes.FindLink(typeid)\n\t\tIf link Then\n\t\t\tReturn LExposedType(link.Value())\n\t\tEndIf\n\t\tReturn New LExposedType.InitWithTypeID(typeid)\n\tEnd Function\n\t\n\t' Compares LExposedTypes based on the TTypeId associated with each LExposedType\n\tMethod Compare:Int(other:Object)\n\t\tLocal ot:LExposedType = LExposedType(other)\n\t\tIf other = Null Then\n\t\t\tReturn 1\n\t\tElseIf TTypeId(other) Then\n\t\t\tReturn typeid.Compare(other)\n\t\tElseIf other And Not ot Then\n\t\t\tThrow \"Invalid type to compare LExposedType against\"\n\t\tElse\n\t\t\tReturn typeid.Compare(ot.typeid)\n\t\tEndIf\n\tEnd Method\n\t\n\t' Returns a list of exposed types to iterate over\n\tFunction EnumTypes:TList()\n\t\tReturn _exposedTypes.Copy()\n\tEnd Function\n\t\n\t' Initializes an LExposedType with information for the type passed\n\t' The object returned may not be the one you originally sent the initialize message to\n\t' If there is already an instance for this type, that instance will be returned instead\n\t' of proceeding with intialization\n\tMethod InitWithTypeID:LExposedType(tid:TTypeId)\n\t\tIf tid = ObjectTypeId Or typeid = StringTypeId Or typeid._class = ArrayTypeId._class Then\n\t\t\tReturn Null\n\t\tEndIf\n\t\t\n\t\tLocal lnk:TLink = _exposedTypes.FindLink(tid)\n\t\tIf lnk Then\n\t\t\tReturn LExposedType(lnk.Value())\n\t\tEndIf\n\t\t\n\t\texposed = typeid.Metadata(LUGI_META_EXPOSE).ToInt()>0\n\t\tstatic = typeid.Metadata(LUGI_META_STATIC).ToInt()>0\n\t\tnoclass = typeid.Metadata(LUGI_META_NOCLASS).ToInt()>0\n\t\thidefields = typeid.Metadata(LUGI_META_HIDEFIELDS).ToInt()>0\n\t\tnonew = typeid.Metadata(LUGI_META_DISABLECONSTRUCTOR).ToInt()>0\n\t\t\n\t\tname = typeid.Metadata(LUGI_META_RENAME).Trim()\n\t\tIf Not name Then\n\t\t\tname = typeid.Name()\n\t\tEndIf\n\t\t\n\t\tIf Not (nonew Or (static and noclass)) Then\n\t\t\tconstructor = typeid.Metadata(LUGI_META_CONSTRUCTOR).Trim()\n\t\t\tIf Not constructor Then\n\t\t\t\t' Force New[A-Z_].* as default\n\t\t\t\tconstructor = \"New\"+name[0..1].ToUpper()+name[1..]\n\t\t\tEndIf\n\t\tEndIf\n\t\t\n\t\t__initMethods\n\t\t__initFields\n\t\t\n\t\t_exposedTypes.AddLast(Self)\n\t\t\n\t\tReturn Self\n\tEnd Method\n\t\n\tMethod PreInitBlock:String()\n\t\tLocal outs$=\"\"\n\t\t\n\t\tIf Not (static And noclass) Then\n\t\t\tFor Local m:LExposedMethod = EachIn methods\n\t\t\t\tLocal initString$ = m.PreInitBlock()\n\t\t\t\tIf initString Then\n\t\t\t\t\touts :+ \"~t\" + initString + \"~n\"\n\t\t\t\tEndIf\n\t\t\tNext\n\t\tEndIf\n\t\t\n\t\tIf Not noclass Then\n\t\t\tFor Local f:LExposedField = EachIn fields\n\t\t\t\tLocal initString$ = f.PreInitBlock()\n\t\t\t\tIf initString Then\n\t\t\t\t\touts :+ \"~t\" + initString + \"~n\"\n\t\t\t\tEndIf\n\t\t\tNext\n\t\tEndIf\n\t\t\n\t\tReturn outs\n\tEnd Method\n\t\n\tMethod PostInitBlock:String()\n\t\tIf Not (nonew Or (static And noclass)) Then\n\t\t\tReturn \t\"~tlua_pushlightuserdata lua_vm, Byte Ptr(TTypeId.ForName(~q\" + typeid.Name() + \"~q)._class)\" + ..\n\t\t\t\t\t\"~tlua_pushcclosure lua_vm, p_lugi_new_object, 1\"\n\t\tElseIf static And Not noclass Then\n\t\t\tReturn\t\"~t\"\n\t\tEndIf\n\tEnd Method\n\t\n\tMethod MethodImplementations:String()\n\t\tLocal m:LExposedMethod\n\t\tLocal outs$\n\t\tLocal instMethod% = Not (static And noclass)\n\t\tLocal block$\n\t\t\n\t\tFor m = EachIn methods\n\t\t\tblock = m.Implementation(instMethod)\n\t\t\tIf block Then\n\t\t\t\touts :+ \"~n~n\"+block\n\t\t\tEndIf\n\t\tNext\n\t\t\n\t\tReturn outs\n\tEnd Method\n\t\n\tMethod _exposedInParent:Int(m:TMethod)\n\t\tLocal name$ = m.Name().ToLower()\n\t\t\n\t\tLocal typ:TTypeId = typeid.SuperType()\n\t\tWhile typ\n\t\t\t\n\t\tWend\n\tEnd Method\n\t\n\tMethod __initMethods()\n\t\tmethods = New TList\n\t\t\n\t\tIf Not exposed Then\n\t\t\tReturn\n\t\tEndIf\n\t\t\n\t\t' Build list of exposed methods\n\t\tFor Local m:TMethod = EachIn typeid.Methods()\n\t\t\t\n\t\tNext\n\tEnd Method\n\t\n\tMethod __initFields()\n\t\tfields = New TList\n\t\t\n\t\tIf Not exposed Or hidefields Then\n\t\t\tReturn\n\t\tEndIf\n\t\t\n\t\tFor Local f:TField = EachIn typeid.Fields()\n\t\t\t\n\t\tNext\n\tEnd Method\nEnd Type\n\n' Builds up the information for all types\nFunction BuildTypeInfo()\nEnd Function\n\nPrivate\n\n' Recursively creates the information for types\nFunction _buildTypeInfo(types:TList)\n\t' Iterate over types and load data for them\n\tFor Local tid:TTypeId = EachIn types\n\t\tNew LExposedType.InitWithTypeID(tid)\n\t\t_buildTypeInfo(tid.DerivedTypes())\n\tNext\nEnd Function\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"9503ac87a72c6aa65ebdb508a1b60d311de4515e","subject":"Updated xmlrpc.mod version","message":"Updated xmlrpc.mod version\n","repos":"Htbaa\/xmlrpc.mod,Htbaa\/xmlrpc.mod,Htbaa\/xmlrpc.mod,Htbaa\/xmlrpc.mod,Htbaa\/xmlrpc.mod","old_file":"xmlrpc.bmx","new_file":"xmlrpc.bmx","new_contents":"SuperStrict\n\nRem\n\tbbdoc: htbaapub.xmlrpc\n\tabout: \nEndRem\nModule htbaapub.xmlrpc\nModuleInfo \"Name: htbaapub.xmlrpc\"\nModuleInfo \"Version: 0.5\"\nModuleInfo \"Author: Christiaan Kras\"\n\nImport brl.blitz\nImport brl.basic\nImport brl.map\nImport brl.reflection\nImport brl.socket\n\nImport \"src\/expat-2.0.1\/src\/*.h\"\nModuleInfo \"CC_OPTS: -DHAVE_EXPAT_CONFIG_H\"\n?ppc\n\tModuleInfo \"CC_OPTS: -DWORDS_BIGENDIAN\"\n?\n\nImport \"src\/expat-2.0.1\/src\/xmlparse.c\"\nImport \"src\/expat-2.0.1\/src\/xmlrole.c\"\nImport \"src\/expat-2.0.1\/src\/xmltok.c\"\nImport \"src\/expat-2.0.1\/src\/xmltok_impl.c\"\nImport \"src\/expat-2.0.1\/src\/xmltok_ns.c\"\n\nImport \"src\/xmlrpc-epi-0.54\/src\/*.h\"\nImport \"glue.cpp\"\n\n?Win32\n\tImport \"win32.cpp\"\n\tModuleInfo \"LD_OPTS: -L%PWD%\/src\/iconv-1.9.2.win32\/lib\"\n\tImport \"src\/iconv-1.9.2.win32\/include\/*.h\"\t'http:\/\/www.zlatkovic.com\/pub\/libxml\n?\n\nImport \"-liconv\"\n\nImport \"src\/xmlrpc-epi-0.54\/src\/xmlrpc.c\"\nImport \"src\/xmlrpc-epi-0.54\/src\/base64.c\"\nImport \"src\/xmlrpc-epi-0.54\/src\/encodings.c\"\nImport \"src\/xmlrpc-epi-0.54\/src\/queue.c\"\nImport \"src\/xmlrpc-epi-0.54\/src\/simplestring.c\"\nImport \"src\/xmlrpc-epi-0.54\/src\/system_methods.c\"\nImport \"src\/xmlrpc-epi-0.54\/src\/xml_element.c\"\nImport \"src\/xmlrpc-epi-0.54\/src\/xml_to_dandarpc.c\"\nImport \"src\/xmlrpc-epi-0.54\/src\/xml_to_soap.c\"\nImport \"src\/xmlrpc-epi-0.54\/src\/xml_to_xmlrpc.c\"\nImport \"src\/xmlrpc-epi-0.54\/src\/xmlrpc_introspection.c\"\n\nInclude \"wrapper.bmx\"\nInclude \"datatypes.bmx\"\nInclude \"response.bmx\"\nInclude \"transport.bmx\"\nInclude \"client.bmx\"\nInclude \"server.bmx\"\n\nRem\n\tbbdoc:\nEnd Rem\nType TXMLRPC_Exception\n\tField message:String\n\tRem\n\t\tbbdoc:\n\tEnd Rem\n\tMethod Create:TXMLRPC_Exception(message:String)\n\t\tSelf.message = message\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc:\n\tEnd Rem\n\tMethod ToString:String()\n\t\tReturn Self.message\n\tEnd Method\nEnd Type\n\nRem\n\tbbdoc:\nEnd Rem\nType TXMLRPC_Call_Parameters\n\tField vector:Byte Ptr\n\n\tRem\n\t\tbbdoc:\n\tEnd Rem\n\tFunction Create:TXMLRPC_Call_Parameters(vectorType:Int = xmlrpc_vector_mixed)\n\t\tLocal parameters:TXMLRPC_Call_Parameters = New TXMLRPC_Call_Parameters\n\t\tparameters.vector = XMLRPC_CreateVector(Null, vectorType)\n\t\tReturn parameters\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc:\n\tEnd Rem\n\tMethod AppendString:Int(id:String, s:String)\n\t\tReturn XMLRPC_VectorAppendString(Self.vector, id, s)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc:\n\tEnd Rem\n\tMethod AppendBase64:Int(id:String, s:String)\n\t\tReturn XMLRPC_VectorAppendBase64(Self.vector, id, s)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc:\n\tEnd Rem\n\tMethod AppendDateTime:Int(id:String, time:Long)\n\t\tReturn XMLRPC_VectorAppendDateTime(Self.vector, id, time)\n\tEnd Method\n\n\tRem\n\t\tbbdoc:\n\tEnd Rem\n\tMethod AppendDateTime_ISO8601:Int(id:String, s:String)\n\t\tReturn XMLRPC_VectorAppendDateTime_ISO8601(Self.vector, id, s)\n\tEnd Method\n\n\tRem\n\t\tbbdoc:\n\tEnd Rem\n\tMethod AppendDouble:Int(id:String, f:Double)\n\t\tReturn XMLRPC_VectorAppendDouble(Self.vector, id, f)\n\tEnd Method\n\n\tRem\n\t\tbbdoc:\n\tEnd Rem\n\tMethod AppendInt:Int(id:String, i:Int)\n\t\tReturn XMLRPC_VectorAppendInt(Self.vector, id, i)\n\tEnd Method\n\n\tRem\n\t\tbbdoc:\n\tEnd Rem\n\tMethod AppendBoolean:Int(id:String, i:Byte)\n\t\tReturn XMLRPC_VectorAppendBoolean(Self.vector, id, i)\n\tEnd Method\nEnd Type\n","old_contents":"SuperStrict\n\nRem\n\tbbdoc: htbaapub.xmlrpc\n\tabout: \nEndRem\nModule htbaapub.xmlrpc\nModuleInfo \"Name: htbaapub.xmlrpc\"\nModuleInfo \"Version: 0.1\"\nModuleInfo \"Author: Christiaan Kras\"\n\nImport brl.blitz\nImport brl.basic\nImport brl.map\nImport brl.reflection\nImport brl.socket\n\nImport \"src\/expat-2.0.1\/src\/*.h\"\nModuleInfo \"CC_OPTS: -DHAVE_EXPAT_CONFIG_H\"\n?ppc\n\tModuleInfo \"CC_OPTS: -DWORDS_BIGENDIAN\"\n?\n\nImport \"src\/expat-2.0.1\/src\/xmlparse.c\"\nImport \"src\/expat-2.0.1\/src\/xmlrole.c\"\nImport \"src\/expat-2.0.1\/src\/xmltok.c\"\nImport \"src\/expat-2.0.1\/src\/xmltok_impl.c\"\nImport \"src\/expat-2.0.1\/src\/xmltok_ns.c\"\n\nImport \"src\/xmlrpc-epi-0.54\/src\/*.h\"\nImport \"glue.cpp\"\n\n?Win32\n\tImport \"win32.cpp\"\n\tModuleInfo \"LD_OPTS: -L%PWD%\/src\/iconv-1.9.2.win32\/lib\"\n\tImport \"src\/iconv-1.9.2.win32\/include\/*.h\"\t'http:\/\/www.zlatkovic.com\/pub\/libxml\n?\n\nImport \"-liconv\"\n\nImport \"src\/xmlrpc-epi-0.54\/src\/xmlrpc.c\"\nImport \"src\/xmlrpc-epi-0.54\/src\/base64.c\"\nImport \"src\/xmlrpc-epi-0.54\/src\/encodings.c\"\nImport \"src\/xmlrpc-epi-0.54\/src\/queue.c\"\nImport \"src\/xmlrpc-epi-0.54\/src\/simplestring.c\"\nImport \"src\/xmlrpc-epi-0.54\/src\/system_methods.c\"\nImport \"src\/xmlrpc-epi-0.54\/src\/xml_element.c\"\nImport \"src\/xmlrpc-epi-0.54\/src\/xml_to_dandarpc.c\"\nImport \"src\/xmlrpc-epi-0.54\/src\/xml_to_soap.c\"\nImport \"src\/xmlrpc-epi-0.54\/src\/xml_to_xmlrpc.c\"\nImport \"src\/xmlrpc-epi-0.54\/src\/xmlrpc_introspection.c\"\n\nInclude \"wrapper.bmx\"\nInclude \"datatypes.bmx\"\nInclude \"response.bmx\"\nInclude \"transport.bmx\"\nInclude \"client.bmx\"\nInclude \"server.bmx\"\n\nRem\n\tbbdoc:\nEnd Rem\nType TXMLRPC_Exception\n\tField message:String\n\tRem\n\t\tbbdoc:\n\tEnd Rem\n\tMethod Create:TXMLRPC_Exception(message:String)\n\t\tSelf.message = message\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc:\n\tEnd Rem\n\tMethod ToString:String()\n\t\tReturn Self.message\n\tEnd Method\nEnd Type\n\nRem\n\tbbdoc:\nEnd Rem\nType TXMLRPC_Call_Parameters\n\tField vector:Byte Ptr\n\n\tRem\n\t\tbbdoc:\n\tEnd Rem\n\tFunction Create:TXMLRPC_Call_Parameters(vectorType:Int = xmlrpc_vector_mixed)\n\t\tLocal parameters:TXMLRPC_Call_Parameters = New TXMLRPC_Call_Parameters\n\t\tparameters.vector = XMLRPC_CreateVector(Null, vectorType)\n\t\tReturn parameters\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc:\n\tEnd Rem\n\tMethod AppendString:Int(id:String, s:String)\n\t\tReturn XMLRPC_VectorAppendString(Self.vector, id, s)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc:\n\tEnd Rem\n\tMethod AppendBase64:Int(id:String, s:String)\n\t\tReturn XMLRPC_VectorAppendBase64(Self.vector, id, s)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc:\n\tEnd Rem\n\tMethod AppendDateTime:Int(id:String, time:Long)\n\t\tReturn XMLRPC_VectorAppendDateTime(Self.vector, id, time)\n\tEnd Method\n\n\tRem\n\t\tbbdoc:\n\tEnd Rem\n\tMethod AppendDateTime_ISO8601:Int(id:String, s:String)\n\t\tReturn XMLRPC_VectorAppendDateTime_ISO8601(Self.vector, id, s)\n\tEnd Method\n\n\tRem\n\t\tbbdoc:\n\tEnd Rem\n\tMethod AppendDouble:Int(id:String, f:Double)\n\t\tReturn XMLRPC_VectorAppendDouble(Self.vector, id, f)\n\tEnd Method\n\n\tRem\n\t\tbbdoc:\n\tEnd Rem\n\tMethod AppendInt:Int(id:String, i:Int)\n\t\tReturn XMLRPC_VectorAppendInt(Self.vector, id, i)\n\tEnd Method\n\n\tRem\n\t\tbbdoc:\n\tEnd Rem\n\tMethod AppendBoolean:Int(id:String, i:Byte)\n\t\tReturn XMLRPC_VectorAppendBoolean(Self.vector, id, i)\n\tEnd Method\nEnd Type\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"6a98d17726f97e62dd4710e43e1ea47c93e17f9a","subject":"Adding picking functions","message":"Adding picking functions\n","repos":"kfprimm\/maxb3d,kfprimm\/maxb3d","old_file":"functions.mod\/functions.bmx","new_file":"functions.mod\/functions.bmx","new_contents":"\nStrict\n\nRem\n\tbbdoc: MaxB3D procedural functions\nEnd Rem\nModule MaxB3D.Functions\nModuleInfo \"Author: Kevin Primm\"\nModuleInfo \"License: MIT\"\n\nImport MaxB3D.Core\n\nRem\n\tbbdoc: Draws the world in its current state.\n\tabout: Tweening is not yet implemented.\nEnd Rem\nFunction RenderWorld:TRenderInfo(tween#=1.0)\n\tReturn CurrentWorld().Render(tween)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction RenderCamera:TRenderInfo(camera:TCamera)\n\tReturn CurrentWorld().RenderCamera(camera)\nEnd Function\nRem\n\tbbdoc: Advances all animations and updates collision\/physics.\nEnd Rem\nFunction UpdateWorld(speed#=1.0)\n\tReturn CurrentWorld().Update(speed)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetCollisions(src,dest,methd,response)\n\tReturn CurrentWorld().SetCollisions(src,dest,methd,response)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetAmbientLight(red Var,green Var,blue Var)\n\tReturn CurrentWorld().GetAmbientLight(red,green,blue)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetAmbientLight(red,green,blue)\n\tReturn CurrentWorld().SetAmbientLight(red,green,blue)\nEnd Function\nRem\n\treturns: Wireframe rendering state, see #SetWireframe\nEnd Rem\nFunction GetWireFrame()\n\tReturn CurrentWorld().GetWireFrame()\nEnd Function\nRem\n\tbbdoc: Enable\/disable global wireframe rendering.\n\tabout: @SetWireframe can enable wireframe rendering for the entire scene. Alternatively, calling #SetEntityFX with @FX_WIREFRAME will cause only \n\t\t\ta single entity's wireframe to be rendered.\nEnd Rem\nFunction SetWireFrame(enable)\n\tReturn CurrentWorld().SetWireFrame(enable)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetDither()\n\tReturn CurrentWorld().GetDither()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetDither(enable)\n\tReturn CurrentWorld().SetDither(enable)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction WorldPick:TPick[](src:Object, target:Object, sort = False)\n\tReturn CurrentWorld().Pick(src,target, sort)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction ClearTextureFilters()\n\tReturn CurrentWorld().ClearTextureFilters()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction AddTextureFilter(text$, flags)\n\tReturn CurrentWorld().AddTextureFilter(text, flags)\nEnd Function\n\n'Bodies\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction CreateBody:TBody()\n\tReturn CurrentWorld().AddBody()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetBodyMass#(body:TBody)\n\tReturn body.GetMass()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetBodyMass(body:TBody,mass#)\n\tReturn body.SetMass(mass)\nEnd Function\n\n'Brushes\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction CreateBrush:TBrush(url:Object=Null)\n\tReturn CurrentWorld().AddBrush(url)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction CopyBrush:TBrush(brush:TBrush)\n\tReturn brush.Copy()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetBrushColor(brush:TBrush,red Var,green Var,blue Var)\n\tReturn brush.GetColor(red,green,blue)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetBrushColor(brush:TBrush,red,green,blue)\n\tReturn brush.SetColor(red,green,blue)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetBrushAlpha#(brush:TBrush)\n\tReturn brush.GetAlpha()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetBrushAlpha(brush:TBrush,alpha#)\n\tReturn brush.SetAlpha(alpha)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetBrushShine#(brush:TBrush)\n\tReturn brush.GetShine()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetBrushShine(brush:TBrush,shine#)\n\tReturn brush.SetShine(shine)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetBrushTexture:TTexture(brush:TBrush,index=0)\n\tReturn brush.GetTexture(index)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetBrushTexture(brush:TBrush,texture:TTexture,index=0,frame=0)\n\tReturn brush.SetTexture(texture,index,frame)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetBrushFrame(brush:TBrush,index=0)\n\tReturn brush.GetFrame(index)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetBrushFrame(brush:TBrush,frame,index=0)\n\tReturn brush.SetFrame(frame,index)\nEnd Function\nRem\n\tbbdoc: Get brush effects.\nEnd Rem\nFunction GetBrushFX(brush:TBrush)\n\tReturn brush.GetFX()\nEnd Function\nRem\n\tbbdoc: Set various rendering effects for a brush.\n\tabout:\nEnd Rem\nFunction SetBrushFX(brush:TBrush,fx)\n\tReturn brush.SetFX(fx)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetBrushBlend(brush:TBrush)\n\tReturn brush.GetBlend()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetBrushBlend(brush:TBrush,fx)\n\tReturn brush.SetBlend(fx)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetBrushShader:TShader(brush:TBrush)\n\tReturn brush.GetShader()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetBrushShader(brush:TBrush,shader:TShader)\n\tReturn brush.SetShader(shader)\nEnd Function\n\n'Cameras\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction CreateCamera:TCamera(parent:TEntity=Null)\n\tReturn CurrentWorld().AddCamera(parent)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetCameraMode(camera:TCamera)\n\tReturn camera.GetMode()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetCameraMode(camera:TCamera,mode)\n\tReturn camera.SetMode(mode)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetCameraFogMode(camera:TCamera)\n\tReturn camera.GetFogMode()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetCameraFogMode(camera:TCamera,mode)\n\tReturn camera.SetFogMode(mode)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetCameraFogColor(camera:TCamera,red Var,green Var,blue Var)\n\tReturn camera.GetFogColor(red,green,blue)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetCameraFogColor(camera:TCamera,red,green,blue)\n\tReturn camera.SetFogColor(red,green,blue)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetCameraFogRange(camera:TCamera,near# Var,far# Var)\n\tReturn camera.GetFogRange(near,far)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetCameraFogRange(camera:TCamera,near#,far#)\n\tReturn camera.SetFogRange(near,far)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetCameraViewport(camera:TCamera,x Var,y Var,width Var,height Var)\n\tReturn camera.GetViewport(x,y,width,height)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetCameraViewport(camera:TCamera,x,y,width,height)\n\tReturn camera.SetViewport(x,y,width,height)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetCameraClsMode(camera:TCamera)\n\tReturn camera.GetClsMode()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetCameraClsMode(camera:TCamera,mode)\n\tReturn camera.SetClsMode(mode)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetCameraRange(camera:TCamera,near# Var,far# Var)\n\tReturn camera.GetRange(near,far)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetCameraRange(camera:TCamera,near#,far#)\n\tReturn camera.SetRange(near,far)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetCameraZoom#(camera:TCamera)\n\tReturn camera.GetZoom()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetCameraZoom(camera:TCamera,zoom#)\n\tReturn camera.SetZoom(zoom)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetCameraFOV#(camera:TCamera)\n\tReturn camera.GetFOV()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetCameraFOV(camera:TCamera,angle#)\n\tReturn camera.SetFOV(angle)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction CameraInView#(camera:TCamera,target:Object)\n\tReturn camera.InView(target)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction CameraProject(camera:TCamera,target:Object,x# Var,y# Var, offset#[] = Null)\n\tReturn camera.Project(target,x,y,offset)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction CameraUnproject(camera:TCamera,wx#,wy#,wz#,x# Var,y# Var,z# Var)\n\tReturn camera.Unproject(wx,wy,wz,x,y,z)\nEnd Function\n\n'Entities\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction CopyEntity:TEntity(entity:TEntity,parent:TEntity=Null)\n\tReturn entity.Copy(parent)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction FreeEntity(entity:TEntity)\n\tReturn entity.Free()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetEntityParent:TEntity(entity:TEntity)\n\tReturn entity.GetParent()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetEntityParent(entity:TEntity,parent:TEntity)\n\tReturn entity.SetParent(parent)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction CountEntityChildren(entity:TEntity,recursive=False)\n\tReturn entity.CountChildren(recursive)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction FindEntityChild:TEntity(entity:TEntity, name$, recursive = False)\n\tReturn entity.FindChild(name, recursive)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetEntityVisible(entity:TEntity)\n\tReturn entity.GetVisible()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetEntityVisible(entity:TEntity,visible)\n\tReturn entity.SetVisible(visible)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetEntityOrder(entity:TEntity)\n\tReturn entity.GetOrder()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetEntityOrder(entity:TEntity,order)\n\tReturn entity.SetOrder(order)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetEntityName$(entity:TEntity)\n\tReturn entity.GetName()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetEntityName(entity:TEntity,name$)\n\tReturn entity.SetName(name)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetEntityBrush:TBrush(entity:TEntity)\n\tReturn entity.GetBrush()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetEntityBrush(entity:TEntity,brush:TBrush)\n\tReturn entity.SetBrush(brush)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetEntityColor(entity:TEntity,red Var,green Var,blue Var)\n\tReturn entity.GetColor(red,green,blue)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetEntityColor(entity:TEntity,red,green,blue)\n\tReturn entity.SetColor(red,green,blue)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetEntityAlpha#(entity:TEntity)\n\tReturn entity.GetAlpha()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetEntityAlpha(entity:TEntity,alpha#)\n\tReturn entity.SetAlpha(alpha)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetEntityShine#(entity:TEntity)\n\tReturn entity.GetShine()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetEntityShine(entity:TEntity,shine#)\n\tReturn entity.SetShine(shine)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetEntityTexture:TTexture(entity:TEntity,index=0)\n\tReturn entity.GetTexture(index)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetEntityTexture(entity:TEntity,texture:TTexture,index=0,frame=0)\n\tReturn entity.SetTexture(texture,index,frame)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetEntityFX(entity:TEntity)\n\tReturn entity.GetFX()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetEntityFX(entity:TEntity,fx)\n\tReturn entity.SetFX(fx)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetEntityBlend(entity:TEntity)\n\tReturn entity.GetBlend()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetEntityBlend(entity:TEntity,blend)\n\tReturn entity.SetBlend(blend)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetEntityShader:TShader(entity:TEntity)\n\tReturn entity.GetShader()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetEntityShader(entity:TEntity,shader:TShader)\n\tReturn entity.SetShader(shader)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction TurnEntity(entity:TEntity,pitch#,yaw#,roll#,glob=False)\n\tReturn entity.Turn(pitch,yaw,roll,glob)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction PointEntity(entity:TEntity,target:Object,roll#=0.0)\n\tReturn entity.Point(target,roll)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction MoveEntity(entity:TEntity,x#,y#,z#)\n\tReturn entity.Move(x,y,z)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction TranslateEntity(entity:TEntity,x#,y#,z#,glob=True)\n\tReturn entity.Translate(x,y,z,glob)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetEntityScale(entity:TEntity,x# Var,y# Var,z# Var,glob=False)\n\tReturn entity.GetScale(x,y,z,glob)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetEntityScale(entity:TEntity,x#,y#,z#,glob=False)\n\tReturn entity.SetScale(x,y,z,glob)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetEntityRotation(entity:TEntity,pitch# Var,yaw# Var,roll# Var,glob=False)\n\tReturn entity.GetRotation(pitch,yaw,roll,glob)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetEntityRotation(entity:TEntity,pitch#,yaw#,roll#,glob=False)\n\tReturn entity.SetRotation(pitch,yaw,roll,glob)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetEntityPosition(entity:TEntity,x# Var,y# Var,z# Var,glob=False)\n\tReturn entity.GetPosition(x,y,z,glob)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetEntityPosition(entity:TEntity,x#,y#,z#,glob=False)\n\tReturn entity.SetPosition(x,y,z,glob)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction TransformEntity(entity:TEntity,matrix:TMatrix,glob=False)\n\tReturn entity.Transform(matrix,glob)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetEntityCollisions:TCollision[](entity:TEntity)\n\tReturn entity.GetCollisions()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetEntityBox(entity:TEntity,x# Var,y# Var,z# Var,width# Var,height# Var,depth# Var)\n\tReturn entity.GetBox(x,y,z,width,height,depth)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetEntityBox(entity:TEntity,x#,y#,z#,width#,height#,depth#)\n\tReturn entity.SetBox(x,y,z,width,height,depth)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetEntityRadius(entity:TEntity,x# Var,y# Var)\n\tReturn entity.GetRadius(x,y)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetEntityRadius(entity:TEntity,x#,y#=-1)\n\tReturn entity.SetRadius(x,y)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetEntityType(entity:TEntity)\n\tReturn entity.GetType()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetEntityType(entity:TEntity,typ,recursive=False)\n\tReturn entity.SetType(typ,recursive)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction ResetEntity(entity:TEntity)\n\tReturn entity.Reset()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetEntityPickMode(entity:TEntity, mode Var, obscurer Var)\n\tReturn entity.GetPickMode(mode, obscurer)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetEntityPickMode(entity:TEntity, mode, obscurer = True)\n\tReturn entity.SetPickMode(mode, obscurer)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetEntityCullRadius#(entity:TEntity)\n\tReturn entity.GetCullRadius()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetEntityCullRadius#(entity:TEntity,radius#)\n\tReturn entity.SetCullRadius(radius)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetEntityDistance#(entity:TEntity,target:Object)\n\tReturn entity.GetDistance(target)\nEnd Function\n\n'Lights\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction CreateLight:TLight(typ=LIGHT_DIRECTIONAL,parent:TEntity=Null)\n\tReturn CurrentWorld().AddLight(typ,parent)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetLightRange#(light:TLight)\n\tReturn light.GetRange()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetLightRange(light:TLight,range#)\n\tReturn light.SetRange(range)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetLightAngles(light:TLight,inner# Var,outer# Var)\n\tReturn light.GetAngles(inner,outer)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetLightAngles(light:TLight,inner#,outer#)\n\tReturn light.SetAngles(inner,outer)\nEnd Function\n\n'Meshes\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction CreateMesh:TMesh(parent:TEntity=Null)\n\tReturn CurrentWorld().AddMesh(\"\/\/empty\",parent)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction LoadMesh:TMesh(url:Object,parent:TEntity=Null)\n\tReturn CurrentWorld().AddMesh(url,parent)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetMeshSurface:TSurface(mesh:TMesh,index)\n\tReturn mesh.GetSurface(index)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction AddMeshSurface:TSurface(mesh:TMesh,brush:TBrush=Null,vertexcount=0,trianglecount=0)\n\tReturn mesh.AddSurface(brush,vertexcount,trianglecount)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SwapMeshSurface(mesh:TMesh,surface:TSurface,new_surface:TSurface)\n\tReturn mesh.SwapSurface(surface,new_surface)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction CloneMesh:TMesh(mesh:TMesh,parent:TEntity=Null)\n\tReturn mesh.Clone(parent)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction TranslateMesh(mesh:TMesh,x#,y#,z#)\n\tReturn mesh.Translate(x,y,z)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction ScaleMesh(mesh:TMesh,x#,y#,z#)\n\tReturn mesh.Scale(x,y,z)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction RotateMesh(mesh:TMesh,pitch#,yaw#,roll#)\n\tReturn mesh.Rotate(pitch,yaw,roll)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction PositionMesh(mesh:TMesh,x#,y#,z#)\n\tReturn mesh.Position(x,y,z)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction CenterMesh(mesh:TMesh)\n\tReturn mesh.Center()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetMeshSize(mesh:TMesh,width# Var,height# Var,depth# Var)\n\tReturn mesh.GetSize(width,height,depth)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction FitMesh(mesh:TMesh,x#,y#,z#,width#,height#,depth#,uniform=False)\n\tReturn mesh.Fit(x,y,z,width,height,depth,uniform)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction FlipMesh(mesh:TMesh)\n\tReturn mesh.Flip()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction UpdateMeshNormals(mesh:TMesh,smoothing=True)\n\tReturn mesh.UpdateNormals(smoothing)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetMeshAnim(mesh:TMesh,seq:TAnimSeq,mode=ANIMATION_LOOP,speed#=1.0)\n\tReturn mesh.SetAnim(seq,mode,speed)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction AddMeshAnimSeq:TAnimSeq(mesh:TMesh)\n\tReturn mesh.AddAnimSeq(0,0)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction ExtractMeshAnimSeq:TAnimSeq(mesh:TMesh,start_frame,end_frame)\n\tReturn mesh.ExtractAnimSeq(start_frame,end_frame)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetMeshAnimSeq:TAnimSeq(mesh:TMesh)\n\tReturn mesh.GetAnimSeq()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetMeshAnimSeq(mesh:TMesh,seq:TAnimSeq)\n\tReturn mesh.SetAnimSeq(seq)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetMeshAnimMode(mesh:TMesh)\n\tReturn mesh.GetAnimMode()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetMeshAnimMode(mesh:TMesh,mode)\n\tReturn mesh.SetAnimMode(mode)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetMeshAnimSpeed#(mesh:TMesh)\n\tReturn mesh.GetAnimSpeed()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetMeshAnimSpeed(mesh:TMesh,speed#)\n\tReturn mesh.SetAnimSpeed(speed)\nEnd Function\n\n'Animation\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction CreateAnimSeq:TAnimSeq(first,last,name$=\"\")\n\tReturn TAnimSeq.Create(first,last,name)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetAnimSeqName$(seq:TAnimSeq)\n\tReturn seq.GetName()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetAnimSeqName(seq:TAnimSeq,name$)\n\tReturn seq.SetName(name)\nEnd Function\n\n'Pivots\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction CreatePivot:TPivot(parent:TEntity=Null)\n\tReturn CurrentWorld().AddPivot(parent)\nEnd Function\n\n'Flats (plane)\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction CreateFlat:TFlat(parent:TEntity=Null)\n\tReturn CurrentWorld().AddFlat(parent)\nEnd Function\n\n'Sprite\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction CreateSprite:TSprite(parent:TEntity=Null)\n\tReturn CurrentWorld().AddSprite(Null,TEXTURE_DEFAULT,parent)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction LoadSprite:TSprite(url:Object,flags=TEXTURE_DEFAULT,parent:TEntity=Null)\n\tReturn CurrentWorld().AddSprite(url,flags,parent)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetSpriteAngle#(sprite:TSprite)\n\tReturn sprite.GetAngle()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetSpriteAngle(sprite:TSprite,angle#)\n\tReturn sprite.SetAngle(angle)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetSpriteHandle(sprite:TSprite,x# Var,y# Var)\n\tReturn sprite.GetHandle(x,y)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd RemS\nFunction SetSpriteHandle(sprite:TSprite,x#,y#)\n\tReturn sprite.SetHandle(x,y)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetSpriteViewMode(sprite:TSprite)\n\tReturn sprite.GetViewMode()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetSpriteViewMode(sprite:TSprite,mode)\n\tReturn sprite.SetViewMode(mode)\nEnd Function\n\n'Surfaces\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction CountSurfaceVertices(surface:TSurface)\n\tReturn surface.CountVertices()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction CountSurfaceTriangles(surface:TSurface)\n\tReturn surface.CountTriangles()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction UpdateSurfaceNormals(surface:TSurface,smoothing=True)\n\tReturn surface.UpdateNormals(smoothing)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction ResizeSurface(surface:TSurface,vertex_count,triangle_count)\n\tReturn surface.Resize(vertex_count,triangle_count)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction AddSurfaceVertex(surface:TSurface,x#,y#,z#,u#=0.0,v#=0.0)\n\tReturn surface.AddVertex(x,y,z,u,v)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetSurfaceCoords(surface:TSurface,index,x# Var,y# Var,z# Var)\n\tReturn surface.GetCoords(index,x,y,z)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetSurfaceCoords(surface:TSurface,index,x#,y#,z#)\n\tReturn surface.SetCoords(index,x,y,z)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetSurfaceColor(surface:TSurface,index,red Var,green Var,blue Var,alpha# Var)\n\tReturn surface.GetColor(index,red,green,blue,alpha)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetSurfaceColor(surface:TSurface,index,red,green,blue,alpha#)\n\tReturn surface.SetColor(index,red,green,blue,alpha)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetSurfaceNormal(surface:TSurface,index,nx# Var,ny# Var,nz# Var)\n\tReturn surface.GetNormal(index,nx,ny,nz)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetSurfaceNormal(surface:TSurface,index,nx#,ny#,nz#)\n\tReturn surface.SetNormal(index,nx,ny,nz)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetSurfaceTexCoords(surface:TSurface,index,u# Var,v# Var,set=0)\n\tReturn surface.GetTexCoords(index,u,v,set)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetSurfaceTexCoords(surface:TSurface,index,u#,v#,set=0)\n\tReturn surface.SetTexCoords(index,u,v,set)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction AddSurfaceTriangle(surface:TSurface,v0,v1,v2)\n\tReturn surface.AddTriangle(v0,v1,v2)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetSurfaceTriangle(surface:TSurface,index,v0 Var,v1 Var,v2 Var)\n\tReturn surface.GetTriangle(index,v0,v1,v2)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetSurfaceTriangle(surface:TSurface,index,v0,v1,v2)\n\tReturn surface.SetTriangle(index,v0,v1,v2)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetSurfaceBrush:TBrush(surface:TSurface)\n\tReturn surface.GetBrush()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetSurfaceBrush(surface:TSurface,brush:TBrush)\n\tReturn surface.SetBrush(brush)\nEnd Function\n\n'Terrains\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction CreateTerrain:TTerrain(size,parent:TEntity=Null)\n\tReturn CurrentWorld().AddTerrain([size],parent)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction LoadTerrain:TTerrain(url:Object,parent:TEntity=Null)\n\tReturn CurrentWorld().AddTerrain(url,parent)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetTerrainDetail(terrain:TTerrain,lmax,max_tris,clmax=-1)\n\tReturn terrain.SetDetail(lmax,max_tris,clmax)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetTerrainHeight#(terrain:TTerrain,x,z)\n\tReturn terrain.GetHeight(x,z)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetTerrainHeight(terrain:TTerrain,height#,x,z)\n\tReturn terrain.SetHeight(height,x,z)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetTerrainSize(terrain:TTerrain)\n\tReturn terrain.GetSize()\nEnd Function\n\n'Textures\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction CreateTexture:TTexture(width,height,flags=TEXTURE_COLOR|TEXTURE_MIPMAP,frames=1)\n\tLocal texture:TTexture=CurrentWorld().AddTexture([width,height,frames],flags)\n\ttexture.SetPixmap(CreatePixmap(width,height,PF_RGBA8888))\n\tReturn texture\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction LoadTexture:TTexture(url:Object,flags=TEXTURE_COLOR|TEXTURE_MIPMAP)\n\tReturn CurrentWorld().AddTexture(url,flags)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction LockTexture:TPixmap(texture:TTexture)\n\tReturn texture.Lock()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction UnlockTexture(texture:TTexture)\n\tReturn texture.Unlock()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetTextureFlags(texture:TTexture)\n\tReturn texture.GetFlags()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetTextureFlags(texture:TTexture,flags)\n\tReturn texture.SetFlags(flags)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetTextureBlend(texture:TTexture)\n\tReturn texture.GetBlend()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetTextureBlend(texture:TTexture,blend)\n\tReturn texture.SetBlend(blend)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetTextureCoords(texture:TTexture)\n\tReturn texture.GetCoords()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetTextureCoords(texture:TTexture,coords)\n\tReturn texture.SetCoords(coords)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetTextureScale(texture:TTexture,x# Var,y# Var)\n\tReturn texture.GetScale(x,y)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetTextureScale(texture:TTexture,x#,y#)\n\tReturn texture.SetScale(x,y)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetTextureRotation#(texture:TTexture)\n\tReturn texture.GetRotation()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetTextureRotation(texture:TTexture,rotation#)\n\tReturn texture.SetRotation(rotation)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetTexturePosition(texture:TTexture,x# Var,y# Var)\n\tReturn texture.GetPosition(x,y)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetTexturePosition(texture:TTexture,x#,y#)\n\tReturn texture.SetPosition(x,y)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetTextureSize(texture:TTexture,width Var,height Var)\n\tReturn texture.GetSize(width,height)\nEnd Function\n\n'BSP\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction LoadBSPModel:TBSPModel(url:Object,parent:TEntity=Null)\n\tReturn CurrentWorld().AddBSPModel(url,parent)\nEnd Function\n\nSetWorld CreateWorld()\n","old_contents":"\nStrict\n\nRem\n\tbbdoc: MaxB3D procedural functions\nEnd Rem\nModule MaxB3D.Functions\nModuleInfo \"Author: Kevin Primm\"\nModuleInfo \"License: MIT\"\n\nImport MaxB3D.Core\n\nRem\n\tbbdoc: Draws the world in its current state.\n\tabout: Tweening is not yet implemented.\nEnd Rem\nFunction RenderWorld:TRenderInfo(tween#=1.0)\n\tReturn CurrentWorld().Render(tween)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction RenderCamera:TRenderInfo(camera:TCamera)\n\tReturn CurrentWorld().RenderCamera(camera)\nEnd Function\nRem\n\tbbdoc: Advances all animations and updates collision\/physics.\nEnd Rem\nFunction UpdateWorld(speed#=1.0)\n\tReturn CurrentWorld().Update(speed)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetCollisions(src,dest,methd,response)\n\tReturn CurrentWorld().SetCollisions(src,dest,methd,response)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetAmbientLight(red Var,green Var,blue Var)\n\tReturn CurrentWorld().GetAmbientLight(red,green,blue)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetAmbientLight(red,green,blue)\n\tReturn CurrentWorld().SetAmbientLight(red,green,blue)\nEnd Function\nRem\n\treturns: Wireframe rendering state, see #SetWireframe\nEnd Rem\nFunction GetWireFrame()\n\tReturn CurrentWorld().GetWireFrame()\nEnd Function\nRem\n\tbbdoc: Enable\/disable global wireframe rendering.\n\tabout: @SetWireframe can enable wireframe rendering for the entire scene. Alternatively, calling #SetEntityFX with @FX_WIREFRAME will cause only \n\t\t\ta single entity's wireframe to be rendered.\nEnd Rem\nFunction SetWireFrame(enable)\n\tReturn CurrentWorld().SetWireFrame(enable)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetDither()\n\tReturn CurrentWorld().GetDither()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetDither(enable)\n\tReturn CurrentWorld().SetDither(enable)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction WorldPick:TPick[](src:Object, target:Object, sort = False)\n\tReturn CurrentWorld().Pick(src,target, sort)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction ClearTextureFilters()\n\tReturn CurrentWorld().ClearTextureFilters()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction AddTextureFilter(text$, flags)\n\tReturn CurrentWorld().AddTextureFilter(text, flags)\nEnd Function\n\n'Bodies\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction CreateBody:TBody()\n\tReturn CurrentWorld().AddBody()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetBodyMass#(body:TBody)\n\tReturn body.GetMass()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetBodyMass(body:TBody,mass#)\n\tReturn body.SetMass(mass)\nEnd Function\n\n'Brushes\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction CreateBrush:TBrush(url:Object=Null)\n\tReturn CurrentWorld().AddBrush(url)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction CopyBrush:TBrush(brush:TBrush)\n\tReturn brush.Copy()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetBrushColor(brush:TBrush,red Var,green Var,blue Var)\n\tReturn brush.GetColor(red,green,blue)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetBrushColor(brush:TBrush,red,green,blue)\n\tReturn brush.SetColor(red,green,blue)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetBrushAlpha#(brush:TBrush)\n\tReturn brush.GetAlpha()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetBrushAlpha(brush:TBrush,alpha#)\n\tReturn brush.SetAlpha(alpha)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetBrushShine#(brush:TBrush)\n\tReturn brush.GetShine()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetBrushShine(brush:TBrush,shine#)\n\tReturn brush.SetShine(shine)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetBrushTexture:TTexture(brush:TBrush,index=0)\n\tReturn brush.GetTexture(index)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetBrushTexture(brush:TBrush,texture:TTexture,index=0,frame=0)\n\tReturn brush.SetTexture(texture,index,frame)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetBrushFrame(brush:TBrush,index=0)\n\tReturn brush.GetFrame(index)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetBrushFrame(brush:TBrush,frame,index=0)\n\tReturn brush.SetFrame(frame,index)\nEnd Function\nRem\n\tbbdoc: Get brush effects.\nEnd Rem\nFunction GetBrushFX(brush:TBrush)\n\tReturn brush.GetFX()\nEnd Function\nRem\n\tbbdoc: Set various rendering effects for a brush.\n\tabout:\nEnd Rem\nFunction SetBrushFX(brush:TBrush,fx)\n\tReturn brush.SetFX(fx)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetBrushBlend(brush:TBrush)\n\tReturn brush.GetBlend()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetBrushBlend(brush:TBrush,fx)\n\tReturn brush.SetBlend(fx)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetBrushShader:TShader(brush:TBrush)\n\tReturn brush.GetShader()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetBrushShader(brush:TBrush,shader:TShader)\n\tReturn brush.SetShader(shader)\nEnd Function\n\n'Cameras\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction CreateCamera:TCamera(parent:TEntity=Null)\n\tReturn CurrentWorld().AddCamera(parent)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetCameraMode(camera:TCamera)\n\tReturn camera.GetMode()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetCameraMode(camera:TCamera,mode)\n\tReturn camera.SetMode(mode)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetCameraFogMode(camera:TCamera)\n\tReturn camera.GetFogMode()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetCameraFogMode(camera:TCamera,mode)\n\tReturn camera.SetFogMode(mode)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetCameraFogColor(camera:TCamera,red Var,green Var,blue Var)\n\tReturn camera.GetFogColor(red,green,blue)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetCameraFogColor(camera:TCamera,red,green,blue)\n\tReturn camera.SetFogColor(red,green,blue)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetCameraFogRange(camera:TCamera,near# Var,far# Var)\n\tReturn camera.GetFogRange(near,far)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetCameraFogRange(camera:TCamera,near#,far#)\n\tReturn camera.SetFogRange(near,far)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetCameraViewport(camera:TCamera,x Var,y Var,width Var,height Var)\n\tReturn camera.GetViewport(x,y,width,height)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetCameraViewport(camera:TCamera,x,y,width,height)\n\tReturn camera.SetViewport(x,y,width,height)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetCameraClsMode(camera:TCamera)\n\tReturn camera.GetClsMode()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetCameraClsMode(camera:TCamera,mode)\n\tReturn camera.SetClsMode(mode)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetCameraRange(camera:TCamera,near# Var,far# Var)\n\tReturn camera.GetRange(near,far)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetCameraRange(camera:TCamera,near#,far#)\n\tReturn camera.SetRange(near,far)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetCameraZoom#(camera:TCamera)\n\tReturn camera.GetZoom()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetCameraZoom(camera:TCamera,zoom#)\n\tReturn camera.SetZoom(zoom)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetCameraFOV#(camera:TCamera)\n\tReturn camera.GetFOV()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetCameraFOV(camera:TCamera,angle#)\n\tReturn camera.SetFOV(angle)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction CameraInView#(camera:TCamera,target:Object)\n\tReturn camera.InView(target)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction CameraProject(camera:TCamera,target:Object,x# Var,y# Var, offset#[] = Null)\n\tReturn camera.Project(target,x,y,offset)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction CameraUnproject(camera:TCamera,wx#,wy#,wz#,x# Var,y# Var,z# Var)\n\tReturn camera.Unproject(wx,wy,wz,x,y,z)\nEnd Function\n\n'Entities\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction CopyEntity:TEntity(entity:TEntity,parent:TEntity=Null)\n\tReturn entity.Copy(parent)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction FreeEntity(entity:TEntity)\n\tReturn entity.Free()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetEntityParent:TEntity(entity:TEntity)\n\tReturn entity.GetParent()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetEntityParent(entity:TEntity,parent:TEntity)\n\tReturn entity.SetParent(parent)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction CountEntityChildren(entity:TEntity,recursive=False)\n\tReturn entity.CountChildren(recursive)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction FindEntityChild:TEntity(entity:TEntity, name$, recursive = False)\n\tReturn entity.FindChild(name, recursive)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetEntityVisible(entity:TEntity)\n\tReturn entity.GetVisible()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetEntityVisible(entity:TEntity,visible)\n\tReturn entity.SetVisible(visible)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetEntityOrder(entity:TEntity)\n\tReturn entity.GetOrder()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetEntityOrder(entity:TEntity,order)\n\tReturn entity.SetOrder(order)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetEntityName$(entity:TEntity)\n\tReturn entity.GetName()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetEntityName(entity:TEntity,name$)\n\tReturn entity.SetName(name)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetEntityBrush:TBrush(entity:TEntity)\n\tReturn entity.GetBrush()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetEntityBrush(entity:TEntity,brush:TBrush)\n\tReturn entity.SetBrush(brush)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetEntityColor(entity:TEntity,red Var,green Var,blue Var)\n\tReturn entity.GetColor(red,green,blue)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetEntityColor(entity:TEntity,red,green,blue)\n\tReturn entity.SetColor(red,green,blue)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetEntityAlpha#(entity:TEntity)\n\tReturn entity.GetAlpha()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetEntityAlpha(entity:TEntity,alpha#)\n\tReturn entity.SetAlpha(alpha)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetEntityShine#(entity:TEntity)\n\tReturn entity.GetShine()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetEntityShine(entity:TEntity,shine#)\n\tReturn entity.SetShine(shine)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetEntityTexture:TTexture(entity:TEntity,index=0)\n\tReturn entity.GetTexture(index)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetEntityTexture(entity:TEntity,texture:TTexture,index=0,frame=0)\n\tReturn entity.SetTexture(texture,index,frame)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetEntityFX(entity:TEntity)\n\tReturn entity.GetFX()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetEntityFX(entity:TEntity,fx)\n\tReturn entity.SetFX(fx)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetEntityBlend(entity:TEntity)\n\tReturn entity.GetBlend()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetEntityBlend(entity:TEntity,blend)\n\tReturn entity.SetBlend(blend)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetEntityShader:TShader(entity:TEntity)\n\tReturn entity.GetShader()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetEntityShader(entity:TEntity,shader:TShader)\n\tReturn entity.SetShader(shader)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction TurnEntity(entity:TEntity,pitch#,yaw#,roll#,glob=False)\n\tReturn entity.Turn(pitch,yaw,roll,glob)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction PointEntity(entity:TEntity,target:Object,roll#=0.0)\n\tReturn entity.Point(target,roll)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction MoveEntity(entity:TEntity,x#,y#,z#)\n\tReturn entity.Move(x,y,z)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction TranslateEntity(entity:TEntity,x#,y#,z#,glob=True)\n\tReturn entity.Translate(x,y,z,glob)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetEntityScale(entity:TEntity,x# Var,y# Var,z# Var,glob=False)\n\tReturn entity.GetScale(x,y,z,glob)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetEntityScale(entity:TEntity,x#,y#,z#,glob=False)\n\tReturn entity.SetScale(x,y,z,glob)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetEntityRotation(entity:TEntity,pitch# Var,yaw# Var,roll# Var,glob=False)\n\tReturn entity.GetRotation(pitch,yaw,roll,glob)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetEntityRotation(entity:TEntity,pitch#,yaw#,roll#,glob=False)\n\tReturn entity.SetRotation(pitch,yaw,roll,glob)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetEntityPosition(entity:TEntity,x# Var,y# Var,z# Var,glob=False)\n\tReturn entity.GetPosition(x,y,z,glob)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetEntityPosition(entity:TEntity,x#,y#,z#,glob=False)\n\tReturn entity.SetPosition(x,y,z,glob)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction TransformEntity(entity:TEntity,matrix:TMatrix,glob=False)\n\tReturn entity.Transform(matrix,glob)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetEntityCollisions:TCollision[](entity:TEntity)\n\tReturn entity.GetCollisions()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetEntityBox(entity:TEntity,x# Var,y# Var,z# Var,width# Var,height# Var,depth# Var)\n\tReturn entity.GetBox(x,y,z,width,height,depth)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetEntityBox(entity:TEntity,x#,y#,z#,width#,height#,depth#)\n\tReturn entity.SetBox(x,y,z,width,height,depth)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetEntityRadius(entity:TEntity,x# Var,y# Var)\n\tReturn entity.GetRadius(x,y)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetEntityRadius(entity:TEntity,x#,y#=-1)\n\tReturn entity.SetRadius(x,y)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetEntityType(entity:TEntity)\n\tReturn entity.GetType()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetEntityType(entity:TEntity,typ,recursive=False)\n\tReturn entity.SetType(typ,recursive)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction ResetEntity(entity:TEntity)\n\tReturn entity.Reset()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetEntityCullRadius#(entity:TEntity)\n\tReturn entity.GetCullRadius()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetEntityCullRadius#(entity:TEntity,radius#)\n\tReturn entity.SetCullRadius(radius)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetEntityDistance#(entity:TEntity,target:Object)\n\tReturn entity.GetDistance(target)\nEnd Function\n\n'Lights\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction CreateLight:TLight(typ=LIGHT_DIRECTIONAL,parent:TEntity=Null)\n\tReturn CurrentWorld().AddLight(typ,parent)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetLightRange#(light:TLight)\n\tReturn light.GetRange()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetLightRange(light:TLight,range#)\n\tReturn light.SetRange(range)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetLightAngles(light:TLight,inner# Var,outer# Var)\n\tReturn light.GetAngles(inner,outer)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetLightAngles(light:TLight,inner#,outer#)\n\tReturn light.SetAngles(inner,outer)\nEnd Function\n\n'Meshes\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction CreateMesh:TMesh(parent:TEntity=Null)\n\tReturn CurrentWorld().AddMesh(\"\/\/empty\",parent)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction LoadMesh:TMesh(url:Object,parent:TEntity=Null)\n\tReturn CurrentWorld().AddMesh(url,parent)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetMeshSurface:TSurface(mesh:TMesh,index)\n\tReturn mesh.GetSurface(index)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction AddMeshSurface:TSurface(mesh:TMesh,brush:TBrush=Null,vertexcount=0,trianglecount=0)\n\tReturn mesh.AddSurface(brush,vertexcount,trianglecount)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SwapMeshSurface(mesh:TMesh,surface:TSurface,new_surface:TSurface)\n\tReturn mesh.SwapSurface(surface,new_surface)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction CloneMesh:TMesh(mesh:TMesh,parent:TEntity=Null)\n\tReturn mesh.Clone(parent)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction TranslateMesh(mesh:TMesh,x#,y#,z#)\n\tReturn mesh.Translate(x,y,z)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction ScaleMesh(mesh:TMesh,x#,y#,z#)\n\tReturn mesh.Scale(x,y,z)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction RotateMesh(mesh:TMesh,pitch#,yaw#,roll#)\n\tReturn mesh.Rotate(pitch,yaw,roll)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction PositionMesh(mesh:TMesh,x#,y#,z#)\n\tReturn mesh.Position(x,y,z)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction CenterMesh(mesh:TMesh)\n\tReturn mesh.Center()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetMeshSize(mesh:TMesh,width# Var,height# Var,depth# Var)\n\tReturn mesh.GetSize(width,height,depth)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction FitMesh(mesh:TMesh,x#,y#,z#,width#,height#,depth#,uniform=False)\n\tReturn mesh.Fit(x,y,z,width,height,depth,uniform)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction FlipMesh(mesh:TMesh)\n\tReturn mesh.Flip()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction UpdateMeshNormals(mesh:TMesh,smoothing=True)\n\tReturn mesh.UpdateNormals(smoothing)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetMeshAnim(mesh:TMesh,seq:TAnimSeq,mode=ANIMATION_LOOP,speed#=1.0)\n\tReturn mesh.SetAnim(seq,mode,speed)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction AddMeshAnimSeq:TAnimSeq(mesh:TMesh)\n\tReturn mesh.AddAnimSeq(0,0)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction ExtractMeshAnimSeq:TAnimSeq(mesh:TMesh,start_frame,end_frame)\n\tReturn mesh.ExtractAnimSeq(start_frame,end_frame)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetMeshAnimSeq:TAnimSeq(mesh:TMesh)\n\tReturn mesh.GetAnimSeq()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetMeshAnimSeq(mesh:TMesh,seq:TAnimSeq)\n\tReturn mesh.SetAnimSeq(seq)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetMeshAnimMode(mesh:TMesh)\n\tReturn mesh.GetAnimMode()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetMeshAnimMode(mesh:TMesh,mode)\n\tReturn mesh.SetAnimMode(mode)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetMeshAnimSpeed#(mesh:TMesh)\n\tReturn mesh.GetAnimSpeed()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetMeshAnimSpeed(mesh:TMesh,speed#)\n\tReturn mesh.SetAnimSpeed(speed)\nEnd Function\n\n'Animation\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction CreateAnimSeq:TAnimSeq(first,last,name$=\"\")\n\tReturn TAnimSeq.Create(first,last,name)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetAnimSeqName$(seq:TAnimSeq)\n\tReturn seq.GetName()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetAnimSeqName(seq:TAnimSeq,name$)\n\tReturn seq.SetName(name)\nEnd Function\n\n'Pivots\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction CreatePivot:TPivot(parent:TEntity=Null)\n\tReturn CurrentWorld().AddPivot(parent)\nEnd Function\n\n'Flats (plane)\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction CreateFlat:TFlat(parent:TEntity=Null)\n\tReturn CurrentWorld().AddFlat(parent)\nEnd Function\n\n'Sprite\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction CreateSprite:TSprite(parent:TEntity=Null)\n\tReturn CurrentWorld().AddSprite(Null,TEXTURE_DEFAULT,parent)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction LoadSprite:TSprite(url:Object,flags=TEXTURE_DEFAULT,parent:TEntity=Null)\n\tReturn CurrentWorld().AddSprite(url,flags,parent)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetSpriteAngle#(sprite:TSprite)\n\tReturn sprite.GetAngle()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetSpriteAngle(sprite:TSprite,angle#)\n\tReturn sprite.SetAngle(angle)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetSpriteHandle(sprite:TSprite,x# Var,y# Var)\n\tReturn sprite.GetHandle(x,y)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd RemS\nFunction SetSpriteHandle(sprite:TSprite,x#,y#)\n\tReturn sprite.SetHandle(x,y)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetSpriteViewMode(sprite:TSprite)\n\tReturn sprite.GetViewMode()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetSpriteViewMode(sprite:TSprite,mode)\n\tReturn sprite.SetViewMode(mode)\nEnd Function\n\n'Surfaces\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction CountSurfaceVertices(surface:TSurface)\n\tReturn surface.CountVertices()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction CountSurfaceTriangles(surface:TSurface)\n\tReturn surface.CountTriangles()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction UpdateSurfaceNormals(surface:TSurface,smoothing=True)\n\tReturn surface.UpdateNormals(smoothing)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction ResizeSurface(surface:TSurface,vertex_count,triangle_count)\n\tReturn surface.Resize(vertex_count,triangle_count)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction AddSurfaceVertex(surface:TSurface,x#,y#,z#,u#=0.0,v#=0.0)\n\tReturn surface.AddVertex(x,y,z,u,v)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetSurfaceCoords(surface:TSurface,index,x# Var,y# Var,z# Var)\n\tReturn surface.GetCoords(index,x,y,z)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetSurfaceCoords(surface:TSurface,index,x#,y#,z#)\n\tReturn surface.SetCoords(index,x,y,z)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetSurfaceColor(surface:TSurface,index,red Var,green Var,blue Var,alpha# Var)\n\tReturn surface.GetColor(index,red,green,blue,alpha)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetSurfaceColor(surface:TSurface,index,red,green,blue,alpha#)\n\tReturn surface.SetColor(index,red,green,blue,alpha)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetSurfaceNormal(surface:TSurface,index,nx# Var,ny# Var,nz# Var)\n\tReturn surface.GetNormal(index,nx,ny,nz)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetSurfaceNormal(surface:TSurface,index,nx#,ny#,nz#)\n\tReturn surface.SetNormal(index,nx,ny,nz)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetSurfaceTexCoords(surface:TSurface,index,u# Var,v# Var,set=0)\n\tReturn surface.GetTexCoords(index,u,v,set)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetSurfaceTexCoords(surface:TSurface,index,u#,v#,set=0)\n\tReturn surface.SetTexCoords(index,u,v,set)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction AddSurfaceTriangle(surface:TSurface,v0,v1,v2)\n\tReturn surface.AddTriangle(v0,v1,v2)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetSurfaceTriangle(surface:TSurface,index,v0 Var,v1 Var,v2 Var)\n\tReturn surface.GetTriangle(index,v0,v1,v2)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetSurfaceTriangle(surface:TSurface,index,v0,v1,v2)\n\tReturn surface.SetTriangle(index,v0,v1,v2)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetSurfaceBrush:TBrush(surface:TSurface)\n\tReturn surface.GetBrush()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetSurfaceBrush(surface:TSurface,brush:TBrush)\n\tReturn surface.SetBrush(brush)\nEnd Function\n\n'Terrains\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction CreateTerrain:TTerrain(size,parent:TEntity=Null)\n\tReturn CurrentWorld().AddTerrain([size],parent)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction LoadTerrain:TTerrain(url:Object,parent:TEntity=Null)\n\tReturn CurrentWorld().AddTerrain(url,parent)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetTerrainDetail(terrain:TTerrain,lmax,max_tris,clmax=-1)\n\tReturn terrain.SetDetail(lmax,max_tris,clmax)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetTerrainHeight#(terrain:TTerrain,x,z)\n\tReturn terrain.GetHeight(x,z)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetTerrainHeight(terrain:TTerrain,height#,x,z)\n\tReturn terrain.SetHeight(height,x,z)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetTerrainSize(terrain:TTerrain)\n\tReturn terrain.GetSize()\nEnd Function\n\n'Textures\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction CreateTexture:TTexture(width,height,flags=TEXTURE_COLOR|TEXTURE_MIPMAP,frames=1)\n\tLocal texture:TTexture=CurrentWorld().AddTexture([width,height,frames],flags)\n\ttexture.SetPixmap(CreatePixmap(width,height,PF_RGBA8888))\n\tReturn texture\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction LoadTexture:TTexture(url:Object,flags=TEXTURE_COLOR|TEXTURE_MIPMAP)\n\tReturn CurrentWorld().AddTexture(url,flags)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction LockTexture:TPixmap(texture:TTexture)\n\tReturn texture.Lock()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction UnlockTexture(texture:TTexture)\n\tReturn texture.Unlock()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetTextureFlags(texture:TTexture)\n\tReturn texture.GetFlags()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetTextureFlags(texture:TTexture,flags)\n\tReturn texture.SetFlags(flags)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetTextureBlend(texture:TTexture)\n\tReturn texture.GetBlend()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetTextureBlend(texture:TTexture,blend)\n\tReturn texture.SetBlend(blend)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetTextureCoords(texture:TTexture)\n\tReturn texture.GetCoords()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetTextureCoords(texture:TTexture,coords)\n\tReturn texture.SetCoords(coords)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetTextureScale(texture:TTexture,x# Var,y# Var)\n\tReturn texture.GetScale(x,y)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetTextureScale(texture:TTexture,x#,y#)\n\tReturn texture.SetScale(x,y)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetTextureRotation#(texture:TTexture)\n\tReturn texture.GetRotation()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetTextureRotation(texture:TTexture,rotation#)\n\tReturn texture.SetRotation(rotation)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetTexturePosition(texture:TTexture,x# Var,y# Var)\n\tReturn texture.GetPosition(x,y)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetTexturePosition(texture:TTexture,x#,y#)\n\tReturn texture.SetPosition(x,y)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetTextureSize(texture:TTexture,width Var,height Var)\n\tReturn texture.GetSize(width,height)\nEnd Function\n\n'BSP\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction LoadBSPModel:TBSPModel(url:Object,parent:TEntity=Null)\n\tReturn CurrentWorld().AddBSPModel(url,parent)\nEnd Function\n\nSetWorld CreateWorld()\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"97dd761cba3e89805ed4ffab78befd9384919ede","subject":"method.bmx: * Implemented LExposedMethod#PreInitBlock","message":"method.bmx:\n* Implemented LExposedMethod#PreInitBlock","repos":"nilium\/lugi.mod,nilium\/lugi.mod","old_file":"Generator\/method.bmx","new_file":"Generator\/method.bmx","new_contents":"Strict\n\nImport \"metadata.bmx\"\n\nPrivate\n\nConst METH_PREFIX$=\"_lugi_glue\"\t' An _ will always follow this\n\nPublic\n\nType LExposedMethod\n\tField methodid:TMethod\n\tField owner:TTypeId\n\tField name$\n\tField hidden%\n\tField tag$\n\t\n\tMethod New()\n\t\tConst TAGCHARS$=\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_\"\n\t\t\n\t\t' generate a short tag to follow the method name, just to reduce the chance of conflicts\n\t\tLocal tagbuff:Short[7]\n\t\ttagbuff[0] = 95 ' underscore\n\t\tFor Local i:Int = 1 Until tagbuff.Length\n\t\t\ttagbuff[i] = TAGCHARS[Rand(0,62)]\n\t\tNext\n\t\ttag = String.FromShorts(tagbuff, tagbuff.Length)\n\tEnd Method\n\t\n\tMethod InitWithMethod:LExposedMethod(meth:TMethod, owner:TTypeId)\n\t\tmethodid = meth\n\t\tSelf.owner = owner\n\t\t\n\t\t' get metadata\n\t\thidden = methodid.Metadata(LUGI_META_HIDDEN).ToInt()>0\n\t\t\n\t\tname = methodid.Metadata(LUGI_META_RENAME).Trim()\n\t\tIf Not name Then\n\t\t\tname = methodid.Name()\n\t\tEndIf\n\t\t\n\t\tReturn Self\n\tEnd Method\n\t\n\tMethod PreInitBlock:String()\n\t\tIf hidden Then\n\t\t\tReturn Null\n\t\tEndIf\n\t\t\n\t\tReturn \"p_lugi_register_method \" + ImplementationName() + \", \" + name + \", Byte Ptr(TTypeId.ForName(~q\" + owner.Name() + \"~q)._class)\"\n\tEnd Method\n\t\n\tMethod PostInitBlock:String()\n\tEnd Method\n\t\n\tMethod ImplementationName$()\n\t\tReturn METH_PREFIX+\"_\"+owner.Name()+\"_\"+name+tag\n\tEnd Method\n\t\n\tMethod Implementation:String( instanceMethod:Int )\n\t\tIf hidden Then\n\t\t\tReturn Null\n\t\tEndIf\n\t\t\n\t\tLocal head$ = \"Function \"+ImplementationName()+\"(lua_vm:Byte Ptr)~n\"\n\t\tLocal tail$ = \"End Function~n\"\n\t\t\n\t\tIf instanceMethod Then\n\t\t\tReturn head+__instanceImp()+tail\n\t\tElse\n\t\t\tReturn head+__noclassImp()+tail\n\t\tEndIf\n\tEnd Method\n\t\n\t' Implementation for instances\/static types\n\tMethod __instanceImp:String()\n\tEnd Method\n\t\n\t' Implementation for types without classes\n\tMethod __noclassImp:String()\n\t\t\n\tEnd Method\nEnd Type\n","old_contents":"Strict\n\nImport \"metadata.bmx\"\n\nPrivate\n\nConst METH_PREFIX$=\"_lugi_glue\"\t' An _ will always follow this\n\nPublic\n\nType LExposedMethod\n\tField methodid:TMethod\n\tField owner:TTypeId\n\tField name$\n\tField hidden%\n\tField tag$\n\t\n\tMethod New()\n\t\tConst TAGCHARS$=\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_\"\n\t\t\n\t\t' generate a short tag to follow the method name, just to reduce the chance of conflicts\n\t\tLocal tagbuff:Short[7]\n\t\ttagbuff[0] = 95 ' underscore\n\t\tFor Local i:Int = 1 Until tagbuff.Length\n\t\t\ttagbuff[i] = TAGCHARS[Rand(0,62)]\n\t\tNext\n\t\ttag = String.FromShorts(tagbuff, tagbuff.Length)\n\tEnd Method\n\t\n\tMethod InitWithMethod:LExposedMethod(meth:TMethod, owner:TTypeId)\n\t\tmethodid = meth\n\t\tSelf.owner = owner\n\t\t\n\t\t' get metadata\n\t\thidden = methodid.Metadata(LUGI_META_HIDDEN).ToInt()>0\n\t\t\n\t\tname = methodid.Metadata(LUGI_META_RENAME).Trim()\n\t\tIf Not name Then\n\t\t\tname = methodid.Name()\n\t\tEndIf\n\t\t\n\t\tReturn Self\n\tEnd Method\n\t\n\tMethod PreInitBlock:String()\n\tEnd Method\n\t\n\tMethod PostInitBlock:String()\n\tEnd Method\n\t\n\tMethod ImplementationName$()\n\t\tReturn METH_PREFIX+\"_\"+owner.Name()+\"_\"+name+tag\n\tEnd Method\n\t\n\tMethod Implementation:String( instanceMethod:Int )\n\t\tIf hidden Then\n\t\t\tReturn Null\n\t\tEndIf\n\t\t\n\t\tLocal head$ = \"Function \"+ImplementationName()+\"(lua_vm:Byte Ptr)~n\"\n\t\tLocal tail$ = \"End Function~n\"\n\t\t\n\t\tIf instanceMethod Then\n\t\t\tReturn head+__instanceImp()+tail\n\t\tElse\n\t\t\tReturn head+__noclassImp()+tail\n\t\tEndIf\n\tEnd Method\n\t\n\t' Implementation for instances\/static types\n\tMethod __instanceImp:String()\n\tEnd Method\n\t\n\t' Implementation for types without classes\n\tMethod __noclassImp:String()\n\t\t\n\tEnd Method\nEnd Type\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"93415e1a8c823062b60645ba646b24fbef61a138","subject":"writing table slots in place","message":"writing table slots in place\n","repos":"Leushenko\/blue-moon","old_file":"blue.bmx","new_file":"blue.bmx","new_contents":"\n' Blue Moon\n' an implementation of Lua in pure BlitzMax\n\nSuperStrict\n\n'Framework Brl.Blitz\n'Import Brl.LinkedList\n'Import Brl.Map\n'Import Brl.Reflection\n\nImport \"bluecompiler.bmx\"\nImport \"blueallocator.bmx\"\nImport \"bluetable.bmx\"\nRem\nImport \"blueasm.o\"\nExtern\nFunction ADD:Int(s:Stack, b:Bytecode, r:Byte Ptr) = \"ADD2\"\nFunction EQ:Int(s:Stack, b:Bytecode, r:Byte Ptr) = \"EQ2\"\nFunction GETUPV:Int(s:Stack, b:Bytecode, r:Byte Ptr) = \"GETUPV2\"\nFunction JIF:Int(s:Stack, b:Bytecode, r:Byte Ptr) = \"JIF2\"\nFunction LOADBOOL:Int(s:Stack, b:Bytecode, r:Byte Ptr) = \"LOADBOOL2\"\nFunction LOADK:Int(s:Stack, b:Bytecode, r:Byte Ptr) = \"LOADK2\"\nFunction LOADNIL:Int(s:Stack, b:Bytecode, r:Byte Ptr) = \"LOADNIL2\"\nFunction LOADSI:Int(s:Stack, b:Bytecode, r:Byte Ptr) = \"LOADSI2\"\nFunction MOV:Int(s:Stack, b:Bytecode, r:Byte Ptr) = \"MOV2\"\nFunction NEWUPV:Int(s:Stack, b:Bytecode, r:Byte Ptr) = \"NEWUPV2\"\nFunction SETLC:Int(s:Stack, b:Bytecode, r:Byte Ptr) = \"SETLC2\"\nEnd Extern\nEnd Rem\n'Const file:String = \"tests\/checktable.lua\"\n'Const file:String = \"tests\/mandelbrot.lua\"\n'Const file:String = \"tests\/sieve.lua\"\n'Const file:String = \"tests\/attrib.lua\"\nConst file:String = \"test.lua\"\n\nConst outFile:String = \"out.lua.so\"\n\n\nPrint BlueCompiler.ShowBytecode(file)\n\nRem\nBlueJIT.InitOpTbl()\n'BlueJIT.opTbl[BlueJIT.opc.ADD] = ADD\n'BlueJIT.opTbl[BlueJIT.opc.EQ] = EQ\n'BlueJIT.opTbl[BlueJIT.opc.GETUPV] = GETUPV\n'BlueJIT.opTbl[BlueJIT.opc.JIF] = JIF\n'BlueJIT.opTbl[BlueJIT.opc.LOADBOOL] = LOADBOOL\n'BlueJIT.opTbl[BlueJIT.opc.LOADK] = LOADK\n'BlueJIT.opTbl[BlueJIT.opc.LOADNIL] = LOADNIL\n'BlueJIT.opTbl[BlueJIT.opc.LOADSI] = LOADSI\nBlueJIT.opTbl[BlueJIT.opc.MOV] = MOV\n'BlueJIT.opTbl[BlueJIT.opc.NEWUPV] = NEWUPV\n'BlueJIT.opTbl[BlueJIT.opc.SETLC] = SETLC\nEnd Rem\n\nLocal code:BlueBinary = BlueCompiler.CompileFileForLoad(file)\nLocal vm:BlueVM = New BlueVM\nLocal tl:BlueLuaVal = vm.LoadObjectCode(code)\n'tl.Call()\n\nLocal stk:Stack = BlueJIT.BPtoS(vm.mem.stack)\nstk.retIP = Null ; stk.prevBase = Null\nLocal vc:Int = 10, upvars:Int = 1\nstk.varp = Long Ptr(Byte Ptr(stk) + BlueJIT.STACKFRAME_INC) + upvars\nstk.func = vm.funIndex[0]\n'stk.IP = 0\nstk.argv = Null\t'may want to add space?\nstk.retv = Null\nstk.argc = 0\nstk.retc = 0\n\nPrint \"running...\"\nLocal t:Int = MilliSecs()\nLocal test:Int(_:Byte Ptr) = stk.func.mcode - BlueJIT.PROLOGUESZ ; test(stk)\nt = MilliSecs() - t\nPrint t\nPrint \"run complete\"\n\n\nPrint \"done.\"\nEnd\n\n' notes:\n' - string constants and bytecode are loaded directly into oldSpc, since they'll be needed often\n' - the structure of a bytecode object is:\n' [ machine code ptr ][ id-offset ][ #k ][ #param ][ #upvar ][ frame sz ][ #instrs ][ vm ][ instructions... ][ upvar table... ][ k table... ]\n' initial fields are all 32b; instructions are each 64b; upvar table is pairs of 32b values (level, pos); k table is NaN-box values\n\n' - the structure of a closure object (actual Lua value representing a function) is:\n' [ bytecode ptr ][ upvar values... ]\n\nType BlueVM\n\tField mem:BlueVMMemory, _ENV:BlueLuaVal\n\tField idMod:Int, funIndex:Bytecode Ptr, _fiSz:Int\n\t\n\tMethod New()\n\t\tmem = New BlueVMMemory\n\tEnd Method\n\t\n\t' Load the procedures and constants of a compiled binary into the VM, returning the function representing the program toplevel\n\tMethod LoadObjectCode:BlueLuaVal(code:BlueBinary)\n\t\tLocal buf:Int[] = code.buf\n\t\tLocal fcount:Int = buf[0], kcount:Int = buf[1], ktblpos:Int = buf[2], ktbl:Long[kcount]\n\t\tLocal convert:Byte Ptr(o:Object) = Byte Ptr(BlueJIT.Identity)\n\t\t\n\t\tFor Local k:Int = 0 Until kcount\n\t\t\tLocal koff:Int = buf[ktblpos + k], sz:Int = buf[ktblpos + k + 1] - koff\n\t\t\tIf sz > 2\t'strings have size > 2\n\t\t\t\tLocal length:Double, lp:Int Ptr = Int Ptr(Varptr(length))\n\t\t\t\tlp[0] = buf[koff] ; lp[1] = buf[koff + 1]\n\t\t\t\tLocal s:Byte Ptr = mem.AllocString(length, Short Ptr(Varptr(buf[koff + 2])))\n\t\t\t\tktbl[k] = mem.PtrToVal(s, BlueTypeTag.STR)\n\t\t\tElse\n\t\t\t\tLocal d:Double, dp:Int Ptr = Int Ptr(Varptr(d))\n\t\t\t\tdp[0] = buf[koff] ; dp[1] = buf[koff + 1]\n\t\t\t\tDouble Ptr(Varptr(ktbl[k]))[0] = d\n\t\t\tEndIf\n\t\tNext\n\t\t\n\t\tExtendFunIndex(idMod + fcount)\n\t\tFor Local f:Int = 0 Until fcount\n\t\t\tLocal foff:Int = buf[3 + f]\n\t\t\tLocal ic:Int = buf[foff + 1], kc:Int = buf[foff + 2], pc:Int = buf[foff + 3], uc:Int = buf[foff + 5], fsz:Int = buf[foff + 6]\n\t\t\t\n\t\t\tLocal b:Bytecode = BPtoBC(mem.AllocObjectOldSpace(mem.oldStrSpace, (8 + 2 * (uc + uc Mod 2) + 2 * kc + 2 * ic) * 4, BlueTypeTag.BCODE))\n\t\t\tb.idMod = idMod ; b.kcount = kc ; b.pcount = pc ; b.upvars = uc + (uc Mod 2)\t'round up for alignment\n\t\t\tb.frameSz = BlueJIT.STACKFRAMESZ + b.upvars * 8 + fsz * 8 ; b.icount = ic ; b.vm = convert(Self)\n\t\t\t\n\t\t\tLocal ib:Int Ptr = Int Ptr(Byte Ptr(b) + 4) + 8 + 2 * ic\n\t\t\tFor Local u:Int = 0 Until uc\n\t\t\t\tLocal uoff:Int = 7 + u * 2\n\t\t\t\tib[u * 2] = buf[foff + uoff] ; ib[u * 2 + 1] = buf[foff + uoff + 1]\n\t\t\tNext\n\t\t\tIf uc <> b.upvars\t'ensure padding is safe by copying the first one\n\t\t\t\tib[uc * 2] = buf[foff + 7] ; ib[uc * 2 + 1] = buf[foff + 7 + 1]\n\t\t\tEndIf\n\t\t\t\n\t\t\tLocal db:Long Ptr = Long Ptr(ib + 2 * b.upvars)\n\t\t\tFor Local k:Int = 0 Until kc\n\t\t\t\tdb[k] = ktbl[buf[foff + 7 + uc * 2 + k]]\n\t\t\tNext\n\t\t\t\n\t\t\tLocal ioff:Int = 7 + 2 * uc + kc ; ib = Int Ptr(Byte Ptr(b) + BlueJIT.BYTECODE_INC)\n\t\t\t\n\t\t\tFor Local i:Int = 0 Until ic * 2\n\t\t\t\tib[i] = buf[foff + ioff + i]\n\t\t\tNext\n\t\t\t\n\t\t\tb.mcode = BlueJIT.Compile(Self, ib, ic, b) + BlueJIT.PROLOGUESZ\n\t\t\tfunIndex[idMod + f] = b\n\t\tNext\n\t\t\n\t\tidMod :+ fcount\n\t\tReturn New BlueLuaVal\n\tEnd Method\n\t\n\tMethod ExtendFunIndex(sz:Int)\t'hack: BlitzMax has a bug with arrays of extern types! so we need to use C-style arrays for now\n\t\tLocal newFI:Bytecode Ptr = Bytecode Ptr(MemAlloc(sz * 4))\n\t\tIf _fiSz\n\t\t\tFor Local b:Int = 0 Until _fiSz\n\t\t\t\tnewFI[b] = funIndex[b]\n\t\t\tNext\n\t\t\tMemFree(funIndex)\n\t\t\tFor Local b:Int = _fiSz Until sz\n\t\t\t\tnewFI[b] = Null\n\t\t\tNext\n\t\tEndIf\n\t\tfunIndex = newFI ; _fiSz = sz\n\tEnd Method\n\t\n\tMethod CallToLua()\n\tEnd Method\n\t\n\tGlobal BPtoBC:Bytecode(p:Byte Ptr) = Byte Ptr(BlueJIT.PointerToExtType)\nEnd Type\n\nPrivate\nExtern\n\tType Stack\n\t\tField retIP:Byte Ptr, prevBase:Stack, varp:Long Ptr, func:Bytecode, _:Long Ptr, argv:Long Ptr, retv:Long Ptr, argc:Short, retc:Short\n\tEnd Type\n\tType Bytecode\n\t\tField mcode:Byte Ptr, idMod:Int, kcount:Int, pcount:Int, upvars:Int, frameSz:Int, icount:Int, vm:Byte Ptr\n\tEnd Type\nEnd Extern\nPublic\n\nType BlueJIT Final\n\tConst PROLOGUESZ:Int = 25, ISIZE:Int = 5\n\t\n\tGlobal opTbl:Int(s:Stack, b:Bytecode, r:Byte Ptr)[], opc:BlueOpcode\n\tGlobal Prologue:Int[] = [ ..\n\t\t$90, $90, ..\n\t\t$8b, $44, $24, $04, .. 'mov 4(%esp), %eax\n\t\t$89, $44, $24, $f4, .. 'mov %eax, -12(%esp)\n\t\t$c7, $44, $24, $f8, $FF, $FF, $FF, $FF, .. 'movl ########, -8(%esp)\n\t\t$89, $64, $24, $fc, .. 'mov %esp, -4(%esp)\n\t\t$83, $ec, $0c.. 'sub $12, %esp\n\t]\n\t\n\tFunction Compile:Byte Ptr(vm:BlueVM, ins:Byte Ptr, icount:Int, bytecode:Bytecode)\n\t\t?Not x86\n\t\tRuntimeError \"The Blue Moon JIT does not support your platform (x86-32 only at this time)\"\n\t\t?\n\t\tAssert SizeOf(0:Long) = SizeOf(0:Double) And SizeOf(0:Int) = 4 And SizeOf(0:Long) = 8 And SizeOf(Byte Ptr(0)) = 4, ..\n\t\t\t\"assumptions about platform datatype sizes are invalid\"\n\t\t\n\t\tIf opTbl = Null Then InitOpTbl()\n\t\t\n\t\tLocal sz:Int = PROLOGUESZ + icount * ISIZE\n\t\t\n\t\t' allocate executable space\n\t\tLocal blocks:Int[] = vm.mem.AllocCodeBlock(PROLOGUESZ + icount * ISIZE)\n\t\tLocal code:Byte Ptr = Byte Ptr(blocks[0]), rsize:Int = blocks[1] - (blocks[1] Mod ISIZE)\n\t\t\n\t\tFor Local p:Int = 0 Until PROLOGUESZ\t'emplace prologue (used for calling in from native only)\n\t\t\tcode[p] = Prologue[p]\n\t\tNext\n\t\tByte Ptr Ptr(code + 14)[0] = Byte Ptr(bytecode)\t'replace the ########\n\t\tcode :+ PROLOGUESZ ; rsize :- PROLOGUESZ\t'easier to not have to take this into account below\n\t\t\n\t\tLocal codePage:Int Ptr = Int Ptr(Int(code) & ((Int(2^12)-1) Shl 20))\t'return-to-native for the page\n\t\tcodePage[1] = $c30cc483\t'add $12, %esp ; ret - i.e. restore the stack to normal\n\t\t\n\t\t' generate machine code!\n\t\tRepeat\n\t\t\t\n\t\t\tFor Local i:Int = 0 Until rsize \/ ISIZE\t'emplace opcode calls and supporting bytecode data\n\t\t\t\tLocal codep:Byte Ptr = code + i * ISIZE, bytecodep:Byte Ptr = Byte Ptr(Int(codep) + vm.mem.PAGESZ)\n\t\t\t\tcodep[0] = $e8\t'call\n\t\t\t\tLocal bi:Int = i * 8, op:Int = ins[bi], ip:Int Ptr = Int Ptr(ins + bi), func:Byte Ptr = opTbl[op]\n\t\t\t\tByte Ptr Ptr(codep + 1)[0] = func - Int(codep + ISIZE)\n\t\t\t\t\n\t\t\t\tSelect op\n\t\t\t\t\tCase opc.LOADSI, opc.CLOSURE, opc.RET, opc.POSTCALL\n\t\t\t\t\t\tbytecodep[0] = ins[bi + 1] ; Int Ptr(bytecodep + 1)[0] = Int Ptr(ins + bi)[1]\n\t\t\t\t\t\t\n\t\t\t\t\tCase opc.LOADK\n\t\t\t\t\t\tLocal kp:Double Ptr = Double Ptr(ins + 8 * bytecode.icount + 8 * bytecode.upvars) + ip[1]\n\t\t\t\t\t\tbytecodep[0] = ins[bi + 1] ; Double Ptr Ptr(bytecodep + 1)[0] = kp\n\t\t\t\t\t\t\n\t\t\t\t\tCase opc.SETTABSI, opc.GETTABSI\n\t\t\t\t\t\tbytecodep[0] = ins[bi + 1] ; bytecodep[1] = ins[bi + 2]\n\t\t\t\t\t\tShort Ptr(bytecodep)[1] = Int Ptr(ins + bi)[1]\n\t\t\t\t\t\t\n\t\t\t\t\tCase opc.CALL\n\t\t\t\t\t\tbytecodep[0] = ins[bi + 1] ; bytecodep[1] = ins[bi + 2]\n\t\t\t\t\t\tShort Ptr(bytecodep)[1] = Int Ptr(ins + bi)[1]\n\t\t\t\t\t\t\n\t\t\t\t\tCase opc.JIF, opc.JNOT\n\t\t\t\t\t\tbytecodep[0] = ins[bi + 1]\n\t\t\t\t\t\tInt Ptr(bytecodep + 1)[0] = Int(codep) + ISIZE * Int Ptr(ins + bi)[1]\n\t\t\t\t\t\t\n\t\t\t\t\tCase opc.JMP\n\t\t\t\t\t\tcodep[0] = $e9\t'use a true jump\n\t\t\t\t\t\tInt Ptr(codep + 1)[0] = ISIZE * (Int Ptr(ins + bi)[1] - 1)\n\t\t\t\t\t\t\n\t\t\t\t\tDefault\t'binary operations A = B op C\n\t\t\t\t\t\tbytecodep[0] = ins[bi + 1] ; bytecodep[1] = ins[bi + 2] ; bytecodep[2] = Int Ptr(ins + bi)[1]\n\t\t\t\tEnd Select\n\t\t\tNext\n\t\t\t\n\t\t\tExit\t'deal with overflowing code sections here\n\t\tForever\n\t\t\n\t\tReturn code - PROLOGUESZ\n\tEnd Function\n\t\n\t\n\tConst STACKFRAMESZ:Int = 8 * 4, BYTECODESZ:Int = 8 * 4, STACKFRAME_INC:Int = STACKFRAMESZ + 4, BYTECODE_INC:Int = BYTECODESZ + 4\n\tConst IP_OFFSET:Int = BlueVMMemory.PAGESZ - ISIZE\n\t\n\t\n\t'note: extern vars must take into account the vtbl offset, so that converting from a typed pointer can be a simple cast (faster)\t\n\t\n\tFunction MOV(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"MOV \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tvarp[rp[0]] = varp[rp[1]]\t'assigning through Double is unsafe as it can corrupt the bit pattern\n\tEnd Function\n\tFunction GETLC(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction SETLC(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"SETLC \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\t'add a write barrier here\n\t\tLong Ptr Ptr(varp + rp[0])[0][0] = varp[rp[1]]\n\tEnd Function\n\tFunction LOADK(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"LOADK \/\/\"\n\t\tLocal rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET, varp:Long Ptr = stk.varp + rp[0], kp:Long Ptr = Long Ptr Ptr(rp + 1)[0]\n\t\tvarp[0] = kp[0]\n\tEnd Function\n\tFunction LOADSI(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"LOADSI \/\/\"\n\t\tLocal rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal val:Int = Int Ptr(rp + 1)[0]\n\t\tDouble Ptr(stk.varp)[rp[0]] = Double(val)\n\tEnd Function\n\tFunction LOADBOOL(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"LOADBOOL \/\/\"\n\t\tLocal rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET, vp:Int Ptr = Int Ptr(stk.varp + rp[0])\n\t\tvp[1] = BlueTypeTag.NANBOX | BlueTypeTag.BOOL\n\t\tvp[0] = Int Ptr(rp + 1)[0]\n\tEnd Function\n\tFunction LOADNIL(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"LOADNIL \/\/\"\n\t\tLocal rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tInt Ptr(stk.varp + rp[0])[1] = BlueTypeTag.NANBOX | BlueTypeTag.NIL\n\tEnd Function\n\t\n\tFunction GETTAB(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction GETTABSI(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction SETTAB(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction SETTABSI(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t\tPrint \"SETTABSI \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal convert:BlueVM(p:Byte Ptr) = Byte Ptr(Identity), vm:BlueVM = convert(bc.vm)\n\t\tLocal tabp:Byte Ptr = varp + rp[0]\n\t\tPrint \" \" + Short Ptr(rp)[1]\n\t\tLocal key:Long ; Double Ptr(Varptr(key))[0] = Short Ptr(rp)[1]\n\t\tBlueTable.Set(vm.mem, Byte Ptr Ptr(tabp)[0], key, varp[rp[1]])\n\tEnd Function\n\tFunction GETTABI(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t\tPrint \"GETTABI \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal tabp:Byte Ptr = varp + rp[1]\n\t\tPrint \" tag: \" + Bin(Int Ptr(varp + rp[2])[1])\n\t\tLocal val:Long = BlueTable.Get(Byte Ptr Ptr(tabp)[0], varp[rp[2]])\n\t\tLocal v:Double = Double Ptr(Varptr(val))[0]\n\t\tPrint \" \" + v\n\t\tvarp[rp[0]] = val\n\tEnd Function\n\tFunction SETTABI(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t\tPrint \"SETTABI \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal convert:BlueVM(p:Byte Ptr) = Byte Ptr(Identity), vm:BlueVM = convert(bc.vm)\n\t\tLocal tabp:Byte Ptr = varp + rp[0]\n\t\tPrint \" \" + Double Ptr(varp)[rp[2]] + \" \" + Double Ptr(varp)[rp[1]]\n\t\tPrint \" tag: \" + Bin(Int Ptr(varp + rp[2])[1])\n\t\tBlueTable.Set(vm.mem, Byte Ptr Ptr(tabp)[0], varp[rp[2]], varp[rp[1]])\n\tEnd Function\n\tFunction GETUPV(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"GETUPV \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, upvp:Byte Ptr Ptr = Byte Ptr Ptr(Byte Ptr(stk) + STACKFRAME_INC)\n\t\tLocal rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET, valp:Long Ptr = Long Ptr(upvp[rp[1]])\n\t\tvarp[rp[0]] = valp[0]\n\tEnd Function\n\tFunction SETUPV(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction NEWTAB(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t\tPrint \"NEWTAB \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal convert:BlueVM(p:Byte Ptr) = Byte Ptr(Identity), vm:BlueVM = convert(bc.vm)\n\t\tLocal tab:Byte Ptr = vm.mem.AllocTable(Null)\n\t\tLocal d:Int Ptr = Int Ptr(varp + rp[0])\n\t\td[0] = Int(tab) ; d[1] = BlueTypeTag.NANBOX | BlueTypeTag.TBL\n\tEnd Function\n\tFunction CLOSURE(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"CLOSURE \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal convert:BlueVM(p:Byte Ptr) = Byte Ptr(Identity), vm:BlueVM = convert(bc.vm)\n\t\tLocal d:Int Ptr = Int Ptr(varp + rp[0])\n\t\tLocal cbytecode:Bytecode = vm.funIndex[Int Ptr(rp + 1)[0]], upvp:Int Ptr = Int Ptr(Byte Ptr(cbytecode) + BYTECODE_INC + 8 * cbytecode.icount)\n\t\tLocal closure:Byte Ptr = vm.mem.AllocClosure(cbytecode, cbytecode.upvars)\t'upvars is always even (alignment)\n\t\t\n\t\t'get upvalues off the stack\n\t\tFor Local u:Int = 0 Until cbytecode.upvars\n\t\t\tIf upvp[2 * u]\n\t\t\t\tByte Ptr Ptr(closure)[2 + u] = Byte Ptr Ptr(Byte Ptr(stk) + STACKFRAME_INC)[upvp[2 * u + 1]]\n\t\t\tElse\n\t\t\t\tByte Ptr Ptr(closure)[2 + u] = Byte Ptr Ptr(varp + upvp[2 * u + 1])[0]\n\t\t\tEndIf\n\t\tNext\n\t\t\n\t\td[0] = Int(closure) ; d[1] = BlueTypeTag.NANBOX | BlueTypeTag.FUN\n\tEnd Function\n\tFunction NEWUPV(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"NEWUPV \/\/\"\n\t\tLocal rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal convert:BlueVM(p:Byte Ptr) = Byte Ptr(Identity), vm:BlueVM = convert(bc.vm)\n\t\tLocal upv:Byte Ptr = vm.mem.AllocObject(8, BlueTypeTag.UPV), d:Int Ptr = Int Ptr(stk.varp + rp[0])\n\t\tLong Ptr(upv)[0] = Long Ptr(d)[0]\t'promote a value if it existed (useful for parameters)\n\t\td[0] = Int(upv) ; d[1] = BlueTypeTag.NANBOX | BlueTypeTag.UPV\n\tEnd Function\n\t\n\tFunction ADD(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t\tPrint \"ADD \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal d:Double Ptr = Double Ptr(varp + rp[0])\n\t\tLocal r:Int Ptr = Int Ptr(varp + rp[1]), l:Int Ptr = Int Ptr(varp + rp[2])\n\t\tIf l[1] & BlueTypeTag.NANBOX_CHK = BlueTypeTag.NANBOX Or r[1] & BlueTypeTag.NANBOX_CHK = BlueTypeTag.NANBOX\n\t\t\tDebugStop\n\t\tElse\n\t\t\tPrint \" \" + Double Ptr(l)[0] + \" \" + Double Ptr(r)[0]\n\t\t\td[0] = Double Ptr(l)[0] + Double Ptr(r)[0]\n\t\tEndIf\n\tEnd Function\n\tFunction SUB(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction MUL(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction DIV(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction NMOD(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction POW(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction CAT(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction IDIV(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction BAND(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction BOR(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction BXOR(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction BSHL(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction BSHR(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction UNM(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction LNOT(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction ALEN(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction BNOT(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction UNP(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction EQ(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"EQ \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = (Byte Ptr Ptr(retptr) - 4)[0] + IP_OFFSET\n\t\tLocal r:Double = Double Ptr(varp)[rp[1]]\n\t\tLocal l:Double = Double Ptr(varp)[rp[2]]\n\t\tInt Ptr(varp + rp[0])[0] = l = r\n\tEnd Function\n\tFunction LT(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction LEQ(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\t\n\tFunction JMP(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t\tPrint \"wait, why are we here?\"\n\tEnd Function\n\tFunction JIF(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"JIF \/\/\"\n\t\tLocal rp:Byte Ptr = (Byte Ptr Ptr(retptr) - 4)[0] + IP_OFFSET\n\t\tIf Int Ptr(stk.varp + rp[0])[0]\n\t\t\tLocal target:Int = Int Ptr(rp + 1)[0]\n\t\t\tInt Ptr(retptr)[-4] = target\n\t\tEndIf\n\tEnd Function\n\tFunction JNOT(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction CALL(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"CALL \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal fp:Int Ptr = Int Ptr(varp + rp[0])\n\t\tIf Not PrepareCall(fp, stk, rp, varp, retptr)\t'PrepareCall sets everything up so there's nothing else to do to make the call happen\n\t\t\t'__call metamethod\n\t\tEndIf\n\tEnd Function\n\tFunction TCALL(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction RET:Byte Ptr(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"RET \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp\n\t\tLocal rp0:Byte Ptr = Byte Ptr Ptr(retptr)[-4], rp:Byte Ptr = rp0 + IP_OFFSET\n\t\t\n\t\tLocal oldStk:Stack = stk.prevBase\n\t\tLocal retv:Long Ptr = varp + rp[0]\n\t\tIf oldStk\n\t\t\toldStk.retv = retv\n\t\t\toldStk.retc = Int Ptr(rp + 1)[0]\n\t\t\tByte Ptr Ptr(retptr)[-4] = stk.retIP\n\t\t\tByte Ptr Ptr(retptr)[-3] = Byte Ptr(oldStk)\n\t\t\tByte Ptr Ptr(retptr)[-2] = Byte Ptr(oldStk.func) + BYTECODE_INC\n\t\tElse\t'return to native code\n\t\t\tLocal codePage:Byte Ptr = Byte Ptr(Int(rp0) & ((Int(2^12)-1) Shl 20))\n\t\t\tByte Ptr Ptr(retptr)[-4] = codePage + 4\n\t\t\tReturn retv\n\t\tEndIf\n\tEnd Function\n\tFunction RETVA(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction POSTCALL(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"POSTCALL \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp\n\t\tLocal rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\t\n\t\tFor Local r:Int = 0 Until Min(Int Ptr(rp + 1)[0], stk.retc)\n\t\t\t(varp + rp[0])[r] = stk.retv[r]\n\t\t'\tPrint \" return \" + r + \": \" + Double Ptr(stk.retv)[r]\n\t\tNext\n\tEnd Function\n\tFunction VARARG(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction VAINIT(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction CALLINIT(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\t\n\t\n\tFunction PrepareCall:Int(fp:Int Ptr, stk:Stack, rp:Byte Ptr, varp:Long Ptr, retptr:Byte Ptr)\n\t\tIf fp[1] = BlueTypeTag.NANBOX | BlueTypeTag.FUN\n\t\t\tLocal newStk0:Stack ; Byte Ptr Ptr(Varptr(newStk0))[0] = Byte Ptr(stk) + stk.func.frameSz\n\t\t\tLocal newStk:Stack = newStk0\t'micro-opt: newStk0 can't be a register because of the unwieldy conversion\n\t\t\t\n\t\t\tnewStk.retIP = Byte Ptr Ptr(retptr)[-4]\n\t\t\tnewStk.prevBase = stk\n\t\t\tLocal closure:Byte Ptr = Byte Ptr(fp[0])\n\t\t\tLocal newBC:Bytecode = Bytecode Ptr(closure)[0]\n\t\t\tLocal voff:Int = STACKFRAME_INC + 4 * newBC.upvars\n\t\t\tnewStk.varp = Long Ptr(Byte Ptr(newStk) + voff)\n\t\t\tnewStk.func = newBC\n\t\t'\tnewStk._IP = 0\n\t\t\t\n\t\t\tLocal argc_actual:Int = Short Ptr(rp)[1], argc_required:Int = newBC.pcount\n\t\t'\tLocal argc_min:Int ; If argc_actual < argc_required Then argc_min = argc_actual Else argc_min = argc_required\n\t\t\tLocal argc_min:Int = argc_actual - argc_required ; argc_min = (argc_min & (argc_min Shr 31)) + argc_required 'branchless 32-bit Min\n\t\t\t\n\t\t\tLocal argv:Long Ptr = varp + rp[1], destv:Long Ptr = newStk.varp\n\t\t\tFor Local a:Int = 0 Until argc_min\n\t\t\t\tdestv[a] = argv[a]\n\t\t\t'\tPrint \" arg \" + a + \": \" + argv[a]\n\t\t\tNext\n\t\t\tFor Local a:Int = argc_min Until argc_required\t'nil any unfilled parameters\n\t\t\t\tInt Ptr(destv + a)[1] = BlueTypeTag.NANBOX | BlueTypeTag.NIL\n\t\t\tNext\n\t\t\tnewStk.argv = argv + argc_min\t'argv should be to the varargs (if any)\n\t\t\tnewStk.argc = argc_actual - argc_min\t'argc is the number of varargs\n\t\t\t\n\t\t\tLocal destup:Byte Ptr Ptr = Byte Ptr Ptr(Byte Ptr(newStk) + STACKFRAME_INC)\n\t\t\tLocal upv:Byte Ptr Ptr = Byte Ptr Ptr(closure + 8)\n\t\t\tFor Local up:Int = 0 Until newBC.upvars\t'emplace upvars\n\t\t\t\tdestup[up] = upv[up]\n\t\t\t'\tPrint \" upv \" + up + \": \" + destv[up]\n\t\t\t'\tPrint \" val: \" + Double Ptr Ptr(Byte Ptr Ptr(closure) + 2 + up)[0][0]\n\t\t\tNext\n\t\t\t\n\t\t\t'note that the following OVERWRITE THE PARAMETERS (in release mode), so no touching stk from here on\n\t\t\tByte Ptr Ptr(retptr)[-4] = newBC.mcode\n\t\t\tByte Ptr Ptr(retptr)[-3] = Byte Ptr(newStk)\n\t\t\tByte Ptr Ptr(retptr)[-2] = Byte Ptr(newBC) + BYTECODE_INC\n\t\t\t\n\t\tElseIf fp[1] = BlueTypeTag.NANBOX | BlueTypeTag.NATFUN\n\t\t\t'native call\n\t\tElse\n\t\t\tReturn False\t'not a function; take appropriate action\n\t\tEndIf\n\t\tReturn True\t'all good and will auto-call when the caller returns\n\tEnd Function\n\t\n\tFunction InitOpTbl()\n\t\topc = New BlueOpcode\n\t\topTbl = [MOV, GETLC, SETLC, LOADK, LOADSI, LOADBOOL, LOADNIL, ..\n\t\t\tGETTAB, GETTABSI, SETTAB, SETTABSI, GETTABI, SETTABI, GETUPV, SETUPV, ..\n\t\t\tNEWTAB, CLOSURE, NEWUPV, ..\n\t\t\tADD, SUB, MUL, DIV, NMOD, POW, CAT, ..\n\t\t\tIDIV, BAND, BOR, BXOR, BSHL, BSHR, ..\n\t\t\tUNM, LNOT, ALEN, BNOT, UNP, ..\n\t\t\tEQ, LT, LEQ, ..\n\t\t\tJMP, JIF, JNOT, CALL, TCALL, RETVA, RETVA, ..\t'not a mistake: RET doesn't fit but we need the spacer\n\t\t\tPOSTCALL, VARARG, VAINIT, CALLINIT]\n\t\t\n\t\topTbl[opc.RET] = Byte Ptr(RET)\n\tEnd Function\n\t\n\tFunction Identity:Byte Ptr(b:Byte Ptr)\n\t\tReturn b\n\tEnd Function\n\tFunction PointerToExtType:Byte Ptr(p:Byte Ptr)\t'horrible pointer abuse (increment down so we can ignore the nonexistent vtbl)\n\t\tReturn p - 4'sizeof(Byte Ptr)\n\tEnd Function\n\tGlobal BPtoS:Stack(p:Byte Ptr) = Byte Ptr(BlueJIT.PointerToExtType)\nEnd Type\n\nType BlueLuaVal\n\tField _obj:BlueGCNode\n\n\tMethod Call()\n\tEnd Method\nEnd Type\n\n\nRem\nLocal files:TList = CreateList()\nLocal as:String, ld:String, showHelp:Int, output:String = \"a.out\", doAssemble:Int = 1\nLocal keepAsm:Int, makeExe:Int = 1, asOpts:String, ldOpts:String, showAST:Int, showVersion:Int\n\n?MacOS\nas = \"clang -m32 -c \" ; ld = \"clang -Wl,-no_pie -m32 -read_only_relocs suppress \"\n?Not MacOS\nas = \"gcc -m32 -c \" ; ld = \"gcc -m32 \"\n?\n\nFor Local a:Int = 1 Until AppArgs.Length\n\tSelect AppArgs[a]\n\t\tCase \"-?\", \"--help\"\n\t\t\tshowHelp = 1\n\t\tCase \"-v\"\n\t\t\tshowVersion = 1\n\t\tCase \"-o\"\n\t\t\tIf makeExe = 0\n\t\t\t\tPrint \"warning: -c and -o are mutually exclusive; -c is overruling -o\"\n\t\t\tElse\n\t\t\t\ta :+ 1 ; output = AppArgs[a] ; makeExe = 2\n\t\t\tEndIf\n\t\tCase \"-c\"\n\t\t\tIf makeExe = 2\n\t\t\t\tPrint \"warning: -o and -c are mutually exclusive; -o is overruling -c\"\n\t\t\tElse\n\t\t\t\tdoAssemble = 1 ; makeExe = 0\n\t\t\tEndIf\n\t\tCase \"-s\"\n\t\t\tkeepAsm = 1\n\t\tCase \"-S\"\n\t\t\tkeepAsm = 1 ; doAssemble = 0 ; makeExe = 0\n\t\tCase \"--as\"\n\t\t\ta :+ 1 ; as = AppArgs[a] + \" \"\n\t\tCase \"--ld\"\n\t\t\ta :+ 1 ; ld = AppArgs[a] + \" \"\n\t\tCase \"--as-opt\"\n\t\t\ta :+ 1 ; asOpts :+ AppArgs[a] + \" \"\n\t\tCase \"--ld-opt\"\n\t\t\ta :+ 1 ; ldOpts :+ AppArgs[a] + \" \"\n\t\tCase \"--tree\"\n\t\t\tshowAST = 1 ; makeExe = 0\n\t\tCase \"-w\" ; YBCodeGen.SetWarningLevel 0\n\t\tCase \"--werr\" ; YBCodeGen.SetWarningLevel 2\n\t\tCase \"--warn\" ; YBCodeGen.SetWarningLevel 1\n\t\tDefault\n\t\t\tfiles.AddLast AppArgs[a]\n\tEnd Select\nNext\nIf AppArgs.Length = 1 Then Print \"ybc: no input files\" ; End\n\nIf showVersion Then DisplayVersion\nIf showHelp Then DisplayHelp\n\n?Win32\nLocal rm:String = \"del \/Q \"\n?Not Win32\nLocal rm:String = \"rm \"\n?\n\nLocal allOFiles:String = \"\"\nFor Local file:String = EachIn files\n\tTry\n\t\tLocal tree:TParseNode = YBParseFile(file)\n\t\tIf showAST\n\t\t\tPrint tree.ToString()\n\t\tElse\n\t\t\tYBCodeGen.Build tree\n\t\t\tYBAssembler.Emit file + \".s\", YBCodeGen.syms, YBCodeGen.funs, YBCodeGen.vars, YBCodeGen.strs\n\t\t\tIf doAssemble\n\t\t\t\tsystem_(as + asOpts + file + \".s -o \" + file + \".o\")\n\t\t\t\tallOFiles :+ file + \".o \"\n\t\t\tEndIf\n\t\t\tIf Not keepAsm\n\t\t\t\tsystem_ rm + file + \".s\"\n\t\t\tEndIf\n\t\tEndIf\n\tCatch e:Object\n\t\tPrint \"Compile error:~n \" + e.ToString()\n\t\tPrint \"Compilation halted.\"\n\t\t?Debug\n\t\tThrow e\n\t\t?\n\t\tEnd\n\tEnd Try\nNext\n\n?Linux\nLocal bLib:String = \"b-lib-linux\"\n?Not Linux\nLocal bLib:String = \"b-lib\"\n?\nIf makeExe\n\tIf Not FileType(\"b-lib.o\") Then system_ as + bLib + \".s -o b-lib.o\"\n\tsystem_(ld + ldOpts + \"-o \" + output + \" \" + allOFiles + \" b-lib.o\")\n\tsystem_(rm + allOFiles)\nEndIf\n\nPrint \"done.\"\nEnd\nEnd Rem\nRem\nFunction DisplayVersion()\n\tPrint \"Shadow SIMD Compiler: version 0.0\"\nEnd Function\n\nFunction DisplayHelp()\n\tPrint \"OVERVIEW: ybc compiler for B~n\"\n\tPrint \"USAGE: ybc [options] ~n\"\n\tPrint \"OPTIONS:~n\"\n\tPrint \" -?, --help Display this message\"\n\tPrint \" -v Show the compiler version\"\n\tPrint \" -o Set the name of the output executable (default 'a.out')\"\n\tPrint \" -c Produce separate .o files instead of an executable\"\n\tPrint \" -s Keep text assembly .s files\"\n\tPrint \" -S Only produce text assembly, do not assemble binaries\"\n\tPrint \" --as Set the command to use as the assembler\"\n\tPrint \" --ld Set the command to use as the linker\"\n\tPrint \" --as-opt Add an option to pass to the assembler (can repeat)\"\n\tPrint \" --ld-opt Add an option to pass to the linker (can repeat)\"\n\tPrint \" --tree Display the AST of the program source instead of compiling\"\n\tPrint \" -w Silence warnings\"\n\tPrint \" --werr Convert warnings to errors\"\n\tPrint \" --warn Notify but do not halt on warnings (default)\"\nEnd Function\nEnd Rem\n","old_contents":"\n' Blue Moon\n' an implementation of Lua in pure BlitzMax\n\nSuperStrict\n\n'Framework Brl.Blitz\n'Import Brl.LinkedList\n'Import Brl.Map\n'Import Brl.Reflection\n\nImport \"bluecompiler.bmx\"\nImport \"blueallocator.bmx\"\nImport \"bluetable.bmx\"\nRem\nImport \"blueasm.o\"\nExtern\nFunction ADD:Int(s:Stack, b:Bytecode, r:Byte Ptr) = \"ADD2\"\nFunction EQ:Int(s:Stack, b:Bytecode, r:Byte Ptr) = \"EQ2\"\nFunction GETUPV:Int(s:Stack, b:Bytecode, r:Byte Ptr) = \"GETUPV2\"\nFunction JIF:Int(s:Stack, b:Bytecode, r:Byte Ptr) = \"JIF2\"\nFunction LOADBOOL:Int(s:Stack, b:Bytecode, r:Byte Ptr) = \"LOADBOOL2\"\nFunction LOADK:Int(s:Stack, b:Bytecode, r:Byte Ptr) = \"LOADK2\"\nFunction LOADNIL:Int(s:Stack, b:Bytecode, r:Byte Ptr) = \"LOADNIL2\"\nFunction LOADSI:Int(s:Stack, b:Bytecode, r:Byte Ptr) = \"LOADSI2\"\nFunction MOV:Int(s:Stack, b:Bytecode, r:Byte Ptr) = \"MOV2\"\nFunction NEWUPV:Int(s:Stack, b:Bytecode, r:Byte Ptr) = \"NEWUPV2\"\nFunction SETLC:Int(s:Stack, b:Bytecode, r:Byte Ptr) = \"SETLC2\"\nEnd Extern\nEnd Rem\n'Const file:String = \"tests\/checktable.lua\"\n'Const file:String = \"tests\/mandelbrot.lua\"\n'Const file:String = \"tests\/sieve.lua\"\n'Const file:String = \"tests\/attrib.lua\"\nConst file:String = \"test.lua\"\n\nConst outFile:String = \"out.lua.so\"\n\n\nPrint BlueCompiler.ShowBytecode(file)\n\nRem\nBlueJIT.InitOpTbl()\n'BlueJIT.opTbl[BlueJIT.opc.ADD] = ADD\n'BlueJIT.opTbl[BlueJIT.opc.EQ] = EQ\n'BlueJIT.opTbl[BlueJIT.opc.GETUPV] = GETUPV\n'BlueJIT.opTbl[BlueJIT.opc.JIF] = JIF\n'BlueJIT.opTbl[BlueJIT.opc.LOADBOOL] = LOADBOOL\n'BlueJIT.opTbl[BlueJIT.opc.LOADK] = LOADK\n'BlueJIT.opTbl[BlueJIT.opc.LOADNIL] = LOADNIL\n'BlueJIT.opTbl[BlueJIT.opc.LOADSI] = LOADSI\nBlueJIT.opTbl[BlueJIT.opc.MOV] = MOV\n'BlueJIT.opTbl[BlueJIT.opc.NEWUPV] = NEWUPV\n'BlueJIT.opTbl[BlueJIT.opc.SETLC] = SETLC\nEnd Rem\n\nLocal code:BlueBinary = BlueCompiler.CompileFileForLoad(file)\nLocal vm:BlueVM = New BlueVM\nLocal tl:BlueLuaVal = vm.LoadObjectCode(code)\n'tl.Call()\n\nLocal stk:Stack = BlueJIT.BPtoS(vm.mem.stack)\nstk.retIP = Null ; stk.prevBase = Null\nLocal vc:Int = 10, upvars:Int = 1\nstk.varp = Long Ptr(Byte Ptr(stk) + BlueJIT.STACKFRAME_INC) + upvars\nstk.func = vm.funIndex[0]\n'stk.IP = 0\nstk.argv = Null\t'may want to add space?\nstk.retv = Null\nstk.argc = 0\nstk.retc = 0\n\nPrint \"running...\"\nLocal t:Int = MilliSecs()\nLocal test:Int(_:Byte Ptr) = stk.func.mcode - BlueJIT.PROLOGUESZ ; test(stk)\nt = MilliSecs() - t\nPrint t\nPrint \"run complete\"\n\n\nPrint \"done.\"\nEnd\n\n' notes:\n' - string constants and bytecode are loaded directly into oldSpc, since they'll be needed often\n' - the structure of a bytecode object is:\n' [ machine code ptr ][ id-offset ][ #k ][ #param ][ #upvar ][ frame sz ][ #instrs ][ vm ][ instructions... ][ upvar table... ][ k table... ]\n' initial fields are all 32b; instructions are each 64b; upvar table is pairs of 32b values (level, pos); k table is NaN-box values\n\n' - the structure of a closure object (actual Lua value representing a function) is:\n' [ bytecode ptr ][ upvar values... ]\n\nType BlueVM\n\tField mem:BlueVMMemory, _ENV:BlueLuaVal\n\tField idMod:Int, funIndex:Bytecode Ptr, _fiSz:Int\n\t\n\tMethod New()\n\t\tmem = New BlueVMMemory\n\tEnd Method\n\t\n\t' Load the procedures and constants of a compiled binary into the VM, returning the function representing the program toplevel\n\tMethod LoadObjectCode:BlueLuaVal(code:BlueBinary)\n\t\tLocal buf:Int[] = code.buf\n\t\tLocal fcount:Int = buf[0], kcount:Int = buf[1], ktblpos:Int = buf[2], ktbl:Long[kcount]\n\t\tLocal convert:Byte Ptr(o:Object) = Byte Ptr(BlueJIT.Identity)\n\t\t\n\t\tFor Local k:Int = 0 Until kcount\n\t\t\tLocal koff:Int = buf[ktblpos + k], sz:Int = buf[ktblpos + k + 1] - koff\n\t\t\tIf sz > 2\t'strings have size > 2\n\t\t\t\tLocal length:Double, lp:Int Ptr = Int Ptr(Varptr(length))\n\t\t\t\tlp[0] = buf[koff] ; lp[1] = buf[koff + 1]\n\t\t\t\tLocal s:Byte Ptr = mem.AllocString(length, Short Ptr(Varptr(buf[koff + 2])))\n\t\t\t\tktbl[k] = mem.PtrToVal(s, BlueTypeTag.STR)\n\t\t\tElse\n\t\t\t\tLocal d:Double, dp:Int Ptr = Int Ptr(Varptr(d))\n\t\t\t\tdp[0] = buf[koff] ; dp[1] = buf[koff + 1]\n\t\t\t\tDouble Ptr(Varptr(ktbl[k]))[0] = d\n\t\t\tEndIf\n\t\tNext\n\t\t\n\t\tExtendFunIndex(idMod + fcount)\n\t\tFor Local f:Int = 0 Until fcount\n\t\t\tLocal foff:Int = buf[3 + f]\n\t\t\tLocal ic:Int = buf[foff + 1], kc:Int = buf[foff + 2], pc:Int = buf[foff + 3], uc:Int = buf[foff + 5], fsz:Int = buf[foff + 6]\n\t\t\t\n\t\t\tLocal b:Bytecode = BPtoBC(mem.AllocObjectOldSpace(mem.oldStrSpace, (8 + 2 * (uc + uc Mod 2) + 2 * kc + 2 * ic) * 4, BlueTypeTag.BCODE))\n\t\t\tb.idMod = idMod ; b.kcount = kc ; b.pcount = pc ; b.upvars = uc + (uc Mod 2)\t'round up for alignment\n\t\t\tb.frameSz = BlueJIT.STACKFRAMESZ + b.upvars * 8 + fsz * 8 ; b.icount = ic ; b.vm = convert(Self)\n\t\t\t\n\t\t\tLocal ib:Int Ptr = Int Ptr(Byte Ptr(b) + 4) + 8 + 2 * ic\n\t\t\tFor Local u:Int = 0 Until uc\n\t\t\t\tLocal uoff:Int = 7 + u * 2\n\t\t\t\tib[u * 2] = buf[foff + uoff] ; ib[u * 2 + 1] = buf[foff + uoff + 1]\n\t\t\tNext\n\t\t\tIf uc <> b.upvars\t'ensure padding is safe by copying the first one\n\t\t\t\tib[uc * 2] = buf[foff + 7] ; ib[uc * 2 + 1] = buf[foff + 7 + 1]\n\t\t\tEndIf\n\t\t\t\n\t\t\tLocal db:Long Ptr = Long Ptr(ib + 2 * b.upvars)\n\t\t\tFor Local k:Int = 0 Until kc\n\t\t\t\tdb[k] = ktbl[buf[foff + 7 + uc * 2 + k]]\n\t\t\tNext\n\t\t\t\n\t\t\tLocal ioff:Int = 7 + 2 * uc + kc ; ib = Int Ptr(Byte Ptr(b) + BlueJIT.BYTECODE_INC)\n\t\t\t\n\t\t\tFor Local i:Int = 0 Until ic * 2\n\t\t\t\tib[i] = buf[foff + ioff + i]\n\t\t\tNext\n\t\t\t\n\t\t\tb.mcode = BlueJIT.Compile(Self, ib, ic, b) + BlueJIT.PROLOGUESZ\n\t\t\tfunIndex[idMod + f] = b\n\t\tNext\n\t\t\n\t\tidMod :+ fcount\n\t\tReturn New BlueLuaVal\n\tEnd Method\n\t\n\tMethod ExtendFunIndex(sz:Int)\t'hack: BlitzMax has a bug with arrays of extern types! so we need to use C-style arrays for now\n\t\tLocal newFI:Bytecode Ptr = Bytecode Ptr(MemAlloc(sz * 4))\n\t\tIf _fiSz\n\t\t\tFor Local b:Int = 0 Until _fiSz\n\t\t\t\tnewFI[b] = funIndex[b]\n\t\t\tNext\n\t\t\tMemFree(funIndex)\n\t\t\tFor Local b:Int = _fiSz Until sz\n\t\t\t\tnewFI[b] = Null\n\t\t\tNext\n\t\tEndIf\n\t\tfunIndex = newFI ; _fiSz = sz\n\tEnd Method\n\t\n\tMethod CallToLua()\n\tEnd Method\n\t\n\tGlobal BPtoBC:Bytecode(p:Byte Ptr) = Byte Ptr(BlueJIT.PointerToExtType)\nEnd Type\n\nPrivate\nExtern\n\tType Stack\n\t\tField retIP:Byte Ptr, prevBase:Stack, varp:Long Ptr, func:Bytecode, _IP:Int, argv:Long Ptr, retv:Long Ptr, argc:Short, retc:Short\n\tEnd Type\n\tType Bytecode\n\t\tField mcode:Byte Ptr, idMod:Int, kcount:Int, pcount:Int, upvars:Int, frameSz:Int, icount:Int, vm:Byte Ptr\n\tEnd Type\nEnd Extern\nPublic\n\nType BlueJIT Final\n\tConst PROLOGUESZ:Int = 25, ISIZE:Int = 5\n\t\n\tGlobal opTbl:Int(s:Stack, b:Bytecode, r:Byte Ptr)[], opc:BlueOpcode\n\tGlobal Prologue:Int[] = [ ..\n\t\t$90, $90, ..\n\t\t$8b, $44, $24, $04, .. 'mov 4(%esp), %eax\n\t\t$89, $44, $24, $f4, .. 'mov %eax, -12(%esp)\n\t\t$c7, $44, $24, $f8, $FF, $FF, $FF, $FF, .. 'movl ########, -8(%esp)\n\t\t$89, $64, $24, $fc, .. 'mov %esp, -4(%esp)\n\t\t$83, $ec, $0c.. 'sub $12, %esp\n\t]\n\t\n\tFunction Compile:Byte Ptr(vm:BlueVM, ins:Byte Ptr, icount:Int, bytecode:Bytecode)\n\t\t?Not x86\n\t\tRuntimeError \"The Blue Moon JIT does not support your platform (x86-32 only at this time)\"\n\t\t?\n\t\tAssert SizeOf(0:Long) = SizeOf(0:Double) And SizeOf(0:Int) = 4 And SizeOf(0:Long) = 8 And SizeOf(Byte Ptr(0)) = 4, ..\n\t\t\t\"assumptions about platform datatype sizes are invalid\"\n\t\t\n\t\tIf opTbl = Null Then InitOpTbl()\n\t\t\n\t\tLocal sz:Int = PROLOGUESZ + icount * ISIZE\n\t\t\n\t\t' allocate executable space\n\t\tLocal blocks:Int[] = vm.mem.AllocCodeBlock(PROLOGUESZ + icount * ISIZE)\n\t\tLocal code:Byte Ptr = Byte Ptr(blocks[0]), rsize:Int = blocks[1] - (blocks[1] Mod ISIZE)\n\t\t\n\t\tFor Local p:Int = 0 Until PROLOGUESZ\t'emplace prologue (used for calling in from native only)\n\t\t\tcode[p] = Prologue[p]\n\t\tNext\n\t\tByte Ptr Ptr(code + 14)[0] = Byte Ptr(bytecode)\t'replace the ########\n\t\tcode :+ PROLOGUESZ ; rsize :- PROLOGUESZ\t'easier to not have to take this into account below\n\t\t\n\t\tLocal codePage:Int Ptr = Int Ptr(Int(code) & ((Int(2^12)-1) Shl 20))\t'return-to-native for the page\n\t\tcodePage[1] = $c30cc483\t'add $12, %esp ; ret - i.e. restore the stack to normal\n\t\t\n\t\t' generate machine code!\n\t\tRepeat\n\t\t\t\n\t\t\tFor Local i:Int = 0 Until rsize \/ ISIZE\t'emplace opcode calls and supporting bytecode data\n\t\t\t\tLocal codep:Byte Ptr = code + i * ISIZE, bytecodep:Byte Ptr = Byte Ptr(Int(codep) + vm.mem.PAGESZ)\n\t\t\t\tcodep[0] = $e8\t'call\n\t\t\t\tLocal bi:Int = i * 8, op:Int = ins[bi], ip:Int Ptr = Int Ptr(ins + bi), func:Byte Ptr = opTbl[op]\n\t\t\t\tByte Ptr Ptr(codep + 1)[0] = func - Int(codep + ISIZE)\n\t\t\t\t\n\t\t\t\tSelect op\n\t\t\t\t\tCase opc.LOADSI, opc.CLOSURE, opc.RET, opc.POSTCALL\n\t\t\t\t\t\tbytecodep[0] = ins[bi + 1] ; Int Ptr(bytecodep + 1)[0] = Int Ptr(ins + bi)[1]\n\t\t\t\t\t\t\n\t\t\t\t\tCase opc.LOADK\n\t\t\t\t\t\tLocal kp:Double Ptr = Double Ptr(ins + 8 * bytecode.icount + 8 * bytecode.upvars) + ip[1]\n\t\t\t\t\t\tbytecodep[0] = ins[bi + 1] ; Double Ptr Ptr(bytecodep + 1)[0] = kp\n\t\t\t\t\t\t\n\t\t\t\t\tCase opc.SETTABSI, opc.GETTABSI\n\t\t\t\t\t\tbytecodep[0] = ins[bi + 1] ; bytecodep[1] = ins[bi + 2]\n\t\t\t\t\t\tShort Ptr(bytecodep)[1] = Int Ptr(ins + bi)[1]\n\t\t\t\t\t\t\n\t\t\t\t\tCase opc.CALL\n\t\t\t\t\t\tbytecodep[0] = ins[bi + 1] ; bytecodep[1] = ins[bi + 2]\n\t\t\t\t\t\tShort Ptr(bytecodep)[1] = Int Ptr(ins + bi)[1]\n\t\t\t\t\t\t\n\t\t\t\t\tCase opc.JIF, opc.JNOT\n\t\t\t\t\t\tbytecodep[0] = ins[bi + 1]\n\t\t\t\t\t\tInt Ptr(bytecodep + 1)[0] = Int(codep) + ISIZE * Int Ptr(ins + bi)[1]\n\t\t\t\t\t\t\n\t\t\t\t\tCase opc.JMP\n\t\t\t\t\t\tcodep[0] = $e9\t'use a true jump\n\t\t\t\t\t\tInt Ptr(codep + 1)[0] = ISIZE * (Int Ptr(ins + bi)[1] - 1)\n\t\t\t\t\t\t\n\t\t\t\t\tDefault\t'binary operations A = B op C\n\t\t\t\t\t\tbytecodep[0] = ins[bi + 1] ; bytecodep[1] = ins[bi + 2] ; bytecodep[2] = Int Ptr(ins + bi)[1]\n\t\t\t\tEnd Select\n\t\t\tNext\n\t\t\t\n\t\t\tExit\t'deal with overflowing code sections here\n\t\tForever\n\t\t\n\t\tReturn code - PROLOGUESZ\n\tEnd Function\n\t\n\t\n\tConst STACKFRAMESZ:Int = 8 * 4, BYTECODESZ:Int = 8 * 4, STACKFRAME_INC:Int = STACKFRAMESZ + 4, BYTECODE_INC:Int = BYTECODESZ + 4\n\tConst IP_OFFSET:Int = BlueVMMemory.PAGESZ - ISIZE\n\t\n\t\n\t'note: extern vars must take into account the vtbl offset, so that converting from a typed pointer can be a simple cast (faster)\t\n\t\n\tFunction MOV(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"MOV \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tvarp[rp[0]] = varp[rp[1]]\t'assigning through Double is unsafe as it can corrupt the bit pattern\n\tEnd Function\n\tFunction GETLC(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction SETLC(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"SETLC \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\t'add a write barrier here\n\t\tLong Ptr Ptr(varp + rp[0])[0][0] = varp[rp[1]]\n\tEnd Function\n\tFunction LOADK(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"LOADK \/\/\"\n\t\tLocal rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET, varp:Long Ptr = stk.varp + rp[0], kp:Long Ptr = Long Ptr Ptr(rp + 1)[0]\n\t\tvarp[0] = kp[0]\n\tEnd Function\n\tFunction LOADSI(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"LOADSI \/\/\"\n\t\tLocal rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal val:Int = Int Ptr(rp + 1)[0]\n\t\tDouble Ptr(stk.varp)[rp[0]] = Double(val)\n\tEnd Function\n\tFunction LOADBOOL(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"LOADBOOL \/\/\"\n\t\tLocal rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET, vp:Int Ptr = Int Ptr(stk.varp + rp[0])\n\t\tvp[1] = BlueTypeTag.NANBOX | BlueTypeTag.BOOL\n\t\tvp[0] = Int Ptr(rp + 1)[0]\n\tEnd Function\n\tFunction LOADNIL(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"LOADNIL \/\/\"\n\t\tLocal rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tInt Ptr(stk.varp + rp[0])[1] = BlueTypeTag.NANBOX | BlueTypeTag.NIL\n\tEnd Function\n\t\n\tFunction GETTAB(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction GETTABSI(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction SETTAB(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction SETTABSI(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t\tPrint \"SETTABSI \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal convert:BlueVM(p:Byte Ptr) = Byte Ptr(Identity), vm:BlueVM = convert(bc.vm)\n\t\tLocal tabp:Byte Ptr = varp + rp[0]\n\t\tPrint \" \" + Short Ptr(rp)[1]\n\t\tLocal key:Long ; Double Ptr(Varptr(key))[0] = Short Ptr(rp)[1]\n\t\tBlueTable.Set(vm.mem, Byte Ptr Ptr(tabp)[0], key, varp[rp[1]])\n\tEnd Function\n\tFunction GETTABI(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t\tPrint \"GETTABI \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal tabp:Byte Ptr = varp + rp[1]\n\t\tLocal val:Long = BlueTable.Get(Byte Ptr Ptr(tabp)[0], varp[rp[2]])\n\t\tLocal v:Double = Double Ptr(Varptr(val))[0]\n\t\tPrint \" \" + v\n\t\tvarp[rp[0]] = val\n\tEnd Function\n\tFunction SETTABI(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t\tPrint \"SETTABI \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal convert:BlueVM(p:Byte Ptr) = Byte Ptr(Identity), vm:BlueVM = convert(bc.vm)\n\t\tLocal tabp:Byte Ptr = varp + rp[0]\n\t\tPrint \" \" + Double Ptr(varp)[rp[2]] + \" \" + Double Ptr(varp)[rp[1]]\n\t\tBlueTable.Set(vm.mem, Byte Ptr Ptr(tabp)[0], varp[rp[2]], varp[rp[1]])\n\tEnd Function\n\tFunction GETUPV(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"GETUPV \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, upvp:Byte Ptr Ptr = Byte Ptr Ptr(Byte Ptr(stk) + STACKFRAME_INC)\n\t\tLocal rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET, valp:Long Ptr = Long Ptr(upvp[rp[1]])\n\t\tvarp[rp[0]] = valp[0]\n\tEnd Function\n\tFunction SETUPV(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction NEWTAB(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t\tPrint \"NEWTAB \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal convert:BlueVM(p:Byte Ptr) = Byte Ptr(Identity), vm:BlueVM = convert(bc.vm)\n\t\tLocal tab:Byte Ptr = vm.mem.AllocTable(Null)\n\t\tLocal d:Int Ptr = Int Ptr(varp + rp[0])\n\t\td[0] = Int(tab) ; d[1] = BlueTypeTag.NANBOX | BlueTypeTag.TBL\n\tEnd Function\n\tFunction CLOSURE(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"CLOSURE \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal convert:BlueVM(p:Byte Ptr) = Byte Ptr(Identity), vm:BlueVM = convert(bc.vm)\n\t\tLocal d:Int Ptr = Int Ptr(varp + rp[0])\n\t\tLocal cbytecode:Bytecode = vm.funIndex[Int Ptr(rp + 1)[0]], upvp:Int Ptr = Int Ptr(Byte Ptr(cbytecode) + BYTECODE_INC + 8 * cbytecode.icount)\n\t\tLocal closure:Byte Ptr = vm.mem.AllocClosure(cbytecode, cbytecode.upvars)\t'upvars is always even (alignment)\n\t\t\n\t\t'get upvalues off the stack\n\t\tFor Local u:Int = 0 Until cbytecode.upvars\n\t\t\tIf upvp[2 * u]\n\t\t\t\tByte Ptr Ptr(closure)[2 + u] = Byte Ptr Ptr(Byte Ptr(stk) + STACKFRAME_INC)[upvp[2 * u + 1]]\n\t\t\tElse\n\t\t\t\tByte Ptr Ptr(closure)[2 + u] = Byte Ptr Ptr(varp + upvp[2 * u + 1])[0]\n\t\t\tEndIf\n\t\tNext\n\t\t\n\t\td[0] = Int(closure) ; d[1] = BlueTypeTag.NANBOX | BlueTypeTag.FUN\n\tEnd Function\n\tFunction NEWUPV(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"NEWUPV \/\/\"\n\t\tLocal rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal convert:BlueVM(p:Byte Ptr) = Byte Ptr(Identity), vm:BlueVM = convert(bc.vm)\n\t\tLocal upv:Byte Ptr = vm.mem.AllocObject(8, BlueTypeTag.UPV), d:Int Ptr = Int Ptr(stk.varp + rp[0])\n\t\tLong Ptr(upv)[0] = Long Ptr(d)[0]\t'promote a value if it existed (useful for parameters)\n\t\td[0] = Int(upv) ; d[1] = BlueTypeTag.NANBOX | BlueTypeTag.UPV\n\tEnd Function\n\t\n\tFunction ADD(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t\tPrint \"ADD \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal d:Double Ptr = Double Ptr(varp + rp[0])\n\t\tLocal r:Int Ptr = Int Ptr(varp + rp[1]), l:Int Ptr = Int Ptr(varp + rp[2])\n\t\tIf l[1] & BlueTypeTag.NANBOX_CHK = BlueTypeTag.NANBOX Or r[1] & BlueTypeTag.NANBOX_CHK = BlueTypeTag.NANBOX\n\t\t\tDebugStop\n\t\tElse\n\t\t\tPrint \" \" + Double Ptr(l)[0] + \" \" + Double Ptr(r)[0]\n\t\t\td[0] = Double Ptr(l)[0] + Double Ptr(r)[0]\n\t\tEndIf\n\tEnd Function\n\tFunction SUB(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction MUL(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction DIV(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction NMOD(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction POW(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction CAT(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction IDIV(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction BAND(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction BOR(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction BXOR(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction BSHL(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction BSHR(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction UNM(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction LNOT(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction ALEN(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction BNOT(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction UNP(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction EQ(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"EQ \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = (Byte Ptr Ptr(retptr) - 4)[0] + IP_OFFSET\n\t\tLocal r:Double = Double Ptr(varp)[rp[1]]\n\t\tLocal l:Double = Double Ptr(varp)[rp[2]]\n\t\tInt Ptr(varp + rp[0])[0] = l = r\n\tEnd Function\n\tFunction LT(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction LEQ(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\t\n\tFunction JMP(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t\tPrint \"wait, why are we here?\"\n\tEnd Function\n\tFunction JIF(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"JIF \/\/\"\n\t\tLocal rp:Byte Ptr = (Byte Ptr Ptr(retptr) - 4)[0] + IP_OFFSET\n\t\tIf Int Ptr(stk.varp + rp[0])[0]\n\t\t\tLocal target:Int = Int Ptr(rp + 1)[0]\n\t\t\tInt Ptr(retptr)[-4] = target\n\t\tEndIf\n\tEnd Function\n\tFunction JNOT(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction CALL(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"CALL \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal fp:Int Ptr = Int Ptr(varp + rp[0])\n\t\tIf Not PrepareCall(fp, stk, rp, varp, retptr)\t'PrepareCall sets everything up so there's nothing else to do to make the call happen\n\t\t\t'__call metamethod\n\t\tEndIf\n\tEnd Function\n\tFunction TCALL(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction RET:Byte Ptr(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"RET \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp\n\t\tLocal rp0:Byte Ptr = Byte Ptr Ptr(retptr)[-4], rp:Byte Ptr = rp0 + IP_OFFSET\n\t\t\n\t\tLocal oldStk:Stack = stk.prevBase\n\t\tLocal retv:Long Ptr = varp + rp[0]\n\t\tIf oldStk\n\t\t\toldStk.retv = retv\n\t\t\toldStk.retc = Int Ptr(rp + 1)[0]\n\t\t\tByte Ptr Ptr(retptr)[-4] = stk.retIP\n\t\t\tByte Ptr Ptr(retptr)[-3] = Byte Ptr(oldStk)\n\t\t\tByte Ptr Ptr(retptr)[-2] = Byte Ptr(oldStk.func) + BYTECODE_INC\n\t\tElse\t'return to native code\n\t\t\tLocal codePage:Byte Ptr = Byte Ptr(Int(rp0) & ((Int(2^12)-1) Shl 20))\n\t\t\tByte Ptr Ptr(retptr)[-4] = codePage + 4\n\t\t\tReturn retv\n\t\tEndIf\n\tEnd Function\n\tFunction RETVA(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction POSTCALL(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"POSTCALL \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp\n\t\tLocal rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\t\n\t\tFor Local r:Int = 0 Until Min(Int Ptr(rp + 1)[0], stk.retc)\n\t\t\t(varp + rp[0])[r] = stk.retv[r]\n\t\t'\tPrint \" return \" + r + \": \" + Double Ptr(stk.retv)[r]\n\t\tNext\n\tEnd Function\n\tFunction VARARG(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction VAINIT(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction CALLINIT(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\t\n\t\n\tFunction PrepareCall:Int(fp:Int Ptr, stk:Stack, rp:Byte Ptr, varp:Long Ptr, retptr:Byte Ptr)\n\t\tIf fp[1] = BlueTypeTag.NANBOX | BlueTypeTag.FUN\n\t\t\tLocal newStk0:Stack ; Byte Ptr Ptr(Varptr(newStk0))[0] = Byte Ptr(stk) + stk.func.frameSz\n\t\t\tLocal newStk:Stack = newStk0\t'micro-opt: newStk0 can't be a register because of the unwieldy conversion\n\t\t\t\n\t\t\tnewStk.retIP = Byte Ptr Ptr(retptr)[-4]\n\t\t\tnewStk.prevBase = stk\n\t\t\tLocal closure:Byte Ptr = Byte Ptr(fp[0])\n\t\t\tLocal newBC:Bytecode = Bytecode Ptr(closure)[0]\n\t\t\tLocal voff:Int = STACKFRAME_INC + 4 * newBC.upvars\n\t\t\tnewStk.varp = Long Ptr(Byte Ptr(newStk) + voff)\n\t\t\tnewStk.func = newBC\n\t\t'\tnewStk._IP = 0\n\t\t\t\n\t\t\tLocal argc_actual:Int = Short Ptr(rp)[1], argc_required:Int = newBC.pcount\n\t\t'\tLocal argc_min:Int ; If argc_actual < argc_required Then argc_min = argc_actual Else argc_min = argc_required\n\t\t\tLocal argc_min:Int = argc_actual - argc_required ; argc_min = (argc_min & (argc_min Shr 31)) + argc_required 'branchless 32-bit Min\n\t\t\t\n\t\t\tLocal argv:Long Ptr = varp + rp[1], destv:Long Ptr = newStk.varp\n\t\t\tFor Local a:Int = 0 Until argc_min\n\t\t\t\tdestv[a] = argv[a]\n\t\t\t'\tPrint \" arg \" + a + \": \" + argv[a]\n\t\t\tNext\n\t\t\tFor Local a:Int = argc_min Until argc_required\t'nil any unfilled parameters\n\t\t\t\tInt Ptr(destv + a)[1] = BlueTypeTag.NANBOX | BlueTypeTag.NIL\n\t\t\tNext\n\t\t\tnewStk.argv = argv + argc_min\t'argv should be to the varargs (if any)\n\t\t\tnewStk.argc = argc_actual - argc_min\t'argc is the number of varargs\n\t\t\t\n\t\t\tLocal destup:Byte Ptr Ptr = Byte Ptr Ptr(Byte Ptr(newStk) + STACKFRAME_INC)\n\t\t\tLocal upv:Byte Ptr Ptr = Byte Ptr Ptr(closure + 8)\n\t\t\tFor Local up:Int = 0 Until newBC.upvars\t'emplace upvars\n\t\t\t\tdestup[up] = upv[up]\n\t\t\t'\tPrint \" upv \" + up + \": \" + destv[up]\n\t\t\t'\tPrint \" val: \" + Double Ptr Ptr(Byte Ptr Ptr(closure) + 2 + up)[0][0]\n\t\t\tNext\n\t\t\t\n\t\t\t'note that the following OVERWRITE THE PARAMETERS (in release mode), so no touching stk from here on\n\t\t\tByte Ptr Ptr(retptr)[-4] = newBC.mcode\n\t\t\tByte Ptr Ptr(retptr)[-3] = Byte Ptr(newStk)\n\t\t\tByte Ptr Ptr(retptr)[-2] = Byte Ptr(newBC) + BYTECODE_INC\n\t\t\t\n\t\tElseIf fp[1] = BlueTypeTag.NANBOX | BlueTypeTag.NATFUN\n\t\t\t'native call\n\t\tElse\n\t\t\tReturn False\t'not a function; take appropriate action\n\t\tEndIf\n\t\tReturn True\t'all good and will auto-call when the caller returns\n\tEnd Function\n\t\n\tFunction InitOpTbl()\n\t\topc = New BlueOpcode\n\t\topTbl = [MOV, GETLC, SETLC, LOADK, LOADSI, LOADBOOL, LOADNIL, ..\n\t\t\tGETTAB, GETTABSI, SETTAB, SETTABSI, GETTABI, SETTABI, GETUPV, SETUPV, ..\n\t\t\tNEWTAB, CLOSURE, NEWUPV, ..\n\t\t\tADD, SUB, MUL, DIV, NMOD, POW, CAT, ..\n\t\t\tIDIV, BAND, BOR, BXOR, BSHL, BSHR, ..\n\t\t\tUNM, LNOT, ALEN, BNOT, UNP, ..\n\t\t\tEQ, LT, LEQ, ..\n\t\t\tJMP, JIF, JNOT, CALL, TCALL, RETVA, RETVA, ..\t'not a mistake: RET doesn't fit but we need the spacer\n\t\t\tPOSTCALL, VARARG, VAINIT, CALLINIT]\n\t\t\n\t\topTbl[opc.RET] = Byte Ptr(RET)\n\tEnd Function\n\t\n\tFunction Identity:Byte Ptr(b:Byte Ptr)\n\t\tReturn b\n\tEnd Function\n\tFunction PointerToExtType:Byte Ptr(p:Byte Ptr)\t'horrible pointer abuse (increment down so we can ignore the nonexistent vtbl)\n\t\tReturn p - 4'sizeof(Byte Ptr)\n\tEnd Function\n\tGlobal BPtoS:Stack(p:Byte Ptr) = Byte Ptr(BlueJIT.PointerToExtType)\nEnd Type\n\nType BlueLuaVal\n\tField _obj:BlueGCNode\n\n\tMethod Call()\n\tEnd Method\nEnd Type\n\n\nRem\nLocal files:TList = CreateList()\nLocal as:String, ld:String, showHelp:Int, output:String = \"a.out\", doAssemble:Int = 1\nLocal keepAsm:Int, makeExe:Int = 1, asOpts:String, ldOpts:String, showAST:Int, showVersion:Int\n\n?MacOS\nas = \"clang -m32 -c \" ; ld = \"clang -Wl,-no_pie -m32 -read_only_relocs suppress \"\n?Not MacOS\nas = \"gcc -m32 -c \" ; ld = \"gcc -m32 \"\n?\n\nFor Local a:Int = 1 Until AppArgs.Length\n\tSelect AppArgs[a]\n\t\tCase \"-?\", \"--help\"\n\t\t\tshowHelp = 1\n\t\tCase \"-v\"\n\t\t\tshowVersion = 1\n\t\tCase \"-o\"\n\t\t\tIf makeExe = 0\n\t\t\t\tPrint \"warning: -c and -o are mutually exclusive; -c is overruling -o\"\n\t\t\tElse\n\t\t\t\ta :+ 1 ; output = AppArgs[a] ; makeExe = 2\n\t\t\tEndIf\n\t\tCase \"-c\"\n\t\t\tIf makeExe = 2\n\t\t\t\tPrint \"warning: -o and -c are mutually exclusive; -o is overruling -c\"\n\t\t\tElse\n\t\t\t\tdoAssemble = 1 ; makeExe = 0\n\t\t\tEndIf\n\t\tCase \"-s\"\n\t\t\tkeepAsm = 1\n\t\tCase \"-S\"\n\t\t\tkeepAsm = 1 ; doAssemble = 0 ; makeExe = 0\n\t\tCase \"--as\"\n\t\t\ta :+ 1 ; as = AppArgs[a] + \" \"\n\t\tCase \"--ld\"\n\t\t\ta :+ 1 ; ld = AppArgs[a] + \" \"\n\t\tCase \"--as-opt\"\n\t\t\ta :+ 1 ; asOpts :+ AppArgs[a] + \" \"\n\t\tCase \"--ld-opt\"\n\t\t\ta :+ 1 ; ldOpts :+ AppArgs[a] + \" \"\n\t\tCase \"--tree\"\n\t\t\tshowAST = 1 ; makeExe = 0\n\t\tCase \"-w\" ; YBCodeGen.SetWarningLevel 0\n\t\tCase \"--werr\" ; YBCodeGen.SetWarningLevel 2\n\t\tCase \"--warn\" ; YBCodeGen.SetWarningLevel 1\n\t\tDefault\n\t\t\tfiles.AddLast AppArgs[a]\n\tEnd Select\nNext\nIf AppArgs.Length = 1 Then Print \"ybc: no input files\" ; End\n\nIf showVersion Then DisplayVersion\nIf showHelp Then DisplayHelp\n\n?Win32\nLocal rm:String = \"del \/Q \"\n?Not Win32\nLocal rm:String = \"rm \"\n?\n\nLocal allOFiles:String = \"\"\nFor Local file:String = EachIn files\n\tTry\n\t\tLocal tree:TParseNode = YBParseFile(file)\n\t\tIf showAST\n\t\t\tPrint tree.ToString()\n\t\tElse\n\t\t\tYBCodeGen.Build tree\n\t\t\tYBAssembler.Emit file + \".s\", YBCodeGen.syms, YBCodeGen.funs, YBCodeGen.vars, YBCodeGen.strs\n\t\t\tIf doAssemble\n\t\t\t\tsystem_(as + asOpts + file + \".s -o \" + file + \".o\")\n\t\t\t\tallOFiles :+ file + \".o \"\n\t\t\tEndIf\n\t\t\tIf Not keepAsm\n\t\t\t\tsystem_ rm + file + \".s\"\n\t\t\tEndIf\n\t\tEndIf\n\tCatch e:Object\n\t\tPrint \"Compile error:~n \" + e.ToString()\n\t\tPrint \"Compilation halted.\"\n\t\t?Debug\n\t\tThrow e\n\t\t?\n\t\tEnd\n\tEnd Try\nNext\n\n?Linux\nLocal bLib:String = \"b-lib-linux\"\n?Not Linux\nLocal bLib:String = \"b-lib\"\n?\nIf makeExe\n\tIf Not FileType(\"b-lib.o\") Then system_ as + bLib + \".s -o b-lib.o\"\n\tsystem_(ld + ldOpts + \"-o \" + output + \" \" + allOFiles + \" b-lib.o\")\n\tsystem_(rm + allOFiles)\nEndIf\n\nPrint \"done.\"\nEnd\nEnd Rem\nRem\nFunction DisplayVersion()\n\tPrint \"Shadow SIMD Compiler: version 0.0\"\nEnd Function\n\nFunction DisplayHelp()\n\tPrint \"OVERVIEW: ybc compiler for B~n\"\n\tPrint \"USAGE: ybc [options] ~n\"\n\tPrint \"OPTIONS:~n\"\n\tPrint \" -?, --help Display this message\"\n\tPrint \" -v Show the compiler version\"\n\tPrint \" -o Set the name of the output executable (default 'a.out')\"\n\tPrint \" -c Produce separate .o files instead of an executable\"\n\tPrint \" -s Keep text assembly .s files\"\n\tPrint \" -S Only produce text assembly, do not assemble binaries\"\n\tPrint \" --as Set the command to use as the assembler\"\n\tPrint \" --ld Set the command to use as the linker\"\n\tPrint \" --as-opt Add an option to pass to the assembler (can repeat)\"\n\tPrint \" --ld-opt Add an option to pass to the linker (can repeat)\"\n\tPrint \" --tree Display the AST of the program source instead of compiling\"\n\tPrint \" -w Silence warnings\"\n\tPrint \" --werr Convert warnings to errors\"\n\tPrint \" --warn Notify but do not halt on warnings (default)\"\nEnd Function\nEnd Rem\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"48e46a2e149e34f3b021b92f19c1e235ae27afb8","subject":"Modified TCamera.Unproject","message":"Modified TCamera.Unproject\n","repos":"kfprimm\/maxb3d,kfprimm\/maxb3d","old_file":"core.mod\/camera.bmx","new_file":"core.mod\/camera.bmx","new_contents":"\nStrict\n\nImport \"entity.bmx\"\nImport \"worldconfig.bmx\"\n\nConst CAMMODE_NONE\t= 0\nConst CAMMODE_PERSP\t= 1\nConst CAMMODE_ORTHO\t= 2\n\nConst CLSMODE_COLOR\t= 1\nConst CLSMODE_DEPTH\t= 2\n\nConst FOGMODE_NONE\t\t= 0\nConst FOGMODE_LINEAR\t= 1\n\nType TCamera Extends TEntity\n\tField _projmode\n\tField _fogmode,_fogr#,_fogg#,_fogb#,_fognear#,_fogfar#\n\tField _viewx,_viewy,_viewwidth,_viewheight\n\tField _clsmode,_near#,_far#\n\tField _zoom#\n\t\n\tField _modelview:TMatrix=New TMatrix\n\tField _projection:TMatrix=New TMatrix\n\tField _viewport[4]\n\tField _frustum:TFrustum\n\t\n\tMethod Init:TCamera(config:TWorldConfig,parent:TEntity)\n\t\tSuper.Init(config, parent)\n\t\tSetMode CAMMODE_PERSP\n\t\tSetFogMode FOGMODE_NONE\n\t\tSetFogRange 1,1000\n\t\tSetViewport 0,0,_config.Width,_config.Height\n\t\tSetClsMode CLSMODE_COLOR|CLSMODE_DEPTH\n\t\tSetColor 0,0,0\n\t\tSetRange 1,1000\n\t\tSetZoom 1.0\n\t\tReturn Self\n\tEnd Method\n\t\n\tMethod Lists[]()\n\t\tReturn Super.Lists() + [WORLDLIST_CAMERA]\n\tEnd Method\n\n\tMethod CopyData:TEntity(entity:TEntity)\n\t\tLocal camera:TCamera = TCamera(entity)\n\t\tLocal red,green,blue,fognear#,fogfar#,x,y,width,height,near#,far#\n\t\tcamera.GetFogColor red,green,blue\n\t\tcamera.GetFogRange fognear,fogfar\n\t\tcamera.GetViewport x,y,width,height\n\t\tcamera.GetRange near,far\n\t\t\n\t\tSetMode camera.GetMode()\n\t\tSetFogMode camera.GetFogMode()\n\t\tSetFogColor red,green,blue\n\t\tSetFogRange fognear,fogfar\n\t\tSetViewport x,y,width,height\n\t\tSetClsMode camera.GetClsMode()\n\t\tSetRange near,far\n\t\tSetZoom camera.GetZoom()\n\t\tReturn Super.CopyData(entity)\n\tEnd Method\n\t\n\tMethod Copy:TCamera(parent:TEntity=Null)\n\t\tReturn TCamera(Super.Copy_(parent))\n\tEnd Method\n\t\n\tMethod GetMode()\n\t\tReturn _projmode\n\tEnd Method\n\tMethod SetMode(mode)\n\t\t_projmode=mode\n\tEnd Method\t\n\t\n\tMethod GetFogMode()\n\t\tReturn _fogmode\n\tEnd Method\n\tMethod SetFogMode(mode)\n\t\t_fogmode=mode\n\tEnd Method\n\t\n\tMethod GetFogColor(red Var,green Var,blue Var)\n\t\tred=_fogr*255.0;green=_fogg*255.0;blue=_fogb*255.0\n\tEnd Method\n\tMethod SetFogColor(red,green,blue)\n\t\t_fogr=red\/255.0;_fogg=green\/255.0;_fogb=blue\/255.0\n\tEnd Method\n\t\n\tMethod GetFogRange(near# Var,far# Var)\n\t\tnear=_fognear;far=_fogfar\n\tEnd Method\n\tMethod SetFogRange(near#,far#)\n\t\t_fognear=Max(near,0);_fogfar=Max(far,0.001)\n\tEnd Method\n\t\n\tMethod GetViewport(x Var,y Var,width Var,height Var)\n\t\tx=_viewx;y=_viewy;width=_viewwidth;height=_viewheight\n\tEnd Method\n\tMethod SetViewport(x,y,width,height)\n\t\t_viewx=x;_viewy=y;_viewwidth=width;_viewheight=height\n\tEnd Method\n\t\n\tMethod GetClsMode()\n\t\tReturn _clsmode\n\tEnd Method\n\tMethod SetClsMode(mode)\n\t\t_clsmode=mode\n\tEnd Method\n\t\n\tMethod GetRange(near# Var,far# Var)\n\t\tnear=_near;far=_far\n\tEnd Method\n\tMethod SetRange(near#,far#)\n\t\t_near=near;_far=far\n\tEnd Method\t\n\t\n\tMethod GetZoom#()\n\t\tReturn _zoom\n\tEnd Method\n\tMethod SetZoom(zoom#)\n\t\t_zoom=zoom\n\tEnd Method\n\t\n\tMethod GetFOV#()\n\t\tReturn ATan(_zoom \/ 1.0)\n\tEnd Method\n\tMethod SetFOV(angle#)\n\t\t_zoom = 1.0 \/ Tan(angle \/ 2.0)\n\tEnd Method\n\t\n\tMethod GetEye:TRay()\n\t\tLocal x#,y#,z#,dx#,dy#,dz#=1.0,o:TVector,d:TVector\n\t\tGetPosition x,y,z,True\n\t\t_matrix.TransformVec3 dx,dy,dz\n\t\tReturn New TRay.Create(New TVector.Create3(x,y,z),New TVector.Create3(dx-x,dy-y,dz-x))\t\t\n\tEnd Method\n\t\n\tMethod UpdateMatrices()\n\t\t_viewport[0]=_viewx\n\t\t_viewport[1]=_viewy\n\t\t_viewport[2]=_viewwidth\n\t\t_viewport[3]=_viewheight\n\t\t\n\t\t_modelview = _matrix.Inverse()\n\t\t\n\t\tLocal ratio#=(Float(_viewwidth)\/_viewheight)\n\t\t_projection = TMatrix.Scale(1,1,-1).Multiply(TMatrix.PerspectiveFovRH(ATan((1.0\/(_zoom*ratio)))*2.0,ratio,_near,_far))\n\n\t\t_frustum=TFrustum.Extract(_modelview, _projection)\n\tEnd Method\n\t\n\tMethod Project(target:Object,x# Var,y# Var, offset#[] = Null)\n\t\tLocal z#\n\t\tTEntity.GetTargetPosition target,x,y,z\n\t\t\n\t\tIf offset\n\t\t x :+ offset[0]\n\t\t y :+ offset[1]\n\t\t z :+ offset[2]\n\t\tEndIf\n\t\t\n\t\tLocal w#=1.0\n\t _modelview.TransformVec4 x,y,z,w\n\t _projection.TransformVec4 x,y,z,w\n\t If w=0 Return False\n\t x:\/w;y:\/w;z:\/w\n\t \n\t x=x*0.5+0.5;y=-y*0.5+0.5;z=z*0.5+0.5;\n\t\n\t x=x*_viewport[2]+_viewport[0]\n\t y=y*_viewport[3]+_viewport[1]\n\t\tReturn True\n\tEnd Method\n\t\n\tMethod Unproject(wx#,wy#,wz#,x# Var,y# Var,z# Var)\n\t\tLocal matrix:TMatrix=_projection.Multiply(_modelview.Inverse())\n\t\t\n\t\tx=((wx-_viewport[0])\/_viewport[2])*2 - 1.0\n\t\ty=((wy-_viewport[1])\/_viewport[3])*2 - 1.0\n\t\tz=2*wz-1.0\n\t\tLocal w#=1.0\n\t\t\t\t\n\t\tmatrix.TransformVec4 x,y,z,w\n\t\tIf w=0 Return False\n\t\t\n\t\tx:\/w;y:\/w;z:\/w\n\t\tReturn True\n\tEnd Method\n\t\n\tMethod InView#(target:Object)\n\t\tLocal x#,y#,z#,radius#\n\t\tLocal entity:TEntity=TEntity(target),point#[]=Float[](target)\n\t\tIf entity\n\t\t\tentity.GetCullParams x,y,z,radius\n\t\tElseIf point\n\t\t\tx=point[0];y=point[1];z=point[2];radius=point[3]\n\t\tElse\n\t\t\tReturn 0\n\t\tEndIf\n\t\tReturn _frustum.IntersectsPoint(x,y,z,radius)\n\tEnd Method\nEnd Type\n","old_contents":"\nStrict\n\nImport \"entity.bmx\"\nImport \"worldconfig.bmx\"\n\nConst CAMMODE_NONE\t= 0\nConst CAMMODE_PERSP\t= 1\nConst CAMMODE_ORTHO\t= 2\n\nConst CLSMODE_COLOR\t= 1\nConst CLSMODE_DEPTH\t= 2\n\nConst FOGMODE_NONE\t\t= 0\nConst FOGMODE_LINEAR\t= 1\n\nType TCamera Extends TEntity\n\tField _projmode\n\tField _fogmode,_fogr#,_fogg#,_fogb#,_fognear#,_fogfar#\n\tField _viewx,_viewy,_viewwidth,_viewheight\n\tField _clsmode,_near#,_far#\n\tField _zoom#\n\t\n\tField _modelview:TMatrix=New TMatrix\n\tField _projection:TMatrix=New TMatrix\n\tField _viewport[4]\n\tField _frustum:TFrustum\n\t\n\tMethod Init:TCamera(config:TWorldConfig,parent:TEntity)\n\t\tSuper.Init(config, parent)\n\t\tSetMode CAMMODE_PERSP\n\t\tSetFogMode FOGMODE_NONE\n\t\tSetFogRange 1,1000\n\t\tSetViewport 0,0,_config.Width,_config.Height\n\t\tSetClsMode CLSMODE_COLOR|CLSMODE_DEPTH\n\t\tSetColor 0,0,0\n\t\tSetRange 1,1000\n\t\tSetZoom 1.0\n\t\tReturn Self\n\tEnd Method\n\t\n\tMethod Lists[]()\n\t\tReturn Super.Lists() + [WORLDLIST_CAMERA]\n\tEnd Method\n\n\tMethod CopyData:TEntity(entity:TEntity)\n\t\tLocal camera:TCamera = TCamera(entity)\n\t\tLocal red,green,blue,fognear#,fogfar#,x,y,width,height,near#,far#\n\t\tcamera.GetFogColor red,green,blue\n\t\tcamera.GetFogRange fognear,fogfar\n\t\tcamera.GetViewport x,y,width,height\n\t\tcamera.GetRange near,far\n\t\t\n\t\tSetMode camera.GetMode()\n\t\tSetFogMode camera.GetFogMode()\n\t\tSetFogColor red,green,blue\n\t\tSetFogRange fognear,fogfar\n\t\tSetViewport x,y,width,height\n\t\tSetClsMode camera.GetClsMode()\n\t\tSetRange near,far\n\t\tSetZoom camera.GetZoom()\n\t\tReturn Super.CopyData(entity)\n\tEnd Method\n\t\n\tMethod Copy:TCamera(parent:TEntity=Null)\n\t\tReturn TCamera(Super.Copy_(parent))\n\tEnd Method\n\t\n\tMethod GetMode()\n\t\tReturn _projmode\n\tEnd Method\n\tMethod SetMode(mode)\n\t\t_projmode=mode\n\tEnd Method\t\n\t\n\tMethod GetFogMode()\n\t\tReturn _fogmode\n\tEnd Method\n\tMethod SetFogMode(mode)\n\t\t_fogmode=mode\n\tEnd Method\n\t\n\tMethod GetFogColor(red Var,green Var,blue Var)\n\t\tred=_fogr*255.0;green=_fogg*255.0;blue=_fogb*255.0\n\tEnd Method\n\tMethod SetFogColor(red,green,blue)\n\t\t_fogr=red\/255.0;_fogg=green\/255.0;_fogb=blue\/255.0\n\tEnd Method\n\t\n\tMethod GetFogRange(near# Var,far# Var)\n\t\tnear=_fognear;far=_fogfar\n\tEnd Method\n\tMethod SetFogRange(near#,far#)\n\t\t_fognear=Max(near,0);_fogfar=Max(far,0.001)\n\tEnd Method\n\t\n\tMethod GetViewport(x Var,y Var,width Var,height Var)\n\t\tx=_viewx;y=_viewy;width=_viewwidth;height=_viewheight\n\tEnd Method\n\tMethod SetViewport(x,y,width,height)\n\t\t_viewx=x;_viewy=y;_viewwidth=width;_viewheight=height\n\tEnd Method\n\t\n\tMethod GetClsMode()\n\t\tReturn _clsmode\n\tEnd Method\n\tMethod SetClsMode(mode)\n\t\t_clsmode=mode\n\tEnd Method\n\t\n\tMethod GetRange(near# Var,far# Var)\n\t\tnear=_near;far=_far\n\tEnd Method\n\tMethod SetRange(near#,far#)\n\t\t_near=near;_far=far\n\tEnd Method\t\n\t\n\tMethod GetZoom#()\n\t\tReturn _zoom\n\tEnd Method\n\tMethod SetZoom(zoom#)\n\t\t_zoom=zoom\n\tEnd Method\n\t\n\tMethod GetFOV#()\n\t\tReturn ATan(_zoom \/ 1.0)\n\tEnd Method\n\tMethod SetFOV(angle#)\n\t\t_zoom = 1.0 \/ Tan(angle \/ 2.0)\n\tEnd Method\n\t\n\tMethod GetEye:TRay()\n\t\tLocal x#,y#,z#,dx#,dy#,dz#=1.0,o:TVector,d:TVector\n\t\tGetPosition x,y,z,True\n\t\t_matrix.TransformVec3 dx,dy,dz\n\t\tReturn New TRay.Create(New TVector.Create3(x,y,z),New TVector.Create3(dx-x,dy-y,dz-x))\t\t\n\tEnd Method\n\t\n\tMethod UpdateMatrices()\n\t\t_viewport[0]=_viewx\n\t\t_viewport[1]=_viewy\n\t\t_viewport[2]=_viewwidth\n\t\t_viewport[3]=_viewheight\n\t\t\n\t\t_modelview = _matrix.Inverse()\n\t\t\n\t\tLocal ratio#=(Float(_viewwidth)\/_viewheight)\n\t\t_projection = TMatrix.Scale(1,1,-1).Multiply(TMatrix.PerspectiveFovRH(ATan((1.0\/(_zoom*ratio)))*2.0,ratio,_near,_far))\n\n\t\t_frustum=TFrustum.Extract(_modelview, _projection)\n\tEnd Method\n\t\n\tMethod Project(target:Object,x# Var,y# Var, offset#[] = Null)\n\t\tLocal z#\n\t\tTEntity.GetTargetPosition target,x,y,z\n\t\t\n\t\tIf offset\n\t\t x :+ offset[0]\n\t\t y :+ offset[1]\n\t\t z :+ offset[2]\n\t\tEndIf\n\t\t\n\t\tLocal w#=1.0\n\t _modelview.TransformVec4 x,y,z,w\n\t _projection.TransformVec4 x,y,z,w\n\t If w=0 Return False\n\t x:\/w;y:\/w;z:\/w\n\t \n\t x=x*0.5+0.5;y=-y*0.5+0.5;z=z*0.5+0.5;\n\t\n\t x=x*_viewport[2]+_viewport[0]\n\t y=y*_viewport[3]+_viewport[1]\n\t\tReturn True\n\tEnd Method\n\t\n\tMethod Unproject(wx#,wy#,wz#,x# Var,y# Var,z# Var)\n\t\tLocal matrix:TMatrix=_projection.Multiply(_modelview).Inverse()\n\t\t\n\t\tx=(wx-_viewport[0])*2\/_viewport[2] - 1.0\n\t\ty=(wy-_viewport[1])*2\/_viewport[3] - 1.0\n\t\tz=2*wz-1.0\n\t\tLocal w#=1.0\n\t\t\t\t\n\t\tmatrix.TransformVec4 x,y,z,w\n\t\tIf w=0 Return False\n\t\t\n\t\tx:\/w;y:\/w;z:\/w\n\t\tReturn True\n\tEnd Method\n\t\n\tMethod InView#(target:Object)\n\t\tLocal x#,y#,z#,radius#\n\t\tLocal entity:TEntity=TEntity(target),point#[]=Float[](target)\n\t\tIf entity\n\t\t\tentity.GetCullParams x,y,z,radius\n\t\tElseIf point\n\t\t\tx=point[0];y=point[1];z=point[2];radius=point[3]\n\t\tElse\n\t\t\tReturn 0\n\t\tEndIf\n\t\tReturn _frustum.IntersectsPoint(x,y,z,radius)\n\tEnd Method\nEnd Type\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"32dfbcccb4db11fd784b9a3ccf11b8d765ca4d29","subject":"add userdata","message":"add userdata\n","repos":"Leushenko\/blue-moon","old_file":"blueallocator.bmx","new_file":"blueallocator.bmx","new_contents":"\n' Blue Moon\n' Memory allocator\/garbage collector\n' this is a generational three-colour mark\/compact collector\n\n' notes:\n\n' - a basic Lua value is represented as a NaN-box (i.e. a double, unless it's a NaN in which case there's a pointer in the significand)\n\n' - objects are allocated in newSpc, Cheney'd over to cpySpc when it runs out; the Eden spaces are 8MB each\n' - when less than .edenThreshold remains in cpySpc after a scavenge, objects held from oldSpc are promoted\n' - when more than .sizeThreshold has been promoted or less than .edenThreshold still remains, a full GC runs\n' this scan updates usage statistics for each page\n' the \"worst\" N pages are then compacted; if total usage is still poor, mark for another compact after next scavenge\n' the rest of Eden is then promoted\n' - fallback to compacting in one go if usage is catastrophic\/increments aren't keeping up\n' - roots are obtained from the gcroots list, and the stack\n\n' - before compacting\/discarding, the space is scanned for objects with finalizers which are resurrected into newSpc and put on toFinalize\n' - during a FULL collection, weak tables are listed in .weakTables rather than colouring elems, then weakscanned before compaction\n\n' - the stack is an 8M block with the last page protected\n' - stack frames use this format:\n' [ ret ip ][ prev base ][[ 16b frame sz ][ 16b var ofs ]][ func obj ][ ip ][ argv ][ retv ][[ 16b argc ][ 16b retc ]][ upv0 | upv1 | ... ][ v0 | v1 | ... ][ tmp... ]\n' the upvar slots, var slots, and temp slots beyond are all 64-bit NaN-boxes\n' the preceding slots are 32-bit words except otherwise shown\n\n' - pages in oldPtrSpc use this format:\n' [[[ 0..256 metadata ] ..16K dirty bitmap ] ..1M allocated objects ]\n' each 64-byte potential NaN-box in the object-space has a corresponding dirty bit that is set if it points to newSpc\n' a metamap in the metadata in turn marks dirty sectors of the bitmap, for reduced scanning\n' metadata also contains allocation pointer and used space total\n\n' - codeSpace stores executable instruction buffers for Lua functions (bytecode is allocated directly into oldStrSpc)\n' - all instruction buffers are the same size; either the function is continued after a JMP, or the tail is unused\n' this means it can form a freelist without needing compaction (or be compacted easily b\/c single-ownership)\n\n' - bigSpc is a simple list of conventionally-allocated objects that don't fit on a 1M page\n\n' - objects use this layout:\n' [ 64b header: [ 32b size ][ 16b type tag ][ 8b colour ][ 1b hasFinalizer ][ 2b weak keys, values ] ][ N * 64b data area... ]\n' size includes header. for moved objects the second 32b are replaced by a forwarding pointer\n' pointers in general are to the data area, skipping header\n\n' - data types are: nil, boolean, number, string, closure, natfun, userdata, thread, table ; upvar, tablearray, tablehash, bytecode\n' nil\/boolean\/number\/natfun are value types and need no allocation\n' string uses this structure:\n' [H][ 32b length ][ 32b hash ][ ceil(length\/4) * 64b chars ]\n' closure uses this structure:\n' [H][ 32b bytecode ptr ][32b][ N * 32b upvar ptrs ] (N rounded up to 2 for alignment)\n' userdata uses this structure:\n' [H][ 32b metatable ][ 32b value ]\n' thread uses this structure:\n' [H][\n' table uses this structure:\n' [H][ 32b metatable ][32b][ 32b hashpart ptr ][ 32b arraypart ptr ]\n' tablearray uses this structure:\n' [H][\n' tablehash uses this structure:\n' [H][\n' upvar uses this structure:\n' [H][ 64b value ]\n' bytecode uses this structure:\n' [H][\n\n\nSuperStrict\n\nImport \"blueerror.bmx\"\nImport \"bluememory.c\"\n\nPrivate\nExtern\n\tFunction PageAlloc:Byte Ptr(size:Int) = \"bluemoon_mmap\"\n\tFunction PageSetRW:Int(p:Byte Ptr, sz:Int) = \"bluemoon_mprotect_rw\"\n\tFunction PageSetRWX:Int(p:Byte Ptr, sz:Int) = \"bluemoon_mprotect_rwx\"\n\tFunction PageSetProtected:Int(p:Byte Ptr, sz:Int) = \"bluemoon_mprotect_none\"\n\tFunction PageFree:Int(p:Byte Ptr, sz:Int) = \"bluemoon_munmap\"\nEnd Extern\nPublic\n\n\nType BlueTypeTag Final\n\tConst NUM:Int = 0, NIL:Int = 1, BOOL:Int = 1 Shl 1, STR:Int = 1 Shl 2, FUN:Int = 1 Shl 3\n\tConst NATFUN:Int = 1 Shl 4, USR:Int = 1 Shl 5, THR:Int = 1 Shl 6, TBL:Int = 1 Shl 7\n\tConst UPV:Int = 1 Shl 8, ARR:Int = 1 Shl 9, HASH:Int = 1 Shl 10, BCODE:Int = 1 Shl 11\n\t\n\tConst NANBOX:Int = Int(2^11 - 1) Shl 20, NANBOX_CHK:Int = NANBOX | (1 Shl 19)\t'test against upper word (and that it's not a genuine NaN)\nEnd Type\n\nType BlueVMMemory Final\n\tConst PAGESZ:Int = 1048576, PAGEBITMAPSZ:Int = 16384, PAGEMETASZ:Int = 256\n\tConst EDENSIZE:Int = 8 * PAGESZ, STACKSZ:Int = 8 * PAGESZ, FUNCSIZE:Int = 120, BIGOBJECTSZ:Int = 500000\n\t\t\n\tField gcroots:BlueGCNode, stack:Byte Ptr\n\tField newSpace:Byte Ptr, cpySpace:Byte Ptr, oldPtrSpace:Byte Ptr[], oldStrSpace:Byte Ptr[], bigSpace:Byte Ptr[]\n\tField toFinalize:BlueGCNode, weakTables:BlueGCNode\n\tField codeSpace:Byte Ptr[], codeFreeList:Byte Ptr\n\t\n\tField memAlloced:Int\n\tField edenThreshold:Int, sizeThreshold:Int\n\tField newPtr:Int\n\t\n\tFunction AlignedAlloc:Byte Ptr(size:Int, align:Int)\t'abuse mmap\/munmap to get greater-than-4K alignments\n\t\t?Not x86\n\t\tRuntimeError \"The Blue Moon memory system does not support your platform (x86-32 only at this time)\"\n\t\t?\n\t\tLocal mem:Byte Ptr = PageAlloc(size + align)\n\t\tIf Not mem Then Throw BlueInterpretError.Make(\"unable to allocate enough memory for system\")\n\t\t\n\t\t' this is where it starts to get unpleasantly x86-32 specific\n\t\tLocal iMem:Int = Int(mem), offset:Int = iMem Mod align\n\t\tIf offset\n\t\t\tLocal preceding:Int = align - offset\n\t\t\tPageFree(mem, preceding) ; mem :+ preceding\n\t\t\tPageFree(mem + size, offset)\t'so we free the surrounding chunks of mem. that aren't aligned, and keep the middle\n\t\tElse\n\t\t\tPageFree(mem + size, align)\n\t\tEndIf\n\t\t\n\t\tReturn mem\n\tEnd Function\n\t\n\tMethod New()\n\t\tstack = AlignedAlloc(STACKSZ, PAGESZ)\n\t\t' add protection to end of stack\n\t\tnewSpace = AlignedAlloc(EDENSIZE, PAGESZ) ; cpySpace = AlignedAlloc(EDENSIZE, PAGESZ)\n\t\tnewPtr = 0\n\t\t\n\t\tAddCodePage()\n\t\tAddPage(oldStrSpace, PAGEMETASZ)\n\t\tAddPage(oldPtrSpace, PAGEBITMAPSZ)\n\tEnd Method\n\tMethod Delete()\n\t\t' unmap a bunch of stuff\n\tEnd Method\n\t\n\tMethod AllocTable:Byte Ptr(meta:Byte Ptr)\n\t\tLocal ret:Byte Ptr = AllocObject(16, BlueTypeTag.TBL)\n\t\tByte Ptr Ptr(ret)[0] = meta\n\t\tInt Ptr(ret)[2] = 0 ; Int Ptr(ret)[3] = 0\n\t\tReturn ret\n\tEnd Method\n\tMethod AllocClosure:Byte Ptr(bc:Byte Ptr, upvars:Int)\t'already aligned\n\t\tLocal ret:Byte Ptr = AllocObject(8 + upvars * 4, BlueTypeTag.FUN)\n\t\tByte Ptr Ptr(ret)[0] = bc\n\t\tReturn ret\n\tEnd Method\n\tMethod AllocString:Byte Ptr(size:Int, charp:Short Ptr)\n\t\tLocal sz:Int = size\n\t\tIf sz Mod 4 Then sz :+ 4 - sz Mod 4\t'align properly\n\t\tLocal ret:Byte Ptr = AllocObject(8 + sz * 2, BlueTypeTag.STR), destp:Short Ptr = Short Ptr(ret + 8), hash:Int = 5381\n\t\tFor Local c:Int = 0 Until size\t'fill the string and compute hash in one go\n\t\t\tdestp[c] = charp[c]\n\t\t\thash = (hash * 33) ~ charp[c]\t'djb2\n\t\tNext\n\t\tInt Ptr(ret)[0] = size ; Int Ptr(ret)[1] = hash\n\t\tReturn ret\n\tEnd Method\n\tMethod AllocUserdata:Byte Ptr(meta:Byte Ptr, val:Byte Ptr)\n\t\tLocal ret:Byte Ptr = AllocObject(8, BlueTypeTag.USR)\n\t\tByte Ptr Ptr(ret)[0] = meta ; Byte Ptr Ptr(ret)[1] = val\n\t\tReturn ret\n\tEnd Method\n\tMethod AllocThread()\n\tEnd Method\n\t\n\tMethod AddCodePage()\n\t\tcodeSpace = [AlignedAlloc(2 * PAGESZ, PAGESZ)] + codeSpace\n\t\tPageSetRWX(codeSpace[0], PAGESZ)\n\t\tInt Ptr(codeSpace[0])[0] = PAGEMETASZ\n\tEnd Method\n\tMethod AddPage:Byte Ptr(space:Byte Ptr[] Var, init:Int, exec:Int = False)\n\t\tLocal p:Byte Ptr = AlignedAlloc(PAGESZ, PAGESZ)\t'x86: assume this returns zero-initialized result already\n\t\tspace = [p] + space ; Int Ptr(p)[0] = init\n\t\tIf exec Then PageSetRWX(space[0], PAGESZ)\n\t\tReturn p\n\tEnd Method\n\tMethod HeaderSize:Int(space:Byte Ptr[])\n\t\tSelect space\n\t\t\tCase oldPtrSpace ; Return PAGEBITMAPSZ\n\t\t\tDefault ; Return PAGEMETASZ\n\t\tEnd Select\n\tEnd Method\n\t\n\tMethod AllocCodeBlock:Int[](sz:Int)\t'this can return less than the requested size; up to the JIT to request more\n\t\tLocal page:Byte Ptr = codeSpace[0], pNewPtr:Int = Int Ptr(page)[0]\n\t\tIf pNewPtr + sz > PAGESZ\n\t\t\tAddCodePage() ; Int Ptr(page)[0] = PAGESZ\n\t\t\tReturn [Int(page) + pNewPtr, PAGESZ - pNewPtr]\n\t\tElse\n\t\t\tInt Ptr(page)[0] :+ sz\n\t\t\tReturn [Int(page) + pNewPtr, sz]\n\t\tEndIf\n\tEnd Method\n\t\n\tMethod AllocObject:Byte Ptr(sz:Int, tag:Int)\n\t\tsz :+ 8 ; Local ret:Byte Ptr\n\t\tIf sz < BIGOBJECTSZ\n\t\t'\tIf newPtr + sz > EDENSIZE Then Collect()\n\t\t\tret = newSpace + newPtr; newPtr :+ sz\n\t\tElse\n\t\t\tret = MemAlloc(sz)\n\t\t\tIf Not ret Then Throw BlueInterpretError.Make(\"unable to allocate memory for object\")\n\t\t\tbigSpace :+ [ret]\n\t\t\t' track as part of allocated memory?\n\t\tEndIf\n\t\tInt Ptr(ret)[0] = sz\n\t\tReturn ret + 8\n\tEnd Method\n\tMethod AllocObjectOldSpace:Byte Ptr(space:Byte Ptr[] Var, sz:Int, tag:Int)\n\t\tsz :+ 8 ; If sz Mod 8 Then sz :+ (8 - sz Mod 8)\n\t\tLocal ret:Byte Ptr, page:Byte Ptr = space[0]\n\t\tLocal pNewPtr:Int = Int Ptr(page)[0]\n\t\tIf pNewPtr + sz > PAGESZ\n\t\t\tpage = AddPage(space, HeaderSize(space)) ; pNewPtr = Int Ptr(page)[0]\n\t\tEndIf\n\t\tret = page + pNewPtr ; Int Ptr(page)[0] = pNewPtr + sz\n\t\tInt Ptr(ret)[0] = sz\n\t\tReturn ret + 8\n\tEnd Method\n\t\n\tFunction PtrToVal:Double(p:Byte Ptr, tag:Int)\n\t\tLocal ret:Double, rp:Int Ptr = Int Ptr(Varptr(ret))\n\t\trp[0] = Int(p) ; rp[1] = BlueTypeTag.NANBOX | tag\n\t\tReturn ret\n\tEnd Function\n\tFunction ValToPtr:Byte Ptr(v:Double)\n\t\tLocal vp:Byte Ptr Ptr = Byte Ptr Ptr(Varptr(v))\n\t\tReturn vp[0]\n\tEnd Function\nEnd Type\n\nType BlueGCNode\n\tField pv:BlueGCNode, nx:BlueGCNode, val:Byte Ptr\n\tMethod Remove()\n\t\tIf pv Then pv.nx = nx ; pv = Null\n\t\tIf nx Then nx.pv = pv ; nx = Null\n\tEnd Method\nEnd Type\n\nPrivate\n\nPublic\n\n","old_contents":"\n' Blue Moon\n' Memory allocator\/garbage collector\n' this is a generational three-colour mark\/compact collector\n\n' notes:\n\n' - a basic Lua value is represented as a NaN-box (i.e. a double, unless it's a NaN in which case there's a pointer in the significand)\n\n' - objects are allocated in newSpc, Cheney'd over to cpySpc when it runs out; the Eden spaces are 8MB each\n' - when less than .edenThreshold remains in cpySpc after a scavenge, objects held from oldSpc are promoted\n' - when more than .sizeThreshold has been promoted or less than .edenThreshold still remains, a full GC runs\n' this scan updates usage statistics for each page\n' the \"worst\" N pages are then compacted; if total usage is still poor, mark for another compact after next scavenge\n' the rest of Eden is then promoted\n' - fallback to compacting in one go if usage is catastrophic\/increments aren't keeping up\n' - roots are obtained from the gcroots list, and the stack\n\n' - before compacting\/discarding, the space is scanned for objects with finalizers which are resurrected into newSpc and put on toFinalize\n' - during a FULL collection, weak tables are listed in .weakTables rather than colouring elems, then weakscanned before compaction\n\n' - the stack is an 8M block with the last page protected\n' - stack frames use this format:\n' [ ret ip ][ prev base ][[ 16b frame sz ][ 16b var ofs ]][ func obj ][ ip ][ argv ][ retv ][[ 16b argc ][ 16b retc ]][ upv0 | upv1 | ... ][ v0 | v1 | ... ][ tmp... ]\n' the upvar slots, var slots, and temp slots beyond are all 64-bit NaN-boxes\n' the preceding slots are 32-bit words except otherwise shown\n\n' - pages in oldPtrSpc use this format:\n' [[[ 0..256 metadata ] ..16K dirty bitmap ] ..1M allocated objects ]\n' each 64-byte potential NaN-box in the object-space has a corresponding dirty bit that is set if it points to newSpc\n' a metamap in the metadata in turn marks dirty sectors of the bitmap, for reduced scanning\n' metadata also contains allocation pointer and used space total\n\n' - codeSpace stores executable instruction buffers for Lua functions (bytecode is allocated directly into oldStrSpc)\n' - all instruction buffers are the same size; either the function is continued after a JMP, or the tail is unused\n' this means it can form a freelist without needing compaction (or be compacted easily b\/c single-ownership)\n\n' - bigSpc is a simple list of conventionally-allocated objects that don't fit on a 1M page\n\n' - objects use this layout:\n' [ 64b header: [ 32b size ][ 16b type tag ][ 8b colour ][ 1b hasFinalizer ][ 2b weak keys, values ] ][ N * 64b data area... ]\n' size includes header. for moved objects the second 32b are replaced by a forwarding pointer\n' pointers in general are to the data area, skipping header\n\n' - data types are: nil, boolean, number, string, closure, natfun, userdata, thread, table ; upvar, tablearray, tablehash, bytecode\n' nil\/boolean\/number\/natfun are value types and need no allocation\n' string uses this structure:\n' [H][ 32b length ][ 32b hash ][ ceil(length\/4) * 64b chars ]\n' closure uses this structure:\n' [H][ 32b bytecode ptr ][32b][ N * 32b upvar ptrs ] (N rounded up to 2 for alignment)\n' userdata uses this structure:\n' [H][ 32b metatable ][ 32b value ]\n' thread uses this structure:\n' [H][\n' table uses this structure:\n' [H][ 32b metatable ][32b][ 32b hashpart ptr ][ 32b arraypart ptr ]\n' tablearray uses this structure:\n' [H][\n' tablehash uses this structure:\n' [H][\n' upvar uses this structure:\n' [H][ 64b value ]\n' bytecode uses this structure:\n' [H][\n\n\nSuperStrict\n\nImport \"blueerror.bmx\"\nImport \"bluememory.c\"\n\nPrivate\nExtern\n\tFunction PageAlloc:Byte Ptr(size:Int) = \"bluemoon_mmap\"\n\tFunction PageSetRW:Int(p:Byte Ptr, sz:Int) = \"bluemoon_mprotect_rw\"\n\tFunction PageSetRWX:Int(p:Byte Ptr, sz:Int) = \"bluemoon_mprotect_rwx\"\n\tFunction PageSetProtected:Int(p:Byte Ptr, sz:Int) = \"bluemoon_mprotect_none\"\n\tFunction PageFree:Int(p:Byte Ptr, sz:Int) = \"bluemoon_munmap\"\nEnd Extern\nPublic\n\n\nType BlueTypeTag Final\n\tConst NUM:Int = 0, NIL:Int = 1, BOOL:Int = 1 Shl 1, STR:Int = 1 Shl 2, FUN:Int = 1 Shl 3\n\tConst NATFUN:Int = 1 Shl 4, USR:Int = 1 Shl 5, THR:Int = 1 Shl 6, TBL:Int = 1 Shl 7\n\tConst UPV:Int = 1 Shl 8, ARR:Int = 1 Shl 9, HASH:Int = 1 Shl 10, BCODE:Int = 1 Shl 11\n\t\n\tConst NANBOX:Int = Int(2^11 - 1) Shl 20, NANBOX_CHK:Int = NANBOX | (1 Shl 19)\t'test against upper word (and that it's not a genuine NaN)\nEnd Type\n\nType BlueVMMemory Final\n\tConst PAGESZ:Int = 1048576, PAGEBITMAPSZ:Int = 16384, PAGEMETASZ:Int = 256\n\tConst EDENSIZE:Int = 8 * PAGESZ, STACKSZ:Int = 8 * PAGESZ, FUNCSIZE:Int = 120, BIGOBJECTSZ:Int = 500000\n\t\t\n\tField gcroots:BlueGCNode, stack:Byte Ptr\n\tField newSpace:Byte Ptr, cpySpace:Byte Ptr, oldPtrSpace:Byte Ptr[], oldStrSpace:Byte Ptr[], bigSpace:Byte Ptr[]\n\tField toFinalize:BlueGCNode, weakTables:BlueGCNode\n\tField codeSpace:Byte Ptr[], codeFreeList:Byte Ptr\n\t\n\tField memAlloced:Int\n\tField edenThreshold:Int, sizeThreshold:Int\n\tField newPtr:Int\n\t\n\tFunction AlignedAlloc:Byte Ptr(size:Int, align:Int)\t'abuse mmap\/munmap to get greater-than-4K alignments\n\t\t?Not x86\n\t\tRuntimeError \"The Blue Moon memory system does not support your platform (x86-32 only at this time)\"\n\t\t?\n\t\tLocal mem:Byte Ptr = PageAlloc(size + align)\n\t\tIf Not mem Then Throw BlueInterpretError.Make(\"unable to allocate enough memory for system\")\n\t\t\n\t\t' this is where it starts to get unpleasantly x86-32 specific\n\t\tLocal iMem:Int = Int(mem), offset:Int = iMem Mod align\n\t\tIf offset\n\t\t\tLocal preceding:Int = align - offset\n\t\t\tPageFree(mem, preceding) ; mem :+ preceding\n\t\t\tPageFree(mem + size, offset)\t'so we free the surrounding chunks of mem. that aren't aligned, and keep the middle\n\t\tElse\n\t\t\tPageFree(mem + size, align)\n\t\tEndIf\n\t\t\n\t\tReturn mem\n\tEnd Function\n\t\n\tMethod New()\n\t\tstack = AlignedAlloc(STACKSZ, PAGESZ)\n\t\t' add protection to end of stack\n\t\tnewSpace = AlignedAlloc(EDENSIZE, PAGESZ) ; cpySpace = AlignedAlloc(EDENSIZE, PAGESZ)\n\t\tnewPtr = 0\n\t\t\n\t\tAddCodePage()\n\t\tAddPage(oldStrSpace, PAGEMETASZ)\n\t\tAddPage(oldPtrSpace, PAGEBITMAPSZ)\n\tEnd Method\n\tMethod Delete()\n\t\t' unmap a bunch of stuff\n\tEnd Method\n\t\n\tMethod AllocTable:Byte Ptr(meta:Byte Ptr)\n\t\tLocal ret:Byte Ptr = AllocObject(16, BlueTypeTag.TBL)\n\t\tByte Ptr Ptr(ret)[0] = meta\n\t\tInt Ptr(ret)[2] = 0 ; Int Ptr(ret)[3] = 0\n\t\tReturn ret\n\tEnd Method\n\tMethod AllocClosure:Byte Ptr(bc:Byte Ptr, upvars:Int)\t'already aligned\n\t\tLocal ret:Byte Ptr = AllocObject(8 + upvars * 4, BlueTypeTag.FUN)\n\t\tByte Ptr Ptr(ret)[0] = bc\n\t\tReturn ret\n\tEnd Method\n\tMethod AllocString:Byte Ptr(size:Int, charp:Short Ptr)\n\t\tLocal sz:Int = size\n\t\tIf sz Mod 4 Then sz :+ 4 - sz Mod 4\t'align properly\n\t\tLocal ret:Byte Ptr = AllocObject(8 + sz * 2, BlueTypeTag.STR), destp:Short Ptr = Short Ptr(ret + 8), hash:Int = 5381\n\t\tFor Local c:Int = 0 Until size\t'fill the string and compute hash in one go\n\t\t\tdestp[c] = charp[c]\n\t\t\thash = (hash * 33) ~ charp[c]\t'djb2\n\t\tNext\n\t\tInt Ptr(ret)[0] = size ; Int Ptr(ret)[1] = hash\n\t\tReturn ret\n\tEnd Method\n\tMethod AllocUserdata()\n\tEnd Method\n\tMethod AllocThread()\n\tEnd Method\n\t\n\tMethod AddCodePage()\n\t\tcodeSpace = [AlignedAlloc(2 * PAGESZ, PAGESZ)] + codeSpace\n\t\tPageSetRWX(codeSpace[0], PAGESZ)\n\t\tInt Ptr(codeSpace[0])[0] = PAGEMETASZ\n\tEnd Method\n\tMethod AddPage:Byte Ptr(space:Byte Ptr[] Var, init:Int, exec:Int = False)\n\t\tLocal p:Byte Ptr = AlignedAlloc(PAGESZ, PAGESZ)\t'x86: assume this returns zero-initialized result already\n\t\tspace = [p] + space ; Int Ptr(p)[0] = init\n\t\tIf exec Then PageSetRWX(space[0], PAGESZ)\n\t\tReturn p\n\tEnd Method\n\tMethod HeaderSize:Int(space:Byte Ptr[])\n\t\tSelect space\n\t\t\tCase oldPtrSpace ; Return PAGEBITMAPSZ\n\t\t\tDefault ; Return PAGEMETASZ\n\t\tEnd Select\n\tEnd Method\n\t\n\tMethod AllocCodeBlock:Int[](sz:Int)\t'this can return less than the requested size; up to the JIT to request more\n\t\tLocal page:Byte Ptr = codeSpace[0], pNewPtr:Int = Int Ptr(page)[0]\n\t\tIf pNewPtr + sz > PAGESZ\n\t\t\tAddCodePage() ; Int Ptr(page)[0] = PAGESZ\n\t\t\tReturn [Int(page) + pNewPtr, PAGESZ - pNewPtr]\n\t\tElse\n\t\t\tInt Ptr(page)[0] :+ sz\n\t\t\tReturn [Int(page) + pNewPtr, sz]\n\t\tEndIf\n\tEnd Method\n\t\n\tMethod AllocObject:Byte Ptr(sz:Int, tag:Int)\n\t\tsz :+ 8 ; Local ret:Byte Ptr\n\t\tIf sz < BIGOBJECTSZ\n\t\t'\tIf newPtr + sz > EDENSIZE Then Collect()\n\t\t\tret = newSpace + newPtr; newPtr :+ sz\n\t\tElse\n\t\t\tret = MemAlloc(sz)\n\t\t\tIf Not ret Then Throw BlueInterpretError.Make(\"unable to allocate memory for object\")\n\t\t\tbigSpace :+ [ret]\n\t\t\t' track as part of allocated memory?\n\t\tEndIf\n\t\tInt Ptr(ret)[0] = sz\n\t\tReturn ret + 8\n\tEnd Method\n\tMethod AllocObjectOldSpace:Byte Ptr(space:Byte Ptr[] Var, sz:Int, tag:Int)\n\t\tsz :+ 8 ; If sz Mod 8 Then sz :+ (8 - sz Mod 8)\n\t\tLocal ret:Byte Ptr, page:Byte Ptr = space[0]\n\t\tLocal pNewPtr:Int = Int Ptr(page)[0]\n\t\tIf pNewPtr + sz > PAGESZ\n\t\t\tpage = AddPage(space, HeaderSize(space)) ; pNewPtr = Int Ptr(page)[0]\n\t\tEndIf\n\t\tret = page + pNewPtr ; Int Ptr(page)[0] = pNewPtr + sz\n\t\tInt Ptr(ret)[0] = sz\n\t\tReturn ret + 8\n\tEnd Method\n\t\n\tFunction PtrToVal:Double(p:Byte Ptr, tag:Int)\n\t\tLocal ret:Double, rp:Int Ptr = Int Ptr(Varptr(ret))\n\t\trp[0] = Int(p) ; rp[1] = BlueTypeTag.NANBOX | tag\n\t\tReturn ret\n\tEnd Function\n\tFunction ValToPtr:Byte Ptr(v:Double)\n\t\tLocal vp:Byte Ptr Ptr = Byte Ptr Ptr(Varptr(v))\n\t\tReturn vp[0]\n\tEnd Function\nEnd Type\n\nType BlueGCNode\n\tField pv:BlueGCNode, nx:BlueGCNode, val:Byte Ptr\n\tMethod Remove()\n\t\tIf pv Then pv.nx = nx ; pv = Null\n\t\tIf nx Then nx.pv = pv ; nx = Null\n\tEnd Method\nEnd Type\n\nPrivate\n\nPublic\n\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"3b511241f5de2d87a19a140e0e2b278d8a6376f2","subject":"Proper error handling when trying to write the metafile to disk","message":"Proper error handling when trying to write the metafile to disk\n\nrefs gh-1\n","repos":"maximos\/maximus","old_file":"src\/module.bmx","new_file":"src\/module.bmx","new_contents":"\nRem\n\tbbdoc: Maximus module base.\n\tabout: An abstract type for the similarities between module scopes and modules.\nEnd Rem\nType mxModuleBase Abstract\n\t\n\tField m_name:String\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the base's name.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetName(name:String)\n\t\tAssert name, \"(mxModuleBase.SetName) name cannot be Null\"\n\t\tm_name = name\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the base's name.\n\t\treturns: The base's name.\n\tEnd Rem\n\tMethod GetName:String()\n\t\tReturn m_name\n\tEnd Method\n\t\n'#end region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set a common field from the given variable.\n\t\treturns: True if the given variable was handled, or False if it was not.\n\tEnd Rem\n\tMethod SetCommonFromVariable:Int(variable:dVariable)\n\t\tReturn False\n\tEnd Method\n\t\nEnd Type\n\nRem\n\tbbdoc: Maximus module scope.\nEnd Rem\nType mxModuleScope Extends mxModuleBase\n\t\n\tField m_modules:dObjectMap\n\t\n\tMethod New()\n\t\tm_modules = New dObjectMap\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Add the given module to the scope.\n\t\treturns: True if the module was added, or False if it was not (the module is Null).\n\tEnd Rem\n\tMethod AddModule:Int(modul:mxModule)\n\t\tIf modul\n\t\t\tm_modules._Insert(modul.GetName(), modul)\n\t\t\tmodul.SetParent(Self)\n\t\t\tReturn True\n\t\tEnd If\n\t\tReturn False\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Check if the given module name is found in the scope.\n\t\treturns: True if the given module was found in the scope, or False if it was not.\n\tEnd Rem\n\tMethod HasModule:Int(modname:String)\n\t\tReturn m_modules._Contains(modname)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get a module with the given name.\n\t\treturns: The module with the given name, or Null if there is no module with the given name.\n\tEnd Rem\n\tMethod GetModuleWithName:mxModule(modname:String)\n\t\tReturn mxModule(m_modules._ObjectWithKey(modname))\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Load the given dJObject into the scope.\n\t\treturns: Itself, or Null if @root is Null.\n\tEnd Rem\n\tMethod FromJSON:mxModuleScope(root:dJObject)\n\t\tIf root\n\t\t\tSetName(root.GetName())\n\t\t\tFor Local variable:dVariable = EachIn root\n\t\t\t\tIf dJObject(variable)\n\t\t\t\t\tAddModule(New mxModule.FromJSON(dJObject(variable)))\n\t\t\t\t'Else\n\t\t\t\t'\tSetCommonFromVariable(variable)\n\t\t\t\tEnd If\n\t\t\tNext\n\t\t\tReturn Self\n\t\tEnd If\n\t\tReturn Null\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the module enumerator for the scope.\n\t\treturns: The module enumerator for the scope.\n\tEnd Rem\n\tMethod ModuleEnumerator:TMapEnumerator()\n\t\tReturn m_modules.ValueEnumerator()\n\tEnd Method\n\t\nEnd Type\n\nRem\n\tbbdoc: Maximus module.\nEnd Rem\nType mxModule Extends mxModuleBase\n\t\n\tField m_parent:mxModuleScope\n\tField m_description:String\n\tField m_versions:dObjectMap\n\t\n\tMethod New()\n\t\tm_versions = New dObjectMap\n\tEnd Method\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the module's parent.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetParent(parent:mxModuleScope)\n\t\tm_parent = parent\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the module's parent.\n\t\treturns: The module's parent.\n\tEnd Rem\n\tMethod GetParent:mxModuleScope()\n\t\tReturn m_parent\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the full name of the module (e.g. \"modscope.module\").\n\t\treturns: The full name of the module.\n\tEnd Rem\n\tMethod GetFullName:String()\n\t\tReturn m_parent.m_name + \".\" + m_name\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the module's description.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetDescription(description:String)\n\t\tm_description = description\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the module's description.\n\t\treturns: The module's description.\n\tEnd Rem\n\tMethod GetDescription:String()\n\t\tReturn m_description\n\tEnd Method\n\t\n'#end region Field accessors\n\t\n\tRem\n\t\tbbdoc: Get the installed version of the module (if it is installed).\n\t\treturns: The version of the module that is installed, or Null if the module is not installed.\n\tEnd Rem\n\tMethod GetInstalledVersion:mxModuleVersion()\n\t\tLocal version:String = mxModUtils.GetInstalledVersionFromVerID(GetFullName())\n\t\tIf version\n\t\t\tReturn New mxModuleVersion.Create(Self, version, Null)\n\t\tEnd If\n\t\tReturn Null\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Add the given version to the module.\n\t\treturns: True if the version was added, or False if it was not (the version is Null).\n\tEnd Rem\n\tMethod AddVersion:Int(version:mxModuleVersion)\n\t\tIf version\n\t\t\tm_versions._Insert(version.GetName(), version)\n\t\t\tversion.SetParent(Self)\n\t\t\tReturn True\n\t\tEnd If\n\t\tReturn False\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Check if there is a version with the given name.\n\t\treturns: True if the version was found, or False if it was not.\n\tEnd Rem\n\tMethod HasVersion:Int(name:String)\n\t\tReturn m_versions._Contains(name)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get a version with the given name.\n\t\treturns: The version with the given name, or Null if there is no version with the given name.\n\tEnd Rem\n\tMethod GetVersionWithName:mxModuleVersion(name:String)\n\t\tReturn mxModuleVersion(m_versions._ObjectWithKey(name))\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the latest (non-dev if available) version for this module.\n\t\treturns: The latest version for this module.\n\t\tabout: The latest version will be returned, or the dev version if it is the only version.\n\tEnd Rem\n\tMethod GetLatestVersion:mxModuleVersion()\n\t\tLocal hver:mxModuleVersion\n\t\tFor Local ver:mxModuleVersion = EachIn VersionEnumerator()\n\t\t\tIf ver.GetName() <> \"dev\"\n\t\t\t\tIf Not hver Or ver.Compare(hver) = 1\n\t\t\t\t\thver = ver\n\t\t\t\tEnd If\n\t\t\tEnd If\n\t\tNext\n\t\tIf Not hver\n\t\t\thver = GetVersionWithName(\"dev\")\n\t\tEnd If\n\t\tReturn hver\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set a common field from the given variable.\n\t\treturns: True if the given variable was handled, or False if it was not.\n\tEnd Rem\n\tMethod SetCommonFromVariable:Int(variable:dVariable)\n\t\tIf Super.SetCommonFromVariable(variable)\n\t\t\tReturn True\n\t\tElse\n\t\t\tSelect variable.GetName().ToLower()\n\t\t\t\tCase \"desc\"\n\t\t\t\t\tSetDescription(dValueVariable(variable).ValueAsString())\n\t\t\t\tCase \"versions\"\n\t\t\t\t\tFor Local jobj:dJObject = EachIn dJObject(variable)\n\t\t\t\t\t\tAddVersion(New mxModuleVersion.FromJSON(jobj))\n\t\t\t\t\tNext\n\t\t\t\tDefault\n\t\t\t\t\tReturn False\n\t\t\tEnd Select\n\t\t\tReturn True\n\t\tEnd If\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Load the given dJObject into the module.\n\t\treturns: Itself, or Null if @root is Null.\n\tEnd Rem\n\tMethod FromJSON:mxModule(root:dJObject)\n\t\tIf root\n\t\t\tSetName(root.GetName())\n\t\t\tFor Local variable:dVariable = EachIn root\n\t\t\t\tSetCommonFromVariable(variable)\n\t\t\tNext\n\t\t\tReturn Self\n\t\tEnd If\n\t\tReturn Null\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the version enumerator for the module.\n\t\treturns: The version enumerator for the module.\n\tEnd Rem\n\tMethod VersionEnumerator:TMapEnumerator()\n\t\tReturn m_versions.ValueEnumerator()\n\tEnd Method\n\t\nEnd Type\n\nRem\n\tbbdoc: Maximus module version.\nEnd Rem\nType mxModuleVersion\n\t\n\tField m_parent:mxModule\n\tField m_name:String, m_url:String\n\tField m_dependencies:mxModuleDependencies\n\t\n\tMethod New()\n\t\tm_dependencies = New mxModuleDependencies\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Create a module version.\n\t\treturns: Itself.\n\tEnd Rem\n\tMethod Create:mxModuleVersion(parent:mxModule, name:String, url:String)\n\t\tSetParent(parent)\n\t\tSetName(name)\n\t\tSetUrl(url)\n\t\tReturn Self\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Clone the version.\n\t\treturns: A clone of the version.\n\t\tabout: If @withdeps is True (default value), the dependencies will be added as well.\n\tEnd Rem\n\tMethod Clone:mxModuleVersion(withdeps:Int = True)\n\t\tLocal v:mxModuleVersion = New mxModuleVersion.Create(m_parent, m_name, m_url)\n\t\tFor Local dep:mxModuleDependency = EachIn DependencyEnumerator()\n\t\t\tv.m_dependencies.AddDependency(dep)\n\t\tNext\n\t\tReturn v\n\tEnd Method\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the version's parent.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetParent(parent:mxModule)\n\t\tm_parent = parent\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the version's parent.\n\t\treturns: The version's parent.\n\tEnd Rem\n\tMethod GetParent:mxModule()\n\t\tReturn m_parent\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the version's name.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetName(name:String)\n\t\tAssert name, \"(mxModuleVersion.SetName) name cannot be Null!\"\n\t\tm_name = name\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the version's name.\n\t\treturns: The version's name.\n\tEnd Rem\n\tMethod GetName:String()\n\t\tReturn m_name\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the version's url.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetUrl(url:String)\n\t\t'Assert url, \"(mxModuleVersion.SetUrl) url cannot be Null!\"\n\t\tm_url = url\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the version's url.\n\t\treturns: The version's url.\n\tEnd Rem\n\tMethod GetUrl:String()\n\t\tReturn m_url\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the temporary fetch path for the version's source archive.\n\t\treturns: The temporary file path for the version's source archive.\n\tEnd Rem\n\tMethod GetTemporaryFilePath:String()\n\t\tReturn \"tmp\/\" + m_parent.GetFullName() + \"-\" + m_name + \".zip\"\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the version's dependencies.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetDependencies(dependencies:mxModuleDependencies)\n\t\tm_dependencies = dependencies\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the version's dependencies.\n\t\treturns: The version's dependencies.\n\tEnd Rem\n\tMethod GetDependencies:mxModuleDependencies()\n\t\tReturn m_dependencies\n\tEnd Method\n\t\n'#end region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set a common field from the given variable.\n\t\treturns: True if the given variable was handled, or False if it was not.\n\tEnd Rem\n\tMethod SetCommonFromVariable:Int(variable:dVariable)\n\t\tSelect variable.GetName().ToLower()\n\t\t\tCase \"url\"\n\t\t\t\tSetUrl(dValueVariable(variable).ValueAsString())\n\t\t\tCase \"deps\"\n\t\t\t\tm_dependencies.FromJSON(dJArray(variable))\n\t\t\tDefault\n\t\t\t\tReturn False\n\t\tEnd Select\n\t\tReturn True\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Load the given dJObject into the version.\n\t\treturns: Itself, or Null if @root is Null.\n\tEnd Rem\n\tMethod FromJSON:mxModuleVersion(root:dJObject)\n\t\tIf root\n\t\t\tSetName(root.GetName())\n\t\t\tFor Local variable:dVariable = EachIn root\n\t\t\t\tSetCommonFromVariable(variable)\n\t\t\tNext\n\t\t\tReturn Self\n\t\tEnd If\n\t\tReturn Null\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the dependency enumerator for the version.\n\t\treturns: The dependency enumerator for the version.\n\tEnd Rem\n\tMethod DependencyEnumerator:TMapEnumerator()\n\t\tReturn m_dependencies.DependencyEnumerator()\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Compare the version with the given version.\n\t\treturns: 0 if the two versions are the same (same in version number alone), 1 if this version is greater than the given, or -1 if the given version is greater than this version.\n\tEnd Rem\n\tMethod Compare:Int(with:Object)\n\t\tLocal ver:mxModuleVersion = mxModuleVersion(with)\n\t\tIf ver\n\t\t\tLocal version1:mxVersionObject = New mxVersionObject.Parse(m_name)\n\t\t\tLocal version2:mxVersionObject = New mxVersionObject.Parse(ver.m_name)\n\t\t\tReturn version1.Compare(version2)\n\t\tEnd If\n\t\tReturn Super.Compare(with)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Fetch the version's source archive.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod FetchSourceArchive()\n\t\tLocal file:String = GetTemporaryFilePath()\n\t\tlogger.LogMessage(\"fetching: \" + GetUrl() + \" -> \" + file + \" \", False)\n\t\tIf FileType(file) = FILETYPE_NONE\n\t\t\tLocal stream:TStream = WriteFileExplicitly(file)\n\t\t\tIf stream\n\t\t\t\tLocal request:TRESTRequest = New TRESTRequest, response:TRESTResponse\n\t\t\t\trequest.SetProgressCallback(_ProgressCallback, New _mxProgressStore)\n\t\t\t\trequest.SetStream(stream)\n\t\t\t\tTry\n\t\t\t\t\tresponse = request.Call(GetUrl(), [\"User-Agent: \" + mainapp.m_useragent], \"GET\")\n\t\t\t\tCatch e:Object\n\t\t\t\t\tstream.Close()\n\t\t\t\t\tDeleteFile(file)\n\t\t\t\t\tlogger.LogMessage(\"\")\n\t\t\t\t\tThrowError(_s(\"error.fetch.archive\", [e.ToString()]))\n\t\t\t\tEnd Try\n\t\t\t\tstream.Close()\n\t\t\t\tIf response.responseCode = 200\n\t\t\t\t\tlogger.LogMessage(_s(\"message.fetch.done\", [String(response.responseCode)]))\n\t\t\t\tElse\n\t\t\t\t\tDeleteFile(file)\n\t\t\t\t\tlogger.LogMessage(\"\")\n\t\t\t\t\tThrowError(_s(\"error.fetch.archive\", [\"Bad response code: \" + String(response.responseCode)]))\n\t\t\t\tEnd If\n\t\t\tElse\n\t\t\t\tThrowError(_s(\"error.writeperms\", [file]))\n\t\t\tEnd If\n\t\tElse\n\t\t\tlogger.LogMessage(_s(\"message.fetch.alreadyfetched\"))\n\t\tEnd If\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Progress callback for source archive fetching.\n\t\treturns: Zero (no error).\n\tEnd Rem\n\tFunction _ProgressCallback:Int(data:Object, dltotal:Double, dlnow:Double, ultotal:Double, ulnow:Double)\n\t\tLocal store:_mxProgressStore = _mxProgressStore(data)\n\t\tLocal prog:Int = (dlnow \/ dltotal) * 100\n\t\tIf prog > store.m_progress + 5\n\t\t\tstore.m_progress = prog\n\t\t\tWriteStdOut(\".\")\n\t\tEnd If\n\t\tReturn 0\n\tEnd Function\n\t\nEnd Type\n\nRem\n\tbbdoc: A object representing a version, not to be confused with mxModuleVersion\n\tabout: Supported formats are 1, 1.1 and 1.1.1.\n\tDo note that because the version is represented as a Double there's a change\n\tthe precision of the final number is off.\n\t\n\t1.1.2 Would be converted to 1.001002 but when converted to a Double it results\n\tin 1.0010019999999999.\n\t\n\t1.1.12 However would be converted to 1.001012 and when converted to a Double it\n\tresults in 1.0010120000000000.\n\t\n\tA version string of 'dev' will be represented as 99999\nEnd Rem\nType mxVersionObject\n\n\tField m_version:Double\n\n\tRem\n\t\tbbdoc: Parse a version string\n\t\treturns: Itself.\n\tEnd Rem\n\tMethod Parse:mxVersionObject(version:String)\n\t\tIf version = \"dev\"\n\t\t\tm_version = 99999\n\t\t\tReturn Self\n\t\tEnd If\n\n\t\tLocal parts:String[] = version.Split(\".\")\n\t\tLocal converted:String = parts[0]\n\t\tIf parts.Length > 1\n\t\t\tconverted:+\".\"\n\t\t\tFor Local part:String = EachIn parts[1..]\n\t\t\t\tWhile part.Length <> 3\n\t\t\t\t\tpart = \"0\" + part\n\t\t\t\tWEnd\n\t\t\t\tconverted:+part\n\t\t\tNext\n\n\t\t\t'Make sure we format to x.x.x\n\t\t\tIf parts.Length = 2\n\t\t\t\tconverted:+\"000\"\n\t\t\tEnd If\n\t\tEnd If\n\n\t\tm_version = converted.ToDouble()\n\t\tReturn Self\n\tEnd Method\n\n\tRem\n\t\tbbdoc: Compare version numbers\n\tEnd Rem\n\tMethod Compare:Int(withObject:Object)\n\t\tLocal version:mxVersionObject = mxVersionObject(withObject)\n\t\tIf version\n\t\t\tIf m_version = version.m_version\n\t\t\t\tReturn 0\n\t\t\tElse If m_version > version.m_version\n\t\t\t\tReturn 1\n\t\t\tElse If m_version < version.m_version\n\t\t\t\tReturn - 1\n\t\t\tEnd If\n\t\tEnd If\n\t\tReturn Super.Compare(withObject)\n\tEnd Method\nEnd Type\n\nRem\n\tbbdoc: Maximus metafile handler\nEnd Rem\nType mxMetaFile\n\n\tField m_metafile:String\n\tField m_scope:String\n\tField m_name:String\n\tField m_version:String\n\t\n\tRem\n\t\tbbdoc: Create a metafile handler.\n\t\treturns: Itself.\n\tEnd Rem\n\tMethod Create:mxMetaFile(metafile:String)\n\t\tSetMetaFile(metafile)\n\t\tReturn Self\n\tEnd Method\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the metafile file path.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetMetaFile(metafile:String)\n\t\tm_metafile = metafile\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the metafile path.\n\t\treturns: The metafile path.\n\tEnd Rem\n\tMethod GetMetaFile:String()\n\t\tReturn m_metafile\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set metadata\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetMetaData(scope:String, name:String, version:String)\n\t\tSelf.m_scope = scope\n\t\tSelf.m_name = name\n\t\tSelf.m_version = version\n\tEnd Method\n\t\n'#end region Field accessors\n\t\n\tRem\n\t\tbbdoc: Load the configuration.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod Load()\n\t\tIf FileType(GetMetaFile()) = FILETYPE_FILE\n\t\t\tTry\n\t\t\t\tLocal contents:String = LoadText(GetMetaFile()).Trim()\n\t\t\t\tLocal parts:String[] = contents.Split(\"\/\")\n\t\t\t\t\n\t\t\t\tIf parts.Length <> 2\n\t\t\t\t\tThrow _s(\"error.load.meta.invalid_format\") ;\n\t\t\t\tEnd If\n\t\t\t\t\n\t\t\t\tLocal modinfo:String[] = parts[0].Split(\".\")\n\t\t\t\tm_scope = modinfo[0]\n\t\t\t\tm_name = modinfo[1]\n\t\t\t\tm_version = parts[1]\n\t\t\tCatch e:Object\n\t\t\t\tlogger.LogError(_s(\"error.load.metafile.parse\", [GetMetaFile()]))\n\t\t\t\tlogger.LogError(_s(\"error.load.metafile.parse\", [e.ToString()]))\n\t\t\tEnd Try\n\t\tElse\n\t\t\tlogger.LogWarning(_s(\"error.load.metafile.notfound\", [GetMetaFile()]))\n\t\tEnd If\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Save the configuration\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod Save()\n\t\tIf m_scope.Length = 0 Or m_name.Length = 0 Or m_version.Length = 0\n\t\t\tThrowError(_s(\"error.save.metafile.incomplete\", [m_scope, m_name, m_version]))\n\t\tEnd If\n\t\t\n\t\tLocal file:String = GetMetaFile()\n\t\tLocal stream:TStream = WriteFileExplicitly(file)\n\t\tIf stream\n\t\t\tstream.WriteString(m_scope + \".\" + m_name + \"\/\" + m_version)\n\t\t\tstream.Close\n\t\tElse\n\t\t\tThrowError(_s(\"error.writeperms\", [file]))\n\t\tEnd If\n\tEnd Method\nEnd Type\n","old_contents":"\nRem\n\tbbdoc: Maximus module base.\n\tabout: An abstract type for the similarities between module scopes and modules.\nEnd Rem\nType mxModuleBase Abstract\n\t\n\tField m_name:String\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the base's name.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetName(name:String)\n\t\tAssert name, \"(mxModuleBase.SetName) name cannot be Null\"\n\t\tm_name = name\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the base's name.\n\t\treturns: The base's name.\n\tEnd Rem\n\tMethod GetName:String()\n\t\tReturn m_name\n\tEnd Method\n\t\n'#end region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set a common field from the given variable.\n\t\treturns: True if the given variable was handled, or False if it was not.\n\tEnd Rem\n\tMethod SetCommonFromVariable:Int(variable:dVariable)\n\t\tReturn False\n\tEnd Method\n\t\nEnd Type\n\nRem\n\tbbdoc: Maximus module scope.\nEnd Rem\nType mxModuleScope Extends mxModuleBase\n\t\n\tField m_modules:dObjectMap\n\t\n\tMethod New()\n\t\tm_modules = New dObjectMap\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Add the given module to the scope.\n\t\treturns: True if the module was added, or False if it was not (the module is Null).\n\tEnd Rem\n\tMethod AddModule:Int(modul:mxModule)\n\t\tIf modul\n\t\t\tm_modules._Insert(modul.GetName(), modul)\n\t\t\tmodul.SetParent(Self)\n\t\t\tReturn True\n\t\tEnd If\n\t\tReturn False\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Check if the given module name is found in the scope.\n\t\treturns: True if the given module was found in the scope, or False if it was not.\n\tEnd Rem\n\tMethod HasModule:Int(modname:String)\n\t\tReturn m_modules._Contains(modname)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get a module with the given name.\n\t\treturns: The module with the given name, or Null if there is no module with the given name.\n\tEnd Rem\n\tMethod GetModuleWithName:mxModule(modname:String)\n\t\tReturn mxModule(m_modules._ObjectWithKey(modname))\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Load the given dJObject into the scope.\n\t\treturns: Itself, or Null if @root is Null.\n\tEnd Rem\n\tMethod FromJSON:mxModuleScope(root:dJObject)\n\t\tIf root\n\t\t\tSetName(root.GetName())\n\t\t\tFor Local variable:dVariable = EachIn root\n\t\t\t\tIf dJObject(variable)\n\t\t\t\t\tAddModule(New mxModule.FromJSON(dJObject(variable)))\n\t\t\t\t'Else\n\t\t\t\t'\tSetCommonFromVariable(variable)\n\t\t\t\tEnd If\n\t\t\tNext\n\t\t\tReturn Self\n\t\tEnd If\n\t\tReturn Null\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the module enumerator for the scope.\n\t\treturns: The module enumerator for the scope.\n\tEnd Rem\n\tMethod ModuleEnumerator:TMapEnumerator()\n\t\tReturn m_modules.ValueEnumerator()\n\tEnd Method\n\t\nEnd Type\n\nRem\n\tbbdoc: Maximus module.\nEnd Rem\nType mxModule Extends mxModuleBase\n\t\n\tField m_parent:mxModuleScope\n\tField m_description:String\n\tField m_versions:dObjectMap\n\t\n\tMethod New()\n\t\tm_versions = New dObjectMap\n\tEnd Method\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the module's parent.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetParent(parent:mxModuleScope)\n\t\tm_parent = parent\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the module's parent.\n\t\treturns: The module's parent.\n\tEnd Rem\n\tMethod GetParent:mxModuleScope()\n\t\tReturn m_parent\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the full name of the module (e.g. \"modscope.module\").\n\t\treturns: The full name of the module.\n\tEnd Rem\n\tMethod GetFullName:String()\n\t\tReturn m_parent.m_name + \".\" + m_name\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the module's description.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetDescription(description:String)\n\t\tm_description = description\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the module's description.\n\t\treturns: The module's description.\n\tEnd Rem\n\tMethod GetDescription:String()\n\t\tReturn m_description\n\tEnd Method\n\t\n'#end region Field accessors\n\t\n\tRem\n\t\tbbdoc: Get the installed version of the module (if it is installed).\n\t\treturns: The version of the module that is installed, or Null if the module is not installed.\n\tEnd Rem\n\tMethod GetInstalledVersion:mxModuleVersion()\n\t\tLocal version:String = mxModUtils.GetInstalledVersionFromVerID(GetFullName())\n\t\tIf version\n\t\t\tReturn New mxModuleVersion.Create(Self, version, Null)\n\t\tEnd If\n\t\tReturn Null\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Add the given version to the module.\n\t\treturns: True if the version was added, or False if it was not (the version is Null).\n\tEnd Rem\n\tMethod AddVersion:Int(version:mxModuleVersion)\n\t\tIf version\n\t\t\tm_versions._Insert(version.GetName(), version)\n\t\t\tversion.SetParent(Self)\n\t\t\tReturn True\n\t\tEnd If\n\t\tReturn False\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Check if there is a version with the given name.\n\t\treturns: True if the version was found, or False if it was not.\n\tEnd Rem\n\tMethod HasVersion:Int(name:String)\n\t\tReturn m_versions._Contains(name)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get a version with the given name.\n\t\treturns: The version with the given name, or Null if there is no version with the given name.\n\tEnd Rem\n\tMethod GetVersionWithName:mxModuleVersion(name:String)\n\t\tReturn mxModuleVersion(m_versions._ObjectWithKey(name))\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the latest (non-dev if available) version for this module.\n\t\treturns: The latest version for this module.\n\t\tabout: The latest version will be returned, or the dev version if it is the only version.\n\tEnd Rem\n\tMethod GetLatestVersion:mxModuleVersion()\n\t\tLocal hver:mxModuleVersion\n\t\tFor Local ver:mxModuleVersion = EachIn VersionEnumerator()\n\t\t\tIf ver.GetName() <> \"dev\"\n\t\t\t\tIf Not hver Or ver.Compare(hver) = 1\n\t\t\t\t\thver = ver\n\t\t\t\tEnd If\n\t\t\tEnd If\n\t\tNext\n\t\tIf Not hver\n\t\t\thver = GetVersionWithName(\"dev\")\n\t\tEnd If\n\t\tReturn hver\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set a common field from the given variable.\n\t\treturns: True if the given variable was handled, or False if it was not.\n\tEnd Rem\n\tMethod SetCommonFromVariable:Int(variable:dVariable)\n\t\tIf Super.SetCommonFromVariable(variable)\n\t\t\tReturn True\n\t\tElse\n\t\t\tSelect variable.GetName().ToLower()\n\t\t\t\tCase \"desc\"\n\t\t\t\t\tSetDescription(dValueVariable(variable).ValueAsString())\n\t\t\t\tCase \"versions\"\n\t\t\t\t\tFor Local jobj:dJObject = EachIn dJObject(variable)\n\t\t\t\t\t\tAddVersion(New mxModuleVersion.FromJSON(jobj))\n\t\t\t\t\tNext\n\t\t\t\tDefault\n\t\t\t\t\tReturn False\n\t\t\tEnd Select\n\t\t\tReturn True\n\t\tEnd If\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Load the given dJObject into the module.\n\t\treturns: Itself, or Null if @root is Null.\n\tEnd Rem\n\tMethod FromJSON:mxModule(root:dJObject)\n\t\tIf root\n\t\t\tSetName(root.GetName())\n\t\t\tFor Local variable:dVariable = EachIn root\n\t\t\t\tSetCommonFromVariable(variable)\n\t\t\tNext\n\t\t\tReturn Self\n\t\tEnd If\n\t\tReturn Null\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the version enumerator for the module.\n\t\treturns: The version enumerator for the module.\n\tEnd Rem\n\tMethod VersionEnumerator:TMapEnumerator()\n\t\tReturn m_versions.ValueEnumerator()\n\tEnd Method\n\t\nEnd Type\n\nRem\n\tbbdoc: Maximus module version.\nEnd Rem\nType mxModuleVersion\n\t\n\tField m_parent:mxModule\n\tField m_name:String, m_url:String\n\tField m_dependencies:mxModuleDependencies\n\t\n\tMethod New()\n\t\tm_dependencies = New mxModuleDependencies\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Create a module version.\n\t\treturns: Itself.\n\tEnd Rem\n\tMethod Create:mxModuleVersion(parent:mxModule, name:String, url:String)\n\t\tSetParent(parent)\n\t\tSetName(name)\n\t\tSetUrl(url)\n\t\tReturn Self\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Clone the version.\n\t\treturns: A clone of the version.\n\t\tabout: If @withdeps is True (default value), the dependencies will be added as well.\n\tEnd Rem\n\tMethod Clone:mxModuleVersion(withdeps:Int = True)\n\t\tLocal v:mxModuleVersion = New mxModuleVersion.Create(m_parent, m_name, m_url)\n\t\tFor Local dep:mxModuleDependency = EachIn DependencyEnumerator()\n\t\t\tv.m_dependencies.AddDependency(dep)\n\t\tNext\n\t\tReturn v\n\tEnd Method\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the version's parent.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetParent(parent:mxModule)\n\t\tm_parent = parent\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the version's parent.\n\t\treturns: The version's parent.\n\tEnd Rem\n\tMethod GetParent:mxModule()\n\t\tReturn m_parent\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the version's name.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetName(name:String)\n\t\tAssert name, \"(mxModuleVersion.SetName) name cannot be Null!\"\n\t\tm_name = name\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the version's name.\n\t\treturns: The version's name.\n\tEnd Rem\n\tMethod GetName:String()\n\t\tReturn m_name\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the version's url.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetUrl(url:String)\n\t\t'Assert url, \"(mxModuleVersion.SetUrl) url cannot be Null!\"\n\t\tm_url = url\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the version's url.\n\t\treturns: The version's url.\n\tEnd Rem\n\tMethod GetUrl:String()\n\t\tReturn m_url\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the temporary fetch path for the version's source archive.\n\t\treturns: The temporary file path for the version's source archive.\n\tEnd Rem\n\tMethod GetTemporaryFilePath:String()\n\t\tReturn \"tmp\/\" + m_parent.GetFullName() + \"-\" + m_name + \".zip\"\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the version's dependencies.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetDependencies(dependencies:mxModuleDependencies)\n\t\tm_dependencies = dependencies\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the version's dependencies.\n\t\treturns: The version's dependencies.\n\tEnd Rem\n\tMethod GetDependencies:mxModuleDependencies()\n\t\tReturn m_dependencies\n\tEnd Method\n\t\n'#end region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set a common field from the given variable.\n\t\treturns: True if the given variable was handled, or False if it was not.\n\tEnd Rem\n\tMethod SetCommonFromVariable:Int(variable:dVariable)\n\t\tSelect variable.GetName().ToLower()\n\t\t\tCase \"url\"\n\t\t\t\tSetUrl(dValueVariable(variable).ValueAsString())\n\t\t\tCase \"deps\"\n\t\t\t\tm_dependencies.FromJSON(dJArray(variable))\n\t\t\tDefault\n\t\t\t\tReturn False\n\t\tEnd Select\n\t\tReturn True\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Load the given dJObject into the version.\n\t\treturns: Itself, or Null if @root is Null.\n\tEnd Rem\n\tMethod FromJSON:mxModuleVersion(root:dJObject)\n\t\tIf root\n\t\t\tSetName(root.GetName())\n\t\t\tFor Local variable:dVariable = EachIn root\n\t\t\t\tSetCommonFromVariable(variable)\n\t\t\tNext\n\t\t\tReturn Self\n\t\tEnd If\n\t\tReturn Null\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the dependency enumerator for the version.\n\t\treturns: The dependency enumerator for the version.\n\tEnd Rem\n\tMethod DependencyEnumerator:TMapEnumerator()\n\t\tReturn m_dependencies.DependencyEnumerator()\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Compare the version with the given version.\n\t\treturns: 0 if the two versions are the same (same in version number alone), 1 if this version is greater than the given, or -1 if the given version is greater than this version.\n\tEnd Rem\n\tMethod Compare:Int(with:Object)\n\t\tLocal ver:mxModuleVersion = mxModuleVersion(with)\n\t\tIf ver\n\t\t\tLocal version1:mxVersionObject = New mxVersionObject.Parse(m_name)\n\t\t\tLocal version2:mxVersionObject = New mxVersionObject.Parse(ver.m_name)\n\t\t\tReturn version1.Compare(version2)\n\t\tEnd If\n\t\tReturn Super.Compare(with)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Fetch the version's source archive.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod FetchSourceArchive()\n\t\tLocal file:String = GetTemporaryFilePath()\n\t\tlogger.LogMessage(\"fetching: \" + GetUrl() + \" -> \" + file + \" \", False)\n\t\tIf FileType(file) = FILETYPE_NONE\n\t\t\tLocal stream:TStream = WriteFileExplicitly(file)\n\t\t\tIf stream\n\t\t\t\tLocal request:TRESTRequest = New TRESTRequest, response:TRESTResponse\n\t\t\t\trequest.SetProgressCallback(_ProgressCallback, New _mxProgressStore)\n\t\t\t\trequest.SetStream(stream)\n\t\t\t\tTry\n\t\t\t\t\tresponse = request.Call(GetUrl(), [\"User-Agent: \" + mainapp.m_useragent], \"GET\")\n\t\t\t\tCatch e:Object\n\t\t\t\t\tstream.Close()\n\t\t\t\t\tDeleteFile(file)\n\t\t\t\t\tlogger.LogMessage(\"\")\n\t\t\t\t\tThrowError(_s(\"error.fetch.archive\", [e.ToString()]))\n\t\t\t\tEnd Try\n\t\t\t\tstream.Close()\n\t\t\t\tIf response.responseCode = 200\n\t\t\t\t\tlogger.LogMessage(_s(\"message.fetch.done\", [String(response.responseCode)]))\n\t\t\t\tElse\n\t\t\t\t\tDeleteFile(file)\n\t\t\t\t\tlogger.LogMessage(\"\")\n\t\t\t\t\tThrowError(_s(\"error.fetch.archive\", [\"Bad response code: \" + String(response.responseCode)]))\n\t\t\t\tEnd If\n\t\t\tElse\n\t\t\t\tThrowError(_s(\"error.writeperms\", [file]))\n\t\t\tEnd If\n\t\tElse\n\t\t\tlogger.LogMessage(_s(\"message.fetch.alreadyfetched\"))\n\t\tEnd If\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Progress callback for source archive fetching.\n\t\treturns: Zero (no error).\n\tEnd Rem\n\tFunction _ProgressCallback:Int(data:Object, dltotal:Double, dlnow:Double, ultotal:Double, ulnow:Double)\n\t\tLocal store:_mxProgressStore = _mxProgressStore(data)\n\t\tLocal prog:Int = (dlnow \/ dltotal) * 100\n\t\tIf prog > store.m_progress + 5\n\t\t\tstore.m_progress = prog\n\t\t\tWriteStdOut(\".\")\n\t\tEnd If\n\t\tReturn 0\n\tEnd Function\n\t\nEnd Type\n\nRem\n\tbbdoc: A object representing a version, not to be confused with mxModuleVersion\n\tabout: Supported formats are 1, 1.1 and 1.1.1.\n\tDo note that because the version is represented as a Double there's a change\n\tthe precision of the final number is off.\n\t\n\t1.1.2 Would be converted to 1.001002 but when converted to a Double it results\n\tin 1.0010019999999999.\n\t\n\t1.1.12 However would be converted to 1.001012 and when converted to a Double it\n\tresults in 1.0010120000000000.\n\t\n\tA version string of 'dev' will be represented as 99999\nEnd Rem\nType mxVersionObject\n\n\tField m_version:Double\n\n\tRem\n\t\tbbdoc: Parse a version string\n\t\treturns: Itself.\n\tEnd Rem\n\tMethod Parse:mxVersionObject(version:String)\n\t\tIf version = \"dev\"\n\t\t\tm_version = 99999\n\t\t\tReturn Self\n\t\tEnd If\n\n\t\tLocal parts:String[] = version.Split(\".\")\n\t\tLocal converted:String = parts[0]\n\t\tIf parts.Length > 1\n\t\t\tconverted:+\".\"\n\t\t\tFor Local part:String = EachIn parts[1..]\n\t\t\t\tWhile part.Length <> 3\n\t\t\t\t\tpart = \"0\" + part\n\t\t\t\tWEnd\n\t\t\t\tconverted:+part\n\t\t\tNext\n\n\t\t\t'Make sure we format to x.x.x\n\t\t\tIf parts.Length = 2\n\t\t\t\tconverted:+\"000\"\n\t\t\tEnd If\n\t\tEnd If\n\n\t\tm_version = converted.ToDouble()\n\t\tReturn Self\n\tEnd Method\n\n\tRem\n\t\tbbdoc: Compare version numbers\n\tEnd Rem\n\tMethod Compare:Int(withObject:Object)\n\t\tLocal version:mxVersionObject = mxVersionObject(withObject)\n\t\tIf version\n\t\t\tIf m_version = version.m_version\n\t\t\t\tReturn 0\n\t\t\tElse If m_version > version.m_version\n\t\t\t\tReturn 1\n\t\t\tElse If m_version < version.m_version\n\t\t\t\tReturn - 1\n\t\t\tEnd If\n\t\tEnd If\n\t\tReturn Super.Compare(withObject)\n\tEnd Method\nEnd Type\n\nRem\n\tbbdoc: Maximus metafile handler\nEnd Rem\nType mxMetaFile\n\n\tField m_metafile:String\n\tField m_scope:String\n\tField m_name:String\n\tField m_version:String\n\t\n\tRem\n\t\tbbdoc: Create a metafile handler.\n\t\treturns: Itself.\n\tEnd Rem\n\tMethod Create:mxMetaFile(metafile:String)\n\t\tSetMetaFile(metafile)\n\t\tReturn Self\n\tEnd Method\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the metafile file path.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetMetaFile(metafile:String)\n\t\tm_metafile = metafile\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the metafile path.\n\t\treturns: The metafile path.\n\tEnd Rem\n\tMethod GetMetaFile:String()\n\t\tReturn m_metafile\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set metadata\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetMetaData(scope:String, name:String, version:String)\n\t\tSelf.m_scope = scope\n\t\tSelf.m_name = name\n\t\tSelf.m_version = version\n\tEnd Method\n\t\n'#end region Field accessors\n\t\n\tRem\n\t\tbbdoc: Load the configuration.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod Load()\n\t\tIf FileType(GetMetaFile()) = FILETYPE_FILE\n\t\t\tTry\n\t\t\t\tLocal contents:String = LoadText(GetMetaFile()).Trim()\n\t\t\t\tLocal parts:String[] = contents.Split(\"\/\")\n\t\t\t\t\n\t\t\t\tIf parts.Length <> 2\n\t\t\t\t\tThrow _s(\"error.load.meta.invalid_format\") ;\n\t\t\t\tEnd If\n\t\t\t\t\n\t\t\t\tLocal modinfo:String[] = parts[0].Split(\".\")\n\t\t\t\tm_scope = modinfo[0]\n\t\t\t\tm_name = modinfo[1]\n\t\t\t\tm_version = parts[1]\n\t\t\tCatch e:Object\n\t\t\t\tlogger.LogError(_s(\"error.load.metafile.parse\", [GetMetaFile()]))\n\t\t\t\tlogger.LogError(_s(\"error.load.metafile.parse\", [e.ToString()]))\n\t\t\tEnd Try\n\t\tElse\n\t\t\tlogger.LogWarning(_s(\"error.load.metafile.notfound\", [GetMetaFile()]))\n\t\tEnd If\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Save the configuration\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod Save()\n\t\tIf m_scope.Length = 0 Or m_name.Length = 0 Or m_version.Length = 0\n\t\t\tThrowError(_s(\"error.save.metafile.incomplete\", [m_scope, m_name, m_version]))\n\t\tEnd If\n\t\t\n\t\tLocal stream:TStream = WriteFileExplicitly(GetMetaFile())\n\t\tstream.WriteString(m_scope + \".\" + m_name + \"\/\" + m_version)\n\t\tstream.Close\n\tEnd Method\nEnd Type\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"16a481c59f10e01b8ff116d0f09fd3c2622d1d8a","subject":"TBSPModel trees now render as polygons instead of triangles.","message":"TBSPModel trees now render as polygons instead of triangles.\n","repos":"kfprimm\/maxb3d,kfprimm\/maxb3d","old_file":"gldriver.mod\/gldriver.bmx","new_file":"gldriver.mod\/gldriver.bmx","new_contents":"\nStrict\n\nRem\n\tbbdoc: OpenGL 1.1 driver for MaxB3D\nEnd Rem\nModule MaxB3D.GLDriver\nModuleInfo \"Author: Kevin Primm\"\nModuleInfo \"License: MIT\"\n\nImport MaxB3D.Core\nImport Prime.GLMax2DEx\n\nPrivate\nFunction ModuleLog(message$)\n\tTMaxB3DLogger.Write \"gldriver\",message\nEnd Function\n\nPublic\n\nGlobal GL_LIGHT[]=[GL_LIGHT0,GL_LIGHT1,GL_LIGHT2,GL_LIGHT3,GL_LIGHT4,GL_LIGHT5,GL_LIGHT6,GL_LIGHT7]\n\nType TGLMaxB3DDriver Extends TMaxB3DDriver\n\tField _currentdata:TMaxB3DShaderData= New TMaxB3DShaderData\n\t\n\tMethod SetGraphics(g:TGraphics)\n\t\tSuper.SetGraphics g\n\t\tIf g<>Null Startup\n\tEnd Method\n\t\n\tFunction BindTexture(index,tex)\n\t\tIf index=-1\n\t\t\tFor Local i=0 To 7\n\t\t\t\tBindTexture i,tex\n\t\t\tNext\n\t\t\tReturn\n\t\tEndIf\n\t\tGlobal currenttexture[] = [-1,-1,-1,-1,-1,-1,-1,-1]\n\t\tIf tex<>currenttexture[index]\n\t\t\tglBindTexture GL_TEXTURE_2D,tex\n\t\t\tcurrenttexture[index]=tex\n\t\tEndIf\n\tEnd Function\n\t\n\tMethod Startup()\n\t\tGlobal _firsttime=True\n\t\tIf _firsttime\n\t\t\tLocal caps:TGLCaps=TGLCaps(_caps)\n\t\t\tModuleLog \"Initializing GL driver\"\n\t\t\tModuleLog \"Vendor: \"+String.FromCString(Byte Ptr(glGetString(GL_VENDOR)))\n\t\t\tModuleLog \"Renderer: \"+String.FromCString(Byte Ptr(glGetString(GL_RENDERER))) \n\t\t\tModuleLog \"Version: \"+String.FromCString(Byte Ptr(glGetString(GL_VERSION)))\n\t\t\tModuleLog \"Extensions supported: \"+\" \".Join(caps.Extensions)\n\t\t\tEndMax2D \n\t\t\t_firsttime=False\t\t\t\n\t\tEndIf\t\t\n\t\tEnableStates\n\tEnd Method\n\t\n\tFunction EnableStates()\t\n\t\tglEnable GL_LIGHTING\n\t\tglEnable GL_DEPTH_TEST\n\t\tglEnable GL_CULL_FACE\n\t\tglEnable GL_SCISSOR_TEST\n\t\t\n\t\tglEnable GL_NORMALIZE\n\t\t\n\t\tglEnableClientState GL_VERTEX_ARRAY\n\t\tglEnableClientState GL_COLOR_ARRAY\n\t\tglEnableClientState GL_NORMAL_ARRAY\n\t\t\n\t\tglFrontFace GL_CW\n\t\t\n\t\tglLightModeli GL_LIGHT_MODEL_COLOR_CONTROL,GL_SEPARATE_SPECULAR_COLOR\n\t\tglLightModeli GL_LIGHT_MODEL_LOCAL_VIEWER,GL_TRUE\n\t\n\t\tglClearDepth 1.0\n\t\tglDepthFunc GL_LEQUAL\n\t\tglHint GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST\n\t\n\t\tglAlphaFunc GL_GEQUAL,0.5\n\t\t\n\t\tBindTexture -1,0\n\tEnd Function\t\n\t\n\tMethod MakeBuffer:TBuffer(src:Object,width,height,flags)\n\t\tLocal buffer:TBuffer\n\t\tSelect True\n\t\tCase TTextureFrame(src)<>Null\n\t\t\tbuffer=TGLBuffer(TTextureFrame(src)._buffer)\n\t\t\tIf buffer=Null\n\t\t\t\tLocal res:TGLTextureRes=UpdateTextureRes(TTextureFrame(src),0)\n\t\t\t\tbuffer=TGLMax2DExDriver(_parent).MakeGLBuffer(res._id,width,height,flags)\n\t\t\tEndIf\n\t\tDefault\n\t\t\tbuffer=TMax2DExDriver(_parent).MakeBuffer(src,width,height,flags)\n\t\tEnd Select\n\t\tReturn buffer\n\tEnd Method\n\t\n\tMethod Abbr$()\n\t\tReturn \"gl\"\n\tEnd Method\n\t\n\tMethod GetCaps:TCaps()\n\t\tLocal caps:TGLCaps=New TGLCaps\n\t\tcaps.Extensions=String.FromCString(glGetString(GL_EXTENSIONS)).Split(\" \")\n\t\tIf caps.HasExtension(\"GL_ARB_point_sprite\")<>-1\n\t\t\tcaps.PointSprites=True\n\t\t\tglGetFloatv GL_POINT_SIZE_MAX_ARB, Varptr caps.MaxPointSize\n\t\tEndIf\n\t\tReturn caps\n\tEnd Method\n\t\n\tMethod SetMax2D(enable)\n\t\tIf enable\n\t\t\tglPopClientAttrib\n\t\t\tglPopAttrib\n\t\t\tIf _shaderdriver _shaderdriver.Use(Null,Null)\t\n\t\t\tTGLMax2DExDriver(_parent).ResetGLContext _current\n\t\t\tglMatrixMode GL_TEXTURE\n\t\t\tglLoadIdentity\n\t\t\tglMatrixMode GL_COLOR\t\n\t\t\tglPopMatrix\t\t\t\t\t\n\t\tElse\t\t\t\n\t\t\tglPushAttrib GL_ALL_ATTRIB_BITS\n\t\t\tglPushClientAttrib GL_CLIENT_ALL_ATTRIB_BITS\n\t\t\tglMatrixMode GL_TEXTURE\n\t\t\tglPushMatrix\n\t\t\tglMatrixMode GL_COLOR\n\t\t\tglPushMatrix \n\t\t\t\n\t\t\tEnableStates()\n\t\tEndIf\n\tEnd Method\t\n\tMethod SetCamera(camera:TCamera, config:TWorldConfig)\n\t\tIf config.Dither\n\t\t\tglEnable GL_DITHER\n\t\tElse\n\t\t\tglDisable GL_DITHER\n\t\tEndIf\n\t\t\n\t\tLocal vy#=config.Height-camera._viewheight-camera._viewy\n\t\tglViewport(camera._viewx,vy,camera._viewwidth,camera._viewheight)\n\t\tglScissor(camera._viewx,vy,camera._viewwidth,camera._viewheight)\n\t\tglClearColor(camera._brush._r,camera._brush._g,camera._brush._b,1.0)\n\t\t\n\t\tIf camera._clsmode&CLSMODE_COLOR And camera._clsmode&CLSMODE_DEPTH\n\t\t\tglDepthMask GL_TRUE\n\t\t\tglClear GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT\n\t\tElse\n\t\t\tIf camera._clsmode&CLSMODE_COLOR\n\t\t\t\tglClear GL_COLOR_BUFFER_BIT\n\t\t\tElse\n\t\t\t\tIf camera._clsmode&CLSMODE_DEPTH\n\t\t\t\t\tglDepthMask GL_TRUE\n\t\t\t\t\tglClear GL_DEPTH_BUFFER_BIT\n\t\t\t\tEndIf\n\t\t\tEndIf\n\t\tEndIf\n\t\t\n\t\tIf camera._fogmode<>FOGMODE_NONE\n\t\t\tglEnable GL_FOG\n\t\t\tglFogi GL_FOG_MODE,GL_LINEAR\n\t\t\tglFogf GL_FOG_START,camera._fognear\n\t\t\tglFogf GL_FOG_END,camera._fogfar\n\t\t\tLocal rgb#[]=[camera._fogr,camera._fogg,camera._fogb]\n\t\t\tglFogfv GL_FOG_COLOR,rgb\n\t\tElse\n\t\t\tglDisable GL_FOG\n\t\tEndIf\n\t\t\n\t\tcamera.UpdateMatrices()\n\t\t\n\t\tglMatrixMode GL_PROJECTION\n\t\tglLoadMatrixf camera._projection.ToPtr()\t\n\t\tglMatrixMode GL_MODELVIEW\t\t\n\t\tglLoadMatrixf camera._modelview.ToPtr()\n\n\t\t' Temporary hack\n\t\tglGetFloatv GL_PROJECTION_MATRIX,camera._projection._m\t\t\n\t\tcamera._frustum=TFrustum.Extract(camera._modelview,camera._projection)\n\tEnd Method\t\n\t\n\tMethod SetLight(light:TLight,index)\n\t\tIf light=Null\n\t\t\tglDisable GL_LIGHT[index]\n\t\t\tReturn\n\t\tElse\n\t\t\tIf light._hidden=True \n\t\t\t\tglDisable GL_LIGHT[index]\n\t\t\t\tReturn False\n\t\t\tEndIf\n\t\tEndIf\n\t\t\n\t\tglEnable GL_LIGHT[index]\n\t\t\n\t\tglPushMatrix\n\t\tglMultMatrixf light.GetMatrix(True).ToPtr()\n\t\t\n\t\tLocal white_light#[]=[1.0,1.0,1.0,1.0]\n\t\tglLightfv GL_LIGHT[index],GL_SPECULAR,white_light\n\t\t\n\t\tLocal z#=1.0\n\t\tLocal w#=0.0\n\t\tIf light._mode>LIGHT_DIRECTIONAL\n\t\t\tz=0.0\n\t\t\tw=1.0\n\t\tEndIf\n\t\t\n\t\tLocal rgba#[]=[light._brush._r,light._brush._g,light._brush._b,1.0]\n\t\tLocal pos#[]=[0.0,0.0,-z,w]\n\t\t\n\t\tglLightfv GL_LIGHT[index],GL_POSITION,pos\n\t\tglLightfv GL_LIGHT[index],GL_DIFFUSE,rgba\n\t\n\t\tIf light._mode<>LIGHT_DIRECTIONAL\n\t\t\tLocal light_range#[]=[0.0]\n\t\t\tLocal range#[]=[light._range]\n\t\t\tglLightfv GL_LIGHT[index],GL_CONSTANT_ATTENUATION,light_range\n\t\t\tglLightfv GL_LIGHT[index],GL_LINEAR_ATTENUATION,range\n\t\tEndIf\t\t\n\n\t\tIf light._mode=LIGHT_SPOT\t\t\n\t\t\tLocal dir#[]=[0.0,0.0,-1.0]\n\t\t\tLocal outer#[]=[light._outer\/2.0]\n\t\t\tLocal exponent#[]=[10.0]\t\n\t\t\tglLightfv GL_LIGHT[index],GL_SPOT_DIRECTION,dir\n\t\t\tglLightfv GL_LIGHT[index],GL_SPOT_CUTOFF,outer\n\t\t\tglLightfv GL_LIGHT[index],GL_SPOT_EXPONENT,exponent\n\t\tEndIf\n\t\t\n\t\tglPopMatrix\n\tEnd Method\n\t\n\tMethod SetBrush(brush:TBrush,hasalpha,config:TWorldConfig)\n\t\tLocal alpha_test\n\t\t\t\n\t\tLocal ambient#[]=[config.AmbientRed\/255.0,config.AmbientGreen\/255.0,config.AmbientBlue\/255.0]\t\t\t\n\t\t\t\t\t\n\t\tIf hasalpha\n\t\t\tglEnable GL_BLEND\n\t\t\tglDepthMask GL_FALSE\n\t\tElse\n\t\t\tglDisable GL_BLEND\n\t\t\tglDepthMask GL_TRUE\n\t\tEndIf\n\t\t\n\t\tSelect brush._blend\n\t\t\tCase BLEND_NONE,BLEND_ALPHA\n\t\t\t\tglBlendFunc GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA\n\t\t\tCase BLEND_MULTIPLY\n\t\t\t\tglBlendFunc GL_DST_COLOR,GL_ZERO\n\t\t\tCase BLEND_ADD\n\t\t\t\tglBlendFunc GL_SRC_ALPHA,GL_ONE\n\t\tEnd Select\n\t\t\n\t\tIf brush._fx&FX_FULLBRIGHT\n\t\t\tambient[0]=1.0\n\t\t\tambient[1]=1.0\n\t\t\tambient[2]=1.0\t\t\n\t\tEndIf\n\t\t\n\t\tIf brush._fx&FX_VERTEXCOLOR\n\t\t\tglEnable GL_COLOR_MATERIAL\n\t\tElse\n\t\t\tglDisable GL_COLOR_MATERIAL\n\t\tEndIf\n\t\t\n\t\tIf brush._fx&FX_FLATSHADED\n\t\t\tglShadeModel GL_FLAT\n\t\tElse\n\t\t\tglShadeModel GL_SMOOTH\n\t\tEndIf\n\n\t\tIf brush._fx&FX_NOFOG\n\t\t\tglDisable GL_FOG\n\t\tEndIf\n\t\t\n\t\tIf brush._fx&FX_NOCULLING\n\t\t\tglDisable GL_CULL_FACE\n\t\tElse\n\t\t\tglEnable GL_CULL_FACE\n\t\tEndIf\n\t\t\n\t\tIf brush._fx&FX_WIREFRAME Or config.Wireframe\n\t\t\tglPolygonMode GL_FRONT_AND_BACK,GL_LINE\n\t\tElse\n\t\t\tglPolygonMode GL_FRONT_AND_BACK,GL_FILL\n\t\tEndIf\t\t\t\n\t\t\n\t\tLocal no_mat#[]=[0.0,0.0]\n\t\tLocal mat_ambient#[]=[brush._r,brush._g,brush._b,brush._a]\n\t\tLocal mat_diffuse#[]=[brush._r,brush._g,brush._b,brush._a]\n\t\tLocal mat_specular#[]=[brush._shine,brush._shine,brush._shine,brush._shine]\n\t\tLocal mat_shininess#[]=[100.0]\n\t\t\t\n\t\tglMaterialfv GL_FRONT,GL_AMBIENT,mat_ambient\n\t\tglMaterialfv GL_FRONT,GL_DIFFUSE,mat_diffuse\n\t\tglMaterialfv GL_FRONT,GL_SPECULAR,mat_specular\n\t\tglMaterialfv GL_FRONT,GL_SHININESS,mat_shininess\n\t\tglLightModelfv GL_LIGHT_MODEL_AMBIENT,ambient\n\t\t\n\t\tFor Local i=0 To 7\n\t\t\tglActiveTextureARB GL_TEXTURE0+i\n\n\t\t\tLocal texture:TTexture=brush._texture[i]\n\t\t\tIf texture=Null Or texture._blend=BLEND_NONE\n\t\t\t\tglDisable GL_TEXTURE_2D\n\t\t\t\tBindTexture i,0\n\t\t\t\tContinue\n\t\t\tEndIf\n\t\t\t\n\t\t\tLocal texres:TGLTextureRes=TGLTextureRes(UpdateTextureRes(texture._frame[brush._textureframe[i]],texture._flags))\n\t\t\t\n\t\t\tglEnable GL_TEXTURE_2D\n\t\t\t\n\t\t\tBindTexture i,texres._id\t\n\t\t\t\n\t\t\tglMatrixMode GL_TEXTURE\n\t\t\tglLoadIdentity\n\t\t\tglTranslatef texture._px,-texture._py,0\n\t\t\tglScalef -texture._sx,texture._sy,1\n\t\t\t\n\t\t\talpha_test :| texture._flags&TEXTURE_ALPHA Or texture._flags&TEXTURE_MASKED\n\t\t\n\t\t\tIf texture._flags&TEXTURE_MIPMAP\n\t\t\t\tglTexParameteri GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR\n\t\t\t\tglTexParameteri GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_LINEAR\n\t\t\tElse\n\t\t\t\tglTexParameteri GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR\n\t\t\t\tglTexParameteri GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR\n\t\t\tEndIf\n\t\t\t\n\t\t\tIf texture._flags&TEXTURE_CLAMPU\n\t\t\t\tglTexParameteri GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_CLAMP_TO_EDGE\n\t\t\tElse\t\t\t\t\t\t\n\t\t\t\tglTexParameteri GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_REPEAT\n\t\t\tEndIf\n\t\t\t\n\t\t\tIf texture._flags&TEXTURE_CLAMPV\n\t\t\t\tglTexParameteri GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_CLAMP_TO_EDGE\n\t\t\tElse\n\t\t\t\tglTexParameteri GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_REPEAT\n\t\t\tEndIf\n\t\n\t\t\tIf texture._flags&TEXTURE_SPHEREMAP\t\t\t\t\n\t\t\t\tglEnable GL_TEXTURE_GEN_S\n\t\t\t\tglEnable GL_TEXTURE_GEN_T\n\t\t\t\tglTexGeni GL_S,GL_TEXTURE_GEN_MODE,GL_SPHERE_MAP\n\t\t\t\tglTexGeni GL_T,GL_TEXTURE_GEN_MODE,GL_SPHERE_MAP\n\t\t\tElse\n\t\t\t\tglDisable GL_TEXTURE_GEN_S\n\t\t\t\tglDisable GL_TEXTURE_GEN_T\n\t\t\tEndIf\n\n\t\t\tSelect texture._blend\n\t\t\tCase BLEND_NONE glTexEnvf(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_REPLACE)\n\t\t\tCase BLEND_ALPHA \tglTexEnvf(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_MODULATE)\n\t\t\tCase BLEND_MULTIPLY glTexEnvf(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_MODULATE)\n\t\t\t'Case BLEND_MULTIPLY glTexEnvf(GL_TEXTURE_ENV,GL_COMBINE_RGB_EXT,GL_MODULATE)\n\t\t\tCase BLEND_ADD glTexEnvf(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_ADD)\n\t\t\tCase BLEND_DOT3\n\t\t\t\tglTexEnvf GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT\n\t\t\t\tglTexEnvf GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_DOT3_RGB_EXT\n\t\t\tCase BLEND_MULTIPLY2\n\t\t\t\tglTexEnvi GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_COMBINE\n\t\t\t\tglTexEnvi GL_TEXTURE_ENV,GL_COMBINE_RGB,GL_MODULATE\n\t\t\t\tglTexEnvi GL_TEXTURE_ENV,GL_RGB_SCALE,2.0\n\t\t\tDefault glTexEnvf GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_MODULATE\n\t\t\tEnd Select\t\t\t\n\t\tNext\t\n\t\t\n\t\tIf alpha_test\n\t\t\tglEnable GL_ALPHA_TEST\n\t\tElse\n\t\t\tglDisable GL_ALPHA_TEST\n\t\tEndIf\n\t\t\t\t\n\t\tIf _shaderdriver _shaderdriver.Use(brush._shader,_currentdata)\t\n\tEnd Method\n\t\n\tMethod RenderSurface(resource:TSurfaceRes,brush:TBrush)\n\t\tLocal res:TGLSurfaceRes=TGLSurfaceRes(resource)\t\n\t\t\n\t\tFor Local i=0 To 7\n\t\t\tglClientActiveTextureARB GL_TEXTURE0+i\n\t\t\t\n\t\t\tLocal texture:TTexture=brush._texture[i]\n\t\t\tIf texture=Null \n\t\t\t\tglDisableClientState GL_TEXTURE_COORD_ARRAY\n\t\t\t\tContinue\n\t\t\tEndIf\n\t\t\t\n\t\t\tglEnableClientState GL_TEXTURE_COORD_ARRAY\n\t\t\tglBindBufferARB GL_ARRAY_BUFFER_ARB,res._vbo[4+texture._coords]\n\t\t\tglTexCoordPointer 2,GL_FLOAT,0,Null\n\t\tNext\n\t\t\n\t\tglBindBufferARB GL_ARRAY_BUFFER_ARB,res._vbo[0]\n\t\tglVertexPointer 3,GL_FLOAT,0,Null\n\t\t\n\t\tglBindBufferARB GL_ARRAY_BUFFER_ARB,res._vbo[1]\n\t\tglNormalPointer GL_FLOAT,0,Null\n\t\t\n\t\tglBindBufferARB GL_ARRAY_BUFFER_ARB,res._vbo[2]\n\t\tglColorPointer 4,GL_FLOAT,0,Null\n\t\n\t\tglBindBufferARB GL_ELEMENT_ARRAY_BUFFER_ARB,res._vbo[3]\n\t\tglDrawElements GL_TRIANGLES,res._trianglecnt*3,GL_UNSIGNED_INT,Null\n\t\t\n\t\tReturn res._trianglecnt\n\tEnd Method\n\t\n\tMethod BeginEntityRender(entity:TEntity)\t\t\n\t\tIf entity._order<>0\n\t\t\tglDisable GL_DEPTH_TEST\n\t\t\tglDepthMask GL_FALSE\n\t\tElse\n\t\t\tglEnable GL_DEPTH_TEST\n\t\t\tglDepthMask GL_TRUE\n\t\tEndIf\n\t\t\n\t\tglMatrixMode GL_MODELVIEW\n\t\tglPushMatrix\n\t\tglMultMatrixf entity.GetMatrix(True,False).ToPtr()\n\t\t\n\t\tGlobal matrix:TMatrix=New TMatrix\n\t\tglGetFloatv GL_MODELVIEW_MATRIX,matrix._m\n\tEnd Method\n\tMethod EndEntityRender(entity:TEntity)\n\t\tglMatrixMode GL_MODELVIEW\n\t\tglPopMatrix\n\tEnd Method\n\t\n\tMethod RenderFlat(flat:TFlat)\n\t\tLocal x#,y#,z#\n\t\tflat.GetScale x,y,z,True\n\t\t\n\t\tglBegin GL_QUADS\n\t\t\tglNormal3f 0,1,0\n\t\t\tglTexCoord2f 0,0\n\t\t\tglVertex3f -1,0, 1\n\t\t\tglTexCoord2f x,0\t\n\t\t\tglVertex3f 1, 0, 1\n\t\t\tglTexCoord2f x,z\n\t\t\tglVertex3f 1, 0, -1\n\t\t\tglTexCoord2f 0,z\n\t\t\tglVertex3f -1,0, -1\n\t\tglEnd\n\t\tReturn 2\n\tEnd Method\n\t\n\tMethod RenderSprite(sprite:TSprite)\n\t\tIf False\n\t\t\tglPointParameterfvARB GL_POINT_DISTANCE_ATTENUATION_ARB, [0.0, 0.0, 1.0]\n\t\t\t\n\t\t\tglPointSize 1.0\n\t\t\t\n\t\t\tglPointParameterfARB GL_POINT_FADE_THRESHOLD_SIZE_ARB,60.0\n\t\t\tglPointParameterfARB GL_POINT_SIZE_MIN_ARB,0.0\n\t\t\tglPointParameterfARB GL_POINT_SIZE_MAX_ARB,9999.0\n\t\t\t\n\t\t\tglTexEnvf GL_POINT_SPRITE_ARB,GL_COORD_REPLACE_ARB,GL_TRUE\n\t\t\t\n\t\t\tglEnable GL_POINT_SPRITE_ARB\n\t\t\t\n\t\t\tglBegin GL_POINTS\t\t\t\n\t\t\tglVertex3f 0,0,0\n\t\t\tglEnd\n\t\t\t\n\t\t\tglDisable GL_POINT_SPRITE_ARB\n\t\tElse\n\t\t\tglBegin GL_QUADS\n\t\t\t\tglNormal3f 0,0,-1\n\t\t\t\tglTexCoord2f 0,1\n\t\t\t\tglVertex3f 1, -1, 0\t\t\t\n\t\t\t\tglTexCoord2f 0,0\n\t\t\t\tglVertex3f 1, 1, 0\t\t\t\n\t\t\t\tglTexCoord2f 1,0\n\t\t\t\tglVertex3f -1,1, 0\t\t\t\n\t\t\t\tglTexCoord2f 1,1\n\t\t\t\tglVertex3f -1,-1, 0\n\t\t\tglEnd\n\t\tEndIf\n\tEnd Method\n\t\n\tMethod RenderTerrain(terrain:TTerrain)\n\t\n\t\tglDisableClientState GL_TEXTURE_COORD_ARRAY\n\t\tFor Local i=0 To 7\n\t\t\tLocal texture:TTexture=terrain._brush._texture[i]\n\t\t\tIf texture=Null Continue\n\t\t\tglEnableClientState(GL_TEXTURE_COORD_ARRAY)\n\t\t\tglClientActiveTextureARB(GL_TEXTURE0+i)\n\t\t\tglTexCoordPointer(2,GL_FLOAT,20,terrain._data)\n\t\tNext\n\t\t\n\t\tglEnableClientState GL_VERTEX_ARRAY\n\t\tglDisableClientState GL_COLOR_ARRAY\n\t\tglDisableClientState GL_NORMAL_ARRAY\n\t\t\n\t\tglVertexPointer(3,GL_FLOAT, 20, terrain._data+2)\n\t\tglDrawArrays(GL_TRIANGLES, 0, 3*terrain._count)\n\t\t\n\t\tglEnableClientState GL_VERTEX_ARRAY\n\t\tglEnableClientState GL_COLOR_ARRAY \n\t\tglEnableClientState GL_NORMAL_ARRAY \n\tEnd Method\n\t\n\tMethod RenderBSPTree(tree:TBSPTree)\n\t\tLocal node:TBSPNode=tree.Node\n\t\tIf node=Null Return\n\t\tLocal triangles\n\t\ttriangles:+RenderBSPTree(node.In)\t\t\n\t\t\n\t\tFor Local poly:TBSPPolygon=EachIn node.On\n\t\t\tglBegin GL_POLYGON\n\t\t\tglNormal3f poly.Plane.x,poly.Plane.y,poly.Plane.z\n\t\t\tFor Local i=0 To poly.Count()-1\n\t\t\t\tglVertex3f poly.Point[i].x,poly.Point[i].y,poly.Point[i].z\n\t\t\tNext\n\t\t\ttriangles:+poly.Count()-2\n\t\t\tglEnd\n\t\tNext\t\n\t\t\n\t\ttriangles:+RenderBSPTree(node.Out)\n\t\tReturn triangles\n\tEnd Method\n\n\tMethod UpdateTextureRes:TGLTextureRes(frame:TTextureFrame,flags)\n\t\tIf frame=Null Return Null\n\t\t\n\t\tLocal glres:TGLTextureRes=TGLTextureRes(frame._res)\n\t\tIf glres=Null\n\t\t\tglres=New TGLTextureRes\n\t\t\tframe._res=glres\n\t\t\tframe._updateres=True\n\t\tEndIf\t\t\n\t\tIf Not frame._updateres Return glres\n\t\t\n\t\tIf glres._id=0 glGenTextures(1,Varptr glres._id)\n\t\tBindTexture 0,glres._id\n\t\tLocal pixmap:TPixmap=frame._pixmap\n\t\tgluBuild2DMipmaps(GL_TEXTURE_2D,GL_RGBA8,pixmap.width,pixmap.height,GL_BGRA,GL_UNSIGNED_BYTE,pixmap.pixels)\n\t\t\n\t\tframe._updateres=0\n\t\tReturn glres\n\tEnd Method\n\t\n\tMethod UpdateSurfaceRes:TGLSurfaceRes(surface:TSurface)\n\t\tLocal res:TGLSurfaceRes=TGLSurfaceRes(surface._res)\n\t\tIf res=Null res=New TGLSurfaceRes;surface._res=res\n\t\tIf surface._reset=0 Return res\n\t\t\n\t\tIf res._vbo[0]=0 glGenBuffersARB(4,res._vbo)\n\t\n\t\tIf surface._reset=-1 Then surface._reset=1|2|4|8|16|32|64|128|256\n\t\n\t\tIf surface._reset&1 UploadVertexBuffer res._vbo[0],surface._vertexpos\n\t\tIf surface._reset&2 UploadVertexNormals res._vbo[1],surface._vertexnml\n\t\tIf surface._reset&4 UploadVertexBuffer res._vbo[2],surface._vertexclr\n\t\tIf surface._reset&8\n\t\t\tglBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB,res._vbo[3])\n\t\t\tglBufferDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB,surface._triangle.length*4,surface._triangle,GL_STATIC_DRAW_ARB)\n\t\tEndIf\n\t\t\n\t\tFor Local i=0 To surface._vertextex.length-1\n\t\t\tIf res._vbo[4+i]=0 glGenBuffersARB(1,Varptr res._vbo[4+i])\n\t\t\tIf surface._reset&Int(2^(4+i)) UploadVertexBuffer res._vbo[4+i],surface._vertextex[i]\n\t\tNext\t\n\t\t\n\t\tres._trianglecnt=surface._trianglecnt\n\t\tres._vertexcnt=surface._vertexcnt\t\t\n\t\tsurface._reset=0\t\t\n\t\tReturn res\n\tEnd Method\n\t\n\tMethod MergeSurfaceRes:TGLSurfaceRes(base:TSurface,animation:TSurface,data)\n\t\tIf animation=Null Return UpdateSurfaceRes(base)\n\t\tLocal res_base:TGLSurfaceRes=UpdateSurfaceRes(base)\n\t\tLocal res_anim:TGLSurfaceRes=UpdateSurfaceRes(animation)\n\t\tLocal res:TGLSurfaceRes=res_base.Copy()\n\t\tres._vbo[0]=res_anim._vbo[0]\n\t\tReturn res\n\tEnd Method\n\t\n\tMethod UploadVertexBuffer(vbo,data#[])\n\t\tglBindBufferARB(GL_ARRAY_BUFFER_ARB,vbo)\n\t\tglBufferDataARB(GL_ARRAY_BUFFER_ARB,data.length*4,data,GL_STATIC_DRAW_ARB)\n\tEnd Method\n\t\n\tMethod UploadVertexNormals(vbo,data#[])\n\t\tglBindBufferARB(GL_ARRAY_BUFFER_ARB,vbo)\n\t\tglBufferDataARB(GL_ARRAY_BUFFER_ARB,data.length*4,data,GL_STATIC_DRAW_ARB)\n\tEnd Method\nEnd Type\n\nType TGLCaps Extends TCaps\n\tField Extensions$[]\n\t\n\tMethod HasExtension(ext$)\n\t\tFor Local extension$=EachIn Extensions\n\t\t\tIf extension.Find(ext)<>-1 Return True\n\t\tNext\n\t\tReturn False \n\tEnd Method\n\t\n\tMethod Copy:TGLCaps()\n\t\tLocal caps:TGLCaps=New TGLCaps\n\t\tcaps.CopyBase(Self)\n\t\tcaps.Extensions=Extensions[..]\n\t\tReturn caps\t\t\n\tEnd Method\nEnd Type\n\nType TGLSurfaceRes Extends TSurfaceRes\n\tField _vbo[12]\n\tField _texcoord\n\t\n\tMethod Copy:TGLSurfaceRes()\n\t\tLocal res:TGLSurfaceRes=New TGLSurfaceRes\n\t\tres._vertexcnt=_vertexcnt;res._trianglecnt=_trianglecnt\n\t\tres._vbo=_vbo[..]\n\t\tres._texcoord=_texcoord\n\t\tReturn res\n\tEnd Method\nEnd Type\n\nType TGLTextureRes Extends TTextureRes\n\tField _id\nEnd Type\n\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GLMaxB3DDriver:TGLMaxB3DDriver()\n\tIf GLMax2DExDriver()\n\t\tGlobal driver:TGLMaxB3DDriver=New TGLMaxB3DDriver\n\t\tdriver._parent=GLMax2DExDriver()\n\t\tReturn driver\n\tEnd If\nEnd Function\n\nRem\n\tbbdoc: Utility function that sets the MaxB3D GL driver and calls Graphics.\nEnd Rem\nFunction GLGraphics3D:TGraphics(width,height,depth=0,hertz=60,flags=0)\n\tSetGraphicsDriver GLMaxB3DDriver(),GRAPHICS_BACKBUFFER|GRAPHICS_DEPTHBUFFER\n\tReturn Graphics(width,height,depth,hertz,flags)\nEnd Function\n\nLocal driver:TGLMaxB3DDriver=GLMaxB3DDriver()\nIf driver SetGraphicsDriver driver,GRAPHICS_BACKBUFFER|GRAPHICS_DEPTHBUFFER\n","old_contents":"\nStrict\n\nRem\n\tbbdoc: OpenGL 1.1 driver for MaxB3D\nEnd Rem\nModule MaxB3D.GLDriver\nModuleInfo \"Author: Kevin Primm\"\nModuleInfo \"License: MIT\"\n\nImport MaxB3D.Core\nImport Prime.GLMax2DEx\n\nPrivate\nFunction ModuleLog(message$)\n\tTMaxB3DLogger.Write \"gldriver\",message\nEnd Function\n\nPublic\n\nGlobal GL_LIGHT[]=[GL_LIGHT0,GL_LIGHT1,GL_LIGHT2,GL_LIGHT3,GL_LIGHT4,GL_LIGHT5,GL_LIGHT6,GL_LIGHT7]\n\nType TGLMaxB3DDriver Extends TMaxB3DDriver\n\tField _currentdata:TMaxB3DShaderData= New TMaxB3DShaderData\n\t\n\tMethod SetGraphics(g:TGraphics)\n\t\tSuper.SetGraphics g\n\t\tIf g<>Null Startup\n\tEnd Method\n\t\n\tFunction BindTexture(index,tex)\n\t\tIf index=-1\n\t\t\tFor Local i=0 To 7\n\t\t\t\tBindTexture i,tex\n\t\t\tNext\n\t\t\tReturn\n\t\tEndIf\n\t\tGlobal currenttexture[] = [-1,-1,-1,-1,-1,-1,-1,-1]\n\t\tIf tex<>currenttexture[index]\n\t\t\tglBindTexture GL_TEXTURE_2D,tex\n\t\t\tcurrenttexture[index]=tex\n\t\tEndIf\n\tEnd Function\n\t\n\tMethod Startup()\n\t\tGlobal _firsttime=True\n\t\tIf _firsttime\n\t\t\tLocal caps:TGLCaps=TGLCaps(_caps)\n\t\t\tModuleLog \"Initializing GL driver\"\n\t\t\tModuleLog \"Vendor: \"+String.FromCString(Byte Ptr(glGetString(GL_VENDOR)))\n\t\t\tModuleLog \"Renderer: \"+String.FromCString(Byte Ptr(glGetString(GL_RENDERER))) \n\t\t\tModuleLog \"Version: \"+String.FromCString(Byte Ptr(glGetString(GL_VERSION)))\n\t\t\tModuleLog \"Extensions supported: \"+\" \".Join(caps.Extensions)\n\t\t\tEndMax2D \n\t\t\t_firsttime=False\t\t\t\n\t\tEndIf\t\t\n\t\tEnableStates\n\tEnd Method\n\t\n\tFunction EnableStates()\t\n\t\tglEnable GL_LIGHTING\n\t\tglEnable GL_DEPTH_TEST\n\t\tglEnable GL_CULL_FACE\n\t\tglEnable GL_SCISSOR_TEST\n\t\t\n\t\tglEnable GL_NORMALIZE\n\t\t\n\t\tglEnableClientState GL_VERTEX_ARRAY\n\t\tglEnableClientState GL_COLOR_ARRAY\n\t\tglEnableClientState GL_NORMAL_ARRAY\n\t\t\n\t\tglFrontFace GL_CW\n\t\t\n\t\tglLightModeli GL_LIGHT_MODEL_COLOR_CONTROL,GL_SEPARATE_SPECULAR_COLOR\n\t\tglLightModeli GL_LIGHT_MODEL_LOCAL_VIEWER,GL_TRUE\n\t\n\t\tglClearDepth 1.0\n\t\tglDepthFunc GL_LEQUAL\n\t\tglHint GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST\n\t\n\t\tglAlphaFunc GL_GEQUAL,0.5\n\t\t\n\t\tBindTexture -1,0\n\tEnd Function\t\n\t\n\tMethod MakeBuffer:TBuffer(src:Object,width,height,flags)\n\t\tLocal buffer:TBuffer\n\t\tSelect True\n\t\tCase TTextureFrame(src)<>Null\n\t\t\tbuffer=TGLBuffer(TTextureFrame(src)._buffer)\n\t\t\tIf buffer=Null\n\t\t\t\tLocal res:TGLTextureRes=UpdateTextureRes(TTextureFrame(src),0)\n\t\t\t\tbuffer=TGLMax2DExDriver(_parent).MakeGLBuffer(res._id,width,height,flags)\n\t\t\tEndIf\n\t\tDefault\n\t\t\tbuffer=TMax2DExDriver(_parent).MakeBuffer(src,width,height,flags)\n\t\tEnd Select\n\t\tReturn buffer\n\tEnd Method\n\t\n\tMethod Abbr$()\n\t\tReturn \"gl\"\n\tEnd Method\n\t\n\tMethod GetCaps:TCaps()\n\t\tLocal caps:TGLCaps=New TGLCaps\n\t\tcaps.Extensions=String.FromCString(glGetString(GL_EXTENSIONS)).Split(\" \")\n\t\tIf caps.HasExtension(\"GL_ARB_point_sprite\")<>-1\n\t\t\tcaps.PointSprites=True\n\t\t\tglGetFloatv GL_POINT_SIZE_MAX_ARB, Varptr caps.MaxPointSize\n\t\tEndIf\n\t\tReturn caps\n\tEnd Method\n\t\n\tMethod SetMax2D(enable)\n\t\tIf enable\n\t\t\tglPopClientAttrib\n\t\t\tglPopAttrib\n\t\t\tIf _shaderdriver _shaderdriver.Use(Null,Null)\t\n\t\t\tTGLMax2DExDriver(_parent).ResetGLContext _current\n\t\t\tglMatrixMode GL_TEXTURE\n\t\t\tglLoadIdentity\n\t\t\tglMatrixMode GL_COLOR\t\n\t\t\tglPopMatrix\t\t\t\t\t\n\t\tElse\t\t\t\n\t\t\tglPushAttrib GL_ALL_ATTRIB_BITS\n\t\t\tglPushClientAttrib GL_CLIENT_ALL_ATTRIB_BITS\n\t\t\tglMatrixMode GL_TEXTURE\n\t\t\tglPushMatrix\n\t\t\tglMatrixMode GL_COLOR\n\t\t\tglPushMatrix \n\t\t\t\n\t\t\tEnableStates()\n\t\tEndIf\n\tEnd Method\t\n\tMethod SetCamera(camera:TCamera, config:TWorldConfig)\n\t\tIf config.Dither\n\t\t\tglEnable GL_DITHER\n\t\tElse\n\t\t\tglDisable GL_DITHER\n\t\tEndIf\n\t\t\n\t\tLocal vy#=config.Height-camera._viewheight-camera._viewy\n\t\tglViewport(camera._viewx,vy,camera._viewwidth,camera._viewheight)\n\t\tglScissor(camera._viewx,vy,camera._viewwidth,camera._viewheight)\n\t\tglClearColor(camera._brush._r,camera._brush._g,camera._brush._b,1.0)\n\t\t\n\t\tIf camera._clsmode&CLSMODE_COLOR And camera._clsmode&CLSMODE_DEPTH\n\t\t\tglDepthMask GL_TRUE\n\t\t\tglClear GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT\n\t\tElse\n\t\t\tIf camera._clsmode&CLSMODE_COLOR\n\t\t\t\tglClear GL_COLOR_BUFFER_BIT\n\t\t\tElse\n\t\t\t\tIf camera._clsmode&CLSMODE_DEPTH\n\t\t\t\t\tglDepthMask GL_TRUE\n\t\t\t\t\tglClear GL_DEPTH_BUFFER_BIT\n\t\t\t\tEndIf\n\t\t\tEndIf\n\t\tEndIf\n\t\t\n\t\tIf camera._fogmode<>FOGMODE_NONE\n\t\t\tglEnable GL_FOG\n\t\t\tglFogi GL_FOG_MODE,GL_LINEAR\n\t\t\tglFogf GL_FOG_START,camera._fognear\n\t\t\tglFogf GL_FOG_END,camera._fogfar\n\t\t\tLocal rgb#[]=[camera._fogr,camera._fogg,camera._fogb]\n\t\t\tglFogfv GL_FOG_COLOR,rgb\n\t\tElse\n\t\t\tglDisable GL_FOG\n\t\tEndIf\n\t\t\n\t\tcamera.UpdateMatrices()\n\t\t\n\t\tglMatrixMode GL_PROJECTION\n\t\tglLoadMatrixf camera._projection.ToPtr()\t\n\t\tglMatrixMode GL_MODELVIEW\t\t\n\t\tglLoadMatrixf camera._modelview.ToPtr()\n\n\t\t' Temporary hack\n\t\tglGetFloatv GL_PROJECTION_MATRIX,camera._projection._m\t\t\n\t\tcamera._frustum=TFrustum.Extract(camera._modelview,camera._projection)\n\tEnd Method\t\n\t\n\tMethod SetLight(light:TLight,index)\n\t\tIf light=Null\n\t\t\tglDisable GL_LIGHT[index]\n\t\t\tReturn\n\t\tElse\n\t\t\tIf light._hidden=True \n\t\t\t\tglDisable GL_LIGHT[index]\n\t\t\t\tReturn False\n\t\t\tEndIf\n\t\tEndIf\n\t\t\n\t\tglEnable GL_LIGHT[index]\n\t\t\n\t\tglPushMatrix\n\t\tglMultMatrixf light.GetMatrix(True).ToPtr()\n\t\t\n\t\tLocal white_light#[]=[1.0,1.0,1.0,1.0]\n\t\tglLightfv GL_LIGHT[index],GL_SPECULAR,white_light\n\t\t\n\t\tLocal z#=1.0\n\t\tLocal w#=0.0\n\t\tIf light._mode>LIGHT_DIRECTIONAL\n\t\t\tz=0.0\n\t\t\tw=1.0\n\t\tEndIf\n\t\t\n\t\tLocal rgba#[]=[light._brush._r,light._brush._g,light._brush._b,1.0]\n\t\tLocal pos#[]=[0.0,0.0,-z,w]\n\t\t\n\t\tglLightfv GL_LIGHT[index],GL_POSITION,pos\n\t\tglLightfv GL_LIGHT[index],GL_DIFFUSE,rgba\n\t\n\t\tIf light._mode<>LIGHT_DIRECTIONAL\n\t\t\tLocal light_range#[]=[0.0]\n\t\t\tLocal range#[]=[light._range]\n\t\t\tglLightfv GL_LIGHT[index],GL_CONSTANT_ATTENUATION,light_range\n\t\t\tglLightfv GL_LIGHT[index],GL_LINEAR_ATTENUATION,range\n\t\tEndIf\t\t\n\n\t\tIf light._mode=LIGHT_SPOT\t\t\n\t\t\tLocal dir#[]=[0.0,0.0,-1.0]\n\t\t\tLocal outer#[]=[light._outer\/2.0]\n\t\t\tLocal exponent#[]=[10.0]\t\n\t\t\tglLightfv GL_LIGHT[index],GL_SPOT_DIRECTION,dir\n\t\t\tglLightfv GL_LIGHT[index],GL_SPOT_CUTOFF,outer\n\t\t\tglLightfv GL_LIGHT[index],GL_SPOT_EXPONENT,exponent\n\t\tEndIf\n\t\t\n\t\tglPopMatrix\n\tEnd Method\n\t\n\tMethod SetBrush(brush:TBrush,hasalpha,config:TWorldConfig)\n\t\tLocal alpha_test\n\t\t\t\n\t\tLocal ambient#[]=[config.AmbientRed\/255.0,config.AmbientGreen\/255.0,config.AmbientBlue\/255.0]\t\t\t\n\t\t\t\t\t\n\t\tIf hasalpha\n\t\t\tglEnable GL_BLEND\n\t\t\tglDepthMask GL_FALSE\n\t\tElse\n\t\t\tglDisable GL_BLEND\n\t\t\tglDepthMask GL_TRUE\n\t\tEndIf\n\t\t\n\t\tSelect brush._blend\n\t\t\tCase BLEND_NONE,BLEND_ALPHA\n\t\t\t\tglBlendFunc GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA\n\t\t\tCase BLEND_MULTIPLY\n\t\t\t\tglBlendFunc GL_DST_COLOR,GL_ZERO\n\t\t\tCase BLEND_ADD\n\t\t\t\tglBlendFunc GL_SRC_ALPHA,GL_ONE\n\t\tEnd Select\n\t\t\n\t\tIf brush._fx&FX_FULLBRIGHT\n\t\t\tambient[0]=1.0\n\t\t\tambient[1]=1.0\n\t\t\tambient[2]=1.0\t\t\n\t\tEndIf\n\t\t\n\t\tIf brush._fx&FX_VERTEXCOLOR\n\t\t\tglEnable GL_COLOR_MATERIAL\n\t\tElse\n\t\t\tglDisable GL_COLOR_MATERIAL\n\t\tEndIf\n\t\t\n\t\tIf brush._fx&FX_FLATSHADED\n\t\t\tglShadeModel GL_FLAT\n\t\tElse\n\t\t\tglShadeModel GL_SMOOTH\n\t\tEndIf\n\n\t\tIf brush._fx&FX_NOFOG\n\t\t\tglDisable GL_FOG\n\t\tEndIf\n\t\t\n\t\tIf brush._fx&FX_NOCULLING\n\t\t\tglDisable GL_CULL_FACE\n\t\tElse\n\t\t\tglEnable GL_CULL_FACE\n\t\tEndIf\n\t\t\n\t\tIf brush._fx&FX_WIREFRAME Or config.Wireframe\n\t\t\tglPolygonMode GL_FRONT_AND_BACK,GL_LINE\n\t\tElse\n\t\t\tglPolygonMode GL_FRONT_AND_BACK,GL_FILL\n\t\tEndIf\t\t\t\n\t\t\n\t\tLocal no_mat#[]=[0.0,0.0]\n\t\tLocal mat_ambient#[]=[brush._r,brush._g,brush._b,brush._a]\n\t\tLocal mat_diffuse#[]=[brush._r,brush._g,brush._b,brush._a]\n\t\tLocal mat_specular#[]=[brush._shine,brush._shine,brush._shine,brush._shine]\n\t\tLocal mat_shininess#[]=[100.0]\n\t\t\t\n\t\tglMaterialfv GL_FRONT,GL_AMBIENT,mat_ambient\n\t\tglMaterialfv GL_FRONT,GL_DIFFUSE,mat_diffuse\n\t\tglMaterialfv GL_FRONT,GL_SPECULAR,mat_specular\n\t\tglMaterialfv GL_FRONT,GL_SHININESS,mat_shininess\n\t\tglLightModelfv GL_LIGHT_MODEL_AMBIENT,ambient\n\t\t\n\t\tFor Local i=0 To 7\n\t\t\tglActiveTextureARB GL_TEXTURE0+i\n\n\t\t\tLocal texture:TTexture=brush._texture[i]\n\t\t\tIf texture=Null Or texture._blend=BLEND_NONE\n\t\t\t\tglDisable GL_TEXTURE_2D\n\t\t\t\tBindTexture i,0\n\t\t\t\tContinue\n\t\t\tEndIf\n\t\t\t\n\t\t\tLocal texres:TGLTextureRes=TGLTextureRes(UpdateTextureRes(texture._frame[brush._textureframe[i]],texture._flags))\n\t\t\t\n\t\t\tglEnable GL_TEXTURE_2D\n\t\t\t\n\t\t\tBindTexture i,texres._id\t\n\t\t\t\n\t\t\tglMatrixMode GL_TEXTURE\n\t\t\tglLoadIdentity\n\t\t\tglTranslatef texture._px,-texture._py,0\n\t\t\tglScalef -texture._sx,texture._sy,1\n\t\t\t\n\t\t\talpha_test :| texture._flags&TEXTURE_ALPHA Or texture._flags&TEXTURE_MASKED\n\t\t\n\t\t\tIf texture._flags&TEXTURE_MIPMAP\n\t\t\t\tglTexParameteri GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR\n\t\t\t\tglTexParameteri GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_LINEAR\n\t\t\tElse\n\t\t\t\tglTexParameteri GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR\n\t\t\t\tglTexParameteri GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR\n\t\t\tEndIf\n\t\t\t\n\t\t\tIf texture._flags&TEXTURE_CLAMPU\n\t\t\t\tglTexParameteri GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_CLAMP_TO_EDGE\n\t\t\tElse\t\t\t\t\t\t\n\t\t\t\tglTexParameteri GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_REPEAT\n\t\t\tEndIf\n\t\t\t\n\t\t\tIf texture._flags&TEXTURE_CLAMPV\n\t\t\t\tglTexParameteri GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_CLAMP_TO_EDGE\n\t\t\tElse\n\t\t\t\tglTexParameteri GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_REPEAT\n\t\t\tEndIf\n\t\n\t\t\tIf texture._flags&TEXTURE_SPHEREMAP\t\t\t\t\n\t\t\t\tglEnable GL_TEXTURE_GEN_S\n\t\t\t\tglEnable GL_TEXTURE_GEN_T\n\t\t\t\tglTexGeni GL_S,GL_TEXTURE_GEN_MODE,GL_SPHERE_MAP\n\t\t\t\tglTexGeni GL_T,GL_TEXTURE_GEN_MODE,GL_SPHERE_MAP\n\t\t\tElse\n\t\t\t\tglDisable GL_TEXTURE_GEN_S\n\t\t\t\tglDisable GL_TEXTURE_GEN_T\n\t\t\tEndIf\n\n\t\t\tSelect texture._blend\n\t\t\tCase BLEND_NONE glTexEnvf(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_REPLACE)\n\t\t\tCase BLEND_ALPHA \tglTexEnvf(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_MODULATE)\n\t\t\tCase BLEND_MULTIPLY glTexEnvf(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_MODULATE)\n\t\t\t'Case BLEND_MULTIPLY glTexEnvf(GL_TEXTURE_ENV,GL_COMBINE_RGB_EXT,GL_MODULATE)\n\t\t\tCase BLEND_ADD glTexEnvf(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_ADD)\n\t\t\tCase BLEND_DOT3\n\t\t\t\tglTexEnvf GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT\n\t\t\t\tglTexEnvf GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_DOT3_RGB_EXT\n\t\t\tCase BLEND_MULTIPLY2\n\t\t\t\tglTexEnvi GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_COMBINE\n\t\t\t\tglTexEnvi GL_TEXTURE_ENV,GL_COMBINE_RGB,GL_MODULATE\n\t\t\t\tglTexEnvi GL_TEXTURE_ENV,GL_RGB_SCALE,2.0\n\t\t\tDefault glTexEnvf GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_MODULATE\n\t\t\tEnd Select\t\t\t\n\t\tNext\t\n\t\t\n\t\tIf alpha_test\n\t\t\tglEnable GL_ALPHA_TEST\n\t\tElse\n\t\t\tglDisable GL_ALPHA_TEST\n\t\tEndIf\n\t\t\t\t\n\t\tIf _shaderdriver _shaderdriver.Use(brush._shader,_currentdata)\t\n\tEnd Method\n\t\n\tMethod RenderSurface(resource:TSurfaceRes,brush:TBrush)\n\t\tLocal res:TGLSurfaceRes=TGLSurfaceRes(resource)\t\n\t\t\n\t\tFor Local i=0 To 7\n\t\t\tglClientActiveTextureARB GL_TEXTURE0+i\n\t\t\t\n\t\t\tLocal texture:TTexture=brush._texture[i]\n\t\t\tIf texture=Null \n\t\t\t\tglDisableClientState GL_TEXTURE_COORD_ARRAY\n\t\t\t\tContinue\n\t\t\tEndIf\n\t\t\t\n\t\t\tglEnableClientState GL_TEXTURE_COORD_ARRAY\n\t\t\tglBindBufferARB GL_ARRAY_BUFFER_ARB,res._vbo[4+texture._coords]\n\t\t\tglTexCoordPointer 2,GL_FLOAT,0,Null\n\t\tNext\n\t\t\n\t\tglBindBufferARB GL_ARRAY_BUFFER_ARB,res._vbo[0]\n\t\tglVertexPointer 3,GL_FLOAT,0,Null\n\t\t\n\t\tglBindBufferARB GL_ARRAY_BUFFER_ARB,res._vbo[1]\n\t\tglNormalPointer GL_FLOAT,0,Null\n\t\t\n\t\tglBindBufferARB GL_ARRAY_BUFFER_ARB,res._vbo[2]\n\t\tglColorPointer 4,GL_FLOAT,0,Null\n\t\n\t\tglBindBufferARB GL_ELEMENT_ARRAY_BUFFER_ARB,res._vbo[3]\n\t\tglDrawElements GL_TRIANGLES,res._trianglecnt*3,GL_UNSIGNED_INT,Null\n\t\t\n\t\tReturn res._trianglecnt\n\tEnd Method\n\t\n\tMethod BeginEntityRender(entity:TEntity)\t\t\n\t\tIf entity._order<>0\n\t\t\tglDisable GL_DEPTH_TEST\n\t\t\tglDepthMask GL_FALSE\n\t\tElse\n\t\t\tglEnable GL_DEPTH_TEST\n\t\t\tglDepthMask GL_TRUE\n\t\tEndIf\n\t\t\n\t\tglMatrixMode GL_MODELVIEW\n\t\tglPushMatrix\n\t\tglMultMatrixf entity.GetMatrix(True,False).ToPtr()\n\t\t\n\t\tGlobal matrix:TMatrix=New TMatrix\n\t\tglGetFloatv GL_MODELVIEW_MATRIX,matrix._m\n\tEnd Method\n\tMethod EndEntityRender(entity:TEntity)\n\t\tglMatrixMode GL_MODELVIEW\n\t\tglPopMatrix\n\tEnd Method\n\t\n\tMethod RenderFlat(flat:TFlat)\n\t\tLocal x#,y#,z#\n\t\tflat.GetScale x,y,z,True\n\t\t\n\t\tglBegin GL_QUADS\n\t\t\tglNormal3f 0,1,0\n\t\t\tglTexCoord2f 0,0\n\t\t\tglVertex3f -1,0, 1\n\t\t\tglTexCoord2f x,0\t\n\t\t\tglVertex3f 1, 0, 1\n\t\t\tglTexCoord2f x,z\n\t\t\tglVertex3f 1, 0, -1\n\t\t\tglTexCoord2f 0,z\n\t\t\tglVertex3f -1,0, -1\n\t\tglEnd\n\t\tReturn 2\n\tEnd Method\n\t\n\tMethod RenderSprite(sprite:TSprite)\n\t\tIf False\n\t\t\tglPointParameterfvARB GL_POINT_DISTANCE_ATTENUATION_ARB, [0.0, 0.0, 1.0]\n\t\t\t\n\t\t\tglPointSize 1.0\n\t\t\t\n\t\t\tglPointParameterfARB GL_POINT_FADE_THRESHOLD_SIZE_ARB,60.0\n\t\t\tglPointParameterfARB GL_POINT_SIZE_MIN_ARB,0.0\n\t\t\tglPointParameterfARB GL_POINT_SIZE_MAX_ARB,9999.0\n\t\t\t\n\t\t\tglTexEnvf GL_POINT_SPRITE_ARB,GL_COORD_REPLACE_ARB,GL_TRUE\n\t\t\t\n\t\t\tglEnable GL_POINT_SPRITE_ARB\n\t\t\t\n\t\t\tglBegin GL_POINTS\t\t\t\n\t\t\tglVertex3f 0,0,0\n\t\t\tglEnd\n\t\t\t\n\t\t\tglDisable GL_POINT_SPRITE_ARB\n\t\tElse\n\t\t\tglBegin GL_QUADS\n\t\t\t\tglNormal3f 0,0,-1\n\t\t\t\tglTexCoord2f 0,1\n\t\t\t\tglVertex3f 1, -1, 0\t\t\t\n\t\t\t\tglTexCoord2f 0,0\n\t\t\t\tglVertex3f 1, 1, 0\t\t\t\n\t\t\t\tglTexCoord2f 1,0\n\t\t\t\tglVertex3f -1,1, 0\t\t\t\n\t\t\t\tglTexCoord2f 1,1\n\t\t\t\tglVertex3f -1,-1, 0\n\t\t\tglEnd\n\t\tEndIf\n\tEnd Method\n\t\n\tMethod RenderTerrain(terrain:TTerrain)\n\t\n\t\tglDisableClientState GL_TEXTURE_COORD_ARRAY\n\t\tFor Local i=0 To 7\n\t\t\tLocal texture:TTexture=terrain._brush._texture[i]\n\t\t\tIf texture=Null Continue\n\t\t\tglEnableClientState(GL_TEXTURE_COORD_ARRAY)\n\t\t\tglClientActiveTextureARB(GL_TEXTURE0+i)\n\t\t\tglTexCoordPointer(2,GL_FLOAT,20,terrain._data)\n\t\tNext\n\t\t\n\t\tglEnableClientState GL_VERTEX_ARRAY\n\t\tglDisableClientState GL_COLOR_ARRAY\n\t\tglDisableClientState GL_NORMAL_ARRAY\n\t\t\n\t\tglVertexPointer(3,GL_FLOAT, 20, terrain._data+2)\n\t\tglDrawArrays(GL_TRIANGLES, 0, 3*terrain._count)\n\t\t\n\t\tglEnableClientState GL_VERTEX_ARRAY\n\t\tglEnableClientState GL_COLOR_ARRAY \n\t\tglEnableClientState GL_NORMAL_ARRAY \n\tEnd Method\n\t\n\tMethod RenderBSPTree(tree:TBSPTree)\n\t\tLocal node:TBSPNode=tree.Node\n\t\tIf node=Null Return\n\t\tLocal triangles\n\t\ttriangles:+RenderBSPTree(node.In)\t\t\n\t\t\n\t\tFor Local poly:TBSPPolygon=EachIn node.On\n\t\t\tglBegin GL_POLYGON\n\t\t\tglNormal3f poly.Plane.x,poly.Plane.y,poly.Plane.z\n\t\t\tLocal ptA:TVector=poly.Point[0],v0\n\t\t\tFor Local i=1 To poly.Count()-2\n\t\t\t\tLocal ptB:TVector=poly.Point[i],ptC:TVector=poly.Point[i+1]\n\t\t\t\tglVertex3f ptA.x,ptA.y,ptA.z\n\t\t\t\tglVertex3f ptB.x,ptB.y,ptB.z\n\t\t\t\tglVertex3f ptC.x,ptC.y,ptC.z\n\t\t\tNext\n\t\t\ttriangles:+poly.Count()-2\n\t\t\tglEnd\n\t\tNext\t\n\t\t\n\t\ttriangles:+RenderBSPTree(node.Out)\n\t\tReturn triangles\n\tEnd Method\n\n\tMethod UpdateTextureRes:TGLTextureRes(frame:TTextureFrame,flags)\n\t\tIf frame=Null Return Null\n\t\t\n\t\tLocal glres:TGLTextureRes=TGLTextureRes(frame._res)\n\t\tIf glres=Null\n\t\t\tglres=New TGLTextureRes\n\t\t\tframe._res=glres\n\t\t\tframe._updateres=True\n\t\tEndIf\t\t\n\t\tIf Not frame._updateres Return glres\n\t\t\n\t\tIf glres._id=0 glGenTextures(1,Varptr glres._id)\n\t\tBindTexture 0,glres._id\n\t\tLocal pixmap:TPixmap=frame._pixmap\n\t\tgluBuild2DMipmaps(GL_TEXTURE_2D,GL_RGBA8,pixmap.width,pixmap.height,GL_BGRA,GL_UNSIGNED_BYTE,pixmap.pixels)\n\t\t\n\t\tframe._updateres=0\n\t\tReturn glres\n\tEnd Method\n\t\n\tMethod UpdateSurfaceRes:TGLSurfaceRes(surface:TSurface)\n\t\tLocal res:TGLSurfaceRes=TGLSurfaceRes(surface._res)\n\t\tIf res=Null res=New TGLSurfaceRes;surface._res=res\n\t\tIf surface._reset=0 Return res\n\t\t\n\t\tIf res._vbo[0]=0 glGenBuffersARB(4,res._vbo)\n\t\n\t\tIf surface._reset=-1 Then surface._reset=1|2|4|8|16|32|64|128|256\n\t\n\t\tIf surface._reset&1 UploadVertexBuffer res._vbo[0],surface._vertexpos\n\t\tIf surface._reset&2 UploadVertexNormals res._vbo[1],surface._vertexnml\n\t\tIf surface._reset&4 UploadVertexBuffer res._vbo[2],surface._vertexclr\n\t\tIf surface._reset&8\n\t\t\tglBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB,res._vbo[3])\n\t\t\tglBufferDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB,surface._triangle.length*4,surface._triangle,GL_STATIC_DRAW_ARB)\n\t\tEndIf\n\t\t\n\t\tFor Local i=0 To surface._vertextex.length-1\n\t\t\tIf res._vbo[4+i]=0 glGenBuffersARB(1,Varptr res._vbo[4+i])\n\t\t\tIf surface._reset&Int(2^(4+i)) UploadVertexBuffer res._vbo[4+i],surface._vertextex[i]\n\t\tNext\t\n\t\t\n\t\tres._trianglecnt=surface._trianglecnt\n\t\tres._vertexcnt=surface._vertexcnt\t\t\n\t\tsurface._reset=0\t\t\n\t\tReturn res\n\tEnd Method\n\t\n\tMethod MergeSurfaceRes:TGLSurfaceRes(base:TSurface,animation:TSurface,data)\n\t\tIf animation=Null Return UpdateSurfaceRes(base)\n\t\tLocal res_base:TGLSurfaceRes=UpdateSurfaceRes(base)\n\t\tLocal res_anim:TGLSurfaceRes=UpdateSurfaceRes(animation)\n\t\tLocal res:TGLSurfaceRes=res_base.Copy()\n\t\tres._vbo[0]=res_anim._vbo[0]\n\t\tReturn res\n\tEnd Method\n\t\n\tMethod UploadVertexBuffer(vbo,data#[])\n\t\tglBindBufferARB(GL_ARRAY_BUFFER_ARB,vbo)\n\t\tglBufferDataARB(GL_ARRAY_BUFFER_ARB,data.length*4,data,GL_STATIC_DRAW_ARB)\n\tEnd Method\n\t\n\tMethod UploadVertexNormals(vbo,data#[])\n\t\tglBindBufferARB(GL_ARRAY_BUFFER_ARB,vbo)\n\t\tglBufferDataARB(GL_ARRAY_BUFFER_ARB,data.length*4,data,GL_STATIC_DRAW_ARB)\n\tEnd Method\nEnd Type\n\nType TGLCaps Extends TCaps\n\tField Extensions$[]\n\t\n\tMethod HasExtension(ext$)\n\t\tFor Local extension$=EachIn Extensions\n\t\t\tIf extension.Find(ext)<>-1 Return True\n\t\tNext\n\t\tReturn False \n\tEnd Method\n\t\n\tMethod Copy:TGLCaps()\n\t\tLocal caps:TGLCaps=New TGLCaps\n\t\tcaps.CopyBase(Self)\n\t\tcaps.Extensions=Extensions[..]\n\t\tReturn caps\t\t\n\tEnd Method\nEnd Type\n\nType TGLSurfaceRes Extends TSurfaceRes\n\tField _vbo[12]\n\tField _texcoord\n\t\n\tMethod Copy:TGLSurfaceRes()\n\t\tLocal res:TGLSurfaceRes=New TGLSurfaceRes\n\t\tres._vertexcnt=_vertexcnt;res._trianglecnt=_trianglecnt\n\t\tres._vbo=_vbo[..]\n\t\tres._texcoord=_texcoord\n\t\tReturn res\n\tEnd Method\nEnd Type\n\nType TGLTextureRes Extends TTextureRes\n\tField _id\nEnd Type\n\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GLMaxB3DDriver:TGLMaxB3DDriver()\n\tIf GLMax2DExDriver()\n\t\tGlobal driver:TGLMaxB3DDriver=New TGLMaxB3DDriver\n\t\tdriver._parent=GLMax2DExDriver()\n\t\tReturn driver\n\tEnd If\nEnd Function\n\nRem\n\tbbdoc: Utility function that sets the MaxB3D GL driver and calls Graphics.\nEnd Rem\nFunction GLGraphics3D:TGraphics(width,height,depth=0,hertz=60,flags=0)\n\tSetGraphicsDriver GLMaxB3DDriver(),GRAPHICS_BACKBUFFER|GRAPHICS_DEPTHBUFFER\n\tReturn Graphics(width,height,depth,hertz,flags)\nEnd Function\n\nLocal driver:TGLMaxB3DDriver=GLMaxB3DDriver()\nIf driver SetGraphicsDriver driver,GRAPHICS_BACKBUFFER|GRAPHICS_DEPTHBUFFER\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"7290706f68204f11906d2d1c888f0f7809b93978","subject":"library loader","message":"library loader\n","repos":"Leushenko\/blue-moon","old_file":"bluevm.bmx","new_file":"bluevm.bmx","new_contents":"\n' Blue Moon\n' Virtual Machine\n' the VM allocates memory, manages bytecode and machine code, and interfaces between Max and Lua objects\n' alongside the compiler, this more or less forms the toplevel accessible to the user\n\n' due to recursive dependency problems, for the moment a lot of this is Include rather than Import based\n' we'll fix that in post\n\n\nSuperStrict\n\nImport \"bluecompiler.bmx\"\nImport \"blueallocator.bmx\"\nImport \"bluetable.bmx\"\n\nRem\nImport \"blueasm.o\"\t'future project: assembly operators (this is a note, not an implementation)\nExtern\nFunction ADD:Int(s:Stack, b:Bytecode, r:Byte Ptr) = \"ADD2\"\nFunction EQ:Int(s:Stack, b:Bytecode, r:Byte Ptr) = \"EQ2\"\n'... you get the idea\nEnd Extern\nBlueJIT.InitOpTbl()\n'BlueJIT.opTbl[BlueJIT.opc.ADD] = ADD\n'BlueJIT.opTbl[BlueJIT.opc.EQ] = EQ\nEnd Rem\n\nInclude \"bluelibrary.bmx\"\n\n\n' notes:\n' - the structure of a bytecode object is:\n' [ machine code ptr ][ id-offset ][ #k ][ #param ][ #upvar ][ frame sz ][ #instrs ][ vm ][ instructions... ][ upvar table... ][ k table... ]\n' initial fields are all 32b; instructions are each 64b; upvar table is pairs of 32b values (level, pos); k table is NaN-box values\n\n' - the structure of a closure object (actual Lua value representing a function) is:\n' [ bytecode ptr ][ upvar values... ]\n\nType BlueVM\n\tField mem:BlueVMMemory, _ENV:BlueLuaVal\n\tField idMod:Int, funIndex:Bytecode Ptr, _fiSz:Int\n\tField strs:TMap\n\t\n\tMethod New()\n\t\tmem = New BlueVMMemory ; strs = CreateMap()\n\t\t_ENV = NewTable()\t'rebuild on each run?\n\t\tBlueBasicLibrary._Load(Self, _ENV)\n\t'\t_ENV._vm = Null\t'circular dependency (this does mean manipulating _ENV from outside could be problematic; we should probably have property accessors)\n\tEnd Method\n\t\n\t' Load the procedures and constants of a compiled binary into the VM, returning the function representing the program toplevel\n\tMethod LoadObjectCode:BlueLuaVal(code:BlueBinary)\n\t\tLocal buf:Int[] = code.buf\n\t\tLocal fcount:Int = buf[0], kcount:Int = buf[1], ktblpos:Int = buf[2], ktbl:Long[kcount]\n\t\tLocal convert:Byte Ptr(o:Object) = Byte Ptr(BlueJIT.Identity)\n\t\t\n\t\tFor Local k:Int = 0 Until kcount\n\t\t\tLocal koff:Int = buf[ktblpos + k], sz:Int = buf[ktblpos + k + 1] - koff\n\t\t\tIf sz > 2\t'strings have size > 2\n\t\t\t\tLocal length:Double, lp:Int Ptr = Int Ptr(Varptr(length))\n\t\t\t\tlp[0] = buf[koff] ; lp[1] = buf[koff + 1]\n\t\t\t\tLocal s:Byte Ptr = mem.AllocConstant(length, Short Ptr(Varptr(buf[koff + 2])))\n\t\t\t\tktbl[k] = mem.PtrToVal(s, BlueTypeTag.STR)\n\t\t\tElse\n\t\t\t\tLocal d:Double, dp:Int Ptr = Int Ptr(Varptr(d))\n\t\t\t\tdp[0] = buf[koff] ; dp[1] = buf[koff + 1]\n\t\t\t\tDouble Ptr(Varptr(ktbl[k]))[0] = d\n\t\t\tEndIf\n\t\tNext\n\t\t\n\t\tExtendFunIndex(idMod + fcount)\n\t\tFor Local f:Int = 0 Until fcount\n\t\t\tLocal foff:Int = buf[3 + f]\n\t\t\tLocal ic:Int = buf[foff + 1], kc:Int = buf[foff + 2], pc:Int = buf[foff + 3], uc:Int = buf[foff + 5], fsz:Int = buf[foff + 6]\n\t\t\t\n\t\t\tLocal b:Bytecode\n\t\t\tRepeat\n\t\t\t\tLocal bp:Byte Ptr = mem.AllocBytecode(uc + uc Mod 2, kc, ic) ; b = BPtoBC(bp)\n\t\t\tUntil True\n\t\t\tb.idMod = idMod ; b.kcount = kc ; b.pcount = pc ; b.upvars = uc + uc Mod 2\t'round up for alignment\n\t\t\tb.frameSz = mem.STACKFRAMESZ + b.upvars * 8 + fsz * 8 ; b.icount = ic ; b.vm = convert(Self)\n\t\t\t\n\t\t\tLocal ib:Int Ptr = Int Ptr(Byte Ptr(b) + 4) + 8 + 2 * ic\n\t\t\tFor Local u:Int = 0 Until uc\n\t\t\t\tLocal uoff:Int = 7 + u * 2\n\t\t\t\tib[u * 2] = buf[foff + uoff] ; ib[u * 2 + 1] = buf[foff + uoff + 1]\n\t\t\tNext\n\t\t\tIf uc <> b.upvars\t'ensure padding is safe by copying the first one\n\t\t\t\tib[uc * 2] = buf[foff + 7] ; ib[uc * 2 + 1] = buf[foff + 7 + 1]\n\t\t\tEndIf\n\t\t\t\n\t\t\tLocal db:Long Ptr = Long Ptr(ib + 2 * b.upvars)\n\t\t\tFor Local k:Int = 0 Until kc\n\t\t\t\tdb[k] = ktbl[buf[foff + 7 + uc * 2 + k]]\n\t\t\tNext\n\t\t\t\n\t\t\tLocal ioff:Int = 7 + 2 * uc + kc ; ib = Int Ptr(Byte Ptr(b) + BlueJIT.BYTECODE_INC)\n\t\t\t\n\t\t\tFor Local i:Int = 0 Until ic * 2\n\t\t\t\tib[i] = buf[foff + ioff + i]\n\t\t\tNext\n\t\t\t\n\t\t\tb.mcode = BlueJIT.Compile(Self, ib, ic, b) + BlueJIT.PROLOGUESZ\n\t\t\tfunIndex[idMod + f] = b\n\t\tNext\n\t\t\n\t\tidMod :+ fcount\n\t\tReturn New BlueLuaVal\n\tEnd Method\n\t\n\tMethod ExtendFunIndex(sz:Int)\t'hack: BlitzMax has a bug with arrays of extern types! so we need to use C-style arrays for now\n\t\tLocal newFI:Bytecode Ptr = Bytecode Ptr(MemAlloc(sz * 4))\n\t\tIf _fiSz\n\t\t\tFor Local b:Int = 0 Until _fiSz\n\t\t\t\tnewFI[b] = funIndex[b]\n\t\t\tNext\n\t\t\tMemFree(funIndex)\n\t\t\tFor Local b:Int = _fiSz Until sz\n\t\t\t\tnewFI[b] = Null\n\t\t\tNext\n\t\tEndIf\n\t\tfunIndex = newFI ; _fiSz = sz\n\tEnd Method\n\t\n\tMethod CallToLua()\n\tEnd Method\n\t\n\tMethod Error(msg:String)\n\t\tThrow \"[temporary error framework]: \" + msg\n\tEnd Method\n\t\n\tMethod NewTable:BlueLuaVal()\n\t\tLocal t:Byte Ptr = mem.AllocTable(Null), ret:BlueLuaVal = BlueLuaVal.Make(Self)\n\t\tByte Ptr Ptr(Varptr(ret.val))[0] = t ; Int Ptr(Varptr(ret.val))[1] = BlueTypeTag.NANBOX | BlueTypeTag.TBL\n\t\tret._obj = mem.RootObj(t)\n\t\tReturn ret\n\tEnd Method\n\t\n\tMethod ValueFromObject:BlueLuaVal(o:Object)\n\tEnd Method\n\tMethod ValueFromNumber:BlueLuaVal(n:Double)\n\t\tLocal v:BlueLuaVal = New BlueLuaVal\n\t\tDouble Ptr(Varptr(v.val))[0] = n\n\t\tReturn v\n\tEnd Method\n\tMethod ValueFromString:BlueLuaVal(s:String)\n\tEnd Method\n\tMethod ValueFromBinary:BlueLuaVal(b:Byte Ptr)\n\tEnd Method\n\tMethod ValueFromFunction:BlueLuaVal(f:Byte Ptr)\n\t\tLocal v:BlueLuaVal = New BlueLuaVal\n\t\tByte Ptr Ptr(Varptr(v.val))[0] = f\n\t\tInt Ptr(Varptr(v.val))[1] = BlueTypeTag.NANBOX | BlueTypeTag.NATFUN\n\t\tReturn v\n\tEnd Method\n\t\n\tGlobal BPtoBC:Bytecode(p:Byte Ptr) = Byte Ptr(BlueJIT.PointerToExtType)\nEnd Type\n\n'Private\t'may need to open these (in the shared interface?)\nExtern\n\tType Stack\n\t\tField retIP:Byte Ptr, prevBase:Stack, varp:Long Ptr, func:Bytecode, _:Long Ptr, argv:Long Ptr, retv:Long Ptr, argc:Short, retc:Short\n\tEnd Type\n\tType Bytecode\n\t\tField mcode:Byte Ptr, idMod:Int, kcount:Int, pcount:Int, upvars:Int, frameSz:Int, icount:Int, vm:Byte Ptr\n\tEnd Type\nEnd Extern\n'Public\n\nType BlueJIT Final\n\tConst PROLOGUESZ:Int = 25, ISIZE:Int = 5\n\t\n\tGlobal opTbl:Int(s:Stack, b:Bytecode, r:Byte Ptr)[], opc:BlueOpcode\n\tGlobal Prologue:Int[] = [ ..\n\t\t$90, $90, ..\n\t\t$8b, $44, $24, $04, .. 'mov 4(%esp), %eax\n\t\t$89, $44, $24, $f4, .. 'mov %eax, -12(%esp)\n\t\t$c7, $44, $24, $f8, $FF, $FF, $FF, $FF, .. 'movl ########, -8(%esp)\n\t\t$89, $64, $24, $fc, .. 'mov %esp, -4(%esp)\n\t\t$83, $ec, $0c.. 'sub $12, %esp\n\t]\n\t\n\tFunction Compile:Byte Ptr(vm:BlueVM, ins:Byte Ptr, icount:Int, bytecode:Bytecode)\n\t\t?Not x86\n\t\tRuntimeError \"The Blue Moon JIT does not support your platform (x86-32 only at this time)\"\n\t\t?\n\t\tAssert SizeOf(0:Long) = SizeOf(0:Double) And SizeOf(0:Int) = 4 And SizeOf(0:Long) = 8 And SizeOf(Byte Ptr(0)) = 4, ..\n\t\t\t\"assumptions about platform datatype sizes are invalid\"\n\t\t\n\t\tIf opTbl = Null Then InitOpTbl()\n\t\t\n\t\t' compute executable code size\n\t\tLocal codesize:Int = PROLOGUESZ, opPos:Int[icount]\t'since sizes are irregular, looking up offsets is easiest\n\t\tFor Local i:Int = 0 Until icount\n\t\t\topPos[i] = codesize\t'finalized below\n\t\t\tSelect ins[i * 8]\n\t\t\t\tCase opc.SETTAB, opc.GETTAB\n\t\t\t\t\tcodesize :+ ISIZE * 2\n\t\t\t\tDefault\n\t\t\t\t\tcodesize :+ ISIZE\n\t\t\tEnd Select\n\t\tNext\n\t\t\n\t\t' allocate executable space\n\t\tLocal code:Byte Ptr = vm.mem.AllocCodeBlock(codesize)\n\t\t\n\t\t'finalize op offsets se we can look them up\n\t\tFor Local i:Int = 0 Until icount\n\t\t\topPos[i] :+ Int(code)\t'direct to executable space\n\t\tNext\n\t\t\n\t\t' emplace prologue (used for calling in from native only)\n\t\tFor Local p:Int = 0 Until PROLOGUESZ\n\t\t\tcode[p] = Prologue[p]\n\t\tNext\n\t\tByte Ptr Ptr(code + 14)[0] = Byte Ptr(bytecode)\t'replace the ########\n\t\t\n\t\t' epilogue (shared location per-vm, probably already set)\n\t\tvm.mem.returnToNative[0] = $c30cc483\t'add $12, %esp ; ret - i.e. restore the stack to normal\n\t\t\n\t\tLocal ktable:Long Ptr = Long Ptr(ins + 8 * bytecode.icount + 8 * bytecode.upvars)\t'constant table\n\t\t\n\t\t' generate machine code!\n\t\tFor Local i:Int = 0 Until icount\t'emplace opcode calls and supporting bytecode data\n\t\t\tLocal codep:Byte Ptr = Byte Ptr(opPos[i]), bytecodep:Byte Ptr = Byte Ptr(Int(codep) + vm.mem.PAGESZ)\n\t\t\tLocal bi:Int = i * 8, op:Int = ins[bi], ip:Int Ptr = Int Ptr(ins + bi), func:Byte Ptr = opTbl[op]\n\t\t\t\n\t\t\tcodep[0] = $e8\t'call\n\t\t\tByte Ptr Ptr(codep + 1)[0] = func - Int(codep + ISIZE)\n\t\t\t\n\t\t\tbytecodep[0] = ins[bi + 1] ; bytecodep[1] = ins[bi + 2]\t'used by most, may get overwritten\n\t\t\t\n\t\t\tSelect op\n\t\t\t\tCase opc.LOADSI, opc.CLOSURE, opc.RET, opc.POSTCALL\n\t\t\t\t\tInt Ptr(bytecodep + 1)[0] = ip[1]\n\t\t\t\t\t\n\t\t\t\tCase opc.LOADK\n\t\t\t\t\tLong Ptr Ptr(bytecodep + 1)[0] = ktable + ip[1]\n\t\t\t\t\t\n\t\t\t\tCase opc.SETTABSI, opc.GETTABSI\n\t\t\t\t\tShort Ptr(bytecodep)[1] = ip[1]\n\t\t\t\t\t\n\t\t\t\tCase opc.SETTAB, opc.GETTAB\n\t\t\t\t\tcodep[ISIZE] = $90 ; Int Ptr(codep + ISIZE + 1)[0] = $90909090\t'nops; the space is needed in the bytecode\n\t\t\t\t\tLong Ptr Ptr(bytecodep + 2)[0] = ktable + ip[1]\n\t\t\t\t\tLong Ptr Ptr(bytecodep + 2)[1] = Null\t'inline cache space\n\t\t\t\t\t\n\t\t\t\tCase opc.GETUPV\n\t\t\t\t\tIf Int Ptr(ins + icount * 8)[2 * bytecodep[1]] = -1\n\t\t\t\t\t\tByte Ptr Ptr(codep + 1)[0] = Byte Ptr(BlueJIT.GETENV) - Int(codep + ISIZE)\n\t\t\t\t\t\tByte Ptr Ptr(bytecodep + 1)[0] = Varptr(vm._ENV.val)\t'note: doesn't allow _ENV to be changed from Max\n\t\t\t\t\tEndIf\n\t\t\t\t\t\n\t\t\t\tCase opc.CALL\n\t\t\t\t\tShort Ptr(bytecodep)[1] = ip[1]\n\t\t\t\t\t\n\t\t\t\tCase opc.JIF, opc.JNOT\n\t\t\t\t\tInt Ptr(bytecodep + 1)[0] = opPos[i + ip[1]]\n\t\t\t\t\t\n\t\t\t\tCase opc.JMP\n\t\t\t\t\tcodep[0] = $e9\t'use a true jump\n\t\t\t\t\tInt Ptr(codep + 1)[0] = opPos[i + ip[1]] - (opPos[i] + ISIZE)\n\t\t\t\t\t\n\t\t\t\tDefault\t'binary operations A = B op C\n\t\t\t\t\tbytecodep[2] = ip[1]\n\t\t\tEnd Select\n\t\tNext\n\t\t\n\t\tReturn code\n\tEnd Function\n\t\n\t\n\tConst STACKFRAME_INC:Int = BlueVMMemory.STACKFRAMESZ + 4, BYTECODE_INC:Int = BlueVMMemory.BYTECODESZ + 4\n\tConst IP_OFFSET:Int = BlueVMMemory.PAGESZ - ISIZE\n\t\n\t\n\t'note: extern vars must take into account the vtbl offset, so that converting from a typed pointer can be a simple cast (faster)\t\n\t\n\tFunction MOV(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"MOV \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tvarp[rp[0]] = varp[rp[1]]\t'assigning through Double is unsafe as it can corrupt the bit pattern\n\tEnd Function\n\tFunction GETLC(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction SETLC(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"SETLC \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\t'add a write barrier here\n\t\tLong Ptr Ptr(varp + rp[0])[0][0] = varp[rp[1]]\n\tEnd Function\n\tFunction LOADK(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"LOADK \/\/\"\n\t\tLocal rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET, varp:Long Ptr = stk.varp + rp[0], kp:Long Ptr = Long Ptr Ptr(rp + 1)[0]\n\t\tvarp[0] = kp[0]\n\tEnd Function\n\tFunction LOADSI(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"LOADSI \/\/\"\n\t\tLocal rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal val:Int = Int Ptr(rp + 1)[0]\n\t\tDouble Ptr(stk.varp)[rp[0]] = Double(val)\n\tEnd Function\n\tFunction LOADBOOL(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"LOADBOOL \/\/\"\n\t\tLocal rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET, vp:Int Ptr = Int Ptr(stk.varp + rp[0])\n\t\tvp[1] = BlueTypeTag.NANBOX | BlueTypeTag.BOOL\n\t\tvp[0] = Int Ptr(rp + 1)[0]\n\tEnd Function\n\tFunction LOADNIL(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"LOADNIL \/\/\"\n\t\tLocal rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tInt Ptr(stk.varp + rp[0])[1] = BlueTypeTag.NANBOX | BlueTypeTag.NIL\n\tEnd Function\n\t\n\tFunction GETTAB(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t\tPrint \"GETTAB \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET, kp:Long Ptr = Long Ptr Ptr(rp + 2)[0]\n\t\tLocal tabp:Byte Ptr = Byte Ptr Ptr(varp + rp[1])[0]\n\t\t'type check\n\t\tPrint \" tag: \" + Bin(Int Ptr(kp)[1])\n\t\tLocal keyslot:Long Ptr = Null, slot:Long Ptr = BlueTable.GetSlot(tabp, kp[0], Varptr(keyslot))\n\t\tPrint \" slot: \" + Hex(Int(slot))\n\t\tIf (slot = Null) Or (keyslot[0] <> kp[0])\t'not in table; invoke metamethod\n\t\t\t'if keyslot == 1 then it's invalid\n\t\t\tDebugStop\n\t\tElse\n\t\t\tvarp[rp[0]] = slot[0]\n\t\tEndIf\n\tEnd Function\n\tFunction GETTABSI(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction SETTAB(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t\tPrint \"SETTAB \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET, kp:Long Ptr = Long Ptr Ptr(rp + 2)[0]\n\t\tLocal tabp:Byte Ptr = Byte Ptr Ptr(varp + rp[0])[0]\n\t\tPrint \" tag: \" + Bin(Int Ptr(kp)[1])\n\t\tLocal keyslot:Long Ptr = Null, slot:Long Ptr = BlueTable.GetSlot(tabp, kp[0], Varptr(keyslot))\n\t\tPrint \" slot: \" + Hex(Int(slot))\n\t\tIf (slot = Null) Or (keyslot[0] <> kp[0])\t'not in table; invoke metamethod or rawset\n\t\t\t'if keyslot == 1 then it's invalid\n\t\t\tLocal convert:BlueVM(p:Byte Ptr) = Byte Ptr(Identity), vm:BlueVM = convert(bc.vm)\n\t\t\tBlueTable.RawSet(vm.mem, tabp, kp[0], varp[rp[1]])\n\t\tElse\n\t\t\tslot[0] = varp[rp[1]]\n\t\tEndIf\n\tEnd Function\n\tFunction SETTABSI(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t\tPrint \"SETTABSI \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal convert:BlueVM(p:Byte Ptr) = Byte Ptr(Identity), vm:BlueVM = convert(bc.vm)\n\t\tLocal tabp:Byte Ptr = varp + rp[0]\n\t\tPrint \" \" + Short Ptr(rp)[1]\n\t\tLocal key:Long ; Double Ptr(Varptr(key))[0] = Short Ptr(rp)[1]\n\t\tBlueTable.RawSet(vm.mem, Byte Ptr Ptr(tabp)[0], key, varp[rp[1]])\n\tEnd Function\n\tFunction GETTABI(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t\tPrint \"GETTABI \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal tabp:Byte Ptr = varp + rp[1]\n\t\tPrint \" tag: \" + Bin(Int Ptr(varp + rp[2])[1])\n\t\tLocal val:Long = BlueTable.RawGet(Byte Ptr Ptr(tabp)[0], varp[rp[2]])\n\t\tLocal v:Double = Double Ptr(Varptr(val))[0]\n\t\tPrint \" \" + v\n\t\tvarp[rp[0]] = val\n\tEnd Function\n\tFunction SETTABI(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t\tPrint \"SETTABI \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal convert:BlueVM(p:Byte Ptr) = Byte Ptr(Identity), vm:BlueVM = convert(bc.vm)\n\t\tLocal tabp:Byte Ptr = varp + rp[0]\n\t\tPrint \" \" + Double Ptr(varp)[rp[2]] + \" \" + Double Ptr(varp)[rp[1]]\n\t\tPrint \" tag: \" + Bin(Int Ptr(varp + rp[2])[1])\n\t\tBlueTable.RawSet(vm.mem, Byte Ptr Ptr(tabp)[0], varp[rp[2]], varp[rp[1]])\n\tEnd Function\n\tFunction GETUPV(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t\tPrint \"GETUPV \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tPrint \" \" + rp[0] + \" \" + rp[1] + \" \" + rp[2]\n\t\tDebugStop\n\t\tLocal upvp:Byte Ptr Ptr = Byte Ptr Ptr(Byte Ptr(stk) + STACKFRAME_INC), valp:Long Ptr = Long Ptr(upvp[rp[1]])\n\t\tvarp[rp[0]] = valp[0]\n\tEnd Function\n\tFunction GETENV(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\t'\"unlisted\" instruction: GETUPV for _ENV is translated into this at load-time\n\t\tPrint \"GETENV \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tPrint \" \" + rp[0] + \" \" + Hex(Int Ptr(rp + 1)[0])\n\t\t'need a type check\n\t\tvarp[rp[0]] = Long Ptr Ptr(rp + 1)[0][0]\n\tEnd Function\n\tFunction SETUPV(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction NEWTAB(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t\tPrint \"NEWTAB \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal convert:BlueVM(p:Byte Ptr) = Byte Ptr(Identity), vm:BlueVM = convert(bc.vm)\n\t\tLocal tab:Byte Ptr = vm.mem.AllocTable(Null)\n\t\tLocal d:Int Ptr = Int Ptr(varp + rp[0])\n\t\td[0] = Int(tab) ; d[1] = BlueTypeTag.NANBOX | BlueTypeTag.TBL\n\tEnd Function\n\tFunction CLOSURE(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"CLOSURE \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal convert:BlueVM(p:Byte Ptr) = Byte Ptr(Identity), vm:BlueVM = convert(bc.vm)\n\t\tLocal d:Int Ptr = Int Ptr(varp + rp[0])\n\t\tLocal cbytecode:Bytecode = vm.funIndex[Int Ptr(rp + 1)[0]], upvp:Int Ptr = Int Ptr(Byte Ptr(cbytecode) + BYTECODE_INC + 8 * cbytecode.icount)\n\t\tLocal closure:Byte Ptr = vm.mem.AllocClosure(cbytecode, cbytecode.upvars)\t'upvars is always even (alignment)\n\t\t\n\t\t'get upvalues off the stack\n\t\tFor Local u:Int = 0 Until cbytecode.upvars\n\t\t\tIf upvp[2 * u]\n\t\t\t\tByte Ptr Ptr(closure)[2 + u] = Byte Ptr Ptr(Byte Ptr(stk) + STACKFRAME_INC)[upvp[2 * u + 1]]\n\t\t\tElse\n\t\t\t\tByte Ptr Ptr(closure)[2 + u] = Byte Ptr Ptr(varp + upvp[2 * u + 1])[0]\n\t\t\tEndIf\n\t\tNext\n\t\t\n\t\td[0] = Int(closure) ; d[1] = BlueTypeTag.NANBOX | BlueTypeTag.FUN\n\tEnd Function\n\tFunction NEWUPV(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"NEWUPV \/\/\"\n\t\tLocal rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal convert:BlueVM(p:Byte Ptr) = Byte Ptr(Identity), vm:BlueVM = convert(bc.vm)\n\t\tLocal upv:Byte Ptr = vm.mem.AllocObject(8, BlueTypeTag.UPV), d:Int Ptr = Int Ptr(stk.varp + rp[0])\n\t\tLong Ptr(upv)[0] = Long Ptr(d)[0]\t'promote a value if it existed (useful for parameters)\n\t\td[0] = Int(upv) ; d[1] = BlueTypeTag.NANBOX | BlueTypeTag.UPV\n\tEnd Function\n\t\n\tFunction ADD(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t\tPrint \"ADD \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal d:Double Ptr = Double Ptr(varp + rp[0])\n\t\tLocal r:Int Ptr = Int Ptr(varp + rp[1]), l:Int Ptr = Int Ptr(varp + rp[2])\n\t\tIf l[1] & BlueTypeTag.NANBOX_CHK = BlueTypeTag.NANBOX Or r[1] & BlueTypeTag.NANBOX_CHK = BlueTypeTag.NANBOX\n\t\t\tDebugStop\n\t\tElse\n\t\t\tPrint \" \" + Double Ptr(l)[0] + \" \" + Double Ptr(r)[0]\n\t\t\td[0] = Double Ptr(l)[0] + Double Ptr(r)[0]\n\t\tEndIf\n\tEnd Function\n\tFunction SUB(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction MUL(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction DIV(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction NMOD(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction POW(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction CAT(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction IDIV(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction BAND(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction BOR(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction BXOR(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction BSHL(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction BSHR(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction UNM(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction LNOT(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction ALEN(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction BNOT(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction UNP(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction EQ(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"EQ \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = (Byte Ptr Ptr(retptr) - 4)[0] + IP_OFFSET\n\t\tLocal r:Double = Double Ptr(varp)[rp[1]]\n\t\tLocal l:Double = Double Ptr(varp)[rp[2]]\n\t\tInt Ptr(varp + rp[0])[0] = l = r\n\tEnd Function\n\tFunction LT(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction LEQ(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\t\n\tFunction JMP(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t\tRuntimeError \"wait, why are we here?\"\n\tEnd Function\n\tFunction JIF(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"JIF \/\/\"\n\t\tLocal rp:Byte Ptr = (Byte Ptr Ptr(retptr) - 4)[0] + IP_OFFSET\n\t\tIf Int Ptr(stk.varp + rp[0])[0]\n\t\t\tLocal target:Int = Int Ptr(rp + 1)[0]\n\t\t\tInt Ptr(retptr)[-4] = target\n\t\tEndIf\n\tEnd Function\n\tFunction JNOT(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction CALL(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"CALL \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal fp:Int Ptr = Int Ptr(varp + rp[0])\n\t\tIf Not PrepareCall(fp, stk, rp, varp, retptr)\t'PrepareCall sets everything up so there's nothing else to do to make the call happen\n\t\t\t'__call metamethod\n\t\tEndIf\n\tEnd Function\n\tFunction TCALL(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction RET:Byte Ptr(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"RET \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp\n\t\tLocal rp0:Byte Ptr = Byte Ptr Ptr(retptr)[-4], rp:Byte Ptr = rp0 + IP_OFFSET\n\t\t\n\t\tLocal oldStk:Stack = stk.prevBase\n\t\tLocal retv:Long Ptr = varp + rp[0]\n\t\tIf oldStk\n\t\t\toldStk.retv = retv\n\t\t\toldStk.retc = Int Ptr(rp + 1)[0]\n\t\t\tByte Ptr Ptr(retptr)[-4] = stk.retIP\n\t\t\tByte Ptr Ptr(retptr)[-3] = Byte Ptr(oldStk)\n\t\t\tByte Ptr Ptr(retptr)[-2] = Byte Ptr(oldStk.func) + BYTECODE_INC\n\t\tElse\t'return to native code\n\t\t\tLocal codePage:Byte Ptr = Byte Ptr(Int(rp0) & ((Int(2^12)-1) Shl 20))\n\t\t\tByte Ptr Ptr(retptr)[-4] = codePage + 4\n\t\t\tReturn retv\n\t\tEndIf\n\tEnd Function\n\tFunction RETVA(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction POSTCALL(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"POSTCALL \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp\n\t\tLocal rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\t\n\t\tFor Local r:Int = 0 Until Min(Int Ptr(rp + 1)[0], stk.retc)\n\t\t\t(varp + rp[0])[r] = stk.retv[r]\n\t\t'\tPrint \" return \" + r + \": \" + Double Ptr(stk.retv)[r]\n\t\tNext\n\tEnd Function\n\tFunction VARARG(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction VAINIT(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction CALLINIT(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\t\n\t\n\tFunction PrepareCall:Int(fp:Int Ptr, stk:Stack, rp:Byte Ptr, varp:Long Ptr, retptr:Byte Ptr)\n\t\tIf fp[1] = BlueTypeTag.NANBOX | BlueTypeTag.FUN\n\t\t\tLocal newStk0:Stack ; Byte Ptr Ptr(Varptr(newStk0))[0] = Byte Ptr(stk) + stk.func.frameSz\n\t\t\tLocal newStk:Stack = newStk0\t'micro-opt: newStk0 can't be a register because of the unwieldy conversion\n\t\t\t\n\t\t\tnewStk.retIP = Byte Ptr Ptr(retptr)[-4]\n\t\t\tnewStk.prevBase = stk\n\t\t\tLocal closure:Byte Ptr = Byte Ptr(fp[0])\n\t\t\tLocal newBC:Bytecode = Bytecode Ptr(closure)[0]\n\t\t\tLocal voff:Int = STACKFRAME_INC + 4 * newBC.upvars\n\t\t\tnewStk.varp = Long Ptr(Byte Ptr(newStk) + voff)\n\t\t\tnewStk.func = newBC\n\t\t\t\n\t\t\tLocal argc_actual:Int = Short Ptr(rp)[1], argc_required:Int = newBC.pcount\n\t\t'\tLocal argc_min:Int ; If argc_actual < argc_required Then argc_min = argc_actual Else argc_min = argc_required\n\t\t\tLocal argc_min:Int = argc_actual - argc_required ; argc_min = (argc_min & (argc_min Shr 31)) + argc_required 'branchless 32-bit Min\n\t\t\t\n\t\t\tLocal argv:Long Ptr = varp + rp[1], destv:Long Ptr = newStk.varp\n\t\t\tFor Local a:Int = 0 Until argc_min\n\t\t\t\tdestv[a] = argv[a]\n\t\t\t'\tPrint \" arg \" + a + \": \" + argv[a]\n\t\t\tNext\n\t\t\tFor Local a:Int = argc_min Until argc_required\t'nil any unfilled parameters\n\t\t\t\tInt Ptr(destv + a)[1] = BlueTypeTag.NANBOX | BlueTypeTag.NIL\n\t\t\tNext\n\t\t\tnewStk.argv = argv + argc_min\t'argv should be to the varargs (if any)\n\t\t\tnewStk.argc = argc_actual - argc_min\t'argc is the number of varargs\n\t\t\t\n\t\t\tLocal destup:Byte Ptr Ptr = Byte Ptr Ptr(Byte Ptr(newStk) + STACKFRAME_INC)\n\t\t\tLocal upv:Byte Ptr Ptr = Byte Ptr Ptr(closure + 8)\n\t\t\tFor Local up:Int = 0 Until newBC.upvars\t'emplace upvars\n\t\t\t\tdestup[up] = upv[up]\n\t\t\t'\tPrint \" upv \" + up + \": \" + destv[up]\n\t\t\t'\tPrint \" val: \" + Double Ptr Ptr(Byte Ptr Ptr(closure) + 2 + up)[0][0]\n\t\t\tNext\n\t\t\t\n\t\t\t'note that the following OVERWRITE THE PARAMETERS (in release mode), so no touching stk from here on\n\t\t\tByte Ptr Ptr(retptr)[-4] = newBC.mcode\n\t\t\tByte Ptr Ptr(retptr)[-3] = Byte Ptr(newStk)\n\t\t\tByte Ptr Ptr(retptr)[-2] = Byte Ptr(newBC) + BYTECODE_INC\n\t\t\t\n\t\tElseIf fp[1] = BlueTypeTag.NANBOX | BlueTypeTag.NATFUN\t'native call\n\t\t\tLocal fun:Int(vm:BlueVM, ac:Int, av:Long Ptr, rv:Long Ptr) = Byte Ptr(fp[0])\n\t\t\tLocal argc:Int = Short Ptr(rp)[1], argv:Long Ptr = varp + rp[1], retv:Long Ptr = Long Ptr(Byte Ptr(stk) + stk.func.frameSz)\n\t\t\tLocal convert:BlueVM(p:Byte Ptr) = Byte Ptr(Identity), vm:BlueVM = convert(stk.func.vm)\n\t\t\tstk.retc = fun(vm, argc, argv, retv)\n\t\t\tstk.retv = retv\n\t\tElse\n\t\t\tReturn False\t'not a function; take appropriate action\n\t\tEndIf\n\t\tReturn True\t'all good and will auto-call when the caller returns\n\tEnd Function\n\t\n\tFunction InitOpTbl()\n\t\topc = New BlueOpcode\n\t\topTbl = [MOV, GETLC, SETLC, LOADK, LOADSI, LOADBOOL, LOADNIL, ..\n\t\t\tGETTAB, GETTABSI, SETTAB, SETTABSI, GETTABI, SETTABI, GETUPV, SETUPV, ..\n\t\t\tNEWTAB, CLOSURE, NEWUPV, ..\n\t\t\tADD, SUB, MUL, DIV, NMOD, POW, CAT, ..\n\t\t\tIDIV, BAND, BOR, BXOR, BSHL, BSHR, ..\n\t\t\tUNM, LNOT, ALEN, BNOT, UNP, ..\n\t\t\tEQ, LT, LEQ, ..\n\t\t\tJMP, JIF, JNOT, CALL, TCALL, RETVA, RETVA, ..\t'not a mistake: RET doesn't fit but we need the spacer\n\t\t\tPOSTCALL, VARARG, VAINIT, CALLINIT]\n\t\t\n\t\topTbl[opc.RET] = Byte Ptr(RET)\n\tEnd Function\n\t\n\tFunction Identity:Byte Ptr(b:Byte Ptr)\n\t\tReturn b\n\tEnd Function\n\tFunction PointerToExtType:Byte Ptr(p:Byte Ptr)\t'horrible pointer abuse (increment down so we can ignore the nonexistent vtbl)\n\t\tReturn p - SizeOf(Byte Ptr(0))\n\tEnd Function\n\tGlobal BPtoS:Stack(p:Byte Ptr) = Byte Ptr(BlueJIT.PointerToExtType)\nEnd Type\n\nType BlueLuaVal\n\tField _obj:BlueGCNode, val:Long, _vm:BlueVM\n\t\n\tMethod Call:BlueLuaVal(arg:BlueLuaVal[])\n\tEnd Method\n\t\n\tMethod Set(f:String, val:BlueLuaVal)\n\t\t'need to add type checks to these operators\n\t\tLocal k:BlueGCNode = BlueGCNode(_vm.strs.ValueForKey(f)), ks:Long\n\t\tIf k\n\t\t\tByte Ptr Ptr(Varptr(ks))[0] = k.val ; Int Ptr(Varptr(ks))[1] = BlueTypeTag.NANBOX | BlueTypeTag.STR\n\t\tElse\n\t\t\tks = _vm.mem.MaxStringToVal(f)\n\t\t\tk = _vm.mem.RootObj(Byte Ptr(Int(ks)))\n\t\t\t_vm.strs.Insert(f, k)\n\t\tEndIf\n\t\tBlueTable.RawSet(_vm.mem, _obj.val, ks, val.val)\n\tEnd Method\n\tMethod Get:BlueLuaVal(f:String)\n\t\tLocal k:BlueGCNode = BlueGCNode(_vm.strs.ValueForKey(f)), ks:Long\n\t\tIf k\n\t\t\tByte Ptr Ptr(Varptr(ks))[0] = k.val ; Int Ptr(Varptr(ks))[1] = BlueTypeTag.NANBOX | BlueTypeTag.STR\n\t\t\tLocal ret:Long = BlueTable.RawGet(_obj.val, ks), tag:Int = Int Ptr(Varptr(ret))[1]\n\t\t\tIf tag = (BlueTypeTag.NANBOX | BlueTypeTag.NIL)\n\t\t\t\tReturn Null\n\t\t\tElseIf tag & BlueTypeTag.NANBOX_CHK <> BlueTypeTag.NANBOX\n\t\t\t\tReturn _vm.ValueFromNumber(Double Ptr(Varptr(ret))[0])\n\t\t\tElse\n\t\t\t\tLocal v:BlueLuaVal = New Self\n\t\t\t\tv.val = ret ; v._vm = _vm ; v._obj = _vm.mem.RootObj(Byte Ptr Ptr(Varptr(ret))[0])\n\t\t\t\tReturn v\n\t\t\tEndIf\n\t\tElse\n\t\t\tReturn Null\n\t\tEndIf\n\tEnd Method\n\t\n\tMethod Unpin()\n\t\tIf _obj Then _obj = Null ; val = 0\n\tEnd Method\n\tFunction Make:BlueLuaVal(vm:BlueVM)\n\t\tLocal v:BlueLuaVal = New Self\n\t\tv._vm = vm\n\t\tReturn v\n\tEnd Function\n\tMethod Delete()\n\t\tIf _obj Then _obj.Remove()\n\tEnd Method\nEnd Type\n\n","old_contents":"\n' Blue Moon\n' Virtual Machine\n' the VM allocates memory, manages bytecode and machine code, and interfaces between Max and Lua objects\n' alongside the compiler, this more or less forms the toplevel accessible to the user\n\n' due to recursive dependency problems, for the moment a lot of this is Include rather than Import based\n' we'll fix that in post\n\n\nSuperStrict\n\nImport \"bluecompiler.bmx\"\nImport \"blueallocator.bmx\"\nImport \"bluetable.bmx\"\n\nRem\nImport \"blueasm.o\"\t'future project: assembly operators (this is a note, not an implementation)\nExtern\nFunction ADD:Int(s:Stack, b:Bytecode, r:Byte Ptr) = \"ADD2\"\nFunction EQ:Int(s:Stack, b:Bytecode, r:Byte Ptr) = \"EQ2\"\n'... you get the idea\nEnd Extern\nBlueJIT.InitOpTbl()\n'BlueJIT.opTbl[BlueJIT.opc.ADD] = ADD\n'BlueJIT.opTbl[BlueJIT.opc.EQ] = EQ\nEnd Rem\n\nInclude \"bluelibrary.bmx\"\n\n\n' notes:\n' - the structure of a bytecode object is:\n' [ machine code ptr ][ id-offset ][ #k ][ #param ][ #upvar ][ frame sz ][ #instrs ][ vm ][ instructions... ][ upvar table... ][ k table... ]\n' initial fields are all 32b; instructions are each 64b; upvar table is pairs of 32b values (level, pos); k table is NaN-box values\n\n' - the structure of a closure object (actual Lua value representing a function) is:\n' [ bytecode ptr ][ upvar values... ]\n\nType BlueVM\n\tField mem:BlueVMMemory, _ENV:BlueLuaVal\n\tField idMod:Int, funIndex:Bytecode Ptr, _fiSz:Int\n\tField strs:TMap\n\t\n\tMethod New()\n\t\tmem = New BlueVMMemory ; strs = CreateMap()\n\t\t_ENV = NewTable()\t'rebuild on each run?\n\tEnd Method\n\t\n\t' Load the procedures and constants of a compiled binary into the VM, returning the function representing the program toplevel\n\tMethod LoadObjectCode:BlueLuaVal(code:BlueBinary)\n\t\tLocal buf:Int[] = code.buf\n\t\tLocal fcount:Int = buf[0], kcount:Int = buf[1], ktblpos:Int = buf[2], ktbl:Long[kcount]\n\t\tLocal convert:Byte Ptr(o:Object) = Byte Ptr(BlueJIT.Identity)\n\t\t\n\t\tFor Local k:Int = 0 Until kcount\n\t\t\tLocal koff:Int = buf[ktblpos + k], sz:Int = buf[ktblpos + k + 1] - koff\n\t\t\tIf sz > 2\t'strings have size > 2\n\t\t\t\tLocal length:Double, lp:Int Ptr = Int Ptr(Varptr(length))\n\t\t\t\tlp[0] = buf[koff] ; lp[1] = buf[koff + 1]\n\t\t\t\tLocal s:Byte Ptr = mem.AllocConstant(length, Short Ptr(Varptr(buf[koff + 2])))\n\t\t\t\tktbl[k] = mem.PtrToVal(s, BlueTypeTag.STR)\n\t\t\tElse\n\t\t\t\tLocal d:Double, dp:Int Ptr = Int Ptr(Varptr(d))\n\t\t\t\tdp[0] = buf[koff] ; dp[1] = buf[koff + 1]\n\t\t\t\tDouble Ptr(Varptr(ktbl[k]))[0] = d\n\t\t\tEndIf\n\t\tNext\n\t\t\n\t\tExtendFunIndex(idMod + fcount)\n\t\tFor Local f:Int = 0 Until fcount\n\t\t\tLocal foff:Int = buf[3 + f]\n\t\t\tLocal ic:Int = buf[foff + 1], kc:Int = buf[foff + 2], pc:Int = buf[foff + 3], uc:Int = buf[foff + 5], fsz:Int = buf[foff + 6]\n\t\t\t\n\t\t\tLocal b:Bytecode\n\t\t\tRepeat\n\t\t\t\tLocal bp:Byte Ptr = mem.AllocBytecode(uc + uc Mod 2, kc, ic) ; b = BPtoBC(bp)\n\t\t\tUntil True\n\t\t\tb.idMod = idMod ; b.kcount = kc ; b.pcount = pc ; b.upvars = uc + uc Mod 2\t'round up for alignment\n\t\t\tb.frameSz = mem.STACKFRAMESZ + b.upvars * 8 + fsz * 8 ; b.icount = ic ; b.vm = convert(Self)\n\t\t\t\n\t\t\tLocal ib:Int Ptr = Int Ptr(Byte Ptr(b) + 4) + 8 + 2 * ic\n\t\t\tFor Local u:Int = 0 Until uc\n\t\t\t\tLocal uoff:Int = 7 + u * 2\n\t\t\t\tib[u * 2] = buf[foff + uoff] ; ib[u * 2 + 1] = buf[foff + uoff + 1]\n\t\t\tNext\n\t\t\tIf uc <> b.upvars\t'ensure padding is safe by copying the first one\n\t\t\t\tib[uc * 2] = buf[foff + 7] ; ib[uc * 2 + 1] = buf[foff + 7 + 1]\n\t\t\tEndIf\n\t\t\t\n\t\t\tLocal db:Long Ptr = Long Ptr(ib + 2 * b.upvars)\n\t\t\tFor Local k:Int = 0 Until kc\n\t\t\t\tdb[k] = ktbl[buf[foff + 7 + uc * 2 + k]]\n\t\t\tNext\n\t\t\t\n\t\t\tLocal ioff:Int = 7 + 2 * uc + kc ; ib = Int Ptr(Byte Ptr(b) + BlueJIT.BYTECODE_INC)\n\t\t\t\n\t\t\tFor Local i:Int = 0 Until ic * 2\n\t\t\t\tib[i] = buf[foff + ioff + i]\n\t\t\tNext\n\t\t\t\n\t\t\tb.mcode = BlueJIT.Compile(Self, ib, ic, b) + BlueJIT.PROLOGUESZ\n\t\t\tfunIndex[idMod + f] = b\n\t\tNext\n\t\t\n\t\tidMod :+ fcount\n\t\tReturn New BlueLuaVal\n\tEnd Method\n\t\n\tMethod ExtendFunIndex(sz:Int)\t'hack: BlitzMax has a bug with arrays of extern types! so we need to use C-style arrays for now\n\t\tLocal newFI:Bytecode Ptr = Bytecode Ptr(MemAlloc(sz * 4))\n\t\tIf _fiSz\n\t\t\tFor Local b:Int = 0 Until _fiSz\n\t\t\t\tnewFI[b] = funIndex[b]\n\t\t\tNext\n\t\t\tMemFree(funIndex)\n\t\t\tFor Local b:Int = _fiSz Until sz\n\t\t\t\tnewFI[b] = Null\n\t\t\tNext\n\t\tEndIf\n\t\tfunIndex = newFI ; _fiSz = sz\n\tEnd Method\n\t\n\tMethod CallToLua()\n\tEnd Method\n\t\n\tMethod NewTable:BlueLuaVal()\n\t\tLocal t:Byte Ptr = mem.AllocTable(Null), ret:BlueLuaVal = BlueLuaVal.Make(Self)\n\t\tByte Ptr Ptr(Varptr(ret.val))[0] = t ; Int Ptr(Varptr(ret.val))[1] = BlueTypeTag.NANBOX | BlueTypeTag.TBL\n\t\tret._obj = mem.RootObj(t)\n\t\tReturn ret\n\tEnd Method\n\t\n\tMethod ValueFromObject:BlueLuaVal(o:Object)\n\tEnd Method\n\tMethod ValueFromNumber:BlueLuaVal(n:Double)\n\t\tLocal v:BlueLuaVal = New BlueLuaVal\n\t\tDouble Ptr(Varptr(v.val))[0] = n\n\t\tReturn v\n\tEnd Method\n\tMethod ValueFromString:BlueLuaVal(s:String)\n\tEnd Method\n\tMethod ValueFromBinary:BlueLuaVal(b:Byte Ptr)\n\tEnd Method\n\tMethod ValueFromFunction:BlueLuaVal(f:Byte Ptr)\n\t\tLocal v:BlueLuaVal = New BlueLuaVal\n\t\tByte Ptr Ptr(Varptr(v.val))[0] = f\n\t\tInt Ptr(Varptr(v.val))[1] = BlueTypeTag.NANBOX | BlueTypeTag.NATFUN\n\t\tReturn v\n\tEnd Method\n\t\n\tGlobal BPtoBC:Bytecode(p:Byte Ptr) = Byte Ptr(BlueJIT.PointerToExtType)\nEnd Type\n\n'Private\t'may need to open these (in the shared interface?)\nExtern\n\tType Stack\n\t\tField retIP:Byte Ptr, prevBase:Stack, varp:Long Ptr, func:Bytecode, _:Long Ptr, argv:Long Ptr, retv:Long Ptr, argc:Short, retc:Short\n\tEnd Type\n\tType Bytecode\n\t\tField mcode:Byte Ptr, idMod:Int, kcount:Int, pcount:Int, upvars:Int, frameSz:Int, icount:Int, vm:Byte Ptr\n\tEnd Type\nEnd Extern\n'Public\n\nType BlueJIT Final\n\tConst PROLOGUESZ:Int = 25, ISIZE:Int = 5\n\t\n\tGlobal opTbl:Int(s:Stack, b:Bytecode, r:Byte Ptr)[], opc:BlueOpcode\n\tGlobal Prologue:Int[] = [ ..\n\t\t$90, $90, ..\n\t\t$8b, $44, $24, $04, .. 'mov 4(%esp), %eax\n\t\t$89, $44, $24, $f4, .. 'mov %eax, -12(%esp)\n\t\t$c7, $44, $24, $f8, $FF, $FF, $FF, $FF, .. 'movl ########, -8(%esp)\n\t\t$89, $64, $24, $fc, .. 'mov %esp, -4(%esp)\n\t\t$83, $ec, $0c.. 'sub $12, %esp\n\t]\n\t\n\tFunction Compile:Byte Ptr(vm:BlueVM, ins:Byte Ptr, icount:Int, bytecode:Bytecode)\n\t\t?Not x86\n\t\tRuntimeError \"The Blue Moon JIT does not support your platform (x86-32 only at this time)\"\n\t\t?\n\t\tAssert SizeOf(0:Long) = SizeOf(0:Double) And SizeOf(0:Int) = 4 And SizeOf(0:Long) = 8 And SizeOf(Byte Ptr(0)) = 4, ..\n\t\t\t\"assumptions about platform datatype sizes are invalid\"\n\t\t\n\t\tIf opTbl = Null Then InitOpTbl()\n\t\t\n\t\t' compute executable code size\n\t\tLocal codesize:Int = PROLOGUESZ, opPos:Int[icount]\t'since sizes are irregular, looking up offsets is easiest\n\t\tFor Local i:Int = 0 Until icount\n\t\t\topPos[i] = codesize\t'finalized below\n\t\t\tSelect ins[i * 8]\n\t\t\t\tCase opc.SETTAB, opc.GETTAB\n\t\t\t\t\tcodesize :+ ISIZE * 2\n\t\t\t\tDefault\n\t\t\t\t\tcodesize :+ ISIZE\n\t\t\tEnd Select\n\t\tNext\n\t\t\n\t\t' allocate executable space\n\t\tLocal code:Byte Ptr = vm.mem.AllocCodeBlock(codesize)\n\t\t\n\t\t'finalize op offsets se we can look them up\n\t\tFor Local i:Int = 0 Until icount\n\t\t\topPos[i] :+ Int(code)\t'direct to executable space\n\t\tNext\n\t\t\n\t\t' emplace prologue (used for calling in from native only)\n\t\tFor Local p:Int = 0 Until PROLOGUESZ\n\t\t\tcode[p] = Prologue[p]\n\t\tNext\n\t\tByte Ptr Ptr(code + 14)[0] = Byte Ptr(bytecode)\t'replace the ########\n\t\t\n\t\t' epilogue (shared location per-vm, probably already set)\n\t\tvm.mem.returnToNative[0] = $c30cc483\t'add $12, %esp ; ret - i.e. restore the stack to normal\n\t\t\n\t\tLocal ktable:Long Ptr = Long Ptr(ins + 8 * bytecode.icount + 8 * bytecode.upvars)\t'constant table\n\t\t\n\t\t' generate machine code!\n\t\tFor Local i:Int = 0 Until icount\t'emplace opcode calls and supporting bytecode data\n\t\t\tLocal codep:Byte Ptr = Byte Ptr(opPos[i]), bytecodep:Byte Ptr = Byte Ptr(Int(codep) + vm.mem.PAGESZ)\n\t\t\tLocal bi:Int = i * 8, op:Int = ins[bi], ip:Int Ptr = Int Ptr(ins + bi), func:Byte Ptr = opTbl[op]\n\t\t\t\n\t\t\tcodep[0] = $e8\t'call\n\t\t\tByte Ptr Ptr(codep + 1)[0] = func - Int(codep + ISIZE)\n\t\t\t\n\t\t\tbytecodep[0] = ins[bi + 1] ; bytecodep[1] = ins[bi + 2]\t'used by most, may get overwritten\n\t\t\t\n\t\t\tSelect op\n\t\t\t\tCase opc.LOADSI, opc.CLOSURE, opc.RET, opc.POSTCALL\n\t\t\t\t\tInt Ptr(bytecodep + 1)[0] = ip[1]\n\t\t\t\t\t\n\t\t\t\tCase opc.LOADK\n\t\t\t\t\tLong Ptr Ptr(bytecodep + 1)[0] = ktable + ip[1]\n\t\t\t\t\t\n\t\t\t\tCase opc.SETTABSI, opc.GETTABSI\n\t\t\t\t\tShort Ptr(bytecodep)[1] = ip[1]\n\t\t\t\t\t\n\t\t\t\tCase opc.SETTAB, opc.GETTAB\n\t\t\t\t\tcodep[ISIZE] = $90 ; Int Ptr(codep + ISIZE + 1)[0] = $90909090\t'nops; the space is needed in the bytecode\n\t\t\t\t\tLong Ptr Ptr(bytecodep + 2)[0] = ktable + ip[1]\n\t\t\t\t\tLong Ptr Ptr(bytecodep + 2)[1] = Null\t'inline cache space\n\t\t\t\t\t\n\t\t\t\tCase opc.GETUPV\n\t\t\t\t\tIf Int Ptr(ins + icount * 8)[2 * bytecodep[1]] = -1\n\t\t\t\t\t\tByte Ptr Ptr(codep + 1)[0] = Byte Ptr(BlueJIT.GETENV) - Int(codep + ISIZE)\n\t\t\t\t\t\tByte Ptr Ptr(bytecodep + 1)[0] = Varptr(vm._ENV.val)\t'note: doesn't allow _ENV to be changed from Max\n\t\t\t\t\tEndIf\n\t\t\t\t\t\n\t\t\t\tCase opc.CALL\n\t\t\t\t\tShort Ptr(bytecodep)[1] = ip[1]\n\t\t\t\t\t\n\t\t\t\tCase opc.JIF, opc.JNOT\n\t\t\t\t\tInt Ptr(bytecodep + 1)[0] = opPos[i + ip[1]]\n\t\t\t\t\t\n\t\t\t\tCase opc.JMP\n\t\t\t\t\tcodep[0] = $e9\t'use a true jump\n\t\t\t\t\tInt Ptr(codep + 1)[0] = opPos[i + ip[1]] - (opPos[i] + ISIZE)\n\t\t\t\t\t\n\t\t\t\tDefault\t'binary operations A = B op C\n\t\t\t\t\tbytecodep[2] = ip[1]\n\t\t\tEnd Select\n\t\tNext\n\t\t\n\t\tReturn code\n\tEnd Function\n\t\n\t\n\tConst STACKFRAME_INC:Int = BlueVMMemory.STACKFRAMESZ + 4, BYTECODE_INC:Int = BlueVMMemory.BYTECODESZ + 4\n\tConst IP_OFFSET:Int = BlueVMMemory.PAGESZ - ISIZE\n\t\n\t\n\t'note: extern vars must take into account the vtbl offset, so that converting from a typed pointer can be a simple cast (faster)\t\n\t\n\tFunction MOV(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"MOV \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tvarp[rp[0]] = varp[rp[1]]\t'assigning through Double is unsafe as it can corrupt the bit pattern\n\tEnd Function\n\tFunction GETLC(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction SETLC(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"SETLC \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\t'add a write barrier here\n\t\tLong Ptr Ptr(varp + rp[0])[0][0] = varp[rp[1]]\n\tEnd Function\n\tFunction LOADK(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"LOADK \/\/\"\n\t\tLocal rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET, varp:Long Ptr = stk.varp + rp[0], kp:Long Ptr = Long Ptr Ptr(rp + 1)[0]\n\t\tvarp[0] = kp[0]\n\tEnd Function\n\tFunction LOADSI(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"LOADSI \/\/\"\n\t\tLocal rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal val:Int = Int Ptr(rp + 1)[0]\n\t\tDouble Ptr(stk.varp)[rp[0]] = Double(val)\n\tEnd Function\n\tFunction LOADBOOL(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"LOADBOOL \/\/\"\n\t\tLocal rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET, vp:Int Ptr = Int Ptr(stk.varp + rp[0])\n\t\tvp[1] = BlueTypeTag.NANBOX | BlueTypeTag.BOOL\n\t\tvp[0] = Int Ptr(rp + 1)[0]\n\tEnd Function\n\tFunction LOADNIL(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"LOADNIL \/\/\"\n\t\tLocal rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tInt Ptr(stk.varp + rp[0])[1] = BlueTypeTag.NANBOX | BlueTypeTag.NIL\n\tEnd Function\n\t\n\tFunction GETTAB(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t\tPrint \"GETTAB \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET, kp:Long Ptr = Long Ptr Ptr(rp + 2)[0]\n\t\tLocal tabp:Byte Ptr = Byte Ptr Ptr(varp + rp[1])[0]\n\t\t'type check\n\t\tPrint \" tag: \" + Bin(Int Ptr(kp)[1])\n\t\tLocal keyslot:Long Ptr = Null, slot:Long Ptr = BlueTable.GetSlot(tabp, kp[0], Varptr(keyslot))\n\t\tPrint \" slot: \" + Hex(Int(slot))\n\t\tIf (slot = Null) Or (keyslot[0] <> kp[0])\t'not in table; invoke metamethod\n\t\t\t'if keyslot == 1 then it's invalid\n\t\t\tDebugStop\n\t\tElse\n\t\t\tvarp[rp[0]] = slot[0]\n\t\tEndIf\n\tEnd Function\n\tFunction GETTABSI(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction SETTAB(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t\tPrint \"SETTAB \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET, kp:Long Ptr = Long Ptr Ptr(rp + 2)[0]\n\t\tLocal tabp:Byte Ptr = Byte Ptr Ptr(varp + rp[0])[0]\n\t\tPrint \" tag: \" + Bin(Int Ptr(kp)[1])\n\t\tLocal keyslot:Long Ptr = Null, slot:Long Ptr = BlueTable.GetSlot(tabp, kp[0], Varptr(keyslot))\n\t\tPrint \" slot: \" + Hex(Int(slot))\n\t\tIf (slot = Null) Or (keyslot[0] <> kp[0])\t'not in table; invoke metamethod or rawset\n\t\t\t'if keyslot == 1 then it's invalid\n\t\t\tLocal convert:BlueVM(p:Byte Ptr) = Byte Ptr(Identity), vm:BlueVM = convert(bc.vm)\n\t\t\tBlueTable.RawSet(vm.mem, tabp, kp[0], varp[rp[1]])\n\t\tElse\n\t\t\tslot[0] = varp[rp[1]]\n\t\tEndIf\n\tEnd Function\n\tFunction SETTABSI(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t\tPrint \"SETTABSI \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal convert:BlueVM(p:Byte Ptr) = Byte Ptr(Identity), vm:BlueVM = convert(bc.vm)\n\t\tLocal tabp:Byte Ptr = varp + rp[0]\n\t\tPrint \" \" + Short Ptr(rp)[1]\n\t\tLocal key:Long ; Double Ptr(Varptr(key))[0] = Short Ptr(rp)[1]\n\t\tBlueTable.RawSet(vm.mem, Byte Ptr Ptr(tabp)[0], key, varp[rp[1]])\n\tEnd Function\n\tFunction GETTABI(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t\tPrint \"GETTABI \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal tabp:Byte Ptr = varp + rp[1]\n\t\tPrint \" tag: \" + Bin(Int Ptr(varp + rp[2])[1])\n\t\tLocal val:Long = BlueTable.RawGet(Byte Ptr Ptr(tabp)[0], varp[rp[2]])\n\t\tLocal v:Double = Double Ptr(Varptr(val))[0]\n\t\tPrint \" \" + v\n\t\tvarp[rp[0]] = val\n\tEnd Function\n\tFunction SETTABI(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t\tPrint \"SETTABI \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal convert:BlueVM(p:Byte Ptr) = Byte Ptr(Identity), vm:BlueVM = convert(bc.vm)\n\t\tLocal tabp:Byte Ptr = varp + rp[0]\n\t\tPrint \" \" + Double Ptr(varp)[rp[2]] + \" \" + Double Ptr(varp)[rp[1]]\n\t\tPrint \" tag: \" + Bin(Int Ptr(varp + rp[2])[1])\n\t\tBlueTable.RawSet(vm.mem, Byte Ptr Ptr(tabp)[0], varp[rp[2]], varp[rp[1]])\n\tEnd Function\n\tFunction GETUPV(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t\tPrint \"GETUPV \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tPrint \" \" + rp[0] + \" \" + rp[1] + \" \" + rp[2]\n\t\tDebugStop\n\t\tLocal upvp:Byte Ptr Ptr = Byte Ptr Ptr(Byte Ptr(stk) + STACKFRAME_INC), valp:Long Ptr = Long Ptr(upvp[rp[1]])\n\t\tvarp[rp[0]] = valp[0]\n\tEnd Function\n\tFunction GETENV(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\t'\"unlisted\" instruction: GETUPV for _ENV is translated into this at load-time\n\t\tPrint \"GETENV \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tPrint \" \" + rp[0] + \" \" + Hex(Int Ptr(rp + 1)[0])\n\t\t'need a type check\n\t\tvarp[rp[0]] = Long Ptr Ptr(rp + 1)[0][0]\n\tEnd Function\n\tFunction SETUPV(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction NEWTAB(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t\tPrint \"NEWTAB \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal convert:BlueVM(p:Byte Ptr) = Byte Ptr(Identity), vm:BlueVM = convert(bc.vm)\n\t\tLocal tab:Byte Ptr = vm.mem.AllocTable(Null)\n\t\tLocal d:Int Ptr = Int Ptr(varp + rp[0])\n\t\td[0] = Int(tab) ; d[1] = BlueTypeTag.NANBOX | BlueTypeTag.TBL\n\tEnd Function\n\tFunction CLOSURE(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"CLOSURE \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal convert:BlueVM(p:Byte Ptr) = Byte Ptr(Identity), vm:BlueVM = convert(bc.vm)\n\t\tLocal d:Int Ptr = Int Ptr(varp + rp[0])\n\t\tLocal cbytecode:Bytecode = vm.funIndex[Int Ptr(rp + 1)[0]], upvp:Int Ptr = Int Ptr(Byte Ptr(cbytecode) + BYTECODE_INC + 8 * cbytecode.icount)\n\t\tLocal closure:Byte Ptr = vm.mem.AllocClosure(cbytecode, cbytecode.upvars)\t'upvars is always even (alignment)\n\t\t\n\t\t'get upvalues off the stack\n\t\tFor Local u:Int = 0 Until cbytecode.upvars\n\t\t\tIf upvp[2 * u]\n\t\t\t\tByte Ptr Ptr(closure)[2 + u] = Byte Ptr Ptr(Byte Ptr(stk) + STACKFRAME_INC)[upvp[2 * u + 1]]\n\t\t\tElse\n\t\t\t\tByte Ptr Ptr(closure)[2 + u] = Byte Ptr Ptr(varp + upvp[2 * u + 1])[0]\n\t\t\tEndIf\n\t\tNext\n\t\t\n\t\td[0] = Int(closure) ; d[1] = BlueTypeTag.NANBOX | BlueTypeTag.FUN\n\tEnd Function\n\tFunction NEWUPV(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"NEWUPV \/\/\"\n\t\tLocal rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal convert:BlueVM(p:Byte Ptr) = Byte Ptr(Identity), vm:BlueVM = convert(bc.vm)\n\t\tLocal upv:Byte Ptr = vm.mem.AllocObject(8, BlueTypeTag.UPV), d:Int Ptr = Int Ptr(stk.varp + rp[0])\n\t\tLong Ptr(upv)[0] = Long Ptr(d)[0]\t'promote a value if it existed (useful for parameters)\n\t\td[0] = Int(upv) ; d[1] = BlueTypeTag.NANBOX | BlueTypeTag.UPV\n\tEnd Function\n\t\n\tFunction ADD(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t\tPrint \"ADD \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal d:Double Ptr = Double Ptr(varp + rp[0])\n\t\tLocal r:Int Ptr = Int Ptr(varp + rp[1]), l:Int Ptr = Int Ptr(varp + rp[2])\n\t\tIf l[1] & BlueTypeTag.NANBOX_CHK = BlueTypeTag.NANBOX Or r[1] & BlueTypeTag.NANBOX_CHK = BlueTypeTag.NANBOX\n\t\t\tDebugStop\n\t\tElse\n\t\t\tPrint \" \" + Double Ptr(l)[0] + \" \" + Double Ptr(r)[0]\n\t\t\td[0] = Double Ptr(l)[0] + Double Ptr(r)[0]\n\t\tEndIf\n\tEnd Function\n\tFunction SUB(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction MUL(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction DIV(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction NMOD(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction POW(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction CAT(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction IDIV(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction BAND(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction BOR(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction BXOR(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction BSHL(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction BSHR(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction UNM(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction LNOT(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction ALEN(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction BNOT(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction UNP(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction EQ(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"EQ \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = (Byte Ptr Ptr(retptr) - 4)[0] + IP_OFFSET\n\t\tLocal r:Double = Double Ptr(varp)[rp[1]]\n\t\tLocal l:Double = Double Ptr(varp)[rp[2]]\n\t\tInt Ptr(varp + rp[0])[0] = l = r\n\tEnd Function\n\tFunction LT(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction LEQ(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\t\n\tFunction JMP(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t\tRuntimeError \"wait, why are we here?\"\n\tEnd Function\n\tFunction JIF(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"JIF \/\/\"\n\t\tLocal rp:Byte Ptr = (Byte Ptr Ptr(retptr) - 4)[0] + IP_OFFSET\n\t\tIf Int Ptr(stk.varp + rp[0])[0]\n\t\t\tLocal target:Int = Int Ptr(rp + 1)[0]\n\t\t\tInt Ptr(retptr)[-4] = target\n\t\tEndIf\n\tEnd Function\n\tFunction JNOT(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction CALL(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"CALL \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal fp:Int Ptr = Int Ptr(varp + rp[0])\n\t\tIf Not PrepareCall(fp, stk, rp, varp, retptr)\t'PrepareCall sets everything up so there's nothing else to do to make the call happen\n\t\t\t'__call metamethod\n\t\tEndIf\n\tEnd Function\n\tFunction TCALL(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction RET:Byte Ptr(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"RET \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp\n\t\tLocal rp0:Byte Ptr = Byte Ptr Ptr(retptr)[-4], rp:Byte Ptr = rp0 + IP_OFFSET\n\t\t\n\t\tLocal oldStk:Stack = stk.prevBase\n\t\tLocal retv:Long Ptr = varp + rp[0]\n\t\tIf oldStk\n\t\t\toldStk.retv = retv\n\t\t\toldStk.retc = Int Ptr(rp + 1)[0]\n\t\t\tByte Ptr Ptr(retptr)[-4] = stk.retIP\n\t\t\tByte Ptr Ptr(retptr)[-3] = Byte Ptr(oldStk)\n\t\t\tByte Ptr Ptr(retptr)[-2] = Byte Ptr(oldStk.func) + BYTECODE_INC\n\t\tElse\t'return to native code\n\t\t\tLocal codePage:Byte Ptr = Byte Ptr(Int(rp0) & ((Int(2^12)-1) Shl 20))\n\t\t\tByte Ptr Ptr(retptr)[-4] = codePage + 4\n\t\t\tReturn retv\n\t\tEndIf\n\tEnd Function\n\tFunction RETVA(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction POSTCALL(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"POSTCALL \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp\n\t\tLocal rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\t\n\t\tFor Local r:Int = 0 Until Min(Int Ptr(rp + 1)[0], stk.retc)\n\t\t\t(varp + rp[0])[r] = stk.retv[r]\n\t\t'\tPrint \" return \" + r + \": \" + Double Ptr(stk.retv)[r]\n\t\tNext\n\tEnd Function\n\tFunction VARARG(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction VAINIT(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction CALLINIT(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\t\n\t\n\tFunction PrepareCall:Int(fp:Int Ptr, stk:Stack, rp:Byte Ptr, varp:Long Ptr, retptr:Byte Ptr)\n\t\tIf fp[1] = BlueTypeTag.NANBOX | BlueTypeTag.FUN\n\t\t\tLocal newStk0:Stack ; Byte Ptr Ptr(Varptr(newStk0))[0] = Byte Ptr(stk) + stk.func.frameSz\n\t\t\tLocal newStk:Stack = newStk0\t'micro-opt: newStk0 can't be a register because of the unwieldy conversion\n\t\t\t\n\t\t\tnewStk.retIP = Byte Ptr Ptr(retptr)[-4]\n\t\t\tnewStk.prevBase = stk\n\t\t\tLocal closure:Byte Ptr = Byte Ptr(fp[0])\n\t\t\tLocal newBC:Bytecode = Bytecode Ptr(closure)[0]\n\t\t\tLocal voff:Int = STACKFRAME_INC + 4 * newBC.upvars\n\t\t\tnewStk.varp = Long Ptr(Byte Ptr(newStk) + voff)\n\t\t\tnewStk.func = newBC\n\t\t\t\n\t\t\tLocal argc_actual:Int = Short Ptr(rp)[1], argc_required:Int = newBC.pcount\n\t\t'\tLocal argc_min:Int ; If argc_actual < argc_required Then argc_min = argc_actual Else argc_min = argc_required\n\t\t\tLocal argc_min:Int = argc_actual - argc_required ; argc_min = (argc_min & (argc_min Shr 31)) + argc_required 'branchless 32-bit Min\n\t\t\t\n\t\t\tLocal argv:Long Ptr = varp + rp[1], destv:Long Ptr = newStk.varp\n\t\t\tFor Local a:Int = 0 Until argc_min\n\t\t\t\tdestv[a] = argv[a]\n\t\t\t'\tPrint \" arg \" + a + \": \" + argv[a]\n\t\t\tNext\n\t\t\tFor Local a:Int = argc_min Until argc_required\t'nil any unfilled parameters\n\t\t\t\tInt Ptr(destv + a)[1] = BlueTypeTag.NANBOX | BlueTypeTag.NIL\n\t\t\tNext\n\t\t\tnewStk.argv = argv + argc_min\t'argv should be to the varargs (if any)\n\t\t\tnewStk.argc = argc_actual - argc_min\t'argc is the number of varargs\n\t\t\t\n\t\t\tLocal destup:Byte Ptr Ptr = Byte Ptr Ptr(Byte Ptr(newStk) + STACKFRAME_INC)\n\t\t\tLocal upv:Byte Ptr Ptr = Byte Ptr Ptr(closure + 8)\n\t\t\tFor Local up:Int = 0 Until newBC.upvars\t'emplace upvars\n\t\t\t\tdestup[up] = upv[up]\n\t\t\t'\tPrint \" upv \" + up + \": \" + destv[up]\n\t\t\t'\tPrint \" val: \" + Double Ptr Ptr(Byte Ptr Ptr(closure) + 2 + up)[0][0]\n\t\t\tNext\n\t\t\t\n\t\t\t'note that the following OVERWRITE THE PARAMETERS (in release mode), so no touching stk from here on\n\t\t\tByte Ptr Ptr(retptr)[-4] = newBC.mcode\n\t\t\tByte Ptr Ptr(retptr)[-3] = Byte Ptr(newStk)\n\t\t\tByte Ptr Ptr(retptr)[-2] = Byte Ptr(newBC) + BYTECODE_INC\n\t\t\t\n\t\tElseIf fp[1] = BlueTypeTag.NANBOX | BlueTypeTag.NATFUN\t'native call\n\t\t\tLocal fun:Int(vm:BlueVM, ac:Int, av:Long Ptr, rv:Long Ptr) = Byte Ptr(fp[0])\n\t\t\tLocal argc:Int = Short Ptr(rp)[1], argv:Long Ptr = varp + rp[1], retv:Long Ptr = Long Ptr(Byte Ptr(stk) + stk.func.frameSz)\n\t\t\tLocal convert:BlueVM(p:Byte Ptr) = Byte Ptr(Identity), vm:BlueVM = convert(stk.func.vm)\n\t\t\tstk.retc = fun(vm, argc, argv, retv)\n\t\t\tstk.retv = retv\n\t\tElse\n\t\t\tReturn False\t'not a function; take appropriate action\n\t\tEndIf\n\t\tReturn True\t'all good and will auto-call when the caller returns\n\tEnd Function\n\t\n\tFunction InitOpTbl()\n\t\topc = New BlueOpcode\n\t\topTbl = [MOV, GETLC, SETLC, LOADK, LOADSI, LOADBOOL, LOADNIL, ..\n\t\t\tGETTAB, GETTABSI, SETTAB, SETTABSI, GETTABI, SETTABI, GETUPV, SETUPV, ..\n\t\t\tNEWTAB, CLOSURE, NEWUPV, ..\n\t\t\tADD, SUB, MUL, DIV, NMOD, POW, CAT, ..\n\t\t\tIDIV, BAND, BOR, BXOR, BSHL, BSHR, ..\n\t\t\tUNM, LNOT, ALEN, BNOT, UNP, ..\n\t\t\tEQ, LT, LEQ, ..\n\t\t\tJMP, JIF, JNOT, CALL, TCALL, RETVA, RETVA, ..\t'not a mistake: RET doesn't fit but we need the spacer\n\t\t\tPOSTCALL, VARARG, VAINIT, CALLINIT]\n\t\t\n\t\topTbl[opc.RET] = Byte Ptr(RET)\n\tEnd Function\n\t\n\tFunction Identity:Byte Ptr(b:Byte Ptr)\n\t\tReturn b\n\tEnd Function\n\tFunction PointerToExtType:Byte Ptr(p:Byte Ptr)\t'horrible pointer abuse (increment down so we can ignore the nonexistent vtbl)\n\t\tReturn p - SizeOf(Byte Ptr(0))\n\tEnd Function\n\tGlobal BPtoS:Stack(p:Byte Ptr) = Byte Ptr(BlueJIT.PointerToExtType)\nEnd Type\n\nType BlueLuaVal\n\tField _obj:BlueGCNode, val:Long, _vm:BlueVM\n\t\n\tMethod Call:BlueLuaVal(arg:BlueLuaVal[])\n\tEnd Method\n\t\n\tMethod Set(f:String, val:BlueLuaVal)\n\t\t'need to add type checks to these operators\n\t\tLocal k:BlueGCNode = BlueGCNode(_vm.strs.ValueForKey(f)), ks:Long\n\t\tIf k\n\t\t\tByte Ptr Ptr(Varptr(ks))[0] = k.val ; Int Ptr(Varptr(ks))[1] = BlueTypeTag.NANBOX | BlueTypeTag.STR\n\t\tElse\n\t\t\tks = _vm.mem.MaxStringToVal(f)\n\t\t\tk = _vm.mem.RootObj(Byte Ptr(Int(ks)))\n\t\t\t_vm.strs.Insert(f, k)\n\t\tEndIf\n\t\tBlueTable.RawSet(_vm.mem, _obj.val, ks, val.val)\n\tEnd Method\n\tMethod Get:BlueLuaVal(f:String)\n\t\tLocal k:BlueGCNode = BlueGCNode(_vm.strs.ValueForKey(f)), ks:Long\n\t\tIf k\n\t\t\tByte Ptr Ptr(Varptr(ks))[0] = k.val ; Int Ptr(Varptr(ks))[1] = BlueTypeTag.NANBOX | BlueTypeTag.STR\n\t\t\tLocal ret:Long = BlueTable.RawGet(_obj.val, ks), tag:Int = Int Ptr(Varptr(ret))[1]\n\t\t\tIf tag = (BlueTypeTag.NANBOX | BlueTypeTag.NIL)\n\t\t\t\tReturn Null\n\t\t\tElseIf tag & BlueTypeTag.NANBOX_CHK <> BlueTypeTag.NANBOX\n\t\t\t\tReturn _vm.ValueFromNumber(Double Ptr(Varptr(ret))[0])\n\t\t\tElse\n\t\t\t\tLocal v:BlueLuaVal = New Self\n\t\t\t\tv.val = ret ; v._vm = _vm ; v._obj = _vm.mem.RootObj(Byte Ptr Ptr(Varptr(ret))[0])\n\t\t\t\tReturn v\n\t\t\tEndIf\n\t\tElse\n\t\t\tReturn Null\n\t\tEndIf\n\tEnd Method\n\t\n\tMethod Unpin()\n\t\tIf _obj Then _obj = Null ; val = 0\n\tEnd Method\n\tFunction Make:BlueLuaVal(vm:BlueVM)\n\t\tLocal v:BlueLuaVal = New Self\n\t\tv._vm = vm\n\t\tReturn v\n\tEnd Function\n\tMethod Delete()\n\t\tIf _obj Then _obj.Remove()\n\tEnd Method\nEnd Type\n\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"edc0abbb621d530363b451f99621d7542a21cfe4","subject":"Fixed minor capitalization issue.","message":"Fixed minor capitalization issue.\n","repos":"kfprimm\/maxb3d,kfprimm\/maxb3d","old_file":"doc\/samples\/mak\/tron.bmx","new_file":"doc\/samples\/mak\/tron.bmx","new_contents":"\nStrict\n\nImport MaxB3D.Drivers\n\nGraphics 800,600\n\nLocal smooth=True\n\nLocal grid_tex:TTexture=CreateTexture( 32,32,8 )\nSetTextureScale grid_tex,10,10\nSetBuffer TextureBuffer( grid_tex )\nSetColor 0,0,64;DrawRect 0,0,32,32\nSetColor 0,0,255;DrawRect 0,0,32,32\nSetBuffer BackBuffer()\n\n\nLocal grid_plane:TFlat=CreateFlat()\nSetEntityTexture grid_plane,grid_tex\nSetEntityBlend grid_plane,1\nSetEntityAlpha grid_plane,.6\nSetEntityFX grid_plane,FX_FULLBRIGHT\n\n'Local mirror:TMirror=CreateMirror()\nRem\nLocal pivot=CreatePivot()\n\np=CreatePivot( p )\ncube=CreateCube( p )\nScaleEntity cube,1,1,5\nSetAnimKey cube,0\nRotateEntity cube,0,120,0\nSetAnimKey cube,60\nRotateEntity cube,0,240,0\nSetAnimKey cube,120\nRotateEntity cube,0,0,0\nSetAnimKey cube,180\nAddAnimSeq p,180\n\nFor x=-100 To 100 Step 25\nFor z=-100 To 100 Step 25\ne=CopyEntity( p,pivot )\nPositionEntity e,x,5,z\nAnimate e\nNext\nNext\nFreeEntity cube\nEnd Rem\n\nLocal trail_mesh:TMesh=CreateMesh()\nLocal trail_brush:TBrush=CreateBrush()\nSetBrushColor trail_brush,255,0,0\nSetBrushBlend trail_brush,3\nSetBrushFX trail_brush,FX_FULLBRIGHT\nLocal trail_surf:TSurface=AddMeshSurface( trail_mesh,trail_brush )\nAddSurfaceVertex trail_surf,0,2,0,0,0\nAddSurfaceVertex trail_surf,0,0,0,0,1\nAddSurfaceVertex trail_surf,0,2,0,0,0\nAddSurfaceVertex trail_surf,0,0,0,0,1\nAddSurfaceTriangle trail_surf,0,2,3\nAddSurfaceTriangle trail_surf,0,3,1\nAddSurfaceTriangle trail_surf,0,3,2\nAddSurfaceTriangle trail_surf,0,1,3\nLocal trail_vert=2\n\nLocal bike:TMesh=CreateSphere()\nScaleMesh bike,.75,1,2\nSetEntityPosition bike,0,1,0\nSetEntityShine bike,1\nSetEntityColor bike,192,0,255\n\nLocal camera:TCamera=CreateCamera()\nTurnEntity camera,45,0,0\nLocal cam_d#=30\n\nLocal light:TLight=CreateLight()\nTurnEntity light,45,45,0\n\nLocal add_flag=False,add_cnt\n\nWhile Not KeyHit(KEY_ESCAPE) And Not AppTerminate()\n\tSetWireFrame KeyDown(KEY_W)\n\t\n\tIf KeyDown(KEY_A) cam_d=cam_d-1\n\tIf KeyDown(KEY_Z) cam_d=cam_d+1\n\t\n\tLocal turn=0\n\tIf smooth\n\t\tIf KeyDown(KEY_LEFT) turn=5\n\t\tIf KeyDown(KEY_RIGHT) turn=-5\n\t\tIf turn\n\t\t\tadd_cnt=add_cnt+1\n\t\t\tIf add_cnt=3\n\t\t\t\tadd_cnt=0\n\t\t\t\tadd_flag=True\n\t\t\tElse\n\t\t\t\tadd_flag=False\n\t\t\tEndIf\n\t\tElse If add_cnt\n\t\t\tadd_cnt=0\n\t\t\tadd_flag=True\n\t\tElse\n\t\t\tadd_flag=False\n\t\tEndIf\n\tElse\n\t\tIf KeyHit(KEY_LEFT) turn=90\n\t\tIf KeyHit(KEY_RIGHT) turn=-90\n\t\tIf turn Then add_flag=True Else add_flag=False\n\tEndIf\n\t\n\tIf turn\n\t\tTurnEntity bike,0,turn,0\n\tEndIf\n\t\n\tMoveEntity bike,0,0,1\n\t\n\tLocal x#,y#,z#\n\tGetEntityPosition bike,x,y,z\n\tIf add_flag\n\t\tAddSurfaceVertex trail_surf,x,2,z,0,0\n\t\tAddSurfaceVertex trail_surf,x,0,z,0,1\n\t\tAddSurfaceTriangle trail_surf,trail_vert,trail_vert+2,trail_vert+3\n\t\tAddSurfaceTriangle trail_surf,trail_vert,trail_vert+3,trail_vert+1\n\t\tAddSurfaceTriangle trail_surf,trail_vert,trail_vert+3,trail_vert+2\n\t\tAddSurfaceTriangle trail_surf,trail_vert,trail_vert+1,trail_vert+3\n\t\ttrail_vert=trail_vert+2\n\tElse\n\t\tSetSurfaceCoords trail_surf,trail_vert,x,2,z\n\t\tSetSurfaceCoords trail_surf,trail_vert+1,x,0,z\n\tEndIf\n\t\n\tUpdateWorld\n\t\n\tSetEntityPosition camera,x-5,0,z\n\tMoveEntity camera,0,0,-cam_d\n\n'\tPositionEntity camera,0,20,0\n'\tPointEntity camera,bike\n\t\n\tRenderWorld\n\tFlip\nWend\n\n","old_contents":"\nStrict\n\nImport MaxB3D.Drivers\n\nGraphics 800,600\n\nLocal smooth=True\n\nLocal grid_tex:TTexture=CreateTexture( 32,32,8 )\nSetTextureScale grid_tex,10,10\nSetBuffer TextureBuffer( grid_tex )\nSetColor 0,0,64;DrawRect 0,0,32,32\nSetColor 0,0,255;DrawRect 0,0,32,32\nSetBuffer BackBuffer()\n\n\nLocal grid_plane:TFlat=CreateFlat()\nSetEntityTexture grid_plane,grid_tex\nSetEntityBlend grid_plane,1\nSetEntityAlpha grid_plane,.6\nSetEntityFX grid_plane,FX_FULLBRIGHT\n\n'Local mirror:TMirror=CreateMirror()\nrem\nLocal pivot=CreatePivot()\n\np=CreatePivot( p )\ncube=CreateCube( p )\nScaleEntity cube,1,1,5\nSetAnimKey cube,0\nRotateEntity cube,0,120,0\nSetAnimKey cube,60\nRotateEntity cube,0,240,0\nSetAnimKey cube,120\nRotateEntity cube,0,0,0\nSetAnimKey cube,180\nAddAnimSeq p,180\n\nFor x=-100 To 100 Step 25\nFor z=-100 To 100 Step 25\ne=CopyEntity( p,pivot )\nPositionEntity e,x,5,z\nAnimate e\nNext\nNext\nFreeEntity cube\nEnd Rem\n\nLocal trail_mesh:TMesh=CreateMesh()\nLocal trail_brush:TBrush=CreateBrush()\nSetBrushColor trail_brush,255,0,0\nSetBrushBlend trail_brush,3\nSetBrushFX trail_brush,FX_FULLBRIGHT\nLocal trail_surf:TSurface=AddMeshSurface( trail_mesh,trail_brush )\nAddSurfaceVertex trail_surf,0,2,0,0,0\nAddSurfaceVertex trail_surf,0,0,0,0,1\nAddSurfaceVertex trail_surf,0,2,0,0,0\nAddSurfaceVertex trail_surf,0,0,0,0,1\nAddSurfaceTriangle trail_surf,0,2,3\nAddSurfaceTriangle trail_surf,0,3,1\nAddSurfaceTriangle trail_surf,0,3,2\nAddSurfaceTriangle trail_surf,0,1,3\nLocal trail_vert=2\n\nLocal bike:TMesh=CreateSphere()\nScaleMesh bike,.75,1,2\nSetEntityPosition bike,0,1,0\nSetEntityShine bike,1\nSetEntityColor bike,192,0,255\n\nLocal camera:TCamera=CreateCamera()\nTurnEntity camera,45,0,0\nLocal cam_d#=30\n\nLocal light:TLight=CreateLight()\nTurnEntity light,45,45,0\n\nLocal add_flag=False,add_cnt\n\nWhile Not KeyHit(KEY_ESCAPE) And Not AppTerminate()\n\tSetWireFrame KeyDown(KEY_W)\n\t\n\tIf KeyDown(KEY_A) cam_d=cam_d-1\n\tIf KeyDown(KEY_Z) cam_d=cam_d+1\n\t\n\tLocal turn=0\n\tIf smooth\n\t\tIf KeyDown(KEY_LEFT) turn=5\n\t\tIf KeyDown(KEY_RIGHT) turn=-5\n\t\tIf turn\n\t\t\tadd_cnt=add_cnt+1\n\t\t\tIf add_cnt=3\n\t\t\t\tadd_cnt=0\n\t\t\t\tadd_flag=True\n\t\t\tElse\n\t\t\t\tadd_flag=False\n\t\t\tEndIf\n\t\tElse If add_cnt\n\t\t\tadd_cnt=0\n\t\t\tadd_flag=True\n\t\tElse\n\t\t\tadd_flag=False\n\t\tEndIf\n\tElse\n\t\tIf KeyHit(KEY_LEFT) turn=90\n\t\tIf KeyHit(KEY_RIGHT) turn=-90\n\t\tIf turn Then add_flag=True Else add_flag=False\n\tEndIf\n\t\n\tIf turn\n\t\tTurnEntity bike,0,turn,0\n\tEndIf\n\t\n\tMoveEntity bike,0,0,1\n\t\n\tLocal x#,y#,z#\n\tGetEntityPosition bike,x,y,z\n\tIf add_flag\n\t\tAddSurfaceVertex trail_surf,x,2,z,0,0\n\t\tAddSurfaceVertex trail_surf,x,0,z,0,1\n\t\tAddSurfaceTriangle trail_surf,trail_vert,trail_vert+2,trail_vert+3\n\t\tAddSurfaceTriangle trail_surf,trail_vert,trail_vert+3,trail_vert+1\n\t\tAddSurfaceTriangle trail_surf,trail_vert,trail_vert+3,trail_vert+2\n\t\tAddSurfaceTriangle trail_surf,trail_vert,trail_vert+1,trail_vert+3\n\t\ttrail_vert=trail_vert+2\n\tElse\n\t\tSetSurfaceCoords trail_surf,trail_vert,x,2,z\n\t\tSetSurfaceCoords trail_surf,trail_vert+1,x,0,z\n\tEndIf\n\t\n\tUpdateWorld\n\t\n\tSetEntityPosition camera,x-5,0,z\n\tMoveEntity camera,0,0,-cam_d\n\n'\tPositionEntity camera,0,20,0\n'\tPointEntity camera,bike\n\t\n\tRenderWorld\n\tFlip\nWend\n\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"a6ee81c5a5d454b2b6d9453d6ade98d49bb7b051","subject":"Added CenterMesh function.","message":"Added CenterMesh function.\n","repos":"kfprimm\/maxb3d,kfprimm\/maxb3d","old_file":"functions.mod\/functions.bmx","new_file":"functions.mod\/functions.bmx","new_contents":"\nStrict\n\nRem\n\tbbdoc: MaxB3D procedural functions\nEnd Rem\nModule MaxB3D.Functions\nModuleInfo \"Author: Kevin Primm\"\nModuleInfo \"License: MIT\"\n\nImport MaxB3D.Core\n\nRem\n\tbbdoc: Draws the world in its current state.\n\tabout: Tweening is not yet implemented.\nEnd Rem\nFunction RenderWorld:TRenderInfo(tween#=1.0)\n\tReturn _currentworld.Render(tween)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction RenderCamera:TRenderInfo(camera:TCamera)\n\tReturn _currentworld.RenderCamera(camera)\nEnd Function\nRem\n\tbbdoc: Advances all animations and updates collision\/physics.\nEnd Rem\nFunction UpdateWorld(anim_speed#=1.0,collision_speed#=1.0)\n\tReturn _currentworld.Update(anim_speed,collision_speed)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetCollisions(src,dest,methd,response)\n\tReturn _currentworld.SetCollisions(src,dest,methd,response)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetAmbientLight(red Var,green Var,blue Var)\n\tReturn _currentworld.GetAmbientLight(red,green,blue)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetAmbientLight(red,green,blue)\n\tReturn _currentworld.SetAmbientLight(red,green,blue)\nEnd Function\nRem\n\treturns: Wireframe rendering state, see #SetWireframe\nEnd Rem\nFunction GetWireFrame()\n\tReturn _currentworld.GetWireFrame()\nEnd Function\nRem\n\tbbdoc: Enable\/disable global wireframe rendering.\n\tabout: @SetWireframe can enable wireframe rendering for the entire scene. Alternatively, calling #SetEntityFX with @FX_WIREFRAME will cause only \n\t\t\ta single entity's wireframe to be rendered.\nEnd Rem\nFunction SetWireFrame(enable)\n\tReturn _currentworld.SetWireFrame(enable)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction WorldPick:TPick[](src:Object, target:Object, sort = False)\n\treturn _currentworld.Pick(src,target, sort)\nEnd function\n\n'Bodies\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction CreateBody:TBody()\n\tReturn _currentworld.AddBody()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetBodyMass#(body:TBody)\n\tReturn body.GetMass()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetBodyMass(body:TBody,mass#)\n\tReturn body.SetMass(mass)\nEnd Function\n\n'Brushes\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction CreateBrush:TBrush(url:Object=Null)\n\tReturn _currentworld.AddBrush(url)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction CopyBrush:TBrush(brush:TBrush)\n\tReturn brush.Copy()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetBrushColor(brush:TBrush,red Var,green Var,blue Var)\n\tReturn brush.GetColor(red,green,blue)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetBrushColor(brush:TBrush,red,green,blue)\n\tReturn brush.SetColor(red,green,blue)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetBrushAlpha#(brush:TBrush)\n\tReturn brush.GetAlpha()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetBrushAlpha(brush:TBrush,alpha#)\n\tReturn brush.SetAlpha(alpha)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetBrushShine#(brush:TBrush)\n\tReturn brush.GetShine()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetBrushShine(brush:TBrush,shine#)\n\tReturn brush.SetShine(shine)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetBrushTexture:TTexture(brush:TBrush,index=0)\n\tReturn brush.GetTexture(index)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetBrushTexture(brush:TBrush,texture:TTexture,index=0,frame=0)\n\tReturn brush.SetTexture(texture,index,frame)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetBrushFrame(brush:TBrush,index=0)\n\tReturn brush.GetFrame(index)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetBrushFrame(brush:TBrush,frame,index=0)\n\tReturn brush.SetFrame(frame,index)\nEnd Function\nRem\n\tbbdoc: Get brush effects.\nEnd Rem\nFunction GetBrushFX(brush:TBrush)\n\tReturn brush.GetFX()\nEnd Function\nRem\n\tbbdoc: Set various rendering effects for a brush.\n\tabout:\nEnd Rem\nFunction SetBrushFX(brush:TBrush,fx)\n\tReturn brush.SetFX(fx)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetBrushBlend(brush:TBrush)\n\tReturn brush.GetBlend()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetBrushBlend(brush:TBrush,fx)\n\tReturn brush.SetBlend(fx)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetBrushShader:TShader(brush:TBrush)\n\tReturn brush.GetShader()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetBrushShader(brush:TBrush,shader:TShader)\n\tReturn brush.SetShader(shader)\nEnd Function\n\n'Cameras\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction CreateCamera:TCamera(parent:TEntity=Null)\n\tReturn _currentworld.AddCamera(parent)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetCameraMode(camera:TCamera)\n\tReturn camera.GetMode()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetCameraMode(camera:TCamera,mode)\n\tReturn camera.SetMode(mode)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetCameraFogMode(camera:TCamera)\n\tReturn camera.GetFogMode()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetCameraFogMode(camera:TCamera,mode)\n\tReturn camera.SetFogMode(mode)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetCameraFogColor(camera:TCamera,red Var,green Var,blue Var)\n\tReturn camera.GetFogColor(red,green,blue)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetCameraFogColor(camera:TCamera,red,green,blue)\n\tReturn camera.SetFogColor(red,green,blue)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetCameraFogRange(camera:TCamera,near# Var,far# Var)\n\tReturn camera.GetFogRange(near,far)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetCameraFogRange(camera:TCamera,near#,far#)\n\tReturn camera.SetFogRange(near,far)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetCameraViewport(camera:TCamera,x Var,y Var,width Var,height Var)\n\tReturn camera.GetViewport(x,y,width,height)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetCameraViewport(camera:TCamera,x,y,width,height)\n\tReturn camera.SetViewport(x,y,width,height)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetCameraClsMode(camera:TCamera)\n\tReturn camera.GetClsMode()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetCameraClsMode(camera:TCamera,mode)\n\tReturn camera.SetClsMode(mode)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetCameraRange(camera:TCamera,near# Var,far# Var)\n\tReturn camera.GetRange(near,far)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetCameraRange(camera:TCamera,near#,far#)\n\tReturn camera.SetRange(near,far)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetCameraZoom#(camera:TCamera)\n\tReturn camera.GetZoom()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetCameraZoom(camera:TCamera,zoom#)\n\tReturn camera.SetZoom(zoom)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetCameraFOV#(camera:TCamera)\n\tReturn camera.GetFOV()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetCameraFOV(camera:TCamera,angle#)\n\tReturn camera.SetFOV(angle)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction CameraInView#(camera:TCamera,target:Object)\n\tReturn camera.InView(target)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction CameraProject(camera:TCamera,target:Object,x# Var,y# Var, offset#[] = Null)\n\tReturn camera.Project(target,x,y,offset)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction CameraUnproject(camera:TCamera,wx#,wy#,wz#,x# Var,y# Var,z# Var)\n\tReturn camera.Unproject(wx,wy,wz,x,y,z)\nEnd Function\n\n'Entities\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction CopyEntity:TEntity(entity:TEntity,parent:TEntity=Null)\n\tReturn entity.Copy(parent)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction FreeEntity(entity:TEntity)\n\tReturn entity.Free()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetEntityParent:TEntity(entity:TEntity)\n\tReturn entity.GetParent()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetEntityParent(entity:TEntity,parent:TEntity)\n\tReturn entity.SetParent(parent)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction CountEntityChildren(entity:TEntity,recursive=False)\n\tReturn entity.CountChildren(recursive)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction FindEntityChild:TEntity(entity:TEntity, name$, recursive = False)\n\tReturn entity.FindChild(name, recursive)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetEntityVisible(entity:TEntity)\n\tReturn entity.GetVisible()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetEntityVisible(entity:TEntity,visible)\n\tReturn entity.SetVisible(visible)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetEntityOrder(entity:TEntity)\n\tReturn entity.GetOrder()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetEntityOrder(entity:TEntity,order)\n\tReturn entity.SetOrder(order)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetEntityName$(entity:TEntity)\n\tReturn entity.GetName()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetEntityName(entity:TEntity,name$)\n\tReturn entity.SetName(name)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetEntityBrush:TBrush(entity:TEntity)\n\tReturn entity.GetBrush()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetEntityBrush(entity:TEntity,brush:TBrush)\n\tReturn entity.SetBrush(brush)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetEntityColor(entity:TEntity,red Var,green Var,blue Var)\n\tReturn entity.GetColor(red,green,blue)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetEntityColor(entity:TEntity,red,green,blue)\n\tReturn entity.SetColor(red,green,blue)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetEntityAlpha#(entity:TEntity)\n\tReturn entity.GetAlpha()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetEntityAlpha(entity:TEntity,alpha#)\n\tReturn entity.SetAlpha(alpha)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetEntityShine#(entity:TEntity)\n\tReturn entity.GetShine()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetEntityShine(entity:TEntity,shine#)\n\tReturn entity.SetShine(shine)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetEntityTexture:TTexture(entity:TEntity,index=0)\n\tReturn entity.GetTexture(index)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetEntityTexture(entity:TEntity,texture:TTexture,index=0,frame=0)\n\tReturn entity.SetTexture(texture,index,frame)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetEntityFX(entity:TEntity)\n\tReturn entity.GetFX()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetEntityFX(entity:TEntity,fx)\n\tReturn entity.SetFX(fx)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetEntityBlend(entity:TEntity)\n\tReturn entity.GetBlend()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetEntityBlend(entity:TEntity,blend)\n\tReturn entity.SetBlend(blend)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetEntityShader:TShader(entity:TEntity)\n\tReturn entity.GetShader()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetEntityShader(entity:TEntity,shader:TShader)\n\tReturn entity.SetShader(shader)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction TurnEntity(entity:TEntity,pitch#,yaw#,roll#,glob=False)\n\tReturn entity.Turn(pitch,yaw,roll,glob)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction PointEntity(entity:TEntity,target:Object,roll#=0.0)\n\tReturn entity.Point(target,roll)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction MoveEntity(entity:TEntity,x#,y#,z#)\n\tReturn entity.Move(x,y,z)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction TranslateEntity(entity:TEntity,x#,y#,z#,glob=True)\n\tReturn entity.Translate(x,y,z,glob)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetEntityScale(entity:TEntity,x# Var,y# Var,z# Var,glob=False)\n\tReturn entity.GetScale(x,y,z,glob)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetEntityScale(entity:TEntity,x#,y#,z#,glob=False)\n\tReturn entity.SetScale(x,y,z,glob)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetEntityRotation(entity:TEntity,pitch# Var,yaw# Var,roll# Var,glob=False)\n\tReturn entity.GetRotation(pitch,yaw,roll,glob)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetEntityRotation(entity:TEntity,pitch#,yaw#,roll#,glob=False)\n\tReturn entity.SetRotation(pitch,yaw,roll,glob)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetEntityPosition(entity:TEntity,x# Var,y# Var,z# Var,glob=False)\n\tReturn entity.GetPosition(x,y,z,glob)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetEntityPosition(entity:TEntity,x#,y#,z#,glob=False)\n\tReturn entity.SetPosition(x,y,z,glob)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction TransformEntity(entity:TEntity,matrix:TMatrix,glob=False)\n\tReturn entity.Transform(matrix,glob)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetEntityCollisions:TCollision[](entity:TEntity)\n\tReturn entity.GetCollisions()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetEntityBox(entity:TEntity,x# Var,y# Var,z# Var,width# Var,height# Var,depth# Var)\n\tReturn entity.GetBox(x,y,z,width,height,depth)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetEntityBox(entity:TEntity,x#,y#,z#,width#,height#,depth#)\n\tReturn entity.SetBox(x,y,z,width,height,depth)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetEntityRadius(entity:TEntity,x# Var,y# Var)\n\tReturn entity.GetRadius(x,y)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetEntityRadius(entity:TEntity,x#,y#=-1)\n\tReturn entity.SetRadius(x,y)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetEntityType(entity:TEntity)\n\tReturn entity.GetType()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetEntityType(entity:TEntity,typ,recursive=False)\n\tReturn entity.SetType(typ,recursive)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction ResetEntity(entity:TEntity)\n\tReturn entity.Reset()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetEntityCullRadius#(entity:TEntity)\n\tReturn entity.GetCullRadius()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetEntityCullRadius#(entity:TEntity,radius#)\n\tReturn entity.SetCullRadius(radius)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetEntityDistance#(entity:TEntity,target:Object)\n\tReturn entity.GetDistance(target)\nEnd Function\n\n'Lights\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction CreateLight:TLight(typ=LIGHT_DIRECTIONAL,parent:TEntity=Null)\n\tReturn _currentworld.AddLight(typ,parent)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetLightRange#(light:TLight)\n\tReturn light.GetRange()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetLightRange(light:TLight,range#)\n\tReturn light.SetRange(range)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetLightAngles(light:TLight,inner# Var,outer# Var)\n\tReturn light.GetAngles(inner,outer)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetLightAngles(light:TLight,inner#,outer#)\n\tReturn light.SetAngles(inner,outer)\nEnd Function\n\n'Meshes\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction CreateMesh:TMesh(parent:TEntity=Null)\n\tReturn _currentworld.AddMesh(\"*null*\",parent)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction LoadMesh:TMesh(url:Object,parent:TEntity=Null)\n\tReturn _currentworld.AddMesh(url,parent)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetMeshSurface:TSurface(mesh:TMesh,index)\n\tReturn mesh.GetSurface(index)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction AddMeshSurface:TSurface(mesh:TMesh,brush:TBrush=Null,vertexcount=0,trianglecount=0)\n\tReturn mesh.AddSurface(brush,vertexcount,trianglecount)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SwapMeshSurface(mesh:TMesh,surface:TSurface,new_surface:TSurface)\n\tReturn mesh.SwapSurface(surface,new_surface)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction CloneMesh:TMesh(mesh:TMesh,parent:TEntity=Null)\n\tReturn mesh.Clone(parent)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction TranslateMesh(mesh:TMesh,x#,y#,z#)\n\tReturn mesh.Translate(x,y,z)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction ScaleMesh(mesh:TMesh,x#,y#,z#)\n\tReturn mesh.Scale(x,y,z)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction RotateMesh(mesh:TMesh,pitch#,yaw#,roll#)\n\tReturn mesh.Rotate(pitch,yaw,roll)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction PositionMesh(mesh:TMesh,x#,y#,z#)\n\tReturn mesh.Position(x,y,z)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction CenterMesh(mesh:TMesh)\n\tReturn mesh.Center()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetMeshSize(mesh:TMesh,width# Var,height# Var,depth# Var)\n\tReturn mesh.GetSize(width,height,depth)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction FitMesh(mesh:TMesh,x#,y#,z#,width#,height#,depth#,uniform=False)\n\tReturn mesh.Fit(x,y,z,width,height,depth,uniform)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction FlipMesh(mesh:TMesh)\n\tReturn mesh.Flip()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction UpdateMeshNormals(mesh:TMesh,smoothing=True)\n\tReturn mesh.UpdateNormals(smoothing)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetMeshAnim(mesh:TMesh,seq:TAnimSeq,mode=ANIMATION_LOOP,speed#=1.0)\n\tReturn mesh.SetAnim(seq,mode,speed)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction AddMeshAnimSeq:TAnimSeq(mesh:TMesh)\n\tReturn mesh.AddAnimSeq(0,0)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction ExtractMeshAnimSeq:TAnimSeq(mesh:TMesh,start_frame,end_frame)\n\tReturn mesh.ExtractAnimSeq(start_frame,end_frame)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetMeshAnimSeq:TAnimSeq(mesh:TMesh)\n\tReturn mesh.GetAnimSeq()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetMeshAnimSeq(mesh:TMesh,seq:TAnimSeq)\n\tReturn mesh.SetAnimSeq(seq)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetMeshAnimMode(mesh:TMesh)\n\tReturn mesh.GetAnimMode()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetMeshAnimMode(mesh:TMesh,mode)\n\tReturn mesh.SetAnimMode(mode)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetMeshAnimSpeed#(mesh:TMesh)\n\tReturn mesh.GetAnimSpeed()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetMeshAnimSpeed(mesh:TMesh,speed#)\n\tReturn mesh.SetAnimSpeed(speed)\nEnd Function\n\n'Animation\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction CreateAnimSeq:TAnimSeq(first,last,name$=\"\")\n\tReturn TAnimSeq.Create(first,last,name)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetAnimSeqName$(seq:TAnimSeq)\n\tReturn seq.GetName()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetAnimSeqName(seq:TAnimSeq,name$)\n\tReturn seq.SetName(name)\nEnd Function\n\n'Pivots\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction CreatePivot:TPivot(parent:TEntity=Null)\n\tReturn _currentworld.AddPivot(parent)\nEnd Function\n\n'Flats (plane)\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction CreateFlat:TFlat(parent:TEntity=Null)\n\tReturn _currentworld.AddFlat(parent)\nEnd Function\n\n'Sprite\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction CreateSprite:TSprite(parent:TEntity=Null)\n\tReturn _currentworld.AddSprite(Null,TEXTURE_DEFAULT,parent)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction LoadSprite:TSprite(url:Object,flags=TEXTURE_DEFAULT,parent:TEntity=Null)\n\tReturn _currentworld.AddSprite(url,flags,parent)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetSpriteAngle#(sprite:TSprite)\n\tReturn sprite.GetAngle()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetSpriteAngle(sprite:TSprite,angle#)\n\tReturn sprite.SetAngle(angle)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetSpriteHandle(sprite:TSprite,x# Var,y# Var)\n\tReturn sprite.GetHandle(x,y)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd RemS\nFunction SetSpriteHandle(sprite:TSprite,x#,y#)\n\tReturn sprite.SetHandle(x,y)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetSpriteViewMode(sprite:TSprite)\n\tReturn sprite.GetViewMode()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetSpriteViewMode(sprite:TSprite,mode)\n\tReturn sprite.SetViewMode(mode)\nEnd Function\n\n'Surfaces\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction CountSurfaceVertices(surface:TSurface)\n\tReturn surface.CountVertices()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction CountSurfaceTriangles(surface:TSurface)\n\tReturn surface.CountTriangles()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction UpdateSurfaceNormals(surface:TSurface,smoothing=True)\n\tReturn surface.UpdateNormals(smoothing)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction ResizeSurface(surface:TSurface,vertex_count,triangle_count)\n\tReturn surface.Resize(vertex_count,triangle_count)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction AddSurfaceVertex(surface:TSurface,x#,y#,z#,u#=0.0,v#=0.0)\n\tReturn surface.AddVertex(x,y,z,u,v)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetSurfaceCoords(surface:TSurface,index,x# Var,y# Var,z# Var)\n\tReturn surface.GetCoords(index,x,y,z)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetSurfaceCoords(surface:TSurface,index,x#,y#,z#)\n\tReturn surface.SetCoords(index,x,y,z)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetSurfaceColor(surface:TSurface,index,red Var,green Var,blue Var,alpha# Var)\n\tReturn surface.GetColor(index,red,green,blue,alpha)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetSurfaceColor(surface:TSurface,index,red,green,blue,alpha#)\n\tReturn surface.SetColor(index,red,green,blue,alpha)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetSurfaceNormal(surface:TSurface,index,nx# Var,ny# Var,nz# Var)\n\tReturn surface.GetNormal(index,nx,ny,nz)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetSurfaceNormal(surface:TSurface,index,nx#,ny#,nz#)\n\tReturn surface.SetNormal(index,nx,ny,nz)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetSurfaceTexCoords(surface:TSurface,index,u# Var,v# Var,set=0)\n\tReturn surface.GetTexCoords(index,u,v,set)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetSurfaceTexCoords(surface:TSurface,index,u#,v#,set=0)\n\tReturn surface.SetTexCoords(index,u,v,set)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction AddSurfaceTriangle(surface:TSurface,v0,v1,v2)\n\tReturn surface.AddTriangle(v0,v1,v2)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetSurfaceTriangle(surface:TSurface,index,v0 Var,v1 Var,v2 Var)\n\tReturn surface.GetTriangle(index,v0,v1,v2)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetSurfaceTriangle(surface:TSurface,index,v0,v1,v2)\n\tReturn surface.SetTriangle(index,v0,v1,v2)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetSurfaceBrush:TBrush(surface:TSurface)\n\tReturn surface.GetBrush()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetSurfaceBrush(surface:TSurface,brush:TBrush)\n\tReturn surface.SetBrush(brush)\nEnd Function\n\n'Terrains\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction CreateTerrain:TTerrain(size,parent:TEntity=Null)\n\tReturn _currentworld.AddTerrain([size],parent)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction LoadTerrain:TTerrain(url:Object,parent:TEntity=Null)\n\tReturn _currentworld.AddTerrain(url,parent)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetTerrainDetail(terrain:TTerrain,lmax,max_tris,clmax=-1)\n\tReturn terrain.SetDetail(lmax,max_tris,clmax)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetTerrainHeight#(terrain:TTerrain,x,z)\n\tReturn terrain.GetHeight(x,z)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetTerrainHeight(terrain:TTerrain,height#,x,z)\n\tReturn terrain.SetHeight(height,x,z)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetTerrainSize(terrain:TTerrain)\n\tReturn terrain.GetSize()\nEnd Function\n\n'Textures\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction CreateTexture:TTexture(width,height,flags=TEXTURE_COLOR|TEXTURE_MIPMAP,frames=1)\n\tLocal texture:TTexture=_currentworld.AddTexture([width,height,frames],flags)\n\ttexture.SetPixmap(CreatePixmap(width,height,PF_RGBA8888))\n\tReturn texture\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction LoadTexture:TTexture(url:Object,flags=TEXTURE_COLOR|TEXTURE_MIPMAP)\n\tReturn _currentworld.AddTexture(url,flags)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction LockTexture:TPixmap(texture:TTexture)\n\tReturn texture.Lock()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction UnlockTexture(texture:TTexture)\n\tReturn texture.Unlock()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetTextureFlags(texture:TTexture)\n\tReturn texture.GetFlags()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetTextureFlags(texture:TTexture,flags)\n\tReturn texture.SetFlags(flags)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetTextureBlend(texture:TTexture)\n\tReturn texture.GetBlend()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetTextureBlend(texture:TTexture,blend)\n\tReturn texture.SetBlend(blend)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetTextureCoords(texture:TTexture)\n\tReturn texture.GetCoords()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetTextureCoords(texture:TTexture,coords)\n\tReturn texture.SetCoords(coords)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetTextureScale(texture:TTexture,x# Var,y# Var)\n\tReturn texture.GetScale(x,y)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetTextureScale(texture:TTexture,x#,y#)\n\tReturn texture.SetScale(x,y)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetTextureRotation#(texture:TTexture)\n\tReturn texture.GetRotation()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetTextureRotation(texture:TTexture,rotation#)\n\tReturn texture.SetRotation(rotation)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetTexturePosition(texture:TTexture,x# Var,y# Var)\n\tReturn texture.GetPosition(x,y)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetTexturePosition(texture:TTexture,x#,y#)\n\tReturn texture.SetPosition(x,y)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetTextureSize(texture:TTexture,width Var,height Var)\n\tReturn texture.GetSize(width,height)\nEnd Function\n\n'BSP\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction LoadBSPModel:TBSPModel(url:Object,parent:TEntity=Null)\n\tReturn _currentworld.AddBSPModel(url,parent)\nEnd Function\n","old_contents":"\nStrict\n\nRem\n\tbbdoc: MaxB3D procedural functions\nEnd Rem\nModule MaxB3D.Functions\nModuleInfo \"Author: Kevin Primm\"\nModuleInfo \"License: MIT\"\n\nImport MaxB3D.Core\n\nRem\n\tbbdoc: Draws the world in its current state.\n\tabout: Tweening is not yet implemented.\nEnd Rem\nFunction RenderWorld:TRenderInfo(tween#=1.0)\n\tReturn _currentworld.Render(tween)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction RenderCamera:TRenderInfo(camera:TCamera)\n\tReturn _currentworld.RenderCamera(camera)\nEnd Function\nRem\n\tbbdoc: Advances all animations and updates collision\/physics.\nEnd Rem\nFunction UpdateWorld(anim_speed#=1.0,collision_speed#=1.0)\n\tReturn _currentworld.Update(anim_speed,collision_speed)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetCollisions(src,dest,methd,response)\n\tReturn _currentworld.SetCollisions(src,dest,methd,response)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetAmbientLight(red Var,green Var,blue Var)\n\tReturn _currentworld.GetAmbientLight(red,green,blue)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetAmbientLight(red,green,blue)\n\tReturn _currentworld.SetAmbientLight(red,green,blue)\nEnd Function\nRem\n\treturns: Wireframe rendering state, see #SetWireframe\nEnd Rem\nFunction GetWireFrame()\n\tReturn _currentworld.GetWireFrame()\nEnd Function\nRem\n\tbbdoc: Enable\/disable global wireframe rendering.\n\tabout: @SetWireframe can enable wireframe rendering for the entire scene. Alternatively, calling #SetEntityFX with @FX_WIREFRAME will cause only \n\t\t\ta single entity's wireframe to be rendered.\nEnd Rem\nFunction SetWireFrame(enable)\n\tReturn _currentworld.SetWireFrame(enable)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction WorldPick:TPick[](src:Object, target:Object, sort = False)\n\treturn _currentworld.Pick(src,target, sort)\nEnd function\n\n'Bodies\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction CreateBody:TBody()\n\tReturn _currentworld.AddBody()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetBodyMass#(body:TBody)\n\tReturn body.GetMass()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetBodyMass(body:TBody,mass#)\n\tReturn body.SetMass(mass)\nEnd Function\n\n'Brushes\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction CreateBrush:TBrush(url:Object=Null)\n\tReturn _currentworld.AddBrush(url)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction CopyBrush:TBrush(brush:TBrush)\n\tReturn brush.Copy()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetBrushColor(brush:TBrush,red Var,green Var,blue Var)\n\tReturn brush.GetColor(red,green,blue)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetBrushColor(brush:TBrush,red,green,blue)\n\tReturn brush.SetColor(red,green,blue)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetBrushAlpha#(brush:TBrush)\n\tReturn brush.GetAlpha()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetBrushAlpha(brush:TBrush,alpha#)\n\tReturn brush.SetAlpha(alpha)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetBrushShine#(brush:TBrush)\n\tReturn brush.GetShine()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetBrushShine(brush:TBrush,shine#)\n\tReturn brush.SetShine(shine)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetBrushTexture:TTexture(brush:TBrush,index=0)\n\tReturn brush.GetTexture(index)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetBrushTexture(brush:TBrush,texture:TTexture,index=0,frame=0)\n\tReturn brush.SetTexture(texture,index,frame)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetBrushFrame(brush:TBrush,index=0)\n\tReturn brush.GetFrame(index)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetBrushFrame(brush:TBrush,frame,index=0)\n\tReturn brush.SetFrame(frame,index)\nEnd Function\nRem\n\tbbdoc: Get brush effects.\nEnd Rem\nFunction GetBrushFX(brush:TBrush)\n\tReturn brush.GetFX()\nEnd Function\nRem\n\tbbdoc: Set various rendering effects for a brush.\n\tabout:\nEnd Rem\nFunction SetBrushFX(brush:TBrush,fx)\n\tReturn brush.SetFX(fx)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetBrushBlend(brush:TBrush)\n\tReturn brush.GetBlend()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetBrushBlend(brush:TBrush,fx)\n\tReturn brush.SetBlend(fx)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetBrushShader:TShader(brush:TBrush)\n\tReturn brush.GetShader()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetBrushShader(brush:TBrush,shader:TShader)\n\tReturn brush.SetShader(shader)\nEnd Function\n\n'Cameras\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction CreateCamera:TCamera(parent:TEntity=Null)\n\tReturn _currentworld.AddCamera(parent)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetCameraMode(camera:TCamera)\n\tReturn camera.GetMode()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetCameraMode(camera:TCamera,mode)\n\tReturn camera.SetMode(mode)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetCameraFogMode(camera:TCamera)\n\tReturn camera.GetFogMode()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetCameraFogMode(camera:TCamera,mode)\n\tReturn camera.SetFogMode(mode)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetCameraFogColor(camera:TCamera,red Var,green Var,blue Var)\n\tReturn camera.GetFogColor(red,green,blue)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetCameraFogColor(camera:TCamera,red,green,blue)\n\tReturn camera.SetFogColor(red,green,blue)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetCameraFogRange(camera:TCamera,near# Var,far# Var)\n\tReturn camera.GetFogRange(near,far)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetCameraFogRange(camera:TCamera,near#,far#)\n\tReturn camera.SetFogRange(near,far)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetCameraViewport(camera:TCamera,x Var,y Var,width Var,height Var)\n\tReturn camera.GetViewport(x,y,width,height)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetCameraViewport(camera:TCamera,x,y,width,height)\n\tReturn camera.SetViewport(x,y,width,height)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetCameraClsMode(camera:TCamera)\n\tReturn camera.GetClsMode()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetCameraClsMode(camera:TCamera,mode)\n\tReturn camera.SetClsMode(mode)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetCameraRange(camera:TCamera,near# Var,far# Var)\n\tReturn camera.GetRange(near,far)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetCameraRange(camera:TCamera,near#,far#)\n\tReturn camera.SetRange(near,far)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetCameraZoom#(camera:TCamera)\n\tReturn camera.GetZoom()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetCameraZoom(camera:TCamera,zoom#)\n\tReturn camera.SetZoom(zoom)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetCameraFOV#(camera:TCamera)\n\tReturn camera.GetFOV()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetCameraFOV(camera:TCamera,angle#)\n\tReturn camera.SetFOV(angle)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction CameraInView#(camera:TCamera,target:Object)\n\tReturn camera.InView(target)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction CameraProject(camera:TCamera,target:Object,x# Var,y# Var, offset#[] = Null)\n\tReturn camera.Project(target,x,y,offset)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction CameraUnproject(camera:TCamera,wx#,wy#,wz#,x# Var,y# Var,z# Var)\n\tReturn camera.Unproject(wx,wy,wz,x,y,z)\nEnd Function\n\n'Entities\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction CopyEntity:TEntity(entity:TEntity,parent:TEntity=Null)\n\tReturn entity.Copy(parent)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction FreeEntity(entity:TEntity)\n\tReturn entity.Free()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetEntityParent:TEntity(entity:TEntity)\n\tReturn entity.GetParent()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetEntityParent(entity:TEntity,parent:TEntity)\n\tReturn entity.SetParent(parent)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction CountEntityChildren(entity:TEntity,recursive=False)\n\tReturn entity.CountChildren(recursive)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction FindEntityChild:TEntity(entity:TEntity, name$, recursive = False)\n\tReturn entity.FindChild(name, recursive)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetEntityVisible(entity:TEntity)\n\tReturn entity.GetVisible()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetEntityVisible(entity:TEntity,visible)\n\tReturn entity.SetVisible(visible)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetEntityOrder(entity:TEntity)\n\tReturn entity.GetOrder()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetEntityOrder(entity:TEntity,order)\n\tReturn entity.SetOrder(order)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetEntityName$(entity:TEntity)\n\tReturn entity.GetName()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetEntityName(entity:TEntity,name$)\n\tReturn entity.SetName(name)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetEntityBrush:TBrush(entity:TEntity)\n\tReturn entity.GetBrush()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetEntityBrush(entity:TEntity,brush:TBrush)\n\tReturn entity.SetBrush(brush)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetEntityColor(entity:TEntity,red Var,green Var,blue Var)\n\tReturn entity.GetColor(red,green,blue)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetEntityColor(entity:TEntity,red,green,blue)\n\tReturn entity.SetColor(red,green,blue)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetEntityAlpha#(entity:TEntity)\n\tReturn entity.GetAlpha()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetEntityAlpha(entity:TEntity,alpha#)\n\tReturn entity.SetAlpha(alpha)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetEntityShine#(entity:TEntity)\n\tReturn entity.GetShine()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetEntityShine(entity:TEntity,shine#)\n\tReturn entity.SetShine(shine)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetEntityTexture:TTexture(entity:TEntity,index=0)\n\tReturn entity.GetTexture(index)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetEntityTexture(entity:TEntity,texture:TTexture,index=0,frame=0)\n\tReturn entity.SetTexture(texture,index,frame)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetEntityFX(entity:TEntity)\n\tReturn entity.GetFX()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetEntityFX(entity:TEntity,fx)\n\tReturn entity.SetFX(fx)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetEntityBlend(entity:TEntity)\n\tReturn entity.GetBlend()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetEntityBlend(entity:TEntity,blend)\n\tReturn entity.SetBlend(blend)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetEntityShader:TShader(entity:TEntity)\n\tReturn entity.GetShader()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetEntityShader(entity:TEntity,shader:TShader)\n\tReturn entity.SetShader(shader)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction TurnEntity(entity:TEntity,pitch#,yaw#,roll#,glob=False)\n\tReturn entity.Turn(pitch,yaw,roll,glob)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction PointEntity(entity:TEntity,target:Object,roll#=0.0)\n\tReturn entity.Point(target,roll)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction MoveEntity(entity:TEntity,x#,y#,z#)\n\tReturn entity.Move(x,y,z)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction TranslateEntity(entity:TEntity,x#,y#,z#,glob=True)\n\tReturn entity.Translate(x,y,z,glob)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetEntityScale(entity:TEntity,x# Var,y# Var,z# Var,glob=False)\n\tReturn entity.GetScale(x,y,z,glob)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetEntityScale(entity:TEntity,x#,y#,z#,glob=False)\n\tReturn entity.SetScale(x,y,z,glob)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetEntityRotation(entity:TEntity,pitch# Var,yaw# Var,roll# Var,glob=False)\n\tReturn entity.GetRotation(pitch,yaw,roll,glob)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetEntityRotation(entity:TEntity,pitch#,yaw#,roll#,glob=False)\n\tReturn entity.SetRotation(pitch,yaw,roll,glob)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetEntityPosition(entity:TEntity,x# Var,y# Var,z# Var,glob=False)\n\tReturn entity.GetPosition(x,y,z,glob)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetEntityPosition(entity:TEntity,x#,y#,z#,glob=False)\n\tReturn entity.SetPosition(x,y,z,glob)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction TransformEntity(entity:TEntity,matrix:TMatrix,glob=False)\n\tReturn entity.Transform(matrix,glob)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetEntityCollisions:TCollision[](entity:TEntity)\n\tReturn entity.GetCollisions()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetEntityBox(entity:TEntity,x# Var,y# Var,z# Var,width# Var,height# Var,depth# Var)\n\tReturn entity.GetBox(x,y,z,width,height,depth)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetEntityBox(entity:TEntity,x#,y#,z#,width#,height#,depth#)\n\tReturn entity.SetBox(x,y,z,width,height,depth)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetEntityRadius(entity:TEntity,x# Var,y# Var)\n\tReturn entity.GetRadius(x,y)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetEntityRadius(entity:TEntity,x#,y#=-1)\n\tReturn entity.SetRadius(x,y)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetEntityType(entity:TEntity)\n\tReturn entity.GetType()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetEntityType(entity:TEntity,typ,recursive=False)\n\tReturn entity.SetType(typ,recursive)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction ResetEntity(entity:TEntity)\n\tReturn entity.Reset()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetEntityCullRadius#(entity:TEntity)\n\tReturn entity.GetCullRadius()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetEntityCullRadius#(entity:TEntity,radius#)\n\tReturn entity.SetCullRadius(radius)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetEntityDistance#(entity:TEntity,target:Object)\n\tReturn entity.GetDistance(target)\nEnd Function\n\n'Lights\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction CreateLight:TLight(typ=LIGHT_DIRECTIONAL,parent:TEntity=Null)\n\tReturn _currentworld.AddLight(typ,parent)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetLightRange#(light:TLight)\n\tReturn light.GetRange()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetLightRange(light:TLight,range#)\n\tReturn light.SetRange(range)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetLightAngles(light:TLight,inner# Var,outer# Var)\n\tReturn light.GetAngles(inner,outer)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetLightAngles(light:TLight,inner#,outer#)\n\tReturn light.SetAngles(inner,outer)\nEnd Function\n\n'Meshes\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction CreateMesh:TMesh(parent:TEntity=Null)\n\tReturn _currentworld.AddMesh(\"*null*\",parent)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction LoadMesh:TMesh(url:Object,parent:TEntity=Null)\n\tReturn _currentworld.AddMesh(url,parent)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetMeshSurface:TSurface(mesh:TMesh,index)\n\tReturn mesh.GetSurface(index)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction AddMeshSurface:TSurface(mesh:TMesh,brush:TBrush=Null,vertexcount=0,trianglecount=0)\n\tReturn mesh.AddSurface(brush,vertexcount,trianglecount)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SwapMeshSurface(mesh:TMesh,surface:TSurface,new_surface:TSurface)\n\tReturn mesh.SwapSurface(surface,new_surface)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction CloneMesh:TMesh(mesh:TMesh,parent:TEntity=Null)\n\tReturn mesh.Clone(parent)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction TranslateMesh(mesh:TMesh,x#,y#,z#)\n\tReturn mesh.Translate(x,y,z)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction ScaleMesh(mesh:TMesh,x#,y#,z#)\n\tReturn mesh.Scale(x,y,z)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction RotateMesh(mesh:TMesh,pitch#,yaw#,roll#)\n\tReturn mesh.Rotate(pitch,yaw,roll)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction PositionMesh(mesh:TMesh,x#,y#,z#)\n\tReturn mesh.Position(x,y,z)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetMeshSize(mesh:TMesh,width# Var,height# Var,depth# Var)\n\tReturn mesh.GetSize(width,height,depth)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction FitMesh(mesh:TMesh,x#,y#,z#,width#,height#,depth#,uniform=False)\n\tReturn mesh.Fit(x,y,z,width,height,depth,uniform)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction FlipMesh(mesh:TMesh)\n\tReturn mesh.Flip()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction UpdateMeshNormals(mesh:TMesh,smoothing=True)\n\tReturn mesh.UpdateNormals(smoothing)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetMeshAnim(mesh:TMesh,seq:TAnimSeq,mode=ANIMATION_LOOP,speed#=1.0)\n\tReturn mesh.SetAnim(seq,mode,speed)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction AddMeshAnimSeq:TAnimSeq(mesh:TMesh)\n\tReturn mesh.AddAnimSeq(0,0)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction ExtractMeshAnimSeq:TAnimSeq(mesh:TMesh,start_frame,end_frame)\n\tReturn mesh.ExtractAnimSeq(start_frame,end_frame)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetMeshAnimSeq:TAnimSeq(mesh:TMesh)\n\tReturn mesh.GetAnimSeq()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetMeshAnimSeq(mesh:TMesh,seq:TAnimSeq)\n\tReturn mesh.SetAnimSeq(seq)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetMeshAnimMode(mesh:TMesh)\n\tReturn mesh.GetAnimMode()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetMeshAnimMode(mesh:TMesh,mode)\n\tReturn mesh.SetAnimMode(mode)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetMeshAnimSpeed#(mesh:TMesh)\n\tReturn mesh.GetAnimSpeed()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetMeshAnimSpeed(mesh:TMesh,speed#)\n\tReturn mesh.SetAnimSpeed(speed)\nEnd Function\n\n'Animation\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction CreateAnimSeq:TAnimSeq(first,last,name$=\"\")\n\tReturn TAnimSeq.Create(first,last,name)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetAnimSeqName$(seq:TAnimSeq)\n\tReturn seq.GetName()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetAnimSeqName(seq:TAnimSeq,name$)\n\tReturn seq.SetName(name)\nEnd Function\n\n'Pivots\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction CreatePivot:TPivot(parent:TEntity=Null)\n\tReturn _currentworld.AddPivot(parent)\nEnd Function\n\n'Flats (plane)\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction CreateFlat:TFlat(parent:TEntity=Null)\n\tReturn _currentworld.AddFlat(parent)\nEnd Function\n\n'Sprite\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction CreateSprite:TSprite(parent:TEntity=Null)\n\tReturn _currentworld.AddSprite(Null,TEXTURE_DEFAULT,parent)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction LoadSprite:TSprite(url:Object,flags=TEXTURE_DEFAULT,parent:TEntity=Null)\n\tReturn _currentworld.AddSprite(url,flags,parent)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetSpriteAngle#(sprite:TSprite)\n\tReturn sprite.GetAngle()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetSpriteAngle(sprite:TSprite,angle#)\n\tReturn sprite.SetAngle(angle)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetSpriteHandle(sprite:TSprite,x# Var,y# Var)\n\tReturn sprite.GetHandle(x,y)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd RemS\nFunction SetSpriteHandle(sprite:TSprite,x#,y#)\n\tReturn sprite.SetHandle(x,y)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetSpriteViewMode(sprite:TSprite)\n\tReturn sprite.GetViewMode()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetSpriteViewMode(sprite:TSprite,mode)\n\tReturn sprite.SetViewMode(mode)\nEnd Function\n\n'Surfaces\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction CountSurfaceVertices(surface:TSurface)\n\tReturn surface.CountVertices()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction CountSurfaceTriangles(surface:TSurface)\n\tReturn surface.CountTriangles()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction UpdateSurfaceNormals(surface:TSurface,smoothing=True)\n\tReturn surface.UpdateNormals(smoothing)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction ResizeSurface(surface:TSurface,vertex_count,triangle_count)\n\tReturn surface.Resize(vertex_count,triangle_count)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction AddSurfaceVertex(surface:TSurface,x#,y#,z#,u#=0.0,v#=0.0)\n\tReturn surface.AddVertex(x,y,z,u,v)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetSurfaceCoords(surface:TSurface,index,x# Var,y# Var,z# Var)\n\tReturn surface.GetCoords(index,x,y,z)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetSurfaceCoords(surface:TSurface,index,x#,y#,z#)\n\tReturn surface.SetCoords(index,x,y,z)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetSurfaceColor(surface:TSurface,index,red Var,green Var,blue Var,alpha# Var)\n\tReturn surface.GetColor(index,red,green,blue,alpha)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetSurfaceColor(surface:TSurface,index,red,green,blue,alpha#)\n\tReturn surface.SetColor(index,red,green,blue,alpha)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetSurfaceNormal(surface:TSurface,index,nx# Var,ny# Var,nz# Var)\n\tReturn surface.GetNormal(index,nx,ny,nz)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetSurfaceNormal(surface:TSurface,index,nx#,ny#,nz#)\n\tReturn surface.SetNormal(index,nx,ny,nz)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetSurfaceTexCoords(surface:TSurface,index,u# Var,v# Var,set=0)\n\tReturn surface.GetTexCoords(index,u,v,set)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetSurfaceTexCoords(surface:TSurface,index,u#,v#,set=0)\n\tReturn surface.SetTexCoords(index,u,v,set)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction AddSurfaceTriangle(surface:TSurface,v0,v1,v2)\n\tReturn surface.AddTriangle(v0,v1,v2)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetSurfaceTriangle(surface:TSurface,index,v0 Var,v1 Var,v2 Var)\n\tReturn surface.GetTriangle(index,v0,v1,v2)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetSurfaceTriangle(surface:TSurface,index,v0,v1,v2)\n\tReturn surface.SetTriangle(index,v0,v1,v2)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetSurfaceBrush:TBrush(surface:TSurface)\n\tReturn surface.GetBrush()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetSurfaceBrush(surface:TSurface,brush:TBrush)\n\tReturn surface.SetBrush(brush)\nEnd Function\n\n'Terrains\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction CreateTerrain:TTerrain(size,parent:TEntity=Null)\n\tReturn _currentworld.AddTerrain([size],parent)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction LoadTerrain:TTerrain(url:Object,parent:TEntity=Null)\n\tReturn _currentworld.AddTerrain(url,parent)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetTerrainDetail(terrain:TTerrain,lmax,max_tris,clmax=-1)\n\tReturn terrain.SetDetail(lmax,max_tris,clmax)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetTerrainHeight#(terrain:TTerrain,x,z)\n\tReturn terrain.GetHeight(x,z)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetTerrainHeight(terrain:TTerrain,height#,x,z)\n\tReturn terrain.SetHeight(height,x,z)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetTerrainSize(terrain:TTerrain)\n\tReturn terrain.GetSize()\nEnd Function\n\n'Textures\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction CreateTexture:TTexture(width,height,flags=TEXTURE_COLOR|TEXTURE_MIPMAP,frames=1)\n\tLocal texture:TTexture=_currentworld.AddTexture([width,height,frames],flags)\n\ttexture.SetPixmap(CreatePixmap(width,height,PF_RGBA8888))\n\tReturn texture\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction LoadTexture:TTexture(url:Object,flags=TEXTURE_COLOR|TEXTURE_MIPMAP)\n\tReturn _currentworld.AddTexture(url,flags)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction LockTexture:TPixmap(texture:TTexture)\n\tReturn texture.Lock()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction UnlockTexture(texture:TTexture)\n\tReturn texture.Unlock()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetTextureFlags(texture:TTexture)\n\tReturn texture.GetFlags()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetTextureFlags(texture:TTexture,flags)\n\tReturn texture.SetFlags(flags)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetTextureBlend(texture:TTexture)\n\tReturn texture.GetBlend()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetTextureBlend(texture:TTexture,blend)\n\tReturn texture.SetBlend(blend)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetTextureCoords(texture:TTexture)\n\tReturn texture.GetCoords()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetTextureCoords(texture:TTexture,coords)\n\tReturn texture.SetCoords(coords)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetTextureScale(texture:TTexture,x# Var,y# Var)\n\tReturn texture.GetScale(x,y)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetTextureScale(texture:TTexture,x#,y#)\n\tReturn texture.SetScale(x,y)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetTextureRotation#(texture:TTexture)\n\tReturn texture.GetRotation()\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetTextureRotation(texture:TTexture,rotation#)\n\tReturn texture.SetRotation(rotation)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetTexturePosition(texture:TTexture,x# Var,y# Var)\n\tReturn texture.GetPosition(x,y)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetTexturePosition(texture:TTexture,x#,y#)\n\tReturn texture.SetPosition(x,y)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetTextureSize(texture:TTexture,width Var,height Var)\n\tReturn texture.GetSize(width,height)\nEnd Function\n\n'BSP\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction LoadBSPModel:TBSPModel(url:Object,parent:TEntity=Null)\n\tReturn _currentworld.AddBSPModel(url,parent)\nEnd Function\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"15cecc3cc7e0b27fa610af6af487ebad879e2097","subject":"Fixed missing 'obj.' bit for method calls without return types.","message":"Fixed missing 'obj.' bit for method calls without return types.\n","repos":"nilium\/lugi.mod,nilium\/lugi.mod","old_file":"generator.mod\/method.bmx","new_file":"generator.mod\/method.bmx","new_contents":"Rem\n\tLuGI - Copyright (c) 2009 Noel R. Cower\n\n\tPermission is hereby granted, free of charge, to any person obtaining a copy\n\tof this software and associated documentation files (the \"Software\"), to deal\n\tin the Software without restriction, including without limitation the rights\n\tto use, copy, modify, merge, publish, distribute, sublicense, and\/or sell\n\tcopies of the Software, and to permit persons to whom the Software is\n\tfurnished to do so, subject to the following conditions:\n\n\tThe above copyright notice and this permission notice shall be included in\n\tall copies or substantial portions of the Software.\n\n\tTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n\tIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n\tFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n\tAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n\tLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n\tOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n\tTHE SOFTWARE.\nEndRem\n\n'Strict\n\n'Import brl.Map\n\n'Import \"metadata.bmx\"\t\t' Metadata names\n'Import \"utility.bmx\"\t\t' FormatString\n\nPrivate\n\nConst REGISTER_METHOD_NAME$ = \"register_method\"\n\nGlobal g_CanReturnBoolTypes:TList = New TList\ng_CanReturnBoolTypes.AddLast(IntTypeID) ' Trying to do this in order of which would be most likely..\ng_CanReturnBoolTypes.AddLast(ShortTypeID)\ng_CanReturnBoolTypes.AddLast(ByteTypeID)\ng_CanReturnBoolTypes.AddLast(LongTypeID)\n\nType LExposedMethod\n\tField methodid:TMethod\n\tField owner:TTypeID\n\tField name$\n\tField hidden%\n\tField booltype%\n\tField tag$\n\t\n\tMethod New()\n\t\ttag = \"_\"+GenerateUniqueTag(6)\n\tEnd Method\n\t\n\t' Initializes an exposed method - returns Null if the method is hidden\/not exposed\n\tMethod InitWithMethod:LExposedMethod(meth:TMethod, owner:TTypeID)\n\t\tmethodid = meth\n\t\tSelf.owner = owner\n\t\t\n\t\t' get metadata\n\t\thidden = methodid.Metadata(LUGI_META_HIDDEN).ToInt()>0\n\t\t\n\t\tIf hidden Then\n\t\t\tReturn Null\n\t\tEndIf\n\t\t\n\t\tname = methodid.Metadata(LUGI_META_RENAME).Trim()\n\t\tIf Not name Then\n\t\t\tname = methodid.Name()\n\t\tEndIf\n\t\t\n\t\tReturn Self\n\tEnd Method\n\t\n\tMethod PreInitBlock:String(fortype:TTypeID=Null)\n\t\tIf hidden Then\n\t\t\tReturn Null\n\t\tEndIf\n\t\t\n\t\tIf fortype Then\n\t\t\t' Registers the method with LuGI's core\n\t\t\tReturn REGISTER_METHOD_NAME+\"( \" + ImplementationName() + \", ~q\" + name + \"~q, Byte Ptr(TTypeID.ForName(~q\" + fortype.Name() + \"~q)._class) )\"\n\t\tElse\n\t\t\t' If no type is provided, then it's assumed that the method is global (e.g., a noclass method)\n\t\t\tReturn REGISTER_METHOD_NAME+\"( \" + ImplementationName() + \", ~q\" + name + \"~q, Null )\"\n\t\tEndIf\n\tEnd Method\n\t\n\tMethod PostInitBlock:String()\n\t\t' noop - methods have no post-init block\n\tEnd Method\n\t\n\tMethod ImplementationName$()\n\t\t' This should never actually be necessary, since hidden methods shouldn't even be\n\t\t' created\n\t\tIf hidden Then\n\t\t\tReturn Null\n\t\tEndIf\n\t\t\n\t\tReturn LUGI_GLOBAL_PREFIX+LUGI_METH_PREFIX+owner.Name()+\"_\"+name+tag\n\tEnd Method\n\t\n\t' Returns the implementation of the method\n\tMethod Implementation:String( instanceMethod:Int, objectName$=Null )\n\t\tIf hidden Then\n\t\t\tReturn Null\n\t\tEndIf\n\t\t\n\t\tLocal head$ = \"Function \"+ImplementationName()+\":Int( lua_vm:Byte Ptr )\"\n\t\t\n\t\t' Whether or not to add the NoDebug flag to method glue functions\n\t\tIf LUGI_METH_NODEBUG Then\n\t\t\thead :+ \" NoDebug\"\n\t\tEndIf\n\t\t\n\t\thead :+ \"~n\"\n\t\t\n\t\t' Tail is same for all methods: return 1 and end function\n\t\tLocal tail$ = \"~nEnd Function~n\"\n\t\t\n\t\t' output string always starts with the head\n\t\tLocal outs$ = head\n\t\t\n\t\t' Choose the implementation type depending on whether this is an instance method or\n\t\t' a noclass method\n\t\tIf instanceMethod Then\n\t\t\touts :+ __instanceImp()\n\t\tElse\n\t\t\t' Pass the name of the global instance for the noclass method\n\t\t\touts :+ __noclassImp(objectName)\n\t\tEndIf\n\t\t\n\t\tLocal retType:TTypeID = methodid.TypeID()\n\t\tLocal pushfn$ = LuaPushFunctionForTypeID(retType)\n\t\t' select the push function needed depending on whether or not the method is to return\n\t\t' a bool and if it matches a type that can be used to return a bool\n\t\tIf retType And pushfn Then\n\t\t\tIf methodid.Metadata(LUGI_META_BOOL).ToInt()>0 And g_CanReturnBoolTypes.Contains(retType) Then\n\t\t\t\touts :+ \"~tlua_pushboolean\"\n\t\t\tElse\n\t\t\t\touts :+ \"~t\"+pushfn\n\t\t\tEndIf\n\t\t\n\t\t\t' method parameters\n\t\t\touts :+ \"( lua_vm, obj.\"+methodid.Name()+\"(\"+(\", \".Join(__argNames()))+\") )~n~n~tReturn 1~n\"\n\t\tElse\n\t\t\t' Method doesn't have a return type (or a supported return type), returns nothing\n\t\t\touts :+ \"~tobj.\"+methodid.Name()+\"(\"+(\", \".Join(__argNames()))+\")~n~n~tReturn 0~n\"\n\t\tEndIf\n\t\t\n\t\touts :+ tail\n\t\t\n\t\tReturn outs\n\tEnd Method\n\t\n\t' Returns a formatted block of code for the arguments (with tabs\/line-endings, as opposed to\n\t' something like PreInitBlock which returns just the line)\n\t' stackstart designates the first stack index of the argument\n\tMethod __argsBlock:String(stackstart%)\n\t\tConst argLocalFormat$ = \"Local \\1:\\2 = \\3\"\n\t\tConst argGetterFormat$ = \"\\1 = \\2\"\n\t\t\n\t\tLocal args:TTypeID[] = methodid.ArgTypes()\n\t\t\n\t\t' If there are no arguments, we have nothing to show\n\t\tIf args.Length = 0 Then\n\t\t\tReturn Null\n\t\tEndIf\n\t\t\n\t\tLocal argNames$[] = __argNames()\n\t\tLocal argGetters$[args.Length]\n\t\tLocal argLocals$[args.Length]\n\t\t\n\t\tFor Local idx:Int = 0 Until args.Length\n\t\t\t' generate the Local declaration\n\t\t\targLocals[idx] = FormatString(argLocalFormat, [argNames[idx], args[idx].Name(), DefaultValueForTypeID(args[idx])])\n\t\t\t' and the getter - many '~t's follow\n\t\t\tSelect args[idx]\n\t\t\t\tCase IntTypeId, ShortTypeId, ByteTypeId, LongTypeId\n\t\t\t\t\targGetters[idx] = ..\n\t\t\t\t\t\t\"Select lua_type(lua_vm, \"+(stackstart+idx)+\")\" + ..\n\t\t\t\t\t\t\t\"~n~t~t~t~tCase LUA_TBOOLEAN~n\" + ..\n\t\t\t\t\t\t\t\t\"~t~t~t~t~t\" + argNames[idx] + \" = \" + LuaToFunctionForTypeID(args[idx], \"lua_vm\", stackstart+idx, True) + ..\n\t\t\t\t\t\t\t\"~n~t~t~t~tDefault~n\" + ..\t\t ' attempt to convert whatever is on the stack to an integer\n\t\t\t\t\t\t\t\t\"~t~t~t~t~t\" + argNames[idx] + \" = \" + LuaToFunctionForTypeID(args[idx], \"lua_vm\", stackstart+idx, False) + ..\n\t\t\t\t\t\t\"~n~t~t~tEnd Select\"\n\t\t\t\t\n\t\t\t\tDefault\n\t\t\t\t\targGetters[idx] = argNames[idx] + \" = \" + LuaToFunctionForTypeID(args[idx], \"lua_vm\", stackstart+idx, False)\n\t\t\tEnd Select\t\n\t\tNext\n\t\t\n\t\tLocal outs$ = \"~t\"+(\"~n~t\".Join(argLocals))+\"~n\"\n\t\t\n\t\tIf args.Length > 1 Then\n\t\t\t' multiple arguments get a select\/case block\n\t\t\t\n\t\t\touts :+ \"~t' Get arguments off stack~n\"\n\t\t\touts :+ \"~tSelect lua_gettop(lua_vm)~n\"\n\t\t\tIf stackstart > 1 Then\n\t\t\t\touts :+ \"~t~tCase \"+(stackstart-1)+\"~n~t~t~t' no arguments provided~n~n\"\n\t\t\tEndIf\n\t\t\tFor Local idx:Int = 0 Until args.Length\n\t\t\t\tIf idx < args.Length - 1 Then\n\t\t\t\t\touts :+ \"~t~tCase \"+(idx+stackstart)+\"~n\"\n\t\t\t\tElse\n\t\t\t\t\touts :+ \"~t~tDefault~n\"\n\t\t\t\tEndIf\n\t\t\t\touts :+ \"~t~t~t\"+(\"~n~t~t~t\".Join(argGetters[..idx+1]))+\"~n\"\n\t\t\t\tIf idx < args.Length-1 Then\n\t\t\t\t\touts :+ \"~n\"\n\t\t\t\tEndIf\n\t\t\tNext\n\t\t\touts :+ \"~tEnd Select ' Arguments retrieved from stack~n\"\n\t\tElseIf args.Length = 1\n\t\t\t' If there's only one argument, simplify it to use a single conditional\n\t\t\touts :+ ..\n\t\t\t\t\"~tIf \"+(stackstart)+\" <= lua_gettop(lua_vm) Then~n\" + ..\n\t\t\t\t\t\"~t~t\"+argGetters[0].Replace(\"~n~t\", \"~n\") + ..\n\t\t\t\t\"~n~tEndIf~n\"\n\t\tEndIf\n\t\t\n\t\tReturn outs\n\tEnd Method\n\t\n\tMethod __argNames$[]()\n\t\tLocal argNames:String[methodid.ArgTypes().Length]\n\t\tFor Local idx:Int = 0 Until argNames.Length\n\t\t\targNames[idx] = \"_arg_\"+(idx+1)\n\t\tNext\n\t\tReturn argNames\n\tEnd Method\n\t\n\t' Implementation for instances\/static types\n\tMethod __instanceImp:String()\n\t\tLocal outs$\n\t\touts :+ \"~tLocal obj:\"+owner.Name()+\" = \"+LuaToFunctionForTypeID(owner, \"lua_vm\", 1, False)+\"~n\"\n\t\touts :+ __argsBlock(2)+\"~n\"\n\t\t\n\t\tReturn outs\n\tEnd Method\n\t\n\t' Implementation for types without classes (has an upvalue object associated with the closure)\n\tMethod __noclassImp:String(objname$)\n\t\tLocal outs$\n\t\t\n\t\touts :+ \"~tLocal obj:\"+owner.Name()+\" = \"+objname+\"~n\"\n\t\touts :+ __argsBlock(1)+\"~n\"\n\t\t\n\t\tReturn outs\n\tEnd Method\nEnd Type\n","old_contents":"Rem\n\tLuGI - Copyright (c) 2009 Noel R. Cower\n\n\tPermission is hereby granted, free of charge, to any person obtaining a copy\n\tof this software and associated documentation files (the \"Software\"), to deal\n\tin the Software without restriction, including without limitation the rights\n\tto use, copy, modify, merge, publish, distribute, sublicense, and\/or sell\n\tcopies of the Software, and to permit persons to whom the Software is\n\tfurnished to do so, subject to the following conditions:\n\n\tThe above copyright notice and this permission notice shall be included in\n\tall copies or substantial portions of the Software.\n\n\tTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n\tIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n\tFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n\tAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n\tLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n\tOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n\tTHE SOFTWARE.\nEndRem\n\n'Strict\n\n'Import brl.Map\n\n'Import \"metadata.bmx\"\t\t' Metadata names\n'Import \"utility.bmx\"\t\t' FormatString\n\nPrivate\n\nConst REGISTER_METHOD_NAME$ = \"register_method\"\n\nGlobal g_CanReturnBoolTypes:TList = New TList\ng_CanReturnBoolTypes.AddLast(IntTypeID) ' Trying to do this in order of which would be most likely..\ng_CanReturnBoolTypes.AddLast(ShortTypeID)\ng_CanReturnBoolTypes.AddLast(ByteTypeID)\ng_CanReturnBoolTypes.AddLast(LongTypeID)\n\nType LExposedMethod\n\tField methodid:TMethod\n\tField owner:TTypeID\n\tField name$\n\tField hidden%\n\tField booltype%\n\tField tag$\n\t\n\tMethod New()\n\t\ttag = \"_\"+GenerateUniqueTag(6)\n\tEnd Method\n\t\n\t' Initializes an exposed method - returns Null if the method is hidden\/not exposed\n\tMethod InitWithMethod:LExposedMethod(meth:TMethod, owner:TTypeID)\n\t\tmethodid = meth\n\t\tSelf.owner = owner\n\t\t\n\t\t' get metadata\n\t\thidden = methodid.Metadata(LUGI_META_HIDDEN).ToInt()>0\n\t\t\n\t\tIf hidden Then\n\t\t\tReturn Null\n\t\tEndIf\n\t\t\n\t\tname = methodid.Metadata(LUGI_META_RENAME).Trim()\n\t\tIf Not name Then\n\t\t\tname = methodid.Name()\n\t\tEndIf\n\t\t\n\t\tReturn Self\n\tEnd Method\n\t\n\tMethod PreInitBlock:String(fortype:TTypeID=Null)\n\t\tIf hidden Then\n\t\t\tReturn Null\n\t\tEndIf\n\t\t\n\t\tIf fortype Then\n\t\t\t' Registers the method with LuGI's core\n\t\t\tReturn REGISTER_METHOD_NAME+\"( \" + ImplementationName() + \", ~q\" + name + \"~q, Byte Ptr(TTypeID.ForName(~q\" + fortype.Name() + \"~q)._class) )\"\n\t\tElse\n\t\t\t' If no type is provided, then it's assumed that the method is global (e.g., a noclass method)\n\t\t\tReturn REGISTER_METHOD_NAME+\"( \" + ImplementationName() + \", ~q\" + name + \"~q, Null )\"\n\t\tEndIf\n\tEnd Method\n\t\n\tMethod PostInitBlock:String()\n\t\t' noop - methods have no post-init block\n\tEnd Method\n\t\n\tMethod ImplementationName$()\n\t\t' This should never actually be necessary, since hidden methods shouldn't even be\n\t\t' created\n\t\tIf hidden Then\n\t\t\tReturn Null\n\t\tEndIf\n\t\t\n\t\tReturn LUGI_GLOBAL_PREFIX+LUGI_METH_PREFIX+owner.Name()+\"_\"+name+tag\n\tEnd Method\n\t\n\t' Returns the implementation of the method\n\tMethod Implementation:String( instanceMethod:Int, objectName$=Null )\n\t\tIf hidden Then\n\t\t\tReturn Null\n\t\tEndIf\n\t\t\n\t\tLocal head$ = \"Function \"+ImplementationName()+\":Int( lua_vm:Byte Ptr )\"\n\t\t\n\t\t' Whether or not to add the NoDebug flag to method glue functions\n\t\tIf LUGI_METH_NODEBUG Then\n\t\t\thead :+ \" NoDebug\"\n\t\tEndIf\n\t\t\n\t\thead :+ \"~n\"\n\t\t\n\t\t' Tail is same for all methods: return 1 and end function\n\t\tLocal tail$ = \"~nEnd Function~n\"\n\t\t\n\t\t' output string always starts with the head\n\t\tLocal outs$ = head\n\t\t\n\t\t' Choose the implementation type depending on whether this is an instance method or\n\t\t' a noclass method\n\t\tIf instanceMethod Then\n\t\t\touts :+ __instanceImp()\n\t\tElse\n\t\t\t' Pass the name of the global instance for the noclass method\n\t\t\touts :+ __noclassImp(objectName)\n\t\tEndIf\n\t\t\n\t\tLocal retType:TTypeID = methodid.TypeID()\n\t\tLocal pushfn$ = LuaPushFunctionForTypeID(retType)\n\t\t' select the push function needed depending on whether or not the method is to return\n\t\t' a bool and if it matches a type that can be used to return a bool\n\t\tIf retType And pushfn Then\n\t\t\tIf methodid.Metadata(LUGI_META_BOOL).ToInt()>0 And g_CanReturnBoolTypes.Contains(retType) Then\n\t\t\t\touts :+ \"~tlua_pushboolean\"\n\t\t\tElse\n\t\t\t\touts :+ \"~t\"+pushfn\n\t\t\tEndIf\n\t\t\n\t\t\t' method parameters\n\t\t\touts :+ \"( lua_vm, obj.\"+methodid.Name()+\"(\"+(\", \".Join(__argNames()))+\") )~n~n~tReturn 1~n\"\n\t\tElse\n\t\t\t' Method doesn't have a return type (or a supported return type), returns nothing\n\t\t\touts :+ \"~t\"+methodid.Name()+\"(\"+(\", \".Join(__argNames()))+\")~n~n~tReturn 0~n\"\n\t\tEndIf\n\t\t\n\t\touts :+ tail\n\t\t\n\t\tReturn outs\n\tEnd Method\n\t\n\t' Returns a formatted block of code for the arguments (with tabs\/line-endings, as opposed to\n\t' something like PreInitBlock which returns just the line)\n\t' stackstart designates the first stack index of the argument\n\tMethod __argsBlock:String(stackstart%)\n\t\tConst argLocalFormat$ = \"Local \\1:\\2 = \\3\"\n\t\tConst argGetterFormat$ = \"\\1 = \\2\"\n\t\t\n\t\tLocal args:TTypeID[] = methodid.ArgTypes()\n\t\t\n\t\t' If there are no arguments, we have nothing to show\n\t\tIf args.Length = 0 Then\n\t\t\tReturn Null\n\t\tEndIf\n\t\t\n\t\tLocal argNames$[] = __argNames()\n\t\tLocal argGetters$[args.Length]\n\t\tLocal argLocals$[args.Length]\n\t\t\n\t\tFor Local idx:Int = 0 Until args.Length\n\t\t\t' generate the Local declaration\n\t\t\targLocals[idx] = FormatString(argLocalFormat, [argNames[idx], args[idx].Name(), DefaultValueForTypeID(args[idx])])\n\t\t\t' and the getter - many '~t's follow\n\t\t\tSelect args[idx]\n\t\t\t\tCase IntTypeId, ShortTypeId, ByteTypeId, LongTypeId\n\t\t\t\t\targGetters[idx] = ..\n\t\t\t\t\t\t\"Select lua_type(lua_vm, \"+(stackstart+idx)+\")\" + ..\n\t\t\t\t\t\t\t\"~n~t~t~t~tCase LUA_TBOOLEAN~n\" + ..\n\t\t\t\t\t\t\t\t\"~t~t~t~t~t\" + argNames[idx] + \" = \" + LuaToFunctionForTypeID(args[idx], \"lua_vm\", stackstart+idx, True) + ..\n\t\t\t\t\t\t\t\"~n~t~t~t~tDefault~n\" + ..\t\t ' attempt to convert whatever is on the stack to an integer\n\t\t\t\t\t\t\t\t\"~t~t~t~t~t\" + argNames[idx] + \" = \" + LuaToFunctionForTypeID(args[idx], \"lua_vm\", stackstart+idx, False) + ..\n\t\t\t\t\t\t\"~n~t~t~tEnd Select\"\n\t\t\t\t\n\t\t\t\tDefault\n\t\t\t\t\targGetters[idx] = argNames[idx] + \" = \" + LuaToFunctionForTypeID(args[idx], \"lua_vm\", stackstart+idx, False)\n\t\t\tEnd Select\t\n\t\tNext\n\t\t\n\t\tLocal outs$ = \"~t\"+(\"~n~t\".Join(argLocals))+\"~n\"\n\t\t\n\t\tIf args.Length > 1 Then\n\t\t\t' multiple arguments get a select\/case block\n\t\t\t\n\t\t\touts :+ \"~t' Get arguments off stack~n\"\n\t\t\touts :+ \"~tSelect lua_gettop(lua_vm)~n\"\n\t\t\tIf stackstart > 1 Then\n\t\t\t\touts :+ \"~t~tCase \"+(stackstart-1)+\"~n~t~t~t' no arguments provided~n~n\"\n\t\t\tEndIf\n\t\t\tFor Local idx:Int = 0 Until args.Length\n\t\t\t\tIf idx < args.Length - 1 Then\n\t\t\t\t\touts :+ \"~t~tCase \"+(idx+stackstart)+\"~n\"\n\t\t\t\tElse\n\t\t\t\t\touts :+ \"~t~tDefault~n\"\n\t\t\t\tEndIf\n\t\t\t\touts :+ \"~t~t~t\"+(\"~n~t~t~t\".Join(argGetters[..idx+1]))+\"~n\"\n\t\t\t\tIf idx < args.Length-1 Then\n\t\t\t\t\touts :+ \"~n\"\n\t\t\t\tEndIf\n\t\t\tNext\n\t\t\touts :+ \"~tEnd Select ' Arguments retrieved from stack~n\"\n\t\tElseIf args.Length = 1\n\t\t\t' If there's only one argument, simplify it to use a single conditional\n\t\t\touts :+ ..\n\t\t\t\t\"~tIf \"+(stackstart)+\" <= lua_gettop(lua_vm) Then~n\" + ..\n\t\t\t\t\t\"~t~t\"+argGetters[0].Replace(\"~n~t\", \"~n\") + ..\n\t\t\t\t\"~n~tEndIf~n\"\n\t\tEndIf\n\t\t\n\t\tReturn outs\n\tEnd Method\n\t\n\tMethod __argNames$[]()\n\t\tLocal argNames:String[methodid.ArgTypes().Length]\n\t\tFor Local idx:Int = 0 Until argNames.Length\n\t\t\targNames[idx] = \"_arg_\"+(idx+1)\n\t\tNext\n\t\tReturn argNames\n\tEnd Method\n\t\n\t' Implementation for instances\/static types\n\tMethod __instanceImp:String()\n\t\tLocal outs$\n\t\touts :+ \"~tLocal obj:\"+owner.Name()+\" = \"+LuaToFunctionForTypeID(owner, \"lua_vm\", 1, False)+\"~n\"\n\t\touts :+ __argsBlock(2)+\"~n\"\n\t\t\n\t\tReturn outs\n\tEnd Method\n\t\n\t' Implementation for types without classes (has an upvalue object associated with the closure)\n\tMethod __noclassImp:String(objname$)\n\t\tLocal outs$\n\t\t\n\t\touts :+ \"~tLocal obj:\"+owner.Name()+\" = \"+objname+\"~n\"\n\t\touts :+ __argsBlock(1)+\"~n\"\n\t\t\n\t\tReturn outs\n\tEnd Method\nEnd Type\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"e6cbd57193052bfb2a296241d1b7657807c502bd","subject":"[variables] (v0.23) \tdIdentifier now uses TListEx","message":"[variables] (v0.23)\n\tdIdentifier now uses TListEx\n","repos":"komiga\/duct-max,komiga\/duct-max,komiga\/duct-max","old_file":"variables.mod\/variables.bmx","new_file":"variables.mod\/variables.bmx","new_contents":"\nRem\nCopyright (c) 2010 Tim Howard\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and\/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\nEnd Rem\n\nSuperStrict\n\nRem\nbbdoc: Variables module\nEnd Rem\nModule duct.variables\n\nModuleInfo \"Version: 0.23\"\nModuleInfo \"Copyright: Tim Howard\"\nModuleInfo \"License: MIT\"\n\nModuleInfo \"History: Version 0.23\"\nModuleInfo \"History: dIdentifier now uses TListEx\"\nModuleInfo \"History: Version 0.22\"\nModuleInfo \"History: Fixed documentation, license\"\nModuleInfo \"History: Renamed TVariable to dVariable\"\nModuleInfo \"History: Renamed TIntVariable to dIntVariable\"\nModuleInfo \"History: Renamed TStringVariable to dStringVariable\"\nModuleInfo \"History: Renamed TFloatVariable to dFloatVariable\"\nModuleInfo \"History: Renamed TEvalVariable to dEvalVariable\"\nModuleInfo \"History: Renamed TIdentifier to dIdentifier\"\nModuleInfo \"History: Renamed TBoolVariable to dBoolVariable\"\nModuleInfo \"History: Version 0.21\"\nModuleInfo \"History: Corrected TVariable.RawToVariable parsing for eval variables; added allowevalvars option\"\nModuleInfo \"History: Version 0.20\"\nModuleInfo \"History: Added TBoolVariable support in TVariable.DeserializeUniversal\"\nModuleInfo \"History: Added TBoolVariable support in TVariable.RawToVariable\"\nModuleInfo \"History: Fixed an issue with eval variables in TVariable.RawToVariable\"\nModuleInfo \"History: Corrected some method names and some documentation.\"\nModuleInfo \"History: Version 0.19\"\nModuleInfo \"History: Added TBoolVariable; documentation correction\"\nModuleInfo \"History: Version 0.18\"\nModuleInfo \"History: TIdentifier.AddValue now sets the variable's parent to itself\"\nModuleInfo \"History: Added SetParent and GetParent to TVaraible\"\nModuleInfo \"History: Version 0.17\"\nModuleInfo \"History: General cleanup\"\nModuleInfo \"History: Version 0.16\"\nModuleInfo \"History: Added SetAmbiguous to all TVariable types\"\nModuleInfo \"History: Added option to always use quoting with TStringVariables (on by default)\"\nModuleInfo \"History: Fixed TStringVariable.ConvToString returning of Null strings\"\nModuleInfo \"History: Version 0.15\"\nModuleInfo \"History: Change the Create method definition for easier use\"\nModuleInfo \"History: Changed the '\/eval::' recognizer to '\/e:' (as per SNode format change)\"\nModuleInfo \"History: Added the Copy method to every variable type\"\nModuleInfo \"History: Changed some formatting\"\nModuleInfo \"History: Version 0.14\"\nModuleInfo \"History: Changed type tabbing\"\nModuleInfo \"History: Fixed script output for TStringVariable (quotes are now only added if whitespace is present)\"\nModuleInfo \"History: Fixed script output for TIdentifier (identifier names can now contain whitespace, in which case they must be quoted)\"\nModuleInfo \"History: Version 0.13\"\nModuleInfo \"History: Added the DeserializeUniversal function to TVariable\"\nModuleInfo \"History: Added Serialize and Deserialize methods to all variable types\"\nModuleInfo \"History: Version 0.12\"\nModuleInfo \"History: Changed module name from 'variablemap' to 'variables'\"\nModuleInfo \"History: Moved all of duct.utilparser here\"\nModuleInfo \"History: Added the GetTVType function to all variable types\"\nModuleInfo \"History: Moved TV_* constants from duct.template here\"\nModuleInfo \"History: Version 0.11\"\nModuleInfo \"History: Added the ReportType function to all variable types\"\nModuleInfo \"History: Version 0.10\"\nModuleInfo \"History: Added the RawToVariable function to TVariable\"\nModuleInfo \"History: General code cleanup\"\nModuleInfo \"History: Version 0.09\"\nModuleInfo \"History: Corrected usage of syntax (in Returns, Cases, News and Selects)\"\nModuleInfo \"History: Version 0.08\"\nModuleInfo \"History: Added the TEvalVariable type\"\nModuleInfo \"History: Initial release\"\n\nImport brl.stream\n\nImport duct.etc\nImport duct.objectmap\n\nRem\n\tbbdoc: Template variable type for the #dIntVariable type.\nEnd Rem\nConst TV_INTEGER:Int = 1\nRem\n\tbbdoc: Template variable type for the #dStringVariable type.\nEnd Rem\nConst TV_STRING:Int = 2\nRem\n\tbbdoc: Template variable type for the #dFloatVariable type.\nEnd Rem\nConst TV_FLOAT:Int = 3\nRem\n\tbbdoc: Template variable type for the #dEvalVariable type.\nEnd Rem\nConst TV_EVAL:Int = 4\nRem\n\tbbdoc: Template variable type for the #dIdentifier type.\nEnd Rem\nConst TV_IDEN:Int = 5\nRem\n\tbbdoc: Template variable type for the #dBoolVariable type.\nEnd Rem\nConst TV_BOOL:Int = 6\n\nRem\n\tbbdoc: duct generic variable.\n\tabout: This is the base variable type, you should extend from this to use it.\nEnd Rem\nType dVariable Abstract\n\t\n\tField m_name:String\n\tField m_parent:dVariable\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the variable's name.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetName(name:String)\n\t\tm_name = name\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the variable's name.\n\t\treturns: The variable's name.\n\tEnd Rem\n\tMethod GetName:String()\n\t\tReturn m_name\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the variable's parent.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetParent(parent:dVariable)\n\t\tm_parent = parent\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the variable's parent.\n\t\treturns: The variable's parent.\n\tEnd Rem\n\tMethod GetParent:dVariable()\n\t\tReturn m_parent\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Base method for setting the value of the variable to the given string (conversion).\n\tEnd Rem\n\tMethod SetAmbiguous(value:String) Abstract\n\t\n\tRem\n\t\tbbdoc: Base method for converting variable data to a script-ready string.\n\tEnd Rem\n\tMethod ConvToString:String() Abstract\n\t\n\tRem\n\t\tbbdoc: Base method for converting variable data to a printable\/usable-in-code string.\n\tEnd Rem\n\tMethod ValueAsString:String() Abstract\n\t\n'#end region (Field accessors)\n\t\n'#region Data handling\n\t\n\tRem\n\t\tbbdoc: Create a copy of the variable.\n\t\treturns: A clone of the variable.\n\tEnd Rem\n\tMethod Copy:dVariable() Abstract\n\t\n\tRem\n\t\tbbdoc: Serialize the variable to a stream.\n\t\treturns: Nothing.\n\t\tabout: @tv tells the method whether it should serialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod Serialize(stream:TStream, tv:Int = True, name:Int = False) Abstract\n\t\n\tRem\n\t\tbbdoc: Deserialize the variable from a stream.\n\t\treturns: The deserialized variable.\n\t\tabout: @tv tells the method whether it should deserialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod Deserialize:dVariable(stream:TStream, tv:Int = True, name:Int = False) Abstract\n\t\n'#end region (Data handling)\n\t\n\tRem\n\t\tbbdoc: Base method: Get the type of this variable.\n\tEnd Rem\n\tFunction ReportType:String() Abstract\n\t\n\tRem\n\t\tbbdoc: Base method: Get the TV_* type of this variable.\n\tEnd Rem\n\tFunction GetTVType:Int() Abstract\n\t\n\tRem\n\t\tbbdoc: Convert raw data (raw data being things like: \"\/e:(a+b\/0.4181)*a-b\" - a dEvalVariable, \"A String variable\", 3452134 - a dIntVariable, 1204.00321 - a variable) into a Variable.\n\t\treturns: A new Variable, or Null if something whacky occured.\n\t\tabout: @etype is optional, it is used to go automagically to one type of a Variable (1 & 4=String (will check for '\/e:' - dEvalVariables and dBoolVariables ['true' or 'false']), 2=Integer, 3=Float).\n\t\t@varname is also an optional parameter. It will be used as the name of the variable.\n\t\tIf @allowevalvars (defaults to False) is True, eval variables will be checked for.\n\tEnd Rem\n\tFunction RawToVariable:dVariable(vraw:String, etype:Int = 0, varname:String = \"\", allowevalvars:Int = False)\n\t\tLocal variable:dVariable\n\t\tIf vraw = Null\n\t\t\tDebugLog(\"(dVariable.RawToVariable) @vraw = Null; returning a dStringVariable (with @varname and Null value)\")\n\t\t\tReturn New dStringVariable.Create(varname, Null)\n\t\tEnd If\n\t\tIf etype = 0 ' Determine the value's type (must be either integer, double, or a string with no spaces)\n\t\t\t' ASCII '0' to '9' = 48-57; '-' = 45, '+' = 43; and '.' = 46\n\t\t\tFor Local i:Int = 0 To vraw.Length - 1\n\t\t\t\tLocal c:Int = vraw[i]\n\t\t\t\tIf c >= 48 And c <= 57 Or c = 43 Or c = 45\n\t\t\t\t\tIf etype = 0 ' Leave float and string alone\n\t\t\t\t\t\tetype = 2 ' Integer so far..\n\t\t\t\t\tEnd If\n\t\t\t\tElse If c = 46\n\t\t\t\t\tIf etype = 2 ' Already declared as an integer?\n\t\t\t\t\t\tetype = 3\n\t\t\t\t\tEnd If\n\t\t\t\tElse ' If the character is not numerical there is nothing else to deduce and the value is a string\n\t\t\t\t\tetype = 4\n\t\t\t\t\tExit\n\t\t\t\tEnd If\n\t\t\tNext\n\t\tEnd If\n\t\t\n\t\tSelect etype\n\t\t\tCase 2 ' Integer\n\t\t\t\tvariable = dVariable(New dIntVariable.Create(varname, Int(vraw)))\n\t\t\tCase 3 ' Double\/Float\n\t\t\t\tvariable = dVariable(New dFloatVariable.Create(varname, Float(vraw)))\n\t\t\tCase 1, 4\n\t\t\t\tLocal vrawlower:String = vraw.ToLower()\n\t\t\t\tIf vrawlower.StartsWith(\"\/e:\") = True and allowevalvars = True\n\t\t\t\t\tvariable = dVariable(New dEvalVariable.Create(varname, vraw[2..]))\n\t\t\t\tElse If vrawlower = \"true\" Or vrawlower = \"false\"\n\t\t\t\t\tvariable = New dBoolVariable.Create(varname, (vrawlower = \"true\") And True Or False)\n\t\t\t\tElse\n\t\t\t\t\tvariable = dVariable(New dStringVariable.Create(varname, vraw))\n\t\t\t\tEnd If\n\t\tEnd Select\n\t\t'DebugLog(\"TSNode.LoadScriptFromStream().RawToVariable(); vraw = ~q\" + vraw + \"~q \\\" + etype)\n\t\t?Debug\n\t\tIf variable = Null Then DebugLog(\"(dVariable.RawToVariable) Unknown error, 'variable' is Null.\")\n\t\t?\n\t\tReturn variable\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Universally deserialize a variable from the given stream.\n\t\treturns: A Deserialized variable.\n\t\tabout: This will deserialize any variable from the stream.\n\t\tThis requires the variable to have been serialized with the template type (see #Serialize parameters).\n\t\t@name tells the further Deserialize calls if the name should be Deserialized or not.\n\tEnd Rem\n\tFunction DeserializeUniversal:dVariable(stream:TStream, name:Int = False)\n\t\tLocal tv:Int = Int(stream.ReadByte())\n\t\tSelect tv\n\t\t\tCase TV_INTEGER\n\t\t\t\tReturn New dIntVariable.Deserialize(stream, True, name)\n\t\t\tCase TV_STRING\n\t\t\t\tReturn New dStringVariable.Deserialize(stream, True, name)\n\t\t\tCase TV_FLOAT\n\t\t\t\tReturn New dFloatVariable.Deserialize(stream, True, name)\n\t\t\tCase TV_EVAL\n\t\t\t\tReturn New dEvalVariable.Deserialize(stream, True, name)\n\t\t\tCase TV_IDEN\n\t\t\t\tReturn New dIdentifier.Deserialize(stream, True, name)\n\t\t\tCase TV_BOOL\n\t\t\t\tReturn New dBoolVariable.Deserialize(stream, True, name)\n\t\t\tDefault\n\t\t\t\tDebugLog(\"(dVariable.DeserializeUniversal) Failed to recognize the TV in the stream: \" + tv)\n\t\tEnd Select\n\t\tReturn Null\n\tEnd Function\n\t\nEnd Type\n\nRem\n\tbbdoc: duct string variable.\nEnd Rem\nType dStringVariable Extends dVariable\n\t\n\tGlobal m_alwaysusequotes:Int = True\n\t\n\tField m_value:String\n\t\n\tRem\n\t\tbbdoc: Create a new String variable.\n\t\treturns: Itself.\n\tEnd Rem\n\tMethod Create:dStringVariable(name:String = Null, value:String)\n\t\tSetName(name)\n\t\tSet(value)\n\t\tReturn Self\n\tEnd Method\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the variable's value.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod Set(value:String)\n\t\tm_value = value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the variable's value.\n\t\treturns: The value of the variable.\n\tEnd Rem\n\tMethod Get:String()\n\t\tReturn m_value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the value of the variable to the given string (ambiguous).\n\t\treturns: Nothing.\n\t\tabout: For this type, this method is no different than calling #Set.\n\tEnd Rem\n\tMethod SetAmbiguous(value:String)\n\t\tm_value = value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Convert the variable to a String.\n\t\treturns: A String representation of the variable.\n\t\tabout: This function is for script output, for in-code use see #ValueAsString.\n\tEnd Rem\n\tMethod ConvToString:String()\n\t\tIf m_alwaysusequotes = True Or m_value.Contains(\"~t\") Or m_value.Contains(\" \") Or m_value = Null\n\t\t\tReturn \"~q\" + m_value + \"~q\"\n\t\tElse\n\t\t\tReturn m_value\n\t\tEnd If\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the variable as a String.\n\t\treturns: The variable's value converted to a String.\n\t\tabout: Here for complete-ness, no difference to `instance.Get()`.\n\tEnd Rem\n\tMethod ValueAsString:String()\n\t\tReturn m_value\n\tEnd Method\n\t\n'#end region (Field accessors)\n\t\n'#region Data handling\n\t\n\tRem\n\t\tbbdoc: Create a copy of the variable\n\t\treturns: A clone of the variable.\n\tEnd Rem\n\tMethod Copy:dStringVariable()\n\t\tReturn New dStringVariable.Create(m_name, m_value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Serialize the variable to a stream.\n\t\treturns: Nothing.\n\t\tabout: @tv tells the method whether it should serialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod Serialize(stream:TStream, tv:Int = True, name:Int = False)\n\t\tIf tv = True Then stream.WriteByte(TV_STRING)\n\t\tIf name = True Then WriteLString(stream, m_name)\n\t\tWriteLString(stream, m_value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Deserialize the variable from a stream.\n\t\treturns: Itself.\n\t\tabout: @tv tells the method whether it should deserialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod Deserialize:dStringVariable(stream:TStream, tv:Int = True, name:Int = False)\n\t\tIf tv = True Then stream.ReadByte()\n\t\tIf name = True Then m_name = ReadLString(stream)\n\t\tm_value = ReadLString(stream)\n\t\tReturn Self\n\tEnd Method\n\t\n'#end region (Data handling)\n\t\n\tRem\n\t\tbbdoc: Get the type of this variable.\n\t\treturns: The type of this variable (\"string\").\n\tEnd Rem\n\tFunction ReportType:String()\n\t\tReturn \"string\"\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Get the TV type of this variable.\n\t\treturns: The TV_* type of this variable (TV_STRING).\n\tEnd Rem\n\tFunction GetTVType:Int()\n\t\tReturn TV_STRING\n\tEnd Function\n\t\nEnd Type\n\nRem\n\tbbdoc: duct Float variable.\nEnd Rem\nType dFloatVariable Extends dVariable\n\t\n\tField m_value:Float\n\t\n\tRem\n\t\tbbdoc: Create a new Float variable.\n\t\treturns: Itself.\n\tEnd Rem\n\tMethod Create:dFloatVariable(name:String = Null, value:Float)\n\t\tSetName(name)\n\t\tSet(value)\n\t\tReturn Self\n\tEnd Method\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the variable's value.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod Set(value:Float)\n\t\tm_value = value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the variable's value.\n\t\treturns: The value of the variable.\n\tEnd Rem\n\tMethod Get:Float()\n\t\tReturn m_value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the value of the variable to the given string (ambiguous).\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetAmbiguous(value:String)\n\t\tm_value = Float(value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Convert the variable to a String.\n\t\treturns: A scriptable form of the variable.\n\t\tabout: This function is for script output, for in-code use see #ValueAsString.\n\tEnd Rem\n\tMethod ConvToString:String()\n\t\tLocal conv:String = String(m_value), encountered:Int\n\t\tFor Local i:Int = conv.Find(\".\") To conv.Length - 1\n\t\t\tIf conv[i] = 48\n\t\t\t\tIf encountered = True\n\t\t\t\t\tconv = conv[..i]\n\t\t\t\t\tExit\n\t\t\t\tEnd If\n\t\t\tElse If conv[i] <> 46\n\t\t\t\tencountered = True\n\t\t\tEnd If\n\t\tNext\n\t\tReturn conv\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the variable as a String.\n\t\treturns: The variable's value converted to a String.\n\tEnd Rem\n\tMethod ValueAsString:String()\n\t\tReturn String(m_value)\n\tEnd Method\n\t\n'#end region (Field accessors)\n\t\n'#region Data handling\n\t\n\tRem\n\t\tbbdoc: Create a copy of the variable\n\t\treturns: A clone of the variable.\n\tEnd Rem\n\tMethod Copy:dFloatVariable()\n\t\tReturn New dFloatVariable.Create(m_name, m_value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Serialize the variable to a stream.\n\t\treturns: Nothing.\n\t\tabout: @tv tells the method whether it should serialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod Serialize(stream:TStream, tv:Int = True, name:Int = False)\n\t\tIf tv = True Then stream.WriteByte(TV_FLOAT)\n\t\tIf name = True Then WriteLString(stream, m_name)\n\t\tstream.WriteFloat(m_value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Deserialize the variable from a stream.\n\t\treturns: Itself.\n\t\tabout: @tv tells the method whether it should deserialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod Deserialize:dFloatVariable(stream:TStream, tv:Int = True, name:Int = False)\n\t\tIf tv = True Then stream.ReadByte()\n\t\tIf name = True Then m_name = ReadLString(stream)\n\t\tm_value = stream.ReadFloat()\n\t\tReturn Self\n\tEnd Method\n\t\n'#end region (Data handling)\n\t\n\tRem\n\t\tbbdoc: Get the type of this variable.\n\t\treturns: The type of this variable (\"float\").\n\tEnd Rem\n\tFunction ReportType:String()\n\t\tReturn \"float\"\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Get the TV type of this variable.\n\t\treturns: The TV_* type of this variable (TV_FLOAT).\n\tEnd Rem\n\tFunction GetTVType:Int()\n\t\tReturn TV_FLOAT\n\tEnd Function\n\t\nEnd Type\n\nRem\n\tbbdoc: duct Int variable.\nEnd Rem\nType dIntVariable Extends dVariable\n\t\n\tField m_value:Int\n\t\n\tRem\n\t\tbbdoc: Create a new Int variable.\n\t\treturns: Itself.\n\tEnd Rem\n\tMethod Create:dIntVariable(name:String = Null, value:Int)\n\t\tSetName(name)\n\t\tSet(value)\n\t\tReturn Self\n\tEnd Method\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the variable's value.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod Set(value:Int)\n\t\tm_value = value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the variable's value.\n\t\treturns: The value of the variable.\n\tEnd Rem\n\tMethod Get:Int()\n\t\tReturn m_value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the value of the variable to the given string (ambiguous).\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetAmbiguous(value:String)\n\t\tm_value = Int(value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Convert the variable to a String.\n\t\treturns: A string representation of the variable.\n\t\tabout: This function is for script output, for in-code use see #ValueAsString.\n\tEnd Rem\n\tMethod ConvToString:String()\n\t\tReturn String(m_value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the variable as a String.\n\t\treturns: The variable's value converted to a String.\n\tEnd Rem\n\tMethod ValueAsString:String()\n\t\tReturn String(m_value)\n\tEnd Method\n\t\n'#end region (Field accessors)\n\t\n'#region Data handling\n\t\n\tRem\n\t\tbbdoc: Create a copy of the variable\n\t\treturns: A clone of the variable.\n\tEnd Rem\n\tMethod Copy:dIntVariable()\n\t\tReturn New dIntVariable.Create(m_name, m_value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Serialize the variable to a stream.\n\t\treturns: Nothing.\n\t\tabout: @tv tells the method whether it should serialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod Serialize(stream:TStream, tv:Int = True, name:Int = False)\n\t\tIf tv = True Then stream.WriteByte(TV_INTEGER)\n\t\tIf name = True Then WriteLString(stream, m_name)\n\t\tstream.WriteInt(m_value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Deserialize the variable from a stream.\n\t\treturns: Itself.\n\t\tabout: @tv tells the method whether it should deserialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod Deserialize:dIntVariable(stream:TStream, tv:Int = True, name:Int = False)\n\t\tIf tv = True Then stream.ReadByte()\n\t\tIf name = True Then m_name = ReadLString(stream)\n\t\tm_value = stream.ReadInt()\n\t\tReturn Self\n\tEnd Method\n\t\n'#end region (Data handling)\n\t\n\tRem\n\t\tbbdoc: Get the type of this variable.\n\t\treturns: The type of this variable (\"int\").\n\tEnd Rem\n\tFunction ReportType:String()\n\t\tReturn \"int\"\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Get the TV type of this variable.\n\t\treturns: The TV_* type of this variable (TV_INTEGER).\n\tEnd Rem\n\tFunction GetTVType:Int()\n\t\tReturn TV_INTEGER\n\tEnd Function\n\t\nEnd Type\n\nRem\n\tbbdoc: duct eval variable (for bah.muparser, and the likes).\nEnd Rem\nType dEvalVariable Extends dVariable\n\t\n\tField m_value:String\n\t\n\tRem\n\t\tbbdoc: Create a new eval variable.\n\t\treturns: Itself.\n\tEnd Rem\n\tMethod Create:dEvalVariable(name:String = Null, value:String)\n\t\tSetName(name)\n\t\tSet(value)\n\t\tReturn Self\n\tEnd Method\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the equation string for the variable.\n\t\treturns: Nothing\n\tEnd Rem\n\tMethod Set(value:String)\n\t\tm_value = value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the equation string.\n\t\treturns: The equation string.\n\tEnd Rem\n\tMethod Get:String()\n\t\tReturn m_value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the value of the variable to the given string (ambiguous).\n\t\treturns: Nothing.\n\t\tabout: For this type, this method is no different than calling #Set.\n\tEnd Rem\n\tMethod SetAmbiguous(value:String)\n\t\tm_value = value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Convert the variable to a visual representation of its data.\n\t\treturns: The scriptable form of the variable.\n\t\tabout: This function is for script output, for in-code use see #ValueAsString.\n\tEnd Rem\n\tMethod ConvToString:String()\n\t\tReturn \"~q\/e:\" + m_value + \"~q\"\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the variable as a String.\n\t\treturns: The variable's value converted to a String.\n\tEnd Rem\n\tMethod ValueAsString:String()\n\t\tReturn m_value\n\tEnd Method\n\t\n'#end region (Field accessors)\n\t\n'#region Data handling\n\t\n\tRem\n\t\tbbdoc: Create a copy of the variable\n\t\treturns: A clone of the variable.\n\tEnd Rem\n\tMethod Copy:dEvalVariable()\n\t\tReturn New dEvalVariable.Create(m_name, m_value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Serialize the variable to a stream.\n\t\treturns: Nothing.\n\t\tabout: @tv tells the method whether it should serialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod Serialize(stream:TStream, tv:Int = True, name:Int = False)\n\t\tIf tv = True Then stream.WriteByte(TV_EVAL)\n\t\tIf name = True Then WriteLString(stream, m_name)\n\t\tWriteLString(stream, m_value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Deserialize the variable from a stream.\n\t\treturns: Itself.\n\t\tabout: @tv tells the method whether it should deserialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod Deserialize:dEvalVariable(stream:TStream, tv:Int = True, name:Int = False)\n\t\tIf tv = True Then stream.ReadByte()\n\t\tIf name = True Then m_name = ReadLString(stream)\n\t\tm_value = ReadLString(stream)\n\t\tReturn Self\n\tEnd Method\n\t\n'#end region (Data handling)\n\t\n\tRem\n\t\tbbdoc: Get the type of this variable.\n\t\treturns: The type of this variable (\"eval\").\n\tEnd Rem\n\tFunction ReportType:String()\n\t\tReturn \"eval\"\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Get the TV type of this variable.\n\t\treturns: The TV_* type of this variable (TV_EVAL).\n\tEnd Rem\n\tFunction GetTVType:Int()\n\t\tReturn TV_EVAL\n\tEnd Function\n\t\nEnd Type\n\nRem\n\tbbdoc: duct boolean variable.\nEnd Rem\nType dBoolVariable Extends dVariable\n\t\n\tField m_value:Int\n\t\n\tRem\n\t\tbbdoc: Create a new boolean variable.\n\t\treturns: Itself.\n\tEnd Rem\n\tMethod Create:dBoolVariable(name:String = Null, value:Int)\n\t\tSetName(name)\n\t\tSet(value)\n\t\tReturn Self\n\tEnd Method\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the variable's value.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod Set(value:Int)\n\t\tm_value = value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the variable's value.\n\t\treturns: The value of the variable.\n\tEnd Rem\n\tMethod Get:Int()\n\t\tReturn m_value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the value of the variable to the given string (ambiguous).\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetAmbiguous(value:String)\n\t\tm_value = Int(value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Convert the variable to a String.\n\t\treturns: A string representation of the variable.\n\t\tabout: This function is for script output, for in-code use see #ValueAsString.\n\tEnd Rem\n\tMethod ConvToString:String()\n\t\tReturn String(m_value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the dBoolVariable as a String.\n\t\treturns: The variable's value converted to a String.\n\tEnd Rem\n\tMethod ValueAsString:String()\n\t\tReturn String(m_value)\n\tEnd Method\n\t\n'#end region (Field accessors)\n\t\n'#region Data handling\n\t\n\tRem\n\t\tbbdoc: Create a copy of the variable\n\t\treturns: A clone of the variable.\n\tEnd Rem\n\tMethod Copy:dBoolVariable()\n\t\tReturn New dBoolVariable.Create(m_name, m_value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Serialize the variable to a stream.\n\t\treturns: Nothing.\n\t\tabout: @tv tells the method whether it should serialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod Serialize(stream:TStream, tv:Int = True, name:Int = False)\n\t\tIf tv = True Then stream.WriteByte(TV_BOOL)\n\t\tIf name = True Then WriteLString(stream, m_name)\n\t\tstream.WriteByte(Byte(m_value))\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Deserialize the variable from a stream.\n\t\treturns: The deserialized variable.\n\t\tabout: @tv tells the method whether it should deserialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod Deserialize:dBoolVariable(stream:TStream, tv:Int = True, name:Int = False)\n\t\tIf tv = True Then stream.ReadByte()\n\t\tIf name = True Then m_name = ReadLString(stream)\n\t\tm_value = Int(stream.ReadByte())\n\t\tReturn Self\n\tEnd Method\n\t\n'#end region (Data handling)\n\t\n\tRem\n\t\tbbdoc: Get the type of this variable.\n\t\treturns: The type of this variable (\"bool\").\n\tEnd Rem\n\tFunction ReportType:String()\n\t\tReturn \"bool\"\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Get the TV type of this variable.\n\t\treturns: The TV_* type of this variable (TV_BOOL).\n\tEnd Rem\n\tFunction GetTVType:Int()\n\t\tReturn TV_BOOL\n\tEnd Function\n\t\nEnd Type\n\nRem\n\tbbdoc: duct identifier (used in parsers, mostly).\nEnd Rem\nType dIdentifier Extends dVariable\n\t\n\tField m_values:TListEx\n\t\n\tMethod New()\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Create a new identifier.\n\t\treturns: Itself.\n\tEnd Rem\n\tMethod Create:dIdentifier()\n\t\tm_values = New TListEx\n\t\tReturn Self\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Create a new identifier with the given data.\n\t\treturns: Itself.\n\t\tabout: If the @values parameter is Null a new list will be created.\n\tEnd Rem\n\tMethod CreateByData:dIdentifier(name:String, values:TListEx = Null)\n\t\tSetName(name)\n\t\tIf values = Null\n\t\t\tm_values = New TListEx\n\t\tElse\n\t\t\tm_values = values\n\t\tEnd If\n\t\tReturn Self\n\tEnd Method\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the identifier's values.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetValues(values:TListEx)\n\t\tm_values = values\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the identifier's values.\n\t\treturns: A list containing the values which the identifier holds.\n\tEnd Rem\n\tMethod GetValues:TListEx()\n\t\tReturn m_values\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Deprecated for this type.\n\t\treturns: Nothing.\n\t\tabout: This does nothing.\n\tEnd Rem\n\tMethod SetAmbiguous(value:String)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Convert the identifier to a string.\n\t\treturns: A string representation of the identifier.\n\tEnd Rem\n\tMethod ConvToString:String()\n\t\tLocal op:String\n\t\tIf m_name.Contains(\"~t\") = True Or m_name.Contains(\" \") = True\n\t\t\top = \"~q\" + m_name + \"~q \"\n\t\tElse\n\t\t\top = m_name + \" \"\n\t\tEnd If\n\t\tFor Local variable:dVariable = EachIn m_values\n\t\t\top:+variable.ConvToString() + \" \"\n\t\tNext\n\t\top = op[..op.Length - 1]\n\t\tReturn op\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the identifier as a string.\n\t\treturns: The identifier contents converted to a string.\n\t\tabout: Here for complete-ness, simply calls #ConvToString.\n\tEnd Rem\n\tMethod ValueAsString:String()\n\t\tReturn ConvToString()\n\tEnd Method\n\t\n'#end region (Field accessors)\n\t\n'#region Value handling\n\t\n\tRem\n\t\tbbdoc: Get a value at an index.\n\t\treturns: The value in the identifier's list at the given index, or Null if it could not be retrieved.\n\t\tabout: The index is zero-based.\n\tEnd Rem\n\tMethod GetValueAtIndex:dVariable(index:Int)\n\t\tIf m_values <> Null And index > - 1 And index < m_values.Count()\n\t\t\tReturn dVariable(m_values.ValueAtIndex(index))\n\t\tEnd If\n\t\tReturn Null\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the number of values.\n\t\treturns: The number of values the identifier contains.\n\tEnd Rem\n\tMethod GetValueCount:Int()\n\t\tIf m_values <> Null\n\t\t\tReturn m_values.Count()\n\t\tEnd If\n\t\tReturn 0\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Add a value to the identifier.\n\t\treturns: True for success, or False for failure.\n\t\tabout: NOTE: This will set the given value's parent.\n\tEnd Rem\n\tMethod AddValue:Int(value:dVariable)\n\t\tIf m_values <> Null And value <> Null\n\t\t\tm_values.AddLast(value)\n\t\t\tvalue.SetParent(Self)\n\t\t\tReturn True\n\t\tEnd If\n\t\tReturn False\n\tEnd Method\n\t\n'#end region (Value handling)\n\t\n'#region Data handling\n\t\n\tRem\n\t\tbbdoc: Create a copy of the identifier\n\t\treturns: A clone of the identifier.\n\tEnd Rem\n\tMethod Copy:dIdentifier()\n\t\tLocal clone:dIdentifier\n\t\tclone = New dIdentifier.CreateByData(m_name)\n\t\tFor Local variable:dVariable = EachIn m_values\n\t\t\tclone.AddValue(variable.Copy())\n\t\tNext\n\t\tReturn clone\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Serialize the variable to a stream.\n\t\treturns: Nothing.\n\t\tabout: @tv tells the method whether it should serialize the TV type for the variable, or to not.\n\t\tIn this case @name tells the method whether it should serialize the values<\/b><\/i>' name (the identifier's name is always read\/written to the stream).\n\tEnd Rem\n\tMethod Serialize(stream:TStream, tv:Int = True, name:Int = False)\n\t\tLocal variable:dVariable\n\t\tIf tv = True Then stream.WriteByte(TV_STRING)\n\t\tWriteLString(stream, m_name)\n\t\tIf m_values = Null\n\t\t\tstream.WriteInt(0)\n\t\tElse\n\t\t\tstream.WriteInt(m_values.Count())\n\t\t\tFor variable = EachIn m_values\n\t\t\t\tvariable.Serialize(stream, True, name)\n\t\t\tNext\n\t\tEnd If\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Deserialize the variable from a stream.\n\t\treturns: The deserialized variable.\n\t\tabout: @tv tells the method whether it should deserialize the TV type for the variable, or to not.\n\t\tIn this case @name tells the method whether it should deserialize the values<\/b><\/i>' name (the identifier's name is always read\/written to the stream).\n\tEnd Rem\n\tMethod Deserialize:dIdentifier(stream:TStream, tv:Int = True, name:Int = False)\n\t\tLocal count:Int, n:Int\n\t\tIf tv = True Then stream.ReadByte()\n\t\tm_name = ReadLString(stream)\n\t\tcount = stream.ReadInt()\n\t\tIf count > 0\n\t\t\tFor n = 0 To count - 1\n\t\t\t\tDeserializeUniversal(stream, name)\n\t\t\tNext\n\t\tEnd If\n\t\tReturn Self\n\tEnd Method\n\t\n'#end region (Data handling)\n\t\n\tRem\n\t\tbbdoc: Get the type of this variable.\n\t\treturns: The type of this variable (\"identifier\").\n\tEnd Rem\n\tFunction ReportType:String()\n\t\tReturn \"identifier\"\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Get the TV type of this variable.\n\t\treturns: The TV_* type of this variable (TV_IDEN).\n\tEnd Rem\n\tFunction GetTVType:Int()\n\t\tReturn TV_IDEN\n\tEnd Function\n\t\nEnd Type\n\nRem\n\tbbdoc: #dVariable map (stores any variable).\nEndRem\nType dVariableMap Extends dObjectMap\n\t\n\tRem\n\t\tbbdoc: Create a new variable map.\n\t\treturns: Itself.\n\tEnd Rem\n\tMethod Create:dVariableMap()\n\t\tReturn Self\n\tEnd Method\n\t\n'#region Collections\n\t\n\tRem\n\t\tbbdoc: Insert a variable into the map.\n\t\treturns: True if the variable was added, or False if it was not (the variable's name is Null).\n\tEnd Rem\n\tMethod InsertVariable:Int(variable:dVariable)\n\t\tIf variable.GetName() <> Null\n\t\t\t_Insert(variable.GetName(), variable)\n\t\t\tReturn True\n\t\tEnd If\n\t\tReturn False\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Remove a variable by the name given.\n\t\treturns: True if a variable was removed, or False if it was not (the map contains no variable with the name given).\n\t\tabout: The name is<\/b> case-sensitive.\n\tEnd Rem\n\tMethod RemoveVariableByName:Int(name:String)\n\t\tReturn _Remove(name)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get a variable from the map by its name.\n\t\treturns: The variable object, or if the variable was not found, Null.\n\t\tabout: The name is<\/b> case-sensitive.\n\tEnd Rem\n\tMethod GetVariableByName:dVariable(name:String)\n\t\tReturn dVariable(_ValueByKey(name))\n\tEnd Method\n\t\n'#end region (Collections)\n\t\nEnd Type\n\n","old_contents":"\nRem\nCopyright (c) 2010 Tim Howard\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and\/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\nEnd Rem\n\nSuperStrict\n\nRem\nbbdoc: Variables module\nEnd Rem\nModule duct.variables\n\nModuleInfo \"Version: 0.22\"\nModuleInfo \"Copyright: Tim Howard\"\nModuleInfo \"License: MIT\"\n\nModuleInfo \"History: Version 0.22\"\nModuleInfo \"History: Fixed documentation, license\"\nModuleInfo \"History: Renamed TVariable to dVariable\"\nModuleInfo \"History: Renamed TIntVariable to dIntVariable\"\nModuleInfo \"History: Renamed TStringVariable to dStringVariable\"\nModuleInfo \"History: Renamed TFloatVariable to dFloatVariable\"\nModuleInfo \"History: Renamed TEvalVariable to dEvalVariable\"\nModuleInfo \"History: Renamed TIdentifier to dIdentifier\"\nModuleInfo \"History: Renamed TBoolVariable to dBoolVariable\"\nModuleInfo \"History: Version 0.21\"\nModuleInfo \"History: Corrected TVariable.RawToVariable parsing for eval variables; added allowevalvars option\"\nModuleInfo \"History: Version 0.20\"\nModuleInfo \"History: Added TBoolVariable support in TVariable.DeserializeUniversal\"\nModuleInfo \"History: Added TBoolVariable support in TVariable.RawToVariable\"\nModuleInfo \"History: Fixed an issue with eval variables in TVariable.RawToVariable\"\nModuleInfo \"History: Corrected some method names and some documentation.\"\nModuleInfo \"History: Version 0.19\"\nModuleInfo \"History: Added TBoolVariable; documentation correction\"\nModuleInfo \"History: Version 0.18\"\nModuleInfo \"History: TIdentifier.AddValue now sets the variable's parent to itself\"\nModuleInfo \"History: Added SetParent and GetParent to TVaraible\"\nModuleInfo \"History: Version 0.17\"\nModuleInfo \"History: General cleanup\"\nModuleInfo \"History: Version 0.16\"\nModuleInfo \"History: Added SetAmbiguous to all TVariable types\"\nModuleInfo \"History: Added option to always use quoting with TStringVariables (on by default)\"\nModuleInfo \"History: Fixed TStringVariable.ConvToString returning of Null strings\"\nModuleInfo \"History: Version 0.15\"\nModuleInfo \"History: Change the Create method definition for easier use\"\nModuleInfo \"History: Changed the '\/eval::' recognizer to '\/e:' (as per SNode format change)\"\nModuleInfo \"History: Added the Copy method to every variable type\"\nModuleInfo \"History: Changed some formatting\"\nModuleInfo \"History: Version 0.14\"\nModuleInfo \"History: Changed type tabbing\"\nModuleInfo \"History: Fixed script output for TStringVariable (quotes are now only added if whitespace is present)\"\nModuleInfo \"History: Fixed script output for TIdentifier (identifier names can now contain whitespace, in which case they must be quoted)\"\nModuleInfo \"History: Version 0.13\"\nModuleInfo \"History: Added the DeserializeUniversal function to TVariable\"\nModuleInfo \"History: Added Serialize and Deserialize methods to all variable types\"\nModuleInfo \"History: Version 0.12\"\nModuleInfo \"History: Changed module name from 'variablemap' to 'variables'\"\nModuleInfo \"History: Moved all of duct.utilparser here\"\nModuleInfo \"History: Added the GetTVType function to all variable types\"\nModuleInfo \"History: Moved TV_* constants from duct.template here\"\nModuleInfo \"History: Version 0.11\"\nModuleInfo \"History: Added the ReportType function to all variable types\"\nModuleInfo \"History: Version 0.10\"\nModuleInfo \"History: Added the RawToVariable function to TVariable\"\nModuleInfo \"History: General code cleanup\"\nModuleInfo \"History: Version 0.09\"\nModuleInfo \"History: Corrected usage of syntax (in Returns, Cases, News and Selects)\"\nModuleInfo \"History: Version 0.08\"\nModuleInfo \"History: Added the TEvalVariable type\"\nModuleInfo \"History: Initial release\"\n\nImport brl.stream\n\nImport duct.etc\nImport duct.objectmap\n\nRem\n\tbbdoc: Template variable type for the #dIntVariable type.\nEnd Rem\nConst TV_INTEGER:Int = 1\nRem\n\tbbdoc: Template variable type for the #dStringVariable type.\nEnd Rem\nConst TV_STRING:Int = 2\nRem\n\tbbdoc: Template variable type for the #dFloatVariable type.\nEnd Rem\nConst TV_FLOAT:Int = 3\nRem\n\tbbdoc: Template variable type for the #dEvalVariable type.\nEnd Rem\nConst TV_EVAL:Int = 4\nRem\n\tbbdoc: Template variable type for the #dIdentifier type.\nEnd Rem\nConst TV_IDEN:Int = 5\nRem\n\tbbdoc: Template variable type for the #dBoolVariable type.\nEnd Rem\nConst TV_BOOL:Int = 6\n\nRem\n\tbbdoc: duct generic variable.\n\tabout: This is the base variable type, you should extend from this to use it.\nEnd Rem\nType dVariable Abstract\n\t\n\tField m_name:String\n\tField m_parent:dVariable\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the variable's name.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetName(name:String)\n\t\tm_name = name\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the variable's name.\n\t\treturns: The variable's name.\n\tEnd Rem\n\tMethod GetName:String()\n\t\tReturn m_name\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the variable's parent.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetParent(parent:dVariable)\n\t\tm_parent = parent\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the variable's parent.\n\t\treturns: The variable's parent.\n\tEnd Rem\n\tMethod GetParent:dVariable()\n\t\tReturn m_parent\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Base method for setting the value of the variable to the given string (conversion).\n\tEnd Rem\n\tMethod SetAmbiguous(value:String) Abstract\n\t\n\tRem\n\t\tbbdoc: Base method for converting variable data to a script-ready string.\n\tEnd Rem\n\tMethod ConvToString:String() Abstract\n\t\n\tRem\n\t\tbbdoc: Base method for converting variable data to a printable\/usable-in-code string.\n\tEnd Rem\n\tMethod ValueAsString:String() Abstract\n\t\n'#end region (Field accessors)\n\t\n'#region Data handling\n\t\n\tRem\n\t\tbbdoc: Create a copy of the variable.\n\t\treturns: A clone of the variable.\n\tEnd Rem\n\tMethod Copy:dVariable() Abstract\n\t\n\tRem\n\t\tbbdoc: Serialize the variable to a stream.\n\t\treturns: Nothing.\n\t\tabout: @tv tells the method whether it should serialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod Serialize(stream:TStream, tv:Int = True, name:Int = False) Abstract\n\t\n\tRem\n\t\tbbdoc: Deserialize the variable from a stream.\n\t\treturns: The deserialized variable.\n\t\tabout: @tv tells the method whether it should deserialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod Deserialize:dVariable(stream:TStream, tv:Int = True, name:Int = False) Abstract\n\t\n'#end region (Data handling)\n\t\n\tRem\n\t\tbbdoc: Base method: Get the type of this variable.\n\tEnd Rem\n\tFunction ReportType:String() Abstract\n\t\n\tRem\n\t\tbbdoc: Base method: Get the TV_* type of this variable.\n\tEnd Rem\n\tFunction GetTVType:Int() Abstract\n\t\n\tRem\n\t\tbbdoc: Convert raw data (raw data being things like: \"\/e:(a+b\/0.4181)*a-b\" - a dEvalVariable, \"A String variable\", 3452134 - a dIntVariable, 1204.00321 - a variable) into a Variable.\n\t\treturns: A new Variable, or Null if something whacky occured.\n\t\tabout: @etype is optional, it is used to go automagically to one type of a Variable (1 & 4=String (will check for '\/e:' - dEvalVariables and dBoolVariables ['true' or 'false']), 2=Integer, 3=Float).\n\t\t@varname is also an optional parameter. It will be used as the name of the variable.\n\t\tIf @allowevalvars (defaults to False) is True, eval variables will be checked for.\n\tEnd Rem\n\tFunction RawToVariable:dVariable(vraw:String, etype:Int = 0, varname:String = \"\", allowevalvars:Int = False)\n\t\tLocal variable:dVariable\n\t\tIf vraw = Null\n\t\t\tDebugLog(\"(dVariable.RawToVariable) @vraw = Null; returning a dStringVariable (with @varname and Null value)\")\n\t\t\tReturn New dStringVariable.Create(varname, Null)\n\t\tEnd If\n\t\tIf etype = 0 ' Determine the value's type (must be either integer, double, or a string with no spaces)\n\t\t\t' ASCII '0' to '9' = 48-57; '-' = 45, '+' = 43; and '.' = 46\n\t\t\tFor Local i:Int = 0 To vraw.Length - 1\n\t\t\t\tLocal c:Int = vraw[i]\n\t\t\t\tIf c >= 48 And c <= 57 Or c = 43 Or c = 45\n\t\t\t\t\tIf etype = 0 ' Leave float and string alone\n\t\t\t\t\t\tetype = 2 ' Integer so far..\n\t\t\t\t\tEnd If\n\t\t\t\tElse If c = 46\n\t\t\t\t\tIf etype = 2 ' Already declared as an integer?\n\t\t\t\t\t\tetype = 3\n\t\t\t\t\tEnd If\n\t\t\t\tElse ' If the character is not numerical there is nothing else to deduce and the value is a string\n\t\t\t\t\tetype = 4\n\t\t\t\t\tExit\n\t\t\t\tEnd If\n\t\t\tNext\n\t\tEnd If\n\t\t\n\t\tSelect etype\n\t\t\tCase 2 ' Integer\n\t\t\t\tvariable = dVariable(New dIntVariable.Create(varname, Int(vraw)))\n\t\t\tCase 3 ' Double\/Float\n\t\t\t\tvariable = dVariable(New dFloatVariable.Create(varname, Float(vraw)))\n\t\t\tCase 1, 4\n\t\t\t\tLocal vrawlower:String = vraw.ToLower()\n\t\t\t\tIf vrawlower.StartsWith(\"\/e:\") = True and allowevalvars = True\n\t\t\t\t\tvariable = dVariable(New dEvalVariable.Create(varname, vraw[2..]))\n\t\t\t\tElse If vrawlower = \"true\" Or vrawlower = \"false\"\n\t\t\t\t\tvariable = New dBoolVariable.Create(varname, (vrawlower = \"true\") And True Or False)\n\t\t\t\tElse\n\t\t\t\t\tvariable = dVariable(New dStringVariable.Create(varname, vraw))\n\t\t\t\tEnd If\n\t\tEnd Select\n\t\t'DebugLog(\"TSNode.LoadScriptFromStream().RawToVariable(); vraw = ~q\" + vraw + \"~q \\\" + etype)\n\t\t?Debug\n\t\tIf variable = Null Then DebugLog(\"(dVariable.RawToVariable) Unknown error, 'variable' is Null.\")\n\t\t?\n\t\tReturn variable\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Universally deserialize a variable from the given stream.\n\t\treturns: A Deserialized variable.\n\t\tabout: This will deserialize any variable from the stream.\n\t\tThis requires the variable to have been serialized with the template type (see #Serialize parameters).\n\t\t@name tells the further Deserialize calls if the name should be Deserialized or not.\n\tEnd Rem\n\tFunction DeserializeUniversal:dVariable(stream:TStream, name:Int = False)\n\t\tLocal tv:Int = Int(stream.ReadByte())\n\t\tSelect tv\n\t\t\tCase TV_INTEGER\n\t\t\t\tReturn New dIntVariable.Deserialize(stream, True, name)\n\t\t\tCase TV_STRING\n\t\t\t\tReturn New dStringVariable.Deserialize(stream, True, name)\n\t\t\tCase TV_FLOAT\n\t\t\t\tReturn New dFloatVariable.Deserialize(stream, True, name)\n\t\t\tCase TV_EVAL\n\t\t\t\tReturn New dEvalVariable.Deserialize(stream, True, name)\n\t\t\tCase TV_IDEN\n\t\t\t\tReturn New dIdentifier.Deserialize(stream, True, name)\n\t\t\tCase TV_BOOL\n\t\t\t\tReturn New dBoolVariable.Deserialize(stream, True, name)\n\t\t\tDefault\n\t\t\t\tDebugLog(\"(dVariable.DeserializeUniversal) Failed to recognize the TV in the stream: \" + tv)\n\t\tEnd Select\n\t\tReturn Null\n\tEnd Function\n\t\nEnd Type\n\nRem\n\tbbdoc: duct string variable.\nEnd Rem\nType dStringVariable Extends dVariable\n\t\n\tGlobal m_alwaysusequotes:Int = True\n\t\n\tField m_value:String\n\t\n\tRem\n\t\tbbdoc: Create a new String variable.\n\t\treturns: Itself.\n\tEnd Rem\n\tMethod Create:dStringVariable(name:String = Null, value:String)\n\t\tSetName(name)\n\t\tSet(value)\n\t\tReturn Self\n\tEnd Method\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the variable's value.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod Set(value:String)\n\t\tm_value = value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the variable's value.\n\t\treturns: The value of the variable.\n\tEnd Rem\n\tMethod Get:String()\n\t\tReturn m_value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the value of the variable to the given string (ambiguous).\n\t\treturns: Nothing.\n\t\tabout: For this type, this method is no different than calling #Set.\n\tEnd Rem\n\tMethod SetAmbiguous(value:String)\n\t\tm_value = value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Convert the variable to a String.\n\t\treturns: A String representation of the variable.\n\t\tabout: This function is for script output, for in-code use see #ValueAsString.\n\tEnd Rem\n\tMethod ConvToString:String()\n\t\tIf m_alwaysusequotes = True Or m_value.Contains(\"~t\") Or m_value.Contains(\" \") Or m_value = Null\n\t\t\tReturn \"~q\" + m_value + \"~q\"\n\t\tElse\n\t\t\tReturn m_value\n\t\tEnd If\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the variable as a String.\n\t\treturns: The variable's value converted to a String.\n\t\tabout: Here for complete-ness, no difference to `instance.Get()`.\n\tEnd Rem\n\tMethod ValueAsString:String()\n\t\tReturn m_value\n\tEnd Method\n\t\n'#end region (Field accessors)\n\t\n'#region Data handling\n\t\n\tRem\n\t\tbbdoc: Create a copy of the variable\n\t\treturns: A clone of the variable.\n\tEnd Rem\n\tMethod Copy:dStringVariable()\n\t\tReturn New dStringVariable.Create(m_name, m_value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Serialize the variable to a stream.\n\t\treturns: Nothing.\n\t\tabout: @tv tells the method whether it should serialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod Serialize(stream:TStream, tv:Int = True, name:Int = False)\n\t\tIf tv = True Then stream.WriteByte(TV_STRING)\n\t\tIf name = True Then WriteLString(stream, m_name)\n\t\tWriteLString(stream, m_value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Deserialize the variable from a stream.\n\t\treturns: Itself.\n\t\tabout: @tv tells the method whether it should deserialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod Deserialize:dStringVariable(stream:TStream, tv:Int = True, name:Int = False)\n\t\tIf tv = True Then stream.ReadByte()\n\t\tIf name = True Then m_name = ReadLString(stream)\n\t\tm_value = ReadLString(stream)\n\t\tReturn Self\n\tEnd Method\n\t\n'#end region (Data handling)\n\t\n\tRem\n\t\tbbdoc: Get the type of this variable.\n\t\treturns: The type of this variable (\"string\").\n\tEnd Rem\n\tFunction ReportType:String()\n\t\tReturn \"string\"\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Get the TV type of this variable.\n\t\treturns: The TV_* type of this variable (TV_STRING).\n\tEnd Rem\n\tFunction GetTVType:Int()\n\t\tReturn TV_STRING\n\tEnd Function\n\t\nEnd Type\n\nRem\n\tbbdoc: duct Float variable.\nEnd Rem\nType dFloatVariable Extends dVariable\n\t\n\tField m_value:Float\n\t\n\tRem\n\t\tbbdoc: Create a new Float variable.\n\t\treturns: Itself.\n\tEnd Rem\n\tMethod Create:dFloatVariable(name:String = Null, value:Float)\n\t\tSetName(name)\n\t\tSet(value)\n\t\tReturn Self\n\tEnd Method\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the variable's value.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod Set(value:Float)\n\t\tm_value = value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the variable's value.\n\t\treturns: The value of the variable.\n\tEnd Rem\n\tMethod Get:Float()\n\t\tReturn m_value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the value of the variable to the given string (ambiguous).\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetAmbiguous(value:String)\n\t\tm_value = Float(value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Convert the variable to a String.\n\t\treturns: A scriptable form of the variable.\n\t\tabout: This function is for script output, for in-code use see #ValueAsString.\n\tEnd Rem\n\tMethod ConvToString:String()\n\t\tLocal conv:String = String(m_value), encountered:Int\n\t\tFor Local i:Int = conv.Find(\".\") To conv.Length - 1\n\t\t\tIf conv[i] = 48\n\t\t\t\tIf encountered = True\n\t\t\t\t\tconv = conv[..i]\n\t\t\t\t\tExit\n\t\t\t\tEnd If\n\t\t\tElse If conv[i] <> 46\n\t\t\t\tencountered = True\n\t\t\tEnd If\n\t\tNext\n\t\tReturn conv\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the variable as a String.\n\t\treturns: The variable's value converted to a String.\n\tEnd Rem\n\tMethod ValueAsString:String()\n\t\tReturn String(m_value)\n\tEnd Method\n\t\n'#end region (Field accessors)\n\t\n'#region Data handling\n\t\n\tRem\n\t\tbbdoc: Create a copy of the variable\n\t\treturns: A clone of the variable.\n\tEnd Rem\n\tMethod Copy:dFloatVariable()\n\t\tReturn New dFloatVariable.Create(m_name, m_value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Serialize the variable to a stream.\n\t\treturns: Nothing.\n\t\tabout: @tv tells the method whether it should serialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod Serialize(stream:TStream, tv:Int = True, name:Int = False)\n\t\tIf tv = True Then stream.WriteByte(TV_FLOAT)\n\t\tIf name = True Then WriteLString(stream, m_name)\n\t\tstream.WriteFloat(m_value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Deserialize the variable from a stream.\n\t\treturns: Itself.\n\t\tabout: @tv tells the method whether it should deserialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod Deserialize:dFloatVariable(stream:TStream, tv:Int = True, name:Int = False)\n\t\tIf tv = True Then stream.ReadByte()\n\t\tIf name = True Then m_name = ReadLString(stream)\n\t\tm_value = stream.ReadFloat()\n\t\tReturn Self\n\tEnd Method\n\t\n'#end region (Data handling)\n\t\n\tRem\n\t\tbbdoc: Get the type of this variable.\n\t\treturns: The type of this variable (\"float\").\n\tEnd Rem\n\tFunction ReportType:String()\n\t\tReturn \"float\"\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Get the TV type of this variable.\n\t\treturns: The TV_* type of this variable (TV_FLOAT).\n\tEnd Rem\n\tFunction GetTVType:Int()\n\t\tReturn TV_FLOAT\n\tEnd Function\n\t\nEnd Type\n\nRem\n\tbbdoc: duct Int variable.\nEnd Rem\nType dIntVariable Extends dVariable\n\t\n\tField m_value:Int\n\t\n\tRem\n\t\tbbdoc: Create a new Int variable.\n\t\treturns: Itself.\n\tEnd Rem\n\tMethod Create:dIntVariable(name:String = Null, value:Int)\n\t\tSetName(name)\n\t\tSet(value)\n\t\tReturn Self\n\tEnd Method\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the variable's value.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod Set(value:Int)\n\t\tm_value = value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the variable's value.\n\t\treturns: The value of the variable.\n\tEnd Rem\n\tMethod Get:Int()\n\t\tReturn m_value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the value of the variable to the given string (ambiguous).\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetAmbiguous(value:String)\n\t\tm_value = Int(value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Convert the variable to a String.\n\t\treturns: A string representation of the variable.\n\t\tabout: This function is for script output, for in-code use see #ValueAsString.\n\tEnd Rem\n\tMethod ConvToString:String()\n\t\tReturn String(m_value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the variable as a String.\n\t\treturns: The variable's value converted to a String.\n\tEnd Rem\n\tMethod ValueAsString:String()\n\t\tReturn String(m_value)\n\tEnd Method\n\t\n'#end region (Field accessors)\n\t\n'#region Data handling\n\t\n\tRem\n\t\tbbdoc: Create a copy of the variable\n\t\treturns: A clone of the variable.\n\tEnd Rem\n\tMethod Copy:dIntVariable()\n\t\tReturn New dIntVariable.Create(m_name, m_value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Serialize the variable to a stream.\n\t\treturns: Nothing.\n\t\tabout: @tv tells the method whether it should serialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod Serialize(stream:TStream, tv:Int = True, name:Int = False)\n\t\tIf tv = True Then stream.WriteByte(TV_INTEGER)\n\t\tIf name = True Then WriteLString(stream, m_name)\n\t\tstream.WriteInt(m_value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Deserialize the variable from a stream.\n\t\treturns: Itself.\n\t\tabout: @tv tells the method whether it should deserialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod Deserialize:dIntVariable(stream:TStream, tv:Int = True, name:Int = False)\n\t\tIf tv = True Then stream.ReadByte()\n\t\tIf name = True Then m_name = ReadLString(stream)\n\t\tm_value = stream.ReadInt()\n\t\tReturn Self\n\tEnd Method\n\t\n'#end region (Data handling)\n\t\n\tRem\n\t\tbbdoc: Get the type of this variable.\n\t\treturns: The type of this variable (\"int\").\n\tEnd Rem\n\tFunction ReportType:String()\n\t\tReturn \"int\"\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Get the TV type of this variable.\n\t\treturns: The TV_* type of this variable (TV_INTEGER).\n\tEnd Rem\n\tFunction GetTVType:Int()\n\t\tReturn TV_INTEGER\n\tEnd Function\n\t\nEnd Type\n\nRem\n\tbbdoc: duct eval variable (for bah.muparser, and the likes).\nEnd Rem\nType dEvalVariable Extends dVariable\n\t\n\tField m_value:String\n\t\n\tRem\n\t\tbbdoc: Create a new eval variable.\n\t\treturns: Itself.\n\tEnd Rem\n\tMethod Create:dEvalVariable(name:String = Null, value:String)\n\t\tSetName(name)\n\t\tSet(value)\n\t\tReturn Self\n\tEnd Method\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the equation string for the variable.\n\t\treturns: Nothing\n\tEnd Rem\n\tMethod Set(value:String)\n\t\tm_value = value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the equation string.\n\t\treturns: The equation string.\n\tEnd Rem\n\tMethod Get:String()\n\t\tReturn m_value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the value of the variable to the given string (ambiguous).\n\t\treturns: Nothing.\n\t\tabout: For this type, this method is no different than calling #Set.\n\tEnd Rem\n\tMethod SetAmbiguous(value:String)\n\t\tm_value = value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Convert the variable to a visual representation of its data.\n\t\treturns: The scriptable form of the variable.\n\t\tabout: This function is for script output, for in-code use see #ValueAsString.\n\tEnd Rem\n\tMethod ConvToString:String()\n\t\tReturn \"~q\/e:\" + m_value + \"~q\"\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the variable as a String.\n\t\treturns: The variable's value converted to a String.\n\tEnd Rem\n\tMethod ValueAsString:String()\n\t\tReturn m_value\n\tEnd Method\n\t\n'#end region (Field accessors)\n\t\n'#region Data handling\n\t\n\tRem\n\t\tbbdoc: Create a copy of the variable\n\t\treturns: A clone of the variable.\n\tEnd Rem\n\tMethod Copy:dEvalVariable()\n\t\tReturn New dEvalVariable.Create(m_name, m_value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Serialize the variable to a stream.\n\t\treturns: Nothing.\n\t\tabout: @tv tells the method whether it should serialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod Serialize(stream:TStream, tv:Int = True, name:Int = False)\n\t\tIf tv = True Then stream.WriteByte(TV_EVAL)\n\t\tIf name = True Then WriteLString(stream, m_name)\n\t\tWriteLString(stream, m_value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Deserialize the variable from a stream.\n\t\treturns: Itself.\n\t\tabout: @tv tells the method whether it should deserialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod Deserialize:dEvalVariable(stream:TStream, tv:Int = True, name:Int = False)\n\t\tIf tv = True Then stream.ReadByte()\n\t\tIf name = True Then m_name = ReadLString(stream)\n\t\tm_value = ReadLString(stream)\n\t\tReturn Self\n\tEnd Method\n\t\n'#end region (Data handling)\n\t\n\tRem\n\t\tbbdoc: Get the type of this variable.\n\t\treturns: The type of this variable (\"eval\").\n\tEnd Rem\n\tFunction ReportType:String()\n\t\tReturn \"eval\"\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Get the TV type of this variable.\n\t\treturns: The TV_* type of this variable (TV_EVAL).\n\tEnd Rem\n\tFunction GetTVType:Int()\n\t\tReturn TV_EVAL\n\tEnd Function\n\t\nEnd Type\n\nRem\n\tbbdoc: duct boolean variable.\nEnd Rem\nType dBoolVariable Extends dVariable\n\t\n\tField m_value:Int\n\t\n\tRem\n\t\tbbdoc: Create a new boolean variable.\n\t\treturns: Itself.\n\tEnd Rem\n\tMethod Create:dBoolVariable(name:String = Null, value:Int)\n\t\tSetName(name)\n\t\tSet(value)\n\t\tReturn Self\n\tEnd Method\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the variable's value.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod Set(value:Int)\n\t\tm_value = value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the variable's value.\n\t\treturns: The value of the variable.\n\tEnd Rem\n\tMethod Get:Int()\n\t\tReturn m_value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the value of the variable to the given string (ambiguous).\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetAmbiguous(value:String)\n\t\tm_value = Int(value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Convert the variable to a String.\n\t\treturns: A string representation of the variable.\n\t\tabout: This function is for script output, for in-code use see #ValueAsString.\n\tEnd Rem\n\tMethod ConvToString:String()\n\t\tReturn String(m_value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the dBoolVariable as a String.\n\t\treturns: The variable's value converted to a String.\n\tEnd Rem\n\tMethod ValueAsString:String()\n\t\tReturn String(m_value)\n\tEnd Method\n\t\n'#end region (Field accessors)\n\t\n'#region Data handling\n\t\n\tRem\n\t\tbbdoc: Create a copy of the variable\n\t\treturns: A clone of the variable.\n\tEnd Rem\n\tMethod Copy:dBoolVariable()\n\t\tReturn New dBoolVariable.Create(m_name, m_value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Serialize the variable to a stream.\n\t\treturns: Nothing.\n\t\tabout: @tv tells the method whether it should serialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod Serialize(stream:TStream, tv:Int = True, name:Int = False)\n\t\tIf tv = True Then stream.WriteByte(TV_BOOL)\n\t\tIf name = True Then WriteLString(stream, m_name)\n\t\tstream.WriteByte(Byte(m_value))\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Deserialize the variable from a stream.\n\t\treturns: The deserialized variable.\n\t\tabout: @tv tells the method whether it should deserialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod Deserialize:dBoolVariable(stream:TStream, tv:Int = True, name:Int = False)\n\t\tIf tv = True Then stream.ReadByte()\n\t\tIf name = True Then m_name = ReadLString(stream)\n\t\tm_value = Int(stream.ReadByte())\n\t\tReturn Self\n\tEnd Method\n\t\n'#end region (Data handling)\n\t\n\tRem\n\t\tbbdoc: Get the type of this variable.\n\t\treturns: The type of this variable (\"bool\").\n\tEnd Rem\n\tFunction ReportType:String()\n\t\tReturn \"bool\"\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Get the TV type of this variable.\n\t\treturns: The TV_* type of this variable (TV_BOOL).\n\tEnd Rem\n\tFunction GetTVType:Int()\n\t\tReturn TV_BOOL\n\tEnd Function\n\t\nEnd Type\n\nRem\n\tbbdoc: duct identifier (used in parsers, mostly).\nEnd Rem\nType dIdentifier Extends dVariable\n\t\n\tField m_values:TList\n\t\n\tMethod New()\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Create a new identifier.\n\t\treturns: Itself.\n\tEnd Rem\n\tMethod Create:dIdentifier()\n\t\tm_values = New TList\n\t\tReturn Self\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Create a new identifier with the given data.\n\t\treturns: Itself.\n\t\tabout: If the @values parameter is Null a new list will be created.\n\tEnd Rem\n\tMethod CreateByData:dIdentifier(name:String, values:TList = Null)\n\t\tSetName(name)\n\t\tIf values = Null\n\t\t\tm_values = New TList\n\t\tElse\n\t\t\tm_values = values\n\t\tEnd If\n\t\tReturn Self\n\tEnd Method\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the identifier's values.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetValues(values:TList)\n\t\tm_values = values\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the identifier's values.\n\t\treturns: A list containing the values which the identifier holds.\n\tEnd Rem\n\tMethod GetValues:TList()\n\t\tReturn m_values\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Deprecated for this type.\n\t\treturns: Nothing.\n\t\tabout: This does nothing.\n\tEnd Rem\n\tMethod SetAmbiguous(value:String)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Convert the identifier to a string.\n\t\treturns: A string representation of the identifier.\n\tEnd Rem\n\tMethod ConvToString:String()\n\t\tLocal op:String\n\t\tIf m_name.Contains(\"~t\") = True Or m_name.Contains(\" \") = True\n\t\t\top = \"~q\" + m_name + \"~q \"\n\t\tElse\n\t\t\top = m_name + \" \"\n\t\tEnd If\n\t\tFor Local variable:dVariable = EachIn m_values\n\t\t\top:+variable.ConvToString() + \" \"\n\t\tNext\n\t\top = op[..op.Length - 1]\n\t\tReturn op\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the identifier as a string.\n\t\treturns: The identifier contents converted to a string.\n\t\tabout: Here for complete-ness, simply calls #ConvToString.\n\tEnd Rem\n\tMethod ValueAsString:String()\n\t\tReturn ConvToString()\n\tEnd Method\n\t\n'#end region (Field accessors)\n\t\n'#region Value handling\n\t\n\tRem\n\t\tbbdoc: Get a value at an index.\n\t\treturns: The value in the identifier's list at the given index, or Null if it could not be retrieved.\n\t\tabout: The index is zero-based.\n\tEnd Rem\n\tMethod GetValueAtIndex:dVariable(index:Int)\n\t\tIf m_values <> Null And index > - 1 And index < m_values.Count()\n\t\t\tReturn dVariable(m_values.ValueAtIndex(index))\n\t\tEnd If\n\t\tReturn Null\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the number of values.\n\t\treturns: The number of values the identifier contains.\n\tEnd Rem\n\tMethod GetValueCount:Int()\n\t\tIf m_values <> Null\n\t\t\tReturn m_values.Count()\n\t\tEnd If\n\t\tReturn 0\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Add a value to the identifier.\n\t\treturns: True for success, or False for failure.\n\t\tabout: NOTE: This will set the given value's parent.\n\tEnd Rem\n\tMethod AddValue:Int(value:dVariable)\n\t\tIf m_values <> Null And value <> Null\n\t\t\tm_values.AddLast(value)\n\t\t\tvalue.SetParent(Self)\n\t\t\tReturn True\n\t\tEnd If\n\t\tReturn False\n\tEnd Method\n\t\n'#end region (Value handling)\n\t\n'#region Data handling\n\t\n\tRem\n\t\tbbdoc: Create a copy of the identifier\n\t\treturns: A clone of the identifier.\n\tEnd Rem\n\tMethod Copy:dIdentifier()\n\t\tLocal clone:dIdentifier\n\t\tclone = New dIdentifier.CreateByData(m_name)\n\t\tFor Local variable:dVariable = EachIn m_values\n\t\t\tclone.AddValue(variable.Copy())\n\t\tNext\n\t\tReturn clone\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Serialize the variable to a stream.\n\t\treturns: Nothing.\n\t\tabout: @tv tells the method whether it should serialize the TV type for the variable, or to not.\n\t\tIn this case @name tells the method whether it should serialize the values<\/b><\/i>' name (the identifier's name is always read\/written to the stream).\n\tEnd Rem\n\tMethod Serialize(stream:TStream, tv:Int = True, name:Int = False)\n\t\tLocal variable:dVariable\n\t\tIf tv = True Then stream.WriteByte(TV_STRING)\n\t\tWriteLString(stream, m_name)\n\t\tIf m_values = Null\n\t\t\tstream.WriteInt(0)\n\t\tElse\n\t\t\tstream.WriteInt(m_values.Count())\n\t\t\tFor variable = EachIn m_values\n\t\t\t\tvariable.Serialize(stream, True, name)\n\t\t\tNext\n\t\tEnd If\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Deserialize the variable from a stream.\n\t\treturns: The deserialized variable.\n\t\tabout: @tv tells the method whether it should deserialize the TV type for the variable, or to not.\n\t\tIn this case @name tells the method whether it should deserialize the values<\/b><\/i>' name (the identifier's name is always read\/written to the stream).\n\tEnd Rem\n\tMethod Deserialize:dIdentifier(stream:TStream, tv:Int = True, name:Int = False)\n\t\tLocal count:Int, n:Int\n\t\tIf tv = True Then stream.ReadByte()\n\t\tm_name = ReadLString(stream)\n\t\tcount = stream.ReadInt()\n\t\tIf count > 0\n\t\t\tFor n = 0 To count - 1\n\t\t\t\tDeserializeUniversal(stream, name)\n\t\t\tNext\n\t\tEnd If\n\t\tReturn Self\n\tEnd Method\n\t\n'#end region (Data handling)\n\t\n\tRem\n\t\tbbdoc: Get the type of this variable.\n\t\treturns: The type of this variable (\"identifier\").\n\tEnd Rem\n\tFunction ReportType:String()\n\t\tReturn \"identifier\"\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Get the TV type of this variable.\n\t\treturns: The TV_* type of this variable (TV_IDEN).\n\tEnd Rem\n\tFunction GetTVType:Int()\n\t\tReturn TV_IDEN\n\tEnd Function\n\t\nEnd Type\n\nRem\n\tbbdoc: #dVariable map (stores any variable).\nEndRem\nType dVariableMap Extends dObjectMap\n\t\n\tRem\n\t\tbbdoc: Create a new variable map.\n\t\treturns: Itself.\n\tEnd Rem\n\tMethod Create:dVariableMap()\n\t\tReturn Self\n\tEnd Method\n\t\n'#region Collections\n\t\n\tRem\n\t\tbbdoc: Insert a variable into the map.\n\t\treturns: True if the variable was added, or False if it was not (the variable's name is Null).\n\tEnd Rem\n\tMethod InsertVariable:Int(variable:dVariable)\n\t\tIf variable.GetName() <> Null\n\t\t\t_Insert(variable.GetName(), variable)\n\t\t\tReturn True\n\t\tEnd If\n\t\tReturn False\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Remove a variable by the name given.\n\t\treturns: True if a variable was removed, or False if it was not (the map contains no variable with the name given).\n\t\tabout: The name is<\/b> case-sensitive.\n\tEnd Rem\n\tMethod RemoveVariableByName:Int(name:String)\n\t\tReturn _Remove(name)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get a variable from the map by its name.\n\t\treturns: The variable object, or if the variable was not found, Null.\n\t\tabout: The name is<\/b> case-sensitive.\n\tEnd Rem\n\tMethod GetVariableByName:dVariable(name:String)\n\t\tReturn dVariable(_ValueByKey(name))\n\tEnd Method\n\t\n'#end region (Collections)\n\t\nEnd Type\n\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"548131002787dca44e083a10f7c79a9ce4868c19","subject":"All vector types have been added to the Select in TXMLRPC_Value_Abstract.XMLRPC_To_BlizMax()","message":"All vector types have been added to the Select in TXMLRPC_Value_Abstract.XMLRPC_To_BlizMax()\n","repos":"Htbaa\/xmlrpc.mod,Htbaa\/xmlrpc.mod,Htbaa\/xmlrpc.mod,Htbaa\/xmlrpc.mod,Htbaa\/xmlrpc.mod","old_file":"datatypes.bmx","new_file":"datatypes.bmx","new_contents":"Rem\n\tbbdoc: XML-RPC Data Type exception\nEnd Rem\nType TXMLRPC_Value_Exception Extends TXMLRPC_Exception \nEnd Type\n\nRem\n\tbbdoc: Base type for all XML-RPC data types\nEnd Rem\nType TXMLRPC_Value_Abstract Abstract\n\tField _type:Int\n\n\tRem\n\t\tbbdoc: The name or id this value has been identified with in the response. read-only\n\tEnd Rem\n\tField name:String\n\t\n\tRem\n\t\tbbdoc: Convert a XMLRPC_VALUE from XMLRPC-EPI to a BlitzMax type\n\tEnd Rem\n\tFunction XMLRPC_To_BlizMax:TXMLRPC_Value_Abstract(val:Byte Ptr) Final\n\t\tLocal dataType:Int = XMLRPC_GetValueType(val)\n\t\tLocal data:TXMLRPC_Value_Abstract\n\t\tSelect dataType\n\t\t\tCase xmlrpc_none\n\t\t\t\tdata = New TXMLRPC_Value_None\n\t\t\tCase xmlrpc_empty\n\t\t\t\tdata = New TXMLRPC_Value_Empty\n\t\t\tCase xmlrpc_base64\n\t\t\t\tdata = New TXMLRPC_Value_Base64\n\t\t\t\tLocal cStr:Byte Ptr = XMLRPC_GetValueBase64(val)\n\t\t\t\tIf cStr\n\t\t\t\t\tTXMLRPC_Value_Base64(data).value = String.FromCString(cStr)\n\t\t\t\t\tXMLRPC_Free(cStr)\n\t\t\t\tEnd If\n\t\t\tCase xmlrpc_boolean\n\t\t\t\tdata = New TXMLRPC_Value_Boolean\n\t\t\t\tTXMLRPC_Value_Boolean(data).value = XMLRPC_GetValueBoolean(val)\n\t\t\tCase xmlrpc_datetime\n\t\t\t\tdata = New TXMLRPC_Value_Datetime\n\t\t\t\tLocal cStr:Byte Ptr = XMLRPC_GetValueDateTime_ISO8601(val)\n\t\t\t\tIf cStr\n\t\t\t\t\tTXMLRPC_Value_Datetime(data).value = String.FromCString(cStr)\n\t\t\t\t\tXMLRPC_Free(cStr)\n\t\t\t\tEnd If\n\t\t\tCase xmlrpc_double\n\t\t\t\tdata = New TXMLRPC_Value_Double\n\t\t\t\tTXMLRPC_Value_Double(data).value = XMLRPC_GetValueDouble(val)\n\t\t\tCase xmlrpc_int\n\t\t\t\tdata = New TXMLRPC_Value_Int\n\t\t\t\tTXMLRPC_Value_Int(data).value = XMLRPC_GetValueInt(val)\n\t\t\tCase xmlrpc_string\n\t\t\t\tdata = New TXMLRPC_Value_String\n\t\t\t\tLocal cStr:Byte Ptr = XMLRPC_GetValueString(val)\n\t\t\t\tIf cStr\n\t\t\t\t\tTXMLRPC_Value_String(data).value = String.FromCString(cStr)\n\t\t\t\t\tXMLRPC_Free(cStr)\n\t\t\t\tEnd If\n\t\t\tCase xmlrpc_vector\n\t\t\t\tLocal vectorType:Int = XMLRPC_GetVectorType(val)\n\t\t\t\tSelect vectorType\n\t\t\t\t\tCase xmlrpc_vector_array\n\t\t\t\t\t\tdata = New TXMLRPC_Value_Array\n\t\t\t\t\tCase xmlrpc_vector_struct\n\t\t\t\t\t\tdata = New TXMLRPC_Value_Struct\n\t\t\t\t\tCase xmlrpc_vector_mixed\n\t\t\t\t\t\tThrow New TXMLRPC_Value_Exception.Create(\"Not sure yet how to handle a xmlrpc_vector_mixed value\")\n\t\t\t\t\tCase xmlrpc_vector_none\n\t\t\t\t\t\tThrow New TXMLRPC_Value_Exception.Create(\"Not sure yet how to handle a xmlrpc_vector_none value\")\n\t\t\t\t\tDefault\n\t\t\t\t\t\tThrow New TXMLRPC_Value_Exception.Create(\"Unknown vector type: \" + vectorType)\n\t\t\t\tEnd Select\n\t\t\t\t\n\t\t\t\tIf TXMLRPC_Value_Collection(data)\n\t\t\t\t\tTXMLRPC_Value_Collection(data).SetData(val)\n\t\t\t\tEnd If\n\t\t\tDefault\n\t\t\t\tThrow New TXMLRPC_Value_Exception.Create(\"I don't know a XMLRPC_VALUE with number \" + dataType)\n\t\tEnd Select\n\t\t\n\t\tIf data\n\t\t\tdata._type = dataType\n\t\t\tLocal cStr:Byte Ptr = XMLRPC_GetValueID(val)\n\t\t\tIf cStr\n\t\t\t\tdata.name = String.FromCString(cStr)\n\t\t\t\tXMLRPC_Free(cStr)\n\t\t\tEnd If\n\t\tEnd If\n\t\t\n\t\tReturn data\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Convert data type to string\n\t\tabout: Uses reflection to see if a Field called value is available. If so, it tries to convert it to a string and returns it\n\tEnd Rem\n\tMethod ToString:String()\n\t\tLocal r:TTypeId = TTypeId.ForObject(Self)\n\t\t\n\t\tFor Local fld:TField = EachIn r.EnumFields()\n\t\t\t'Check if object has a Field called value\n\t\t\t'If so, check it's type, convert it to a string and return it\n\t\t\tIf fld.Name() = \"value\"\n\t\t\t\tSelect fld.TypeId().Name()\n\t\t\t\t\tCase \"String\"\n\t\t\t\t\t\tReturn fld.GetString(Self)\n\t\t\t\t\tCase \"Int\"\n\t\t\t\t\t\tReturn String(fld.GetInt(Self))\n\t\t\t\t\tCase \"Byte\"\n\t\t\t\t\t\tReturn String(fld.GetInt(Self))\n\t\t\t\t\tCase \"Long\"\n\t\t\t\t\t\tReturn String(fld.GetLong(Self))\n\t\t\t\t\tCase \"Double\"\n\t\t\t\t\t\tReturn String(fld.GetDouble(Self))\n\t\t\t\tEnd Select\n\t\t\tEnd If\n\t\tNext\n\t\tReturn \"\"\n'\t\tThrow New TXMLRPC_Value_Exception.Create(\"Can't convert datatype to string\")\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Return byte value\n\tEnd Rem\n\tMethod GetByte:Byte()\n\t\tThrow New TXMLRPC_Value_Exception.Create(\"Method GetByte not implemented for this type\")\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Return integer value\n\tEnd Rem\n\tMethod GetInt:Int()\n\t\tThrow New TXMLRPC_Value_Exception.Create(\"Method GetInt not implemented for this type\")\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Return double value\n\tEnd Rem\n\tMethod GetDouble:Double()\n\t\tThrow New TXMLRPC_Value_Exception.Create(\"Method GetDouble not implemented for this type\")\n\tEnd Method\n\n\tRem\n\t\tbbdoc: Return string value\n\tEnd Rem\n\tMethod GetString:String()\n\t\tThrow New TXMLRPC_Value_Exception.Create(\"Method GetString not implemented for this type\")\n\tEnd Method\nEnd Type\n\nRem\n\tbbdoc: Represents none value\nEnd Rem\nType TXMLRPC_Value_None Extends TXMLRPC_Value_Abstract\nEnd Type\n\nRem\n\tbbdoc: Represents an empty value\nEnd Rem\nType TXMLRPC_Value_Empty Extends TXMLRPC_Value_Abstract\n\tField value:Object = Null\nEnd Type\n\nRem\n\tbbdoc: Represents a Base64 encoded string\nEnd Rem\nType TXMLRPC_Value_Base64 Extends TXMLRPC_Value_Abstract\n\tField value:String\n\tMethod GetString:String()\n\t\tReturn Self.value\n\tEnd Method\nEnd Type\n\nRem\n\tbbdoc: Represents a boolean value\nEnd Rem\nType TXMLRPC_Value_Boolean Extends TXMLRPC_Value_Abstract\n\tField value:Byte\n\tMethod GetByte:Byte()\n\t\tReturn Self.value\n\tEnd Method\nEnd Type\n\nRem\n\tbbdoc: Represents a datetime string\nEnd Rem\nType TXMLRPC_Value_Datetime Extends TXMLRPC_Value_Abstract\n\tField value:String\n\tMethod GetString:String()\n\t\tReturn Self.value\n\tEnd Method\nEnd Type\n\nRem\n\tbbdoc: Represents a double value\nEnd Rem\nType TXMLRPC_Value_Double Extends TXMLRPC_Value_Abstract\n\tField value:Double\n\tMethod GetDouble:Double()\n\t\tReturn Self.value\n\tEnd Method\nEnd Type\n\nRem\n\tbbdoc: Represents a integer value\nEnd Rem\nType TXMLRPC_Value_Int Extends TXMLRPC_Value_Abstract\n\tField value:Int\n\tMethod GetInt:Int()\n\t\tReturn Self.value\n\tEnd Method\nEnd Type\n\nRem\n\tbbdoc: Represents a string value\nEnd Rem\nType TXMLRPC_Value_String Extends TXMLRPC_Value_Abstract\n\tField value:String\n\tMethod GetString:String()\n\t\tReturn Self.value\n\tEnd Method\nEnd Type\n\nRem\n\tbbdoc: Represents a collection. This is a base type\nEnd Rem\nType TXMLRPC_Value_Collection Extends TXMLRPC_Value_Abstract Abstract\n\tField data:TMap\n\tMethod SetData(el:Byte Ptr) Abstract\nEnd Type\n\nRem\n\tbbdoc: Represents an array\nEnd Rem\nType TXMLRPC_Value_Array Extends TXMLRPC_Value_Collection\n\tMethod SetData(el:Byte Ptr)\n\t\tSelf.data = New TMap\n\t\tLocal map:TMap = TXMLRPC_Response_Data.IterateVector(el)\n\t\tLocal counter:Int = 0\n\t\tFor Local val:TXMLRPC_Value_Abstract = EachIn map.Values()\n\t\t\tSelf.data.Insert(String.FromInt(counter), val)\n\t\t\tcounter:+1\n\t\tNext\n\tEnd Method\nEnd Type\n\nRem\n\tbbdoc: Represents an associative array\nEnd Rem\nType TXMLRPC_Value_Struct Extends TXMLRPC_Value_Collection\n\tMethod SetData(el:Byte Ptr)\n\t\tSelf.data = TXMLRPC_Response_Data.IterateVector(el)\n\tEnd Method\nEnd Type\n","old_contents":"Rem\n\tbbdoc: XML-RPC Data Type exception\nEnd Rem\nType TXMLRPC_Value_Exception Extends TXMLRPC_Exception \nEnd Type\n\nRem\n\tbbdoc: Base type for all XML-RPC data types\nEnd Rem\nType TXMLRPC_Value_Abstract Abstract\n\tField _type:Int\n\n\tRem\n\t\tbbdoc: The name or id this value has been identified with in the response. read-only\n\tEnd Rem\n\tField name:String\n\t\n\tRem\n\t\tbbdoc: Convert a XMLRPC_VALUE from XMLRPC-EPI to a BlitzMax type\n\tEnd Rem\n\tFunction XMLRPC_To_BlizMax:TXMLRPC_Value_Abstract(val:Byte Ptr) Final\n\t\tLocal dataType:Int = XMLRPC_GetValueType(val)\n\t\tLocal data:TXMLRPC_Value_Abstract\n\t\tSelect dataType\n\t\t\tCase xmlrpc_none\n\t\t\t\tdata = New TXMLRPC_Value_None\n\t\t\tCase xmlrpc_empty\n\t\t\t\tdata = New TXMLRPC_Value_Empty\n\t\t\tCase xmlrpc_base64\n\t\t\t\tdata = New TXMLRPC_Value_Base64\n\t\t\t\tLocal cStr:Byte Ptr = XMLRPC_GetValueBase64(val)\n\t\t\t\tIf cStr\n\t\t\t\t\tTXMLRPC_Value_Base64(data).value = String.FromCString(cStr)\n\t\t\t\t\tXMLRPC_Free(cStr)\n\t\t\t\tEnd If\n\t\t\tCase xmlrpc_boolean\n\t\t\t\tdata = New TXMLRPC_Value_Boolean\n\t\t\t\tTXMLRPC_Value_Boolean(data).value = XMLRPC_GetValueBoolean(val)\n\t\t\tCase xmlrpc_datetime\n\t\t\t\tdata = New TXMLRPC_Value_Datetime\n\t\t\t\tLocal cStr:Byte Ptr = XMLRPC_GetValueDateTime_ISO8601(val)\n\t\t\t\tIf cStr\n\t\t\t\t\tTXMLRPC_Value_Datetime(data).value = String.FromCString(cStr)\n\t\t\t\t\tXMLRPC_Free(cStr)\n\t\t\t\tEnd If\n\t\t\tCase xmlrpc_double\n\t\t\t\tdata = New TXMLRPC_Value_Double\n\t\t\t\tTXMLRPC_Value_Double(data).value = XMLRPC_GetValueDouble(val)\n\t\t\tCase xmlrpc_int\n\t\t\t\tdata = New TXMLRPC_Value_Int\n\t\t\t\tTXMLRPC_Value_Int(data).value = XMLRPC_GetValueInt(val)\n\t\t\tCase xmlrpc_string\n\t\t\t\tdata = New TXMLRPC_Value_String\n\t\t\t\tLocal cStr:Byte Ptr = XMLRPC_GetValueString(val)\n\t\t\t\tIf cStr\n\t\t\t\t\tTXMLRPC_Value_String(data).value = String.FromCString(cStr)\n\t\t\t\t\tXMLRPC_Free(cStr)\n\t\t\t\tEnd If\n\t\t\tCase xmlrpc_vector\n\t\t\t\tLocal vectorType:Int = XMLRPC_GetVectorType(val)\n\t\t\t\tSelect vectorType\n\t\t\t\t\tCase xmlrpc_vector_array\n\t\t\t\t\t\tdata = New TXMLRPC_Value_Array\n\t\t\t\t\tCase xmlrpc_vector_struct\n\t\t\t\t\t\tdata = New TXMLRPC_Value_Struct\n\t\t\t\t\tCase xmlrpc_vector_mixed\n\t\t\t\t\t\tThrow New TXMLRPC_Value_Exception.Create(\"Not sure yet how to handle a xmlrpc_vector_mixed value\")\n\t\t\t\tEnd Select\n\t\t\t\t\n\t\t\t\tIf TXMLRPC_Value_Collection(data)\n\t\t\t\t\tTXMLRPC_Value_Collection(data).SetData(val)\n\t\t\t\tEnd If\n\t\t\tDefault\n\t\t\t\tThrow New TXMLRPC_Value_Exception.Create(\"I don't know a XMLRPC_VALUE with number \" + dataType)\n\t\tEnd Select\n\t\t\n\t\tIf data\n\t\t\tdata._type = dataType\n\t\t\tLocal cStr:Byte Ptr = XMLRPC_GetValueID(val)\n\t\t\tIf cStr\n\t\t\t\tdata.name = String.FromCString(cStr)\n\t\t\t\tXMLRPC_Free(cStr)\n\t\t\tEnd If\n\t\tEnd If\n\t\t\n\t\tReturn data\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Convert data type to string\n\t\tabout: Uses reflection to see if a Field called value is available. If so, it tries to convert it to a string and returns it\n\tEnd Rem\n\tMethod ToString:String()\n\t\tLocal r:TTypeId = TTypeId.ForObject(Self)\n\t\t\n\t\tFor Local fld:TField = EachIn r.EnumFields()\n\t\t\t'Check if object has a Field called value\n\t\t\t'If so, check it's type, convert it to a string and return it\n\t\t\tIf fld.Name() = \"value\"\n\t\t\t\tSelect fld.TypeId().Name()\n\t\t\t\t\tCase \"String\"\n\t\t\t\t\t\tReturn fld.GetString(Self)\n\t\t\t\t\tCase \"Int\"\n\t\t\t\t\t\tReturn String(fld.GetInt(Self))\n\t\t\t\t\tCase \"Byte\"\n\t\t\t\t\t\tReturn String(fld.GetInt(Self))\n\t\t\t\t\tCase \"Long\"\n\t\t\t\t\t\tReturn String(fld.GetLong(Self))\n\t\t\t\t\tCase \"Double\"\n\t\t\t\t\t\tReturn String(fld.GetDouble(Self))\n\t\t\t\tEnd Select\n\t\t\tEnd If\n\t\tNext\n\t\tReturn \"\"\n'\t\tThrow New TXMLRPC_Value_Exception.Create(\"Can't convert datatype to string\")\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Return byte value\n\tEnd Rem\n\tMethod GetByte:Byte()\n\t\tThrow New TXMLRPC_Value_Exception.Create(\"Method GetByte not implemented for this type\")\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Return integer value\n\tEnd Rem\n\tMethod GetInt:Int()\n\t\tThrow New TXMLRPC_Value_Exception.Create(\"Method GetInt not implemented for this type\")\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Return double value\n\tEnd Rem\n\tMethod GetDouble:Double()\n\t\tThrow New TXMLRPC_Value_Exception.Create(\"Method GetDouble not implemented for this type\")\n\tEnd Method\n\n\tRem\n\t\tbbdoc: Return string value\n\tEnd Rem\n\tMethod GetString:String()\n\t\tThrow New TXMLRPC_Value_Exception.Create(\"Method GetString not implemented for this type\")\n\tEnd Method\nEnd Type\n\nRem\n\tbbdoc: Represents none value\nEnd Rem\nType TXMLRPC_Value_None Extends TXMLRPC_Value_Abstract\nEnd Type\n\nRem\n\tbbdoc: Represents an empty value\nEnd Rem\nType TXMLRPC_Value_Empty Extends TXMLRPC_Value_Abstract\n\tField value:Object = Null\nEnd Type\n\nRem\n\tbbdoc: Represents a Base64 encoded string\nEnd Rem\nType TXMLRPC_Value_Base64 Extends TXMLRPC_Value_Abstract\n\tField value:String\n\tMethod GetString:String()\n\t\tReturn Self.value\n\tEnd Method\nEnd Type\n\nRem\n\tbbdoc: Represents a boolean value\nEnd Rem\nType TXMLRPC_Value_Boolean Extends TXMLRPC_Value_Abstract\n\tField value:Byte\n\tMethod GetByte:Byte()\n\t\tReturn Self.value\n\tEnd Method\nEnd Type\n\nRem\n\tbbdoc: Represents a datetime string\nEnd Rem\nType TXMLRPC_Value_Datetime Extends TXMLRPC_Value_Abstract\n\tField value:String\n\tMethod GetString:String()\n\t\tReturn Self.value\n\tEnd Method\nEnd Type\n\nRem\n\tbbdoc: Represents a double value\nEnd Rem\nType TXMLRPC_Value_Double Extends TXMLRPC_Value_Abstract\n\tField value:Double\n\tMethod GetDouble:Double()\n\t\tReturn Self.value\n\tEnd Method\nEnd Type\n\nRem\n\tbbdoc: Represents a integer value\nEnd Rem\nType TXMLRPC_Value_Int Extends TXMLRPC_Value_Abstract\n\tField value:Int\n\tMethod GetInt:Int()\n\t\tReturn Self.value\n\tEnd Method\nEnd Type\n\nRem\n\tbbdoc: Represents a string value\nEnd Rem\nType TXMLRPC_Value_String Extends TXMLRPC_Value_Abstract\n\tField value:String\n\tMethod GetString:String()\n\t\tReturn Self.value\n\tEnd Method\nEnd Type\n\nRem\n\tbbdoc: Represents a collection. This is a base type\nEnd Rem\nType TXMLRPC_Value_Collection Extends TXMLRPC_Value_Abstract Abstract\n\tField data:TMap\n\tMethod SetData(el:Byte Ptr) Abstract\nEnd Type\n\nRem\n\tbbdoc: Represents an array\nEnd Rem\nType TXMLRPC_Value_Array Extends TXMLRPC_Value_Collection\n\tMethod SetData(el:Byte Ptr)\n\t\tSelf.data = New TMap\n\t\tLocal map:TMap = TXMLRPC_Response_Data.IterateVector(el)\n\t\tLocal counter:Int = 0\n\t\tFor Local val:TXMLRPC_Value_Abstract = EachIn map.Values()\n\t\t\tSelf.data.Insert(String.FromInt(counter), val)\n\t\t\tcounter:+1\n\t\tNext\n\tEnd Method\nEnd Type\n\nRem\n\tbbdoc: Represents an associative array\nEnd Rem\nType TXMLRPC_Value_Struct Extends TXMLRPC_Value_Collection\n\tMethod SetData(el:Byte Ptr)\n\t\tSelf.data = TXMLRPC_Response_Data.IterateVector(el)\n\tEnd Method\nEnd Type\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"fcd2f478a93fbebc61280fabdad50cf90d1ebfb0","subject":"Wrapped LoadText with a Try\/Catch to return Null","message":"Wrapped LoadText with a Try\/Catch to return Null\n","repos":"swoolcock\/diddy,swoolcock\/diddy,swoolcock\/diddy,swoolcock\/diddy,swoolcock\/diddy","old_file":"monkeymax\/modules\/mojo\/native\/mojo.bmax.bmx","new_file":"monkeymax\/modules\/mojo\/native\/mojo.bmax.bmx","new_contents":"' ***** Start mojo.bmax.bmx ******\r\n\r\nGlobal app:gxtkApp\r\n\r\nType gxtkApp\r\n\tField ginput:gxtkInput\r\n\tField gaudio:gxtkAudio\r\n\tField ggraphics:gxtkGraphics\r\n\r\n\tField dead:Int=0\r\n\tField suspended:Int=0\r\n\tField vloading:Int=0\r\n\tField maxloading:Int=0\r\n\tField updateRate:Int=0\r\n\tField nextUpdate:Float=0\r\n\tField updatePeriod:Float=0\r\n\tField startMillis:Float=0\r\n\t\r\n\tMethod New()' gxtkApp()\r\n\t\tapp=Self\r\n\t\tggraphics=New gxtkGraphics\r\n\tEndMethod\r\n\t\r\n\tMethod Setup()\r\n\t\tginput=New gxtkInput\r\n\t\tgaudio=New gxtkAudio\r\n\r\n\t\tbb_input__1Set_1Input_1Device(ginput)\r\n\t\tbb_audio__1Set_1Audio_1Device(gaudio)\r\n\t\t\r\n\t\tstartMillis=BlitzMaxMillisecs()\r\n\t\t\r\n\t\tSetFrameRate( 0 )\r\n\t\t\r\n\t\tInvokeOnCreate()\r\n\t\tInvokeOnRender()\r\n\t\tUpdate()\r\n\tEndMethod\r\n\t\r\n\tMethod Update()\r\n\t\tWhile Not AppTerminate()\r\n\t\t\tIf Not updatePeriod return\r\n\t\t\tLocal updates:Int = 0\r\n\t\t\t\r\n\t\t\tRepeat\r\n\t\t\t\tnextUpdate:+updatePeriod\r\n\t\t\t\tInvokeOnUpdate()\r\n\t\t\t\tIf Not updatePeriod Then Exit\r\n\t\t\t\tIf nextUpdate>BlitzMaxMillisecs() Then Exit\r\n\t\t\t\tupdates:+1\r\n\t\t\t\tIf updates = 7 Then\r\n\t\t\t\t\tnextUpdate = BlitzMaxMillisecs()\r\n\t\t\t\t\tExit\r\n\t\t\t\tEndIf\r\n\t\t\tForever\r\n\t\t\tInvokeOnRender()\r\n\t\t\tLocal del:Int = nextUpdate - BlitzMaxMillisecs()\r\n\t\t\tIf del < 1 Then del = 1\r\n\t\t\tDelay(del)\r\n\t\tWend\r\n\tEndMethod\r\n\t\r\n\tMethod InvokeOnCreate()\r\n\t\tIf dead Return\r\n\t\tdead = 1\r\n\t\tOnCreate()\r\n\t\tdead = 0\r\n\tEndMethod\r\n\r\n\tMethod InvokeOnUpdate()\r\n\t\tIf dead Or suspended Or Not updateRate Or vloading Return\r\n\t\tOnUpdate()\r\n\tEndMethod\r\n\t\r\n\tMethod InvokeOnRender()\r\n\t\tIf dead Or suspended Return\r\n\t\tggraphics.BeginRender()\r\n\t\tIf vloading\r\n\t\t\tOnLoading()\r\n\t\tElse\r\n\t\t\tOnRender()\r\n\t\tEndIf\r\n\t\tggraphics.EndRender()\r\n\tEndMethod\r\n\t\r\n\t\r\n\tMethod SetFrameRate( fps:Int )\r\n\t\tIf fps\r\n\t\t\tupdatePeriod=1000.0\/fps\r\n\t\t\tnextUpdate=BlitzMaxMillisecs() +updatePeriod\r\n\t\tElse\r\n\t\t\tupdatePeriod=0\r\n\t\tEndIf\r\n\tEndMethod\r\n\r\n\tMethod LoadState:String()\r\n'\t\tvar file:SharedObject=SharedObject.getLocal( \"gxtkapp\" );\r\n'\t\tvar state:String=file.data.state;\r\n'\t\tfile.close();\r\n'\t\tif( state ) return state;\r\n\t\tReturn \"\"\r\n\tEndMethod\r\n\t\r\n\tMethod SaveState:Int( state:String )\r\n'\t\tvar file:SharedObject=SharedObject.getLocal( \"gxtkapp\" );\r\n'\t\tfile.data.state=state;\r\n'\t\tfile.close();\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod LoadString:String( path:String )\r\n\t\tpath = \"data\/\" + path\r\n\t\tTry\r\n\t\t\tReturn LoadText( path )\r\n\t\tCatch ReadFail:Object\r\n\t\t\tReturn Null\r\n\t\tEndTry\r\n\tEndMethod\r\n\t\r\n\t' ***** GXTK API *****\r\n\t\r\n\tMethod GraphicsDevice:gxtkGraphics()\r\n\t\tReturn ggraphics\r\n\tEndMethod\r\n\r\n\tMethod InputDevice:gxtkInput()\r\n\t\tReturn ginput\r\n\tEndMethod\r\n\r\n\tMethod AudioDevice:gxtkAudio()\r\n\t\tReturn gaudio\r\n\tEndMethod\r\n\r\n\tMethod SetUpdateRate:Int(hertz:Int)\r\n\t\tupdateRate = hertz\r\n\t\tIf Not vloading Then SetFrameRate(updateRate)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod MilliSecs:Int()\r\n\t\tReturn BlitzMaxMillisecs() - startMillis\r\n\tEndMethod\r\n\t\r\n\tMethod Loading:Int()\r\n\t\tReturn vloading\r\n\tEndMethod\r\n\r\n\tMethod OnCreate:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod OnUpdate:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod OnSuspend:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod OnResume:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod OnRender:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod OnLoading:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkGraphics\r\n\tField gmode:Int = 1\r\n\tField ix:Float=1,iy:Float,jx:Float,jy:Float=1,tx:Float,ty:Float\r\n\tField sx:Float=1,sy:Float=1,rot:Float=0\r\n\t\r\n\tMethod Mode:Int()\r\n\t\tReturn gmode\r\n\tEndMethod\r\n\t\r\n\tMethod Cls:Int(r:Int = 0, g:Int = 0, b:Int = 0)\r\n\t\tBlitzMaxCls(r, g, b)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawPoint:Int(x:Float, y:Float)\r\n\t\tLocal nx:Float = TransX(x,y)\r\n\t\tLocal ny:Float = TransY(x,y)\r\n\t\tPlot nx, ny\r\n\tEndMethod\r\n\t\r\n\tMethod LoadSurface:gxtkSurface(path:String)\r\n\t\tLocal image:TImage = LoadImage(\"data\/\"+path)\r\n\t\tIf image Then\r\n\t\t\tLocal gs:gxtkSurface = New gxtkSurface\r\n\t\t\tgs.setImage(image)\r\n\t\t\tReturn gs\r\n\t\tEndIf\r\n\t\tReturn Null\r\n\tEndMethod\r\n\t\r\n\tMethod BeginRender()\r\n\tEndMethod\r\n\t\r\n\tMethod EndRender()\r\n\t\tFlip\r\n\tEndMethod\r\n\t\r\n\tMethod SetColor:Int(r:Int, g:Int, b:Int)\r\n\t\tBlitzMaxSetColor(r, g, b)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod SetAlpha:Int(a:Float)\r\n\t\tBlitzMaxSetAlpha(a)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod SetBlend:Int(blend:Int)\r\n\t\tBlitzMaxSetBlend(blend)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod Width:Int()\r\n\t\tReturn GraphicsWidth()\r\n\tEndMethod\r\n\t\r\n\tMethod Height:Int()\r\n\t\tReturn GraphicsHeight()\r\n\tEndMethod\r\n\t\r\n\tMethod SetScissor:Int(x:Int, y:Int, w:Int, h:Int)\r\n\t\tSetViewport(x, y, w, h) ' NOT TESTED!\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod TransX:Float(x:Float, y:Float)\r\n\t\tReturn ix*x + jx*y + tx\r\n\tEndMethod\r\n\t\r\n\tMethod TransY:Float(x:Float, y:Float)\r\n\t\tReturn iy*x + jy*y + ty\r\n\tEndMethod\r\n\t\r\n\tMethod SetMatrix:Int(ix:Float,iy:Float,jx:Float,jy:Float,tx:Float,ty:Float)\r\n\t\tSelf.ix = ix ; Self.iy = iy\r\n\t\tSelf.jx = jx ; Self.jy = jy\r\n\t\tSelf.tx = tx ; Self.ty = ty\r\n\t\tsx = Sqr(ix*ix+iy*iy)\r\n\t\tsy = Sqr(jx*jx+jy*jy)\r\n\t\trot = Atan2( iy, ix )\r\n\t\tIf ix < 0 Then\r\n\t\t\tsx = -sx\r\n\t\t\trot :+ 180\r\n\t\tEndIf\r\n\t\tIf jy < 0 Then sy = -sy\r\n\t\tSetTransform( rot, sx, sy )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawSurface:Int(surface:gxtkSurface,x:Float,y:Float)\r\n\t\tLocal nx:Float = TransX(x,y)\r\n\t\tLocal ny:Float = TransY(x,y)\r\n\t\tDrawImage(surface.image, nx, ny, 0)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawSurface2:Int(surface:gxtkSurface,x:Float,y:Float, srcx:Int, srcy:Int, srcw:Int, srch:Int )\r\n\t\tLocal nx:Float = TransX(x,y)\r\n\t\tLocal ny:Float = TransY(x,y)\r\n\t\tDrawSubImageRect(surface.image, nx, ny, srcw, srch, srcx, srcy, srcw, srch)\t\t\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawLine:Int( x1:Float,y1:Float,x2:Float,y2:Float )\r\n\t\tLocal nx1:Float = TransX(x1,y1)\r\n\t\tLocal ny1:Float = TransY(x1,y1)\r\n\t\tLocal nx2:Float = TransX(x2,y2)\r\n\t\tLocal ny2:Float = TransY(x2,y2)\r\n\t\t' Need to reset transform so that BlitzMax doesn't try to apply rotation\r\n\t\tSetTransform( 0, 1, 1 )\r\n\t\tBlitzMaxDrawLine(nx1, ny1, nx2, ny2)\r\n\t\tSetTransform( rot, sx, sy )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawOval:Int( x:Float, y:Float, w:Float, h:Float )\r\n\t\tLocal nx:Float = TransX(x,y)\r\n\t\tLocal ny:Float = TransY(x,y)\r\n\t\tBlitzMaxDrawOval(nx, ny, w, h)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawPoly:Int(vertices:Float[])\r\n\t\t' setting the origin to use the current rotation translation\r\n\t\tSetOrigin(TransX(0,0), TransY(0,0))\r\n\t\tBlitzMaxDrawPoly( vertices )\r\n\t\tSetOrigin(0, 0)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawRect:Int( x:Float, y:Float, w:Float, h:Float )\r\n\t\tLocal nx:Float = TransX(x,y)\r\n\t\tLocal ny:Float = TransY(x,y)\r\n\t\tBlitzMaxDrawRect(nx, ny, w, h)\r\n\t\tReturn 0\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkInput\r\n\tMethod MouseX:Float()\r\n\t\tReturn BRL.PolledInput.MouseX()\r\n\tEndMethod\r\n\r\n\tMethod MouseY:Float()\r\n\t\tReturn BRL.PolledInput.MouseY()\r\n\tEndMethod\r\n\t\r\n\tMethod KeyDown:Int( key:Int )\r\n\t\tif( key = 384 ) key = 1 ' change TOUCH0 to MOUSE_LMB\r\n\r\n\t\tIf( key >= 1 And key <= 3 )\r\n\t\t\tReturn BRL.PolledInput.MouseDown( key )\r\n\t\tEndIf\r\n\t\tIf key < 256\r\n\t\t\tReturn BRL.PolledInput.KeyDown( key )\r\n\t\tElse\r\n\t\t\tReturn 0\r\n\t\tEndIf\r\n\tEndMethod\r\n\r\n\tMethod KeyHit:Int( key:Int )\r\n\t\tif( key = 384 ) key = 1 ' change TOUCH0 to MOUSE_LMB\r\n\t\tIf( key >= 1 And key <= 3 )\r\n\t\t\tReturn BRL.PolledInput.MouseHit( key )\r\n\t\tEndIf\r\n\t\tIf key < 256\r\n\t\t\tReturn BRL.PolledInput.KeyHit( key )\r\n\t\tElse\r\n\t\t\tReturn 0\r\n\t\tEndIf\r\n\tEndMethod\r\n\r\n\tMethod GetChar:Int()\r\n\t\tReturn BRL.PolledInput.GetChar()\r\n\tEndMethod\r\n\r\n\tMethod JoyX:Int( index:Int )\r\n\t\tReturn Pub.FreeJoy.JoyX( index )\r\n\tEndMethod\r\n\r\n\tMethod JoyY:Int( index:Int )\r\n\t\tReturn Pub.FreeJoy.JoyY( index )\r\n\tEndMethod\r\n\r\n\tMethod JoyZ:Int( index:Int )\r\n\t\tReturn Pub.FreeJoy.JoyZ( index )\r\n\tEndMethod\r\n\r\n\tMethod TouchX:Float( index:Int )\r\n\t\tReturn BRL.PolledInput.MouseX()\r\n\tEndMethod\r\n\r\n\tMethod TouchY:Float( index:Int )\r\n\t\tReturn BRL.PolledInput.MouseY()\r\n\tEndMethod\r\n\t\r\n\tMethod AccelX:Int()\r\n\t\treturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod AccelY:Int()\r\n\t\treturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod AccelZ:Int()\r\n\t\treturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod SetKeyboardEnabled:Int( enabled:int )\r\n\t\tReturn 0\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkChannel\r\n\tField channel:TChannel\t' null then not playing\r\n\tField sample:gxtkSample\r\n\tField loops:int\r\n\t'Field transform:SoundTransform=new SoundTransform()\r\n\t'Field pausepos:Number\r\n\tField state:int\r\n\t\r\n\tMethod New()\r\n\t\tchannel = New TChannel\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkAudio\r\n\tField amusicState:Int = 0\r\n\tField channels:gxtkChannel[] = New gxtkChannel[33]\r\n\t\r\n\tMethod New()\r\n\t\tFor local i:Int = 0 To 33 - 1\r\n\t\t\tchannels[i] = New gxtkChannel\r\n\t\tNext\r\n\tEndMethod\r\n\t\r\n\tMethod MusicState:Int()\r\n'\t\tIf( musicState = 1 And music.isPlaying() = False )\r\n'\t\t\tmusicState = 0;\r\n'\t\tEndif\r\n\t\tReturn amusicState\r\n\tEndMethod\r\n\t\r\n\tMethod PlayMusic:Int( path:String, flags:Int )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod ChannelState:int( channel:int )\r\n\t\tReturn -1\r\n\tEndMethod\r\n\t\r\n\tMethod StopMusic()\r\n\tEndMethod\r\n\t\r\n\tMethod StopChannel( channel:Int )\r\n\tEndMethod\r\n\r\n\tMethod PlaySample( sound:gxtkSample, channel:Int, flags:Int )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\t\r\n\t\t'If chan.state <> 0 Then chan.channel.Stop() <-- this crashes after the first play!?\r\n\t\t\r\n\t\tchan.sample = sound\r\n\t\t'chan.loops = flags ? 0x7fffffff : 0;\r\n\t\t'chan.channel = sample.sound.play( 0,chan.loops,chan.transform );\r\n\t\t'chan.channel = sound\r\n\t\tchan.state=1\r\n\t\r\n\t\tPlaySound( sound.sound, chan.channel )\r\n\tEndMethod\r\n\r\n\tMethod SetPan( channel:Int, pan:Float )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tchan.channel.SetPan(pan)\r\n\tEndMethod\r\n\r\n\tMethod SetRate( channel:Int, rate:Float )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tchan.channel.SetRate(rate)\r\n\tEndMethod\r\n\r\n\tMethod PauseMusic:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod ResumeMusic:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod SetMusicVolume:Int( volume:Float )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod SetVolume:Int( channel:Int, volume:Float )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tchan.channel.SetVolume(volume)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod LoadSample:gxtkSample( path:String )\r\n\t\tLocal extension:String = ExtractExt( path)\r\n\t\tIf extension = \"ogg\" Or extension = \"wav\" Then\r\n\t\t\tLocal sound:TSound = LoadSound(\"data\/\"+path)\r\n\t\t\tIf sound Then\r\n\t\t\t\tLocal gs:gxtkSample = New gxtkSample\r\n\t\t\t\tgs.setSound(sound)\r\n\t\t\t\tReturn gs\r\n\t\t\tEndIf\r\n\t\tElse\r\n\t\t\tRuntimeError \"BlitzMax can only use ogg and wav file formats\"\r\n\t\tEndIf\r\n\t\tReturn Null\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkSample\r\n\tField sound:TSound\r\n\t\r\n\tMethod setSound(sound:TSound)\r\n\t\tSelf.sound = sound\r\n\tEndMethod\r\n\t\r\n\tMethod Discard()\r\n\t\tSelf.sound = null\r\n\tEndMethod\r\nEndType\r\n\r\nFunction BlitzMaxDrawPoly:Int(vertices:Float[])\r\n\tDrawPoly vertices\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxDrawRect:Int( x:Float, y:Float, w:Float, h:Float )\r\n\tDrawRect x, y, w, h\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxDrawOval:Int( x:Float, y:Float, w:Float, h:Float )\r\n\tDrawOval x, y, w, h\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxDrawLine:Int( x1:Float,y1:Float,x2:Float,y2:Float )\r\n\tDrawLine x1, y1, x2, y2\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxMillisecs:Int()\r\n\tReturn MilliSecs()\r\nEndFunction\r\n\r\nFunction BlitzMaxSetColor(r:Int, g:Int, b:Int)\r\n\tSetColor(r, g, b)\r\nEndFunction\r\n\r\nFunction BlitzMaxSetBlend(blend:Int)\r\n\tSelect blend\r\n\t\tCase 0\r\n\t\t\tSetBlend( ALPHABLEND )\r\n\t\tCase 1\r\n\t\t\tSetBlend( LIGHTBLEND )\r\n\tEnd Select\r\nEndFunction\r\n\r\nFunction BlitzMaxSetAlpha(a:Float)\r\n\tSetAlpha(a)\r\nEndFunction\r\n\r\nFunction BlitzMaxCls(r:Int = 0, g:Int = 0, b:Int = 0)\r\n\tSetClsColor(r, g, b)\r\n\tCls\r\nEndFunction\r\n\r\nType gxtkSurface\r\n\tField w:Int, h:Int\r\n\tField image:TImage\r\n\t\r\n\tMethod setImage(image:TImage)\r\n\t\tSelf.image = image\r\n\tEndMethod\r\n\t\r\n\tMethod Width:Int()\r\n\t\tReturn image.Width\r\n\tEndMethod\r\n\t\r\n\tMethod Height:Int()\r\n\t\tReturn image.Height\r\n\tEndMethod\r\n\t\r\n\tMethod Discard()\r\n\tEndMethod\r\nEndType\r\n\r\n' ***** End mojo.bmax.bmx ******\r\n\r\n","old_contents":"' ***** Start mojo.bmax.bmx ******\r\n\r\nGlobal app:gxtkApp\r\n\r\nType gxtkApp\r\n\tField ginput:gxtkInput\r\n\tField gaudio:gxtkAudio\r\n\tField ggraphics:gxtkGraphics\r\n\r\n\tField dead:Int=0\r\n\tField suspended:Int=0\r\n\tField vloading:Int=0\r\n\tField maxloading:Int=0\r\n\tField updateRate:Int=0\r\n\tField nextUpdate:Float=0\r\n\tField updatePeriod:Float=0\r\n\tField startMillis:Float=0\r\n\t\r\n\tMethod New()' gxtkApp()\r\n\t\tapp=Self\r\n\t\tggraphics=New gxtkGraphics\r\n\tEndMethod\r\n\t\r\n\tMethod Setup()\r\n\t\tginput=New gxtkInput\r\n\t\tgaudio=New gxtkAudio\r\n\r\n\t\tbb_input__1Set_1Input_1Device(ginput)\r\n\t\tbb_audio__1Set_1Audio_1Device(gaudio)\r\n\t\t\r\n\t\tstartMillis=BlitzMaxMillisecs()\r\n\t\t\r\n\t\tSetFrameRate( 0 )\r\n\t\t\r\n\t\tInvokeOnCreate()\r\n\t\tInvokeOnRender()\r\n\t\tUpdate()\r\n\tEndMethod\r\n\t\r\n\tMethod Update()\r\n\t\tWhile Not AppTerminate()\r\n\t\t\tIf Not updatePeriod return\r\n\t\t\tLocal updates:Int = 0\r\n\t\t\t\r\n\t\t\tRepeat\r\n\t\t\t\tnextUpdate:+updatePeriod\r\n\t\t\t\tInvokeOnUpdate()\r\n\t\t\t\tIf Not updatePeriod Then Exit\r\n\t\t\t\tIf nextUpdate>BlitzMaxMillisecs() Then Exit\r\n\t\t\t\tupdates:+1\r\n\t\t\t\tIf updates = 7 Then\r\n\t\t\t\t\tnextUpdate = BlitzMaxMillisecs()\r\n\t\t\t\t\tExit\r\n\t\t\t\tEndIf\r\n\t\t\tForever\r\n\t\t\tInvokeOnRender()\r\n\t\t\tLocal del:Int = nextUpdate - BlitzMaxMillisecs()\r\n\t\t\tIf del < 1 Then del = 1\r\n\t\t\tDelay(del)\r\n\t\tWend\r\n\tEndMethod\r\n\t\r\n\tMethod InvokeOnCreate()\r\n\t\tIf dead Return\r\n\t\tdead = 1\r\n\t\tOnCreate()\r\n\t\tdead = 0\r\n\tEndMethod\r\n\r\n\tMethod InvokeOnUpdate()\r\n\t\tIf dead Or suspended Or Not updateRate Or vloading Return\r\n\t\tOnUpdate()\r\n\tEndMethod\r\n\t\r\n\tMethod InvokeOnRender()\r\n\t\tIf dead Or suspended Return\r\n\t\tggraphics.BeginRender()\r\n\t\tIf vloading\r\n\t\t\tOnLoading()\r\n\t\tElse\r\n\t\t\tOnRender()\r\n\t\tEndIf\r\n\t\tggraphics.EndRender()\r\n\tEndMethod\r\n\t\r\n\t\r\n\tMethod SetFrameRate( fps:Int )\r\n\t\tIf fps\r\n\t\t\tupdatePeriod=1000.0\/fps\r\n\t\t\tnextUpdate=BlitzMaxMillisecs() +updatePeriod\r\n\t\tElse\r\n\t\t\tupdatePeriod=0\r\n\t\tEndIf\r\n\tEndMethod\r\n\r\n\tMethod LoadState:String()\r\n'\t\tvar file:SharedObject=SharedObject.getLocal( \"gxtkapp\" );\r\n'\t\tvar state:String=file.data.state;\r\n'\t\tfile.close();\r\n'\t\tif( state ) return state;\r\n\t\tReturn \"\"\r\n\tEndMethod\r\n\t\r\n\tMethod SaveState:Int( state:String )\r\n'\t\tvar file:SharedObject=SharedObject.getLocal( \"gxtkapp\" );\r\n'\t\tfile.data.state=state;\r\n'\t\tfile.close();\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod LoadString:String( path:String )\r\n\t\tpath = \"data\/\" + path\r\n\t\tReturn LoadText( path )\r\n\tEndMethod\r\n\t\r\n\t' ***** GXTK API *****\r\n\t\r\n\tMethod GraphicsDevice:gxtkGraphics()\r\n\t\tReturn ggraphics\r\n\tEndMethod\r\n\r\n\tMethod InputDevice:gxtkInput()\r\n\t\tReturn ginput\r\n\tEndMethod\r\n\r\n\tMethod AudioDevice:gxtkAudio()\r\n\t\tReturn gaudio\r\n\tEndMethod\r\n\r\n\tMethod SetUpdateRate:Int(hertz:Int)\r\n\t\tupdateRate = hertz\r\n\t\tIf Not vloading Then SetFrameRate(updateRate)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod MilliSecs:Int()\r\n\t\tReturn BlitzMaxMillisecs() - startMillis\r\n\tEndMethod\r\n\t\r\n\tMethod Loading:Int()\r\n\t\tReturn vloading\r\n\tEndMethod\r\n\r\n\tMethod OnCreate:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod OnUpdate:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod OnSuspend:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod OnResume:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod OnRender:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod OnLoading:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkGraphics\r\n\tField gmode:Int = 1\r\n\tField ix:Float=1,iy:Float,jx:Float,jy:Float=1,tx:Float,ty:Float\r\n\tField sx:Float=1,sy:Float=1,rot:Float=0\r\n\t\r\n\tMethod Mode:Int()\r\n\t\tReturn gmode\r\n\tEndMethod\r\n\t\r\n\tMethod Cls:Int(r:Int = 0, g:Int = 0, b:Int = 0)\r\n\t\tBlitzMaxCls(r, g, b)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawPoint:Int(x:Float, y:Float)\r\n\t\tLocal nx:Float = TransX(x,y)\r\n\t\tLocal ny:Float = TransY(x,y)\r\n\t\tPlot nx, ny\r\n\tEndMethod\r\n\t\r\n\tMethod LoadSurface:gxtkSurface(path:String)\r\n\t\tLocal image:TImage = LoadImage(\"data\/\"+path)\r\n\t\tIf image Then\r\n\t\t\tLocal gs:gxtkSurface = New gxtkSurface\r\n\t\t\tgs.setImage(image)\r\n\t\t\tReturn gs\r\n\t\tEndIf\r\n\t\tReturn Null\r\n\tEndMethod\r\n\t\r\n\tMethod BeginRender()\r\n\tEndMethod\r\n\t\r\n\tMethod EndRender()\r\n\t\tFlip\r\n\tEndMethod\r\n\t\r\n\tMethod SetColor:Int(r:Int, g:Int, b:Int)\r\n\t\tBlitzMaxSetColor(r, g, b)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod SetAlpha:Int(a:Float)\r\n\t\tBlitzMaxSetAlpha(a)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod SetBlend:Int(blend:Int)\r\n\t\tBlitzMaxSetBlend(blend)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod Width:Int()\r\n\t\tReturn GraphicsWidth()\r\n\tEndMethod\r\n\t\r\n\tMethod Height:Int()\r\n\t\tReturn GraphicsHeight()\r\n\tEndMethod\r\n\t\r\n\tMethod SetScissor:Int(x:Int, y:Int, w:Int, h:Int)\r\n\t\tSetViewport(x, y, w, h) ' NOT TESTED!\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod TransX:Float(x:Float, y:Float)\r\n\t\tReturn ix*x + jx*y + tx\r\n\tEndMethod\r\n\t\r\n\tMethod TransY:Float(x:Float, y:Float)\r\n\t\tReturn iy*x + jy*y + ty\r\n\tEndMethod\r\n\t\r\n\tMethod SetMatrix:Int(ix:Float,iy:Float,jx:Float,jy:Float,tx:Float,ty:Float)\r\n\t\tSelf.ix = ix ; Self.iy = iy\r\n\t\tSelf.jx = jx ; Self.jy = jy\r\n\t\tSelf.tx = tx ; Self.ty = ty\r\n\t\tsx = Sqr(ix*ix+iy*iy)\r\n\t\tsy = Sqr(jx*jx+jy*jy)\r\n\t\trot = Atan2( iy, ix )\r\n\t\tIf ix < 0 Then\r\n\t\t\tsx = -sx\r\n\t\t\trot :+ 180\r\n\t\tEndIf\r\n\t\tIf jy < 0 Then sy = -sy\r\n\t\tSetTransform( rot, sx, sy )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawSurface:Int(surface:gxtkSurface,x:Float,y:Float)\r\n\t\tLocal nx:Float = TransX(x,y)\r\n\t\tLocal ny:Float = TransY(x,y)\r\n\t\tDrawImage(surface.image, nx, ny, 0)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawSurface2:Int(surface:gxtkSurface,x:Float,y:Float, srcx:Int, srcy:Int, srcw:Int, srch:Int )\r\n\t\tLocal nx:Float = TransX(x,y)\r\n\t\tLocal ny:Float = TransY(x,y)\r\n\t\tDrawSubImageRect(surface.image, nx, ny, srcw, srch, srcx, srcy, srcw, srch)\t\t\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawLine:Int( x1:Float,y1:Float,x2:Float,y2:Float )\r\n\t\tLocal nx1:Float = TransX(x1,y1)\r\n\t\tLocal ny1:Float = TransY(x1,y1)\r\n\t\tLocal nx2:Float = TransX(x2,y2)\r\n\t\tLocal ny2:Float = TransY(x2,y2)\r\n\t\t' Need to reset transform so that BlitzMax doesn't try to apply rotation\r\n\t\tSetTransform( 0, 1, 1 )\r\n\t\tBlitzMaxDrawLine(nx1, ny1, nx2, ny2)\r\n\t\tSetTransform( rot, sx, sy )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawOval:Int( x:Float, y:Float, w:Float, h:Float )\r\n\t\tLocal nx:Float = TransX(x,y)\r\n\t\tLocal ny:Float = TransY(x,y)\r\n\t\tBlitzMaxDrawOval(nx, ny, w, h)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawPoly:Int(vertices:Float[])\r\n\t\t' setting the origin to use the current rotation translation\r\n\t\tSetOrigin(TransX(0,0), TransY(0,0))\r\n\t\tBlitzMaxDrawPoly( vertices )\r\n\t\tSetOrigin(0, 0)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawRect:Int( x:Float, y:Float, w:Float, h:Float )\r\n\t\tLocal nx:Float = TransX(x,y)\r\n\t\tLocal ny:Float = TransY(x,y)\r\n\t\tBlitzMaxDrawRect(nx, ny, w, h)\r\n\t\tReturn 0\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkInput\r\n\tMethod MouseX:Float()\r\n\t\tReturn BRL.PolledInput.MouseX()\r\n\tEndMethod\r\n\r\n\tMethod MouseY:Float()\r\n\t\tReturn BRL.PolledInput.MouseY()\r\n\tEndMethod\r\n\t\r\n\tMethod KeyDown:Int( key:Int )\r\n\t\tif( key = 384 ) key = 1 ' change TOUCH0 to MOUSE_LMB\r\n\r\n\t\tIf( key >= 1 And key <= 3 )\r\n\t\t\tReturn BRL.PolledInput.MouseDown( key )\r\n\t\tEndIf\r\n\t\tIf key < 256\r\n\t\t\tReturn BRL.PolledInput.KeyDown( key )\r\n\t\tElse\r\n\t\t\tReturn 0\r\n\t\tEndIf\r\n\tEndMethod\r\n\r\n\tMethod KeyHit:Int( key:Int )\r\n\t\tif( key = 384 ) key = 1 ' change TOUCH0 to MOUSE_LMB\r\n\t\tIf( key >= 1 And key <= 3 )\r\n\t\t\tReturn BRL.PolledInput.MouseHit( key )\r\n\t\tEndIf\r\n\t\tIf key < 256\r\n\t\t\tReturn BRL.PolledInput.KeyHit( key )\r\n\t\tElse\r\n\t\t\tReturn 0\r\n\t\tEndIf\r\n\tEndMethod\r\n\r\n\tMethod GetChar:Int()\r\n\t\tReturn BRL.PolledInput.GetChar()\r\n\tEndMethod\r\n\r\n\tMethod JoyX:Int( index:Int )\r\n\t\tReturn Pub.FreeJoy.JoyX( index )\r\n\tEndMethod\r\n\r\n\tMethod JoyY:Int( index:Int )\r\n\t\tReturn Pub.FreeJoy.JoyY( index )\r\n\tEndMethod\r\n\r\n\tMethod JoyZ:Int( index:Int )\r\n\t\tReturn Pub.FreeJoy.JoyZ( index )\r\n\tEndMethod\r\n\r\n\tMethod TouchX:Float( index:Int )\r\n\t\tReturn BRL.PolledInput.MouseX()\r\n\tEndMethod\r\n\r\n\tMethod TouchY:Float( index:Int )\r\n\t\tReturn BRL.PolledInput.MouseY()\r\n\tEndMethod\r\n\t\r\n\tMethod AccelX:Int()\r\n\t\treturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod AccelY:Int()\r\n\t\treturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod AccelZ:Int()\r\n\t\treturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod SetKeyboardEnabled:Int( enabled:int )\r\n\t\tReturn 0\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkChannel\r\n\tField channel:TChannel\t' null then not playing\r\n\tField sample:gxtkSample\r\n\tField loops:int\r\n\t'Field transform:SoundTransform=new SoundTransform()\r\n\t'Field pausepos:Number\r\n\tField state:int\r\n\t\r\n\tMethod New()\r\n\t\tchannel = New TChannel\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkAudio\r\n\tField amusicState:Int = 0\r\n\tField channels:gxtkChannel[] = New gxtkChannel[33]\r\n\t\r\n\tMethod New()\r\n\t\tFor local i:Int = 0 To 33 - 1\r\n\t\t\tchannels[i] = New gxtkChannel\r\n\t\tNext\r\n\tEndMethod\r\n\t\r\n\tMethod MusicState:Int()\r\n'\t\tIf( musicState = 1 And music.isPlaying() = False )\r\n'\t\t\tmusicState = 0;\r\n'\t\tEndif\r\n\t\tReturn amusicState\r\n\tEndMethod\r\n\t\r\n\tMethod PlayMusic:Int( path:String, flags:Int )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod ChannelState:int( channel:int )\r\n\t\tReturn -1\r\n\tEndMethod\r\n\t\r\n\tMethod StopMusic()\r\n\tEndMethod\r\n\t\r\n\tMethod StopChannel( channel:Int )\r\n\tEndMethod\r\n\r\n\tMethod PlaySample( sound:gxtkSample, channel:Int, flags:Int )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\t\r\n\t\t'If chan.state <> 0 Then chan.channel.Stop() <-- this crashes after the first play!?\r\n\t\t\r\n\t\tchan.sample = sound\r\n\t\t'chan.loops = flags ? 0x7fffffff : 0;\r\n\t\t'chan.channel = sample.sound.play( 0,chan.loops,chan.transform );\r\n\t\t'chan.channel = sound\r\n\t\tchan.state=1\r\n\t\r\n\t\tPlaySound( sound.sound, chan.channel )\r\n\tEndMethod\r\n\r\n\tMethod SetPan( channel:Int, pan:Float )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tchan.channel.SetPan(pan)\r\n\tEndMethod\r\n\r\n\tMethod SetRate( channel:Int, rate:Float )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tchan.channel.SetRate(rate)\r\n\tEndMethod\r\n\r\n\tMethod PauseMusic:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod ResumeMusic:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod SetMusicVolume:Int( volume:Float )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod SetVolume:Int( channel:Int, volume:Float )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tchan.channel.SetVolume(volume)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod LoadSample:gxtkSample( path:String )\r\n\t\tLocal extension:String = ExtractExt( path)\r\n\t\tIf extension = \"ogg\" Or extension = \"wav\" Then\r\n\t\t\tLocal sound:TSound = LoadSound(\"data\/\"+path)\r\n\t\t\tIf sound Then\r\n\t\t\t\tLocal gs:gxtkSample = New gxtkSample\r\n\t\t\t\tgs.setSound(sound)\r\n\t\t\t\tReturn gs\r\n\t\t\tEndIf\r\n\t\tElse\r\n\t\t\tRuntimeError \"BlitzMax can only use ogg and wav file formats\"\r\n\t\tEndIf\r\n\t\tReturn Null\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkSample\r\n\tField sound:TSound\r\n\t\r\n\tMethod setSound(sound:TSound)\r\n\t\tSelf.sound = sound\r\n\tEndMethod\r\n\t\r\n\tMethod Discard()\r\n\t\tSelf.sound = null\r\n\tEndMethod\r\nEndType\r\n\r\nFunction BlitzMaxDrawPoly:Int(vertices:Float[])\r\n\tDrawPoly vertices\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxDrawRect:Int( x:Float, y:Float, w:Float, h:Float )\r\n\tDrawRect x, y, w, h\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxDrawOval:Int( x:Float, y:Float, w:Float, h:Float )\r\n\tDrawOval x, y, w, h\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxDrawLine:Int( x1:Float,y1:Float,x2:Float,y2:Float )\r\n\tDrawLine x1, y1, x2, y2\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxMillisecs:Int()\r\n\tReturn MilliSecs()\r\nEndFunction\r\n\r\nFunction BlitzMaxSetColor(r:Int, g:Int, b:Int)\r\n\tSetColor(r, g, b)\r\nEndFunction\r\n\r\nFunction BlitzMaxSetBlend(blend:Int)\r\n\tSelect blend\r\n\t\tCase 0\r\n\t\t\tSetBlend( ALPHABLEND )\r\n\t\tCase 1\r\n\t\t\tSetBlend( LIGHTBLEND )\r\n\tEnd Select\r\nEndFunction\r\n\r\nFunction BlitzMaxSetAlpha(a:Float)\r\n\tSetAlpha(a)\r\nEndFunction\r\n\r\nFunction BlitzMaxCls(r:Int = 0, g:Int = 0, b:Int = 0)\r\n\tSetClsColor(r, g, b)\r\n\tCls\r\nEndFunction\r\n\r\nType gxtkSurface\r\n\tField w:Int, h:Int\r\n\tField image:TImage\r\n\t\r\n\tMethod setImage(image:TImage)\r\n\t\tSelf.image = image\r\n\tEndMethod\r\n\t\r\n\tMethod Width:Int()\r\n\t\tReturn image.Width\r\n\tEndMethod\r\n\t\r\n\tMethod Height:Int()\r\n\t\tReturn image.Height\r\n\tEndMethod\r\n\t\r\n\tMethod Discard()\r\n\tEndMethod\r\nEndType\r\n\r\n' ***** End mojo.bmax.bmx ******\r\n\r\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"06ae80075879070787b4b5a7d8b692e2ffc1f3f6","subject":"[variables] (v0.24) \tRemoved silly debuglog","message":"[variables] (v0.24)\n\tRemoved silly debuglog\n","repos":"komiga\/duct-max,komiga\/duct-max,komiga\/duct-max","old_file":"variables.mod\/variables.bmx","new_file":"variables.mod\/variables.bmx","new_contents":"\nRem\nCopyright (c) 2010 Tim Howard\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and\/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\nEnd Rem\n\nSuperStrict\n\nRem\nbbdoc: Variables module\nEnd Rem\nModule duct.variables\n\nModuleInfo \"Version: 0.24\"\nModuleInfo \"Copyright: Tim Howard\"\nModuleInfo \"License: MIT\"\n\nModuleInfo \"History: Version 0.24\"\nModuleInfo \"History: Removed silly debuglog\"\nModuleInfo \"History: Version 0.23\"\nModuleInfo \"History: dIdentifier now uses TListEx\"\nModuleInfo \"History: Version 0.22\"\nModuleInfo \"History: Fixed documentation, license\"\nModuleInfo \"History: Renamed TVariable to dVariable\"\nModuleInfo \"History: Renamed TIntVariable to dIntVariable\"\nModuleInfo \"History: Renamed TStringVariable to dStringVariable\"\nModuleInfo \"History: Renamed TFloatVariable to dFloatVariable\"\nModuleInfo \"History: Renamed TEvalVariable to dEvalVariable\"\nModuleInfo \"History: Renamed TIdentifier to dIdentifier\"\nModuleInfo \"History: Renamed TBoolVariable to dBoolVariable\"\nModuleInfo \"History: Version 0.21\"\nModuleInfo \"History: Corrected TVariable.RawToVariable parsing for eval variables; added allowevalvars option\"\nModuleInfo \"History: Version 0.20\"\nModuleInfo \"History: Added TBoolVariable support in TVariable.DeserializeUniversal\"\nModuleInfo \"History: Added TBoolVariable support in TVariable.RawToVariable\"\nModuleInfo \"History: Fixed an issue with eval variables in TVariable.RawToVariable\"\nModuleInfo \"History: Corrected some method names and some documentation.\"\nModuleInfo \"History: Version 0.19\"\nModuleInfo \"History: Added TBoolVariable; documentation correction\"\nModuleInfo \"History: Version 0.18\"\nModuleInfo \"History: TIdentifier.AddValue now sets the variable's parent to itself\"\nModuleInfo \"History: Added SetParent and GetParent to TVaraible\"\nModuleInfo \"History: Version 0.17\"\nModuleInfo \"History: General cleanup\"\nModuleInfo \"History: Version 0.16\"\nModuleInfo \"History: Added SetAmbiguous to all TVariable types\"\nModuleInfo \"History: Added option to always use quoting with TStringVariables (on by default)\"\nModuleInfo \"History: Fixed TStringVariable.ConvToString returning of Null strings\"\nModuleInfo \"History: Version 0.15\"\nModuleInfo \"History: Change the Create method definition for easier use\"\nModuleInfo \"History: Changed the '\/eval::' recognizer to '\/e:' (as per SNode format change)\"\nModuleInfo \"History: Added the Copy method to every variable type\"\nModuleInfo \"History: Changed some formatting\"\nModuleInfo \"History: Version 0.14\"\nModuleInfo \"History: Changed type tabbing\"\nModuleInfo \"History: Fixed script output for TStringVariable (quotes are now only added if whitespace is present)\"\nModuleInfo \"History: Fixed script output for TIdentifier (identifier names can now contain whitespace, in which case they must be quoted)\"\nModuleInfo \"History: Version 0.13\"\nModuleInfo \"History: Added the DeserializeUniversal function to TVariable\"\nModuleInfo \"History: Added Serialize and Deserialize methods to all variable types\"\nModuleInfo \"History: Version 0.12\"\nModuleInfo \"History: Changed module name from 'variablemap' to 'variables'\"\nModuleInfo \"History: Moved all of duct.utilparser here\"\nModuleInfo \"History: Added the GetTVType function to all variable types\"\nModuleInfo \"History: Moved TV_* constants from duct.template here\"\nModuleInfo \"History: Version 0.11\"\nModuleInfo \"History: Added the ReportType function to all variable types\"\nModuleInfo \"History: Version 0.10\"\nModuleInfo \"History: Added the RawToVariable function to TVariable\"\nModuleInfo \"History: General code cleanup\"\nModuleInfo \"History: Version 0.09\"\nModuleInfo \"History: Corrected usage of syntax (in Returns, Cases, News and Selects)\"\nModuleInfo \"History: Version 0.08\"\nModuleInfo \"History: Added the TEvalVariable type\"\nModuleInfo \"History: Initial release\"\n\nImport brl.stream\n\nImport duct.etc\nImport duct.objectmap\n\nRem\n\tbbdoc: Template variable type for the #dIntVariable type.\nEnd Rem\nConst TV_INTEGER:Int = 1\nRem\n\tbbdoc: Template variable type for the #dStringVariable type.\nEnd Rem\nConst TV_STRING:Int = 2\nRem\n\tbbdoc: Template variable type for the #dFloatVariable type.\nEnd Rem\nConst TV_FLOAT:Int = 3\nRem\n\tbbdoc: Template variable type for the #dEvalVariable type.\nEnd Rem\nConst TV_EVAL:Int = 4\nRem\n\tbbdoc: Template variable type for the #dIdentifier type.\nEnd Rem\nConst TV_IDEN:Int = 5\nRem\n\tbbdoc: Template variable type for the #dBoolVariable type.\nEnd Rem\nConst TV_BOOL:Int = 6\n\nRem\n\tbbdoc: duct generic variable.\n\tabout: This is the base variable type, you should extend from this to use it.\nEnd Rem\nType dVariable Abstract\n\t\n\tField m_name:String\n\tField m_parent:dVariable\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the variable's name.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetName(name:String)\n\t\tm_name = name\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the variable's name.\n\t\treturns: The variable's name.\n\tEnd Rem\n\tMethod GetName:String()\n\t\tReturn m_name\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the variable's parent.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetParent(parent:dVariable)\n\t\tm_parent = parent\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the variable's parent.\n\t\treturns: The variable's parent.\n\tEnd Rem\n\tMethod GetParent:dVariable()\n\t\tReturn m_parent\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Base method for setting the value of the variable to the given string (conversion).\n\tEnd Rem\n\tMethod SetAmbiguous(value:String) Abstract\n\t\n\tRem\n\t\tbbdoc: Base method for converting variable data to a script-ready string.\n\tEnd Rem\n\tMethod ConvToString:String() Abstract\n\t\n\tRem\n\t\tbbdoc: Base method for converting variable data to a printable\/usable-in-code string.\n\tEnd Rem\n\tMethod ValueAsString:String() Abstract\n\t\n'#end region (Field accessors)\n\t\n'#region Data handling\n\t\n\tRem\n\t\tbbdoc: Create a copy of the variable.\n\t\treturns: A clone of the variable.\n\tEnd Rem\n\tMethod Copy:dVariable() Abstract\n\t\n\tRem\n\t\tbbdoc: Serialize the variable to a stream.\n\t\treturns: Nothing.\n\t\tabout: @tv tells the method whether it should serialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod Serialize(stream:TStream, tv:Int = True, name:Int = False) Abstract\n\t\n\tRem\n\t\tbbdoc: Deserialize the variable from a stream.\n\t\treturns: The deserialized variable.\n\t\tabout: @tv tells the method whether it should deserialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod Deserialize:dVariable(stream:TStream, tv:Int = True, name:Int = False) Abstract\n\t\n'#end region (Data handling)\n\t\n\tRem\n\t\tbbdoc: Base method: Get the type of this variable.\n\tEnd Rem\n\tFunction ReportType:String() Abstract\n\t\n\tRem\n\t\tbbdoc: Base method: Get the TV_* type of this variable.\n\tEnd Rem\n\tFunction GetTVType:Int() Abstract\n\t\n\tRem\n\t\tbbdoc: Convert raw data (raw data being things like: \"\/e:(a+b\/0.4181)*a-b\" - a dEvalVariable, \"A String variable\", 3452134 - a dIntVariable, 1204.00321 - a variable) into a Variable.\n\t\treturns: A new Variable, or Null if something whacky occured.\n\t\tabout: @etype is optional, it is used to go automagically to one type of a Variable (1 & 4=String (will check for '\/e:' - dEvalVariables and dBoolVariables ['true' or 'false']), 2=Integer, 3=Float).\n\t\t@varname is also an optional parameter. It will be used as the name of the variable.\n\t\tIf @allowevalvars (defaults to False) is True, eval variables will be checked for.\n\tEnd Rem\n\tFunction RawToVariable:dVariable(vraw:String, etype:Int = 0, varname:String = \"\", allowevalvars:Int = False)\n\t\tLocal variable:dVariable\n\t\tIf vraw = Null\n\t\t\t'DebugLog(\"(dVariable.RawToVariable) @vraw = Null; returning a dStringVariable (with @varname and Null value)\")\n\t\t\tReturn New dStringVariable.Create(varname, Null)\n\t\tEnd If\n\t\tIf etype = 0 ' Determine the value's type (must be either integer, double, or a string with no spaces)\n\t\t\t' ASCII '0' to '9' = 48-57; '-' = 45, '+' = 43; and '.' = 46\n\t\t\tFor Local i:Int = 0 To vraw.Length - 1\n\t\t\t\tLocal c:Int = vraw[i]\n\t\t\t\tIf c >= 48 And c <= 57 Or c = 43 Or c = 45\n\t\t\t\t\tIf etype = 0 ' Leave float and string alone\n\t\t\t\t\t\tetype = 2 ' Integer so far..\n\t\t\t\t\tEnd If\n\t\t\t\tElse If c = 46\n\t\t\t\t\tIf etype = 2 ' Already declared as an integer?\n\t\t\t\t\t\tetype = 3\n\t\t\t\t\tEnd If\n\t\t\t\tElse ' If the character is not numerical there is nothing else to deduce and the value is a string\n\t\t\t\t\tetype = 4\n\t\t\t\t\tExit\n\t\t\t\tEnd If\n\t\t\tNext\n\t\tEnd If\n\t\t\n\t\tSelect etype\n\t\t\tCase 2 ' Integer\n\t\t\t\tvariable = dVariable(New dIntVariable.Create(varname, Int(vraw)))\n\t\t\tCase 3 ' Double\/Float\n\t\t\t\tvariable = dVariable(New dFloatVariable.Create(varname, Float(vraw)))\n\t\t\tCase 1, 4\n\t\t\t\tLocal vrawlower:String = vraw.ToLower()\n\t\t\t\tIf vrawlower.StartsWith(\"\/e:\") = True and allowevalvars = True\n\t\t\t\t\tvariable = dVariable(New dEvalVariable.Create(varname, vraw[2..]))\n\t\t\t\tElse If vrawlower = \"true\" Or vrawlower = \"false\"\n\t\t\t\t\tvariable = New dBoolVariable.Create(varname, (vrawlower = \"true\") And True Or False)\n\t\t\t\tElse\n\t\t\t\t\tvariable = dVariable(New dStringVariable.Create(varname, vraw))\n\t\t\t\tEnd If\n\t\tEnd Select\n\t\t'DebugLog(\"TSNode.LoadScriptFromStream().RawToVariable(); vraw = ~q\" + vraw + \"~q \\\" + etype)\n\t\t?Debug\n\t\tIf variable = Null Then DebugLog(\"(dVariable.RawToVariable) Unknown error, 'variable' is Null.\")\n\t\t?\n\t\tReturn variable\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Universally deserialize a variable from the given stream.\n\t\treturns: A Deserialized variable.\n\t\tabout: This will deserialize any variable from the stream.\n\t\tThis requires the variable to have been serialized with the template type (see #Serialize parameters).\n\t\t@name tells the further Deserialize calls if the name should be Deserialized or not.\n\tEnd Rem\n\tFunction DeserializeUniversal:dVariable(stream:TStream, name:Int = False)\n\t\tLocal tv:Int = Int(stream.ReadByte())\n\t\tSelect tv\n\t\t\tCase TV_INTEGER\n\t\t\t\tReturn New dIntVariable.Deserialize(stream, True, name)\n\t\t\tCase TV_STRING\n\t\t\t\tReturn New dStringVariable.Deserialize(stream, True, name)\n\t\t\tCase TV_FLOAT\n\t\t\t\tReturn New dFloatVariable.Deserialize(stream, True, name)\n\t\t\tCase TV_EVAL\n\t\t\t\tReturn New dEvalVariable.Deserialize(stream, True, name)\n\t\t\tCase TV_IDEN\n\t\t\t\tReturn New dIdentifier.Deserialize(stream, True, name)\n\t\t\tCase TV_BOOL\n\t\t\t\tReturn New dBoolVariable.Deserialize(stream, True, name)\n\t\t\tDefault\n\t\t\t\tDebugLog(\"(dVariable.DeserializeUniversal) Failed to recognize the TV in the stream: \" + tv)\n\t\tEnd Select\n\t\tReturn Null\n\tEnd Function\n\t\nEnd Type\n\nRem\n\tbbdoc: duct string variable.\nEnd Rem\nType dStringVariable Extends dVariable\n\t\n\tGlobal m_alwaysusequotes:Int = True\n\t\n\tField m_value:String\n\t\n\tRem\n\t\tbbdoc: Create a new String variable.\n\t\treturns: Itself.\n\tEnd Rem\n\tMethod Create:dStringVariable(name:String = Null, value:String)\n\t\tSetName(name)\n\t\tSet(value)\n\t\tReturn Self\n\tEnd Method\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the variable's value.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod Set(value:String)\n\t\tm_value = value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the variable's value.\n\t\treturns: The value of the variable.\n\tEnd Rem\n\tMethod Get:String()\n\t\tReturn m_value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the value of the variable to the given string (ambiguous).\n\t\treturns: Nothing.\n\t\tabout: For this type, this method is no different than calling #Set.\n\tEnd Rem\n\tMethod SetAmbiguous(value:String)\n\t\tm_value = value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Convert the variable to a String.\n\t\treturns: A String representation of the variable.\n\t\tabout: This function is for script output, for in-code use see #ValueAsString.\n\tEnd Rem\n\tMethod ConvToString:String()\n\t\tIf m_alwaysusequotes = True Or m_value.Contains(\"~t\") Or m_value.Contains(\" \") Or m_value = Null\n\t\t\tReturn \"~q\" + m_value + \"~q\"\n\t\tElse\n\t\t\tReturn m_value\n\t\tEnd If\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the variable as a String.\n\t\treturns: The variable's value converted to a String.\n\t\tabout: Here for complete-ness, no difference to `instance.Get()`.\n\tEnd Rem\n\tMethod ValueAsString:String()\n\t\tReturn m_value\n\tEnd Method\n\t\n'#end region (Field accessors)\n\t\n'#region Data handling\n\t\n\tRem\n\t\tbbdoc: Create a copy of the variable\n\t\treturns: A clone of the variable.\n\tEnd Rem\n\tMethod Copy:dStringVariable()\n\t\tReturn New dStringVariable.Create(m_name, m_value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Serialize the variable to a stream.\n\t\treturns: Nothing.\n\t\tabout: @tv tells the method whether it should serialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod Serialize(stream:TStream, tv:Int = True, name:Int = False)\n\t\tIf tv = True Then stream.WriteByte(TV_STRING)\n\t\tIf name = True Then WriteLString(stream, m_name)\n\t\tWriteLString(stream, m_value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Deserialize the variable from a stream.\n\t\treturns: Itself.\n\t\tabout: @tv tells the method whether it should deserialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod Deserialize:dStringVariable(stream:TStream, tv:Int = True, name:Int = False)\n\t\tIf tv = True Then stream.ReadByte()\n\t\tIf name = True Then m_name = ReadLString(stream)\n\t\tm_value = ReadLString(stream)\n\t\tReturn Self\n\tEnd Method\n\t\n'#end region (Data handling)\n\t\n\tRem\n\t\tbbdoc: Get the type of this variable.\n\t\treturns: The type of this variable (\"string\").\n\tEnd Rem\n\tFunction ReportType:String()\n\t\tReturn \"string\"\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Get the TV type of this variable.\n\t\treturns: The TV_* type of this variable (TV_STRING).\n\tEnd Rem\n\tFunction GetTVType:Int()\n\t\tReturn TV_STRING\n\tEnd Function\n\t\nEnd Type\n\nRem\n\tbbdoc: duct Float variable.\nEnd Rem\nType dFloatVariable Extends dVariable\n\t\n\tField m_value:Float\n\t\n\tRem\n\t\tbbdoc: Create a new Float variable.\n\t\treturns: Itself.\n\tEnd Rem\n\tMethod Create:dFloatVariable(name:String = Null, value:Float)\n\t\tSetName(name)\n\t\tSet(value)\n\t\tReturn Self\n\tEnd Method\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the variable's value.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod Set(value:Float)\n\t\tm_value = value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the variable's value.\n\t\treturns: The value of the variable.\n\tEnd Rem\n\tMethod Get:Float()\n\t\tReturn m_value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the value of the variable to the given string (ambiguous).\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetAmbiguous(value:String)\n\t\tm_value = Float(value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Convert the variable to a String.\n\t\treturns: A scriptable form of the variable.\n\t\tabout: This function is for script output, for in-code use see #ValueAsString.\n\tEnd Rem\n\tMethod ConvToString:String()\n\t\tLocal conv:String = String(m_value), encountered:Int\n\t\tFor Local i:Int = conv.Find(\".\") To conv.Length - 1\n\t\t\tIf conv[i] = 48\n\t\t\t\tIf encountered = True\n\t\t\t\t\tconv = conv[..i]\n\t\t\t\t\tExit\n\t\t\t\tEnd If\n\t\t\tElse If conv[i] <> 46\n\t\t\t\tencountered = True\n\t\t\tEnd If\n\t\tNext\n\t\tReturn conv\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the variable as a String.\n\t\treturns: The variable's value converted to a String.\n\tEnd Rem\n\tMethod ValueAsString:String()\n\t\tReturn String(m_value)\n\tEnd Method\n\t\n'#end region (Field accessors)\n\t\n'#region Data handling\n\t\n\tRem\n\t\tbbdoc: Create a copy of the variable\n\t\treturns: A clone of the variable.\n\tEnd Rem\n\tMethod Copy:dFloatVariable()\n\t\tReturn New dFloatVariable.Create(m_name, m_value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Serialize the variable to a stream.\n\t\treturns: Nothing.\n\t\tabout: @tv tells the method whether it should serialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod Serialize(stream:TStream, tv:Int = True, name:Int = False)\n\t\tIf tv = True Then stream.WriteByte(TV_FLOAT)\n\t\tIf name = True Then WriteLString(stream, m_name)\n\t\tstream.WriteFloat(m_value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Deserialize the variable from a stream.\n\t\treturns: Itself.\n\t\tabout: @tv tells the method whether it should deserialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod Deserialize:dFloatVariable(stream:TStream, tv:Int = True, name:Int = False)\n\t\tIf tv = True Then stream.ReadByte()\n\t\tIf name = True Then m_name = ReadLString(stream)\n\t\tm_value = stream.ReadFloat()\n\t\tReturn Self\n\tEnd Method\n\t\n'#end region (Data handling)\n\t\n\tRem\n\t\tbbdoc: Get the type of this variable.\n\t\treturns: The type of this variable (\"float\").\n\tEnd Rem\n\tFunction ReportType:String()\n\t\tReturn \"float\"\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Get the TV type of this variable.\n\t\treturns: The TV_* type of this variable (TV_FLOAT).\n\tEnd Rem\n\tFunction GetTVType:Int()\n\t\tReturn TV_FLOAT\n\tEnd Function\n\t\nEnd Type\n\nRem\n\tbbdoc: duct Int variable.\nEnd Rem\nType dIntVariable Extends dVariable\n\t\n\tField m_value:Int\n\t\n\tRem\n\t\tbbdoc: Create a new Int variable.\n\t\treturns: Itself.\n\tEnd Rem\n\tMethod Create:dIntVariable(name:String = Null, value:Int)\n\t\tSetName(name)\n\t\tSet(value)\n\t\tReturn Self\n\tEnd Method\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the variable's value.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod Set(value:Int)\n\t\tm_value = value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the variable's value.\n\t\treturns: The value of the variable.\n\tEnd Rem\n\tMethod Get:Int()\n\t\tReturn m_value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the value of the variable to the given string (ambiguous).\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetAmbiguous(value:String)\n\t\tm_value = Int(value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Convert the variable to a String.\n\t\treturns: A string representation of the variable.\n\t\tabout: This function is for script output, for in-code use see #ValueAsString.\n\tEnd Rem\n\tMethod ConvToString:String()\n\t\tReturn String(m_value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the variable as a String.\n\t\treturns: The variable's value converted to a String.\n\tEnd Rem\n\tMethod ValueAsString:String()\n\t\tReturn String(m_value)\n\tEnd Method\n\t\n'#end region (Field accessors)\n\t\n'#region Data handling\n\t\n\tRem\n\t\tbbdoc: Create a copy of the variable\n\t\treturns: A clone of the variable.\n\tEnd Rem\n\tMethod Copy:dIntVariable()\n\t\tReturn New dIntVariable.Create(m_name, m_value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Serialize the variable to a stream.\n\t\treturns: Nothing.\n\t\tabout: @tv tells the method whether it should serialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod Serialize(stream:TStream, tv:Int = True, name:Int = False)\n\t\tIf tv = True Then stream.WriteByte(TV_INTEGER)\n\t\tIf name = True Then WriteLString(stream, m_name)\n\t\tstream.WriteInt(m_value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Deserialize the variable from a stream.\n\t\treturns: Itself.\n\t\tabout: @tv tells the method whether it should deserialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod Deserialize:dIntVariable(stream:TStream, tv:Int = True, name:Int = False)\n\t\tIf tv = True Then stream.ReadByte()\n\t\tIf name = True Then m_name = ReadLString(stream)\n\t\tm_value = stream.ReadInt()\n\t\tReturn Self\n\tEnd Method\n\t\n'#end region (Data handling)\n\t\n\tRem\n\t\tbbdoc: Get the type of this variable.\n\t\treturns: The type of this variable (\"int\").\n\tEnd Rem\n\tFunction ReportType:String()\n\t\tReturn \"int\"\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Get the TV type of this variable.\n\t\treturns: The TV_* type of this variable (TV_INTEGER).\n\tEnd Rem\n\tFunction GetTVType:Int()\n\t\tReturn TV_INTEGER\n\tEnd Function\n\t\nEnd Type\n\nRem\n\tbbdoc: duct eval variable (for bah.muparser, and the likes).\nEnd Rem\nType dEvalVariable Extends dVariable\n\t\n\tField m_value:String\n\t\n\tRem\n\t\tbbdoc: Create a new eval variable.\n\t\treturns: Itself.\n\tEnd Rem\n\tMethod Create:dEvalVariable(name:String = Null, value:String)\n\t\tSetName(name)\n\t\tSet(value)\n\t\tReturn Self\n\tEnd Method\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the equation string for the variable.\n\t\treturns: Nothing\n\tEnd Rem\n\tMethod Set(value:String)\n\t\tm_value = value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the equation string.\n\t\treturns: The equation string.\n\tEnd Rem\n\tMethod Get:String()\n\t\tReturn m_value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the value of the variable to the given string (ambiguous).\n\t\treturns: Nothing.\n\t\tabout: For this type, this method is no different than calling #Set.\n\tEnd Rem\n\tMethod SetAmbiguous(value:String)\n\t\tm_value = value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Convert the variable to a visual representation of its data.\n\t\treturns: The scriptable form of the variable.\n\t\tabout: This function is for script output, for in-code use see #ValueAsString.\n\tEnd Rem\n\tMethod ConvToString:String()\n\t\tReturn \"~q\/e:\" + m_value + \"~q\"\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the variable as a String.\n\t\treturns: The variable's value converted to a String.\n\tEnd Rem\n\tMethod ValueAsString:String()\n\t\tReturn m_value\n\tEnd Method\n\t\n'#end region (Field accessors)\n\t\n'#region Data handling\n\t\n\tRem\n\t\tbbdoc: Create a copy of the variable\n\t\treturns: A clone of the variable.\n\tEnd Rem\n\tMethod Copy:dEvalVariable()\n\t\tReturn New dEvalVariable.Create(m_name, m_value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Serialize the variable to a stream.\n\t\treturns: Nothing.\n\t\tabout: @tv tells the method whether it should serialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod Serialize(stream:TStream, tv:Int = True, name:Int = False)\n\t\tIf tv = True Then stream.WriteByte(TV_EVAL)\n\t\tIf name = True Then WriteLString(stream, m_name)\n\t\tWriteLString(stream, m_value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Deserialize the variable from a stream.\n\t\treturns: Itself.\n\t\tabout: @tv tells the method whether it should deserialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod Deserialize:dEvalVariable(stream:TStream, tv:Int = True, name:Int = False)\n\t\tIf tv = True Then stream.ReadByte()\n\t\tIf name = True Then m_name = ReadLString(stream)\n\t\tm_value = ReadLString(stream)\n\t\tReturn Self\n\tEnd Method\n\t\n'#end region (Data handling)\n\t\n\tRem\n\t\tbbdoc: Get the type of this variable.\n\t\treturns: The type of this variable (\"eval\").\n\tEnd Rem\n\tFunction ReportType:String()\n\t\tReturn \"eval\"\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Get the TV type of this variable.\n\t\treturns: The TV_* type of this variable (TV_EVAL).\n\tEnd Rem\n\tFunction GetTVType:Int()\n\t\tReturn TV_EVAL\n\tEnd Function\n\t\nEnd Type\n\nRem\n\tbbdoc: duct boolean variable.\nEnd Rem\nType dBoolVariable Extends dVariable\n\t\n\tField m_value:Int\n\t\n\tRem\n\t\tbbdoc: Create a new boolean variable.\n\t\treturns: Itself.\n\tEnd Rem\n\tMethod Create:dBoolVariable(name:String = Null, value:Int)\n\t\tSetName(name)\n\t\tSet(value)\n\t\tReturn Self\n\tEnd Method\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the variable's value.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod Set(value:Int)\n\t\tm_value = value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the variable's value.\n\t\treturns: The value of the variable.\n\tEnd Rem\n\tMethod Get:Int()\n\t\tReturn m_value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the value of the variable to the given string (ambiguous).\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetAmbiguous(value:String)\n\t\tm_value = Int(value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Convert the variable to a String.\n\t\treturns: A string representation of the variable.\n\t\tabout: This function is for script output, for in-code use see #ValueAsString.\n\tEnd Rem\n\tMethod ConvToString:String()\n\t\tReturn String(m_value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the dBoolVariable as a String.\n\t\treturns: The variable's value converted to a String.\n\tEnd Rem\n\tMethod ValueAsString:String()\n\t\tReturn String(m_value)\n\tEnd Method\n\t\n'#end region (Field accessors)\n\t\n'#region Data handling\n\t\n\tRem\n\t\tbbdoc: Create a copy of the variable\n\t\treturns: A clone of the variable.\n\tEnd Rem\n\tMethod Copy:dBoolVariable()\n\t\tReturn New dBoolVariable.Create(m_name, m_value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Serialize the variable to a stream.\n\t\treturns: Nothing.\n\t\tabout: @tv tells the method whether it should serialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod Serialize(stream:TStream, tv:Int = True, name:Int = False)\n\t\tIf tv = True Then stream.WriteByte(TV_BOOL)\n\t\tIf name = True Then WriteLString(stream, m_name)\n\t\tstream.WriteByte(Byte(m_value))\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Deserialize the variable from a stream.\n\t\treturns: The deserialized variable.\n\t\tabout: @tv tells the method whether it should deserialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod Deserialize:dBoolVariable(stream:TStream, tv:Int = True, name:Int = False)\n\t\tIf tv = True Then stream.ReadByte()\n\t\tIf name = True Then m_name = ReadLString(stream)\n\t\tm_value = Int(stream.ReadByte())\n\t\tReturn Self\n\tEnd Method\n\t\n'#end region (Data handling)\n\t\n\tRem\n\t\tbbdoc: Get the type of this variable.\n\t\treturns: The type of this variable (\"bool\").\n\tEnd Rem\n\tFunction ReportType:String()\n\t\tReturn \"bool\"\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Get the TV type of this variable.\n\t\treturns: The TV_* type of this variable (TV_BOOL).\n\tEnd Rem\n\tFunction GetTVType:Int()\n\t\tReturn TV_BOOL\n\tEnd Function\n\t\nEnd Type\n\nRem\n\tbbdoc: duct identifier (used in parsers, mostly).\nEnd Rem\nType dIdentifier Extends dVariable\n\t\n\tField m_values:TListEx\n\t\n\tMethod New()\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Create a new identifier.\n\t\treturns: Itself.\n\tEnd Rem\n\tMethod Create:dIdentifier()\n\t\tm_values = New TListEx\n\t\tReturn Self\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Create a new identifier with the given data.\n\t\treturns: Itself.\n\t\tabout: If the @values parameter is Null a new list will be created.\n\tEnd Rem\n\tMethod CreateByData:dIdentifier(name:String, values:TListEx = Null)\n\t\tSetName(name)\n\t\tIf values = Null\n\t\t\tm_values = New TListEx\n\t\tElse\n\t\t\tm_values = values\n\t\tEnd If\n\t\tReturn Self\n\tEnd Method\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the identifier's values.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetValues(values:TListEx)\n\t\tm_values = values\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the identifier's values.\n\t\treturns: A list containing the values which the identifier holds.\n\tEnd Rem\n\tMethod GetValues:TListEx()\n\t\tReturn m_values\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Deprecated for this type.\n\t\treturns: Nothing.\n\t\tabout: This does nothing.\n\tEnd Rem\n\tMethod SetAmbiguous(value:String)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Convert the identifier to a string.\n\t\treturns: A string representation of the identifier.\n\tEnd Rem\n\tMethod ConvToString:String()\n\t\tLocal op:String\n\t\tIf m_name.Contains(\"~t\") = True Or m_name.Contains(\" \") = True\n\t\t\top = \"~q\" + m_name + \"~q \"\n\t\tElse\n\t\t\top = m_name + \" \"\n\t\tEnd If\n\t\tFor Local variable:dVariable = EachIn m_values\n\t\t\top:+variable.ConvToString() + \" \"\n\t\tNext\n\t\top = op[..op.Length - 1]\n\t\tReturn op\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the identifier as a string.\n\t\treturns: The identifier contents converted to a string.\n\t\tabout: Here for complete-ness, simply calls #ConvToString.\n\tEnd Rem\n\tMethod ValueAsString:String()\n\t\tReturn ConvToString()\n\tEnd Method\n\t\n'#end region (Field accessors)\n\t\n'#region Value handling\n\t\n\tRem\n\t\tbbdoc: Get a value at an index.\n\t\treturns: The value in the identifier's list at the given index, or Null if it could not be retrieved.\n\t\tabout: The index is zero-based.\n\tEnd Rem\n\tMethod GetValueAtIndex:dVariable(index:Int)\n\t\tIf m_values <> Null And index > - 1 And index < m_values.Count()\n\t\t\tReturn dVariable(m_values.ValueAtIndex(index))\n\t\tEnd If\n\t\tReturn Null\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the number of values.\n\t\treturns: The number of values the identifier contains.\n\tEnd Rem\n\tMethod GetValueCount:Int()\n\t\tIf m_values <> Null\n\t\t\tReturn m_values.Count()\n\t\tEnd If\n\t\tReturn 0\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Add a value to the identifier.\n\t\treturns: True for success, or False for failure.\n\t\tabout: NOTE: This will set the given value's parent.\n\tEnd Rem\n\tMethod AddValue:Int(value:dVariable)\n\t\tIf m_values <> Null And value <> Null\n\t\t\tm_values.AddLast(value)\n\t\t\tvalue.SetParent(Self)\n\t\t\tReturn True\n\t\tEnd If\n\t\tReturn False\n\tEnd Method\n\t\n'#end region (Value handling)\n\t\n'#region Data handling\n\t\n\tRem\n\t\tbbdoc: Create a copy of the identifier\n\t\treturns: A clone of the identifier.\n\tEnd Rem\n\tMethod Copy:dIdentifier()\n\t\tLocal clone:dIdentifier\n\t\tclone = New dIdentifier.CreateByData(m_name)\n\t\tFor Local variable:dVariable = EachIn m_values\n\t\t\tclone.AddValue(variable.Copy())\n\t\tNext\n\t\tReturn clone\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Serialize the variable to a stream.\n\t\treturns: Nothing.\n\t\tabout: @tv tells the method whether it should serialize the TV type for the variable, or to not.\n\t\tIn this case @name tells the method whether it should serialize the values<\/b><\/i>' name (the identifier's name is always read\/written to the stream).\n\tEnd Rem\n\tMethod Serialize(stream:TStream, tv:Int = True, name:Int = False)\n\t\tLocal variable:dVariable\n\t\tIf tv = True Then stream.WriteByte(TV_STRING)\n\t\tWriteLString(stream, m_name)\n\t\tIf m_values = Null\n\t\t\tstream.WriteInt(0)\n\t\tElse\n\t\t\tstream.WriteInt(m_values.Count())\n\t\t\tFor variable = EachIn m_values\n\t\t\t\tvariable.Serialize(stream, True, name)\n\t\t\tNext\n\t\tEnd If\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Deserialize the variable from a stream.\n\t\treturns: The deserialized variable.\n\t\tabout: @tv tells the method whether it should deserialize the TV type for the variable, or to not.\n\t\tIn this case @name tells the method whether it should deserialize the values<\/b><\/i>' name (the identifier's name is always read\/written to the stream).\n\tEnd Rem\n\tMethod Deserialize:dIdentifier(stream:TStream, tv:Int = True, name:Int = False)\n\t\tLocal count:Int, n:Int\n\t\tIf tv = True Then stream.ReadByte()\n\t\tm_name = ReadLString(stream)\n\t\tcount = stream.ReadInt()\n\t\tIf count > 0\n\t\t\tFor n = 0 To count - 1\n\t\t\t\tDeserializeUniversal(stream, name)\n\t\t\tNext\n\t\tEnd If\n\t\tReturn Self\n\tEnd Method\n\t\n'#end region (Data handling)\n\t\n\tRem\n\t\tbbdoc: Get the type of this variable.\n\t\treturns: The type of this variable (\"identifier\").\n\tEnd Rem\n\tFunction ReportType:String()\n\t\tReturn \"identifier\"\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Get the TV type of this variable.\n\t\treturns: The TV_* type of this variable (TV_IDEN).\n\tEnd Rem\n\tFunction GetTVType:Int()\n\t\tReturn TV_IDEN\n\tEnd Function\n\t\nEnd Type\n\nRem\n\tbbdoc: #dVariable map (stores any variable).\nEndRem\nType dVariableMap Extends dObjectMap\n\t\n\tRem\n\t\tbbdoc: Create a new variable map.\n\t\treturns: Itself.\n\tEnd Rem\n\tMethod Create:dVariableMap()\n\t\tReturn Self\n\tEnd Method\n\t\n'#region Collections\n\t\n\tRem\n\t\tbbdoc: Insert a variable into the map.\n\t\treturns: True if the variable was added, or False if it was not (the variable's name is Null).\n\tEnd Rem\n\tMethod InsertVariable:Int(variable:dVariable)\n\t\tIf variable.GetName() <> Null\n\t\t\t_Insert(variable.GetName(), variable)\n\t\t\tReturn True\n\t\tEnd If\n\t\tReturn False\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Remove a variable by the name given.\n\t\treturns: True if a variable was removed, or False if it was not (the map contains no variable with the name given).\n\t\tabout: The name is<\/b> case-sensitive.\n\tEnd Rem\n\tMethod RemoveVariableByName:Int(name:String)\n\t\tReturn _Remove(name)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get a variable from the map by its name.\n\t\treturns: The variable object, or if the variable was not found, Null.\n\t\tabout: The name is<\/b> case-sensitive.\n\tEnd Rem\n\tMethod GetVariableByName:dVariable(name:String)\n\t\tReturn dVariable(_ValueByKey(name))\n\tEnd Method\n\t\n'#end region (Collections)\n\t\nEnd Type\n\n","old_contents":"\nRem\nCopyright (c) 2010 Tim Howard\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and\/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\nEnd Rem\n\nSuperStrict\n\nRem\nbbdoc: Variables module\nEnd Rem\nModule duct.variables\n\nModuleInfo \"Version: 0.23\"\nModuleInfo \"Copyright: Tim Howard\"\nModuleInfo \"License: MIT\"\n\nModuleInfo \"History: Version 0.23\"\nModuleInfo \"History: dIdentifier now uses TListEx\"\nModuleInfo \"History: Version 0.22\"\nModuleInfo \"History: Fixed documentation, license\"\nModuleInfo \"History: Renamed TVariable to dVariable\"\nModuleInfo \"History: Renamed TIntVariable to dIntVariable\"\nModuleInfo \"History: Renamed TStringVariable to dStringVariable\"\nModuleInfo \"History: Renamed TFloatVariable to dFloatVariable\"\nModuleInfo \"History: Renamed TEvalVariable to dEvalVariable\"\nModuleInfo \"History: Renamed TIdentifier to dIdentifier\"\nModuleInfo \"History: Renamed TBoolVariable to dBoolVariable\"\nModuleInfo \"History: Version 0.21\"\nModuleInfo \"History: Corrected TVariable.RawToVariable parsing for eval variables; added allowevalvars option\"\nModuleInfo \"History: Version 0.20\"\nModuleInfo \"History: Added TBoolVariable support in TVariable.DeserializeUniversal\"\nModuleInfo \"History: Added TBoolVariable support in TVariable.RawToVariable\"\nModuleInfo \"History: Fixed an issue with eval variables in TVariable.RawToVariable\"\nModuleInfo \"History: Corrected some method names and some documentation.\"\nModuleInfo \"History: Version 0.19\"\nModuleInfo \"History: Added TBoolVariable; documentation correction\"\nModuleInfo \"History: Version 0.18\"\nModuleInfo \"History: TIdentifier.AddValue now sets the variable's parent to itself\"\nModuleInfo \"History: Added SetParent and GetParent to TVaraible\"\nModuleInfo \"History: Version 0.17\"\nModuleInfo \"History: General cleanup\"\nModuleInfo \"History: Version 0.16\"\nModuleInfo \"History: Added SetAmbiguous to all TVariable types\"\nModuleInfo \"History: Added option to always use quoting with TStringVariables (on by default)\"\nModuleInfo \"History: Fixed TStringVariable.ConvToString returning of Null strings\"\nModuleInfo \"History: Version 0.15\"\nModuleInfo \"History: Change the Create method definition for easier use\"\nModuleInfo \"History: Changed the '\/eval::' recognizer to '\/e:' (as per SNode format change)\"\nModuleInfo \"History: Added the Copy method to every variable type\"\nModuleInfo \"History: Changed some formatting\"\nModuleInfo \"History: Version 0.14\"\nModuleInfo \"History: Changed type tabbing\"\nModuleInfo \"History: Fixed script output for TStringVariable (quotes are now only added if whitespace is present)\"\nModuleInfo \"History: Fixed script output for TIdentifier (identifier names can now contain whitespace, in which case they must be quoted)\"\nModuleInfo \"History: Version 0.13\"\nModuleInfo \"History: Added the DeserializeUniversal function to TVariable\"\nModuleInfo \"History: Added Serialize and Deserialize methods to all variable types\"\nModuleInfo \"History: Version 0.12\"\nModuleInfo \"History: Changed module name from 'variablemap' to 'variables'\"\nModuleInfo \"History: Moved all of duct.utilparser here\"\nModuleInfo \"History: Added the GetTVType function to all variable types\"\nModuleInfo \"History: Moved TV_* constants from duct.template here\"\nModuleInfo \"History: Version 0.11\"\nModuleInfo \"History: Added the ReportType function to all variable types\"\nModuleInfo \"History: Version 0.10\"\nModuleInfo \"History: Added the RawToVariable function to TVariable\"\nModuleInfo \"History: General code cleanup\"\nModuleInfo \"History: Version 0.09\"\nModuleInfo \"History: Corrected usage of syntax (in Returns, Cases, News and Selects)\"\nModuleInfo \"History: Version 0.08\"\nModuleInfo \"History: Added the TEvalVariable type\"\nModuleInfo \"History: Initial release\"\n\nImport brl.stream\n\nImport duct.etc\nImport duct.objectmap\n\nRem\n\tbbdoc: Template variable type for the #dIntVariable type.\nEnd Rem\nConst TV_INTEGER:Int = 1\nRem\n\tbbdoc: Template variable type for the #dStringVariable type.\nEnd Rem\nConst TV_STRING:Int = 2\nRem\n\tbbdoc: Template variable type for the #dFloatVariable type.\nEnd Rem\nConst TV_FLOAT:Int = 3\nRem\n\tbbdoc: Template variable type for the #dEvalVariable type.\nEnd Rem\nConst TV_EVAL:Int = 4\nRem\n\tbbdoc: Template variable type for the #dIdentifier type.\nEnd Rem\nConst TV_IDEN:Int = 5\nRem\n\tbbdoc: Template variable type for the #dBoolVariable type.\nEnd Rem\nConst TV_BOOL:Int = 6\n\nRem\n\tbbdoc: duct generic variable.\n\tabout: This is the base variable type, you should extend from this to use it.\nEnd Rem\nType dVariable Abstract\n\t\n\tField m_name:String\n\tField m_parent:dVariable\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the variable's name.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetName(name:String)\n\t\tm_name = name\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the variable's name.\n\t\treturns: The variable's name.\n\tEnd Rem\n\tMethod GetName:String()\n\t\tReturn m_name\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the variable's parent.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetParent(parent:dVariable)\n\t\tm_parent = parent\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the variable's parent.\n\t\treturns: The variable's parent.\n\tEnd Rem\n\tMethod GetParent:dVariable()\n\t\tReturn m_parent\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Base method for setting the value of the variable to the given string (conversion).\n\tEnd Rem\n\tMethod SetAmbiguous(value:String) Abstract\n\t\n\tRem\n\t\tbbdoc: Base method for converting variable data to a script-ready string.\n\tEnd Rem\n\tMethod ConvToString:String() Abstract\n\t\n\tRem\n\t\tbbdoc: Base method for converting variable data to a printable\/usable-in-code string.\n\tEnd Rem\n\tMethod ValueAsString:String() Abstract\n\t\n'#end region (Field accessors)\n\t\n'#region Data handling\n\t\n\tRem\n\t\tbbdoc: Create a copy of the variable.\n\t\treturns: A clone of the variable.\n\tEnd Rem\n\tMethod Copy:dVariable() Abstract\n\t\n\tRem\n\t\tbbdoc: Serialize the variable to a stream.\n\t\treturns: Nothing.\n\t\tabout: @tv tells the method whether it should serialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod Serialize(stream:TStream, tv:Int = True, name:Int = False) Abstract\n\t\n\tRem\n\t\tbbdoc: Deserialize the variable from a stream.\n\t\treturns: The deserialized variable.\n\t\tabout: @tv tells the method whether it should deserialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod Deserialize:dVariable(stream:TStream, tv:Int = True, name:Int = False) Abstract\n\t\n'#end region (Data handling)\n\t\n\tRem\n\t\tbbdoc: Base method: Get the type of this variable.\n\tEnd Rem\n\tFunction ReportType:String() Abstract\n\t\n\tRem\n\t\tbbdoc: Base method: Get the TV_* type of this variable.\n\tEnd Rem\n\tFunction GetTVType:Int() Abstract\n\t\n\tRem\n\t\tbbdoc: Convert raw data (raw data being things like: \"\/e:(a+b\/0.4181)*a-b\" - a dEvalVariable, \"A String variable\", 3452134 - a dIntVariable, 1204.00321 - a variable) into a Variable.\n\t\treturns: A new Variable, or Null if something whacky occured.\n\t\tabout: @etype is optional, it is used to go automagically to one type of a Variable (1 & 4=String (will check for '\/e:' - dEvalVariables and dBoolVariables ['true' or 'false']), 2=Integer, 3=Float).\n\t\t@varname is also an optional parameter. It will be used as the name of the variable.\n\t\tIf @allowevalvars (defaults to False) is True, eval variables will be checked for.\n\tEnd Rem\n\tFunction RawToVariable:dVariable(vraw:String, etype:Int = 0, varname:String = \"\", allowevalvars:Int = False)\n\t\tLocal variable:dVariable\n\t\tIf vraw = Null\n\t\t\tDebugLog(\"(dVariable.RawToVariable) @vraw = Null; returning a dStringVariable (with @varname and Null value)\")\n\t\t\tReturn New dStringVariable.Create(varname, Null)\n\t\tEnd If\n\t\tIf etype = 0 ' Determine the value's type (must be either integer, double, or a string with no spaces)\n\t\t\t' ASCII '0' to '9' = 48-57; '-' = 45, '+' = 43; and '.' = 46\n\t\t\tFor Local i:Int = 0 To vraw.Length - 1\n\t\t\t\tLocal c:Int = vraw[i]\n\t\t\t\tIf c >= 48 And c <= 57 Or c = 43 Or c = 45\n\t\t\t\t\tIf etype = 0 ' Leave float and string alone\n\t\t\t\t\t\tetype = 2 ' Integer so far..\n\t\t\t\t\tEnd If\n\t\t\t\tElse If c = 46\n\t\t\t\t\tIf etype = 2 ' Already declared as an integer?\n\t\t\t\t\t\tetype = 3\n\t\t\t\t\tEnd If\n\t\t\t\tElse ' If the character is not numerical there is nothing else to deduce and the value is a string\n\t\t\t\t\tetype = 4\n\t\t\t\t\tExit\n\t\t\t\tEnd If\n\t\t\tNext\n\t\tEnd If\n\t\t\n\t\tSelect etype\n\t\t\tCase 2 ' Integer\n\t\t\t\tvariable = dVariable(New dIntVariable.Create(varname, Int(vraw)))\n\t\t\tCase 3 ' Double\/Float\n\t\t\t\tvariable = dVariable(New dFloatVariable.Create(varname, Float(vraw)))\n\t\t\tCase 1, 4\n\t\t\t\tLocal vrawlower:String = vraw.ToLower()\n\t\t\t\tIf vrawlower.StartsWith(\"\/e:\") = True and allowevalvars = True\n\t\t\t\t\tvariable = dVariable(New dEvalVariable.Create(varname, vraw[2..]))\n\t\t\t\tElse If vrawlower = \"true\" Or vrawlower = \"false\"\n\t\t\t\t\tvariable = New dBoolVariable.Create(varname, (vrawlower = \"true\") And True Or False)\n\t\t\t\tElse\n\t\t\t\t\tvariable = dVariable(New dStringVariable.Create(varname, vraw))\n\t\t\t\tEnd If\n\t\tEnd Select\n\t\t'DebugLog(\"TSNode.LoadScriptFromStream().RawToVariable(); vraw = ~q\" + vraw + \"~q \\\" + etype)\n\t\t?Debug\n\t\tIf variable = Null Then DebugLog(\"(dVariable.RawToVariable) Unknown error, 'variable' is Null.\")\n\t\t?\n\t\tReturn variable\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Universally deserialize a variable from the given stream.\n\t\treturns: A Deserialized variable.\n\t\tabout: This will deserialize any variable from the stream.\n\t\tThis requires the variable to have been serialized with the template type (see #Serialize parameters).\n\t\t@name tells the further Deserialize calls if the name should be Deserialized or not.\n\tEnd Rem\n\tFunction DeserializeUniversal:dVariable(stream:TStream, name:Int = False)\n\t\tLocal tv:Int = Int(stream.ReadByte())\n\t\tSelect tv\n\t\t\tCase TV_INTEGER\n\t\t\t\tReturn New dIntVariable.Deserialize(stream, True, name)\n\t\t\tCase TV_STRING\n\t\t\t\tReturn New dStringVariable.Deserialize(stream, True, name)\n\t\t\tCase TV_FLOAT\n\t\t\t\tReturn New dFloatVariable.Deserialize(stream, True, name)\n\t\t\tCase TV_EVAL\n\t\t\t\tReturn New dEvalVariable.Deserialize(stream, True, name)\n\t\t\tCase TV_IDEN\n\t\t\t\tReturn New dIdentifier.Deserialize(stream, True, name)\n\t\t\tCase TV_BOOL\n\t\t\t\tReturn New dBoolVariable.Deserialize(stream, True, name)\n\t\t\tDefault\n\t\t\t\tDebugLog(\"(dVariable.DeserializeUniversal) Failed to recognize the TV in the stream: \" + tv)\n\t\tEnd Select\n\t\tReturn Null\n\tEnd Function\n\t\nEnd Type\n\nRem\n\tbbdoc: duct string variable.\nEnd Rem\nType dStringVariable Extends dVariable\n\t\n\tGlobal m_alwaysusequotes:Int = True\n\t\n\tField m_value:String\n\t\n\tRem\n\t\tbbdoc: Create a new String variable.\n\t\treturns: Itself.\n\tEnd Rem\n\tMethod Create:dStringVariable(name:String = Null, value:String)\n\t\tSetName(name)\n\t\tSet(value)\n\t\tReturn Self\n\tEnd Method\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the variable's value.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod Set(value:String)\n\t\tm_value = value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the variable's value.\n\t\treturns: The value of the variable.\n\tEnd Rem\n\tMethod Get:String()\n\t\tReturn m_value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the value of the variable to the given string (ambiguous).\n\t\treturns: Nothing.\n\t\tabout: For this type, this method is no different than calling #Set.\n\tEnd Rem\n\tMethod SetAmbiguous(value:String)\n\t\tm_value = value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Convert the variable to a String.\n\t\treturns: A String representation of the variable.\n\t\tabout: This function is for script output, for in-code use see #ValueAsString.\n\tEnd Rem\n\tMethod ConvToString:String()\n\t\tIf m_alwaysusequotes = True Or m_value.Contains(\"~t\") Or m_value.Contains(\" \") Or m_value = Null\n\t\t\tReturn \"~q\" + m_value + \"~q\"\n\t\tElse\n\t\t\tReturn m_value\n\t\tEnd If\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the variable as a String.\n\t\treturns: The variable's value converted to a String.\n\t\tabout: Here for complete-ness, no difference to `instance.Get()`.\n\tEnd Rem\n\tMethod ValueAsString:String()\n\t\tReturn m_value\n\tEnd Method\n\t\n'#end region (Field accessors)\n\t\n'#region Data handling\n\t\n\tRem\n\t\tbbdoc: Create a copy of the variable\n\t\treturns: A clone of the variable.\n\tEnd Rem\n\tMethod Copy:dStringVariable()\n\t\tReturn New dStringVariable.Create(m_name, m_value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Serialize the variable to a stream.\n\t\treturns: Nothing.\n\t\tabout: @tv tells the method whether it should serialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod Serialize(stream:TStream, tv:Int = True, name:Int = False)\n\t\tIf tv = True Then stream.WriteByte(TV_STRING)\n\t\tIf name = True Then WriteLString(stream, m_name)\n\t\tWriteLString(stream, m_value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Deserialize the variable from a stream.\n\t\treturns: Itself.\n\t\tabout: @tv tells the method whether it should deserialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod Deserialize:dStringVariable(stream:TStream, tv:Int = True, name:Int = False)\n\t\tIf tv = True Then stream.ReadByte()\n\t\tIf name = True Then m_name = ReadLString(stream)\n\t\tm_value = ReadLString(stream)\n\t\tReturn Self\n\tEnd Method\n\t\n'#end region (Data handling)\n\t\n\tRem\n\t\tbbdoc: Get the type of this variable.\n\t\treturns: The type of this variable (\"string\").\n\tEnd Rem\n\tFunction ReportType:String()\n\t\tReturn \"string\"\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Get the TV type of this variable.\n\t\treturns: The TV_* type of this variable (TV_STRING).\n\tEnd Rem\n\tFunction GetTVType:Int()\n\t\tReturn TV_STRING\n\tEnd Function\n\t\nEnd Type\n\nRem\n\tbbdoc: duct Float variable.\nEnd Rem\nType dFloatVariable Extends dVariable\n\t\n\tField m_value:Float\n\t\n\tRem\n\t\tbbdoc: Create a new Float variable.\n\t\treturns: Itself.\n\tEnd Rem\n\tMethod Create:dFloatVariable(name:String = Null, value:Float)\n\t\tSetName(name)\n\t\tSet(value)\n\t\tReturn Self\n\tEnd Method\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the variable's value.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod Set(value:Float)\n\t\tm_value = value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the variable's value.\n\t\treturns: The value of the variable.\n\tEnd Rem\n\tMethod Get:Float()\n\t\tReturn m_value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the value of the variable to the given string (ambiguous).\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetAmbiguous(value:String)\n\t\tm_value = Float(value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Convert the variable to a String.\n\t\treturns: A scriptable form of the variable.\n\t\tabout: This function is for script output, for in-code use see #ValueAsString.\n\tEnd Rem\n\tMethod ConvToString:String()\n\t\tLocal conv:String = String(m_value), encountered:Int\n\t\tFor Local i:Int = conv.Find(\".\") To conv.Length - 1\n\t\t\tIf conv[i] = 48\n\t\t\t\tIf encountered = True\n\t\t\t\t\tconv = conv[..i]\n\t\t\t\t\tExit\n\t\t\t\tEnd If\n\t\t\tElse If conv[i] <> 46\n\t\t\t\tencountered = True\n\t\t\tEnd If\n\t\tNext\n\t\tReturn conv\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the variable as a String.\n\t\treturns: The variable's value converted to a String.\n\tEnd Rem\n\tMethod ValueAsString:String()\n\t\tReturn String(m_value)\n\tEnd Method\n\t\n'#end region (Field accessors)\n\t\n'#region Data handling\n\t\n\tRem\n\t\tbbdoc: Create a copy of the variable\n\t\treturns: A clone of the variable.\n\tEnd Rem\n\tMethod Copy:dFloatVariable()\n\t\tReturn New dFloatVariable.Create(m_name, m_value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Serialize the variable to a stream.\n\t\treturns: Nothing.\n\t\tabout: @tv tells the method whether it should serialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod Serialize(stream:TStream, tv:Int = True, name:Int = False)\n\t\tIf tv = True Then stream.WriteByte(TV_FLOAT)\n\t\tIf name = True Then WriteLString(stream, m_name)\n\t\tstream.WriteFloat(m_value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Deserialize the variable from a stream.\n\t\treturns: Itself.\n\t\tabout: @tv tells the method whether it should deserialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod Deserialize:dFloatVariable(stream:TStream, tv:Int = True, name:Int = False)\n\t\tIf tv = True Then stream.ReadByte()\n\t\tIf name = True Then m_name = ReadLString(stream)\n\t\tm_value = stream.ReadFloat()\n\t\tReturn Self\n\tEnd Method\n\t\n'#end region (Data handling)\n\t\n\tRem\n\t\tbbdoc: Get the type of this variable.\n\t\treturns: The type of this variable (\"float\").\n\tEnd Rem\n\tFunction ReportType:String()\n\t\tReturn \"float\"\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Get the TV type of this variable.\n\t\treturns: The TV_* type of this variable (TV_FLOAT).\n\tEnd Rem\n\tFunction GetTVType:Int()\n\t\tReturn TV_FLOAT\n\tEnd Function\n\t\nEnd Type\n\nRem\n\tbbdoc: duct Int variable.\nEnd Rem\nType dIntVariable Extends dVariable\n\t\n\tField m_value:Int\n\t\n\tRem\n\t\tbbdoc: Create a new Int variable.\n\t\treturns: Itself.\n\tEnd Rem\n\tMethod Create:dIntVariable(name:String = Null, value:Int)\n\t\tSetName(name)\n\t\tSet(value)\n\t\tReturn Self\n\tEnd Method\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the variable's value.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod Set(value:Int)\n\t\tm_value = value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the variable's value.\n\t\treturns: The value of the variable.\n\tEnd Rem\n\tMethod Get:Int()\n\t\tReturn m_value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the value of the variable to the given string (ambiguous).\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetAmbiguous(value:String)\n\t\tm_value = Int(value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Convert the variable to a String.\n\t\treturns: A string representation of the variable.\n\t\tabout: This function is for script output, for in-code use see #ValueAsString.\n\tEnd Rem\n\tMethod ConvToString:String()\n\t\tReturn String(m_value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the variable as a String.\n\t\treturns: The variable's value converted to a String.\n\tEnd Rem\n\tMethod ValueAsString:String()\n\t\tReturn String(m_value)\n\tEnd Method\n\t\n'#end region (Field accessors)\n\t\n'#region Data handling\n\t\n\tRem\n\t\tbbdoc: Create a copy of the variable\n\t\treturns: A clone of the variable.\n\tEnd Rem\n\tMethod Copy:dIntVariable()\n\t\tReturn New dIntVariable.Create(m_name, m_value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Serialize the variable to a stream.\n\t\treturns: Nothing.\n\t\tabout: @tv tells the method whether it should serialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod Serialize(stream:TStream, tv:Int = True, name:Int = False)\n\t\tIf tv = True Then stream.WriteByte(TV_INTEGER)\n\t\tIf name = True Then WriteLString(stream, m_name)\n\t\tstream.WriteInt(m_value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Deserialize the variable from a stream.\n\t\treturns: Itself.\n\t\tabout: @tv tells the method whether it should deserialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod Deserialize:dIntVariable(stream:TStream, tv:Int = True, name:Int = False)\n\t\tIf tv = True Then stream.ReadByte()\n\t\tIf name = True Then m_name = ReadLString(stream)\n\t\tm_value = stream.ReadInt()\n\t\tReturn Self\n\tEnd Method\n\t\n'#end region (Data handling)\n\t\n\tRem\n\t\tbbdoc: Get the type of this variable.\n\t\treturns: The type of this variable (\"int\").\n\tEnd Rem\n\tFunction ReportType:String()\n\t\tReturn \"int\"\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Get the TV type of this variable.\n\t\treturns: The TV_* type of this variable (TV_INTEGER).\n\tEnd Rem\n\tFunction GetTVType:Int()\n\t\tReturn TV_INTEGER\n\tEnd Function\n\t\nEnd Type\n\nRem\n\tbbdoc: duct eval variable (for bah.muparser, and the likes).\nEnd Rem\nType dEvalVariable Extends dVariable\n\t\n\tField m_value:String\n\t\n\tRem\n\t\tbbdoc: Create a new eval variable.\n\t\treturns: Itself.\n\tEnd Rem\n\tMethod Create:dEvalVariable(name:String = Null, value:String)\n\t\tSetName(name)\n\t\tSet(value)\n\t\tReturn Self\n\tEnd Method\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the equation string for the variable.\n\t\treturns: Nothing\n\tEnd Rem\n\tMethod Set(value:String)\n\t\tm_value = value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the equation string.\n\t\treturns: The equation string.\n\tEnd Rem\n\tMethod Get:String()\n\t\tReturn m_value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the value of the variable to the given string (ambiguous).\n\t\treturns: Nothing.\n\t\tabout: For this type, this method is no different than calling #Set.\n\tEnd Rem\n\tMethod SetAmbiguous(value:String)\n\t\tm_value = value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Convert the variable to a visual representation of its data.\n\t\treturns: The scriptable form of the variable.\n\t\tabout: This function is for script output, for in-code use see #ValueAsString.\n\tEnd Rem\n\tMethod ConvToString:String()\n\t\tReturn \"~q\/e:\" + m_value + \"~q\"\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the variable as a String.\n\t\treturns: The variable's value converted to a String.\n\tEnd Rem\n\tMethod ValueAsString:String()\n\t\tReturn m_value\n\tEnd Method\n\t\n'#end region (Field accessors)\n\t\n'#region Data handling\n\t\n\tRem\n\t\tbbdoc: Create a copy of the variable\n\t\treturns: A clone of the variable.\n\tEnd Rem\n\tMethod Copy:dEvalVariable()\n\t\tReturn New dEvalVariable.Create(m_name, m_value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Serialize the variable to a stream.\n\t\treturns: Nothing.\n\t\tabout: @tv tells the method whether it should serialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod Serialize(stream:TStream, tv:Int = True, name:Int = False)\n\t\tIf tv = True Then stream.WriteByte(TV_EVAL)\n\t\tIf name = True Then WriteLString(stream, m_name)\n\t\tWriteLString(stream, m_value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Deserialize the variable from a stream.\n\t\treturns: Itself.\n\t\tabout: @tv tells the method whether it should deserialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod Deserialize:dEvalVariable(stream:TStream, tv:Int = True, name:Int = False)\n\t\tIf tv = True Then stream.ReadByte()\n\t\tIf name = True Then m_name = ReadLString(stream)\n\t\tm_value = ReadLString(stream)\n\t\tReturn Self\n\tEnd Method\n\t\n'#end region (Data handling)\n\t\n\tRem\n\t\tbbdoc: Get the type of this variable.\n\t\treturns: The type of this variable (\"eval\").\n\tEnd Rem\n\tFunction ReportType:String()\n\t\tReturn \"eval\"\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Get the TV type of this variable.\n\t\treturns: The TV_* type of this variable (TV_EVAL).\n\tEnd Rem\n\tFunction GetTVType:Int()\n\t\tReturn TV_EVAL\n\tEnd Function\n\t\nEnd Type\n\nRem\n\tbbdoc: duct boolean variable.\nEnd Rem\nType dBoolVariable Extends dVariable\n\t\n\tField m_value:Int\n\t\n\tRem\n\t\tbbdoc: Create a new boolean variable.\n\t\treturns: Itself.\n\tEnd Rem\n\tMethod Create:dBoolVariable(name:String = Null, value:Int)\n\t\tSetName(name)\n\t\tSet(value)\n\t\tReturn Self\n\tEnd Method\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the variable's value.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod Set(value:Int)\n\t\tm_value = value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the variable's value.\n\t\treturns: The value of the variable.\n\tEnd Rem\n\tMethod Get:Int()\n\t\tReturn m_value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the value of the variable to the given string (ambiguous).\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetAmbiguous(value:String)\n\t\tm_value = Int(value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Convert the variable to a String.\n\t\treturns: A string representation of the variable.\n\t\tabout: This function is for script output, for in-code use see #ValueAsString.\n\tEnd Rem\n\tMethod ConvToString:String()\n\t\tReturn String(m_value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the dBoolVariable as a String.\n\t\treturns: The variable's value converted to a String.\n\tEnd Rem\n\tMethod ValueAsString:String()\n\t\tReturn String(m_value)\n\tEnd Method\n\t\n'#end region (Field accessors)\n\t\n'#region Data handling\n\t\n\tRem\n\t\tbbdoc: Create a copy of the variable\n\t\treturns: A clone of the variable.\n\tEnd Rem\n\tMethod Copy:dBoolVariable()\n\t\tReturn New dBoolVariable.Create(m_name, m_value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Serialize the variable to a stream.\n\t\treturns: Nothing.\n\t\tabout: @tv tells the method whether it should serialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod Serialize(stream:TStream, tv:Int = True, name:Int = False)\n\t\tIf tv = True Then stream.WriteByte(TV_BOOL)\n\t\tIf name = True Then WriteLString(stream, m_name)\n\t\tstream.WriteByte(Byte(m_value))\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Deserialize the variable from a stream.\n\t\treturns: The deserialized variable.\n\t\tabout: @tv tells the method whether it should deserialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod Deserialize:dBoolVariable(stream:TStream, tv:Int = True, name:Int = False)\n\t\tIf tv = True Then stream.ReadByte()\n\t\tIf name = True Then m_name = ReadLString(stream)\n\t\tm_value = Int(stream.ReadByte())\n\t\tReturn Self\n\tEnd Method\n\t\n'#end region (Data handling)\n\t\n\tRem\n\t\tbbdoc: Get the type of this variable.\n\t\treturns: The type of this variable (\"bool\").\n\tEnd Rem\n\tFunction ReportType:String()\n\t\tReturn \"bool\"\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Get the TV type of this variable.\n\t\treturns: The TV_* type of this variable (TV_BOOL).\n\tEnd Rem\n\tFunction GetTVType:Int()\n\t\tReturn TV_BOOL\n\tEnd Function\n\t\nEnd Type\n\nRem\n\tbbdoc: duct identifier (used in parsers, mostly).\nEnd Rem\nType dIdentifier Extends dVariable\n\t\n\tField m_values:TListEx\n\t\n\tMethod New()\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Create a new identifier.\n\t\treturns: Itself.\n\tEnd Rem\n\tMethod Create:dIdentifier()\n\t\tm_values = New TListEx\n\t\tReturn Self\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Create a new identifier with the given data.\n\t\treturns: Itself.\n\t\tabout: If the @values parameter is Null a new list will be created.\n\tEnd Rem\n\tMethod CreateByData:dIdentifier(name:String, values:TListEx = Null)\n\t\tSetName(name)\n\t\tIf values = Null\n\t\t\tm_values = New TListEx\n\t\tElse\n\t\t\tm_values = values\n\t\tEnd If\n\t\tReturn Self\n\tEnd Method\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the identifier's values.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetValues(values:TListEx)\n\t\tm_values = values\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the identifier's values.\n\t\treturns: A list containing the values which the identifier holds.\n\tEnd Rem\n\tMethod GetValues:TListEx()\n\t\tReturn m_values\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Deprecated for this type.\n\t\treturns: Nothing.\n\t\tabout: This does nothing.\n\tEnd Rem\n\tMethod SetAmbiguous(value:String)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Convert the identifier to a string.\n\t\treturns: A string representation of the identifier.\n\tEnd Rem\n\tMethod ConvToString:String()\n\t\tLocal op:String\n\t\tIf m_name.Contains(\"~t\") = True Or m_name.Contains(\" \") = True\n\t\t\top = \"~q\" + m_name + \"~q \"\n\t\tElse\n\t\t\top = m_name + \" \"\n\t\tEnd If\n\t\tFor Local variable:dVariable = EachIn m_values\n\t\t\top:+variable.ConvToString() + \" \"\n\t\tNext\n\t\top = op[..op.Length - 1]\n\t\tReturn op\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the identifier as a string.\n\t\treturns: The identifier contents converted to a string.\n\t\tabout: Here for complete-ness, simply calls #ConvToString.\n\tEnd Rem\n\tMethod ValueAsString:String()\n\t\tReturn ConvToString()\n\tEnd Method\n\t\n'#end region (Field accessors)\n\t\n'#region Value handling\n\t\n\tRem\n\t\tbbdoc: Get a value at an index.\n\t\treturns: The value in the identifier's list at the given index, or Null if it could not be retrieved.\n\t\tabout: The index is zero-based.\n\tEnd Rem\n\tMethod GetValueAtIndex:dVariable(index:Int)\n\t\tIf m_values <> Null And index > - 1 And index < m_values.Count()\n\t\t\tReturn dVariable(m_values.ValueAtIndex(index))\n\t\tEnd If\n\t\tReturn Null\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the number of values.\n\t\treturns: The number of values the identifier contains.\n\tEnd Rem\n\tMethod GetValueCount:Int()\n\t\tIf m_values <> Null\n\t\t\tReturn m_values.Count()\n\t\tEnd If\n\t\tReturn 0\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Add a value to the identifier.\n\t\treturns: True for success, or False for failure.\n\t\tabout: NOTE: This will set the given value's parent.\n\tEnd Rem\n\tMethod AddValue:Int(value:dVariable)\n\t\tIf m_values <> Null And value <> Null\n\t\t\tm_values.AddLast(value)\n\t\t\tvalue.SetParent(Self)\n\t\t\tReturn True\n\t\tEnd If\n\t\tReturn False\n\tEnd Method\n\t\n'#end region (Value handling)\n\t\n'#region Data handling\n\t\n\tRem\n\t\tbbdoc: Create a copy of the identifier\n\t\treturns: A clone of the identifier.\n\tEnd Rem\n\tMethod Copy:dIdentifier()\n\t\tLocal clone:dIdentifier\n\t\tclone = New dIdentifier.CreateByData(m_name)\n\t\tFor Local variable:dVariable = EachIn m_values\n\t\t\tclone.AddValue(variable.Copy())\n\t\tNext\n\t\tReturn clone\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Serialize the variable to a stream.\n\t\treturns: Nothing.\n\t\tabout: @tv tells the method whether it should serialize the TV type for the variable, or to not.\n\t\tIn this case @name tells the method whether it should serialize the values<\/b><\/i>' name (the identifier's name is always read\/written to the stream).\n\tEnd Rem\n\tMethod Serialize(stream:TStream, tv:Int = True, name:Int = False)\n\t\tLocal variable:dVariable\n\t\tIf tv = True Then stream.WriteByte(TV_STRING)\n\t\tWriteLString(stream, m_name)\n\t\tIf m_values = Null\n\t\t\tstream.WriteInt(0)\n\t\tElse\n\t\t\tstream.WriteInt(m_values.Count())\n\t\t\tFor variable = EachIn m_values\n\t\t\t\tvariable.Serialize(stream, True, name)\n\t\t\tNext\n\t\tEnd If\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Deserialize the variable from a stream.\n\t\treturns: The deserialized variable.\n\t\tabout: @tv tells the method whether it should deserialize the TV type for the variable, or to not.\n\t\tIn this case @name tells the method whether it should deserialize the values<\/b><\/i>' name (the identifier's name is always read\/written to the stream).\n\tEnd Rem\n\tMethod Deserialize:dIdentifier(stream:TStream, tv:Int = True, name:Int = False)\n\t\tLocal count:Int, n:Int\n\t\tIf tv = True Then stream.ReadByte()\n\t\tm_name = ReadLString(stream)\n\t\tcount = stream.ReadInt()\n\t\tIf count > 0\n\t\t\tFor n = 0 To count - 1\n\t\t\t\tDeserializeUniversal(stream, name)\n\t\t\tNext\n\t\tEnd If\n\t\tReturn Self\n\tEnd Method\n\t\n'#end region (Data handling)\n\t\n\tRem\n\t\tbbdoc: Get the type of this variable.\n\t\treturns: The type of this variable (\"identifier\").\n\tEnd Rem\n\tFunction ReportType:String()\n\t\tReturn \"identifier\"\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Get the TV type of this variable.\n\t\treturns: The TV_* type of this variable (TV_IDEN).\n\tEnd Rem\n\tFunction GetTVType:Int()\n\t\tReturn TV_IDEN\n\tEnd Function\n\t\nEnd Type\n\nRem\n\tbbdoc: #dVariable map (stores any variable).\nEndRem\nType dVariableMap Extends dObjectMap\n\t\n\tRem\n\t\tbbdoc: Create a new variable map.\n\t\treturns: Itself.\n\tEnd Rem\n\tMethod Create:dVariableMap()\n\t\tReturn Self\n\tEnd Method\n\t\n'#region Collections\n\t\n\tRem\n\t\tbbdoc: Insert a variable into the map.\n\t\treturns: True if the variable was added, or False if it was not (the variable's name is Null).\n\tEnd Rem\n\tMethod InsertVariable:Int(variable:dVariable)\n\t\tIf variable.GetName() <> Null\n\t\t\t_Insert(variable.GetName(), variable)\n\t\t\tReturn True\n\t\tEnd If\n\t\tReturn False\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Remove a variable by the name given.\n\t\treturns: True if a variable was removed, or False if it was not (the map contains no variable with the name given).\n\t\tabout: The name is<\/b> case-sensitive.\n\tEnd Rem\n\tMethod RemoveVariableByName:Int(name:String)\n\t\tReturn _Remove(name)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get a variable from the map by its name.\n\t\treturns: The variable object, or if the variable was not found, Null.\n\t\tabout: The name is<\/b> case-sensitive.\n\tEnd Rem\n\tMethod GetVariableByName:dVariable(name:String)\n\t\tReturn dVariable(_ValueByKey(name))\n\tEnd Method\n\t\n'#end region (Collections)\n\t\nEnd Type\n\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"042c138eaf712ac1ef5580c598634059da2b5fe3","subject":"Fixed TEntity.Point","message":"Fixed TEntity.Point\n","repos":"kfprimm\/maxb3d,kfprimm\/maxb3d","old_file":"core.mod\/entity.bmx","new_file":"core.mod\/entity.bmx","new_contents":"\nStrict\n\nImport BRL.LinkedList\nImport MaxB3D.Math\nImport \"brush.bmx\"\nImport \"collision.bmx\"\nImport \"worldconfig.bmx\"\n\nConst PICKMODE_OFF\t\t= 1\nConst PICKMODE_SPHERE\t= 2\nConst PICKMODE_POLYGON\t= 3\nConst PICKMODE_BOX\t\t= 4\n\nType TEntity\n\tField _config:TWorldConfig\n\tField _matrix:TMatrix=TMatrix.Identity(), _lockmatrix\n\t\n\tField _name$\n\tField _px#,_py#,_pz#\n\tField _rx#,_ry#,_rz#\n\tField _sx#,_sy#,_sz#\n\t\t\n\tField _brush:TBrush=New TBrush\n\t\n\tField _parent:TEntity,_childlist:TList=CreateList()\n\tField _hidden,_order\n\t\n\tField _collision:TCollision[]\n\tField _oldx#,_oldy#,_oldz#\n\tField _radiusx#,_radiusy#\n\tField _boxx#,_boxy#,_boxz#,_boxwidth#,_boxheight#,_boxdepth#\n\tField _type,_typelink:TLink\n\tField _pickmode, _obscurer\n\t\n\tField _cullradius#\n\t\n\tField _alphaorder#\n\t\n\tField _linklist:TList=CreateList()\n\t\n\tMethod Init:TEntity(config:TWorldConfig,parent:TEntity)\n\t\t_config = config\n\t\tSetParent parent,False\n\t\tFor Local l=EachIn Lists()\n\t\t\tAddLink _config.AddObject(Self,l)\n\t\tNext\n\t\t\n\t\tSetScale 1,1,1\n\t\t\n\t\tReturn Self\n\tEnd Method\n\t\n\tMethod Free()\n\t\tFor Local child:TEntity=EachIn _childlist\n\t\t\tchild.Free()\n\t\tNext\n\t\tFor Local link:TLink=EachIn _linklist\n\t\t\tRemoveLink link\n\t\tNext\n\tEnd Method\n\t\n\tMethod AddLink(link:TLink)\n\t\t_linklist.AddLast link\n\tEnd Method\n\t\n\tMethod Lists[]()\n\t\tReturn [WORLDLIST_ENTITY]\n\tEnd Method\n\t\n\tMethod CopyData:TEntity(entity:TEntity)\n\t\tSetBrush entity.GetBrush()\n\t\tSetName entity.GetName()\n\t\tReturn Self\n\tEnd Method\n\t\n\tMethod Copy_:TEntity(parent:TEntity=Null)\n\t\tReturn New Self.CopyData(Self).Init(_config,parent)\n\tEnd Method\n\t\n\tMethod Copy:TEntity(parent:TEntity=Null) Abstract\n\t\n\tMethod AddParent(parent:TEntity)\n\t\t_parent=parent\n\t\tIf parent\n\t\t\t_matrix.Overwrite parent._matrix\n\t\t\tparent._childlist.AddLast Self\n\t\tEndIf\n\tEnd Method\n\t\n\tMethod GetParent:TEntity()\n\t\tReturn _parent\n\tEnd Method\n\tMethod SetParent(parent:TEntity,glob=True)\n\t\tLocal gpx#,gpy#,gpz#\t\t\n\t\tLocal grx#,gry#,grz#\t\t\n\t\tLocal gsx#,gsy#,gsz#\n\t\t\n\t\tGetPosition gpx,gpy,gpz,True\n\t\tGetRotation grx,gry,grz,True\n\t\tGetScale gsx,gsy,gsz,True\n\t\t\n\t\tIf _parent\n\t\t\tFor Local entity:TEntity=EachIn _parent._childlist\n\t\t\t\tIf entity=Self ListRemove(_parent._childlist,Self)\n\t\t\tNext\n\t\t\t_parent=Null\n\t\tEndIf\n\n\t\t_px=gpx;_py=gpy;_pz=gpz\n\t\t_rx=grx;_ry=gry;_rz=grz\n\t\t_sx=gsx;_sy=gsy;_sz=gsz\n\t\t\n\t\tIf parent=Null UpdateMatrix(True);Return\t\t\n\t\t\n\t\tAddParent(parent)\n\t\tIf glob\t\t\t\t\n\t\t\tSetPosition(gpx,gpy,gpz,True)\n\t\t\tSetRotation(grx,gry,grz,True)\n\t\t\tSetScale(gsx,gsy,gsz,True)\n\t\tElse\t\t\t\n\t\t\tUpdateMatrix(False)\t\t\t\t\n\t\tEndIf\t\t\t\n\tEnd Method\n\t\n\tMethod CountChildren(recursive=False)\n\t\tLocal count\n\t\tIf recursive\n\t\t\tFor Local child:TEntity=EachIn _childlist\n\t\t\t\tcount:+child.CountChildren(True)\n\t\t\tNext\n\t\tEndIf\n\t\tReturn _childlist.Count()+count\n\tEnd Method\n\t\n\tMethod FindChild:TEntity(name$,recursive=False)\n\t\tFor Local child:TEntity=EachIn _childlist\n\t\t\tIf child.GetName()=name Return child\n\t\tNext\n\t\tIf recursive\n\t\t\tFor Local child:TEntity=EachIn _childlist\n\t\t\t\tLocal entity:TEntity = child.FindChild(name, True)\n\t\t\t\tIf entity Return entity\n\t\t\tNext\n\t\tEndIf\n\tEnd Method\n\t\n\tMethod GetName$()\n\t\tReturn _name\n\tEnd Method\n\tMethod SetName(name$)\n\t\t_name=name\n\tEnd Method\n\t\n\tMethod GetBrush:TBrush()\n\t\tReturn _brush.Copy()\n\tEnd Method\n\tMethod SetBrush(brush:TBrush)\n\t\t_brush.Load brush\n\tEnd Method\n\t\n\tMethod GetColor(red Var,green Var,blue Var)\n\t\tReturn _brush.GetColor(red,green,blue)\n\tEnd Method\n\tMethod SetColor(red,green,blue)\n\t\tReturn _brush.SetColor(red,green,blue)\n\tEnd Method\n\t\n\tMethod GetAlpha#()\n\t\tReturn _brush.GetAlpha()\n\tEnd Method\n\tMethod SetAlpha(alpha#)\n\t\t_brush.SetAlpha(alpha)\n\tEnd Method\n\t\n\tMethod GetShine#()\n\t\tReturn _brush.GetShine()\n\tEnd Method\n\tMethod SetShine(shine#)\n\t\t_brush.SetShine(shine)\n\tEnd Method\n\t\n\tMethod GetTexture:TTexture(index)\n\t\tReturn _brush.GetTexture(index)\n\tEnd Method\n\tMethod SetTexture(texture:TTexture,index=0,frame=0)\n\t\tReturn _brush.SetTexture(texture,index,frame)\n\tEnd Method\n\t\n\tMethod GetFX()\n\t\tReturn _brush.GetFX()\n\tEnd Method\n\tMethod SetFX(fx)\n\t\tReturn _brush.SetFX(fx)\n\tEnd Method\n\t\n\tMethod GetBlend()\n\t\tReturn _brush.GetBlend()\n\tEnd Method\n\tMethod SetBlend(blend)\n\t\tReturn _brush.SetBlend(blend)\n\tEnd Method\n\t\n\tMethod GetShader:TShader()\n\t\tReturn _brush.GetShader()\n\tEnd Method\n\tMethod SetShader(shader:TShader)\n\t\tReturn _brush.SetShader(shader)\n\tEnd Method\n\t\n\tMethod GetScale(x# Var,y# Var,z# Var,glob=False)\n\t\tIf glob\n\t\t\tx=_matrix._m[0,0]\n\t\t\ty=_matrix._m[1,1]\n\t\t\tz=_matrix._m[2,2]\n\t\tElse\n\t\t\tx=_sx;y=_sy;z=_sz\n\t\tEndIf\n\tEnd Method\n\tMethod SetScale(x#,y#,z#,glob=False)\n\t\t_sx=x;_sy=y;_sz=z\n\t\tIf glob=True And _parent<>Null\n\t\t\tLocal entity:TEntity=Self\n\t\t\tRepeat\n\t\t\t\t_sx:\/entity._parent._sx\n\t\t\t\t_sy:\/entity._parent._sy\n\t\t\t\t_sz:\/entity._parent._sz\n\t\t\t\tentity=entity._parent\n\t\t\tUntil entity._parent=Null\n\t\tEndIf\n\t\tRefreshMatrix()\t\n\tEnd Method\n\t\n\tMethod Transform(matrix:TMatrix,glob=False)\n\t\tSetMatrix matrix.Multiply(_matrix),glob\n\tEnd Method\n\t\n\tMethod Turn(pitch#,yaw#,roll#,glob=False)\n\t\t_rx:+pitch;_ry:+yaw;_rz:+roll\n\t\tRefreshMatrix()\n\tEnd Method\n\t\n\tMethod Point(target:Object,roll#=0.0)\n\t\tLocal x#,y#,z#,tx#,ty#,tz#\n\t\tGetPosition x,y,z,True\n\t\tGetTargetPosition target,tx,ty,tz \n\n\t\tLocal xdiff#=x-tx,ydiff#=y-ty,zdiff#=z-tz\n\n\t\tLocal dist22#=Sqr((xdiff*xdiff)+(zdiff*zdiff))\n\t\tLocal pitch#=ATan2(ydiff,dist22)\n\t\tLocal yaw#=ATan2(xdiff,-zdiff)\n\n\t\tSetRotation pitch,yaw,roll,True\n\tEnd Method\n\t\n\tMethod GetDistance#(target:Object)\n\t\tLocal x#,y#,z#,tx#,ty#,tz#\n\t\tGetPosition x,y,z,True\n\t\tGetTargetPosition target,tx,ty,tz\t\t\n\t\tReturn Sqr((x-tx)*(x-tx)+(y-ty)*(y-ty)+(z-tz)*(z-tz))\n\tEnd Method\n\t\n\tFunction GetTargetPosition(target:Object,x# Var,y# Var,z# Var)\n\t\tAssert target,\"Null target given.\"\n\t\tIf TEntity(target) TEntity(target).GetPosition x,y,z,True\n\t\tIf Float[](target)\n\t\t\tLocal coords#[]=Float[](target)\n\t\t\tIf coords.length>0 x=coords[0]\n\t\t\tIf coords.length>1 y=coords[1]\n\t\t\tIf coords.length>2 z=coords[2]\n\t\tEndIf\n\t\tAssert \"Invalid target given.\"\n\tEnd Function\t\n\t\n\tMethod GetRotation(pitch# Var,yaw# Var,roll# Var,glob=False)\n\t\tIf glob\n\t\t\t_matrix.GetRotation pitch,yaw,roll\n\t\t\tpitch:*-1\n\t\t\tyaw:*-1\n\t\tElse\n\t\t\tpitch=_rx;yaw=_ry;roll=_rz\n\t\tEndIf\n\tEnd Method\n\tMethod SetRotation(pitch#,yaw#,roll#,glob=False)\n\t\t_rx=pitch;_ry=yaw;_rz=roll\n\t\tIf glob And _parent<>Null\n\t\t\tLocal rx#,ry#,rz#\n\t\t\t_parent.GetRotation rx,ry,rz\n\t\t\t_rx:+rx;_ry:+ry;_rz:+rz\t\t\t\n\t\tEndIf\n\t\tRefreshMatrix()\n\tEnd Method\n\t\t\n\tMethod GetPosition(x# Var,y# Var,z# Var,glob=False)\n\t\tx=_px;y=_py;z=_pz\n\t\tIf glob _matrix.GetPosition x,y,z\n\tEnd Method\n\tMethod SetPosition(x#,y#,z#,glob=False)\n\t\t_px=x;_py=y;_pz=z\n\t\t\n\t\tIf glob And _parent<>Null\n\t\t\tLocal px#,py#,pz#\n\t\t\t_parent.GetPosition px,py,pz,True\n\t\t\t_px:-px;_py:-py;_pz:-pz\n\t\tEndIf\n\t\t\n\t\tRefreshMatrix()\n\tEnd Method\n\t\n\tMethod Move(x#,y#,z#)\n\t\tLocal matrix:TMatrix=TMatrix.Identity()\n\t\tmatrix=TMatrix.YawPitchRoll(-_ry,-_rx,_rz).Multiply(matrix)\n\t\tmatrix=TMatrix.Translation(x,y,z).Multiply(matrix)\n\t\n\t\tmatrix.GetPosition(x,y,z)\t\t\n\t\t_px:+x;_py:+y;_pz:+z\n\n\t\tRefreshMatrix()\n\tEnd Method\n\t\n\tMethod Translate(x#,y#,z#,glob=True)\n\t\tIf glob And _parent\t\t\t\n\t\t\tLocal ax#,ay#,az#\n\t\t\tGetRotation ax,ay,az,True\n\t\t\t\t\t\t\n\t\t\tLocal matrix:TMatrix=TMatrix.Roll(-az)\n\t\t\tmatrix=matrix.Multiply(TMatrix.Pitch(-ax))\n\t\t\tmatrix=matrix.Multiply(TMatrix.Yaw(-ay))\n\t\t\tmatrix=matrix.Multiply(TMatrix.Translation(x,y,z))\n\t\t\t\n\t\t\tmatrix.GetPosition x,y,z\n\t\tEndIf\n\t\t\n\t\t_px:+x;_py:+y;_pz:+z\n\n\t\tRefreshMatrix()\n\tEnd Method\n\t\n\tMethod GetVisible()\n\t\tLocal entity:TEntity=Self\n\t\tWhile entity<>Null\n\t\t\tIf entity._hidden=True Return False\n\t\t\tentity=entity._parent\n\t\tWend\n\t\tReturn True\n\tEnd Method\n\tMethod SetVisible(visible)\n\t\t_hidden=Not visible\n\tEnd Method\n\t\n\tMethod GetOrder()\n\t\tReturn _order\n\tEnd Method\n\tMethod SetOrder(order)\n\t\t_order=order\n\tEnd Method\n\t\n\tMethod GetCollisions:TCollision[]()\n\t\tReturn _collision\n\tEnd Method\n\t\n\tMethod GetRadius(x# Var,y# Var)\n\t\tx=_radiusx;y=_radiusy\n\tEnd Method\n\tMethod SetRadius(x#,y#=-1)\n\t\t_radiusx=x;_radiusy=x\n\t\tIf y>-1 _radiusy=y\n\tEnd Method\n\t\n\tMethod GetBox(x# Var,y# Var,z# Var,width# Var,height# Var,depth# Var)\n\t\tx=_boxx;y=_boxy;z=_boxz\n\t\twidth=_boxwidth;height=_boxheight;depth=_boxdepth\n\tEnd Method\n\tMethod SetBox(x#,y#,z#,width#,height#,depth#)\n\t\t_boxx=x;_boxy=y;_boxz=z\n\t\t_boxwidth=width;_boxheight=height;_boxdepth=depth\n\tEnd Method\n\t\n\tMethod Reset()\n\t\t_collision=Null\n\t\tGetPosition _oldx,_oldy,_oldz,True\n\tEnd Method\n\t\n\tMethod GetType()\n\t\tReturn _type\n\tEnd Method\n\tMethod SetType(typ,recursive=False)\n\t\tIf _typelink\n\t\t\t_linklist.Remove(_typelink)\n\t\t\t_typelink.Remove()\n\t\t\t_typelink=Null\n\t\tEndIf\n\t\t\n\t\tIf typ>0\n\t\t\tIf _config.CollisionType[typ]=Null _config.CollisionType[typ]=CreateList()\n\t\t\t_typelink=_config.CollisionType[typ].AddLast(Self)\n\t\t\tAddLink _typelink\n\t\tEndIf\t\t\n\t\t\n\t\t_type=typ\n\t\tGetPosition _oldx,_oldy,_oldz,True\n\t\t\n\t\tIf recursive\n\t\t\tFor Local child:TEntity=EachIn _childlist\n\t\t\t\tchild.SetType typ,True\n\t\t\tNext\n\t\tEndIf\n\tEnd Method\n\t\n\tMethod GetCullRadius#()\n\t\tReturn Abs(_cullradius)\n\tEnd Method\n\tMethod SetCullRadius(radius#)\n\t\t_cullradius=-radius\n\tEnd Method\n\n\tMethod GetCullParams(x# Var,y# Var,z# Var,radius# Var)\n\t\tGetPosition x,y,z,True\n\t\tradius=GetCullRadius()\n\tEnd Method\n\t\n\tMethod GetPickMode(mode Var, obscurer Var)\n\t\tmode = _pickmode\n\t\tobscurer = _obscurer\n\tEnd Method\t\n\tMethod SetPickMode(mode, obscurer=True)\n\t\t_pickmode = mode\n\t\t_obscurer = obscurer\n\tEnd Method\n\t\n\tMethod HasAlpha()\n\t\tReturn _brush.HasAlpha()\n\tEnd Method\n\t\n\tMethod GetMatrix:TMatrix(alternate=False,copy=True)\n\t\tIf copy Return _matrix.Copy()\n\t\tReturn _matrix\n\tEnd Method\n\tMethod SetMatrix(matrix:TMatrix,glob=True)\n\t\tLocal x#,y#,z#,pitch#,yaw#,roll#,sx#,sy#,sz#\n\t\tmatrix.GetPosition x,y,z\n\t\tmatrix.GetRotation pitch,yaw,roll\n\t\tmatrix.GetScale sx,sy,sz\n\t\t\n\t\tLockMatrix\n\t\tSetPosition x,y,z,glob\n\t\tSetRotation pitch,yaw,roll,glob\n\t\tSetScale sx,sy,sz,glob\n\t\tUnlockMatrix\n\tEnd Method\n\t\n\tMethod LockMatrix()\n\t\t_lockmatrix=True\n\tEnd Method\n\tMethod UnlockMatrix()\n\t\t_lockmatrix=False\n\t\tRefreshMatrix()\n\tEnd Method\n\t\n\tMethod RefreshMatrix()\n\t\tIf _lockmatrix Return\n\t\tIf _parent<>Null\n\t\t\t_matrix.Overwrite _parent._matrix\n\t\t\tUpdateMatrix False\n\t\tElse\n\t\t\tUpdateMatrix True\n\t\tEndIf\t\t\n\t\t\n\t\tFor Local child:TEntity=EachIn _childlist\n\t\t\tchild.RefreshMatrix()\n\t\tNext\n\tEnd Method\n\t\n\tMethod UpdateMatrix(loadidentity)\n\t\tIf loadidentity _matrix=TMatrix.Identity()\n\t\t_matrix=TMatrix.Translation(_px,_py,_pz).Multiply(_matrix)\n\t\t_matrix=TMatrix.YawPitchRoll(-_ry,-_rx,_rz).Multiply(_matrix)\n\t\t_matrix=TMatrix.Scale(_sx,_sy,_sz).Multiply(_matrix)\n\tEnd Method\n\t\n\tMethod ObjectEnumerator:Object()\n\t\tReturn TChildrenEnumerator.Create(_childlist)\n\tEnd Method\nEnd Type\n\nType TChildrenEnumerator\n\tField _children:TEntity[],_index=-1\n\t\n\tFunction Create:TChildrenEnumerator(list:TList)\n\t\tLocal enum:TChildrenEnumerator=New TChildrenEnumerator\n\t\tenum._children=TEntity[](list.ToArray())\n\t\tReturn enum\n\tEnd Function\n\t\n\tMethod HasNext()\n\t\tReturn _index>=_children.length-1\n\tEnd Method\n\t\n\tMethod NextObject:Object()\n\t\t_index:+1\n\t\tReturn _children[_index]\n\tEnd Method\nEnd Type\n","old_contents":"\nStrict\n\nImport BRL.LinkedList\nImport MaxB3D.Math\nImport \"brush.bmx\"\nImport \"collision.bmx\"\nImport \"worldconfig.bmx\"\n\nConst PICKMODE_OFF\t\t= 1\nConst PICKMODE_SPHERE\t= 2\nConst PICKMODE_POLYGON\t= 3\nConst PICKMODE_BOX\t\t= 4\n\nType TEntity\n\tField _config:TWorldConfig\n\tField _matrix:TMatrix=TMatrix.Identity(), _lockmatrix\n\t\n\tField _name$\n\tField _px#,_py#,_pz#\n\tField _rx#,_ry#,_rz#\n\tField _sx#,_sy#,_sz#\n\t\t\n\tField _brush:TBrush=New TBrush\n\t\n\tField _parent:TEntity,_childlist:TList=CreateList()\n\tField _hidden,_order\n\t\n\tField _collision:TCollision[]\n\tField _oldx#,_oldy#,_oldz#\n\tField _radiusx#,_radiusy#\n\tField _boxx#,_boxy#,_boxz#,_boxwidth#,_boxheight#,_boxdepth#\n\tField _type,_typelink:TLink\n\tField _pickmode, _obscurer\n\t\n\tField _cullradius#\n\t\n\tField _alphaorder#\n\t\n\tField _linklist:TList=CreateList()\n\t\n\tMethod Init:TEntity(config:TWorldConfig,parent:TEntity)\n\t\t_config = config\n\t\tSetParent parent,False\n\t\tFor Local l=EachIn Lists()\n\t\t\tAddLink _config.AddObject(Self,l)\n\t\tNext\n\t\t\n\t\tSetScale 1,1,1\n\t\t\n\t\tReturn Self\n\tEnd Method\n\t\n\tMethod Free()\n\t\tFor Local child:TEntity=EachIn _childlist\n\t\t\tchild.Free()\n\t\tNext\n\t\tFor Local link:TLink=EachIn _linklist\n\t\t\tRemoveLink link\n\t\tNext\n\tEnd Method\n\t\n\tMethod AddLink(link:TLink)\n\t\t_linklist.AddLast link\n\tEnd Method\n\t\n\tMethod Lists[]()\n\t\tReturn [WORLDLIST_ENTITY]\n\tEnd Method\n\t\n\tMethod CopyData:TEntity(entity:TEntity)\n\t\tSetBrush entity.GetBrush()\n\t\tSetName entity.GetName()\n\t\tReturn Self\n\tEnd Method\n\t\n\tMethod Copy_:TEntity(parent:TEntity=Null)\n\t\tReturn New Self.CopyData(Self).Init(_config,parent)\n\tEnd Method\n\t\n\tMethod Copy:TEntity(parent:TEntity=Null) Abstract\n\t\n\tMethod AddParent(parent:TEntity)\n\t\t_parent=parent\n\t\tIf parent\n\t\t\t_matrix.Overwrite parent._matrix\n\t\t\tparent._childlist.AddLast Self\n\t\tEndIf\n\tEnd Method\n\t\n\tMethod GetParent:TEntity()\n\t\tReturn _parent\n\tEnd Method\n\tMethod SetParent(parent:TEntity,glob=True)\n\t\tLocal gpx#,gpy#,gpz#\t\t\n\t\tLocal grx#,gry#,grz#\t\t\n\t\tLocal gsx#,gsy#,gsz#\n\t\t\n\t\tGetPosition gpx,gpy,gpz,True\n\t\tGetRotation grx,gry,grz,True\n\t\tGetScale gsx,gsy,gsz,True\n\t\t\n\t\tIf _parent\n\t\t\tFor Local entity:TEntity=EachIn _parent._childlist\n\t\t\t\tIf entity=Self ListRemove(_parent._childlist,Self)\n\t\t\tNext\n\t\t\t_parent=Null\n\t\tEndIf\n\n\t\t_px=gpx;_py=gpy;_pz=gpz\n\t\t_rx=grx;_ry=gry;_rz=grz\n\t\t_sx=gsx;_sy=gsy;_sz=gsz\n\t\t\n\t\tIf parent=Null UpdateMatrix(True);Return\t\t\n\t\t\n\t\tAddParent(parent)\n\t\tIf glob\t\t\t\t\n\t\t\tSetPosition(gpx,gpy,gpz,True)\n\t\t\tSetRotation(grx,gry,grz,True)\n\t\t\tSetScale(gsx,gsy,gsz,True)\n\t\tElse\t\t\t\n\t\t\tUpdateMatrix(False)\t\t\t\t\n\t\tEndIf\t\t\t\n\tEnd Method\n\t\n\tMethod CountChildren(recursive=False)\n\t\tLocal count\n\t\tIf recursive\n\t\t\tFor Local child:TEntity=EachIn _childlist\n\t\t\t\tcount:+child.CountChildren(True)\n\t\t\tNext\n\t\tEndIf\n\t\tReturn _childlist.Count()+count\n\tEnd Method\n\t\n\tMethod FindChild:TEntity(name$,recursive=False)\n\t\tFor Local child:TEntity=EachIn _childlist\n\t\t\tIf child.GetName()=name Return child\n\t\tNext\n\t\tIf recursive\n\t\t\tFor Local child:TEntity=EachIn _childlist\n\t\t\t\tLocal entity:TEntity = child.FindChild(name, True)\n\t\t\t\tIf entity Return entity\n\t\t\tNext\n\t\tEndIf\n\tEnd Method\n\t\n\tMethod GetName$()\n\t\tReturn _name\n\tEnd Method\n\tMethod SetName(name$)\n\t\t_name=name\n\tEnd Method\n\t\n\tMethod GetBrush:TBrush()\n\t\tReturn _brush.Copy()\n\tEnd Method\n\tMethod SetBrush(brush:TBrush)\n\t\t_brush.Load brush\n\tEnd Method\n\t\n\tMethod GetColor(red Var,green Var,blue Var)\n\t\tReturn _brush.GetColor(red,green,blue)\n\tEnd Method\n\tMethod SetColor(red,green,blue)\n\t\tReturn _brush.SetColor(red,green,blue)\n\tEnd Method\n\t\n\tMethod GetAlpha#()\n\t\tReturn _brush.GetAlpha()\n\tEnd Method\n\tMethod SetAlpha(alpha#)\n\t\t_brush.SetAlpha(alpha)\n\tEnd Method\n\t\n\tMethod GetShine#()\n\t\tReturn _brush.GetShine()\n\tEnd Method\n\tMethod SetShine(shine#)\n\t\t_brush.SetShine(shine)\n\tEnd Method\n\t\n\tMethod GetTexture:TTexture(index)\n\t\tReturn _brush.GetTexture(index)\n\tEnd Method\n\tMethod SetTexture(texture:TTexture,index=0,frame=0)\n\t\tReturn _brush.SetTexture(texture,index,frame)\n\tEnd Method\n\t\n\tMethod GetFX()\n\t\tReturn _brush.GetFX()\n\tEnd Method\n\tMethod SetFX(fx)\n\t\tReturn _brush.SetFX(fx)\n\tEnd Method\n\t\n\tMethod GetBlend()\n\t\tReturn _brush.GetBlend()\n\tEnd Method\n\tMethod SetBlend(blend)\n\t\tReturn _brush.SetBlend(blend)\n\tEnd Method\n\t\n\tMethod GetShader:TShader()\n\t\tReturn _brush.GetShader()\n\tEnd Method\n\tMethod SetShader(shader:TShader)\n\t\tReturn _brush.SetShader(shader)\n\tEnd Method\n\t\n\tMethod GetScale(x# Var,y# Var,z# Var,glob=False)\n\t\tIf glob\n\t\t\tx=_matrix._m[0,0]\n\t\t\ty=_matrix._m[1,1]\n\t\t\tz=_matrix._m[2,2]\n\t\tElse\n\t\t\tx=_sx;y=_sy;z=_sz\n\t\tEndIf\n\tEnd Method\n\tMethod SetScale(x#,y#,z#,glob=False)\n\t\t_sx=x;_sy=y;_sz=z\n\t\tIf glob=True And _parent<>Null\n\t\t\tLocal entity:TEntity=Self\n\t\t\tRepeat\n\t\t\t\t_sx:\/entity._parent._sx\n\t\t\t\t_sy:\/entity._parent._sy\n\t\t\t\t_sz:\/entity._parent._sz\n\t\t\t\tentity=entity._parent\n\t\t\tUntil entity._parent=Null\n\t\tEndIf\n\t\tRefreshMatrix()\t\n\tEnd Method\n\t\n\tMethod Transform(matrix:TMatrix,glob=False)\n\t\tSetMatrix matrix.Multiply(_matrix),glob\n\tEnd Method\n\t\n\tMethod Turn(pitch#,yaw#,roll#,glob=False)\n\t\t_rx:+pitch;_ry:+yaw;_rz:+roll\n\t\tRefreshMatrix()\n\tEnd Method\n\t\n\tMethod Point(target:Object,roll#=0.0)\n\t\tLocal x#,y#,z#,tx#,ty#,tz#\n\t\tGetPosition x,y,z,True\n\t\tGetTargetPosition target,tx,ty,tz \n\n\t\tLocal xdiff#=x-tx,ydiff#=y-ty,zdiff#=z-tz\n\n\t\tLocal dist22#=Sqr((xdiff*xdiff)+(zdiff*zdiff))\n\t\tLocal pitch#=ATan2(ydiff,dist22)\n\t\tLocal yaw#=-ATan2(xdiff,-zdiff)\n\n\t\tSetRotation pitch,yaw,roll,True\n\tEnd Method\n\t\n\tMethod GetDistance#(target:Object)\n\t\tLocal x#,y#,z#,tx#,ty#,tz#\n\t\tGetPosition x,y,z,True\n\t\tGetTargetPosition target,tx,ty,tz\t\t\n\t\tReturn Sqr((x-tx)*(x-tx)+(y-ty)*(y-ty)+(z-tz)*(z-tz))\n\tEnd Method\n\t\n\tFunction GetTargetPosition(target:Object,x# Var,y# Var,z# Var)\n\t\tAssert target,\"Null target given.\"\n\t\tIf TEntity(target) TEntity(target).GetPosition x,y,z,True\n\t\tIf Float[](target)\n\t\t\tLocal coords#[]=Float[](target)\n\t\t\tIf coords.length>0 x=coords[0]\n\t\t\tIf coords.length>1 y=coords[1]\n\t\t\tIf coords.length>2 z=coords[2]\n\t\tEndIf\n\t\tAssert \"Invalid target given.\"\n\tEnd Function\t\n\t\n\tMethod GetRotation(pitch# Var,yaw# Var,roll# Var,glob=False)\n\t\tIf glob\n\t\t\t_matrix.GetRotation pitch,yaw,roll\n\t\t\tpitch:*-1\n\t\t\tyaw:*-1\n\t\tElse\n\t\t\tpitch=_rx;yaw=_ry;roll=_rz\n\t\tEndIf\n\tEnd Method\n\tMethod SetRotation(pitch#,yaw#,roll#,glob=False)\n\t\t_rx=pitch;_ry=yaw;_rz=roll\n\t\tIf glob And _parent<>Null\n\t\t\tLocal rx#,ry#,rz#\n\t\t\t_parent.GetRotation rx,ry,rz\n\t\t\t_rx:+rx;_ry:+ry;_rz:+rz\t\t\t\n\t\tEndIf\n\t\tRefreshMatrix()\n\tEnd Method\n\t\t\n\tMethod GetPosition(x# Var,y# Var,z# Var,glob=False)\n\t\tx=_px;y=_py;z=_pz\n\t\tIf glob _matrix.GetPosition x,y,z\n\tEnd Method\n\tMethod SetPosition(x#,y#,z#,glob=False)\n\t\t_px=x;_py=y;_pz=z\n\t\t\n\t\tIf glob And _parent<>Null\n\t\t\tLocal px#,py#,pz#\n\t\t\t_parent.GetPosition px,py,pz,True\n\t\t\t_px:-px;_py:-py;_pz:-pz\n\t\tEndIf\n\t\t\n\t\tRefreshMatrix()\n\tEnd Method\n\t\n\tMethod Move(x#,y#,z#)\n\t\tLocal matrix:TMatrix=TMatrix.Identity()\n\t\tmatrix=TMatrix.YawPitchRoll(-_ry,-_rx,_rz).Multiply(matrix)\n\t\tmatrix=TMatrix.Translation(x,y,z).Multiply(matrix)\n\t\n\t\tmatrix.GetPosition(x,y,z)\t\t\n\t\t_px:+x;_py:+y;_pz:+z\n\n\t\tRefreshMatrix()\n\tEnd Method\n\t\n\tMethod Translate(x#,y#,z#,glob=True)\n\t\tIf glob And _parent\t\t\t\n\t\t\tLocal ax#,ay#,az#\n\t\t\tGetRotation ax,ay,az,True\n\t\t\t\t\t\t\n\t\t\tLocal matrix:TMatrix=TMatrix.Roll(-az)\n\t\t\tmatrix=matrix.Multiply(TMatrix.Pitch(-ax))\n\t\t\tmatrix=matrix.Multiply(TMatrix.Yaw(-ay))\n\t\t\tmatrix=matrix.Multiply(TMatrix.Translation(x,y,z))\n\t\t\t\n\t\t\tmatrix.GetPosition x,y,z\n\t\tEndIf\n\t\t\n\t\t_px:+x;_py:+y;_pz:+z\n\n\t\tRefreshMatrix()\n\tEnd Method\n\t\n\tMethod GetVisible()\n\t\tLocal entity:TEntity=Self\n\t\tWhile entity<>Null\n\t\t\tIf entity._hidden=True Return False\n\t\t\tentity=entity._parent\n\t\tWend\n\t\tReturn True\n\tEnd Method\n\tMethod SetVisible(visible)\n\t\t_hidden=Not visible\n\tEnd Method\n\t\n\tMethod GetOrder()\n\t\tReturn _order\n\tEnd Method\n\tMethod SetOrder(order)\n\t\t_order=order\n\tEnd Method\n\t\n\tMethod GetCollisions:TCollision[]()\n\t\tReturn _collision\n\tEnd Method\n\t\n\tMethod GetRadius(x# Var,y# Var)\n\t\tx=_radiusx;y=_radiusy\n\tEnd Method\n\tMethod SetRadius(x#,y#=-1)\n\t\t_radiusx=x;_radiusy=x\n\t\tIf y>-1 _radiusy=y\n\tEnd Method\n\t\n\tMethod GetBox(x# Var,y# Var,z# Var,width# Var,height# Var,depth# Var)\n\t\tx=_boxx;y=_boxy;z=_boxz\n\t\twidth=_boxwidth;height=_boxheight;depth=_boxdepth\n\tEnd Method\n\tMethod SetBox(x#,y#,z#,width#,height#,depth#)\n\t\t_boxx=x;_boxy=y;_boxz=z\n\t\t_boxwidth=width;_boxheight=height;_boxdepth=depth\n\tEnd Method\n\t\n\tMethod Reset()\n\t\t_collision=Null\n\t\tGetPosition _oldx,_oldy,_oldz,True\n\tEnd Method\n\t\n\tMethod GetType()\n\t\tReturn _type\n\tEnd Method\n\tMethod SetType(typ,recursive=False)\n\t\tIf _typelink\n\t\t\t_linklist.Remove(_typelink)\n\t\t\t_typelink.Remove()\n\t\t\t_typelink=Null\n\t\tEndIf\n\t\t\n\t\tIf typ>0\n\t\t\tIf _config.CollisionType[typ]=Null _config.CollisionType[typ]=CreateList()\n\t\t\t_typelink=_config.CollisionType[typ].AddLast(Self)\n\t\t\tAddLink _typelink\n\t\tEndIf\t\t\n\t\t\n\t\t_type=typ\n\t\tGetPosition _oldx,_oldy,_oldz,True\n\t\t\n\t\tIf recursive\n\t\t\tFor Local child:TEntity=EachIn _childlist\n\t\t\t\tchild.SetType typ,True\n\t\t\tNext\n\t\tEndIf\n\tEnd Method\n\t\n\tMethod GetCullRadius#()\n\t\tReturn Abs(_cullradius)\n\tEnd Method\n\tMethod SetCullRadius(radius#)\n\t\t_cullradius=-radius\n\tEnd Method\n\n\tMethod GetCullParams(x# Var,y# Var,z# Var,radius# Var)\n\t\tGetPosition x,y,z,True\n\t\tradius=GetCullRadius()\n\tEnd Method\n\t\n\tMethod GetPickMode(mode Var, obscurer Var)\n\t\tmode = _pickmode\n\t\tobscurer = _obscurer\n\tEnd Method\t\n\tMethod SetPickMode(mode, obscurer=True)\n\t\t_pickmode = mode\n\t\t_obscurer = obscurer\n\tEnd Method\n\t\n\tMethod HasAlpha()\n\t\tReturn _brush.HasAlpha()\n\tEnd Method\n\t\n\tMethod GetMatrix:TMatrix(alternate=False,copy=True)\n\t\tIf copy Return _matrix.Copy()\n\t\tReturn _matrix\n\tEnd Method\n\tMethod SetMatrix(matrix:TMatrix,glob=True)\n\t\tLocal x#,y#,z#,pitch#,yaw#,roll#,sx#,sy#,sz#\n\t\tmatrix.GetPosition x,y,z\n\t\tmatrix.GetRotation pitch,yaw,roll\n\t\tmatrix.GetScale sx,sy,sz\n\t\t\n\t\tLockMatrix\n\t\tSetPosition x,y,z,glob\n\t\tSetRotation pitch,yaw,roll,glob\n\t\tSetScale sx,sy,sz,glob\n\t\tUnlockMatrix\n\tEnd Method\n\t\n\tMethod LockMatrix()\n\t\t_lockmatrix=True\n\tEnd Method\n\tMethod UnlockMatrix()\n\t\t_lockmatrix=False\n\t\tRefreshMatrix()\n\tEnd Method\n\t\n\tMethod RefreshMatrix()\n\t\tIf _lockmatrix Return\n\t\tIf _parent<>Null\n\t\t\t_matrix.Overwrite _parent._matrix\n\t\t\tUpdateMatrix False\n\t\tElse\n\t\t\tUpdateMatrix True\n\t\tEndIf\t\t\n\t\t\n\t\tFor Local child:TEntity=EachIn _childlist\n\t\t\tchild.RefreshMatrix()\n\t\tNext\n\tEnd Method\n\t\n\tMethod UpdateMatrix(loadidentity)\n\t\tIf loadidentity _matrix=TMatrix.Identity()\n\t\t_matrix=TMatrix.Translation(_px,_py,_pz).Multiply(_matrix)\n\t\t_matrix=TMatrix.YawPitchRoll(-_ry,-_rx,_rz).Multiply(_matrix)\n\t\t_matrix=TMatrix.Scale(_sx,_sy,_sz).Multiply(_matrix)\n\tEnd Method\n\t\n\tMethod ObjectEnumerator:Object()\n\t\tReturn TChildrenEnumerator.Create(_childlist)\n\tEnd Method\nEnd Type\n\nType TChildrenEnumerator\n\tField _children:TEntity[],_index=-1\n\t\n\tFunction Create:TChildrenEnumerator(list:TList)\n\t\tLocal enum:TChildrenEnumerator=New TChildrenEnumerator\n\t\tenum._children=TEntity[](list.ToArray())\n\t\tReturn enum\n\tEnd Function\n\t\n\tMethod HasNext()\n\t\tReturn _index>=_children.length-1\n\tEnd Method\n\t\n\tMethod NextObject:Object()\n\t\t_index:+1\n\t\tReturn _children[_index]\n\tEnd Method\nEnd Type\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"6bae1780cbd7106f7a3832952845ea1df21ce15c","subject":"Fixed gl crash with bad texture.","message":"Fixed gl crash with bad texture.\n","repos":"kfprimm\/maxb3d,kfprimm\/maxb3d","old_file":"gldriver.mod\/gldriver.bmx","new_file":"gldriver.mod\/gldriver.bmx","new_contents":"\nStrict\n\nRem\n\tbbdoc: OpenGL 1.1 driver for MaxB3D\nEnd Rem\nModule MaxB3D.GLDriver\nModuleInfo \"Author: Kevin Primm\"\nModuleInfo \"License: MIT\"\n\nImport MaxB3D.Core\nImport GFX.GLMax2DEx\n\nPrivate\nFunction ModuleLog(message$)\n\tTMaxB3DLogger.Write \"gldriver\",message\nEnd Function\n\nPublic\n\nGlobal GL_LIGHT[]=[GL_LIGHT0,GL_LIGHT1,GL_LIGHT2,GL_LIGHT3,GL_LIGHT4,GL_LIGHT5,GL_LIGHT6,GL_LIGHT7]\n\nType TGLMaxB3DDriver Extends TMaxB3DDriver\n\tField _currentdata:TMaxB3DShaderData= New TMaxB3DShaderData\n\t\n\tMethod SetGraphics(g:TGraphics)\n\t\tSuper.SetGraphics g\n\t\tIf g<>Null Startup\n\tEnd Method\n\t\n\tFunction BindTexture(index,tex)\n\t\tIf index=-1\n\t\t\tFor Local i=0 To 7\n\t\t\t\tBindTexture i,tex\n\t\t\tNext\n\t\t\tReturn\n\t\tEndIf\n\t\tGlobal currenttexture[] = [-1,-1,-1,-1,-1,-1,-1,-1]\n\t\tIf tex<>currenttexture[index]\n\t\t\tglBindTexture GL_TEXTURE_2D,tex\n\t\t\tcurrenttexture[index]=tex\n\t\tEndIf\n\tEnd Function\n\t\n\tMethod Startup()\n\t\tGlobal _firsttime=True\n\t\tIf _firsttime\n\t\t\tLocal caps:TGLCaps=TGLCaps(_caps)\n\t\t\tModuleLog \"Initializing GL driver\"\n\t\t\tModuleLog \"Vendor: \"+String.FromCString(Byte Ptr(glGetString(GL_VENDOR)))\n\t\t\tModuleLog \"Renderer: \"+String.FromCString(Byte Ptr(glGetString(GL_RENDERER))) \n\t\t\tModuleLog \"Version: \"+String.FromCString(Byte Ptr(glGetString(GL_VERSION)))\n\t\t\tModuleLog \"Extensions supported: \"+\" \".Join(caps.Extensions)\n\t\t\tEndMax2D \n\t\t\t_firsttime=False\t\t\t\n\t\tEndIf\t\t\n\t\tEnableStates\n\tEnd Method\n\t\n\tFunction EnableStates()\t\n\t\tglEnable GL_LIGHTING\n\t\tglEnable GL_DEPTH_TEST\n\t\tglEnable GL_CULL_FACE\n\t\tglEnable GL_SCISSOR_TEST\n\t\t\n\t\tglEnable GL_NORMALIZE\n\t\t\n\t\tglEnableClientState GL_VERTEX_ARRAY\n\t\tglEnableClientState GL_COLOR_ARRAY\n\t\tglEnableClientState GL_NORMAL_ARRAY\n\t\t\n\t\tglFrontFace GL_CW\n\t\t\n\t\tglLightModeli GL_LIGHT_MODEL_COLOR_CONTROL,GL_SEPARATE_SPECULAR_COLOR\n\t\tglLightModeli GL_LIGHT_MODEL_LOCAL_VIEWER,GL_TRUE\n\t\n\t\tglClearDepth 1.0\n\t\tglDepthFunc GL_LEQUAL\n\t\tglHint GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST\n\t\n\t\tglAlphaFunc GL_GEQUAL,0.5\n\t\t\n\t\tBindTexture -1,0\n\tEnd Function\t\n\t\n\tMethod MakeBuffer:TBuffer(src:Object,width,height,flags)\n\t\tLocal buffer:TBuffer\n\t\tSelect True\n\t\tCase TTextureFrame(src)<>Null\n\t\t\tbuffer=TGLBuffer(TTextureFrame(src)._buffer)\n\t\t\tIf buffer=Null\n\t\t\t\tLocal res:TGLTextureRes=UpdateTextureRes(TTextureFrame(src),0)\n\t\t\t\tbuffer=TGLMax2DExDriver(_parent).MakeGLBuffer(res._id,width,height,flags)\n\t\t\tEndIf\n\t\tDefault\n\t\t\tbuffer=TMax2DExDriver(_parent).MakeBuffer(src,width,height,flags)\n\t\tEnd Select\n\t\tReturn buffer\n\tEnd Method\n\t\n\tMethod Abbr$()\n\t\tReturn \"gl\"\n\tEnd Method\n\t\n\tMethod GetCaps:TCaps()\n\t\tLocal caps:TGLCaps=New TGLCaps\n\t\tcaps.Extensions=String.FromCString(glGetString(GL_EXTENSIONS)).Split(\" \")\n\t\tIf caps.HasExtension(\"GL_ARB_point_sprite\")<>-1\n\t\t\tcaps.PointSprites=True\n\t\t\tglGetFloatv GL_POINT_SIZE_MAX_ARB, Varptr caps.MaxPointSize\n\t\tEndIf\n\t\tReturn caps\n\tEnd Method\n\t\n\tMethod SetMax2D(enable)\n\t\tIf enable\n\t\t\tglPopClientAttrib\n\t\t\tglPopAttrib\n\t\t\tIf _shaderdriver _shaderdriver.Use(Null,Null)\t\n\t\t\tTGLMax2DExDriver(_parent).ResetGLContext _current\n\t\t\tglMatrixMode GL_TEXTURE\n\t\t\tglLoadIdentity\n\t\t\tglMatrixMode GL_COLOR\t\n\t\t\tglPopMatrix\t\t\t\t\t\n\t\tElse\t\t\t\n\t\t\tglPushAttrib GL_ALL_ATTRIB_BITS\n\t\t\tglPushClientAttrib GL_CLIENT_ALL_ATTRIB_BITS\n\t\t\tglMatrixMode GL_TEXTURE\n\t\t\tglPushMatrix\n\t\t\tglMatrixMode GL_COLOR\n\t\t\tglPushMatrix \n\t\t\t\n\t\t\tEnableStates()\n\t\tEndIf\n\tEnd Method\t\n\tMethod SetCamera(camera:TCamera, config:TWorldConfig)\n\t\tIf config.Dither\n\t\t\tglEnable GL_DITHER\n\t\tElse\n\t\t\tglDisable GL_DITHER\n\t\tEndIf\n\t\t\n\t\tLocal vy#=config.Height-camera._viewheight-camera._viewy\n\t\tglViewport(camera._viewx,vy,camera._viewwidth,camera._viewheight)\n\t\tglScissor(camera._viewx,vy,camera._viewwidth,camera._viewheight)\n\t\tglClearColor(camera._brush._r,camera._brush._g,camera._brush._b,1.0)\n\t\t\n\t\tIf camera._clsmode&CLSMODE_COLOR And camera._clsmode&CLSMODE_DEPTH\n\t\t\tglDepthMask GL_TRUE\n\t\t\tglClear GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT\n\t\tElse\n\t\t\tIf camera._clsmode&CLSMODE_COLOR\n\t\t\t\tglClear GL_COLOR_BUFFER_BIT\n\t\t\tElse\n\t\t\t\tIf camera._clsmode&CLSMODE_DEPTH\n\t\t\t\t\tglDepthMask GL_TRUE\n\t\t\t\t\tglClear GL_DEPTH_BUFFER_BIT\n\t\t\t\tEndIf\n\t\t\tEndIf\n\t\tEndIf\n\t\t\n\t\tIf camera._fogmode<>FOGMODE_NONE\n\t\t\tglEnable GL_FOG\n\t\t\tglFogi GL_FOG_MODE,GL_LINEAR\n\t\t\tglFogf GL_FOG_START,camera._fognear\n\t\t\tglFogf GL_FOG_END,camera._fogfar\n\t\t\tLocal rgb#[]=[camera._fogr,camera._fogg,camera._fogb]\n\t\t\tglFogfv GL_FOG_COLOR,rgb\n\t\tElse\n\t\t\tglDisable GL_FOG\n\t\tEndIf\n\t\t\n\t\tcamera.UpdateMatrices()\n\t\t\n\t\tglMatrixMode GL_PROJECTION\n\t\tglLoadMatrixf camera._projection.ToPtr()\t\n\t\tglMatrixMode GL_MODELVIEW\t\t\n\t\tglLoadMatrixf camera._modelview.ToPtr()\n\n\t\t' Temporary hack\n\t\t'glGetFloatv GL_PROJECTION_MATRIX,camera._projection._m\t\t\n\t\t'camera._frustum=TFrustum.Extract(camera._modelview,camera._projection)\n\tEnd Method\t\n\t\n\tMethod SetLight(light:TLight,index)\n\t\tIf light=Null\n\t\t\tglDisable GL_LIGHT[index]\n\t\t\tReturn\n\t\tElse\n\t\t\tIf light._hidden=True \n\t\t\t\tglDisable GL_LIGHT[index]\n\t\t\t\tReturn False\n\t\t\tEndIf\n\t\tEndIf\n\t\t\n\t\tglEnable GL_LIGHT[index]\n\t\t\n\t\tglPushMatrix\n\t\tglMultMatrixf light.GetMatrix(True).ToPtr()\n\t\t\n\t\tLocal white_light#[]=[1.0,1.0,1.0,1.0]\n\t\tglLightfv GL_LIGHT[index],GL_SPECULAR,white_light\n\t\t\n\t\tLocal z#=1.0\n\t\tLocal w#=0.0\n\t\tIf light._mode>LIGHT_DIRECTIONAL\n\t\t\tz=0.0\n\t\t\tw=1.0\n\t\tEndIf\n\t\t\n\t\tLocal rgba#[]=[light._brush._r,light._brush._g,light._brush._b,1.0]\n\t\tLocal pos#[]=[0.0,0.0,-z,w]\n\t\t\n\t\tglLightfv GL_LIGHT[index],GL_POSITION,pos\n\t\tglLightfv GL_LIGHT[index],GL_DIFFUSE,rgba\n\t\n\t\tIf light._mode<>LIGHT_DIRECTIONAL\n\t\t\tLocal light_range#[]=[0.0]\n\t\t\tLocal range#[]=[light._range]\n\t\t\tglLightfv GL_LIGHT[index],GL_CONSTANT_ATTENUATION,light_range\n\t\t\tglLightfv GL_LIGHT[index],GL_LINEAR_ATTENUATION,range\n\t\tEndIf\t\t\n\n\t\tIf light._mode=LIGHT_SPOT\t\t\n\t\t\tLocal dir#[]=[0.0,0.0,-1.0]\n\t\t\tLocal outer#[]=[light._outer\/2.0]\n\t\t\tLocal exponent#[]=[10.0]\t\n\t\t\tglLightfv GL_LIGHT[index],GL_SPOT_DIRECTION,dir\n\t\t\tglLightfv GL_LIGHT[index],GL_SPOT_CUTOFF,outer\n\t\t\tglLightfv GL_LIGHT[index],GL_SPOT_EXPONENT,exponent\n\t\tEndIf\n\t\t\n\t\tglPopMatrix\n\tEnd Method\n\t\n\tMethod SetBrush(brush:TBrush,hasalpha,config:TWorldConfig)\n\t\tLocal alpha_test\n\t\t\t\n\t\tLocal ambient#[]=[config.AmbientRed\/255.0,config.AmbientGreen\/255.0,config.AmbientBlue\/255.0]\t\t\t\n\t\t\t\t\t\n\t\tIf hasalpha\n\t\t\tglEnable GL_BLEND\n\t\t\tglDepthMask GL_FALSE\n\t\tElse\n\t\t\tglDisable GL_BLEND\n\t\t\tglDepthMask GL_TRUE\n\t\tEndIf\n\t\t\n\t\tSelect brush._blend\n\t\t\tCase BLEND_NONE,BLEND_ALPHA\n\t\t\t\tglBlendFunc GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA\n\t\t\tCase BLEND_MULTIPLY\n\t\t\t\tglBlendFunc GL_DST_COLOR,GL_ZERO\n\t\t\tCase BLEND_ADD\n\t\t\t\tglBlendFunc GL_SRC_ALPHA,GL_ONE\n\t\tEnd Select\n\t\t\n\t\tIf brush._fx&FX_FULLBRIGHT\n\t\t\tambient[0]=1.0\n\t\t\tambient[1]=1.0\n\t\t\tambient[2]=1.0\t\t\n\t\tEndIf\n\t\t\n\t\tIf brush._fx&FX_VERTEXCOLOR\n\t\t\tglEnable GL_COLOR_MATERIAL\n\t\tElse\n\t\t\tglDisable GL_COLOR_MATERIAL\n\t\tEndIf\n\t\t\n\t\tIf brush._fx&FX_FLATSHADED\n\t\t\tglShadeModel GL_FLAT\n\t\tElse\n\t\t\tglShadeModel GL_SMOOTH\n\t\tEndIf\n\n\t\tIf brush._fx&FX_NOFOG\n\t\t\tglDisable GL_FOG\n\t\tEndIf\n\t\t\n\t\tIf brush._fx&FX_NOCULLING\n\t\t\tglDisable GL_CULL_FACE\n\t\tElse\n\t\t\tglEnable GL_CULL_FACE\n\t\tEndIf\n\t\t\n\t\tIf brush._fx&FX_WIREFRAME Or config.Wireframe\n\t\t\tglPolygonMode GL_FRONT_AND_BACK,GL_LINE\n\t\tElse\n\t\t\tglPolygonMode GL_FRONT_AND_BACK,GL_FILL\n\t\tEndIf\t\t\t\n\t\t\n\t\tLocal no_mat#[]=[0.0,0.0]\n\t\tLocal mat_ambient#[]=[brush._r,brush._g,brush._b,brush._a]\n\t\tLocal mat_diffuse#[]=[brush._r,brush._g,brush._b,brush._a]\n\t\tLocal mat_specular#[]=[brush._shine,brush._shine,brush._shine,brush._shine]\n\t\tLocal mat_shininess#[]=[100.0]\n\t\t\t\n\t\tglMaterialfv GL_FRONT,GL_AMBIENT,mat_ambient\n\t\tglMaterialfv GL_FRONT,GL_DIFFUSE,mat_diffuse\n\t\tglMaterialfv GL_FRONT,GL_SPECULAR,mat_specular\n\t\tglMaterialfv GL_FRONT,GL_SHININESS,mat_shininess\n\t\tglLightModelfv GL_LIGHT_MODEL_AMBIENT,ambient\n\t\t\n\t\tFor Local i=0 To 7\n\t\t\tglActiveTextureARB GL_TEXTURE0+i\n\n\t\t\tLocal texture:TTexture=brush._texture[i]\n\t\t\tIf texture=Null Or texture._blend=BLEND_NONE\n\t\t\t\tglDisable GL_TEXTURE_2D\n\t\t\t\tBindTexture i,0\n\t\t\t\tContinue\n\t\t\tEndIf\n\t\t\t\n\t\t\tLocal texres:TGLTextureRes=TGLTextureRes(UpdateTextureRes(texture._frame[brush._textureframe[i]],texture._flags))\n\t\t\t\n\t\t\tglEnable GL_TEXTURE_2D\n\t\t\t\n\t\t\tBindTexture i,texres._id\t\n\t\t\t\n\t\t\tglMatrixMode GL_TEXTURE\n\t\t\tglLoadIdentity\n\t\t\tglTranslatef texture._px,-texture._py,0\n\t\t\tglScalef -texture._sx,texture._sy,1\n\t\t\t\n\t\t\talpha_test :| texture._flags&TEXTURE_ALPHA Or texture._flags&TEXTURE_MASKED\n\t\t\n\t\t\tIf texture._flags&TEXTURE_MIPMAP\n\t\t\t\tglTexParameteri GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR\n\t\t\t\tglTexParameteri GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_LINEAR\n\t\t\tElse\n\t\t\t\tglTexParameteri GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR\n\t\t\t\tglTexParameteri GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR\n\t\t\tEndIf\n\t\t\t\n\t\t\tIf texture._flags&TEXTURE_CLAMPU\n\t\t\t\tglTexParameteri GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_CLAMP_TO_EDGE\n\t\t\tElse\t\t\t\t\t\t\n\t\t\t\tglTexParameteri GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_REPEAT\n\t\t\tEndIf\n\t\t\t\n\t\t\tIf texture._flags&TEXTURE_CLAMPV\n\t\t\t\tglTexParameteri GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_CLAMP_TO_EDGE\n\t\t\tElse\n\t\t\t\tglTexParameteri GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_REPEAT\n\t\t\tEndIf\n\t\n\t\t\tIf texture._flags&TEXTURE_SPHEREMAP\t\t\t\t\n\t\t\t\tglEnable GL_TEXTURE_GEN_S\n\t\t\t\tglEnable GL_TEXTURE_GEN_T\n\t\t\t\tglTexGeni GL_S,GL_TEXTURE_GEN_MODE,GL_SPHERE_MAP\n\t\t\t\tglTexGeni GL_T,GL_TEXTURE_GEN_MODE,GL_SPHERE_MAP\n\t\t\tElse\n\t\t\t\tglDisable GL_TEXTURE_GEN_S\n\t\t\t\tglDisable GL_TEXTURE_GEN_T\n\t\t\tEndIf\n\n\t\t\tSelect texture._blend\n\t\t\tCase BLEND_NONE glTexEnvf(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_REPLACE)\n\t\t\tCase BLEND_ALPHA \tglTexEnvf(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_MODULATE)\n\t\t\tCase BLEND_MULTIPLY glTexEnvf(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_MODULATE)\n\t\t\t'Case BLEND_MULTIPLY glTexEnvf(GL_TEXTURE_ENV,GL_COMBINE_RGB_EXT,GL_MODULATE)\n\t\t\tCase BLEND_ADD glTexEnvf(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_ADD)\n\t\t\tCase BLEND_DOT3\n\t\t\t\tglTexEnvf GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT\n\t\t\t\tglTexEnvf GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_DOT3_RGB_EXT\n\t\t\tCase BLEND_MULTIPLY2\n\t\t\t\tglTexEnvi GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_COMBINE\n\t\t\t\tglTexEnvi GL_TEXTURE_ENV,GL_COMBINE_RGB,GL_MODULATE\n\t\t\t\tglTexEnvi GL_TEXTURE_ENV,GL_RGB_SCALE,2.0\n\t\t\tDefault glTexEnvf GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_MODULATE\n\t\t\tEnd Select\t\t\t\n\t\tNext\t\n\t\t\n\t\tIf alpha_test\n\t\t\tglEnable GL_ALPHA_TEST\n\t\tElse\n\t\t\tglDisable GL_ALPHA_TEST\n\t\tEndIf\n\t\t\t\t\n\t\tIf _shaderdriver _shaderdriver.Use(brush._shader,_currentdata)\t\n\tEnd Method\n\t\n\tMethod RenderSurface(resource:TSurfaceRes,brush:TBrush)\n\t\tLocal res:TGLSurfaceRes=TGLSurfaceRes(resource)\t\n\t\t\n\t\tFor Local i=0 To 7\n\t\t\tglClientActiveTextureARB GL_TEXTURE0+i\n\t\t\t\n\t\t\tLocal texture:TTexture=brush._texture[i]\n\t\t\tIf texture=Null Or res._vbo[4+texture._coords] = 0\n\t\t\t\tglDisableClientState GL_TEXTURE_COORD_ARRAY\n\t\t\t\tContinue\n\t\t\tEndIf\n\t\t\t\n\t\t\tglEnableClientState GL_TEXTURE_COORD_ARRAY\n\t\t\tglBindBufferARB GL_ARRAY_BUFFER_ARB,res._vbo[4+texture._coords]\n\t\t\tglTexCoordPointer 2,GL_FLOAT,0,Null\n\t\tNext\n\t\t\n\t\tglBindBufferARB GL_ARRAY_BUFFER_ARB,res._vbo[0]\n\t\tglVertexPointer 3,GL_FLOAT,0,Null\n\t\t\n\t\tglBindBufferARB GL_ARRAY_BUFFER_ARB,res._vbo[1]\n\t\tglNormalPointer GL_FLOAT,0,Null\n\t\t\n\t\tglBindBufferARB GL_ARRAY_BUFFER_ARB,res._vbo[2]\n\t\tglColorPointer 4,GL_FLOAT,0,Null\n\t\n\t\tglBindBufferARB GL_ELEMENT_ARRAY_BUFFER_ARB,res._vbo[3]\n\t\tglDrawElements GL_TRIANGLES,res._trianglecnt*3,GL_UNSIGNED_INT,Null\n\t\t\n\t\tReturn res._trianglecnt\n\tEnd Method\n\t\n\tMethod BeginEntityRender(entity:TEntity)\t\t\n\t\tIf entity._order<>0\n\t\t\tglDisable GL_DEPTH_TEST\n\t\t\tglDepthMask GL_FALSE\n\t\tElse\n\t\t\tglEnable GL_DEPTH_TEST\n\t\t\tglDepthMask GL_TRUE\n\t\tEndIf\n\t\t\n\t\tglMatrixMode GL_MODELVIEW\n\t\tglPushMatrix\n\t\tglMultMatrixf entity.GetMatrix(True,False).ToPtr()\n\t\t\n\t\tGlobal matrix:TMatrix=New TMatrix\n\t\tglGetFloatv GL_MODELVIEW_MATRIX,matrix._m\n\tEnd Method\n\tMethod EndEntityRender(entity:TEntity)\n\t\tglMatrixMode GL_MODELVIEW\n\t\tglPopMatrix\n\tEnd Method\n\t\n\tMethod RenderFlat(flat:TFlat)\n\t\tLocal x#,y#,z#\n\t\tflat.GetScale x,y,z,True\n\t\t\n\t\tglBegin GL_QUADS\n\t\t\tglNormal3f 0,1,0\n\t\t\tglTexCoord2f 0,0\n\t\t\tglVertex3f -1,0, 1\n\t\t\tglTexCoord2f x,0\t\n\t\t\tglVertex3f 1, 0, 1\n\t\t\tglTexCoord2f x,z\n\t\t\tglVertex3f 1, 0, -1\n\t\t\tglTexCoord2f 0,z\n\t\t\tglVertex3f -1,0, -1\n\t\tglEnd\n\t\tReturn 2\n\tEnd Method\n\t\n\tMethod RenderSprite(sprite:TSprite)\n\t\tIf False\n\t\t\tglPointParameterfvARB GL_POINT_DISTANCE_ATTENUATION_ARB, [0.0, 0.0, 1.0]\n\t\t\t\n\t\t\tglPointSize 1.0\n\t\t\t\n\t\t\tglPointParameterfARB GL_POINT_FADE_THRESHOLD_SIZE_ARB,60.0\n\t\t\tglPointParameterfARB GL_POINT_SIZE_MIN_ARB,0.0\n\t\t\tglPointParameterfARB GL_POINT_SIZE_MAX_ARB,9999.0\n\t\t\t\n\t\t\tglTexEnvf GL_POINT_SPRITE_ARB,GL_COORD_REPLACE_ARB,GL_TRUE\n\t\t\t\n\t\t\tglEnable GL_POINT_SPRITE_ARB\n\t\t\t\n\t\t\tglBegin GL_POINTS\t\t\t\n\t\t\tglVertex3f 0,0,0\n\t\t\tglEnd\n\t\t\t\n\t\t\tglDisable GL_POINT_SPRITE_ARB\n\t\tElse\n\t\t\tglBegin GL_QUADS\n\t\t\t\tglNormal3f 0,0,-1\n\t\t\t\tglTexCoord2f 0,1\n\t\t\t\tglVertex3f 1, -1, 0\t\t\t\n\t\t\t\tglTexCoord2f 0,0\n\t\t\t\tglVertex3f 1, 1, 0\t\t\t\n\t\t\t\tglTexCoord2f 1,0\n\t\t\t\tglVertex3f -1,1, 0\t\t\t\n\t\t\t\tglTexCoord2f 1,1\n\t\t\t\tglVertex3f -1,-1, 0\n\t\t\tglEnd\n\t\tEndIf\n\tEnd Method\n\t\n\tMethod RenderTerrain(terrain:TTerrain)\n\t\n\t\tglDisableClientState GL_TEXTURE_COORD_ARRAY\n\t\tFor Local i=0 To 7\n\t\t\tLocal texture:TTexture=terrain._brush._texture[i]\n\t\t\tIf texture=Null Continue\n\t\t\tglEnableClientState(GL_TEXTURE_COORD_ARRAY)\n\t\t\tglClientActiveTextureARB(GL_TEXTURE0+i)\n\t\t\tglTexCoordPointer(2,GL_FLOAT,20,terrain._data)\n\t\tNext\n\t\t\n\t\tglEnableClientState GL_VERTEX_ARRAY\n\t\tglDisableClientState GL_COLOR_ARRAY\n\t\tglDisableClientState GL_NORMAL_ARRAY\n\t\t\n\t\tglVertexPointer(3,GL_FLOAT, 20, terrain._data+2)\n\t\tglDrawArrays(GL_TRIANGLES, 0, 3*terrain._count)\n\t\t\n\t\tglEnableClientState GL_VERTEX_ARRAY\n\t\tglEnableClientState GL_COLOR_ARRAY \n\t\tglEnableClientState GL_NORMAL_ARRAY \n\tEnd Method\n\t\n\tMethod RenderBSPTree(tree:TBSPTree)\n\t\tLocal node:TBSPNode=tree.Node\n\t\tIf node=Null Return\n\t\tLocal triangles\n\t\ttriangles:+RenderBSPTree(node.In)\t\t\n\t\t\n\t\tFor Local poly:TBSPPolygon=EachIn node.On\n\t\t\tglBegin GL_POLYGON\n\t\t\tglNormal3f poly.Plane.x,poly.Plane.y,poly.Plane.z\n\t\t\tFor Local i=0 To poly.Count()-1\n\t\t\t\tglTexCoord2f (poly.Plane.x-poly.Center.x)*poly.Point[i].x+(poly.Plane.y-poly.Center.y)*poly.Point[i].y+(poly.Plane.z-poly.Center.z)*poly.Point[i].z, (poly.Plane.x-poly.Center.x)*poly.Point[i].x+(poly.Plane.y-poly.Center.y)*poly.Point[i].y+(poly.Plane.z-poly.Center.z)*poly.Point[i].z\n\t\t\t\tglVertex3f poly.Point[i].x,poly.Point[i].y,poly.Point[i].z\n\t\t\tNext\n\t\t\ttriangles:+poly.Count()-2\n\t\t\tglEnd\n\t\tNext\t\n\t\t\n\t\ttriangles:+RenderBSPTree(node.Out)\n\t\tReturn triangles\n\tEnd Method\n\n\tMethod UpdateTextureRes:TGLTextureRes(frame:TTextureFrame,flags)\n\t\tIf frame=Null Return Null\n\t\t\n\t\tLocal glres:TGLTextureRes=TGLTextureRes(frame._res)\n\t\tIf glres=Null\n\t\t\tglres=New TGLTextureRes\n\t\t\tframe._res=glres\n\t\t\tframe._updateres=True\n\t\tEndIf\t\t\n\t\tIf Not frame._updateres Return glres\n\t\t\n\t\tIf glres._id=0 glGenTextures(1,Varptr glres._id)\n\t\tBindTexture 0,glres._id\n\t\tLocal pixmap:TPixmap=frame._pixmap\n\t\tgluBuild2DMipmaps(GL_TEXTURE_2D,GL_RGBA8,pixmap.width,pixmap.height,GL_BGRA,GL_UNSIGNED_BYTE,pixmap.pixels)\n\t\t\n\t\tframe._updateres=0\n\t\tReturn glres\n\tEnd Method\n\t\n\tMethod UpdateSurfaceRes:TGLSurfaceRes(surface:TSurface)\n\t\tLocal res:TGLSurfaceRes=TGLSurfaceRes(surface._res)\n\t\tIf res=Null res=New TGLSurfaceRes;surface._res=res\n\t\tIf surface._reset=0 Return res\n\t\t\n\t\tIf res._vbo[0]=0 glGenBuffersARB(4,res._vbo)\n\t\n\t\tIf surface._reset=-1 Then surface._reset=1|2|4|8|16|32|64|128|256\n\t\n\t\tIf surface._reset&1 UploadVertexBuffer res._vbo[0],surface._vertexpos\n\t\tIf surface._reset&2 UploadVertexNormals res._vbo[1],surface._vertexnml\n\t\tIf surface._reset&4 UploadVertexBuffer res._vbo[2],surface._vertexclr\n\t\tIf surface._reset&8\n\t\t\tglBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB,res._vbo[3])\n\t\t\tglBufferDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB,surface._triangle.length*4,surface._triangle,GL_STATIC_DRAW_ARB)\n\t\tEndIf\n\t\t\n\t\tFor Local i=0 To surface._vertextex.length-1\n\t\t\tIf res._vbo[4+i]=0 glGenBuffersARB(1,Varptr res._vbo[4+i])\n\t\t\tIf surface._reset&Int(2^(4+i)) UploadVertexBuffer res._vbo[4+i],surface._vertextex[i]\n\t\tNext\t\n\t\t\n\t\tres._trianglecnt=surface._trianglecnt\n\t\tres._vertexcnt=surface._vertexcnt\t\t\n\t\tsurface._reset=0\t\t\n\t\tReturn res\n\tEnd Method\n\t\n\tMethod MergeSurfaceRes:TGLSurfaceRes(base:TSurface,animation:TSurface,data)\n\t\tIf animation=Null Return UpdateSurfaceRes(base)\n\t\tLocal res_base:TGLSurfaceRes=UpdateSurfaceRes(base)\n\t\tLocal res_anim:TGLSurfaceRes=UpdateSurfaceRes(animation)\n\t\tLocal res:TGLSurfaceRes=res_base.Copy()\n\t\tres._vbo[0]=res_anim._vbo[0]\n\t\tReturn res\n\tEnd Method\n\t\n\tMethod UploadVertexBuffer(vbo,data#[])\n\t\tglBindBufferARB(GL_ARRAY_BUFFER_ARB,vbo)\n\t\tglBufferDataARB(GL_ARRAY_BUFFER_ARB,data.length*4,data,GL_STATIC_DRAW_ARB)\n\tEnd Method\n\t\n\tMethod UploadVertexNormals(vbo,data#[])\n\t\tglBindBufferARB(GL_ARRAY_BUFFER_ARB,vbo)\n\t\tglBufferDataARB(GL_ARRAY_BUFFER_ARB,data.length*4,data,GL_STATIC_DRAW_ARB)\n\tEnd Method\nEnd Type\n\nType TGLCaps Extends TCaps\n\tField Extensions$[]\n\t\n\tMethod HasExtension(ext$)\n\t\tFor Local extension$=EachIn Extensions\n\t\t\tIf extension.Find(ext)<>-1 Return True\n\t\tNext\n\t\tReturn False \n\tEnd Method\n\t\n\tMethod Copy:TGLCaps()\n\t\tLocal caps:TGLCaps=New TGLCaps\n\t\tcaps.CopyBase(Self)\n\t\tcaps.Extensions=Extensions[..]\n\t\tReturn caps\t\t\n\tEnd Method\nEnd Type\n\nType TGLSurfaceRes Extends TSurfaceRes\n\tField _vbo[12]\n\tField _texcoord\n\t\n\tMethod Copy:TGLSurfaceRes()\n\t\tLocal res:TGLSurfaceRes=New TGLSurfaceRes\n\t\tres._vertexcnt=_vertexcnt;res._trianglecnt=_trianglecnt\n\t\tres._vbo=_vbo[..]\n\t\tres._texcoord=_texcoord\n\t\tReturn res\n\tEnd Method\nEnd Type\n\nType TGLTextureRes Extends TTextureRes\n\tField _id\nEnd Type\n\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GLMaxB3DDriver:TGLMaxB3DDriver()\n\tIf GLMax2DExDriver()\n\t\tGlobal driver:TGLMaxB3DDriver=New TGLMaxB3DDriver\n\t\tdriver._parent=GLMax2DExDriver()\n\t\tReturn driver\n\tEnd If\nEnd Function\n\nRem\n\tbbdoc: Utility function that sets the MaxB3D GL driver and calls Graphics.\nEnd Rem\nFunction GLGraphics3D:TGraphics(width,height,depth=0,hertz=60,flags=0)\n\tSetGraphicsDriver GLMaxB3DDriver(),GRAPHICS_BACKBUFFER|GRAPHICS_DEPTHBUFFER\n\tReturn Graphics(width,height,depth,hertz,flags)\nEnd Function\n\nLocal driver:TGLMaxB3DDriver=GLMaxB3DDriver()\nIf driver SetGraphicsDriver driver,GRAPHICS_BACKBUFFER|GRAPHICS_DEPTHBUFFER\n","old_contents":"\nStrict\n\nRem\n\tbbdoc: OpenGL 1.1 driver for MaxB3D\nEnd Rem\nModule MaxB3D.GLDriver\nModuleInfo \"Author: Kevin Primm\"\nModuleInfo \"License: MIT\"\n\nImport MaxB3D.Core\nImport GFX.GLMax2DEx\n\nPrivate\nFunction ModuleLog(message$)\n\tTMaxB3DLogger.Write \"gldriver\",message\nEnd Function\n\nPublic\n\nGlobal GL_LIGHT[]=[GL_LIGHT0,GL_LIGHT1,GL_LIGHT2,GL_LIGHT3,GL_LIGHT4,GL_LIGHT5,GL_LIGHT6,GL_LIGHT7]\n\nType TGLMaxB3DDriver Extends TMaxB3DDriver\n\tField _currentdata:TMaxB3DShaderData= New TMaxB3DShaderData\n\t\n\tMethod SetGraphics(g:TGraphics)\n\t\tSuper.SetGraphics g\n\t\tIf g<>Null Startup\n\tEnd Method\n\t\n\tFunction BindTexture(index,tex)\n\t\tIf index=-1\n\t\t\tFor Local i=0 To 7\n\t\t\t\tBindTexture i,tex\n\t\t\tNext\n\t\t\tReturn\n\t\tEndIf\n\t\tGlobal currenttexture[] = [-1,-1,-1,-1,-1,-1,-1,-1]\n\t\tIf tex<>currenttexture[index]\n\t\t\tglBindTexture GL_TEXTURE_2D,tex\n\t\t\tcurrenttexture[index]=tex\n\t\tEndIf\n\tEnd Function\n\t\n\tMethod Startup()\n\t\tGlobal _firsttime=True\n\t\tIf _firsttime\n\t\t\tLocal caps:TGLCaps=TGLCaps(_caps)\n\t\t\tModuleLog \"Initializing GL driver\"\n\t\t\tModuleLog \"Vendor: \"+String.FromCString(Byte Ptr(glGetString(GL_VENDOR)))\n\t\t\tModuleLog \"Renderer: \"+String.FromCString(Byte Ptr(glGetString(GL_RENDERER))) \n\t\t\tModuleLog \"Version: \"+String.FromCString(Byte Ptr(glGetString(GL_VERSION)))\n\t\t\tModuleLog \"Extensions supported: \"+\" \".Join(caps.Extensions)\n\t\t\tEndMax2D \n\t\t\t_firsttime=False\t\t\t\n\t\tEndIf\t\t\n\t\tEnableStates\n\tEnd Method\n\t\n\tFunction EnableStates()\t\n\t\tglEnable GL_LIGHTING\n\t\tglEnable GL_DEPTH_TEST\n\t\tglEnable GL_CULL_FACE\n\t\tglEnable GL_SCISSOR_TEST\n\t\t\n\t\tglEnable GL_NORMALIZE\n\t\t\n\t\tglEnableClientState GL_VERTEX_ARRAY\n\t\tglEnableClientState GL_COLOR_ARRAY\n\t\tglEnableClientState GL_NORMAL_ARRAY\n\t\t\n\t\tglFrontFace GL_CW\n\t\t\n\t\tglLightModeli GL_LIGHT_MODEL_COLOR_CONTROL,GL_SEPARATE_SPECULAR_COLOR\n\t\tglLightModeli GL_LIGHT_MODEL_LOCAL_VIEWER,GL_TRUE\n\t\n\t\tglClearDepth 1.0\n\t\tglDepthFunc GL_LEQUAL\n\t\tglHint GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST\n\t\n\t\tglAlphaFunc GL_GEQUAL,0.5\n\t\t\n\t\tBindTexture -1,0\n\tEnd Function\t\n\t\n\tMethod MakeBuffer:TBuffer(src:Object,width,height,flags)\n\t\tLocal buffer:TBuffer\n\t\tSelect True\n\t\tCase TTextureFrame(src)<>Null\n\t\t\tbuffer=TGLBuffer(TTextureFrame(src)._buffer)\n\t\t\tIf buffer=Null\n\t\t\t\tLocal res:TGLTextureRes=UpdateTextureRes(TTextureFrame(src),0)\n\t\t\t\tbuffer=TGLMax2DExDriver(_parent).MakeGLBuffer(res._id,width,height,flags)\n\t\t\tEndIf\n\t\tDefault\n\t\t\tbuffer=TMax2DExDriver(_parent).MakeBuffer(src,width,height,flags)\n\t\tEnd Select\n\t\tReturn buffer\n\tEnd Method\n\t\n\tMethod Abbr$()\n\t\tReturn \"gl\"\n\tEnd Method\n\t\n\tMethod GetCaps:TCaps()\n\t\tLocal caps:TGLCaps=New TGLCaps\n\t\tcaps.Extensions=String.FromCString(glGetString(GL_EXTENSIONS)).Split(\" \")\n\t\tIf caps.HasExtension(\"GL_ARB_point_sprite\")<>-1\n\t\t\tcaps.PointSprites=True\n\t\t\tglGetFloatv GL_POINT_SIZE_MAX_ARB, Varptr caps.MaxPointSize\n\t\tEndIf\n\t\tReturn caps\n\tEnd Method\n\t\n\tMethod SetMax2D(enable)\n\t\tIf enable\n\t\t\tglPopClientAttrib\n\t\t\tglPopAttrib\n\t\t\tIf _shaderdriver _shaderdriver.Use(Null,Null)\t\n\t\t\tTGLMax2DExDriver(_parent).ResetGLContext _current\n\t\t\tglMatrixMode GL_TEXTURE\n\t\t\tglLoadIdentity\n\t\t\tglMatrixMode GL_COLOR\t\n\t\t\tglPopMatrix\t\t\t\t\t\n\t\tElse\t\t\t\n\t\t\tglPushAttrib GL_ALL_ATTRIB_BITS\n\t\t\tglPushClientAttrib GL_CLIENT_ALL_ATTRIB_BITS\n\t\t\tglMatrixMode GL_TEXTURE\n\t\t\tglPushMatrix\n\t\t\tglMatrixMode GL_COLOR\n\t\t\tglPushMatrix \n\t\t\t\n\t\t\tEnableStates()\n\t\tEndIf\n\tEnd Method\t\n\tMethod SetCamera(camera:TCamera, config:TWorldConfig)\n\t\tIf config.Dither\n\t\t\tglEnable GL_DITHER\n\t\tElse\n\t\t\tglDisable GL_DITHER\n\t\tEndIf\n\t\t\n\t\tLocal vy#=config.Height-camera._viewheight-camera._viewy\n\t\tglViewport(camera._viewx,vy,camera._viewwidth,camera._viewheight)\n\t\tglScissor(camera._viewx,vy,camera._viewwidth,camera._viewheight)\n\t\tglClearColor(camera._brush._r,camera._brush._g,camera._brush._b,1.0)\n\t\t\n\t\tIf camera._clsmode&CLSMODE_COLOR And camera._clsmode&CLSMODE_DEPTH\n\t\t\tglDepthMask GL_TRUE\n\t\t\tglClear GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT\n\t\tElse\n\t\t\tIf camera._clsmode&CLSMODE_COLOR\n\t\t\t\tglClear GL_COLOR_BUFFER_BIT\n\t\t\tElse\n\t\t\t\tIf camera._clsmode&CLSMODE_DEPTH\n\t\t\t\t\tglDepthMask GL_TRUE\n\t\t\t\t\tglClear GL_DEPTH_BUFFER_BIT\n\t\t\t\tEndIf\n\t\t\tEndIf\n\t\tEndIf\n\t\t\n\t\tIf camera._fogmode<>FOGMODE_NONE\n\t\t\tglEnable GL_FOG\n\t\t\tglFogi GL_FOG_MODE,GL_LINEAR\n\t\t\tglFogf GL_FOG_START,camera._fognear\n\t\t\tglFogf GL_FOG_END,camera._fogfar\n\t\t\tLocal rgb#[]=[camera._fogr,camera._fogg,camera._fogb]\n\t\t\tglFogfv GL_FOG_COLOR,rgb\n\t\tElse\n\t\t\tglDisable GL_FOG\n\t\tEndIf\n\t\t\n\t\tcamera.UpdateMatrices()\n\t\t\n\t\tglMatrixMode GL_PROJECTION\n\t\tglLoadMatrixf camera._projection.ToPtr()\t\n\t\tglMatrixMode GL_MODELVIEW\t\t\n\t\tglLoadMatrixf camera._modelview.ToPtr()\n\n\t\t' Temporary hack\n\t\t'glGetFloatv GL_PROJECTION_MATRIX,camera._projection._m\t\t\n\t\t'camera._frustum=TFrustum.Extract(camera._modelview,camera._projection)\n\tEnd Method\t\n\t\n\tMethod SetLight(light:TLight,index)\n\t\tIf light=Null\n\t\t\tglDisable GL_LIGHT[index]\n\t\t\tReturn\n\t\tElse\n\t\t\tIf light._hidden=True \n\t\t\t\tglDisable GL_LIGHT[index]\n\t\t\t\tReturn False\n\t\t\tEndIf\n\t\tEndIf\n\t\t\n\t\tglEnable GL_LIGHT[index]\n\t\t\n\t\tglPushMatrix\n\t\tglMultMatrixf light.GetMatrix(True).ToPtr()\n\t\t\n\t\tLocal white_light#[]=[1.0,1.0,1.0,1.0]\n\t\tglLightfv GL_LIGHT[index],GL_SPECULAR,white_light\n\t\t\n\t\tLocal z#=1.0\n\t\tLocal w#=0.0\n\t\tIf light._mode>LIGHT_DIRECTIONAL\n\t\t\tz=0.0\n\t\t\tw=1.0\n\t\tEndIf\n\t\t\n\t\tLocal rgba#[]=[light._brush._r,light._brush._g,light._brush._b,1.0]\n\t\tLocal pos#[]=[0.0,0.0,-z,w]\n\t\t\n\t\tglLightfv GL_LIGHT[index],GL_POSITION,pos\n\t\tglLightfv GL_LIGHT[index],GL_DIFFUSE,rgba\n\t\n\t\tIf light._mode<>LIGHT_DIRECTIONAL\n\t\t\tLocal light_range#[]=[0.0]\n\t\t\tLocal range#[]=[light._range]\n\t\t\tglLightfv GL_LIGHT[index],GL_CONSTANT_ATTENUATION,light_range\n\t\t\tglLightfv GL_LIGHT[index],GL_LINEAR_ATTENUATION,range\n\t\tEndIf\t\t\n\n\t\tIf light._mode=LIGHT_SPOT\t\t\n\t\t\tLocal dir#[]=[0.0,0.0,-1.0]\n\t\t\tLocal outer#[]=[light._outer\/2.0]\n\t\t\tLocal exponent#[]=[10.0]\t\n\t\t\tglLightfv GL_LIGHT[index],GL_SPOT_DIRECTION,dir\n\t\t\tglLightfv GL_LIGHT[index],GL_SPOT_CUTOFF,outer\n\t\t\tglLightfv GL_LIGHT[index],GL_SPOT_EXPONENT,exponent\n\t\tEndIf\n\t\t\n\t\tglPopMatrix\n\tEnd Method\n\t\n\tMethod SetBrush(brush:TBrush,hasalpha,config:TWorldConfig)\n\t\tLocal alpha_test\n\t\t\t\n\t\tLocal ambient#[]=[config.AmbientRed\/255.0,config.AmbientGreen\/255.0,config.AmbientBlue\/255.0]\t\t\t\n\t\t\t\t\t\n\t\tIf hasalpha\n\t\t\tglEnable GL_BLEND\n\t\t\tglDepthMask GL_FALSE\n\t\tElse\n\t\t\tglDisable GL_BLEND\n\t\t\tglDepthMask GL_TRUE\n\t\tEndIf\n\t\t\n\t\tSelect brush._blend\n\t\t\tCase BLEND_NONE,BLEND_ALPHA\n\t\t\t\tglBlendFunc GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA\n\t\t\tCase BLEND_MULTIPLY\n\t\t\t\tglBlendFunc GL_DST_COLOR,GL_ZERO\n\t\t\tCase BLEND_ADD\n\t\t\t\tglBlendFunc GL_SRC_ALPHA,GL_ONE\n\t\tEnd Select\n\t\t\n\t\tIf brush._fx&FX_FULLBRIGHT\n\t\t\tambient[0]=1.0\n\t\t\tambient[1]=1.0\n\t\t\tambient[2]=1.0\t\t\n\t\tEndIf\n\t\t\n\t\tIf brush._fx&FX_VERTEXCOLOR\n\t\t\tglEnable GL_COLOR_MATERIAL\n\t\tElse\n\t\t\tglDisable GL_COLOR_MATERIAL\n\t\tEndIf\n\t\t\n\t\tIf brush._fx&FX_FLATSHADED\n\t\t\tglShadeModel GL_FLAT\n\t\tElse\n\t\t\tglShadeModel GL_SMOOTH\n\t\tEndIf\n\n\t\tIf brush._fx&FX_NOFOG\n\t\t\tglDisable GL_FOG\n\t\tEndIf\n\t\t\n\t\tIf brush._fx&FX_NOCULLING\n\t\t\tglDisable GL_CULL_FACE\n\t\tElse\n\t\t\tglEnable GL_CULL_FACE\n\t\tEndIf\n\t\t\n\t\tIf brush._fx&FX_WIREFRAME Or config.Wireframe\n\t\t\tglPolygonMode GL_FRONT_AND_BACK,GL_LINE\n\t\tElse\n\t\t\tglPolygonMode GL_FRONT_AND_BACK,GL_FILL\n\t\tEndIf\t\t\t\n\t\t\n\t\tLocal no_mat#[]=[0.0,0.0]\n\t\tLocal mat_ambient#[]=[brush._r,brush._g,brush._b,brush._a]\n\t\tLocal mat_diffuse#[]=[brush._r,brush._g,brush._b,brush._a]\n\t\tLocal mat_specular#[]=[brush._shine,brush._shine,brush._shine,brush._shine]\n\t\tLocal mat_shininess#[]=[100.0]\n\t\t\t\n\t\tglMaterialfv GL_FRONT,GL_AMBIENT,mat_ambient\n\t\tglMaterialfv GL_FRONT,GL_DIFFUSE,mat_diffuse\n\t\tglMaterialfv GL_FRONT,GL_SPECULAR,mat_specular\n\t\tglMaterialfv GL_FRONT,GL_SHININESS,mat_shininess\n\t\tglLightModelfv GL_LIGHT_MODEL_AMBIENT,ambient\n\t\t\n\t\tFor Local i=0 To 7\n\t\t\tglActiveTextureARB GL_TEXTURE0+i\n\n\t\t\tLocal texture:TTexture=brush._texture[i]\n\t\t\tIf texture=Null Or texture._blend=BLEND_NONE\n\t\t\t\tglDisable GL_TEXTURE_2D\n\t\t\t\tBindTexture i,0\n\t\t\t\tContinue\n\t\t\tEndIf\n\t\t\t\n\t\t\tLocal texres:TGLTextureRes=TGLTextureRes(UpdateTextureRes(texture._frame[brush._textureframe[i]],texture._flags))\n\t\t\t\n\t\t\tglEnable GL_TEXTURE_2D\n\t\t\t\n\t\t\tBindTexture i,texres._id\t\n\t\t\t\n\t\t\tglMatrixMode GL_TEXTURE\n\t\t\tglLoadIdentity\n\t\t\tglTranslatef texture._px,-texture._py,0\n\t\t\tglScalef -texture._sx,texture._sy,1\n\t\t\t\n\t\t\talpha_test :| texture._flags&TEXTURE_ALPHA Or texture._flags&TEXTURE_MASKED\n\t\t\n\t\t\tIf texture._flags&TEXTURE_MIPMAP\n\t\t\t\tglTexParameteri GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR\n\t\t\t\tglTexParameteri GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_LINEAR\n\t\t\tElse\n\t\t\t\tglTexParameteri GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR\n\t\t\t\tglTexParameteri GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR\n\t\t\tEndIf\n\t\t\t\n\t\t\tIf texture._flags&TEXTURE_CLAMPU\n\t\t\t\tglTexParameteri GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_CLAMP_TO_EDGE\n\t\t\tElse\t\t\t\t\t\t\n\t\t\t\tglTexParameteri GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_REPEAT\n\t\t\tEndIf\n\t\t\t\n\t\t\tIf texture._flags&TEXTURE_CLAMPV\n\t\t\t\tglTexParameteri GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_CLAMP_TO_EDGE\n\t\t\tElse\n\t\t\t\tglTexParameteri GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_REPEAT\n\t\t\tEndIf\n\t\n\t\t\tIf texture._flags&TEXTURE_SPHEREMAP\t\t\t\t\n\t\t\t\tglEnable GL_TEXTURE_GEN_S\n\t\t\t\tglEnable GL_TEXTURE_GEN_T\n\t\t\t\tglTexGeni GL_S,GL_TEXTURE_GEN_MODE,GL_SPHERE_MAP\n\t\t\t\tglTexGeni GL_T,GL_TEXTURE_GEN_MODE,GL_SPHERE_MAP\n\t\t\tElse\n\t\t\t\tglDisable GL_TEXTURE_GEN_S\n\t\t\t\tglDisable GL_TEXTURE_GEN_T\n\t\t\tEndIf\n\n\t\t\tSelect texture._blend\n\t\t\tCase BLEND_NONE glTexEnvf(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_REPLACE)\n\t\t\tCase BLEND_ALPHA \tglTexEnvf(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_MODULATE)\n\t\t\tCase BLEND_MULTIPLY glTexEnvf(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_MODULATE)\n\t\t\t'Case BLEND_MULTIPLY glTexEnvf(GL_TEXTURE_ENV,GL_COMBINE_RGB_EXT,GL_MODULATE)\n\t\t\tCase BLEND_ADD glTexEnvf(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_ADD)\n\t\t\tCase BLEND_DOT3\n\t\t\t\tglTexEnvf GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT\n\t\t\t\tglTexEnvf GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_DOT3_RGB_EXT\n\t\t\tCase BLEND_MULTIPLY2\n\t\t\t\tglTexEnvi GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_COMBINE\n\t\t\t\tglTexEnvi GL_TEXTURE_ENV,GL_COMBINE_RGB,GL_MODULATE\n\t\t\t\tglTexEnvi GL_TEXTURE_ENV,GL_RGB_SCALE,2.0\n\t\t\tDefault glTexEnvf GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_MODULATE\n\t\t\tEnd Select\t\t\t\n\t\tNext\t\n\t\t\n\t\tIf alpha_test\n\t\t\tglEnable GL_ALPHA_TEST\n\t\tElse\n\t\t\tglDisable GL_ALPHA_TEST\n\t\tEndIf\n\t\t\t\t\n\t\tIf _shaderdriver _shaderdriver.Use(brush._shader,_currentdata)\t\n\tEnd Method\n\t\n\tMethod RenderSurface(resource:TSurfaceRes,brush:TBrush)\n\t\tLocal res:TGLSurfaceRes=TGLSurfaceRes(resource)\t\n\t\t\n\t\tFor Local i=0 To 7\n\t\t\tglClientActiveTextureARB GL_TEXTURE0+i\n\t\t\t\n\t\t\tLocal texture:TTexture=brush._texture[i]\n\t\t\tIf texture=Null \n\t\t\t\tglDisableClientState GL_TEXTURE_COORD_ARRAY\n\t\t\t\tContinue\n\t\t\tEndIf\n\t\t\t\n\t\t\tglEnableClientState GL_TEXTURE_COORD_ARRAY\n\t\t\tglBindBufferARB GL_ARRAY_BUFFER_ARB,res._vbo[4+texture._coords]\n\t\t\tglTexCoordPointer 2,GL_FLOAT,0,Null\n\t\tNext\n\t\t\n\t\tglBindBufferARB GL_ARRAY_BUFFER_ARB,res._vbo[0]\n\t\tglVertexPointer 3,GL_FLOAT,0,Null\n\t\t\n\t\tglBindBufferARB GL_ARRAY_BUFFER_ARB,res._vbo[1]\n\t\tglNormalPointer GL_FLOAT,0,Null\n\t\t\n\t\tglBindBufferARB GL_ARRAY_BUFFER_ARB,res._vbo[2]\n\t\tglColorPointer 4,GL_FLOAT,0,Null\n\t\n\t\tglBindBufferARB GL_ELEMENT_ARRAY_BUFFER_ARB,res._vbo[3]\n\t\tglDrawElements GL_TRIANGLES,res._trianglecnt*3,GL_UNSIGNED_INT,Null\n\t\t\n\t\tReturn res._trianglecnt\n\tEnd Method\n\t\n\tMethod BeginEntityRender(entity:TEntity)\t\t\n\t\tIf entity._order<>0\n\t\t\tglDisable GL_DEPTH_TEST\n\t\t\tglDepthMask GL_FALSE\n\t\tElse\n\t\t\tglEnable GL_DEPTH_TEST\n\t\t\tglDepthMask GL_TRUE\n\t\tEndIf\n\t\t\n\t\tglMatrixMode GL_MODELVIEW\n\t\tglPushMatrix\n\t\tglMultMatrixf entity.GetMatrix(True,False).ToPtr()\n\t\t\n\t\tGlobal matrix:TMatrix=New TMatrix\n\t\tglGetFloatv GL_MODELVIEW_MATRIX,matrix._m\n\tEnd Method\n\tMethod EndEntityRender(entity:TEntity)\n\t\tglMatrixMode GL_MODELVIEW\n\t\tglPopMatrix\n\tEnd Method\n\t\n\tMethod RenderFlat(flat:TFlat)\n\t\tLocal x#,y#,z#\n\t\tflat.GetScale x,y,z,True\n\t\t\n\t\tglBegin GL_QUADS\n\t\t\tglNormal3f 0,1,0\n\t\t\tglTexCoord2f 0,0\n\t\t\tglVertex3f -1,0, 1\n\t\t\tglTexCoord2f x,0\t\n\t\t\tglVertex3f 1, 0, 1\n\t\t\tglTexCoord2f x,z\n\t\t\tglVertex3f 1, 0, -1\n\t\t\tglTexCoord2f 0,z\n\t\t\tglVertex3f -1,0, -1\n\t\tglEnd\n\t\tReturn 2\n\tEnd Method\n\t\n\tMethod RenderSprite(sprite:TSprite)\n\t\tIf False\n\t\t\tglPointParameterfvARB GL_POINT_DISTANCE_ATTENUATION_ARB, [0.0, 0.0, 1.0]\n\t\t\t\n\t\t\tglPointSize 1.0\n\t\t\t\n\t\t\tglPointParameterfARB GL_POINT_FADE_THRESHOLD_SIZE_ARB,60.0\n\t\t\tglPointParameterfARB GL_POINT_SIZE_MIN_ARB,0.0\n\t\t\tglPointParameterfARB GL_POINT_SIZE_MAX_ARB,9999.0\n\t\t\t\n\t\t\tglTexEnvf GL_POINT_SPRITE_ARB,GL_COORD_REPLACE_ARB,GL_TRUE\n\t\t\t\n\t\t\tglEnable GL_POINT_SPRITE_ARB\n\t\t\t\n\t\t\tglBegin GL_POINTS\t\t\t\n\t\t\tglVertex3f 0,0,0\n\t\t\tglEnd\n\t\t\t\n\t\t\tglDisable GL_POINT_SPRITE_ARB\n\t\tElse\n\t\t\tglBegin GL_QUADS\n\t\t\t\tglNormal3f 0,0,-1\n\t\t\t\tglTexCoord2f 0,1\n\t\t\t\tglVertex3f 1, -1, 0\t\t\t\n\t\t\t\tglTexCoord2f 0,0\n\t\t\t\tglVertex3f 1, 1, 0\t\t\t\n\t\t\t\tglTexCoord2f 1,0\n\t\t\t\tglVertex3f -1,1, 0\t\t\t\n\t\t\t\tglTexCoord2f 1,1\n\t\t\t\tglVertex3f -1,-1, 0\n\t\t\tglEnd\n\t\tEndIf\n\tEnd Method\n\t\n\tMethod RenderTerrain(terrain:TTerrain)\n\t\n\t\tglDisableClientState GL_TEXTURE_COORD_ARRAY\n\t\tFor Local i=0 To 7\n\t\t\tLocal texture:TTexture=terrain._brush._texture[i]\n\t\t\tIf texture=Null Continue\n\t\t\tglEnableClientState(GL_TEXTURE_COORD_ARRAY)\n\t\t\tglClientActiveTextureARB(GL_TEXTURE0+i)\n\t\t\tglTexCoordPointer(2,GL_FLOAT,20,terrain._data)\n\t\tNext\n\t\t\n\t\tglEnableClientState GL_VERTEX_ARRAY\n\t\tglDisableClientState GL_COLOR_ARRAY\n\t\tglDisableClientState GL_NORMAL_ARRAY\n\t\t\n\t\tglVertexPointer(3,GL_FLOAT, 20, terrain._data+2)\n\t\tglDrawArrays(GL_TRIANGLES, 0, 3*terrain._count)\n\t\t\n\t\tglEnableClientState GL_VERTEX_ARRAY\n\t\tglEnableClientState GL_COLOR_ARRAY \n\t\tglEnableClientState GL_NORMAL_ARRAY \n\tEnd Method\n\t\n\tMethod RenderBSPTree(tree:TBSPTree)\n\t\tLocal node:TBSPNode=tree.Node\n\t\tIf node=Null Return\n\t\tLocal triangles\n\t\ttriangles:+RenderBSPTree(node.In)\t\t\n\t\t\n\t\tFor Local poly:TBSPPolygon=EachIn node.On\n\t\t\tglBegin GL_POLYGON\n\t\t\tglNormal3f poly.Plane.x,poly.Plane.y,poly.Plane.z\n\t\t\tFor Local i=0 To poly.Count()-1\n\t\t\t\tglTexCoord2f (poly.Plane.x-poly.Center.x)*poly.Point[i].x+(poly.Plane.y-poly.Center.y)*poly.Point[i].y+(poly.Plane.z-poly.Center.z)*poly.Point[i].z, (poly.Plane.x-poly.Center.x)*poly.Point[i].x+(poly.Plane.y-poly.Center.y)*poly.Point[i].y+(poly.Plane.z-poly.Center.z)*poly.Point[i].z\n\t\t\t\tglVertex3f poly.Point[i].x,poly.Point[i].y,poly.Point[i].z\n\t\t\tNext\n\t\t\ttriangles:+poly.Count()-2\n\t\t\tglEnd\n\t\tNext\t\n\t\t\n\t\ttriangles:+RenderBSPTree(node.Out)\n\t\tReturn triangles\n\tEnd Method\n\n\tMethod UpdateTextureRes:TGLTextureRes(frame:TTextureFrame,flags)\n\t\tIf frame=Null Return Null\n\t\t\n\t\tLocal glres:TGLTextureRes=TGLTextureRes(frame._res)\n\t\tIf glres=Null\n\t\t\tglres=New TGLTextureRes\n\t\t\tframe._res=glres\n\t\t\tframe._updateres=True\n\t\tEndIf\t\t\n\t\tIf Not frame._updateres Return glres\n\t\t\n\t\tIf glres._id=0 glGenTextures(1,Varptr glres._id)\n\t\tBindTexture 0,glres._id\n\t\tLocal pixmap:TPixmap=frame._pixmap\n\t\tgluBuild2DMipmaps(GL_TEXTURE_2D,GL_RGBA8,pixmap.width,pixmap.height,GL_BGRA,GL_UNSIGNED_BYTE,pixmap.pixels)\n\t\t\n\t\tframe._updateres=0\n\t\tReturn glres\n\tEnd Method\n\t\n\tMethod UpdateSurfaceRes:TGLSurfaceRes(surface:TSurface)\n\t\tLocal res:TGLSurfaceRes=TGLSurfaceRes(surface._res)\n\t\tIf res=Null res=New TGLSurfaceRes;surface._res=res\n\t\tIf surface._reset=0 Return res\n\t\t\n\t\tIf res._vbo[0]=0 glGenBuffersARB(4,res._vbo)\n\t\n\t\tIf surface._reset=-1 Then surface._reset=1|2|4|8|16|32|64|128|256\n\t\n\t\tIf surface._reset&1 UploadVertexBuffer res._vbo[0],surface._vertexpos\n\t\tIf surface._reset&2 UploadVertexNormals res._vbo[1],surface._vertexnml\n\t\tIf surface._reset&4 UploadVertexBuffer res._vbo[2],surface._vertexclr\n\t\tIf surface._reset&8\n\t\t\tglBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB,res._vbo[3])\n\t\t\tglBufferDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB,surface._triangle.length*4,surface._triangle,GL_STATIC_DRAW_ARB)\n\t\tEndIf\n\t\t\n\t\tFor Local i=0 To surface._vertextex.length-1\n\t\t\tIf res._vbo[4+i]=0 glGenBuffersARB(1,Varptr res._vbo[4+i])\n\t\t\tIf surface._reset&Int(2^(4+i)) UploadVertexBuffer res._vbo[4+i],surface._vertextex[i]\n\t\tNext\t\n\t\t\n\t\tres._trianglecnt=surface._trianglecnt\n\t\tres._vertexcnt=surface._vertexcnt\t\t\n\t\tsurface._reset=0\t\t\n\t\tReturn res\n\tEnd Method\n\t\n\tMethod MergeSurfaceRes:TGLSurfaceRes(base:TSurface,animation:TSurface,data)\n\t\tIf animation=Null Return UpdateSurfaceRes(base)\n\t\tLocal res_base:TGLSurfaceRes=UpdateSurfaceRes(base)\n\t\tLocal res_anim:TGLSurfaceRes=UpdateSurfaceRes(animation)\n\t\tLocal res:TGLSurfaceRes=res_base.Copy()\n\t\tres._vbo[0]=res_anim._vbo[0]\n\t\tReturn res\n\tEnd Method\n\t\n\tMethod UploadVertexBuffer(vbo,data#[])\n\t\tglBindBufferARB(GL_ARRAY_BUFFER_ARB,vbo)\n\t\tglBufferDataARB(GL_ARRAY_BUFFER_ARB,data.length*4,data,GL_STATIC_DRAW_ARB)\n\tEnd Method\n\t\n\tMethod UploadVertexNormals(vbo,data#[])\n\t\tglBindBufferARB(GL_ARRAY_BUFFER_ARB,vbo)\n\t\tglBufferDataARB(GL_ARRAY_BUFFER_ARB,data.length*4,data,GL_STATIC_DRAW_ARB)\n\tEnd Method\nEnd Type\n\nType TGLCaps Extends TCaps\n\tField Extensions$[]\n\t\n\tMethod HasExtension(ext$)\n\t\tFor Local extension$=EachIn Extensions\n\t\t\tIf extension.Find(ext)<>-1 Return True\n\t\tNext\n\t\tReturn False \n\tEnd Method\n\t\n\tMethod Copy:TGLCaps()\n\t\tLocal caps:TGLCaps=New TGLCaps\n\t\tcaps.CopyBase(Self)\n\t\tcaps.Extensions=Extensions[..]\n\t\tReturn caps\t\t\n\tEnd Method\nEnd Type\n\nType TGLSurfaceRes Extends TSurfaceRes\n\tField _vbo[12]\n\tField _texcoord\n\t\n\tMethod Copy:TGLSurfaceRes()\n\t\tLocal res:TGLSurfaceRes=New TGLSurfaceRes\n\t\tres._vertexcnt=_vertexcnt;res._trianglecnt=_trianglecnt\n\t\tres._vbo=_vbo[..]\n\t\tres._texcoord=_texcoord\n\t\tReturn res\n\tEnd Method\nEnd Type\n\nType TGLTextureRes Extends TTextureRes\n\tField _id\nEnd Type\n\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GLMaxB3DDriver:TGLMaxB3DDriver()\n\tIf GLMax2DExDriver()\n\t\tGlobal driver:TGLMaxB3DDriver=New TGLMaxB3DDriver\n\t\tdriver._parent=GLMax2DExDriver()\n\t\tReturn driver\n\tEnd If\nEnd Function\n\nRem\n\tbbdoc: Utility function that sets the MaxB3D GL driver and calls Graphics.\nEnd Rem\nFunction GLGraphics3D:TGraphics(width,height,depth=0,hertz=60,flags=0)\n\tSetGraphicsDriver GLMaxB3DDriver(),GRAPHICS_BACKBUFFER|GRAPHICS_DEPTHBUFFER\n\tReturn Graphics(width,height,depth,hertz,flags)\nEnd Function\n\nLocal driver:TGLMaxB3DDriver=GLMaxB3DDriver()\nIf driver SetGraphicsDriver driver,GRAPHICS_BACKBUFFER|GRAPHICS_DEPTHBUFFER\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"b4879ffc731c727c472d27c193b919f6feaff047","subject":"Accessed wrong variables in example2","message":"Accessed wrong variables in example2\n","repos":"Htbaa\/xmlrpc.mod,Htbaa\/xmlrpc.mod,Htbaa\/xmlrpc.mod,Htbaa\/xmlrpc.mod,Htbaa\/xmlrpc.mod","old_file":"examples\/example2.bmx","new_file":"examples\/example2.bmx","new_contents":"SuperStrict\nImport htbaapub.xmlrpc\n\nLocal client:TXMLRPC_Client = New TXMLRPC_Client.Create()\nclient.SetTransport(New TXMLRPC_Transport_Http.Create(\"www.upcdatabase.com\", \"\/rpc\"))\n\nLocal parameters:TXMLRPC_Call_Parameters = TXMLRPC_Call_Parameters.Create(xmlrpc_vector_array)\nparameters.AppendString(Null, \"0045496718749\")\n\nLocal response:TXMLRPC_Response_Data = client.Call(\"lookupEAN\", parameters)\n\nLocal description:TXMLRPC_Value_String = TXMLRPC_Value_String(response.data.ValueForKey(\"description\"))\nLocal issuerCountry:TXMLRPC_Value_String = TXMLRPC_Value_String(response.data.ValueForKey(\"issuerCountry\"))\nLocal ean:TXMLRPC_Value_String = TXMLRPC_Value_String(response.data.ValueForKey(\"ean\"))\n\nPrint description.name + \": \" + description.ToString()\nPrint issuerCountry.name + \": \" + issuerCountry.ToString()\nPrint ean.name + \": \" + ean.ToString()","old_contents":"SuperStrict\nImport htbaapub.xmlrpc\n\nLocal client:TXMLRPC_Client = New TXMLRPC_Client.Create()\nclient.SetTransport(New TXMLRPC_Transport_Http.Create(\"www.upcdatabase.com\", \"\/rpc\"))\n\nLocal parameters:TXMLRPC_Call_Parameters = TXMLRPC_Call_Parameters.Create(xmlrpc_vector_array)\nparameters.AppendString(Null, \"0045496718749\")\n\nLocal response:TXMLRPC_Response_Data = client.Call(\"lookupEAN\", parameters)\n\nLocal description:TXMLRPC_Value_String = TXMLRPC_Value_String(response.data.ValueForKey(\"description\"))\nLocal issuerCountry:TXMLRPC_Value_String = TXMLRPC_Value_String(response.data.ValueForKey(\"issuerCountry\"))\nLocal ean:TXMLRPC_Value_String = TXMLRPC_Value_String(response.data.ValueForKey(\"ean\"))\n\nPrint description.name + \": \" + description.ToString()\nPrint description.name + \": \" + issuerCountry.ToString()\nPrint description.name + \": \" + ean.ToString()","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"75dfb5faf3fc5afb3f7b8d20de07342d3414ff26","subject":"Changed module import order to include B3D collision before functions module.","message":"Changed module import order to include B3D collision before functions module.\n","repos":"kfprimm\/maxb3d,kfprimm\/maxb3d","old_file":"drivers.mod\/drivers.bmx","new_file":"drivers.mod\/drivers.bmx","new_contents":"\nStrict\n\nRem\n\tbbdoc: MaxB3D driver collection\nEnd Rem\nModule MaxB3D.Drivers\nModuleInfo \"Author: Kevin Primm\"\nModuleInfo \"License: MIT\"\n\nImport MaxB3D.Core\nImport MaxB3D.B3DCollision\nImport MaxB3D.Primitives\nImport MaxB3D.GLDriver\nImport MaxB3D.D3D9Driver\nImport MaxB3D.Functions\n\n","old_contents":"\nStrict\n\nRem\n\tbbdoc: MaxB3D driver collection\nEnd Rem\nModule MaxB3D.Drivers\nModuleInfo \"Author: Kevin Primm\"\nModuleInfo \"License: MIT\"\n\nImport MaxB3D.Functions\nImport MaxB3D.GLDriver\nImport MaxB3D.D3D9Driver\nImport MaxB3D.Primitives\nImport MaxB3D.B3DCollision","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"e57664b8fddffd660f5717e5ad1ed033165faba6","subject":"filled out control opcodes","message":"filled out control opcodes\n","repos":"Leushenko\/blue-moon","old_file":"bluejit.bmx","new_file":"bluejit.bmx","new_contents":"\n' Blue Moon\n' JIT engine\/opcodes\n\n' this is the core of the runtime: the machine code generator and opcodes\n' it's a halfway blend between JIT and interpreter: a basic JIT generates machine code\n' for \"unrolled\" interpreter loops, theoretically (ha!) providing a speed boost\n' it can also \"inline\" selected operations, coming closer to being a true JIT\n\n' for now this is an Include rather than Import lib due to recursive dependency\n' we'll fix that later\n\nRem\nSuperStrict\n\nImport \"blueerror.bmx\"\nImport \"bluevm.bmx\"\nImport etc etc...\nEnd Rem\n\n'Private\t'may need to rename and open these (in the shared interface?)\nExtern\n\tType Stack\n\t\tField retIP:Byte Ptr, prevBase:Stack, varp:Long Ptr, func:Bytecode, _:Long Ptr, argv:Long Ptr, retv:Long Ptr, argc:Short, retc:Short\n\tEnd Type\n\tType Bytecode\n\t\tField mcode:Byte Ptr, idMod:Int, kcount:Int, pcount:Int, upvars:Int, frameSz:Int, icount:Int, vm:Byte Ptr\n\tEnd Type\nEnd Extern\n'Public\n\nType BlueJIT Final\n\tConst PROLOGUESZ:Int = 25, ISIZE:Int = 5\n\t\n\tGlobal opTbl:Int(s:Stack, b:Bytecode, r:Byte Ptr)[], opc:BlueOpcode\n\tGlobal Prologue:Int[] = [ ..\n\t\t$90, $90, ..\n\t\t$8b, $44, $24, $04, .. 'mov 4(%esp), %eax\n\t\t$89, $44, $24, $f4, .. 'mov %eax, -12(%esp)\n\t\t$c7, $44, $24, $f8, $FF, $FF, $FF, $FF, .. 'movl ########, -8(%esp)\n\t\t$89, $64, $24, $fc, .. 'mov %esp, -4(%esp)\n\t\t$83, $ec, $0c.. 'sub $12, %esp\n\t]\n\t\n\tFunction Compile:Byte Ptr(vm:BlueVM, ins:Byte Ptr, icount:Int, bytecode:Bytecode)\n\t\t?Not x86\n\t\tRuntimeError \"The Blue Moon JIT does not support your platform (x86-32 only at this time)\"\n\t\t?\n\t\tAssert SizeOf(0:Long) = SizeOf(0:Double) And SizeOf(0:Int) = 4 And SizeOf(0:Long) = 8 And SizeOf(Byte Ptr(0)) = 4, ..\n\t\t\t\"assumptions about platform datatype sizes are invalid\"\n\t\t\n\t\tIf opTbl = Null Then InitOpTbl()\n\t\t\n\t\t' compute executable code size\n\t\tLocal codesize:Int = PROLOGUESZ, opPos:Int[icount]\t'since sizes are irregular, looking up offsets is easiest\n\t\tFor Local i:Int = 0 Until icount\n\t\t\topPos[i] = codesize\t'finalized below\n\t\t\tSelect ins[i * 8]\n\t\t\t\tCase opc.SETTAB, opc.GETTAB\n\t\t\t\t\tcodesize :+ ISIZE * 2\n\t\t\t\tDefault\n\t\t\t\t\tcodesize :+ ISIZE\n\t\t\tEnd Select\n\t\tNext\n\t\t\n\t\t' allocate executable space\n\t\tLocal code:Byte Ptr = vm.mem.AllocCodeBlock(codesize)\n\t\t\n\t\t'finalize op offsets se we can look them up\n\t\tFor Local i:Int = 0 Until icount\n\t\t\topPos[i] :+ Int(code)\t'direct to executable space\n\t\tNext\n\t\t\n\t\t' emplace prologue (used for calling in from native only)\n\t\tFor Local p:Int = 0 Until PROLOGUESZ\n\t\t\tcode[p] = Prologue[p]\n\t\tNext\n\t\tByte Ptr Ptr(code + 14)[0] = Byte Ptr(bytecode)\t'replace the ########\n\t\t\n\t\t' epilogue (shared location per-vm, probably already set)\n\t\tvm.mem.returnToNative[0] = $c30cc483\t'add $12, %esp ; ret - i.e. restore the stack to normal\n\t\t\n\t\tLocal ktable:Long Ptr = Long Ptr(ins + 8 * bytecode.icount + 8 * bytecode.upvars)\t'constant table\n\t\t\n\t\t' generate machine code!\n\t\tFor Local i:Int = 0 Until icount\t'emplace opcode calls and supporting bytecode data\n\t\t\tLocal codep:Byte Ptr = Byte Ptr(opPos[i]), bytecodep:Byte Ptr = Byte Ptr(Int(codep) + vm.mem.PAGESZ)\n\t\t\tLocal bi:Int = i * 8, op:Int = ins[bi], ip:Int Ptr = Int Ptr(ins + bi), func:Byte Ptr = opTbl[op]\n\t\t\t\n\t\t\tcodep[0] = $e8\t'call\n\t\t\tByte Ptr Ptr(codep + 1)[0] = func - Int(codep + ISIZE)\n\t\t\t\n\t\t\tbytecodep[0] = ins[bi + 1] ; bytecodep[1] = ins[bi + 2]\t'used by most, may get overwritten\n\t\t\t\n\t\t\tSelect op\n\t\t\t\tCase opc.LOADSI, opc.CLOSURE, opc.RET, opc.POSTCALL\n\t\t\t\t\tInt Ptr(bytecodep + 1)[0] = ip[1]\n\t\t\t\t\t\n\t\t\t\tCase opc.LOADK\n\t\t\t\t\tLong Ptr Ptr(bytecodep + 1)[0] = ktable + ip[1]\n\t\t\t\t\t\n\t\t\t\tCase opc.SETTABSI, opc.GETTABSI\n\t\t\t\t\tShort Ptr(bytecodep)[1] = ip[1]\n\t\t\t\t\t\n\t\t\t\tCase opc.SETTAB, opc.GETTAB\n\t\t\t\t\tcodep[ISIZE] = $90 ; Int Ptr(codep + ISIZE + 1)[0] = $90909090\t'nops; the space is needed in the bytecode\n\t\t\t\t\tLong Ptr Ptr(bytecodep + 2)[0] = ktable + ip[1]\n\t\t\t\t\tLong Ptr Ptr(bytecodep + 2)[1] = Null\t'inline cache space\n\t\t\t\t\t\n\t\t\t\tCase opc.GETUPV\n\t\t\t\t\tIf Int Ptr(ins + icount * 8)[2 * bytecodep[1]] = -1\n\t\t\t\t\t\tByte Ptr Ptr(codep + 1)[0] = Byte Ptr(BlueJIT.GETENV) - Int(codep + ISIZE)\n\t\t\t\t\t\tByte Ptr Ptr(bytecodep + 1)[0] = Varptr(vm._ENV.val)\t'note: doesn't allow _ENV to be changed from Max\n\t\t\t\t\tEndIf\n\t\t\t\t\t\n\t\t\t\tCase opc.CALL\n\t\t\t\t\tShort Ptr(bytecodep)[1] = ip[1]\n\t\t\t\t\t\n\t\t\t\tCase opc.JIF, opc.JNOT\n\t\t\t\t\tInt Ptr(bytecodep + 1)[0] = opPos[i + ip[1]]\n\t\t\t\t\t\n\t\t\t\tCase opc.JMP\n\t\t\t\t\tcodep[0] = $e9\t'use a true jump\n\t\t\t\t\tInt Ptr(codep + 1)[0] = opPos[i + ip[1]] - (opPos[i] + ISIZE)\n\t\t\t\t\t\n\t\t\t\tDefault\t'binary operations A = B op C\n\t\t\t\t\tbytecodep[2] = ip[1]\n\t\t\tEnd Select\n\t\tNext\n\t\t\n\t\tReturn code\n\tEnd Function\n\t\n\t\n\tConst STACKFRAME_INC:Int = BlueVMMemory.STACKFRAMESZ + 4, BYTECODE_INC:Int = BlueVMMemory.BYTECODESZ + 4\n\tConst IP_OFFSET:Int = BlueVMMemory.PAGESZ - ISIZE\n\t\n\t\n\t'note: extern vars must take into account the vtbl offset, so that converting from a typed pointer can be a simple cast (faster)\t\n\t\n\tFunction MOV(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"MOV \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tvarp[rp[0]] = varp[rp[1]]\n\tEnd Function\n\tFunction GETLC(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"GETLC \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tvarp[rp[0]] = Long Ptr Ptr(varp + rp[1])[0][0]\n\tEnd Function\n\tFunction SETLC(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"SETLC \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal convert:BlueVM(p:Byte Ptr) = Byte Ptr(Identity), vm:BlueVM = convert(bc.vm)\n\t\tvm.mem.Write(Long Ptr Ptr(varp + rp[0])[0], varp[rp[1]])\t'unlikely but technically possible to need this\n\tEnd Function\n\tFunction LOADK(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"LOADK \/\/\"\n\t\tLocal rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET, varp:Long Ptr = stk.varp + rp[0], kp:Long Ptr = Long Ptr Ptr(rp + 1)[0]\n\t\tvarp[0] = kp[0]\n\tEnd Function\n\tFunction LOADSI(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"LOADSI \/\/\"\n\t\tLocal rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal val:Int = Int Ptr(rp + 1)[0]\n\t\tDouble Ptr(stk.varp)[rp[0]] = Double(val)\n\tEnd Function\n\tFunction LOADBOOL(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"LOADBOOL \/\/\"\n\t\tLocal rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET, vp:Int Ptr = Int Ptr(stk.varp + rp[0])\n\t\tvp[1] = BlueTypeTag.NANBOX | BlueTypeTag.BOOL\n\t\tvp[0] = Int Ptr(rp + 1)[0]\n\tEnd Function\n\tFunction LOADNIL(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"LOADNIL \/\/\"\n\t\tLocal rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tInt Ptr(stk.varp + rp[0])[1] = BlueTypeTag.NANBOX | BlueTypeTag.NIL\n\tEnd Function\n\t\n\tFunction GETTAB(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"GETTAB \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET, kp:Long Ptr = Long Ptr Ptr(rp + 2)[0]\n\t\tLocal tabp:Byte Ptr = Byte Ptr Ptr(varp + rp[1])[0]\n\t\tIf Int Ptr(varp + rp[1])[1] = BlueTypeTag.TBLBOX\n\t\t\tLocal keyslot:Long Ptr = Null, slot:Long Ptr = BlueTable.GetSlot(tabp, kp[0], Varptr(keyslot))\n\t\t\tIf (slot = Null) Or (keyslot[0] <> kp[0])\n\t\t\t\tIf keyslot = Long Ptr(1) Then varp[rp[0]] = BlueVMMemory.NIL ; Return\t'nil key\n\t\t\tElse\n\t\t\t\tvarp[rp[0]] = slot[0] ; Return\n\t\t\tEndIf\n\t\tEndIf\n\t\tIndexMetamethod bc, retptr, varp + rp[0], varp[rp[1]], kp[0]\t'not in table; invoke metamethod\n\tEnd Function\n\tFunction GETTABSI(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"GETTABSI \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal tabp:Byte Ptr = Byte Ptr Ptr(varp + rp[1])[0], key:Long ; Double Ptr(Varptr(key))[0] = Short Ptr(rp)[1]\n\t\tIf Int Ptr(varp + rp[0])[1] = BlueTypeTag.TBLBOX\n\t\t\tLocal keyslot:Long Ptr = Null, slot:Long Ptr = BlueTable.GetSlot(tabp, key, Varptr(keyslot))\n\t\t\tIf Not (slot = Null Or (keyslot And keyslot[0] <> key)) Then varp[rp[0]] = slot[0] ; Return\n\t\t\tIf keyslot = Long Ptr(1) Then varp[rp[0]] = BlueVMMemory.NIL ; Return\n\t\tEndIf\n\t\tIndexMetamethod bc, retptr, varp + rp[0], varp[rp[1]], key\n\tEnd Function\n\tFunction SETTAB(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"SETTAB \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal tabvp:Byte Ptr = varp + rp[0], kp:Long Ptr = Long Ptr Ptr(rp + 2)[0]\n\t\tIf Int Ptr(tabvp)[1] = BlueTypeTag.TBLBOX\n\t\t\tLocal keyslot:Long Ptr = Null, slot:Long Ptr = BlueTable.GetSlot(Byte Ptr Ptr(tabvp)[0], kp[0], Varptr(keyslot))\n\t\t\tIf Not (slot = Null Or keyslot[0] <> kp[0]) Then slot[0] = varp[rp[1]] ; Return\n\t\tEndIf\n\t\tNewindexMetamethod bc, retptr, varp[rp[0]], varp[rp[1]], kp[0]\t'not in table; invoke metamethod or rawset\n\tEnd Function\n\tFunction SETTABSI(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"SETTABSI \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET, tabvp:Byte Ptr = varp + rp[0]\n\t\tLocal key:Long ; Double Ptr(Varptr(key))[0] = Short Ptr(rp)[1]\n\t\tIf Int Ptr(tabvp)[1] = BlueTypeTag.TBLBOX\n\t\t\tLocal keyslot:Long Ptr = Null, slot:Long Ptr = BlueTable.GetSlot(Byte Ptr Ptr(tabvp)[0], key, Varptr(keyslot))\n\t\t\tIf Not (slot = Null Or (keyslot And keyslot[0] <> key)) Then slot[0] = varp[rp[1]] ; Return\n\t\tEndIf\n\t\tNewindexMetamethod bc, retptr, Long Ptr(tabvp)[0], varp[rp[1]], key\n\tEnd Function\n\tFunction GETTABI(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"GETTABI \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal tabvp:Byte Ptr = varp + rp[1], key:Long = varp[rp[2]]\n\t\tIf Int Ptr(tabvp)[1] = BlueTypeTag.TBLBOX\n\t\t\tLocal keyslot:Long Ptr = Null, slot:Long Ptr = BlueTable.GetSlot(Byte Ptr Ptr(tabvp)[0], key, Varptr(keyslot))\n\t\t\tIf Not (slot = Null Or (keyslot And keyslot[0] <> key)) Then varp[rp[0]] = slot[0] ; Return\n\t\tEndIf\n\t\tIndexMetamethod bc, retptr, varp + rp[0], Long Ptr(tabvp)[0], key\n\tEnd Function\n\tFunction SETTABI(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"SETTABI \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal tabvp:Byte Ptr = varp + rp[0], key:Long = varp[rp[2]]\n\t\tIf Int Ptr(tabvp)[1] = BlueTypeTag.TBLBOX\n\t\t\tLocal keyslot:Long Ptr = Null, slot:Long Ptr = BlueTable.GetSlot(Byte Ptr Ptr(tabvp)[0], key, Varptr(keyslot))\n\t\t\tIf Not (slot = Null Or (keyslot And keyslot[0] <> key)) Then slot[0] = varp[rp[1]] ; Return\n\t\tEndIf\n\t\tNewindexMetamethod bc, retptr, Long Ptr(tabvp)[0], varp[rp[1]], key\n\tEnd Function\n\tFunction GETUPV(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"GETUPV \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal upvp:Byte Ptr Ptr = Byte Ptr Ptr(Byte Ptr(stk) + STACKFRAME_INC), valp:Long Ptr = Long Ptr(upvp[rp[1]])\n\t\tvarp[rp[0]] = valp[0]\n\tEnd Function\n\tFunction GETENV(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\t'\"unlisted\" instruction: GETUPV for _ENV is translated into this at load-time\n\t'\tPrint \"GETENV \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tvarp[rp[0]] = Long Ptr Ptr(rp + 1)[0][0]\t'type check should not be necessary (will be handled by following op)\n\tEnd Function\n\tFunction SETUPV(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"SETUPV \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal convert:BlueVM(p:Byte Ptr) = Byte Ptr(Identity), vm:BlueVM = convert(bc.vm)\n\t\tLocal upvp:Byte Ptr Ptr = Byte Ptr Ptr(Byte Ptr(stk) + STACKFRAME_INC), valp:Long Ptr = Long Ptr(upvp[rp[0]])\n\t\tvm.mem.Write(valp, varp[rp[1]])\n\tEnd Function\n\tFunction NEWTAB(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"NEWTAB \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal convert:BlueVM(p:Byte Ptr) = Byte Ptr(Identity), vm:BlueVM = convert(bc.vm)\n\t\tLocal tab:Byte Ptr = vm.mem.AllocTable(Null)\n\t\tLocal d:Int Ptr = Int Ptr(varp + rp[0])\n\t\td[0] = Int(tab) ; d[1] = BlueTypeTag.TBLBOX\n\tEnd Function\n\tFunction CLOSURE(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"CLOSURE \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal convert:BlueVM(p:Byte Ptr) = Byte Ptr(Identity), vm:BlueVM = convert(bc.vm)\n\t\tLocal d:Int Ptr = Int Ptr(varp + rp[0])\n\t\tLocal cbytecode:Bytecode = vm.funIndex[Int Ptr(rp + 1)[0]], upvp:Int Ptr = Int Ptr(Byte Ptr(cbytecode) + BYTECODE_INC + 8 * cbytecode.icount)\n\t\tLocal closure:Byte Ptr = vm.mem.AllocClosure(cbytecode, cbytecode.upvars)\t'upvars is always even (alignment)\n\t\t\n\t\t'get upvalues off the stack\n\t\tFor Local u:Int = 0 Until cbytecode.upvars\n\t\t\tIf upvp[2 * u]\n\t\t\t\tByte Ptr Ptr(closure)[2 + u] = Byte Ptr Ptr(Byte Ptr(stk) + STACKFRAME_INC)[upvp[2 * u + 1]]\n\t\t\tElse\n\t\t\t\tByte Ptr Ptr(closure)[2 + u] = Byte Ptr Ptr(varp + upvp[2 * u + 1])[0]\n\t\t\tEndIf\n\t\tNext\n\t\t\n\t\td[0] = Int(closure) ; d[1] = BlueTypeTag.FUNBOX\n\tEnd Function\n\tFunction NEWUPV(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"NEWUPV \/\/\"\n\t\tLocal rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal convert:BlueVM(p:Byte Ptr) = Byte Ptr(Identity), vm:BlueVM = convert(bc.vm)\n\t\tLocal upv:Byte Ptr = vm.mem.AllocObject(8, BlueTypeTag.UPV), d:Int Ptr = Int Ptr(stk.varp + rp[0])\n\t\tLong Ptr(upv)[0] = Long Ptr(d)[0]\t'promote a value if it existed (useful for parameters)\n\t\td[0] = Int(upv) ; d[1] = BlueTypeTag.NANBOX | BlueTypeTag.UPV\n\tEnd Function\n\t\n\tFunction ADD(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"ADD \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal d:Double Ptr = Double Ptr(varp + rp[0])\n\t\tLocal r:Int Ptr = Int Ptr(varp + rp[1]), l:Int Ptr = Int Ptr(varp + rp[2])\n\t\tIf l[1] & BlueTypeTag.NANBOX_CHK = BlueTypeTag.NANBOX Or r[1] & BlueTypeTag.NANBOX_CHK = BlueTypeTag.NANBOX\n\t\t\tBinopMetamethod opc.ADD, bc, retptr, Long Ptr(d), Long Ptr(r), Long Ptr(l)\n\t\tElse\n\t\t\tPrint \" \" + Double Ptr(l)[0] + \" \" + Double Ptr(r)[0]\n\t\t\td[0] = Double Ptr(l)[0] + Double Ptr(r)[0]\n\t\tEndIf\n\tEnd Function\n\tFunction SUB(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"SUB \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal d:Double Ptr = Double Ptr(varp + rp[0])\n\t\tLocal r:Int Ptr = Int Ptr(varp + rp[1]), l:Int Ptr = Int Ptr(varp + rp[2])\n\t\tIf l[1] & BlueTypeTag.NANBOX_CHK = BlueTypeTag.NANBOX Or r[1] & BlueTypeTag.NANBOX_CHK = BlueTypeTag.NANBOX\n\t\t\tBinopMetamethod opc.SUB, bc, retptr, Long Ptr(d), Long Ptr(r), Long Ptr(l)\n\t\tElse\n\t\t\td[0] = Double Ptr(l)[0] - Double Ptr(r)[0]\n\t\tEndIf\n\tEnd Function\n\tFunction MUL(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction DIV(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction NMOD(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction POW(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction CAT(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction IDIV(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction BAND(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction BOR(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction BXOR(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction BSHL(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction BSHR(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction UNM(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction LNOT(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction ALEN(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction BNOT(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction UNP(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction EQ(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"EQ \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal d:Int Ptr = Int Ptr(varp + rp[0]), r:Int Ptr = Int Ptr(varp + rp[1]), l:Int Ptr = Int Ptr(varp + rp[2])\n\t\tIf l[1] & BlueTypeTag.NANBOX_CHK = BlueTypeTag.NANBOX Or r[1] & BlueTypeTag.NANBOX_CHK = BlueTypeTag.NANBOX\n\t\t\tBinopMetamethod opc.EQ, bc, retptr, Long Ptr(d), Long Ptr(r), Long Ptr(l)\n\t\tElse\n\t\t\td[0] = Double Ptr(l)[0] = Double Ptr(r)[0] ; d[1] = BlueTypeTag.BOOLBOX\n\t\tEndIf\n\tEnd Function\n\tFunction LT(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"LT \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal d:Int Ptr = Int Ptr(varp + rp[0]), r:Int Ptr = Int Ptr(varp + rp[1]), l:Int Ptr = Int Ptr(varp + rp[2])\n\t\tIf l[1] & BlueTypeTag.NANBOX_CHK = BlueTypeTag.NANBOX Or r[1] & BlueTypeTag.NANBOX_CHK = BlueTypeTag.NANBOX\n\t\t\tBinopMetamethod opc.LT, bc, retptr, Long Ptr(d), Long Ptr(r), Long Ptr(l)\n\t\tElse\n\t\t\td[0] = Double Ptr(l)[0] < Double Ptr(r)[0] ; d[1] = BlueTypeTag.BOOLBOX\n\t\tEndIf\n\tEnd Function\n\tFunction LEQ(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"LEQ \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal d:Int Ptr = Int Ptr(varp + rp[0]), r:Int Ptr = Int Ptr(varp + rp[1]), l:Int Ptr = Int Ptr(varp + rp[2])\n\t\tIf l[1] & BlueTypeTag.NANBOX_CHK = BlueTypeTag.NANBOX Or r[1] & BlueTypeTag.NANBOX_CHK = BlueTypeTag.NANBOX\n\t\t\tBinopMetamethod opc.LEQ, bc, retptr, Long Ptr(d), Long Ptr(r), Long Ptr(l)\n\t\tElse\n\t\t\td[0] = Double Ptr(l)[0] <= Double Ptr(r)[0] ; d[1] = BlueTypeTag.BOOLBOX\n\t\tEndIf\n\tEnd Function\n\t\n\tFunction JMP(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t\tRuntimeError \"wait, why are we here?\"\n\tEnd Function\n\tFunction JIF(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"JIF \/\/\"\n\t\tLocal rp:Byte Ptr = (Byte Ptr Ptr(retptr) - 4)[0] + IP_OFFSET, valp:Int Ptr = Int Ptr(stk.varp + rp[0])\n\t\tIf valp[1] <> BlueTypeTag.NILBOX And Not(valp[1] = BlueTypeTag.BOOLBOX And valp[0] = 0)\n\t\t\tLocal target:Int = Int Ptr(rp + 1)[0] ; Int Ptr(retptr)[-4] = target\n\t\tEndIf\n\tEnd Function\n\tFunction JNOT(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"JNOT \/\/\"\n\t\tLocal rp:Byte Ptr = (Byte Ptr Ptr(retptr) - 4)[0] + IP_OFFSET, valp:Int Ptr = Int Ptr(stk.varp + rp[0])\n\t\tIf valp[1] = BlueTypeTag.NILBOX Or (valp[1] = BlueTypeTag.BOOLBOX And valp[0] = 0)\n\t\t\tLocal target:Int = Int Ptr(rp + 1)[0] ; Int Ptr(retptr)[-4] = target\n\t\tEndIf\n\tEnd Function\n\tFunction CALL(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"CALL \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal fp:Int Ptr = Int Ptr(varp + rp[0])\n\t\tIf Not PrepareCall(fp, stk, rp, varp, retptr)\t'PrepareCall sets everything up so there's nothing else to do to make the call happen\n\t\t\t'__call metamethod\n\t\tEndIf\n\tEnd Function\n\tFunction TCALL(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t\t'implement this properly\n\t\tCALL(stk, bc, retptr)\n\tEnd Function\n\tFunction RET:Byte Ptr(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"RET \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp\n\t\tLocal rp0:Byte Ptr = Byte Ptr Ptr(retptr)[-4], rp:Byte Ptr = rp0 + IP_OFFSET\n\t\t\n\t\tLocal oldStk:Stack = stk.prevBase\n\t\tLocal retv:Long Ptr = varp + rp[0]\n\t\tIf oldStk\n\t\t\toldStk.retv = retv\n\t\t\toldStk.retc = Int Ptr(rp + 1)[0]\n\t\t\tByte Ptr Ptr(retptr)[-4] = stk.retIP\n\t\t\tByte Ptr Ptr(retptr)[-3] = Byte Ptr(oldStk)\n\t\t\tByte Ptr Ptr(retptr)[-2] = Byte Ptr(oldStk.func) + BYTECODE_INC\n\t\tElse\t'return to native code\n\t\t\tLocal codePage:Byte Ptr = Byte Ptr(Int(rp0) & ((Int(2^12)-1) Shl 20))\n\t\t\tByte Ptr Ptr(retptr)[-4] = codePage + 4\n\t\t\tReturn retv\n\t\tEndIf\n\tEnd Function\n\tFunction RETVA(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t\tLocal convert:BlueVM(p:Byte Ptr) = Byte Ptr(Identity), vm:BlueVM = convert(stk.func.vm)\n\t\tvm.Error(\"vararg return not yet implemented\")\n\tEnd Function\n\tFunction POSTCALL(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"POSTCALL \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal rneed:Int = Int Ptr(rp + 1)[0], rmin:Int = Min(rneed, stk.retc)\n\t\tFor Local r:Int = 0 Until rmin\n\t\t\t(varp + rp[0])[r] = stk.retv[r]\n\t\t'\tPrint \" return \" + r + \": \" + Double Ptr(stk.retv)[r]\n\t\tNext\n\t\tFor Local r:Int = rmin Until rneed\t'nil the rest\n\t\t\t(varp + rp[0])[r] = BlueVMMemory.NIL\n\t\tNext\n\tEnd Function\n\tFunction VARARG(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t\tLocal convert:BlueVM(p:Byte Ptr) = Byte Ptr(Identity), vm:BlueVM = convert(stk.func.vm)\n\t\tvm.Error(\"varargs not yet implemented\")\n\tEnd Function\n\tFunction VAINIT(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t\tLocal convert:BlueVM(p:Byte Ptr) = Byte Ptr(Identity), vm:BlueVM = convert(stk.func.vm)\n\t\tvm.Error(\"vararg initialization not yet implemented\")\n\tEnd Function\n\tFunction CALLINIT(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t\tLocal convert:BlueVM(p:Byte Ptr) = Byte Ptr(Identity), vm:BlueVM = convert(stk.func.vm)\n\t\tvm.Error(\"variable-length call initialization not yet implemented\")\n\tEnd Function\n\t\n\t\n\tFunction PrepareCall:Int(fp:Int Ptr, stk:Stack, rp:Byte Ptr, varp:Long Ptr, retptr:Byte Ptr)\n\t\tIf fp[1] = BlueTypeTag.NANBOX | BlueTypeTag.FUN\n\t\t\tLocal newStk0:Stack ; Byte Ptr Ptr(Varptr(newStk0))[0] = Byte Ptr(stk) + stk.func.frameSz\n\t\t\tLocal newStk:Stack = newStk0\t'micro-opt: newStk0 can't be a register because of the unwieldy conversion\n\t\t\t\n\t\t\tnewStk.retIP = Byte Ptr Ptr(retptr)[-4]\n\t\t\tnewStk.prevBase = stk\n\t\t\tLocal closure:Byte Ptr = Byte Ptr(fp[0])\n\t\t\tLocal newBC:Bytecode = Bytecode Ptr(closure)[0]\n\t\t\tLocal voff:Int = STACKFRAME_INC + 4 * newBC.upvars\n\t\t\tnewStk.varp = Long Ptr(Byte Ptr(newStk) + voff)\n\t\t\tnewStk.func = newBC\n\t\t\t\n\t\t\tLocal argc_actual:Int = Short Ptr(rp)[1], argc_required:Int = newBC.pcount\n\t\t'\tLocal argc_min:Int ; If argc_actual < argc_required Then argc_min = argc_actual Else argc_min = argc_required\n\t\t\tLocal argc_min:Int = argc_actual - argc_required ; argc_min = (argc_min & (argc_min Shr 31)) + argc_required 'branchless 32-bit Min\n\t\t\t\n\t\t\tLocal argv:Long Ptr = varp + rp[1], destv:Long Ptr = newStk.varp\n\t\t\tFor Local a:Int = 0 Until argc_min\n\t\t\t\tdestv[a] = argv[a]\n\t\t\t'\tPrint \" arg \" + a + \": \" + argv[a]\n\t\t\tNext\n\t\t\tFor Local a:Int = argc_min Until argc_required\t'nil any unfilled parameters\n\t\t\t\tInt Ptr(destv + a)[1] = BlueTypeTag.NANBOX | BlueTypeTag.NIL\n\t\t\tNext\n\t\t\tnewStk.argv = argv + argc_min\t'argv should be to the varargs (if any)\n\t\t\tnewStk.argc = argc_actual - argc_min\t'argc is the number of varargs\n\t\t\t\n\t\t\tLocal destup:Byte Ptr Ptr = Byte Ptr Ptr(Byte Ptr(newStk) + STACKFRAME_INC)\n\t\t\tLocal upv:Byte Ptr Ptr = Byte Ptr Ptr(closure + 8)\n\t\t\tFor Local up:Int = 0 Until newBC.upvars\t'emplace upvars\n\t\t\t\tdestup[up] = upv[up]\n\t\t\t'\tPrint \" upv \" + up + \": \" + destv[up]\n\t\t\t'\tPrint \" val: \" + Double Ptr Ptr(Byte Ptr Ptr(closure) + 2 + up)[0][0]\n\t\t\tNext\n\t\t\t\n\t\t\t'note that the following OVERWRITE THE PARAMETERS (in release mode), so no touching stk from here on\n\t\t\tByte Ptr Ptr(retptr)[-4] = newBC.mcode\n\t\t\tByte Ptr Ptr(retptr)[-3] = Byte Ptr(newStk)\n\t\t\tByte Ptr Ptr(retptr)[-2] = Byte Ptr(newBC) + BYTECODE_INC\n\t\t\t\n\t\tElseIf fp[1] = BlueTypeTag.NANBOX | BlueTypeTag.NATFUN\t'native call\n\t\t\tLocal fun:Int(vm:BlueVM, ac:Int, av:Long Ptr, rv:Long Ptr) = Byte Ptr(fp[0])\n\t\t\tLocal argc:Int = Short Ptr(rp)[1], argv:Long Ptr = varp + rp[1], retv:Long Ptr = Long Ptr(Byte Ptr(stk) + stk.func.frameSz)\n\t\t\tLocal convert:BlueVM(p:Byte Ptr) = Byte Ptr(Identity), vm:BlueVM = convert(stk.func.vm)\n\t\t\tstk.retc = fun(vm, argc, argv, retv)\n\t\t\tstk.retv = retv\n\t\tElse\n\t\t\tReturn False\t'not a function; take appropriate action\n\t\tEndIf\n\t\tReturn True\t'all good and will auto-call when the caller returns\n\tEnd Function\n\t\n\tFunction IndexMetamethod(bc:Bytecode, retptr:Byte Ptr, d:Long Ptr, tbl:Long, key:Long)\t'prep but not execute a call\n\t\t'need to work out a way to return values from this without POSTCALL (maybe can co-opt RET to handle singles by itself)\n\t\tLocal convert:BlueVM(p:Byte Ptr) = Byte Ptr(Identity), vm:BlueVM = convert(bc.vm)\n\t\tvm.Error(\"metamethod access isn't implemented yet\")\n\tEnd Function\n\tFunction NewindexMetamethod(bc:Bytecode, retptr:Byte Ptr, d:Long, val:Long, key:Long)\t'as above\n\t\tLocal convert:BlueVM(p:Byte Ptr) = Byte Ptr(Identity), vm:BlueVM = convert(bc.vm)\n\t'\tvm.Error(\"metamethod access isn't implemented yet\")\n\t\t'just rawset it for now\n\t\t'remember to handle nil key (what is correct?)\n\t\tLocal tabp:Byte Ptr = Byte Ptr(Int(d))\n\t\tBlueTable.RawSet(vm.mem, tabp, key, val)\n\tEnd Function\n\t\n\tFunction BinopMetamethod(op:Int, bc:Bytecode, retptr:Byte Ptr, d:Long Ptr, r:Long Ptr, l:Long Ptr)\t'as above\n\t\tLocal convert:BlueVM(p:Byte Ptr) = Byte Ptr(Identity), vm:BlueVM = convert(bc.vm)\n\t\tvm.Error(\"metamethod access isn't implemented yet\")\n\tEnd Function\n\t\n\tFunction InitOpTbl()\n\t\topc = New BlueOpcode\n\t\topTbl = [MOV, GETLC, SETLC, LOADK, LOADSI, LOADBOOL, LOADNIL, ..\n\t\t\tGETTAB, GETTABSI, SETTAB, SETTABSI, GETTABI, SETTABI, GETUPV, SETUPV, ..\n\t\t\tNEWTAB, CLOSURE, NEWUPV, ..\n\t\t\tADD, SUB, MUL, DIV, NMOD, POW, CAT, ..\n\t\t\tIDIV, BAND, BOR, BXOR, BSHL, BSHR, ..\n\t\t\tUNM, LNOT, ALEN, BNOT, UNP, ..\n\t\t\tEQ, LT, LEQ, ..\n\t\t\tJMP, JIF, JNOT, CALL, TCALL, RETVA, RETVA, ..\t'not a mistake: RET doesn't fit but we need the spacer\n\t\t\tPOSTCALL, VARARG, VAINIT, CALLINIT]\n\t\t\n\t\topTbl[opc.RET] = Byte Ptr(RET)\n\tEnd Function\n\t\n\tFunction Identity:Byte Ptr(b:Byte Ptr)\n\t\tReturn b\n\tEnd Function\n\tFunction PointerToExtType:Byte Ptr(p:Byte Ptr)\t'horrible pointer abuse (increment down so we can ignore the nonexistent vtbl)\n\t\tReturn p - SizeOf(Byte Ptr(0))\n\tEnd Function\n\tGlobal BPtoS:Stack(p:Byte Ptr) = Byte Ptr(BlueJIT.PointerToExtType)\nEnd Type\n\n","old_contents":"\n' Blue Moon\n' JIT engine\/opcodes\n\n' this is the core of the runtime: the machine code generator and opcodes\n' it's a halfway blend between JIT and interpreter: a basic JIT generates machine code\n' for \"unrolled\" interpreter loops, theoretically (ha!) providing a speed boost\n' it can also \"inline\" selected operations, coming closer to being a true JIT\n\n' for now this is an Include rather than Import lib due to recursive dependency\n' we'll fix that later\n\nRem\nSuperStrict\n\nImport \"blueerror.bmx\"\nImport \"bluevm.bmx\"\nImport etc etc...\nEnd Rem\n\n'Private\t'may need to rename and open these (in the shared interface?)\nExtern\n\tType Stack\n\t\tField retIP:Byte Ptr, prevBase:Stack, varp:Long Ptr, func:Bytecode, _:Long Ptr, argv:Long Ptr, retv:Long Ptr, argc:Short, retc:Short\n\tEnd Type\n\tType Bytecode\n\t\tField mcode:Byte Ptr, idMod:Int, kcount:Int, pcount:Int, upvars:Int, frameSz:Int, icount:Int, vm:Byte Ptr\n\tEnd Type\nEnd Extern\n'Public\n\nType BlueJIT Final\n\tConst PROLOGUESZ:Int = 25, ISIZE:Int = 5\n\t\n\tGlobal opTbl:Int(s:Stack, b:Bytecode, r:Byte Ptr)[], opc:BlueOpcode\n\tGlobal Prologue:Int[] = [ ..\n\t\t$90, $90, ..\n\t\t$8b, $44, $24, $04, .. 'mov 4(%esp), %eax\n\t\t$89, $44, $24, $f4, .. 'mov %eax, -12(%esp)\n\t\t$c7, $44, $24, $f8, $FF, $FF, $FF, $FF, .. 'movl ########, -8(%esp)\n\t\t$89, $64, $24, $fc, .. 'mov %esp, -4(%esp)\n\t\t$83, $ec, $0c.. 'sub $12, %esp\n\t]\n\t\n\tFunction Compile:Byte Ptr(vm:BlueVM, ins:Byte Ptr, icount:Int, bytecode:Bytecode)\n\t\t?Not x86\n\t\tRuntimeError \"The Blue Moon JIT does not support your platform (x86-32 only at this time)\"\n\t\t?\n\t\tAssert SizeOf(0:Long) = SizeOf(0:Double) And SizeOf(0:Int) = 4 And SizeOf(0:Long) = 8 And SizeOf(Byte Ptr(0)) = 4, ..\n\t\t\t\"assumptions about platform datatype sizes are invalid\"\n\t\t\n\t\tIf opTbl = Null Then InitOpTbl()\n\t\t\n\t\t' compute executable code size\n\t\tLocal codesize:Int = PROLOGUESZ, opPos:Int[icount]\t'since sizes are irregular, looking up offsets is easiest\n\t\tFor Local i:Int = 0 Until icount\n\t\t\topPos[i] = codesize\t'finalized below\n\t\t\tSelect ins[i * 8]\n\t\t\t\tCase opc.SETTAB, opc.GETTAB\n\t\t\t\t\tcodesize :+ ISIZE * 2\n\t\t\t\tDefault\n\t\t\t\t\tcodesize :+ ISIZE\n\t\t\tEnd Select\n\t\tNext\n\t\t\n\t\t' allocate executable space\n\t\tLocal code:Byte Ptr = vm.mem.AllocCodeBlock(codesize)\n\t\t\n\t\t'finalize op offsets se we can look them up\n\t\tFor Local i:Int = 0 Until icount\n\t\t\topPos[i] :+ Int(code)\t'direct to executable space\n\t\tNext\n\t\t\n\t\t' emplace prologue (used for calling in from native only)\n\t\tFor Local p:Int = 0 Until PROLOGUESZ\n\t\t\tcode[p] = Prologue[p]\n\t\tNext\n\t\tByte Ptr Ptr(code + 14)[0] = Byte Ptr(bytecode)\t'replace the ########\n\t\t\n\t\t' epilogue (shared location per-vm, probably already set)\n\t\tvm.mem.returnToNative[0] = $c30cc483\t'add $12, %esp ; ret - i.e. restore the stack to normal\n\t\t\n\t\tLocal ktable:Long Ptr = Long Ptr(ins + 8 * bytecode.icount + 8 * bytecode.upvars)\t'constant table\n\t\t\n\t\t' generate machine code!\n\t\tFor Local i:Int = 0 Until icount\t'emplace opcode calls and supporting bytecode data\n\t\t\tLocal codep:Byte Ptr = Byte Ptr(opPos[i]), bytecodep:Byte Ptr = Byte Ptr(Int(codep) + vm.mem.PAGESZ)\n\t\t\tLocal bi:Int = i * 8, op:Int = ins[bi], ip:Int Ptr = Int Ptr(ins + bi), func:Byte Ptr = opTbl[op]\n\t\t\t\n\t\t\tcodep[0] = $e8\t'call\n\t\t\tByte Ptr Ptr(codep + 1)[0] = func - Int(codep + ISIZE)\n\t\t\t\n\t\t\tbytecodep[0] = ins[bi + 1] ; bytecodep[1] = ins[bi + 2]\t'used by most, may get overwritten\n\t\t\t\n\t\t\tSelect op\n\t\t\t\tCase opc.LOADSI, opc.CLOSURE, opc.RET, opc.POSTCALL\n\t\t\t\t\tInt Ptr(bytecodep + 1)[0] = ip[1]\n\t\t\t\t\t\n\t\t\t\tCase opc.LOADK\n\t\t\t\t\tLong Ptr Ptr(bytecodep + 1)[0] = ktable + ip[1]\n\t\t\t\t\t\n\t\t\t\tCase opc.SETTABSI, opc.GETTABSI\n\t\t\t\t\tShort Ptr(bytecodep)[1] = ip[1]\n\t\t\t\t\t\n\t\t\t\tCase opc.SETTAB, opc.GETTAB\n\t\t\t\t\tcodep[ISIZE] = $90 ; Int Ptr(codep + ISIZE + 1)[0] = $90909090\t'nops; the space is needed in the bytecode\n\t\t\t\t\tLong Ptr Ptr(bytecodep + 2)[0] = ktable + ip[1]\n\t\t\t\t\tLong Ptr Ptr(bytecodep + 2)[1] = Null\t'inline cache space\n\t\t\t\t\t\n\t\t\t\tCase opc.GETUPV\n\t\t\t\t\tIf Int Ptr(ins + icount * 8)[2 * bytecodep[1]] = -1\n\t\t\t\t\t\tByte Ptr Ptr(codep + 1)[0] = Byte Ptr(BlueJIT.GETENV) - Int(codep + ISIZE)\n\t\t\t\t\t\tByte Ptr Ptr(bytecodep + 1)[0] = Varptr(vm._ENV.val)\t'note: doesn't allow _ENV to be changed from Max\n\t\t\t\t\tEndIf\n\t\t\t\t\t\n\t\t\t\tCase opc.CALL\n\t\t\t\t\tShort Ptr(bytecodep)[1] = ip[1]\n\t\t\t\t\t\n\t\t\t\tCase opc.JIF, opc.JNOT\n\t\t\t\t\tInt Ptr(bytecodep + 1)[0] = opPos[i + ip[1]]\n\t\t\t\t\t\n\t\t\t\tCase opc.JMP\n\t\t\t\t\tcodep[0] = $e9\t'use a true jump\n\t\t\t\t\tInt Ptr(codep + 1)[0] = opPos[i + ip[1]] - (opPos[i] + ISIZE)\n\t\t\t\t\t\n\t\t\t\tDefault\t'binary operations A = B op C\n\t\t\t\t\tbytecodep[2] = ip[1]\n\t\t\tEnd Select\n\t\tNext\n\t\t\n\t\tReturn code\n\tEnd Function\n\t\n\t\n\tConst STACKFRAME_INC:Int = BlueVMMemory.STACKFRAMESZ + 4, BYTECODE_INC:Int = BlueVMMemory.BYTECODESZ + 4\n\tConst IP_OFFSET:Int = BlueVMMemory.PAGESZ - ISIZE\n\t\n\t\n\t'note: extern vars must take into account the vtbl offset, so that converting from a typed pointer can be a simple cast (faster)\t\n\t\n\tFunction MOV(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"MOV \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tvarp[rp[0]] = varp[rp[1]]\n\tEnd Function\n\tFunction GETLC(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"GETLC \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tvarp[rp[0]] = Long Ptr Ptr(varp + rp[1])[0][0]\n\tEnd Function\n\tFunction SETLC(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"SETLC \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal convert:BlueVM(p:Byte Ptr) = Byte Ptr(Identity), vm:BlueVM = convert(bc.vm)\n\t\tvm.mem.Write(Long Ptr Ptr(varp + rp[0])[0], varp[rp[1]])\t'unlikely but technically possible to need this\n\tEnd Function\n\tFunction LOADK(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"LOADK \/\/\"\n\t\tLocal rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET, varp:Long Ptr = stk.varp + rp[0], kp:Long Ptr = Long Ptr Ptr(rp + 1)[0]\n\t\tvarp[0] = kp[0]\n\tEnd Function\n\tFunction LOADSI(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"LOADSI \/\/\"\n\t\tLocal rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal val:Int = Int Ptr(rp + 1)[0]\n\t\tDouble Ptr(stk.varp)[rp[0]] = Double(val)\n\tEnd Function\n\tFunction LOADBOOL(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"LOADBOOL \/\/\"\n\t\tLocal rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET, vp:Int Ptr = Int Ptr(stk.varp + rp[0])\n\t\tvp[1] = BlueTypeTag.NANBOX | BlueTypeTag.BOOL\n\t\tvp[0] = Int Ptr(rp + 1)[0]\n\tEnd Function\n\tFunction LOADNIL(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"LOADNIL \/\/\"\n\t\tLocal rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tInt Ptr(stk.varp + rp[0])[1] = BlueTypeTag.NANBOX | BlueTypeTag.NIL\n\tEnd Function\n\t\n\tFunction GETTAB(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"GETTAB \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET, kp:Long Ptr = Long Ptr Ptr(rp + 2)[0]\n\t\tLocal tabp:Byte Ptr = Byte Ptr Ptr(varp + rp[1])[0]\n\t\tIf Int Ptr(varp + rp[1])[1] = BlueTypeTag.TBLBOX\n\t\t\tLocal keyslot:Long Ptr = Null, slot:Long Ptr = BlueTable.GetSlot(tabp, kp[0], Varptr(keyslot))\n\t\t\tIf (slot = Null) Or (keyslot[0] <> kp[0])\n\t\t\t\tIf keyslot = Long Ptr(1) Then varp[rp[0]] = BlueVMMemory.NIL ; Return\t'nil key\n\t\t\tElse\n\t\t\t\tvarp[rp[0]] = slot[0] ; Return\n\t\t\tEndIf\n\t\tEndIf\n\t\tIndexMetamethod bc, retptr, varp + rp[0], varp[rp[1]], kp[0]\t'not in table; invoke metamethod\n\tEnd Function\n\tFunction GETTABSI(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"GETTABSI \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal tabp:Byte Ptr = Byte Ptr Ptr(varp + rp[1])[0], key:Long ; Double Ptr(Varptr(key))[0] = Short Ptr(rp)[1]\n\t\tIf Int Ptr(varp + rp[0])[1] = BlueTypeTag.TBLBOX\n\t\t\tLocal keyslot:Long Ptr = Null, slot:Long Ptr = BlueTable.GetSlot(tabp, key, Varptr(keyslot))\n\t\t\tIf Not (slot = Null Or (keyslot And keyslot[0] <> key)) Then varp[rp[0]] = slot[0] ; Return\n\t\t\tIf keyslot = Long Ptr(1) Then varp[rp[0]] = BlueVMMemory.NIL ; Return\n\t\tEndIf\n\t\tIndexMetamethod bc, retptr, varp + rp[0], varp[rp[1]], key\n\tEnd Function\n\tFunction SETTAB(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"SETTAB \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal tabvp:Byte Ptr = varp + rp[0], kp:Long Ptr = Long Ptr Ptr(rp + 2)[0]\n\t\tIf Int Ptr(tabvp)[1] = BlueTypeTag.TBLBOX\n\t\t\tLocal keyslot:Long Ptr = Null, slot:Long Ptr = BlueTable.GetSlot(Byte Ptr Ptr(tabvp)[0], kp[0], Varptr(keyslot))\n\t\t\tIf Not (slot = Null Or keyslot[0] <> kp[0]) Then slot[0] = varp[rp[1]] ; Return\n\t\tEndIf\n\t\tNewindexMetamethod bc, retptr, varp[rp[0]], varp[rp[1]], kp[0]\t'not in table; invoke metamethod or rawset\n\tEnd Function\n\tFunction SETTABSI(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"SETTABSI \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET, tabvp:Byte Ptr = varp + rp[0]\n\t\tLocal key:Long ; Double Ptr(Varptr(key))[0] = Short Ptr(rp)[1]\n\t\tIf Int Ptr(tabvp)[1] = BlueTypeTag.TBLBOX\n\t\t\tLocal keyslot:Long Ptr = Null, slot:Long Ptr = BlueTable.GetSlot(Byte Ptr Ptr(tabvp)[0], key, Varptr(keyslot))\n\t\t\tIf Not (slot = Null Or (keyslot And keyslot[0] <> key)) Then slot[0] = varp[rp[1]] ; Return\n\t\tEndIf\n\t\tNewindexMetamethod bc, retptr, Long Ptr(tabvp)[0], varp[rp[1]], key\n\tEnd Function\n\tFunction GETTABI(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"GETTABI \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal tabvp:Byte Ptr = varp + rp[1], key:Long = varp[rp[2]]\n\t\tIf Int Ptr(tabvp)[1] = BlueTypeTag.TBLBOX\n\t\t\tLocal keyslot:Long Ptr = Null, slot:Long Ptr = BlueTable.GetSlot(Byte Ptr Ptr(tabvp)[0], key, Varptr(keyslot))\n\t\t\tIf Not (slot = Null Or (keyslot And keyslot[0] <> key)) Then varp[rp[0]] = slot[0] ; Return\n\t\tEndIf\n\t\tIndexMetamethod bc, retptr, varp + rp[0], Long Ptr(tabvp)[0], key\n\tEnd Function\n\tFunction SETTABI(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"SETTABI \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal tabvp:Byte Ptr = varp + rp[0], key:Long = varp[rp[2]]\n\t\tIf Int Ptr(tabvp)[1] = BlueTypeTag.TBLBOX\n\t\t\tLocal keyslot:Long Ptr = Null, slot:Long Ptr = BlueTable.GetSlot(Byte Ptr Ptr(tabvp)[0], key, Varptr(keyslot))\n\t\t\tIf Not (slot = Null Or (keyslot And keyslot[0] <> key)) Then slot[0] = varp[rp[1]] ; Return\n\t\tEndIf\n\t\tNewindexMetamethod bc, retptr, Long Ptr(tabvp)[0], varp[rp[1]], key\n\tEnd Function\n\tFunction GETUPV(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"GETUPV \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal upvp:Byte Ptr Ptr = Byte Ptr Ptr(Byte Ptr(stk) + STACKFRAME_INC), valp:Long Ptr = Long Ptr(upvp[rp[1]])\n\t\tvarp[rp[0]] = valp[0]\n\tEnd Function\n\tFunction GETENV(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\t'\"unlisted\" instruction: GETUPV for _ENV is translated into this at load-time\n\t'\tPrint \"GETENV \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tvarp[rp[0]] = Long Ptr Ptr(rp + 1)[0][0]\t'type check should not be necessary (will be handled by following op)\n\tEnd Function\n\tFunction SETUPV(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"SETUPV \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal convert:BlueVM(p:Byte Ptr) = Byte Ptr(Identity), vm:BlueVM = convert(bc.vm)\n\t\tLocal upvp:Byte Ptr Ptr = Byte Ptr Ptr(Byte Ptr(stk) + STACKFRAME_INC), valp:Long Ptr = Long Ptr(upvp[rp[0]])\n\t\tvm.mem.Write(valp, varp[rp[1]])\n\tEnd Function\n\tFunction NEWTAB(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"NEWTAB \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal convert:BlueVM(p:Byte Ptr) = Byte Ptr(Identity), vm:BlueVM = convert(bc.vm)\n\t\tLocal tab:Byte Ptr = vm.mem.AllocTable(Null)\n\t\tLocal d:Int Ptr = Int Ptr(varp + rp[0])\n\t\td[0] = Int(tab) ; d[1] = BlueTypeTag.TBLBOX\n\tEnd Function\n\tFunction CLOSURE(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"CLOSURE \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal convert:BlueVM(p:Byte Ptr) = Byte Ptr(Identity), vm:BlueVM = convert(bc.vm)\n\t\tLocal d:Int Ptr = Int Ptr(varp + rp[0])\n\t\tLocal cbytecode:Bytecode = vm.funIndex[Int Ptr(rp + 1)[0]], upvp:Int Ptr = Int Ptr(Byte Ptr(cbytecode) + BYTECODE_INC + 8 * cbytecode.icount)\n\t\tLocal closure:Byte Ptr = vm.mem.AllocClosure(cbytecode, cbytecode.upvars)\t'upvars is always even (alignment)\n\t\t\n\t\t'get upvalues off the stack\n\t\tFor Local u:Int = 0 Until cbytecode.upvars\n\t\t\tIf upvp[2 * u]\n\t\t\t\tByte Ptr Ptr(closure)[2 + u] = Byte Ptr Ptr(Byte Ptr(stk) + STACKFRAME_INC)[upvp[2 * u + 1]]\n\t\t\tElse\n\t\t\t\tByte Ptr Ptr(closure)[2 + u] = Byte Ptr Ptr(varp + upvp[2 * u + 1])[0]\n\t\t\tEndIf\n\t\tNext\n\t\t\n\t\td[0] = Int(closure) ; d[1] = BlueTypeTag.FUNBOX\n\tEnd Function\n\tFunction NEWUPV(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"NEWUPV \/\/\"\n\t\tLocal rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal convert:BlueVM(p:Byte Ptr) = Byte Ptr(Identity), vm:BlueVM = convert(bc.vm)\n\t\tLocal upv:Byte Ptr = vm.mem.AllocObject(8, BlueTypeTag.UPV), d:Int Ptr = Int Ptr(stk.varp + rp[0])\n\t\tLong Ptr(upv)[0] = Long Ptr(d)[0]\t'promote a value if it existed (useful for parameters)\n\t\td[0] = Int(upv) ; d[1] = BlueTypeTag.NANBOX | BlueTypeTag.UPV\n\tEnd Function\n\t\n\tFunction ADD(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t\tPrint \"ADD \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal d:Double Ptr = Double Ptr(varp + rp[0])\n\t\tLocal r:Int Ptr = Int Ptr(varp + rp[1]), l:Int Ptr = Int Ptr(varp + rp[2])\n\t\tIf l[1] & BlueTypeTag.NANBOX_CHK = BlueTypeTag.NANBOX Or r[1] & BlueTypeTag.NANBOX_CHK = BlueTypeTag.NANBOX\n\t\t\tDebugStop\n\t\tElse\n\t\t\tPrint \" \" + Double Ptr(l)[0] + \" \" + Double Ptr(r)[0]\n\t\t\td[0] = Double Ptr(l)[0] + Double Ptr(r)[0]\n\t\tEndIf\n\tEnd Function\n\tFunction SUB(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction MUL(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction DIV(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction NMOD(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction POW(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction CAT(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction IDIV(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction BAND(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction BOR(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction BXOR(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction BSHL(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction BSHR(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction UNM(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction LNOT(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction ALEN(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction BNOT(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction UNP(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction EQ(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"EQ \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = (Byte Ptr Ptr(retptr) - 4)[0] + IP_OFFSET\n\t\tLocal r:Double = Double Ptr(varp)[rp[1]]\n\t\tLocal l:Double = Double Ptr(varp)[rp[2]]\n\t\tInt Ptr(varp + rp[0])[0] = l = r\n\tEnd Function\n\tFunction LT(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction LEQ(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\t\n\tFunction JMP(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t\tRuntimeError \"wait, why are we here?\"\n\tEnd Function\n\tFunction JIF(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"JIF \/\/\"\n\t\tLocal rp:Byte Ptr = (Byte Ptr Ptr(retptr) - 4)[0] + IP_OFFSET\n\t\tIf Int Ptr(stk.varp + rp[0])[0]\n\t\t\tLocal target:Int = Int Ptr(rp + 1)[0]\n\t\t\tInt Ptr(retptr)[-4] = target\n\t\tEndIf\n\tEnd Function\n\tFunction JNOT(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction CALL(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"CALL \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal fp:Int Ptr = Int Ptr(varp + rp[0])\n\t\tIf Not PrepareCall(fp, stk, rp, varp, retptr)\t'PrepareCall sets everything up so there's nothing else to do to make the call happen\n\t\t\t'__call metamethod\n\t\tEndIf\n\tEnd Function\n\tFunction TCALL(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction RET:Byte Ptr(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"RET \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp\n\t\tLocal rp0:Byte Ptr = Byte Ptr Ptr(retptr)[-4], rp:Byte Ptr = rp0 + IP_OFFSET\n\t\t\n\t\tLocal oldStk:Stack = stk.prevBase\n\t\tLocal retv:Long Ptr = varp + rp[0]\n\t\tIf oldStk\n\t\t\toldStk.retv = retv\n\t\t\toldStk.retc = Int Ptr(rp + 1)[0]\n\t\t\tByte Ptr Ptr(retptr)[-4] = stk.retIP\n\t\t\tByte Ptr Ptr(retptr)[-3] = Byte Ptr(oldStk)\n\t\t\tByte Ptr Ptr(retptr)[-2] = Byte Ptr(oldStk.func) + BYTECODE_INC\n\t\tElse\t'return to native code\n\t\t\tLocal codePage:Byte Ptr = Byte Ptr(Int(rp0) & ((Int(2^12)-1) Shl 20))\n\t\t\tByte Ptr Ptr(retptr)[-4] = codePage + 4\n\t\t\tReturn retv\n\t\tEndIf\n\tEnd Function\n\tFunction RETVA(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction POSTCALL(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"POSTCALL \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp\n\t\tLocal rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\t\n\t\tFor Local r:Int = 0 Until Min(Int Ptr(rp + 1)[0], stk.retc)\n\t\t\t(varp + rp[0])[r] = stk.retv[r]\n\t\t'\tPrint \" return \" + r + \": \" + Double Ptr(stk.retv)[r]\n\t\tNext\n\t\t'nil the rest\n\tEnd Function\n\tFunction VARARG(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction VAINIT(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction CALLINIT(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\t\n\t\n\tFunction PrepareCall:Int(fp:Int Ptr, stk:Stack, rp:Byte Ptr, varp:Long Ptr, retptr:Byte Ptr)\n\t\tIf fp[1] = BlueTypeTag.NANBOX | BlueTypeTag.FUN\n\t\t\tLocal newStk0:Stack ; Byte Ptr Ptr(Varptr(newStk0))[0] = Byte Ptr(stk) + stk.func.frameSz\n\t\t\tLocal newStk:Stack = newStk0\t'micro-opt: newStk0 can't be a register because of the unwieldy conversion\n\t\t\t\n\t\t\tnewStk.retIP = Byte Ptr Ptr(retptr)[-4]\n\t\t\tnewStk.prevBase = stk\n\t\t\tLocal closure:Byte Ptr = Byte Ptr(fp[0])\n\t\t\tLocal newBC:Bytecode = Bytecode Ptr(closure)[0]\n\t\t\tLocal voff:Int = STACKFRAME_INC + 4 * newBC.upvars\n\t\t\tnewStk.varp = Long Ptr(Byte Ptr(newStk) + voff)\n\t\t\tnewStk.func = newBC\n\t\t\t\n\t\t\tLocal argc_actual:Int = Short Ptr(rp)[1], argc_required:Int = newBC.pcount\n\t\t'\tLocal argc_min:Int ; If argc_actual < argc_required Then argc_min = argc_actual Else argc_min = argc_required\n\t\t\tLocal argc_min:Int = argc_actual - argc_required ; argc_min = (argc_min & (argc_min Shr 31)) + argc_required 'branchless 32-bit Min\n\t\t\t\n\t\t\tLocal argv:Long Ptr = varp + rp[1], destv:Long Ptr = newStk.varp\n\t\t\tFor Local a:Int = 0 Until argc_min\n\t\t\t\tdestv[a] = argv[a]\n\t\t\t'\tPrint \" arg \" + a + \": \" + argv[a]\n\t\t\tNext\n\t\t\tFor Local a:Int = argc_min Until argc_required\t'nil any unfilled parameters\n\t\t\t\tInt Ptr(destv + a)[1] = BlueTypeTag.NANBOX | BlueTypeTag.NIL\n\t\t\tNext\n\t\t\tnewStk.argv = argv + argc_min\t'argv should be to the varargs (if any)\n\t\t\tnewStk.argc = argc_actual - argc_min\t'argc is the number of varargs\n\t\t\t\n\t\t\tLocal destup:Byte Ptr Ptr = Byte Ptr Ptr(Byte Ptr(newStk) + STACKFRAME_INC)\n\t\t\tLocal upv:Byte Ptr Ptr = Byte Ptr Ptr(closure + 8)\n\t\t\tFor Local up:Int = 0 Until newBC.upvars\t'emplace upvars\n\t\t\t\tdestup[up] = upv[up]\n\t\t\t'\tPrint \" upv \" + up + \": \" + destv[up]\n\t\t\t'\tPrint \" val: \" + Double Ptr Ptr(Byte Ptr Ptr(closure) + 2 + up)[0][0]\n\t\t\tNext\n\t\t\t\n\t\t\t'note that the following OVERWRITE THE PARAMETERS (in release mode), so no touching stk from here on\n\t\t\tByte Ptr Ptr(retptr)[-4] = newBC.mcode\n\t\t\tByte Ptr Ptr(retptr)[-3] = Byte Ptr(newStk)\n\t\t\tByte Ptr Ptr(retptr)[-2] = Byte Ptr(newBC) + BYTECODE_INC\n\t\t\t\n\t\tElseIf fp[1] = BlueTypeTag.NANBOX | BlueTypeTag.NATFUN\t'native call\n\t\t\tLocal fun:Int(vm:BlueVM, ac:Int, av:Long Ptr, rv:Long Ptr) = Byte Ptr(fp[0])\n\t\t\tLocal argc:Int = Short Ptr(rp)[1], argv:Long Ptr = varp + rp[1], retv:Long Ptr = Long Ptr(Byte Ptr(stk) + stk.func.frameSz)\n\t\t\tLocal convert:BlueVM(p:Byte Ptr) = Byte Ptr(Identity), vm:BlueVM = convert(stk.func.vm)\n\t\t\tstk.retc = fun(vm, argc, argv, retv)\n\t\t\tstk.retv = retv\n\t\tElse\n\t\t\tReturn False\t'not a function; take appropriate action\n\t\tEndIf\n\t\tReturn True\t'all good and will auto-call when the caller returns\n\tEnd Function\n\t\n\tFunction IndexMetamethod(bc:Bytecode, retptr:Byte Ptr, d:Long Ptr, tbl:Long, key:Long)\t'prep but not execute a call\n\t\t'need to work out a way to return values from this without POSTCALL (maybe can co-opt RET to handle singles by itself)\n\t\tLocal convert:BlueVM(p:Byte Ptr) = Byte Ptr(Identity), vm:BlueVM = convert(bc.vm)\n\t\tvm.Error(\"metamethod access isn't implemented yet\")\n\tEnd Function\n\tFunction NewindexMetamethod(bc:Bytecode, retptr:Byte Ptr, d:Long, val:Long, key:Long)\t'as above\n\t\tLocal convert:BlueVM(p:Byte Ptr) = Byte Ptr(Identity), vm:BlueVM = convert(bc.vm)\n\t'\tvm.Error(\"metamethod access isn't implemented yet\")\n\t\t'just rawset it for now\n\t\t'remember to handle nil key (what is correct?)\n\t\tLocal tabp:Byte Ptr = Byte Ptr(Int(d))\n\t\tBlueTable.RawSet(vm.mem, tabp, key, val)\n\tEnd Function\n\t\n\tFunction BinopMetamethod(op:Int, bc:Bytecode, retptr:Byte Ptr, d:Long Ptr, r:Long Ptr, l:Long Ptr)\t'as above\n\t\tLocal convert:BlueVM(p:Byte Ptr) = Byte Ptr(Identity), vm:BlueVM = convert(bc.vm)\n\t\tvm.Error(\"metamethod access isn't implemented yet\")\n\tEnd Function\n\t\n\tFunction InitOpTbl()\n\t\topc = New BlueOpcode\n\t\topTbl = [MOV, GETLC, SETLC, LOADK, LOADSI, LOADBOOL, LOADNIL, ..\n\t\t\tGETTAB, GETTABSI, SETTAB, SETTABSI, GETTABI, SETTABI, GETUPV, SETUPV, ..\n\t\t\tNEWTAB, CLOSURE, NEWUPV, ..\n\t\t\tADD, SUB, MUL, DIV, NMOD, POW, CAT, ..\n\t\t\tIDIV, BAND, BOR, BXOR, BSHL, BSHR, ..\n\t\t\tUNM, LNOT, ALEN, BNOT, UNP, ..\n\t\t\tEQ, LT, LEQ, ..\n\t\t\tJMP, JIF, JNOT, CALL, TCALL, RETVA, RETVA, ..\t'not a mistake: RET doesn't fit but we need the spacer\n\t\t\tPOSTCALL, VARARG, VAINIT, CALLINIT]\n\t\t\n\t\topTbl[opc.RET] = Byte Ptr(RET)\n\tEnd Function\n\t\n\tFunction Identity:Byte Ptr(b:Byte Ptr)\n\t\tReturn b\n\tEnd Function\n\tFunction PointerToExtType:Byte Ptr(p:Byte Ptr)\t'horrible pointer abuse (increment down so we can ignore the nonexistent vtbl)\n\t\tReturn p - SizeOf(Byte Ptr(0))\n\tEnd Function\n\tGlobal BPtoS:Stack(p:Byte Ptr) = Byte Ptr(BlueJIT.PointerToExtType)\nEnd Type\n\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"89808ba7c700943b85385a356b9d69f0bf5248d5","subject":"[variables] (v0.19) \tAdded TBoolVariable; documentation correction","message":"[variables] (v0.19)\n\tAdded TBoolVariable; documentation correction\n","repos":"komiga\/duct-max,komiga\/duct-max,komiga\/duct-max","old_file":"variables.mod\/variables.bmx","new_file":"variables.mod\/variables.bmx","new_contents":"\nRem\n\tCopyright (c) 2009 Tim Howard\n\t\n\tPermission is hereby granted, free of charge, to any person obtaining a copy\n\tof this software and associated documentation files (the \"Software\"), to deal\n\tin the Software without restriction, including without limitation the rights\n\tto use, copy, modify, merge, publish, distribute, sublicense, and\/or sell\n\tcopies of the Software, and to permit persons to whom the Software is\n\tfurnished to do so, subject to the following conditions:\n\t\n\tThe above copyright notice and this permission notice shall be included in\n\tall copies or substantial portions of the Software.\n\t\n\tTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n\tIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n\tFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n\tAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n\tLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n\tOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n\tTHE SOFTWARE.\n\t-----------------------------------------------------------------------------\n\t\n\tvariables.bmx (Contains: TV_INTEGER, TV_STRING, TV_FLOAT, TV_EVAL,\n\t\t\t\t\t\t\tTVariable, TStringVariable, TFloatVariable, TIntVariable, TEvalVariable, TIdentifier,\n\t\t\t\t\t\t\tTVariableMap, )\n\t\nEnd Rem\n\nSuperStrict\n\nRem\nbbdoc: Variables module\nEnd Rem\nModule duct.variables\n\nModuleInfo \"Version: 0.19\"\nModuleInfo \"Copyright: Tim Howard\"\nModuleInfo \"License: MIT\"\n\nModuleInfo \"History: Version 0.19\"\nModuleInfo \"History: Added TBoolVariable; documentation correction\"\nModuleInfo \"History: Version 0.18\"\nModuleInfo \"History: TIdentifier.AddValue now sets the variable's parent to itself\"\nModuleInfo \"History: Added SetParent and GetParent to TVaraible\"\nModuleInfo \"History: Version 0.17\"\nModuleInfo \"History: General cleanup\"\nModuleInfo \"History: Version 0.16\"\nModuleInfo \"History: Added SetAmbiguous to all TVariable types\"\nModuleInfo \"History: Added option to always use quoting with TStringVariables (on by default)\"\nModuleInfo \"History: Fixed TStringVariable.ConvToString returning of Null strings\"\nModuleInfo \"History: Version 0.15\"\nModuleInfo \"History: Change the Create method definition for easier use\"\nModuleInfo \"History: Changed the '\/eval::' recognizer to '\/e:' (as per SNode format change)\"\nModuleInfo \"History: Added the Copy method to every variable type\"\nModuleInfo \"History: Changed some formatting\"\nModuleInfo \"History: Version 0.14\"\nModuleInfo \"History: Changed type tabbing\"\nModuleInfo \"History: Fixed script output for TStringVariable (quotes are now only added if whitespace is present)\"\nModuleInfo \"History: Fixed script output for TIdentifier (identifier names can now contain whitespace, in which case they must be quoted)\"\nModuleInfo \"History: Version 0.13\"\nModuleInfo \"History: Added the DeSerializeUniversal function to TVariable\"\nModuleInfo \"History: Added Serialize and DeSerialize methods to all variable types\"\nModuleInfo \"History: Version 0.12\"\nModuleInfo \"History: Changed module name from 'variablemap' to 'variables'\"\nModuleInfo \"History: Moved all of duct.utilparser here\"\nModuleInfo \"History: Added the GetTVType function to all variable types\"\nModuleInfo \"History: Moved TV_* constants from duct.template here\"\nModuleInfo \"History: Version 0.11\"\nModuleInfo \"History: Added the ReportType function to all variable types\"\nModuleInfo \"History: Version 0.10\"\nModuleInfo \"History: Added the RawToVariable function to TVariable\"\nModuleInfo \"History: General code cleanup\"\nModuleInfo \"History: Version 0.09\"\nModuleInfo \"History: Corrected usage of syntax (in Returns, Cases, News and Selects)\"\nModuleInfo \"History: Version 0.08\"\nModuleInfo \"History: Added the TEvalVariable type\"\nModuleInfo \"History: Initial release\"\n\nImport brl.stream\nImport brl.linkedlist\n\nImport duct.etc\nImport duct.objectmap\n\nRem\n\tbbdoc: Template variable type for the TIntVariable type.\nEnd Rem\nConst TV_INTEGER:Int = 1\nRem\n\tbbdoc: Template variable type for the TTStringVariable type.\nEnd Rem\nConst TV_STRING:Int = 2\nRem\n\tbbdoc: Template variable type for the TFloatVariable type.\nEnd Rem\nConst TV_FLOAT:Int = 3\nRem\n\tbbdoc: Template variable type for the TEvalVariable type.\nEnd Rem\nConst TV_EVAL:Int = 4\nRem\n\tbbdoc: Template variable type for the TIdentifier type.\nEnd Rem\nConst TV_IDEN:Int = 5\nRem\n\tbbdoc: Template variable type for the TIdentifier type.\nEnd Rem\nConst TV_BOOL:Int = 6\n\nRem\n\tbbdoc: The Variable type.\n\tabout: This is the base variable type, you should extend from this to use it.\nEnd Rem\nType TVariable Abstract\n\t\n\tField m_name:String\n\tField m_parent:TVariable\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the variable's name.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetName(name:String)\n\t\tm_name = name\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the variable's name.\n\t\treturns: The variable's name.\n\tEnd Rem\n\tMethod GetName:String()\n\t\tReturn m_name\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the variable's parent.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetParent(parent:TVariable)\n\t\tm_parent = parent\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the variable's parent.\n\t\treturns: The variable's parent.\n\tEnd Rem\n\tMethod GetParent:TVariable()\n\t\tReturn m_parent\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Base method for setting the value of the variable to the given string (conversion).\n\tEnd Rem\n\tMethod SetAmbiguous(value:String) Abstract\n\t\n\tRem\n\t\tbbdoc: Base method for converting variable data to a script-ready string.\n\tEnd Rem\n\tMethod ConvToString:String() Abstract\n\t\n\tRem\n\t\tbbdoc: Base method for converting variable data to a printable\/usable-in-code string.\n\tEnd Rem\n\tMethod ValueAsString:String() Abstract\n\t\n'#end region (Field accessors)\n\t\n'#region Data handling\n\t\n\tRem\n\t\tbbdoc: Create a copy of the variable.\n\t\treturns: A clone of the variable.\n\tEnd Rem\n\tMethod Copy:TVariable() Abstract\n\t\n\tRem\n\t\tbbdoc: Serialize the variable to a stream.\n\t\treturns: Nothing.\n\t\tabout: @tv tells the method whether it should serialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod Serialize(stream:TStream, tv:Int = True, name:Int = False) Abstract\n\t\n\tRem\n\t\tbbdoc: Deserialize the variable from a stream.\n\t\treturns: The deserialized variable.\n\t\tabout: @tv tells the method whether it should deserialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod DeSerialize:TVariable(stream:TStream, tv:Int = True, name:Int = False) Abstract\n\t\n'#end region (Data handling)\n\t\n\tRem\n\t\tbbdoc: Base method: Get the type of this variable.\n\tEnd Rem\n\tFunction ReportType:String() Abstract\n\t\n\tRem\n\t\tbbdoc: Base method: Get the TV_* type of this variable.\n\tEnd Rem\n\tFunction GetTVType:Int() Abstract\n\t\n\tRem\n\t\tbbdoc: Convert raw data (raw data being things like: \"\/eval::(a+b\/0.4181)*a-b\" - an EvalVariable, \"A String variable1!!\", 3452134 - an IntVariable, 1204.00321 - a FloatVariable) into a Variable.\n\t\treturns: A new Variable, or Null if something whacky occured.\n\t\tabout: @etype is optional, it is used to go automagically to one type of a Variable (1 & 4=String (will check for '\/eval::' - EvalVariables), 2=Integer, 3=Float).
\n\t\t@varname is also an optional parameter. It will be used as the name of the variable.\n\tEnd Rem\n\tFunction RawToVariable:TVariable(vraw:String, etype:Int = 0, varname:String = \"\")\n\t\tLocal variable:TVariable\n\t\t\n\t\tIf vraw = Null\n\t\t\tDebugLog(\"(TVariable.RawToVariable) @vraw = Null; returning StringVariable (with @varname and Null value)\")\n\t\t\tReturn New TStringVariable.Create(varname, Null)\n\t\tEnd If\n\t\t\n\t\t'If etype = 1 ' Explicitly a string\n\t\t'\t\n\t\t'\tvariable = TVariable(New TStringVariable.Create(\"\", vraw))\n\t\t'\t\n\t\tIf etype = 0 ' Determine the value's type (must be either integer, double, or a string with no spaces)\n\t\t\tLocal i:Int\n\t\t\t\n\t\t\t' ASCII '0' to '9' = 48-57; '-' = 45, '+' = 43; and '.' = 46\n\t\t\tFor i = 0 To vraw.Length - 1\n\t\t\t\tLocal c:Int\n\t\t\t\t\n\t\t\t\tc = vraw[i]\n\t\t\t\tIf c >= 48 And c <= 57 Or c = 43 Or c = 45\n\t\t\t\t\tIf etype = 0 ' Leave float and string alone\n\t\t\t\t\t\tetype = 2 ' Integer so far..\n\t\t\t\t\tEnd If\n\t\t\t\tElse If c = 46\n\t\t\t\t\tIf etype = 2 ' Already declared as an integer?\n\t\t\t\t\t\tetype = 3\n\t\t\t\t\tEnd If\n\t\t\t\tElse ' If the character is not numerical there is nothing else to deduce and the value is a string\n\t\t\t\t\tetype = 4\n\t\t\t\t\tExit\n\t\t\t\tEnd If\n\t\t\tNext\n\t\t\t\n\t\t\tSelect etype\n\t\t\t\tCase 2 ' Integer\n\t\t\t\t\tvariable = TVariable(New TIntVariable.Create(varname, Int(vraw)))\n\t\t\t\tCase 3 ' Double\/Float\n\t\t\t\t\tvariable = TVariable(New TFloatVariable.Create(varname, Float(vraw)))\n\t\t\t\t'Case 4 ' String - non-explicit\n\t\t\t\t' Local evaltest:Int = vraw.ToLower().Find(\"\/eval::\")\n\t\t\t\t'\t\n\t\t\t\t'\tIf evaltest >= 0\n\t\t\t\t'\t\tvariable = TVariable(New TEvalVariable.Create(varname, vraw[evaltest + 7..]))\n\t\t\t\t'\tElse\n\t\t\t\t'\t\tvariable = TVariable(New TStringVariable.Create(varname, vraw))\n\t\t\t\t'\tEnd If\n\t\t\tEnd Select\n\t\t\t\n\t\tEnd If\n\t\t\n\t\tIf etype = 1 Or etype = 4\n\t\t\tLocal evaltest:Int = vraw.ToLower().Find(\"\/e:\")\n\t\t\tIf evaltest >= 0\n\t\t\t\tvariable = TVariable(New TEvalVariable.Create(varname, vraw[evaltest + 7..]))\n\t\t\tElse\n\t\t\t\tvariable = TVariable(New TStringVariable.Create(varname, vraw))\n\t\t\tEnd If\n\t\tEnd If\n\t\t' DebugLog(\"TSNode.LoadScriptFromStream().RawToVariable(); vraw = ~q\" + vraw + \"~q \\\" + etype)\n\t\t?Debug\n\t\tIf variable = Null Then DebugLog(\"( TVariable.RawToVariable() ) Unknown error, 'variable' is Null.\")\n\t\t?\n\t\tReturn variable\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Universally deserialize a variable from the given stream.\n\t\treturns: A DeSerialized variable.\n\t\tabout: This will deserialize any variable from the stream.
\n\t\tThis requires the variable to have been serialized with the template type (see #Serialize parameters).
\n\t\t@name tells the further DeSerialize calls if the name should be DeSerialized or not.\n\tEnd Rem\n\tFunction DeSerializeUniversal:TVariable(stream:TStream, name:Int = False)\n\t\tLocal tv:Int\n\t\t\n\t\ttv = Int(stream.ReadByte())\n\t\t\n\t\tSelect tv\n\t\t\tCase TV_INTEGER\n\t\t\t\tReturn New TIntVariable.DeSerialize(stream, True, name)\n\t\t\tCase TV_STRING\n\t\t\t\tReturn New TStringVariable.DeSerialize(stream, True, name)\n\t\t\tCase TV_FLOAT\n\t\t\t\tReturn New TFloatVariable.DeSerialize(stream, True, name)\n\t\t\tCase TV_EVAL\n\t\t\t\tReturn New TEvalVariable.DeSerialize(stream, True, name)\n\t\t\tCase TV_IDEN\n\t\t\t\tReturn New TIdentifier.DeSerialize(stream, True, name)\n\t\t\t\t\n\t\t\tDefault\n\t\t\t\tDebugLog(\"(TVariable.DeSerializeUniversal) Failed to recognize the TV in the stream: \" + tv)\n\t\t\t\t\n\t\tEnd Select\n\t\tReturn Null\n\tEnd Function\n\t\nEnd Type\n\nRem\n\tbbdoc: The TStringVariable type.\nEnd Rem\nType TStringVariable Extends TVariable\n\t\n\tGlobal m_alwaysusequotes:Int = True\n\t\n\tField m_value:String\n\t\n\tRem\n\t\tbbdoc: Create a new StringVariable.\n\t\treturns: The new StringVariable (itself).\n\tEnd Rem\n\tMethod Create:TStringVariable(name:String = Null, value:String)\n\t\tSetName(name)\n\t\tSet(value)\n\t\tReturn Self\n\tEnd Method\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the variable's value.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod Set(value:String)\n\t\tm_value = value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the variable's value.\n\t\treturns: The value of the variable.\n\tEnd Rem\n\tMethod Get:String()\n\t\tReturn m_value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the value of the TStringVariable to the given string (ambiguous).\n\t\treturns: Nothing.\n\t\tabout: For this type, this method is no different than calling #Set.\n\tEnd Rem\n\tMethod SetAmbiguous(value:String)\n\t\tm_value = value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Convert the variable to a String.\n\t\treturns: A String representation of the variable.\n\t\tabout: This function is for script output, for in-code use see #ValueAsString.\n\tEnd Rem\n\tMethod ConvToString:String()\n\t\tIf m_alwaysusequotes = True Or m_value.Contains(\"~t\") Or m_value.Contains(\" \") Or m_value = Null\n\t\t\tReturn \"~q\" + m_value + \"~q\"\n\t\tElse\n\t\t\tReturn m_value\n\t\tEnd If\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the StringVariable as a String.\n\t\treturns: The variable's value converted to a String.\n\t\tabout: Here for complete-ness, no difference to `instance.Get()`.\n\tEnd Rem\n\tMethod ValueAsString:String()\n\t\tReturn m_value\n\tEnd Method\n\t\n'#end region (Field accessors)\n\t\n'#region Data handling\n\t\n\tRem\n\t\tbbdoc: Create a copy of the variable\n\t\treturns: A clone of the variable.\n\tEnd Rem\n\tMethod Copy:TStringVariable()\n\t\tReturn New TStringVariable.Create(m_name, m_value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Serialize the variable to a stream.\n\t\treturns: Nothing.\n\t\tabout: @tv tells the method whether it should serialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod Serialize(stream:TStream, tv:Int = True, name:Int = False)\n\t\tIf tv = True\n\t\t\tstream.WriteByte(TV_STRING)\n\t\tEnd If\n\t\tIf name = True\n\t\t\tWriteLString(stream, m_name)\n\t\tEnd If\n\t\t\n\t\tWriteLString(stream, m_value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Deserialize the variable from a stream.\n\t\treturns: The deserialized variable.\n\t\tabout: @tv tells the method whether it should deserialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod DeSerialize:TStringVariable(stream:TStream, tv:Int = True, name:Int = False)\n\t\tIf tv = True\n\t\t\tstream.ReadByte()\n\t\tEnd If\n\t\tIf name = True\n\t\t\tm_name = ReadLString(stream)\n\t\tEnd If\n\t\t\n\t\tm_value = ReadLString(stream)\n\t\tReturn Self\n\tEnd Method\n\t\n'#end region (Data handling)\n\t\n\tRem\n\t\tbbdoc: Get the type of this variable.\n\t\treturns: The type of this variable (\"string\").\n\tEnd Rem\n\tFunction ReportType:String()\n\t\tReturn \"string\"\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Get the TV type of this variable.\n\t\treturns: The TV_* type of this variable (TV_STRING).\n\tEnd Rem\n\tFunction GetTVType:Int()\n\t\tReturn TV_STRING\n\tEnd Function\n\t\nEnd Type\n\nRem\n\tbbdoc: The TFloatVariable type.\nEnd Rem\nType TFloatVariable Extends TVariable\n\t\n\tField m_value:Float\n\t\n\tRem\n\t\tbbdoc: Create a new FloatVariable.\n\t\treturns: The new FloatVariable (itself).\n\tEnd Rem\n\tMethod Create:TFloatVariable(name:String = Null, value:Float)\n\t\tSetName(name)\n\t\tSet(value)\n\t\tReturn Self\n\tEnd Method\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the variable's value.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod Set(value:Float)\n\t\tm_value = value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the variable's value.\n\t\treturns: The value of the variable.\n\tEnd Rem\n\tMethod Get:Float()\n\t\tReturn m_value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the value of the variable to the given string (ambiguous).\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetAmbiguous(value:String)\n\t\tm_value = Float(value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Convert the variable to a String.\n\t\treturns: A scriptable form of the StringVariable.\n\t\tabout: This function is for script output, for in-code use see #ValueAsString.\n\tEnd Rem\n\tMethod ConvToString:String()\n\t\tLocal conv:String = String(m_value), i:Int, encountered:Int\n\t\t\n\t\tFor i = conv.Find(\".\") To conv.Length - 1\n\t\t\tIf conv[i] = 48\n\t\t\t\tIf encountered = True\n\t\t\t\t\tconv = conv[..i]\n\t\t\t\t\tExit\n\t\t\t\tEnd If\n\t\t\tElse If conv[i] <> 46\n\t\t\t\tencountered = True\n\t\t\tEnd If\n\t\tNext\n\t\t\n\t\tReturn conv\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the FloatVariable as a String.\n\t\treturns: The variable's value converted to a String.\n\tEnd Rem\n\tMethod ValueAsString:String()\n\t\tReturn String(m_value)\n\tEnd Method\n\t\n'#end region (Field accessors)\n\t\n'#region Data handling\n\t\n\tRem\n\t\tbbdoc: Create a copy of the variable\n\t\treturns: A clone of the variable.\n\tEnd Rem\n\tMethod Copy:TFloatVariable()\n\t\tReturn New TFloatVariable.Create(m_name, m_value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Serialize the variable to a stream.\n\t\treturns: Nothing.\n\t\tabout: @tv tells the method whether it should serialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod Serialize(stream:TStream, tv:Int = True, name:Int = False)\n\t\tIf tv = True\n\t\t\tstream.WriteByte(TV_FLOAT)\n\t\tEnd If\n\t\tIf name = True\n\t\t\tWriteLString(stream, m_name)\n\t\tEnd If\n\t\tstream.WriteFloat(m_value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Deserialize the variable from a stream.\n\t\treturns: The deserialized variable.\n\t\tabout: @tv tells the method whether it should deserialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod DeSerialize:TFloatVariable(stream:TStream, tv:Int = True, name:Int = False)\n\t\tIf tv = True\n\t\t\tstream.ReadByte()\n\t\tEnd If\n\t\tIf name = True\n\t\t\tm_name = ReadLString(stream)\n\t\tEnd If\n\t\tm_value = stream.ReadFloat()\n\t\tReturn Self\n\tEnd Method\n\t\n'#end region (Data handling)\n\t\n\tRem\n\t\tbbdoc: Get the type of this variable.\n\t\treturns: The type of this variable (\"float\").\n\tEnd Rem\n\tFunction ReportType:String()\n\t\tReturn \"float\"\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Get the TV type of this variable.\n\t\treturns: The TV_* type of this variable (TV_FLOAT).\n\tEnd Rem\n\tFunction GetTVType:Int()\n\t\tReturn TV_FLOAT\n\tEnd Function\n\t\nEnd Type\n\nRem\n\tbbdoc: The TIntVariable type.\nEnd Rem\nType TIntVariable Extends TVariable\n\t\n\tField m_value:Int\n\t\n\tRem\n\t\tbbdoc: Create a new IntVariable.\n\t\treturns: The new IntVariable (itself).\n\tEnd Rem\n\tMethod Create:TIntVariable(name:String = Null, value:Int)\n\t\tSetName(name)\n\t\tSet(value)\n\t\tReturn Self\n\tEnd Method\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the variable's value.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod Set(value:Int)\n\t\tm_value = value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the variable's value.\n\t\treturns: The value of the variable.\n\tEnd Rem\n\tMethod Get:Int()\n\t\tReturn m_value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the value of the variable to the given string (ambiguous).\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetAmbiguous(value:String)\n\t\tm_value = Int(value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Convert the variable to a String.\n\t\treturns: A string representation of the variable.\n\t\tabout: This function is for script output, for in-code use see #ValueAsString.\n\tEnd Rem\n\tMethod ConvToString:String()\n\t\tReturn String(m_value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the IntVariable as a String.\n\t\treturns: The variable's value converted to a String.\n\tEnd Rem\n\tMethod ValueAsString:String()\n\t\tReturn String(m_value)\n\tEnd Method\n\t\n'#end region (Field accessors)\n\t\n'#region Data handling\n\t\n\tRem\n\t\tbbdoc: Create a copy of the variable\n\t\treturns: A clone of the variable.\n\tEnd Rem\n\tMethod Copy:TIntVariable()\n\t\tReturn New TIntVariable.Create(m_name, m_value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Serialize the variable to a stream.\n\t\treturns: Nothing.\n\t\tabout: @tv tells the method whether it should serialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod Serialize(stream:TStream, tv:Int = True, name:Int = False)\n\t\tIf tv = True\n\t\t\tstream.WriteByte(TV_INTEGER)\n\t\tEnd If\n\t\tIf name = True\n\t\t\tWriteLString(stream, m_name)\n\t\tEnd If\n\t\t\n\t\tstream.WriteInt(m_value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Deserialize the variable from a stream.\n\t\treturns: The deserialized variable.\n\t\tabout: @tv tells the method whether it should deserialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod DeSerialize:TIntVariable(stream:TStream, tv:Int = True, name:Int = False)\n\t\tIf tv = True\n\t\t\tstream.ReadByte()\n\t\tEnd If\n\t\tIf name = True\n\t\t\tm_name = ReadLString(stream)\n\t\tEnd If\n\t\t\n\t\tm_value = stream.ReadInt()\n\t\tReturn Self\n\tEnd Method\n\t\n'#end region (Data handling)\n\t\n\tRem\n\t\tbbdoc: Get the type of this variable.\n\t\treturns: The type of this variable (\"int\").\n\tEnd Rem\n\tFunction ReportType:String()\n\t\tReturn \"int\"\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Get the TV type of this variable.\n\t\treturns: The TV_* type of this variable (TV_INTEGER).\n\tEnd Rem\n\tFunction GetTVType:Int()\n\t\tReturn TV_INTEGER\n\tEnd Function\n\t\nEnd Type\n\nRem\n\tbbdoc: The TEvalVariable type.\nEnd Rem\nType TEvalVariable Extends TVariable\n\t\n\tField m_value:String\n\t\n\tRem\n\t\tbbdoc: Create a new EvalVariable.\n\t\treturns: The new EvalVariable (itself).\n\tEnd Rem\n\tMethod Create:TEvalVariable(name:String = Null, value:String)\n\t\tSetName(name)\n\t\tSet(value)\n\t\tReturn Self\n\tEnd Method\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the equation string for the EvalVariable.\n\t\treturns: Nothing\n\tEnd Rem\n\tMethod Set(value:String)\n\t\tm_value = value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the equation string.\n\t\treturns: The equation string.\n\tEnd Rem\n\tMethod Get:String()\n\t\tReturn m_value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the value of the variable to the given string (ambiguous).\n\t\treturns: Nothing.\n\t\tabout: For this type, this method is no different than calling #Set.\n\tEnd Rem\n\tMethod SetAmbiguous(value:String)\n\t\tm_value = value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Convert the EvalVariable to a visual representation of its data.\n\t\treturns: The scriptable form of the EvalVariable.\n\t\tabout: This function is for script output, for in-code use see #ValueAsString.\n\tEnd Rem\n\tMethod ConvToString:String()\n\t\tReturn \"~q\/e:\" + m_value + \"~q\"\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the EvalVariable as a String.\n\t\treturns: The variable's value converted to a String.\n\tEnd Rem\n\tMethod ValueAsString:String()\n\t\tReturn m_value\n\tEnd Method\n\t\n'#end region (Field accessors)\n\t\n'#region Data handling\n\t\n\tRem\n\t\tbbdoc: Create a copy of the variable\n\t\treturns: A clone of the variable.\n\tEnd Rem\n\tMethod Copy:TEvalVariable()\n\t\tReturn New TEvalVariable.Create(m_name, m_value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Serialize the variable to a stream.\n\t\treturns: Nothing.\n\t\tabout: @tv tells the method whether it should serialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod Serialize(stream:TStream, tv:Int = True, name:Int = False)\n\t\tIf tv = True\n\t\t\tstream.WriteByte(TV_EVAL)\n\t\tEnd If\n\t\tIf name = True\n\t\t\tWriteLString(stream, m_name)\n\t\tEnd If\n\t\t\n\t\tWriteLString(stream, m_value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Deserialize the variable from a stream.\n\t\treturns: The deserialized variable.\n\t\tabout: @tv tells the method whether it should deserialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod DeSerialize:TEvalVariable(stream:TStream, tv:Int = True, name:Int = False)\n\t\tIf tv = True\n\t\t\tstream.ReadByte()\n\t\tEnd If\n\t\tIf name = True\n\t\t\tm_name = ReadLString(stream)\n\t\tEnd If\n\t\t\n\t\tm_value = ReadLString(stream)\n\t\tReturn Self\n\tEnd Method\n\t\n'#end region (Data handling)\n\t\n\tRem\n\t\tbbdoc: Get the type of this variable.\n\t\treturns: The type of this variable (\"eval\").\n\tEnd Rem\n\tFunction ReportType:String()\n\t\tReturn \"eval\"\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Get the TV type of this variable.\n\t\treturns: The TV_* type of this variable (TV_EVAL).\n\tEnd Rem\n\tFunction GetTVType:Int()\n\t\tReturn TV_EVAL\n\tEnd Function\n\t\nEnd Type\n\nRem\n\tbbdoc: The TBoolVariable type.\nEnd Rem\nType TBoolVariable Extends TVariable\n\t\n\tField m_value:Int\n\t\n\tRem\n\t\tbbdoc: Create a new BoolVariable.\n\t\treturns: The new BoolVariable (itself).\n\tEnd Rem\n\tMethod Create:TBoolVariable(name:String = Null, value:Int)\n\t\tSetName(name)\n\t\tSet(value)\n\t\tReturn Self\n\tEnd Method\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the variable's value.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod Set(value:Int)\n\t\tm_value = value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the variable's value.\n\t\treturns: The value of the variable.\n\tEnd Rem\n\tMethod Get:Int()\n\t\tReturn m_value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the value of the variable to the given string (ambiguous).\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetAmbiguous(value:String)\n\t\tm_value = Int(value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Convert the variable to a String.\n\t\treturns: A string representation of the variable.\n\t\tabout: This function is for script output, for in-code use see #ValueAsString.\n\tEnd Rem\n\tMethod ConvToString:String()\n\t\tReturn String(m_value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the TBoolVariable as a String.\n\t\treturns: The variable's value converted to a String.\n\tEnd Rem\n\tMethod ValueAsString:String()\n\t\tReturn String(m_value)\n\tEnd Method\n\t\n'#end region (Field accessors)\n\t\n'#region Data handling\n\t\n\tRem\n\t\tbbdoc: Create a copy of the variable\n\t\treturns: A clone of the variable.\n\tEnd Rem\n\tMethod Copy:TBoolVariable()\n\t\tReturn New TBoolVariable.Create(m_name, m_value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Serialize the variable to a stream.\n\t\treturns: Nothing.\n\t\tabout: @tv tells the method whether it should serialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod Serialize(stream:TStream, tv:Int = True, name:Int = False)\n\t\tIf tv = True\n\t\t\tstream.WriteByte(TV_BOOL)\n\t\tEnd If\n\t\tIf name = True\n\t\t\tWriteLString(stream, m_name)\n\t\tEnd If\n\t\tstream.WriteByte(Byte(m_value))\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Deserialize the variable from a stream.\n\t\treturns: The deserialized variable.\n\t\tabout: @tv tells the method whether it should deserialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod DeSerialize:TBoolVariable(stream:TStream, tv:Int = True, name:Int = False)\n\t\tIf tv = True\n\t\t\tstream.ReadByte()\n\t\tEnd If\n\t\tIf name = True\n\t\t\tm_name = ReadLString(stream)\n\t\tEnd If\n\t\tm_value = Int(stream.ReadByte())\n\t\tReturn Self\n\tEnd Method\n\t\n'#end region (Data handling)\n\t\n\tRem\n\t\tbbdoc: Get the type of this variable.\n\t\treturns: The type of this variable (\"bool\").\n\tEnd Rem\n\tFunction ReportType:String()\n\t\tReturn \"bool\"\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Get the TV type of this variable.\n\t\treturns: The TV_* type of this variable (TV_BOOL).\n\tEnd Rem\n\tFunction GetTVType:Int()\n\t\tReturn TV_BOOL\n\tEnd Function\n\t\nEnd Type\n\nRem\n\tbbdoc: The Identifier type.\nEnd Rem\nType TIdentifier Extends TVariable\n\t\n\tField m_values:TList\n\t\n\tMethod New()\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Create a new Identifier.\n\t\treturns: The new Identfier (itself).\n\tEnd Rem\n\tMethod Create:TIdentifier()\n\t\tm_values = New TList\n\t\tReturn Self\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Create a new Identifier with the given data.\n\t\treturns: The new Identfier (itself).\n\t\tabout: If the @values parameter is Null a new list will be created.\n\tEnd Rem\n\tMethod CreateByData:TIdentifier(name:String, values:TList = Null)\n\t\tSetName(name)\n\t\tIf values = Null\n\t\t\tm_values = New TList\n\t\tElse\n\t\t\tm_values = values\n\t\tEnd If\n\t\tReturn Self\n\tEnd Method\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the Identifier's values.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetValues(values:TList)\n\t\tm_values = values\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the Identifier's values.\n\t\treturns: A list containing the values which the Identifier holds.\n\tEnd Rem\n\tMethod GetValues:TList()\n\t\tReturn m_values\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Deprecated for this type.\n\t\treturns: Nothing.\n\t\tabout: This does nothing.\n\tEnd Rem\n\tMethod SetAmbiguous(value:String)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Convert the identifier to a string.\n\t\treturns: A string representation of the identifier.\n\tEnd Rem\n\tMethod ConvToString:String()\n\t\tLocal op:String, variable:TVariable\n\t\t\n\t\tIf m_name.Contains(\"~t\") = True Or m_name.Contains(\" \") = True\n\t\t\top = \"~q\" + m_name + \"~q \"\n\t\tElse\n\t\t\top = m_name + \" \"\n\t\tEnd If\n\t\t\n\t\tFor variable = EachIn m_values\n\t\t\top:+variable.ConvToString() + \" \"\n\t\tNext\n\t\top = op[..op.Length - 1]\n\t\tReturn op\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the Identifier as a string.\n\t\treturns: The Identifier contents converted to a string.\n\t\tabout: Here for complete-ness, simply calls #ConvToString.\n\tEnd Rem\n\tMethod ValueAsString:String()\n\t\tReturn ConvToString()\n\tEnd Method\n\t\n'#end region (Field accessors)\n\t\n'#region Value handling\n\t\n\tRem\n\t\tbbdoc: Get a value at an index.\n\t\treturns: The value in the identifier's list at the given index, or Null if it could not be retrieved.\n\t\tabout: The index is zero-based.\n\tEnd Rem\n\tMethod GetValueAtIndex:TVariable(index:Int)\n\t\tIf m_values <> Null And index > - 1 And index < m_values.Count()\n\t\t\tReturn TVariable(m_values.ValueAtIndex(index))\n\t\tEnd If\n\t\tReturn Null\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the number of values.\n\t\treturns: The number of values the Identifier contains.\n\tEnd Rem\n\tMethod GetValueCount:Int()\n\t\tIf m_values <> Null\n\t\t\tReturn m_values.Count()\n\t\tEnd If\n\t\tReturn 0\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Add a value to the Identifier.\n\t\treturns: True for success, or False for failure.\n\t\tabout: NOTE: This will set the given value's parent.\n\tEnd Rem\n\tMethod AddValue:Int(value:TVariable)\n\t\tIf m_values <> Null And value <> Null\n\t\t\tm_values.AddLast(value)\n\t\t\tvalue.SetParent(Self)\n\t\t\tReturn True\n\t\tEnd If\n\t\tReturn False\n\tEnd Method\n\t\n'#end region (Value handling)\n\t\n'#region Data handling\n\t\n\tRem\n\t\tbbdoc: Create a copy of the variable\n\t\treturns: A clone of the variable.\n\tEnd Rem\n\tMethod Copy:TIdentifier()\n\t\tLocal clone:TIdentifier\n\t\tclone = New TIdentifier.CreateByData(m_name)\n\t\tFor Local variable:TVariable = EachIn m_values\n\t\t\tclone.AddValue(variable.Copy())\n\t\tNext\n\t\tReturn clone\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Serialize the variable to a stream.\n\t\treturns: Nothing.\n\t\tabout: @tv tells the method whether it should serialize the TV type for the variable, or to not.
\n\t\tIn this case @name tells the method whether it should serialize the values<\/b><\/i>' name (the Identifier's name is always read\/written to the stream).\n\tEnd Rem\n\tMethod Serialize(stream:TStream, tv:Int = True, name:Int = False)\n\t\tLocal variable:TVariable\n\t\t\n\t\tIf tv = True\n\t\t\tstream.WriteByte(TV_STRING)\n\t\tEnd If\n\t\tWriteLString(stream, m_name)\n\t\t\n\t\tIf m_values = Null\n\t\t\tstream.WriteInt(0)\n\t\tElse\n\t\t\tstream.WriteInt(m_values.Count())\n\t\t\tFor variable = EachIn m_values\n\t\t\t\tvariable.Serialize(stream, True, name)\n\t\t\tNext\n\t\tEnd If\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Deserialize the variable from a stream.\n\t\treturns: The deserialized variable.\n\t\tabout: @tv tells the method whether it should deserialize the TV type for the variable, or to not.
\n\t\tIn this case @name tells the method whether it should deserialize the values<\/b><\/i>' name (the Identifier's name is always read\/written to the stream).\n\tEnd Rem\n\tMethod DeSerialize:TIdentifier(stream:TStream, tv:Int = True, name:Int = False)\n\t\tLocal count:Int, n:Int\n\t\t\n\t\tIf tv = True\n\t\t\tstream.ReadByte()\n\t\tEnd If\n\t\tm_name = ReadLString(stream)\n\t\t\n\t\tcount = stream.ReadInt()\n\t\tIf count > 0\n\t\t\tFor n = 0 To count - 1\n\t\t\t\tDeSerializeUniversal(stream, name)\n\t\t\tNext\n\t\tEnd If\n\t\t\n\t\tReturn Self\n\tEnd Method\n\t\n'#end region (Data handling)\n\t\n\tRem\n\t\tbbdoc: Get the type of this variable.\n\t\treturns: The type of this variable (\"identifier\").\n\tEnd Rem\n\tFunction ReportType:String()\n\t\tReturn \"identifier\"\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Get the TV type of this variable.\n\t\treturns: The TV_* type of this variable (TV_IDEN).\n\tEnd Rem\n\tFunction GetTVType:Int()\n\t\tReturn TV_IDEN\n\tEnd Function\n\t\nEnd Type\n\nRem\n\tbbdoc: The VariableMap type.\nEndRem\nType TVariableMap Extends TObjectMap\n\t\n\tRem\n\t\tbbdoc: Create a new VariableMap.\n\t\treturns: The new VariableMap (itself).\n\tEnd Rem\n\tMethod Create:TVariableMap()\n\t\tReturn Self\n\tEnd Method\n\t\n'#region Collections\n\t\n\tRem\n\t\tbbdoc: Insert a variable into the map.\n\t\treturns: True if the variable was added, or False if it was not (the variable's name is Null).\n\tEnd Rem\n\tMethod InsertVariable:Int(variable:TVariable)\n\t\tIf variable.GetName() <> Null\n\t\t\t_Insert(variable.GetName(), variable)\n\t\t\tReturn True\n\t\tEnd If\n\t\tReturn False\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Remove a variable by the name given.\n\t\treturns: True if a variable was removed, or False if it was not (the map contains no variable with the name given).\n\t\tabout: The name is<\/b> case-sensitive.\n\tEnd Rem\n\tMethod RemoveVariableByName:Int(name:String)\n\t\tReturn _Remove(name)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get a variable from the map by its name.\n\t\treturns: The variable object, or if the variable was not found, Null.\n\t\tabout: The name is<\/b> case-sensitive.\n\tEnd Rem\n\tMethod GetVariableByName:TVariable(name:String)\n\t\tReturn TVariable(_ValueByKey(name))\n\tEnd Method\n\t\n'#end region (Collections)\n\t\nEnd Type\n\n","old_contents":"\nRem\n\tCopyright (c) 2009 Tim Howard\n\t\n\tPermission is hereby granted, free of charge, to any person obtaining a copy\n\tof this software and associated documentation files (the \"Software\"), to deal\n\tin the Software without restriction, including without limitation the rights\n\tto use, copy, modify, merge, publish, distribute, sublicense, and\/or sell\n\tcopies of the Software, and to permit persons to whom the Software is\n\tfurnished to do so, subject to the following conditions:\n\t\n\tThe above copyright notice and this permission notice shall be included in\n\tall copies or substantial portions of the Software.\n\t\n\tTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n\tIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n\tFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n\tAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n\tLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n\tOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n\tTHE SOFTWARE.\n\t-----------------------------------------------------------------------------\n\t\n\tvariables.bmx (Contains: TV_INTEGER, TV_STRING, TV_FLOAT, TV_EVAL,\n\t\t\t\t\t\t\tTVariable, TStringVariable, TFloatVariable, TIntVariable, TEvalVariable, TIdentifier,\n\t\t\t\t\t\t\tTVariableMap, )\n\t\nEnd Rem\n\nSuperStrict\n\nRem\nbbdoc: Variables module\nEnd Rem\nModule duct.variables\n\nModuleInfo \"Version: 0.18\"\nModuleInfo \"Copyright: Tim Howard\"\nModuleInfo \"License: MIT\"\n\nModuleInfo \"History: Version 0.18\"\nModuleInfo \"History: TIdentifier.AddValue now sets the variable's parent to itself\"\nModuleInfo \"History: Added SetParent and GetParent to TVaraible\"\nModuleInfo \"History: Version 0.17\"\nModuleInfo \"History: General cleanup\"\nModuleInfo \"History: Version 0.16\"\nModuleInfo \"History: Added SetAmbiguous to all TVariable types\"\nModuleInfo \"History: Added option to always use quoting with TStringVariables (on by default)\"\nModuleInfo \"History: Fixed TStringVariable.ConvToString returning of Null strings\"\nModuleInfo \"History: Version 0.15\"\nModuleInfo \"History: Change the Create method definition for easier use\"\nModuleInfo \"History: Changed the '\/eval::' recognizer to '\/e:' (as per SNode format change)\"\nModuleInfo \"History: Added the Copy method to every variable type\"\nModuleInfo \"History: Changed some formatting\"\nModuleInfo \"History: Version 0.14\"\nModuleInfo \"History: Changed type tabbing\"\nModuleInfo \"History: Fixed script output for TStringVariable (quotes are now only added if whitespace is present)\"\nModuleInfo \"History: Fixed script output for TIdentifier (identifier names can now contain whitespace, in which case they must be quoted)\"\nModuleInfo \"History: Version 0.13\"\nModuleInfo \"History: Added the DeSerializeUniversal function to TVariable\"\nModuleInfo \"History: Added Serialize and DeSerialize methods to all variable types\"\nModuleInfo \"History: Version 0.12\"\nModuleInfo \"History: Changed module name from 'variablemap' to 'variables'\"\nModuleInfo \"History: Moved all of duct.utilparser here\"\nModuleInfo \"History: Added the GetTVType function to all variable types\"\nModuleInfo \"History: Moved TV_* constants from duct.template here\"\nModuleInfo \"History: Version 0.11\"\nModuleInfo \"History: Added the ReportType function to all variable types\"\nModuleInfo \"History: Version 0.10\"\nModuleInfo \"History: Added the RawToVariable function to TVariable\"\nModuleInfo \"History: General code cleanup\"\nModuleInfo \"History: Version 0.09\"\nModuleInfo \"History: Corrected usage of syntax (in Returns, Cases, News and Selects)\"\nModuleInfo \"History: Version 0.08\"\nModuleInfo \"History: Added the TEvalVariable type\"\nModuleInfo \"History: Initial release\"\n\nImport brl.stream\nImport brl.linkedlist\n\nImport duct.etc\nImport duct.objectmap\n\nRem\n\tbbdoc: Template variable type for the TIntVariable type.\nEnd Rem\nConst TV_INTEGER:Int = 1\nRem\n\tbbdoc: Template variable type for the TTStringVariable type.\nEnd Rem\nConst TV_STRING:Int = 2\nRem\n\tbbdoc: Template variable type for the TFloatVariable type.\nEnd Rem\nConst TV_FLOAT:Int = 3\nRem\n\tbbdoc: Template variable type for the TEvalVariable type.\nEnd Rem\nConst TV_EVAL:Int = 4\nRem\n\tbbdoc: Template variable type for the TIdentifier type.\nEnd Rem\nConst TV_IDEN:Int = 5\n\nRem\n\tbbdoc: The Variable type.\n\tabout: This is the base variable type, you should extend from this to use it.\nEnd Rem\nType TVariable Abstract\n\t\n\tField m_name:String\n\tField m_parent:TVariable\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the variable's name.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetName(name:String)\n\t\tm_name = name\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the variable's name.\n\t\treturns: The variable's name.\n\tEnd Rem\n\tMethod GetName:String()\n\t\tReturn m_name\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the variable's parent.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetParent(parent:TVariable)\n\t\tm_parent = parent\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the variable's parent.\n\t\treturns: The variable's parent.\n\tEnd Rem\n\tMethod GetParent:TVariable()\n\t\tReturn m_parent\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Base method for setting the value of the variable to the given string (conversion).\n\tEnd Rem\n\tMethod SetAmbiguous(value:String) Abstract\n\t\n\tRem\n\t\tbbdoc: Base method for converting variable data to a script-ready string.\n\tEnd Rem\n\tMethod ConvToString:String() Abstract\n\t\n\tRem\n\t\tbbdoc: Base method for converting variable data to a printable\/usable-in-code string.\n\tEnd Rem\n\tMethod ValueAsString:String() Abstract\n\t\n'#end region (Field accessors)\n\t\n'#region Data handling\n\t\n\tRem\n\t\tbbdoc: Create a copy of the variable.\n\t\treturns: A clone of the variable.\n\tEnd Rem\n\tMethod Copy:TVariable() Abstract\n\t\n\tRem\n\t\tbbdoc: Serialize the variable to a stream.\n\t\treturns: Nothing.\n\t\tabout: @tv tells the method whether it should serialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod Serialize(stream:TStream, tv:Int = True, name:Int = False) Abstract\n\t\n\tRem\n\t\tbbdoc: Deserialize the variable from a stream.\n\t\treturns: The deserialized variable.\n\t\tabout: @tv tells the method whether it should deserialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod DeSerialize:TVariable(stream:TStream, tv:Int = True, name:Int = False) Abstract\n\t\n'#end region (Data handling)\n\t\n\tRem\n\t\tbbdoc: Base method: Get the type of this variable.\n\tEnd Rem\n\tFunction ReportType:String() Abstract\n\t\n\tRem\n\t\tbbdoc: Base method: Get the TV_* type of this variable.\n\tEnd Rem\n\tFunction GetTVType:Int() Abstract\n\t\n\tRem\n\t\tbbdoc: Convert raw data (raw data being things like: \"\/eval::(a+b\/0.4181)*a-b\" - an EvalVariable, \"A String variable1!!\", 3452134 - an IntVariable, 1204.00321 - a FloatVariable) into a Variable.\n\t\treturns: A new Variable, or Null if something whacky occured.\n\t\tabout: @etype is optional, it is used to go automagically to one type of a Variable (1 & 4=String (will check for '\/eval::' - EvalVariables), 2=Integer, 3=Float).
\n\t\t@varname is also an optional parameter. It will be used as the name of the variable.\n\tEnd Rem\n\tFunction RawToVariable:TVariable(vraw:String, etype:Int = 0, varname:String = \"\")\n\t\tLocal variable:TVariable\n\t\t\n\t\tIf vraw = Null\n\t\t\tDebugLog(\"(TVariable.RawToVariable) @vraw = Null; returning StringVariable (with @varname and Null value)\")\n\t\t\tReturn New TStringVariable.Create(varname, Null)\n\t\tEnd If\n\t\t\n\t\t'If etype = 1 ' Explicitly a string\n\t\t'\t\n\t\t'\tvariable = TVariable(New TStringVariable.Create(\"\", vraw))\n\t\t'\t\n\t\tIf etype = 0 ' Determine the value's type (must be either integer, double, or a string with no spaces)\n\t\t\tLocal i:Int\n\t\t\t\n\t\t\t' ASCII '0' to '9' = 48-57; '-' = 45, '+' = 43; and '.' = 46\n\t\t\tFor i = 0 To vraw.Length - 1\n\t\t\t\tLocal c:Int\n\t\t\t\t\n\t\t\t\tc = vraw[i]\n\t\t\t\tIf c >= 48 And c <= 57 Or c = 43 Or c = 45\n\t\t\t\t\tIf etype = 0 ' Leave float and string alone\n\t\t\t\t\t\tetype = 2 ' Integer so far..\n\t\t\t\t\tEnd If\n\t\t\t\tElse If c = 46\n\t\t\t\t\tIf etype = 2 ' Already declared as an integer?\n\t\t\t\t\t\tetype = 3\n\t\t\t\t\tEnd If\n\t\t\t\tElse ' If the character is not numerical there is nothing else to deduce and the value is a string\n\t\t\t\t\tetype = 4\n\t\t\t\t\tExit\n\t\t\t\tEnd If\n\t\t\tNext\n\t\t\t\n\t\t\tSelect etype\n\t\t\t\tCase 2 ' Integer\n\t\t\t\t\tvariable = TVariable(New TIntVariable.Create(varname, Int(vraw)))\n\t\t\t\tCase 3 ' Double\/Float\n\t\t\t\t\tvariable = TVariable(New TFloatVariable.Create(varname, Float(vraw)))\n\t\t\t\t'Case 4 ' String - non-explicit\n\t\t\t\t' Local evaltest:Int = vraw.ToLower().Find(\"\/eval::\")\n\t\t\t\t'\t\n\t\t\t\t'\tIf evaltest >= 0\n\t\t\t\t'\t\tvariable = TVariable(New TEvalVariable.Create(varname, vraw[evaltest + 7..]))\n\t\t\t\t'\tElse\n\t\t\t\t'\t\tvariable = TVariable(New TStringVariable.Create(varname, vraw))\n\t\t\t\t'\tEnd If\n\t\t\tEnd Select\n\t\t\t\n\t\tEnd If\n\t\t\n\t\tIf etype = 1 Or etype = 4\n\t\t\tLocal evaltest:Int = vraw.ToLower().Find(\"\/e:\")\n\t\t\tIf evaltest >= 0\n\t\t\t\tvariable = TVariable(New TEvalVariable.Create(varname, vraw[evaltest + 7..]))\n\t\t\tElse\n\t\t\t\tvariable = TVariable(New TStringVariable.Create(varname, vraw))\n\t\t\tEnd If\n\t\tEnd If\n\t\t' DebugLog(\"TSNode.LoadScriptFromStream().RawToVariable(); vraw = ~q\" + vraw + \"~q \\\" + etype)\n\t\t?Debug\n\t\tIf variable = Null Then DebugLog(\"( TVariable.RawToVariable() ) Unknown error, 'variable' is Null.\")\n\t\t?\n\t\tReturn variable\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Universally deserialize a variable from the given stream.\n\t\treturns: A DeSerialized variable.\n\t\tabout: This will deserialize any variable from the stream.
\n\t\tThis requires the variable to have been serialized with the template type (see #Serialize parameters).
\n\t\t@name tells the further DeSerialize calls if the name should be DeSerialized or not.\n\tEnd Rem\n\tFunction DeSerializeUniversal:TVariable(stream:TStream, name:Int = False)\n\t\tLocal tv:Int\n\t\t\n\t\ttv = Int(stream.ReadByte())\n\t\t\n\t\tSelect tv\n\t\t\tCase TV_INTEGER\n\t\t\t\tReturn New TIntVariable.DeSerialize(stream, True, name)\n\t\t\tCase TV_STRING\n\t\t\t\tReturn New TStringVariable.DeSerialize(stream, True, name)\n\t\t\tCase TV_FLOAT\n\t\t\t\tReturn New TFloatVariable.DeSerialize(stream, True, name)\n\t\t\tCase TV_EVAL\n\t\t\t\tReturn New TEvalVariable.DeSerialize(stream, True, name)\n\t\t\tCase TV_IDEN\n\t\t\t\tReturn New TIdentifier.DeSerialize(stream, True, name)\n\t\t\t\t\n\t\t\tDefault\n\t\t\t\tDebugLog(\"(TVariable.DeSerializeUniversal) Failed to recognize the TV in the stream: \" + tv)\n\t\t\t\t\n\t\tEnd Select\n\t\tReturn Null\n\tEnd Function\n\t\nEnd Type\n\nRem\n\tbbdoc: The TStringVariable type.\nEnd Rem\nType TStringVariable Extends TVariable\n\t\n\tGlobal m_alwaysusequotes:Int = True\n\t\n\tField m_value:String\n\t\n\tRem\n\t\tbbdoc: Create a new StringVariable.\n\t\treturns: The new StringVariable (itself).\n\tEnd Rem\n\tMethod Create:TStringVariable(name:String = Null, value:String)\n\t\tSetName(name)\n\t\tSet(value)\n\t\tReturn Self\n\tEnd Method\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the variable's value.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod Set(value:String)\n\t\tm_value = value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the variable's value.\n\t\treturns: The value of the variable.\n\tEnd Rem\n\tMethod Get:String()\n\t\tReturn m_value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the value of the TStringVariable to the given string (ambiguous).\n\t\treturns: Nothing.\n\t\tabout: For this type, this method is no different than calling #Set.\n\tEnd Rem\n\tMethod SetAmbiguous(value:String)\n\t\tm_value = value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Convert the variable to a String.\n\t\treturns: A String representation of the variable.\n\t\tabout: This function is for script output, for in-code use see #ValueAsString.\n\tEnd Rem\n\tMethod ConvToString:String()\n\t\tIf m_alwaysusequotes = True Or m_value.Contains(\"~t\") Or m_value.Contains(\" \") Or m_value = Null\n\t\t\tReturn \"~q\" + m_value + \"~q\"\n\t\tElse\n\t\t\tReturn m_value\n\t\tEnd If\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the StringVariable as a String.\n\t\treturns: The variable's value converted to a String.\n\t\tabout: Here for complete-ness, no difference to `instance.Get()`.\n\tEnd Rem\n\tMethod ValueAsString:String()\n\t\tReturn m_value\n\tEnd Method\n\t\n'#end region (Field accessors)\n\t\n'#region Data handling\n\t\n\tRem\n\t\tbbdoc: Create a copy of the variable\n\t\treturns: A clone of the variable.\n\tEnd Rem\n\tMethod Copy:TStringVariable()\n\t\tReturn New TStringVariable.Create(m_name, m_value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Serialize the variable to a stream.\n\t\treturns: Nothing.\n\t\tabout: @tv tells the method whether it should serialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod Serialize(stream:TStream, tv:Int = True, name:Int = False)\n\t\tIf tv = True\n\t\t\tstream.WriteByte(TV_STRING)\n\t\tEnd If\n\t\tIf name = True\n\t\t\tWriteLString(stream, m_name)\n\t\tEnd If\n\t\t\n\t\tWriteLString(stream, m_value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Deserialize the variable from a stream.\n\t\treturns: The deserialized variable.\n\t\tabout: @tv tells the method whether it should deserialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod DeSerialize:TStringVariable(stream:TStream, tv:Int = True, name:Int = False)\n\t\tIf tv = True\n\t\t\tstream.ReadByte()\n\t\tEnd If\n\t\tIf name = True\n\t\t\tm_name = ReadLString(stream)\n\t\tEnd If\n\t\t\n\t\tm_value = ReadLString(stream)\n\t\tReturn Self\n\tEnd Method\n\t\n'#end region (Data handling)\n\t\n\tRem\n\t\tbbdoc: Get the type of this variable.\n\t\treturns: The type of this variable (\"string\").\n\tEnd Rem\n\tFunction ReportType:String()\n\t\tReturn \"string\"\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Get the TV type of this variable.\n\t\treturns: The TV_* type of this variable (TV_STRING).\n\tEnd Rem\n\tFunction GetTVType:Int()\n\t\tReturn TV_STRING\n\tEnd Function\n\t\nEnd Type\n\nRem\n\tbbdoc: The TFloatVariable type.\nEnd Rem\nType TFloatVariable Extends TVariable\n\t\n\tField m_value:Float\n\t\n\tRem\n\t\tbbdoc: Create a new FloatVariable.\n\t\treturns: The new FloatVariable (itself).\n\tEnd Rem\n\tMethod Create:TFloatVariable(name:String = Null, value:Float)\n\t\tSetName(name)\n\t\tSet(value)\n\t\tReturn Self\n\tEnd Method\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the variable's value.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod Set(value:Float)\n\t\tm_value = value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the variable's value.\n\t\treturns: The value of the variable.\n\tEnd Rem\n\tMethod Get:Float()\n\t\tReturn m_value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the value of the variable to the given string (ambiguous).\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetAmbiguous(value:String)\n\t\tm_value = Float(value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Convert the variable to a String.\n\t\treturns: A scriptable form of the StringVariable.\n\t\tabout: This function is for script output, for in-code use see #ValueAsString.\n\tEnd Rem\n\tMethod ConvToString:String()\n\t\tLocal conv:String = String(m_value), i:Int, encountered:Int\n\t\t\n\t\tFor i = conv.Find(\".\") To conv.Length - 1\n\t\t\tIf conv[i] = 48\n\t\t\t\tIf encountered = True\n\t\t\t\t\tconv = conv[..i]\n\t\t\t\t\tExit\n\t\t\t\tEnd If\n\t\t\tElse If conv[i] <> 46\n\t\t\t\tencountered = True\n\t\t\tEnd If\n\t\tNext\n\t\t\n\t\tReturn conv\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the FloatVariable as a String.\n\t\treturns: The variable's value converted to a String.\n\tEnd Rem\n\tMethod ValueAsString:String()\n\t\tReturn String(m_value)\n\tEnd Method\n\t\n'#end region (Field accessors)\n\t\n'#region Data handling\n\t\n\tRem\n\t\tbbdoc: Create a copy of the variable\n\t\treturns: A clone of the variable.\n\tEnd Rem\n\tMethod Copy:TFloatVariable()\n\t\tReturn New TFloatVariable.Create(m_name, m_value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Serialize the variable to a stream.\n\t\treturns: Nothing.\n\t\tabout: @tv tells the method whether it should serialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod Serialize(stream:TStream, tv:Int = True, name:Int = False)\n\t\tIf tv = True\n\t\t\tstream.WriteByte(TV_FLOAT)\n\t\tEnd If\n\t\tIf name = True\n\t\t\tWriteLString(stream, m_name)\n\t\tEnd If\n\t\tstream.WriteFloat(m_value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Deserialize the variable from a stream.\n\t\treturns: The deserialized variable.\n\t\tabout: @tv tells the method whether it should deserialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod DeSerialize:TFloatVariable(stream:TStream, tv:Int = True, name:Int = False)\n\t\tIf tv = True\n\t\t\tstream.ReadByte()\n\t\tEnd If\n\t\tIf name = True\n\t\t\tm_name = ReadLString(stream)\n\t\tEnd If\n\t\tm_value = stream.ReadFloat()\n\t\tReturn Self\n\tEnd Method\n\t\n'#end region (Data handling)\n\t\n\tRem\n\t\tbbdoc: Get the type of this variable.\n\t\treturns: The type of this variable (\"float\").\n\tEnd Rem\n\tFunction ReportType:String()\n\t\tReturn \"float\"\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Get the TV type of this variable.\n\t\treturns: The TV_* type of this variable (TV_FLOAT).\n\tEnd Rem\n\tFunction GetTVType:Int()\n\t\tReturn TV_FLOAT\n\tEnd Function\n\t\nEnd Type\n\nRem\n\tbbdoc: The TIntVariable type.\nEnd Rem\nType TIntVariable Extends TVariable\n\t\t\n\tField m_value:Int\n\t\n\tRem\n\t\tbbdoc: Create a new IntVariable.\n\t\treturns: The new IntVariable (itself).\n\tEnd Rem\n\tMethod Create:TIntVariable(name:String = Null, value:Int)\n\t\tSetName(name)\n\t\tSet(value)\n\t\tReturn Self\n\tEnd Method\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the variable's value.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod Set(value:Int)\n\t\tm_value = value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the variable's value.\n\t\treturns: The value of the variable.\n\tEnd Rem\n\tMethod Get:Int()\n\t\tReturn m_value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the value of the variable to the given string (ambiguous).\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetAmbiguous(value:String)\n\t\tm_value = Int(value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Convert the variable to a String.\n\t\treturns: A string representation of the variable.\n\t\tabout: This function is for script output, for in-code use see #ValueAsString.\n\tEnd Rem\n\tMethod ConvToString:String()\n\t\tReturn String(m_value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the IntVariable as a String.\n\t\treturns: The variable value converted to a String.\n\tEnd Rem\n\tMethod ValueAsString:String()\n\t\tReturn String(m_value)\n\tEnd Method\n\t\n'#end region (Field accessors)\n\t\n'#region Data handling\n\t\n\tRem\n\t\tbbdoc: Create a copy of the variable\n\t\treturns: A clone of the variable.\n\tEnd Rem\n\tMethod Copy:TIntVariable()\n\t\tReturn New TIntVariable.Create(m_name, m_value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Serialize the variable to a stream.\n\t\treturns: Nothing.\n\t\tabout: @tv tells the method whether it should serialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod Serialize(stream:TStream, tv:Int = True, name:Int = False)\n\t\tIf tv = True\n\t\t\tstream.WriteByte(TV_INTEGER)\n\t\tEnd If\n\t\tIf name = True\n\t\t\tWriteLString(stream, m_name)\n\t\tEnd If\n\t\t\n\t\tstream.WriteInt(m_value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Deserialize the variable from a stream.\n\t\treturns: The deserialized variable.\n\t\tabout: @tv tells the method whether it should deserialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod DeSerialize:TIntVariable(stream:TStream, tv:Int = True, name:Int = False)\n\t\tIf tv = True\n\t\t\tstream.ReadByte()\n\t\tEnd If\n\t\tIf name = True\n\t\t\tm_name = ReadLString(stream)\n\t\tEnd If\n\t\t\n\t\tm_value = stream.ReadInt()\n\t\tReturn Self\n\tEnd Method\n\t\n'#end region (Data handling)\n\t\n\tRem\n\t\tbbdoc: Get the type of this variable.\n\t\treturns: The type of this variable (\"int\").\n\tEnd Rem\n\tFunction ReportType:String()\n\t\tReturn \"int\"\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Get the TV type of this variable.\n\t\treturns: The TV_* type of this variable (TV_INTEGER).\n\tEnd Rem\n\tFunction GetTVType:Int()\n\t\tReturn TV_INTEGER\n\tEnd Function\n\t\nEnd Type\n\n\nRem\n\tbbdoc: The TEvalVariable type.\nEnd Rem\nType TEvalVariable Extends TVariable\n\t\n\tField m_value:String\n\t\n\tRem\n\t\tbbdoc: Create a new EvalVariable.\n\t\treturns: The new EvalVariable (itself).\n\tEnd Rem\n\tMethod Create:TEvalVariable(name:String = Null, value:String)\n\t\tSetName(name)\n\t\tSet(value)\n\t\tReturn Self\n\tEnd Method\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the equation string for the EvalVariable.\n\t\treturns: Nothing\n\tEnd Rem\n\tMethod Set(value:String)\n\t\tm_value = value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the equation string.\n\t\treturns: The equation string.\n\tEnd Rem\n\tMethod Get:String()\n\t\tReturn m_value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the value of the variable to the given string (ambiguous).\n\t\treturns: Nothing.\n\t\tabout: For this type, this method is no different than calling #Set.\n\tEnd Rem\n\tMethod SetAmbiguous(value:String)\n\t\tm_value = value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Convert the EvalVariable to a visual representation of its data.\n\t\treturns: The scriptable form of the EvalVariable.\n\t\tabout: This function is for script output, for in-code use see #ValueAsString.\n\tEnd Rem\n\tMethod ConvToString:String()\n\t\tReturn \"~q\/e:\" + m_value + \"~q\"\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the EvalVariable as a String.\n\t\treturns: The variable value converted to a String.\n\tEnd Rem\n\tMethod ValueAsString:String()\n\t\tReturn m_value\n\tEnd Method\n\t\n'#end region (Field accessors)\n\t\n'#region Data handling\n\t\n\tRem\n\t\tbbdoc: Create a copy of the variable\n\t\treturns: A clone of the variable.\n\tEnd Rem\n\tMethod Copy:TEvalVariable()\n\t\tReturn New TEvalVariable.Create(m_name, m_value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Serialize the variable to a stream.\n\t\treturns: Nothing.\n\t\tabout: @tv tells the method whether it should serialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod Serialize(stream:TStream, tv:Int = True, name:Int = False)\n\t\tIf tv = True\n\t\t\tstream.WriteByte(TV_EVAL)\n\t\tEnd If\n\t\tIf name = True\n\t\t\tWriteLString(stream, m_name)\n\t\tEnd If\n\t\t\n\t\tWriteLString(stream, m_value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Deserialize the variable from a stream.\n\t\treturns: The deserialized variable.\n\t\tabout: @tv tells the method whether it should deserialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod DeSerialize:TEvalVariable(stream:TStream, tv:Int = True, name:Int = False)\n\t\tIf tv = True\n\t\t\tstream.ReadByte()\n\t\tEnd If\n\t\tIf name = True\n\t\t\tm_name = ReadLString(stream)\n\t\tEnd If\n\t\t\n\t\tm_value = ReadLString(stream)\n\t\tReturn Self\n\tEnd Method\n\t\n'#end region (Data handling)\n\t\n\tRem\n\t\tbbdoc: Get the type of this variable.\n\t\treturns: The type of this variable (\"eval\").\n\tEnd Rem\n\tFunction ReportType:String()\n\t\tReturn \"eval\"\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Get the TV type of this variable.\n\t\treturns: The TV_* type of this variable (TV_EVAL).\n\tEnd Rem\n\tFunction GetTVType:Int()\n\t\tReturn TV_EVAL\n\tEnd Function\n\t\nEnd Type\n\nRem\n\tbbdoc: The Identifier type.\nEnd Rem\nType TIdentifier Extends TVariable\n\t\n\tField m_values:TList\n\t\n\tMethod New()\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Create a new Identifier.\n\t\treturns: The new Identfier (itself).\n\tEnd Rem\n\tMethod Create:TIdentifier()\n\t\tm_values = New TList\n\t\tReturn Self\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Create a new Identifier with the given data.\n\t\treturns: The new Identfier (itself).\n\t\tabout: If the @values parameter is Null a new list will be created.\n\tEnd Rem\n\tMethod CreateByData:TIdentifier(name:String, values:TList = Null)\n\t\tSetName(name)\n\t\tIf values = Null\n\t\t\tm_values = New TList\n\t\tElse\n\t\t\tm_values = values\n\t\tEnd If\n\t\tReturn Self\n\tEnd Method\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the Identifier's values.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetValues(values:TList)\n\t\tm_values = values\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the Identifier's values.\n\t\treturns: A list containing the values which the Identifier holds.\n\tEnd Rem\n\tMethod GetValues:TList()\n\t\tReturn m_values\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Deprecated for this type.\n\t\treturns: Nothing.\n\t\tabout: This does nothing.\n\tEnd Rem\n\tMethod SetAmbiguous(value:String)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Convert the identifier to a string.\n\t\treturns: A string representation of the identifier.\n\tEnd Rem\n\tMethod ConvToString:String()\n\t\tLocal op:String, variable:TVariable\n\t\t\n\t\tIf m_name.Contains(\"~t\") = True Or m_name.Contains(\" \") = True\n\t\t\top = \"~q\" + m_name + \"~q \"\n\t\tElse\n\t\t\top = m_name + \" \"\n\t\tEnd If\n\t\t\n\t\tFor variable = EachIn m_values\n\t\t\top:+variable.ConvToString() + \" \"\n\t\tNext\n\t\top = op[..op.Length - 1]\n\t\tReturn op\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the Identifier as a string.\n\t\treturns: The Identifier contents converted to a string.\n\t\tabout: Here for complete-ness, simply calls #ConvToString.\n\tEnd Rem\n\tMethod ValueAsString:String()\n\t\tReturn ConvToString()\n\tEnd Method\n\t\n'#end region (Field accessors)\n\t\n'#region Value handling\n\t\n\tRem\n\t\tbbdoc: Get a value at an index.\n\t\treturns: The value in the identifier's list at the given index, or Null if it could not be retrieved.\n\t\tabout: The index is zero-based.\n\tEnd Rem\n\tMethod GetValueAtIndex:TVariable(index:Int)\n\t\tIf m_values <> Null And index > - 1 And index < m_values.Count()\n\t\t\tReturn TVariable(m_values.ValueAtIndex(index))\n\t\tEnd If\n\t\tReturn Null\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the number of values.\n\t\treturns: The number of values the Identifier contains.\n\tEnd Rem\n\tMethod GetValueCount:Int()\n\t\tIf m_values <> Null\n\t\t\tReturn m_values.Count()\n\t\tEnd If\n\t\tReturn 0\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Add a value to the Identifier.\n\t\treturns: True for success, or False for failure.\n\t\tabout: NOTE: This will set the given value's parent.\n\tEnd Rem\n\tMethod AddValue:Int(value:TVariable)\n\t\tIf m_values <> Null And value <> Null\n\t\t\tm_values.AddLast(value)\n\t\t\tvalue.SetParent(Self)\n\t\t\tReturn True\n\t\tEnd If\n\t\tReturn False\n\tEnd Method\n\t\n'#end region (Value handling)\n\t\n'#region Data handling\n\t\n\tRem\n\t\tbbdoc: Create a copy of the variable\n\t\treturns: A clone of the variable.\n\tEnd Rem\n\tMethod Copy:TIdentifier()\n\t\tLocal clone:TIdentifier\n\t\tclone = New TIdentifier.CreateByData(m_name)\n\t\tFor Local variable:TVariable = EachIn m_values\n\t\t\tclone.AddValue(variable.Copy())\n\t\tNext\n\t\tReturn clone\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Serialize the variable to a stream.\n\t\treturns: Nothing.\n\t\tabout: @tv tells the method whether it should serialize the TV type for the variable, or to not.
\n\t\tIn this case @name tells the method whether it should serialize the values<\/b><\/i>' name (the Identifier's name is always read\/written to the stream).\n\tEnd Rem\n\tMethod Serialize(stream:TStream, tv:Int = True, name:Int = False)\n\t\tLocal variable:TVariable\n\t\t\n\t\tIf tv = True\n\t\t\tstream.WriteByte(TV_STRING)\n\t\tEnd If\n\t\tWriteLString(stream, m_name)\n\t\t\n\t\tIf m_values = Null\n\t\t\tstream.WriteInt(0)\n\t\tElse\n\t\t\tstream.WriteInt(m_values.Count())\n\t\t\tFor variable = EachIn m_values\n\t\t\t\tvariable.Serialize(stream, True, name)\n\t\t\tNext\n\t\tEnd If\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Deserialize the variable from a stream.\n\t\treturns: The deserialized variable.\n\t\tabout: @tv tells the method whether it should deserialize the TV type for the variable, or to not.
\n\t\tIn this case @name tells the method whether it should deserialize the values<\/b><\/i>' name (the Identifier's name is always read\/written to the stream).\n\tEnd Rem\n\tMethod DeSerialize:TIdentifier(stream:TStream, tv:Int = True, name:Int = False)\n\t\tLocal count:Int, n:Int\n\t\t\n\t\tIf tv = True\n\t\t\tstream.ReadByte()\n\t\tEnd If\n\t\tm_name = ReadLString(stream)\n\t\t\n\t\tcount = stream.ReadInt()\n\t\tIf count > 0\n\t\t\tFor n = 0 To count - 1\n\t\t\t\tDeSerializeUniversal(stream, name)\n\t\t\tNext\n\t\tEnd If\n\t\t\n\t\tReturn Self\n\tEnd Method\n\t\n'#end region (Data handling)\n\t\n\tRem\n\t\tbbdoc: Get the type of this variable.\n\t\treturns: The type of this variable (\"identifier\").\n\tEnd Rem\n\tFunction ReportType:String()\n\t\tReturn \"identifier\"\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Get the TV type of this variable.\n\t\treturns: The TV_* type of this variable (TV_IDEN).\n\tEnd Rem\n\tFunction GetTVType:Int()\n\t\tReturn TV_IDEN\n\tEnd Function\n\t\nEnd Type\n\nRem\n\tbbdoc: The VariableMap type.\nEndRem\nType TVariableMap Extends TObjectMap\n\t\n\tRem\n\t\tbbdoc: Create a new VariableMap.\n\t\treturns: The new VariableMap (itself).\n\tEnd Rem\n\tMethod Create:TVariableMap()\n\t\tReturn Self\n\tEnd Method\n\t\n'#region Collections\n\t\n\tRem\n\t\tbbdoc: Insert a variable into the map.\n\t\treturns: True if the variable was added, or False if it was not (the variable's name is Null).\n\tEnd Rem\n\tMethod InsertVariable:Int(variable:TVariable)\n\t\tIf variable.GetName() <> Null\n\t\t\t_Insert(variable.GetName(), variable)\n\t\t\tReturn True\n\t\tEnd If\n\t\tReturn False\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Remove a variable by the name given.\n\t\treturns: True if a variable was removed, or False if it was not (the map contains no variable with the name given).\n\t\tabout: The name is<\/b> case-sensitive.\n\tEnd Rem\n\tMethod RemoveVariableByName:Int(name:String)\n\t\tReturn _Remove(name)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get a variable from the map by its name.\n\t\treturns: The variable object, or if the variable was not found, Null.\n\t\tabout: The name is<\/b> case-sensitive.\n\tEnd Rem\n\tMethod GetVariableByName:TVariable(name:String)\n\t\tReturn TVariable(_ValueByKey(name))\n\tEnd Method\n\t\n'#end region (Collections)\n\t\nEnd Type\n\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"8bc0fda9460197770354a97935db01c8d166a5d1","subject":"Enabled alpha testing with masked textures.","message":"Enabled alpha testing with masked textures.\n","repos":"kfprimm\/maxb3d,kfprimm\/maxb3d","old_file":"gldriver.mod\/gldriver.bmx","new_file":"gldriver.mod\/gldriver.bmx","new_contents":"\nStrict\n\nRem\n\tbbdoc: OpenGL 1.1 driver for MaxB3D\nEnd Rem\nModule MaxB3D.GLDriver\nModuleInfo \"Author: Kevin Primm\"\nModuleInfo \"License: MIT\"\n\nImport MaxB3D.Core\nImport Prime.GLMax2DEx\n\nPrivate\nFunction ModuleLog(message$)\n\tTMaxB3DLogger.Write \"gldriver\",message\nEnd Function\n\nPublic\n\nGlobal GL_LIGHT[]=[GL_LIGHT0,GL_LIGHT1,GL_LIGHT2,GL_LIGHT3,GL_LIGHT4,GL_LIGHT5,GL_LIGHT6,GL_LIGHT7]\n\nType TGLMaxB3DDriver Extends TMaxB3DDriver\n\tField _currentdata:TMaxB3DShaderData= New TMaxB3DShaderData\n\t\n\tMethod SetGraphics(g:TGraphics)\n\t\tSuper.SetGraphics g\n\t\tIf g<>Null Startup\n\tEnd Method\n\t\n\tFunction BindTexture(index,tex)\n\t\tIf index=-1\n\t\t\tFor Local i=0 To 7\n\t\t\t\tBindTexture i,tex\n\t\t\tNext\n\t\t\tReturn\n\t\tEndIf\n\t\tGlobal currenttexture[] = [-1,-1,-1,-1,-1,-1,-1,-1]\n\t\tIf tex<>currenttexture[index]\n\t\t\tglBindTexture GL_TEXTURE_2D,tex\n\t\t\tcurrenttexture[index]=tex\n\t\tEndIf\n\tEnd Function\n\t\n\tMethod Startup()\n\t\tGlobal _firsttime=True\n\t\tIf _firsttime\n\t\t\tLocal caps:TGLCaps=TGLCaps(_caps)\n\t\t\tModuleLog \"Initializing GL driver\"\n\t\t\tModuleLog \"Vendor: \"+String.FromCString(Byte Ptr(glGetString(GL_VENDOR)))\n\t\t\tModuleLog \"Renderer: \"+String.FromCString(Byte Ptr(glGetString(GL_RENDERER))) \n\t\t\tModuleLog \"Version: \"+String.FromCString(Byte Ptr(glGetString(GL_VERSION)))\n\t\t\tModuleLog \"Extensions supported: \"+\" \".Join(caps.Extensions)\n\t\t\tEndMax2D \n\t\t\t_firsttime=False\t\t\t\n\t\tEndIf\t\t\n\t\tEnableStates\n\tEnd Method\n\t\n\tFunction EnableStates()\t\n\t\tglEnable GL_LIGHTING\n\t\tglEnable GL_DEPTH_TEST\n\t\tglEnable GL_CULL_FACE\n\t\tglEnable GL_SCISSOR_TEST\n\t\t\n\t\tglEnable GL_NORMALIZE\n\t\t\n\t\tglEnableClientState GL_VERTEX_ARRAY\n\t\tglEnableClientState GL_COLOR_ARRAY\n\t\tglEnableClientState GL_NORMAL_ARRAY\n\t\t\n\t\tglFrontFace GL_CCW\n\t\t\n\t\tglLightModeli GL_LIGHT_MODEL_COLOR_CONTROL,GL_SEPARATE_SPECULAR_COLOR\n\t\tglLightModeli GL_LIGHT_MODEL_LOCAL_VIEWER,GL_TRUE\n\t\n\t\tglClearDepth 1.0\n\t\tglDepthFunc GL_LEQUAL\n\t\tglHint GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST\n\t\n\t\tglAlphaFunc GL_GEQUAL,0.5\n\t\t\n\t\tBindTexture -1,0\n\tEnd Function\t\n\t\n\tMethod MakeBuffer:TBuffer(src:Object,width,height,flags)\n\t\tLocal buffer:TBuffer\n\t\tSelect True\n\t\tCase TTextureFrame(src)<>Null\n\t\t\tbuffer=TGLBuffer(TTextureFrame(src)._buffer)\n\t\t\tIf buffer=Null\n\t\t\t\tLocal res:TGLTextureRes=UpdateTextureRes(TTextureFrame(src),0)\n\t\t\t\tbuffer=TGLMax2DExDriver(_parent).MakeGLBuffer(res._id,width,height,flags)\n\t\t\tEndIf\n\t\tDefault\n\t\t\tbuffer=_parent.MakeBuffer(src,width,height,flags)\n\t\tEnd Select\n\t\tReturn buffer\n\tEnd Method\n\t\n\tMethod Abbr$()\n\t\tReturn \"gl\"\n\tEnd Method\n\t\n\tMethod GetCaps:TCaps()\n\t\tLocal caps:TGLCaps=New TGLCaps\n\t\tcaps.Extensions=String.FromCString(glGetString(GL_EXTENSIONS)).Split(\" \")\n\t\tIf caps.HasExtension(\"GL_ARB_point_sprite\")<>-1\n\t\t\tcaps.PointSprites=True\n\t\t\tglGetFloatv GL_POINT_SIZE_MAX_ARB, Varptr caps.MaxPointSize\n\t\tEndIf\n\t\tReturn caps\n\tEnd Method\n\t\n\tMethod SetMax2D(enable)\n\t\tIf enable\n\t\t\tglPopClientAttrib\n\t\t\tglPopAttrib\n\t\t\tIf _shaderdriver _shaderdriver.Use(Null,Null)\t\n\t\t\tTGLMax2DExDriver(_parent).ResetGLContext _current\n\t\t\tglMatrixMode GL_TEXTURE\n\t\t\tglLoadIdentity\n\t\t\tglMatrixMode GL_COLOR\t\n\t\t\tglPopMatrix\t\t\t\t\t\n\t\tElse\t\t\t\n\t\t\tglPushAttrib GL_ALL_ATTRIB_BITS\n\t\t\tglPushClientAttrib GL_CLIENT_ALL_ATTRIB_BITS\n\t\t\tglMatrixMode GL_TEXTURE\n\t\t\tglPushMatrix\n\t\t\tglMatrixMode GL_COLOR\n\t\t\tglPushMatrix \n\t\t\t\n\t\t\tEnableStates()\n\t\tEndIf\n\tEnd Method\t\n\tMethod SetCamera(camera:TCamera)\n\t\tLocal vy#=WorldConfig.Height-camera._viewheight-camera._viewy\n\t\tglViewport(camera._viewx,vy,camera._viewwidth,camera._viewheight)\n\t\tglScissor(camera._viewx,vy,camera._viewwidth,camera._viewheight)\n\t\tglClearColor(camera._brush._r,camera._brush._g,camera._brush._b,1.0)\n\t\t\n\t\tIf camera._clsmode&CLSMODE_COLOR And camera._clsmode&CLSMODE_DEPTH\n\t\t\tglDepthMask GL_TRUE\n\t\t\tglClear GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT\n\t\tElse\n\t\t\tIf camera._clsmode&CLSMODE_COLOR\n\t\t\t\tglClear GL_COLOR_BUFFER_BIT\n\t\t\tElse\n\t\t\t\tIf camera._clsmode&CLSMODE_DEPTH\n\t\t\t\t\tglDepthMask GL_TRUE\n\t\t\t\t\tglClear GL_DEPTH_BUFFER_BIT\n\t\t\t\tEndIf\n\t\t\tEndIf\n\t\tEndIf\n\t\t\n\t\tIf camera._fogmode<>FOGMODE_NONE\n\t\t\tglEnable GL_FOG\n\t\t\tglFogi GL_FOG_MODE,GL_LINEAR\n\t\t\tglFogf GL_FOG_START,camera._fognear\n\t\t\tglFogf GL_FOG_END,camera._fogfar\n\t\t\tLocal rgb#[]=[camera._fogr,camera._fogg,camera._fogb]\n\t\t\tglFogfv GL_FOG_COLOR,rgb\n\t\tElse\n\t\t\tglDisable GL_FOG\n\t\tEndIf\n\t\t\n\t\tcamera.UpdateMatrices()\n\t\t\n\t\tglMatrixMode GL_PROJECTION\n\t\tglLoadIdentity\n\t\tglLoadMatrixf camera._lastprojection.ToPtr()\n\t\tglScalef -1,1,-1\n\t\t\n\t\tglMatrixMode GL_MODELVIEW\t\t\n\t\tglLoadMatrixf camera._lastmodelview.ToPtr()\n\n\t\t' Temporary hack\n\t\tglGetFloatv GL_PROJECTION_MATRIX,camera._lastprojection._m\t\t\n\t\tcamera._lastfrustum=TFrustum.Extract(camera._lastmodelview,camera._lastprojection)\n\t\t\n\t\t_currentdata._projection=camera._lastprojection\n\tEnd Method\t\n\t\n\tMethod SetLight(light:TLight,index)\n\t\tIf light=Null\n\t\t\tglDisable GL_LIGHT[index]\n\t\t\tReturn\n\t\tElse\n\t\t\tIf light._hidden=True \n\t\t\t\tglDisable GL_LIGHT[index]\n\t\t\t\tReturn False\n\t\t\tEndIf\n\t\tEndIf\n\t\t\n\t\tglEnable GL_LIGHT[index]\n\t\t\n\t\tglPushMatrix\n\t\tglMultMatrixf light.GetMatrix(True).ToPtr()\n\t\t\n\t\tLocal white_light#[]=[1.0,1.0,1.0,1.0]\n\t\tglLightfv GL_LIGHT[index],GL_SPECULAR,white_light\n\t\t\n\t\tLocal z#=1.0\n\t\tLocal w#=0.0\n\t\tIf light._mode>LIGHT_DIRECTIONAL\n\t\t\tz=0.0\n\t\t\tw=1.0\n\t\tEndIf\n\t\t\n\t\tLocal rgba#[]=[light._brush._r,light._brush._g,light._brush._b,1.0]\n\t\tLocal pos#[]=[0.0,0.0,-z,w]\n\t\t\n\t\tglLightfv GL_LIGHT[index],GL_POSITION,pos\n\t\tglLightfv GL_LIGHT[index],GL_DIFFUSE,rgba\n\t\n\t\tIf light._mode<>LIGHT_DIRECTIONAL\n\t\t\tLocal light_range#[]=[0.0]\n\t\t\tLocal range#[]=[light._range]\n\t\t\tglLightfv GL_LIGHT[index],GL_CONSTANT_ATTENUATION,light_range\n\t\t\tglLightfv GL_LIGHT[index],GL_LINEAR_ATTENUATION,range\n\t\tEndIf\t\t\n\n\t\tIf light._mode=LIGHT_SPOT\t\t\n\t\t\tLocal dir#[]=[0.0,0.0,-1.0]\n\t\t\tLocal outer#[]=[light._outer\/2.0]\n\t\t\tLocal exponent#[]=[10.0]\t\n\t\t\tglLightfv GL_LIGHT[index],GL_SPOT_DIRECTION,dir\n\t\t\tglLightfv GL_LIGHT[index],GL_SPOT_CUTOFF,outer\n\t\t\tglLightfv GL_LIGHT[index],GL_SPOT_EXPONENT,exponent\n\t\tEndIf\n\t\t\n\t\tglPopMatrix\n\tEnd Method\n\t\n\tMethod SetBrush(brush:TBrush,hasalpha)\n\t\tglDisable GL_ALPHA_TEST\n\t\t\t\n\t\tLocal ambient#[]=[WorldConfig.AmbientRed\/255.0,WorldConfig.AmbientGreen\/255.0,WorldConfig.AmbientBlue\/255.0]\t\t\t\n\t\t\t\t\t\n\t\tIf hasalpha\n\t\t\tglEnable GL_BLEND\n\t\t\tglDepthMask GL_FALSE\n\t\tElse\n\t\t\tglDisable GL_BLEND\n\t\t\tglDepthMask GL_TRUE\n\t\tEndIf\n\t\t\n\t\tSelect brush._blend\n\t\t\tCase BLEND_NONE,BLEND_ALPHA\n\t\t\t\tglBlendFunc GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA\n\t\t\tCase BLEND_MULTIPLY\n\t\t\t\tglBlendFunc GL_DST_COLOR,GL_ZERO\n\t\t\tCase BLEND_ADD\n\t\t\t\tglBlendFunc GL_SRC_ALPHA,GL_ONE\n\t\tEnd Select\n\t\t\n\t\tIf brush._fx&FX_FULLBRIGHT\n\t\t\tambient[0]=1.0\n\t\t\tambient[1]=1.0\n\t\t\tambient[2]=1.0\t\t\n\t\tEndIf\n\t\t\n\t\tIf brush._fx&FX_VERTEXCOLOR\n\t\t\tglEnable GL_COLOR_MATERIAL\n\t\tElse\n\t\t\tglDisable GL_COLOR_MATERIAL\n\t\tEndIf\n\t\t\n\t\tIf brush._fx&FX_FLATSHADED\n\t\t\tglShadeModel GL_FLAT\n\t\tElse\n\t\t\tglShadeModel GL_SMOOTH\n\t\tEndIf\n\n\t\tIf brush._fx&FX_NOFOG\n\t\t\tglDisable GL_FOG\n\t\tEndIf\n\t\t\n\t\tIf brush._fx&FX_NOCULLING\n\t\t\tglDisable GL_CULL_FACE\n\t\tElse\n\t\t\tglEnable GL_CULL_FACE\n\t\tEndIf\n\t\t\n\t\tIf brush._fx&FX_WIREFRAME Or WorldConfig.Wireframe\n\t\t\tglPolygonMode GL_FRONT_AND_BACK,GL_LINE\n\t\tElse\n\t\t\tglPolygonMode GL_FRONT_AND_BACK,GL_FILL\n\t\tEndIf\t\t\t\n\t\t\n\t\tLocal no_mat#[]=[0.0,0.0]\n\t\tLocal mat_ambient#[]=[brush._r,brush._g,brush._b,brush._a]\n\t\tLocal mat_diffuse#[]=[brush._r,brush._g,brush._b,brush._a]\n\t\tLocal mat_specular#[]=[brush._shine,brush._shine,brush._shine,brush._shine]\n\t\tLocal mat_shininess#[]=[100.0]\n\t\t\t\n\t\tglMaterialfv GL_FRONT,GL_AMBIENT,mat_ambient\n\t\tglMaterialfv GL_FRONT,GL_DIFFUSE,mat_diffuse\n\t\tglMaterialfv GL_FRONT,GL_SPECULAR,mat_specular\n\t\tglMaterialfv GL_FRONT,GL_SHININESS,mat_shininess\n\t\tglLightModelfv GL_LIGHT_MODEL_AMBIENT,ambient\n\t\t\n\t\tFor Local i=0 To 7\n\t\t\tglActiveTextureARB GL_TEXTURE0+i\n\n\t\t\tLocal texture:TTexture=brush._texture[i]\n\t\t\tIf texture=Null Or texture._blend=BLEND_NONE\n\t\t\t\tglDisable GL_TEXTURE_2D\n\t\t\t\tBindTexture i,0\n\t\t\t\tContinue\n\t\t\tEndIf\n\t\t\t\n\t\t\tLocal texres:TGLTextureRes=TGLTextureRes(UpdateTextureRes(texture._frame[brush._textureframe[i]],texture._flags))\n\t\t\t\n\t\t\tglEnable GL_TEXTURE_2D\n\t\t\t\n\t\t\tBindTexture i,texres._id\t\n\t\t\t\n\t\t\tglMatrixMode GL_TEXTURE\n\t\t\tglLoadIdentity\n\t\t\tglTranslatef texture._px,-texture._py,0\n\t\t\tglScalef -texture._sx,texture._sy,1\n\t\t\t\n\t\t\tIf texture._flags&TEXTURE_ALPHA or texture._flags&TEXTURE_MASKED\n\t\t\t\tglEnable GL_ALPHA_TEST\n\t\t\tElse\n\t\t\t\tglDisable GL_ALPHA_TEST\n\t\t\tEndIf\n\t\t\n\t\t\tIf texture._flags&TEXTURE_MIPMAP\n\t\t\t\tglTexParameteri GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR\n\t\t\t\tglTexParameteri GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_LINEAR\n\t\t\tElse\n\t\t\t\tglTexParameteri GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR\n\t\t\t\tglTexParameteri GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR\n\t\t\tEndIf\n\t\t\t\n\t\t\tIf texture._flags&TEXTURE_CLAMPU\n\t\t\t\tglTexParameteri GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_CLAMP_TO_EDGE\n\t\t\tElse\t\t\t\t\t\t\n\t\t\t\tglTexParameteri GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_REPEAT\n\t\t\tEndIf\n\t\t\t\n\t\t\tIf texture._flags&TEXTURE_CLAMPV\n\t\t\t\tglTexParameteri GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_CLAMP_TO_EDGE\n\t\t\tElse\n\t\t\t\tglTexParameteri GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_REPEAT\n\t\t\tEndIf\n\t\n\t\t\tIf texture._flags&TEXTURE_SPHEREMAP\t\t\t\t\n\t\t\t\tglEnable GL_TEXTURE_GEN_S\n\t\t\t\tglEnable GL_TEXTURE_GEN_T\n\t\t\t\tglTexGeni GL_S,GL_TEXTURE_GEN_MODE,GL_SPHERE_MAP\n\t\t\t\tglTexGeni GL_T,GL_TEXTURE_GEN_MODE,GL_SPHERE_MAP\n\t\t\tElse\n\t\t\t\tglDisable GL_TEXTURE_GEN_S\n\t\t\t\tglDisable GL_TEXTURE_GEN_T\n\t\t\tEndIf\n\n\t\t\tSelect texture._blend\n\t\t\tCase BLEND_NONE glTexEnvf(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_REPLACE)\n\t\t\tCase BLEND_ALPHA \tglTexEnvf(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_MODULATE)\n\t\t\tCase BLEND_MULTIPLY glTexEnvf(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_MODULATE)\n\t\t\t'Case BLEND_MULTIPLY glTexEnvf(GL_TEXTURE_ENV,GL_COMBINE_RGB_EXT,GL_MODULATE)\n\t\t\tCase BLEND_ADD glTexEnvf(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_ADD)\n\t\t\tCase BLEND_DOT3\n\t\t\t\tglTexEnvf GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT\n\t\t\t\tglTexEnvf GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_DOT3_RGB_EXT\n\t\t\tCase BLEND_MULTIPLY2\n\t\t\t\tglTexEnvi GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_COMBINE\n\t\t\t\tglTexEnvi GL_TEXTURE_ENV,GL_COMBINE_RGB,GL_MODULATE\n\t\t\t\tglTexEnvi GL_TEXTURE_ENV,GL_RGB_SCALE,2.0\n\t\t\tDefault glTexEnvf GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_MODULATE\n\t\t\tEnd Select\t\t\t\n\t\tNext\t\n\t\t\n\t\tIf _shaderdriver _shaderdriver.Use(brush._shader,_currentdata)\t\n\tEnd Method\n\t\n\tMethod RenderSurface(resource:TSurfaceRes,brush:TBrush)\n\t\tLocal res:TGLSurfaceRes=TGLSurfaceRes(resource)\t\n\t\t\n\t\tFor Local i=0 To 7\n\t\t\tglClientActiveTextureARB GL_TEXTURE0+i\n\t\t\t\n\t\t\tLocal texture:TTexture=brush._texture[i]\n\t\t\tIf texture=Null \n\t\t\t\tglDisableClientState GL_TEXTURE_COORD_ARRAY\n\t\t\t\tContinue\n\t\t\tEndIf\n\t\t\t\n\t\t\tglEnableClientState GL_TEXTURE_COORD_ARRAY\n\t\t\tglBindBufferARB GL_ARRAY_BUFFER_ARB,res._vbo[4+texture._coords]\n\t\t\tglTexCoordPointer 2,GL_FLOAT,0,Null\n\t\tNext\n\t\t\n\t\tglBindBufferARB GL_ARRAY_BUFFER_ARB,res._vbo[0]\n\t\tglVertexPointer 3,GL_FLOAT,0,Null\n\t\t\n\t\tglBindBufferARB GL_ARRAY_BUFFER_ARB,res._vbo[1]\n\t\tglNormalPointer GL_FLOAT,0,Null\n\t\t\n\t\tglBindBufferARB GL_ARRAY_BUFFER_ARB,res._vbo[2]\n\t\tglColorPointer 4,GL_FLOAT,0,Null\n\t\n\t\tglBindBufferARB GL_ELEMENT_ARRAY_BUFFER_ARB,res._vbo[3]\n\t\tglDrawElements GL_TRIANGLES,res._trianglecnt*3,GL_UNSIGNED_INT,Null\n\t\t\n\t\tReturn res._trianglecnt\n\tEnd Method\n\t\n\tMethod BeginEntityRender(entity:TEntity)\t\t\n\t\tIf entity._order<>0\n\t\t\tglDisable GL_DEPTH_TEST\n\t\t\tglDepthMask GL_FALSE\n\t\tElse\n\t\t\tglEnable GL_DEPTH_TEST\n\t\t\tglDepthMask GL_TRUE\n\t\tEndIf\n\t\t\n\t\tglMatrixMode GL_MODELVIEW\n\t\tglPushMatrix\n\t\tglMultMatrixf entity.GetMatrix(True,False).ToPtr()\n\t\t\n\t\tGlobal matrix:TMatrix=New TMatrix\n\t\tglGetFloatv GL_MODELVIEW_MATRIX,matrix._m\n\t\t_currentdata._modelviewproj=matrix.Multiply(_currentdata._projection)\n\tEnd Method\n\tMethod EndEntityRender(entity:TEntity)\n\t\tglMatrixMode GL_MODELVIEW\n\t\tglPopMatrix\n\tEnd Method\n\t\n\tMethod RenderFlat(flat:TFlat)\n\t\tLocal x#,y#,z#\n\t\tflat.GetScale x,y,z,True\n\t\t\n\t\tglBegin GL_QUADS\n\t\t\tglNormal3f 0,1,0\n\t\t\tglTexCoord2f 0,0\n\t\t\tglVertex3f -1,0, 1\n\t\t\tglTexCoord2f x,0\t\n\t\t\tglVertex3f 1, 0, 1\n\t\t\tglTexCoord2f x,z\n\t\t\tglVertex3f 1, 0, -1\n\t\t\tglTexCoord2f 0,z\n\t\t\tglVertex3f -1,0, -1\n\t\tglEnd\n\t\tReturn 2\n\tEnd Method\n\t\n\tMethod RenderSprite(sprite:TSprite)\n\t\tIf False\n\t\t\tglPointParameterfvARB GL_POINT_DISTANCE_ATTENUATION_ARB, [0.0, 0.0, 1.0]\n\t\t\t\n\t\t\tglPointSize 1.0\n\t\t\t\n\t\t\tglPointParameterfARB GL_POINT_FADE_THRESHOLD_SIZE_ARB,60.0\n\t\t\tglPointParameterfARB GL_POINT_SIZE_MIN_ARB,0.0\n\t\t\tglPointParameterfARB GL_POINT_SIZE_MAX_ARB,9999.0\n\t\t\t\n\t\t\tglTexEnvf GL_POINT_SPRITE_ARB,GL_COORD_REPLACE_ARB,GL_TRUE\n\t\t\t\n\t\t\tglEnable GL_POINT_SPRITE_ARB\n\t\t\t\n\t\t\tglBegin GL_POINTS\t\t\t\n\t\t\tglVertex3f 0,0,0\n\t\t\tglEnd\n\t\t\t\n\t\t\tglDisable GL_POINT_SPRITE_ARB\n\t\tElse\n\t\t\tglBegin GL_QUADS\n\t\t\t\tglNormal3f 0,0,-1\n\t\t\t\tglTexCoord2f 0,1\n\t\t\t\tglVertex3f 1, -1, 0\t\t\t\n\t\t\t\tglTexCoord2f 0,0\n\t\t\t\tglVertex3f 1, 1, 0\t\t\t\n\t\t\t\tglTexCoord2f 1,0\n\t\t\t\tglVertex3f -1,1, 0\t\t\t\n\t\t\t\tglTexCoord2f 1,1\n\t\t\t\tglVertex3f -1,-1, 0\n\t\t\tglEnd\n\t\tEndIf\n\tEnd Method\n\t\n\tMethod RenderTerrain(terrain:TTerrain)\n\t\n\t\tglDisableClientState GL_TEXTURE_COORD_ARRAY\n\t\tFor Local i=0 To 7\n\t\t\tLocal texture:TTexture=terrain._brush._texture[i]\n\t\t\tIf texture=Null Continue\n\t\t\tglEnableClientState(GL_TEXTURE_COORD_ARRAY)\n\t\t\tglClientActiveTextureARB(GL_TEXTURE0+i)\n\t\t\tglTexCoordPointer(2,GL_FLOAT,20,terrain._data)\n\t\tNext\n\t\t\n\t\tglEnableClientState GL_VERTEX_ARRAY\n\t\tglDisableClientState GL_COLOR_ARRAY\n\t\tglDisableClientState GL_NORMAL_ARRAY\n\t\t\n\t\tglVertexPointer(3,GL_FLOAT, 20, terrain._data+2)\n\t\tglDrawArrays(GL_TRIANGLES, 0, 3*terrain._count)\n\t\t\n\t\tglEnableClientState GL_VERTEX_ARRAY\n\t\tglEnableClientState GL_COLOR_ARRAY \n\t\tglEnableClientState GL_NORMAL_ARRAY \n\tEnd Method\n\t\n\tMethod RenderBSPTree(tree:TBSPTree)\n\t\tLocal node:TBSPNode=tree.Node\n\t\tIf node=Null Return\n\t\tLocal triangles\n\t\ttriangles:+RenderBSPTree(node.In)\t\t\n\t\t\n\t\tFor Local poly:TBSPPolygon=EachIn node.On\n\t\t\tglBegin GL_POLYGON\n\t\t\tglNormal3f poly.Plane.x,poly.Plane.y,poly.Plane.z\n\t\t\tLocal ptA:TVector=poly.Point[0],v0\n\t\t\tFor Local i=1 To poly.Count()-2\n\t\t\t\tLocal ptB:TVector=poly.Point[i],ptC:TVector=poly.Point[i+1]\n\t\t\t\tglVertex3f ptA.x,ptA.y,ptA.z\n\t\t\t\tglVertex3f ptB.x,ptB.y,ptB.z\n\t\t\t\tglVertex3f ptC.x,ptC.y,ptC.z\n\t\t\tNext\n\t\t\ttriangles:+poly.Count()-2\n\t\t\tglEnd\n\t\tNext\t\n\t\t\n\t\ttriangles:+RenderBSPTree(node.Out)\n\t\tReturn triangles\n\tEnd Method\n\n\tMethod UpdateTextureRes:TGLTextureRes(frame:TTextureFrame,flags)\n\t\tIf frame=Null Return Null\n\t\t\n\t\tLocal glres:TGLTextureRes=TGLTextureRes(frame._res)\n\t\tIf glres=Null\n\t\t\tglres=New TGLTextureRes\n\t\t\tframe._res=glres\n\t\t\tframe._updateres=True\n\t\tEndIf\t\t\n\t\tIf Not frame._updateres Return glres\n\t\t\n\t\tIf glres._id=0 glGenTextures(1,Varptr glres._id)\n\t\tBindTexture 0,glres._id\n\t\tLocal pixmap:TPixmap=frame._pixmap\n\t\tgluBuild2DMipmaps(GL_TEXTURE_2D,GL_RGBA8,pixmap.width,pixmap.height,GL_BGRA,GL_UNSIGNED_BYTE,pixmap.pixels)\n\t\t\n\t\tframe._updateres=0\n\t\tReturn glres\n\tEnd Method\n\t\n\tMethod UpdateSurfaceRes:TGLSurfaceRes(surface:TSurface)\n\t\tLocal res:TGLSurfaceRes=TGLSurfaceRes(surface._res)\n\t\tIf res=Null res=New TGLSurfaceRes;surface._res=res\n\t\tIf surface._reset=0 Return res\n\t\t\n\t\tIf res._vbo[0]=0 glGenBuffersARB(4,res._vbo)\n\t\n\t\tIf surface._reset=-1 Then surface._reset=1|2|4|8|16|32|64|128|256\n\t\n\t\tIf surface._reset&1 UploadVertexBuffer res._vbo[0],surface._vertexpos\n\t\tIf surface._reset&2 UploadVertexNormals res._vbo[1],surface._vertexnml\n\t\tIf surface._reset&4 UploadVertexBuffer res._vbo[2],surface._vertexclr\n\t\tIf surface._reset&8\n\t\t\tglBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB,res._vbo[3])\n\t\t\tglBufferDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB,surface._triangle.length*4,surface._triangle,GL_STATIC_DRAW_ARB)\n\t\tEndIf\n\t\t\n\t\tFor Local i=0 To surface._vertextex.length-1\n\t\t\tIf res._vbo[4+i]=0 glGenBuffersARB(1,Varptr res._vbo[4+i])\n\t\t\tIf surface._reset&Int(2^(4+i)) UploadVertexBuffer res._vbo[4+i],surface._vertextex[i]\n\t\tNext\t\n\t\t\n\t\tres._trianglecnt=surface._trianglecnt\n\t\tres._vertexcnt=surface._vertexcnt\t\t\n\t\tsurface._reset=0\t\t\n\t\tReturn res\n\tEnd Method\n\t\n\tMethod MergeSurfaceRes:TGLSurfaceRes(base:TSurface,animation:TSurface,data)\n\t\tIf animation=Null Return UpdateSurfaceRes(base)\n\t\tLocal res_base:TGLSurfaceRes=UpdateSurfaceRes(base)\n\t\tLocal res_anim:TGLSurfaceRes=UpdateSurfaceRes(animation)\n\t\tLocal res:TGLSurfaceRes=res_base.Copy()\n\t\tres._vbo[0]=res_anim._vbo[0]\n\t\tReturn res\n\tEnd Method\n\t\n\tMethod UploadVertexBuffer(vbo,data#[])\n\t\tglBindBufferARB(GL_ARRAY_BUFFER_ARB,vbo)\n\t\tglBufferDataARB(GL_ARRAY_BUFFER_ARB,data.length*4,data,GL_STATIC_DRAW_ARB)\n\tEnd Method\n\t\n\tMethod UploadVertexNormals(vbo,data#[])\n\t\tglBindBufferARB(GL_ARRAY_BUFFER_ARB,vbo)\n\t\tglBufferDataARB(GL_ARRAY_BUFFER_ARB,data.length*4,data,GL_STATIC_DRAW_ARB)\n\tEnd Method\nEnd Type\n\nType TGLCaps Extends TCaps\n\tField Extensions$[]\n\t\n\tMethod HasExtension(ext$)\n\t\tFor Local extension$=EachIn Extensions\n\t\t\tIf extension.Find(ext)<>-1 Return True\n\t\tNext\n\t\tReturn False \n\tEnd Method\n\t\n\tMethod Copy:TGLCaps()\n\t\tLocal caps:TGLCaps=New TGLCaps\n\t\tcaps.CopyBase(Self)\n\t\tcaps.Extensions=Extensions[..]\n\t\tReturn caps\t\t\n\tEnd Method\nEnd Type\n\nType TGLSurfaceRes Extends TSurfaceRes\n\tField _vbo[12]\n\tField _texcoord\n\t\n\tMethod Copy:TGLSurfaceRes()\n\t\tLocal res:TGLSurfaceRes=New TGLSurfaceRes\n\t\tres._vertexcnt=_vertexcnt;res._trianglecnt=_trianglecnt\n\t\tres._vbo=_vbo[..]\n\t\tres._texcoord=_texcoord\n\t\tReturn res\n\tEnd Method\nEnd Type\n\nType TGLTextureRes Extends TTextureRes\n\tField _id\nEnd Type\n\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GLMaxB3DDriver:TGLMaxB3DDriver()\n\tIf GLMax2DExDriver()\n\t\tGlobal driver:TGLMaxB3DDriver=New TGLMaxB3DDriver\n\t\tdriver._parent=GLMax2DExDriver()\n\t\tReturn driver\n\tEnd If\nEnd Function\n\nRem\n\tbbdoc: Utility function that sets the MaxB3D GL driver and calls Graphics.\nEnd Rem\nFunction GLGraphics3D:TGraphics(width,height,depth=0,hertz=60,flags=0)\n\tSetGraphicsDriver GLMaxB3DDriver(),GRAPHICS_BACKBUFFER|GRAPHICS_DEPTHBUFFER\n\tReturn Graphics(width,height,depth,hertz,flags)\nEnd Function\n\nLocal driver:TGLMaxB3DDriver=GLMaxB3DDriver()\nIf driver SetGraphicsDriver driver,GRAPHICS_BACKBUFFER|GRAPHICS_DEPTHBUFFER\n","old_contents":"\nStrict\n\nRem\n\tbbdoc: OpenGL 1.1 driver for MaxB3D\nEnd Rem\nModule MaxB3D.GLDriver\nModuleInfo \"Author: Kevin Primm\"\nModuleInfo \"License: MIT\"\n\nImport MaxB3D.Core\nImport Prime.GLMax2DEx\n\nPrivate\nFunction ModuleLog(message$)\n\tTMaxB3DLogger.Write \"gldriver\",message\nEnd Function\n\nPublic\n\nGlobal GL_LIGHT[]=[GL_LIGHT0,GL_LIGHT1,GL_LIGHT2,GL_LIGHT3,GL_LIGHT4,GL_LIGHT5,GL_LIGHT6,GL_LIGHT7]\n\nType TGLMaxB3DDriver Extends TMaxB3DDriver\n\tField _currentdata:TMaxB3DShaderData= New TMaxB3DShaderData\n\t\n\tMethod SetGraphics(g:TGraphics)\n\t\tSuper.SetGraphics g\n\t\tIf g<>Null Startup\n\tEnd Method\n\t\n\tFunction BindTexture(index,tex)\n\t\tIf index=-1\n\t\t\tFor Local i=0 To 7\n\t\t\t\tBindTexture i,tex\n\t\t\tNext\n\t\t\tReturn\n\t\tEndIf\n\t\tGlobal currenttexture[] = [-1,-1,-1,-1,-1,-1,-1,-1]\n\t\tIf tex<>currenttexture[index]\n\t\t\tglBindTexture GL_TEXTURE_2D,tex\n\t\t\tcurrenttexture[index]=tex\n\t\tEndIf\n\tEnd Function\n\t\n\tMethod Startup()\n\t\tGlobal _firsttime=True\n\t\tIf _firsttime\n\t\t\tLocal caps:TGLCaps=TGLCaps(_caps)\n\t\t\tModuleLog \"Initializing GL driver\"\n\t\t\tModuleLog \"Vendor: \"+String.FromCString(Byte Ptr(glGetString(GL_VENDOR)))\n\t\t\tModuleLog \"Renderer: \"+String.FromCString(Byte Ptr(glGetString(GL_RENDERER))) \n\t\t\tModuleLog \"Version: \"+String.FromCString(Byte Ptr(glGetString(GL_VERSION)))\n\t\t\tModuleLog \"Extensions supported: \"+\" \".Join(caps.Extensions)\n\t\t\tEndMax2D \n\t\t\t_firsttime=False\t\t\t\n\t\tEndIf\t\t\n\t\tEnableStates\n\tEnd Method\n\t\n\tFunction EnableStates()\t\n\t\tglEnable GL_LIGHTING\n\t\tglEnable GL_DEPTH_TEST\n\t\tglEnable GL_CULL_FACE\n\t\tglEnable GL_SCISSOR_TEST\n\t\t\n\t\tglEnable GL_NORMALIZE\n\t\t\n\t\tglEnableClientState GL_VERTEX_ARRAY\n\t\tglEnableClientState GL_COLOR_ARRAY\n\t\tglEnableClientState GL_NORMAL_ARRAY\n\t\t\n\t\tglFrontFace GL_CCW\n\t\t\n\t\tglLightModeli GL_LIGHT_MODEL_COLOR_CONTROL,GL_SEPARATE_SPECULAR_COLOR\n\t\tglLightModeli GL_LIGHT_MODEL_LOCAL_VIEWER,GL_TRUE\n\t\n\t\tglClearDepth 1.0\n\t\tglDepthFunc GL_LEQUAL\n\t\tglHint GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST\n\t\n\t\tglAlphaFunc GL_GEQUAL,0.5\n\t\t\n\t\tBindTexture -1,0\n\tEnd Function\t\n\t\n\tMethod MakeBuffer:TBuffer(src:Object,width,height,flags)\n\t\tLocal buffer:TBuffer\n\t\tSelect True\n\t\tCase TTextureFrame(src)<>Null\n\t\t\tbuffer=TGLBuffer(TTextureFrame(src)._buffer)\n\t\t\tIf buffer=Null\n\t\t\t\tLocal res:TGLTextureRes=UpdateTextureRes(TTextureFrame(src),0)\n\t\t\t\tbuffer=TGLMax2DExDriver(_parent).MakeGLBuffer(res._id,width,height,flags)\n\t\t\tEndIf\n\t\tDefault\n\t\t\tbuffer=_parent.MakeBuffer(src,width,height,flags)\n\t\tEnd Select\n\t\tReturn buffer\n\tEnd Method\n\t\n\tMethod Abbr$()\n\t\tReturn \"gl\"\n\tEnd Method\n\t\n\tMethod GetCaps:TCaps()\n\t\tLocal caps:TGLCaps=New TGLCaps\n\t\tcaps.Extensions=String.FromCString(glGetString(GL_EXTENSIONS)).Split(\" \")\n\t\tIf caps.HasExtension(\"GL_ARB_point_sprite\")<>-1\n\t\t\tcaps.PointSprites=True\n\t\t\tglGetFloatv GL_POINT_SIZE_MAX_ARB, Varptr caps.MaxPointSize\n\t\tEndIf\n\t\tReturn caps\n\tEnd Method\n\t\n\tMethod SetMax2D(enable)\n\t\tIf enable\n\t\t\tglPopClientAttrib\n\t\t\tglPopAttrib\n\t\t\tIf _shaderdriver _shaderdriver.Use(Null,Null)\t\n\t\t\tTGLMax2DExDriver(_parent).ResetGLContext _current\n\t\t\tglMatrixMode GL_TEXTURE\n\t\t\tglLoadIdentity\n\t\t\tglMatrixMode GL_COLOR\t\n\t\t\tglPopMatrix\t\t\t\t\t\n\t\tElse\t\t\t\n\t\t\tglPushAttrib GL_ALL_ATTRIB_BITS\n\t\t\tglPushClientAttrib GL_CLIENT_ALL_ATTRIB_BITS\n\t\t\tglMatrixMode GL_TEXTURE\n\t\t\tglPushMatrix\n\t\t\tglMatrixMode GL_COLOR\n\t\t\tglPushMatrix \n\t\t\t\n\t\t\tEnableStates()\n\t\tEndIf\n\tEnd Method\t\n\tMethod SetCamera(camera:TCamera)\n\t\tLocal vy#=WorldConfig.Height-camera._viewheight-camera._viewy\n\t\tglViewport(camera._viewx,vy,camera._viewwidth,camera._viewheight)\n\t\tglScissor(camera._viewx,vy,camera._viewwidth,camera._viewheight)\n\t\tglClearColor(camera._brush._r,camera._brush._g,camera._brush._b,1.0)\n\t\t\n\t\tIf camera._clsmode&CLSMODE_COLOR And camera._clsmode&CLSMODE_DEPTH\n\t\t\tglDepthMask GL_TRUE\n\t\t\tglClear GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT\n\t\tElse\n\t\t\tIf camera._clsmode&CLSMODE_COLOR\n\t\t\t\tglClear GL_COLOR_BUFFER_BIT\n\t\t\tElse\n\t\t\t\tIf camera._clsmode&CLSMODE_DEPTH\n\t\t\t\t\tglDepthMask GL_TRUE\n\t\t\t\t\tglClear GL_DEPTH_BUFFER_BIT\n\t\t\t\tEndIf\n\t\t\tEndIf\n\t\tEndIf\n\t\t\n\t\tIf camera._fogmode<>FOGMODE_NONE\n\t\t\tglEnable GL_FOG\n\t\t\tglFogi GL_FOG_MODE,GL_LINEAR\n\t\t\tglFogf GL_FOG_START,camera._fognear\n\t\t\tglFogf GL_FOG_END,camera._fogfar\n\t\t\tLocal rgb#[]=[camera._fogr,camera._fogg,camera._fogb]\n\t\t\tglFogfv GL_FOG_COLOR,rgb\n\t\tElse\n\t\t\tglDisable GL_FOG\n\t\tEndIf\n\t\t\n\t\tcamera.UpdateMatrices()\n\t\t\n\t\tglMatrixMode GL_PROJECTION\n\t\tglLoadIdentity\n\t\tglLoadMatrixf camera._lastprojection.ToPtr()\n\t\tglScalef -1,1,-1\n\t\t\n\t\tglMatrixMode GL_MODELVIEW\t\t\n\t\tglLoadMatrixf camera._lastmodelview.ToPtr()\n\n\t\t' Temporary hack\n\t\tglGetFloatv GL_PROJECTION_MATRIX,camera._lastprojection._m\t\t\n\t\tcamera._lastfrustum=TFrustum.Extract(camera._lastmodelview,camera._lastprojection)\n\t\t\n\t\t_currentdata._projection=camera._lastprojection\n\tEnd Method\t\n\t\n\tMethod SetLight(light:TLight,index)\n\t\tIf light=Null\n\t\t\tglDisable GL_LIGHT[index]\n\t\t\tReturn\n\t\tElse\n\t\t\tIf light._hidden=True \n\t\t\t\tglDisable GL_LIGHT[index]\n\t\t\t\tReturn False\n\t\t\tEndIf\n\t\tEndIf\n\t\t\n\t\tglEnable GL_LIGHT[index]\n\t\t\n\t\tglPushMatrix\n\t\tglMultMatrixf light.GetMatrix(True).ToPtr()\n\t\t\n\t\tLocal white_light#[]=[1.0,1.0,1.0,1.0]\n\t\tglLightfv GL_LIGHT[index],GL_SPECULAR,white_light\n\t\t\n\t\tLocal z#=1.0\n\t\tLocal w#=0.0\n\t\tIf light._mode>LIGHT_DIRECTIONAL\n\t\t\tz=0.0\n\t\t\tw=1.0\n\t\tEndIf\n\t\t\n\t\tLocal rgba#[]=[light._brush._r,light._brush._g,light._brush._b,1.0]\n\t\tLocal pos#[]=[0.0,0.0,-z,w]\n\t\t\n\t\tglLightfv GL_LIGHT[index],GL_POSITION,pos\n\t\tglLightfv GL_LIGHT[index],GL_DIFFUSE,rgba\n\t\n\t\tIf light._mode<>LIGHT_DIRECTIONAL\n\t\t\tLocal light_range#[]=[0.0]\n\t\t\tLocal range#[]=[light._range]\n\t\t\tglLightfv GL_LIGHT[index],GL_CONSTANT_ATTENUATION,light_range\n\t\t\tglLightfv GL_LIGHT[index],GL_LINEAR_ATTENUATION,range\n\t\tEndIf\t\t\n\n\t\tIf light._mode=LIGHT_SPOT\t\t\n\t\t\tLocal dir#[]=[0.0,0.0,-1.0]\n\t\t\tLocal outer#[]=[light._outer\/2.0]\n\t\t\tLocal exponent#[]=[10.0]\t\n\t\t\tglLightfv GL_LIGHT[index],GL_SPOT_DIRECTION,dir\n\t\t\tglLightfv GL_LIGHT[index],GL_SPOT_CUTOFF,outer\n\t\t\tglLightfv GL_LIGHT[index],GL_SPOT_EXPONENT,exponent\n\t\tEndIf\n\t\t\n\t\tglPopMatrix\n\tEnd Method\n\t\n\tMethod SetBrush(brush:TBrush,hasalpha)\n\t\tglDisable GL_ALPHA_TEST\n\t\t\t\n\t\tLocal ambient#[]=[WorldConfig.AmbientRed\/255.0,WorldConfig.AmbientGreen\/255.0,WorldConfig.AmbientBlue\/255.0]\t\t\t\n\t\t\t\t\t\n\t\tIf hasalpha\n\t\t\tglEnable GL_BLEND\n\t\t\tglDepthMask GL_FALSE\n\t\tElse\n\t\t\tglDisable GL_BLEND\n\t\t\tglDepthMask GL_TRUE\n\t\tEndIf\n\t\t\n\t\tSelect brush._blend\n\t\t\tCase BLEND_NONE,BLEND_ALPHA\n\t\t\t\tglBlendFunc GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA\n\t\t\tCase BLEND_MULTIPLY\n\t\t\t\tglBlendFunc GL_DST_COLOR,GL_ZERO\n\t\t\tCase BLEND_ADD\n\t\t\t\tglBlendFunc GL_SRC_ALPHA,GL_ONE\n\t\tEnd Select\n\t\t\n\t\tIf brush._fx&FX_FULLBRIGHT\n\t\t\tambient[0]=1.0\n\t\t\tambient[1]=1.0\n\t\t\tambient[2]=1.0\t\t\n\t\tEndIf\n\t\t\n\t\tIf brush._fx&FX_VERTEXCOLOR\n\t\t\tglEnable GL_COLOR_MATERIAL\n\t\tElse\n\t\t\tglDisable GL_COLOR_MATERIAL\n\t\tEndIf\n\t\t\n\t\tIf brush._fx&FX_FLATSHADED\n\t\t\tglShadeModel GL_FLAT\n\t\tElse\n\t\t\tglShadeModel GL_SMOOTH\n\t\tEndIf\n\n\t\tIf brush._fx&FX_NOFOG\n\t\t\tglDisable GL_FOG\n\t\tEndIf\n\t\t\n\t\tIf brush._fx&FX_NOCULLING\n\t\t\tglDisable GL_CULL_FACE\n\t\tElse\n\t\t\tglEnable GL_CULL_FACE\n\t\tEndIf\n\t\t\n\t\tIf brush._fx&FX_WIREFRAME Or WorldConfig.Wireframe\n\t\t\tglPolygonMode GL_FRONT_AND_BACK,GL_LINE\n\t\tElse\n\t\t\tglPolygonMode GL_FRONT_AND_BACK,GL_FILL\n\t\tEndIf\t\t\t\n\t\t\n\t\tLocal no_mat#[]=[0.0,0.0]\n\t\tLocal mat_ambient#[]=[brush._r,brush._g,brush._b,brush._a]\n\t\tLocal mat_diffuse#[]=[brush._r,brush._g,brush._b,brush._a]\n\t\tLocal mat_specular#[]=[brush._shine,brush._shine,brush._shine,brush._shine]\n\t\tLocal mat_shininess#[]=[100.0]\n\t\t\t\n\t\tglMaterialfv GL_FRONT,GL_AMBIENT,mat_ambient\n\t\tglMaterialfv GL_FRONT,GL_DIFFUSE,mat_diffuse\n\t\tglMaterialfv GL_FRONT,GL_SPECULAR,mat_specular\n\t\tglMaterialfv GL_FRONT,GL_SHININESS,mat_shininess\n\t\tglLightModelfv GL_LIGHT_MODEL_AMBIENT,ambient\n\t\t\n\t\tFor Local i=0 To 7\n\t\t\tglActiveTextureARB GL_TEXTURE0+i\n\n\t\t\tLocal texture:TTexture=brush._texture[i]\n\t\t\tIf texture=Null Or texture._blend=BLEND_NONE\n\t\t\t\tglDisable GL_TEXTURE_2D\n\t\t\t\tBindTexture i,0\n\t\t\t\tContinue\n\t\t\tEndIf\n\t\t\t\n\t\t\tLocal texres:TGLTextureRes=TGLTextureRes(UpdateTextureRes(texture._frame[brush._textureframe[i]],texture._flags))\n\t\t\t\n\t\t\tglEnable GL_TEXTURE_2D\n\t\t\t\n\t\t\tBindTexture i,texres._id\t\n\t\t\t\n\t\t\tglMatrixMode GL_TEXTURE\n\t\t\tglLoadIdentity\n\t\t\tglTranslatef texture._px,-texture._py,0\n\t\t\tglScalef -texture._sx,texture._sy,1\n\t\t\t\n\t\t\tIf texture._flags&TEXTURE_ALPHA\n\t\t\t\tglEnable GL_ALPHA_TEST\n\t\t\tElse\n\t\t\t\tglDisable GL_ALPHA_TEST\n\t\t\tEndIf\n\t\t\n\t\t\tIf texture._flags&TEXTURE_MIPMAP\n\t\t\t\tglTexParameteri GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR\n\t\t\t\tglTexParameteri GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_LINEAR\n\t\t\tElse\n\t\t\t\tglTexParameteri GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR\n\t\t\t\tglTexParameteri GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR\n\t\t\tEndIf\n\t\t\t\n\t\t\tIf texture._flags&TEXTURE_CLAMPU\n\t\t\t\tglTexParameteri GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_CLAMP_TO_EDGE\n\t\t\tElse\t\t\t\t\t\t\n\t\t\t\tglTexParameteri GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_REPEAT\n\t\t\tEndIf\n\t\t\t\n\t\t\tIf texture._flags&TEXTURE_CLAMPV\n\t\t\t\tglTexParameteri GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_CLAMP_TO_EDGE\n\t\t\tElse\n\t\t\t\tglTexParameteri GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_REPEAT\n\t\t\tEndIf\n\t\n\t\t\tIf texture._flags&TEXTURE_SPHEREMAP\t\t\t\t\n\t\t\t\tglEnable GL_TEXTURE_GEN_S\n\t\t\t\tglEnable GL_TEXTURE_GEN_T\n\t\t\t\tglTexGeni GL_S,GL_TEXTURE_GEN_MODE,GL_SPHERE_MAP\n\t\t\t\tglTexGeni GL_T,GL_TEXTURE_GEN_MODE,GL_SPHERE_MAP\n\t\t\tElse\n\t\t\t\tglDisable GL_TEXTURE_GEN_S \n\t\t\t\tglDisable GL_TEXTURE_GEN_T\n\t\t\tEndIf\n\t\t\t\n\t\t\tSelect texture._blend\n\t\t\tCase BLEND_NONE glTexEnvf(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_REPLACE)\n\t\t\tCase BLEND_ALPHA \tglTexEnvf(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_MODULATE)\n\t\t\tCase BLEND_MULTIPLY glTexEnvf(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_MODULATE)\n\t\t\t'Case BLEND_MULTIPLY glTexEnvf(GL_TEXTURE_ENV,GL_COMBINE_RGB_EXT,GL_MODULATE)\n\t\t\tCase BLEND_ADD glTexEnvf(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_ADD)\n\t\t\tCase BLEND_DOT3\n\t\t\t\tglTexEnvf GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT\n\t\t\t\tglTexEnvf GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_DOT3_RGB_EXT\n\t\t\tCase BLEND_MULTIPLY2\n\t\t\t\tglTexEnvi(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_COMBINE)\n\t\t\t\tglTexEnvi(GL_TEXTURE_ENV,GL_COMBINE_RGB,GL_MODULATE)\n\t\t\t\tglTexEnvi(GL_TEXTURE_ENV,GL_RGB_SCALE,2.0)\n\t\t\tDefault glTexEnvf(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_MODULATE)\n\t\t\tEnd Select\t\t\t\n\t\tNext\t\n\t\t\n\t\tIf _shaderdriver _shaderdriver.Use(brush._shader,_currentdata)\t\n\tEnd Method\n\t\n\tMethod RenderSurface(resource:TSurfaceRes,brush:TBrush)\n\t\tLocal res:TGLSurfaceRes=TGLSurfaceRes(resource)\t\n\t\t\n\t\tFor Local i=0 To 7\n\t\t\tglClientActiveTextureARB GL_TEXTURE0+i\n\t\t\t\n\t\t\tLocal texture:TTexture=brush._texture[i]\n\t\t\tIf texture=Null \n\t\t\t\tglDisableClientState GL_TEXTURE_COORD_ARRAY\n\t\t\t\tContinue\n\t\t\tEndIf\n\t\t\t\n\t\t\tglEnableClientState GL_TEXTURE_COORD_ARRAY\n\t\t\tglBindBufferARB GL_ARRAY_BUFFER_ARB,res._vbo[4+texture._coords]\n\t\t\tglTexCoordPointer 2,GL_FLOAT,0,Null\n\t\tNext\n\t\t\n\t\tglBindBufferARB GL_ARRAY_BUFFER_ARB,res._vbo[0]\n\t\tglVertexPointer 3,GL_FLOAT,0,Null\n\t\t\n\t\tglBindBufferARB GL_ARRAY_BUFFER_ARB,res._vbo[1]\n\t\tglNormalPointer GL_FLOAT,0,Null\n\t\t\n\t\tglBindBufferARB GL_ARRAY_BUFFER_ARB,res._vbo[2]\n\t\tglColorPointer 4,GL_FLOAT,0,Null\n\t\n\t\tglBindBufferARB GL_ELEMENT_ARRAY_BUFFER_ARB,res._vbo[3]\n\t\tglDrawElements GL_TRIANGLES,res._trianglecnt*3,GL_UNSIGNED_INT,Null\n\t\t\n\t\tReturn res._trianglecnt\n\tEnd Method\n\t\n\tMethod BeginEntityRender(entity:TEntity)\t\t\n\t\tIf entity._order<>0\n\t\t\tglDisable GL_DEPTH_TEST\n\t\t\tglDepthMask GL_FALSE\n\t\tElse\n\t\t\tglEnable GL_DEPTH_TEST\n\t\t\tglDepthMask GL_TRUE\n\t\tEndIf\n\t\t\n\t\tglMatrixMode GL_MODELVIEW\n\t\tglPushMatrix\n\t\tglMultMatrixf entity.GetMatrix(True,False).ToPtr()\n\t\t\n\t\tGlobal matrix:TMatrix=New TMatrix\n\t\tglGetFloatv GL_MODELVIEW_MATRIX,matrix._m\n\t\t_currentdata._modelviewproj=matrix.Multiply(_currentdata._projection)\n\tEnd Method\n\tMethod EndEntityRender(entity:TEntity)\n\t\tglMatrixMode GL_MODELVIEW\n\t\tglPopMatrix\n\tEnd Method\n\t\n\tMethod RenderFlat(flat:TFlat)\n\t\tLocal x#,y#,z#\n\t\tflat.GetScale x,y,z,True\n\t\t\n\t\tglBegin GL_QUADS\n\t\t\tglNormal3f 0,1,0\n\t\t\tglTexCoord2f 0,0\n\t\t\tglVertex3f -1,0, 1\n\t\t\tglTexCoord2f x,0\t\n\t\t\tglVertex3f 1, 0, 1\n\t\t\tglTexCoord2f x,z\n\t\t\tglVertex3f 1, 0, -1\n\t\t\tglTexCoord2f 0,z\n\t\t\tglVertex3f -1,0, -1\n\t\tglEnd\n\t\tReturn 2\n\tEnd Method\n\t\n\tMethod RenderSprite(sprite:TSprite)\n\t\tIf False\n\t\t\tglPointParameterfvARB GL_POINT_DISTANCE_ATTENUATION_ARB, [0.0, 0.0, 1.0]\n\t\t\t\n\t\t\tglPointSize 1.0\n\t\t\t\n\t\t\tglPointParameterfARB GL_POINT_FADE_THRESHOLD_SIZE_ARB,60.0\n\t\t\tglPointParameterfARB GL_POINT_SIZE_MIN_ARB,0.0\n\t\t\tglPointParameterfARB GL_POINT_SIZE_MAX_ARB,9999.0\n\t\t\t\n\t\t\tglTexEnvf GL_POINT_SPRITE_ARB,GL_COORD_REPLACE_ARB,GL_TRUE\n\t\t\t\n\t\t\tglEnable GL_POINT_SPRITE_ARB\n\t\t\t\n\t\t\tglBegin GL_POINTS\t\t\t\n\t\t\tglVertex3f 0,0,0\n\t\t\tglEnd\n\t\t\t\n\t\t\tglDisable GL_POINT_SPRITE_ARB\n\t\tElse\n\t\t\tglBegin GL_QUADS\n\t\t\t\tglNormal3f 0,0,-1\n\t\t\t\tglTexCoord2f 0,1\n\t\t\t\tglVertex3f 1, -1, 0\t\t\t\n\t\t\t\tglTexCoord2f 0,0\n\t\t\t\tglVertex3f 1, 1, 0\t\t\t\n\t\t\t\tglTexCoord2f 1,0\n\t\t\t\tglVertex3f -1,1, 0\t\t\t\n\t\t\t\tglTexCoord2f 1,1\n\t\t\t\tglVertex3f -1,-1, 0\n\t\t\tglEnd\n\t\tEndIf\n\tEnd Method\n\t\n\tMethod RenderTerrain(terrain:TTerrain)\n\t\n\t\tglDisableClientState GL_TEXTURE_COORD_ARRAY\n\t\tFor Local i=0 To 7\n\t\t\tLocal texture:TTexture=terrain._brush._texture[i]\n\t\t\tIf texture=Null Continue\n\t\t\tglEnableClientState(GL_TEXTURE_COORD_ARRAY)\n\t\t\tglClientActiveTextureARB(GL_TEXTURE0+i)\n\t\t\tglTexCoordPointer(2,GL_FLOAT,20,terrain._data)\n\t\tNext\n\t\t\n\t\tglEnableClientState GL_VERTEX_ARRAY\n\t\tglDisableClientState GL_COLOR_ARRAY\n\t\tglDisableClientState GL_NORMAL_ARRAY\n\t\t\n\t\tglVertexPointer(3,GL_FLOAT, 20, terrain._data+2)\n\t\tglDrawArrays(GL_TRIANGLES, 0, 3*terrain._count)\n\t\t\n\t\tglEnableClientState GL_VERTEX_ARRAY\n\t\tglEnableClientState GL_COLOR_ARRAY \n\t\tglEnableClientState GL_NORMAL_ARRAY \n\tEnd Method\n\t\n\tMethod RenderBSPTree(tree:TBSPTree)\n\t\tLocal node:TBSPNode=tree.Node\n\t\tIf node=Null Return\n\t\tLocal triangles\n\t\ttriangles:+RenderBSPTree(node.In)\t\t\n\t\t\n\t\tFor Local poly:TBSPPolygon=EachIn node.On\n\t\t\tglBegin GL_POLYGON\n\t\t\tglNormal3f poly.Plane.x,poly.Plane.y,poly.Plane.z\n\t\t\tLocal ptA:TVector=poly.Point[0],v0\n\t\t\tFor Local i=1 To poly.Count()-2\n\t\t\t\tLocal ptB:TVector=poly.Point[i],ptC:TVector=poly.Point[i+1]\n\t\t\t\tglVertex3f ptA.x,ptA.y,ptA.z\n\t\t\t\tglVertex3f ptB.x,ptB.y,ptB.z\n\t\t\t\tglVertex3f ptC.x,ptC.y,ptC.z\n\t\t\tNext\n\t\t\ttriangles:+poly.Count()-2\n\t\t\tglEnd\n\t\tNext\t\n\t\t\n\t\ttriangles:+RenderBSPTree(node.Out)\n\t\tReturn triangles\n\tEnd Method\n\n\tMethod UpdateTextureRes:TGLTextureRes(frame:TTextureFrame,flags)\n\t\tIf frame=Null Return Null\n\t\t\n\t\tLocal glres:TGLTextureRes=TGLTextureRes(frame._res)\n\t\tIf glres=Null\n\t\t\tglres=New TGLTextureRes\n\t\t\tframe._res=glres\n\t\t\tframe._updateres=True\n\t\tEndIf\t\t\n\t\tIf Not frame._updateres Return glres\n\t\t\n\t\tIf glres._id=0 glGenTextures(1,Varptr glres._id)\n\t\tBindTexture 0,glres._id\n\t\tLocal pixmap:TPixmap=frame._pixmap\n\t\tgluBuild2DMipmaps(GL_TEXTURE_2D,GL_RGBA8,pixmap.width,pixmap.height,GL_BGRA,GL_UNSIGNED_BYTE,pixmap.pixels)\n\t\t\n\t\tframe._updateres=0\n\t\tReturn glres\n\tEnd Method\n\t\n\tMethod UpdateSurfaceRes:TGLSurfaceRes(surface:TSurface)\n\t\tLocal res:TGLSurfaceRes=TGLSurfaceRes(surface._res)\n\t\tIf res=Null res=New TGLSurfaceRes;surface._res=res\n\t\tIf surface._reset=0 Return res\n\t\t\n\t\tIf res._vbo[0]=0 glGenBuffersARB(4,res._vbo)\n\t\n\t\tIf surface._reset=-1 Then surface._reset=1|2|4|8|16|32|64|128|256\n\t\n\t\tIf surface._reset&1 UploadVertexBuffer res._vbo[0],surface._vertexpos\n\t\tIf surface._reset&2 UploadVertexNormals res._vbo[1],surface._vertexnml\n\t\tIf surface._reset&4 UploadVertexBuffer res._vbo[2],surface._vertexclr\n\t\tIf surface._reset&8\n\t\t\tglBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB,res._vbo[3])\n\t\t\tglBufferDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB,surface._triangle.length*4,surface._triangle,GL_STATIC_DRAW_ARB)\n\t\tEndIf\n\t\t\n\t\tFor Local i=0 To surface._vertextex.length-1\n\t\t\tIf res._vbo[4+i]=0 glGenBuffersARB(1,Varptr res._vbo[4+i])\n\t\t\tIf surface._reset&Int(2^(4+i)) UploadVertexBuffer res._vbo[4+i],surface._vertextex[i]\n\t\tNext\t\n\t\t\n\t\tres._trianglecnt=surface._trianglecnt\n\t\tres._vertexcnt=surface._vertexcnt\t\t\n\t\tsurface._reset=0\t\t\n\t\tReturn res\n\tEnd Method\n\t\n\tMethod MergeSurfaceRes:TGLSurfaceRes(base:TSurface,animation:TSurface,data)\n\t\tIf animation=Null Return UpdateSurfaceRes(base)\n\t\tLocal res_base:TGLSurfaceRes=UpdateSurfaceRes(base)\n\t\tLocal res_anim:TGLSurfaceRes=UpdateSurfaceRes(animation)\n\t\tLocal res:TGLSurfaceRes=res_base.Copy()\n\t\tres._vbo[0]=res_anim._vbo[0]\n\t\tReturn res\n\tEnd Method\n\t\n\tMethod UploadVertexBuffer(vbo,data#[])\n\t\tglBindBufferARB(GL_ARRAY_BUFFER_ARB,vbo)\n\t\tglBufferDataARB(GL_ARRAY_BUFFER_ARB,data.length*4,data,GL_STATIC_DRAW_ARB)\n\tEnd Method\n\t\n\tMethod UploadVertexNormals(vbo,data#[])\n\t\tglBindBufferARB(GL_ARRAY_BUFFER_ARB,vbo)\n\t\tglBufferDataARB(GL_ARRAY_BUFFER_ARB,data.length*4,data,GL_STATIC_DRAW_ARB)\n\tEnd Method\nEnd Type\n\nType TGLCaps Extends TCaps\n\tField Extensions$[]\n\t\n\tMethod HasExtension(ext$)\n\t\tFor Local extension$=EachIn Extensions\n\t\t\tIf extension.Find(ext)<>-1 Return True\n\t\tNext\n\t\tReturn False \n\tEnd Method\n\t\n\tMethod Copy:TGLCaps()\n\t\tLocal caps:TGLCaps=New TGLCaps\n\t\tcaps.CopyBase(Self)\n\t\tcaps.Extensions=Extensions[..]\n\t\tReturn caps\t\t\n\tEnd Method\nEnd Type\n\nType TGLSurfaceRes Extends TSurfaceRes\n\tField _vbo[12]\n\tField _texcoord\n\t\n\tMethod Copy:TGLSurfaceRes()\n\t\tLocal res:TGLSurfaceRes=New TGLSurfaceRes\n\t\tres._vertexcnt=_vertexcnt;res._trianglecnt=_trianglecnt\n\t\tres._vbo=_vbo[..]\n\t\tres._texcoord=_texcoord\n\t\tReturn res\n\tEnd Method\nEnd Type\n\nType TGLTextureRes Extends TTextureRes\n\tField _id\nEnd Type\n\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GLMaxB3DDriver:TGLMaxB3DDriver()\n\tIf GLMax2DExDriver()\n\t\tGlobal driver:TGLMaxB3DDriver=New TGLMaxB3DDriver\n\t\tdriver._parent=GLMax2DExDriver()\n\t\tReturn driver\n\tEnd If\nEnd Function\n\nRem\n\tbbdoc: Utility function that sets the MaxB3D GL driver and calls Graphics.\nEnd Rem\nFunction GLGraphics3D:TGraphics(width,height,depth=0,hertz=60,flags=0)\n\tSetGraphicsDriver GLMaxB3DDriver(),GRAPHICS_BACKBUFFER|GRAPHICS_DEPTHBUFFER\n\tReturn Graphics(width,height,depth,hertz,flags)\nEnd Function\n\nLocal driver:TGLMaxB3DDriver=GLMaxB3DDriver()\nIf driver SetGraphicsDriver driver,GRAPHICS_BACKBUFFER|GRAPHICS_DEPTHBUFFER\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"9c757f6c6f04372e7731606bd14c6eb64384385f","subject":"Added time delay to the main update loop (to match HTML5 mojo)","message":"Added time delay to the main update loop (to match HTML5 mojo)\n","repos":"swoolcock\/diddy,swoolcock\/diddy,swoolcock\/diddy,swoolcock\/diddy,swoolcock\/diddy","old_file":"monkeymax\/modules\/mojo\/native\/mojo.bmax.bmx","new_file":"monkeymax\/modules\/mojo\/native\/mojo.bmax.bmx","new_contents":"' ***** Start mojo.bmax.bmx ******\r\n\r\nGlobal app:gxtkApp\r\n\r\nType gxtkApp\r\n\tField ginput:gxtkInput\r\n\tField gaudio:gxtkAudio\r\n\tField ggraphics:gxtkGraphics\r\n\r\n\tField dead:Int=0\r\n\tField suspended:Int=0\r\n\tField vloading:Int=0\r\n\tField maxloading:Int=0\r\n\tField updateRate:Int=0\r\n\tField nextUpdate:Float=0\r\n\tField updatePeriod:Float=0\r\n\tField startMillis:Float=0\r\n\t\r\n\tMethod New()' gxtkApp()\r\n\t\tapp=Self\r\n\t\tggraphics=New gxtkGraphics\r\n\tEndMethod\r\n\t\r\n\tMethod Setup()\r\n\t\tginput=New gxtkInput\r\n\t\tgaudio=New gxtkAudio\r\n\r\n\t\tbb_input__1Set_1Input_1Device(ginput)\r\n\t\tbb_audio__1Set_1Audio_1Device(gaudio)\r\n\t\t\r\n\t\tstartMillis=BlitzMaxMillisecs()\r\n\t\t\r\n\t\tSetFrameRate( 0 )\r\n\t\t\r\n\t\tInvokeOnCreate()\r\n\t\tInvokeOnRender()\r\n\t\tUpdate()\r\n\tEndMethod\r\n\t\r\n\tMethod Update()\r\n\t\tWhile Not AppTerminate()\r\n\t\t\tIf Not updatePeriod return\r\n\t\t\tLocal updates:Int = 0\r\n\t\t\t\r\n\t\t\tRepeat\r\n\t\t\t\tnextUpdate:+updatePeriod\r\n\t\t\t\tInvokeOnUpdate()\r\n\t\t\t\tIf Not updatePeriod Then Exit\r\n\t\t\t\tIf nextUpdate>BlitzMaxMillisecs() Then Exit\r\n\t\t\t\tupdates:+1\r\n\t\t\t\tIf updates = 7 Then\r\n\t\t\t\t\tnextUpdate = BlitzMaxMillisecs()\r\n\t\t\t\t\tExit\r\n\t\t\t\tEndIf\r\n\t\t\tForever\r\n\t\t\tInvokeOnRender()\r\n\t\t\tLocal del:Int = nextUpdate - BlitzMaxMillisecs()\r\n\t\t\tIf del < 1 Then del = 1\r\n\t\t\tDelay(del)\r\n\t\tWend\r\n\tEndMethod\r\n\t\r\n\tMethod InvokeOnCreate()\r\n\t\tIf dead Return\r\n\t\tdead = 1\r\n\t\tOnCreate()\r\n\t\tdead = 0\r\n\tEndMethod\r\n\r\n\tMethod InvokeOnUpdate()\r\n\t\tIf dead Or suspended Or Not updateRate Or vloading Return\r\n\t\tOnUpdate()\r\n\tEndMethod\r\n\t\r\n\tMethod InvokeOnRender()\r\n\t\tIf dead Or suspended Return\r\n\t\tggraphics.BeginRender()\r\n\t\tIf vloading\r\n\t\t\tOnLoading()\r\n\t\tElse\r\n\t\t\tOnRender()\r\n\t\tEndIf\r\n\t\tggraphics.EndRender()\r\n\tEndMethod\r\n\t\r\n\t\r\n\tMethod SetFrameRate( fps:Int )\r\n\t\tIf fps\r\n\t\t\tupdatePeriod=1000.0\/fps\r\n\t\t\tnextUpdate=BlitzMaxMillisecs() +updatePeriod\r\n\t\tElse\r\n\t\t\tupdatePeriod=0\r\n\t\tEndIf\r\n\tEndMethod\r\n\r\n\tMethod LoadState:String()\r\n'\t\tvar file:SharedObject=SharedObject.getLocal( \"gxtkapp\" );\r\n'\t\tvar state:String=file.data.state;\r\n'\t\tfile.close();\r\n'\t\tif( state ) return state;\r\n\t\tReturn \"\"\r\n\tEndMethod\r\n\t\r\n\tMethod SaveState:Int( state:String )\r\n'\t\tvar file:SharedObject=SharedObject.getLocal( \"gxtkapp\" );\r\n'\t\tfile.data.state=state;\r\n'\t\tfile.close();\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod LoadString:String( path:String )\r\n\t\tpath = \"data\/\" + path\r\n\t\tReturn LoadText( path )\r\n\tEndMethod\r\n\t\r\n\t' ***** GXTK API *****\r\n\t\r\n\tMethod GraphicsDevice:gxtkGraphics()\r\n\t\tReturn ggraphics\r\n\tEndMethod\r\n\r\n\tMethod InputDevice:gxtkInput()\r\n\t\tReturn ginput\r\n\tEndMethod\r\n\r\n\tMethod AudioDevice:gxtkAudio()\r\n\t\tReturn gaudio\r\n\tEndMethod\r\n\r\n\tMethod SetUpdateRate:Int(hertz:Int)\r\n\t\tupdateRate = hertz\r\n\t\tIf Not vloading Then SetFrameRate(updateRate)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod MilliSecs:Int()\r\n\t\tReturn BlitzMaxMillisecs() - startMillis\r\n\tEndMethod\r\n\t\r\n\tMethod Loading:Int()\r\n\t\tReturn vloading\r\n\tEndMethod\r\n\r\n\tMethod OnCreate:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod OnUpdate:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod OnSuspend:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod OnResume:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod OnRender:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod OnLoading:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkGraphics\r\n\tField gmode:Int = 1\r\n\tField ix:Float=1,iy:Float,jx:Float,jy:Float=1,tx:Float,ty:Float\r\n\tField sx:Float=1,sy:Float=1,rot:Float=0\r\n\t\r\n\tMethod Mode:Int()\r\n\t\tReturn gmode\r\n\tEndMethod\r\n\t\r\n\tMethod Cls:Int(r:Int = 0, g:Int = 0, b:Int = 0)\r\n\t\tBlitzMaxCls(r, g, b)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawPoint:Int(x:Float, y:Float)\r\n\t\tLocal nx:Float = TransX(x,y)\r\n\t\tLocal ny:Float = TransY(x,y)\r\n\t\tPlot nx, ny\r\n\tEndMethod\r\n\t\r\n\tMethod LoadSurface:gxtkSurface(path:String)\r\n\t\tLocal image:TImage = LoadImage(\"data\/\"+path)\r\n\t\tIf image Then\r\n\t\t\tLocal gs:gxtkSurface = New gxtkSurface\r\n\t\t\tgs.setImage(image)\r\n\t\t\tReturn gs\r\n\t\tEndIf\r\n\t\tReturn Null\r\n\tEndMethod\r\n\t\r\n\tMethod BeginRender()\r\n\tEndMethod\r\n\t\r\n\tMethod EndRender()\r\n\t\tFlip\r\n\tEndMethod\r\n\t\r\n\tMethod SetColor:Int(r:Int, g:Int, b:Int)\r\n\t\tBlitzMaxSetColor(r, g, b)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod SetAlpha:Int(a:Float)\r\n\t\tBlitzMaxSetAlpha(a)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod SetBlend:Int(blend:Int)\r\n\t\tBlitzMaxSetBlend(blend)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod Width:Int()\r\n\t\tReturn GraphicsWidth()\r\n\tEndMethod\r\n\t\r\n\tMethod Height:Int()\r\n\t\tReturn GraphicsHeight()\r\n\tEndMethod\r\n\t\r\n\tMethod SetScissor:Int(x:Int, y:Int, w:Int, h:Int)\r\n\t\tSetViewport(x, y, w, h) ' NOT TESTED!\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod TransX:Float(x:Float, y:Float)\r\n\t\tReturn ix*x + jx*y + tx\r\n\tEndMethod\r\n\t\r\n\tMethod TransY:Float(x:Float, y:Float)\r\n\t\tReturn iy*x + jy*y + ty\r\n\tEndMethod\r\n\t\r\n\tMethod SetMatrix:Int(ix:Float,iy:Float,jx:Float,jy:Float,tx:Float,ty:Float)\r\n\t\tSelf.ix = ix ; Self.iy = iy\r\n\t\tSelf.jx = jx ; Self.jy = jy\r\n\t\tSelf.tx = tx ; Self.ty = ty\r\n\t\tsx = Sqr( (ix*ix) + (jx*jx) )\r\n\t\tsy = Sqr( (iy*iy) + (jy*jy) )\r\n\t\trot = -Atan2( jx, ix )\r\n\t\tSetTransform( rot, sx, sy )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawSurface:Int(surface:gxtkSurface,x:Float,y:Float)\r\n\t\tLocal nx:Float = TransX(x,y)\r\n\t\tLocal ny:Float = TransY(x,y)\r\n\t\tDrawImage(surface.image, nx, ny, 0)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawSurface2:Int(surface:gxtkSurface,x:Float,y:Float, srcx:Int, srcy:Int, srcw:Int, srch:Int )\r\n\t\tLocal nx:Float = TransX(x,y)\r\n\t\tLocal ny:Float = TransY(x,y)\r\n\t\tDrawSubImageRect(surface.image, nx, ny, srcw, srch, srcx, srcy, srcw, srch)\t\t\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawLine:Int( x1:Float,y1:Float,x2:Float,y2:Float )\r\n\t\tLocal nx1:Float = TransX(x1,y1)\r\n\t\tLocal ny1:Float = TransY(x1,y1)\r\n\t\tLocal nx2:Float = TransX(x2,y2)\r\n\t\tLocal ny2:Float = TransY(x2,y2)\r\n\t\t' Need to reset transform so that BlitzMax doesn't try to apply rotation\r\n\t\tSetTransform( 0, 1, 1 )\r\n\t\tBlitzMaxDrawLine(nx1, ny1, nx2, ny2)\r\n\t\tSetTransform( rot, sx, sy )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawOval:Int( x:Float, y:Float, w:Float, h:Float )\r\n\t\tLocal nx:Float = TransX(x,y)\r\n\t\tLocal ny:Float = TransY(x,y)\r\n\t\tBlitzMaxDrawOval(nx, ny, w, h)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawPoly:Int(vertices:Float[])\r\n\t\t' setting the origin to use the current rotation translation\r\n\t\tSetOrigin(TransX(0,0), TransY(0,0))\r\n\t\tBlitzMaxDrawPoly( vertices )\r\n\t\tSetOrigin(0, 0)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawRect:Int( x:Float, y:Float, w:Float, h:Float )\r\n\t\tLocal nx:Float = TransX(x,y)\r\n\t\tLocal ny:Float = TransY(x,y)\r\n\t\tBlitzMaxDrawRect(nx, ny, w, h)\r\n\t\tReturn 0\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkInput\r\n\tMethod MouseX:Float()\r\n\t\tReturn BRL.PolledInput.MouseX()\r\n\tEndMethod\r\n\r\n\tMethod MouseY:Float()\r\n\t\tReturn BRL.PolledInput.MouseY()\r\n\tEndMethod\r\n\t\r\n\tMethod KeyDown:Int( key:Int )\r\n\t\tif( key = 384 ) key = 1 ' change TOUCH0 to MOUSE_LMB\r\n\r\n\t\tIf( key >= 1 And key <= 3 )\r\n\t\t\tReturn BRL.PolledInput.MouseDown( key )\r\n\t\tEndIf\r\n\t\tIf key < 256\r\n\t\t\tReturn BRL.PolledInput.KeyDown( key )\r\n\t\tElse\r\n\t\t\tReturn 0\r\n\t\tEndIf\r\n\tEndMethod\r\n\r\n\tMethod KeyHit:Int( key:Int )\r\n\t\tif( key = 384 ) key = 1 ' change TOUCH0 to MOUSE_LMB\r\n\t\tIf( key >= 1 And key <= 3 )\r\n\t\t\tReturn BRL.PolledInput.MouseHit( key )\r\n\t\tEndIf\r\n\t\tIf key < 256\r\n\t\t\tReturn BRL.PolledInput.KeyHit( key )\r\n\t\tElse\r\n\t\t\tReturn 0\r\n\t\tEndIf\r\n\tEndMethod\r\n\r\n\tMethod GetChar:Int()\r\n\t\tReturn BRL.PolledInput.GetChar()\r\n\tEndMethod\r\n\r\n\tMethod JoyX:Int( index:Int )\r\n\t\tReturn Pub.FreeJoy.JoyX( index )\r\n\tEndMethod\r\n\r\n\tMethod JoyY:Int( index:Int )\r\n\t\tReturn Pub.FreeJoy.JoyY( index )\r\n\tEndMethod\r\n\r\n\tMethod JoyZ:Int( index:Int )\r\n\t\tReturn Pub.FreeJoy.JoyZ( index )\r\n\tEndMethod\r\n\r\n\tMethod TouchX:Float( index:Int )\r\n\t\tReturn BRL.PolledInput.MouseX()\r\n\tEndMethod\r\n\r\n\tMethod TouchY:Float( index:Int )\r\n\t\tReturn BRL.PolledInput.MouseY()\r\n\tEndMethod\r\n\t\r\n\tMethod AccelX:Int()\r\n\t\treturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod AccelY:Int()\r\n\t\treturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod AccelZ:Int()\r\n\t\treturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod SetKeyboardEnabled:Int( enabled:int )\r\n\t\tReturn 0\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkChannel\r\n\tField channel:TChannel\t' null then not playing\r\n\tField sample:gxtkSample\r\n\tField loops:int\r\n\t'Field transform:SoundTransform=new SoundTransform()\r\n\t'Field pausepos:Number\r\n\tField state:int\r\n\t\r\n\tMethod New()\r\n\t\tchannel = New TChannel\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkAudio\r\n\tField amusicState:Int = 0\r\n\tField channels:gxtkChannel[] = New gxtkChannel[33]\r\n\t\r\n\tMethod New()\r\n\t\tFor local i:Int = 0 To 33 - 1\r\n\t\t\tchannels[i] = New gxtkChannel\r\n\t\tNext\r\n\tEndMethod\r\n\t\r\n\tMethod MusicState:Int()\r\n'\t\tIf( musicState = 1 And music.isPlaying() = False )\r\n'\t\t\tmusicState = 0;\r\n'\t\tEndif\r\n\t\tReturn amusicState\r\n\tEndMethod\r\n\t\r\n\tMethod PlayMusic:Int( path:String, flags:Int )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod ChannelState:int( channel:int )\r\n\t\tReturn -1\r\n\tEndMethod\r\n\t\r\n\tMethod StopMusic()\r\n\tEndMethod\r\n\t\r\n\tMethod StopChannel( channel:Int )\r\n\tEndMethod\r\n\r\n\tMethod PlaySample( sound:gxtkSample, channel:Int, flags:Int )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\t\r\n\t\t'If chan.state <> 0 Then chan.channel.Stop() <-- this crashes after the first play!?\r\n\t\t\r\n\t\tchan.sample = sound\r\n\t\t'chan.loops = flags ? 0x7fffffff : 0;\r\n\t\t'chan.channel = sample.sound.play( 0,chan.loops,chan.transform );\r\n\t\t'chan.channel = sound\r\n\t\tchan.state=1\r\n\t\r\n\t\tPlaySound( sound.sound, chan.channel )\r\n\tEndMethod\r\n\r\n\tMethod SetPan( channel:Int, pan:Float )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tchan.channel.SetPan(pan)\r\n\tEndMethod\r\n\r\n\tMethod SetRate( channel:Int, rate:Float )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tchan.channel.SetRate(rate)\r\n\tEndMethod\r\n\r\n\tMethod PauseMusic:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod ResumeMusic:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod SetMusicVolume:Int( volume:Float )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod SetVolume:Int( channel:Int, volume:Float )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tchan.channel.SetVolume(volume)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod LoadSample:gxtkSample( path:String )\r\n\t\tLocal extension:String = ExtractExt( path)\r\n\t\tIf extension = \"ogg\" Or extension = \"wav\" Then\r\n\t\t\tLocal sound:TSound = LoadSound(\"data\/\"+path)\r\n\t\t\tIf sound Then\r\n\t\t\t\tLocal gs:gxtkSample = New gxtkSample\r\n\t\t\t\tgs.setSound(sound)\r\n\t\t\t\tReturn gs\r\n\t\t\tEndIf\r\n\t\tElse\r\n\t\t\tRuntimeError \"BlitzMax can only use ogg and wav file formats\"\r\n\t\tEndIf\r\n\t\tReturn Null\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkSample\r\n\tField sound:TSound\r\n\t\r\n\tMethod setSound(sound:TSound)\r\n\t\tSelf.sound = sound\r\n\tEndMethod\r\n\t\r\n\tMethod Discard()\r\n\t\tSelf.sound = null\r\n\tEndMethod\r\nEndType\r\n\r\nFunction BlitzMaxDrawPoly:Int(vertices:Float[])\r\n\tDrawPoly vertices\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxDrawRect:Int( x:Float, y:Float, w:Float, h:Float )\r\n\tDrawRect x, y, w, h\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxDrawOval:Int( x:Float, y:Float, w:Float, h:Float )\r\n\tDrawOval x, y, w, h\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxDrawLine:Int( x1:Float,y1:Float,x2:Float,y2:Float )\r\n\tDrawLine x1, y1, x2, y2\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxMillisecs:Int()\r\n\tReturn MilliSecs()\r\nEndFunction\r\n\r\nFunction BlitzMaxSetColor(r:Int, g:Int, b:Int)\r\n\tSetColor(r, g, b)\r\nEndFunction\r\n\r\nFunction BlitzMaxSetBlend(blend:Int)\r\n\tSelect blend\r\n\t\tCase 0\r\n\t\t\tSetBlend( ALPHABLEND )\r\n\t\tCase 1\r\n\t\t\tSetBlend( LIGHTBLEND )\r\n\tEnd Select\r\nEndFunction\r\n\r\nFunction BlitzMaxSetAlpha(a:Float)\r\n\tSetAlpha(a)\r\nEndFunction\r\n\r\nFunction BlitzMaxCls(r:Int = 0, g:Int = 0, b:Int = 0)\r\n\tSetClsColor(r, g, b)\r\n\tCls\r\nEndFunction\r\n\r\nType gxtkSurface\r\n\tField w:Int, h:Int\r\n\tField image:TImage\r\n\t\r\n\tMethod setImage(image:TImage)\r\n\t\tSelf.image = image\r\n\tEndMethod\r\n\t\r\n\tMethod Width:Int()\r\n\t\tReturn image.Width\r\n\tEndMethod\r\n\t\r\n\tMethod Height:Int()\r\n\t\tReturn image.Height\r\n\tEndMethod\r\n\t\r\n\tMethod Discard()\r\n\tEndMethod\r\nEndType\r\n\r\n' ***** End mojo.bmax.bmx ******\r\n\r\n","old_contents":"' ***** Start mojo.bmax.bmx ******\r\n\r\nGlobal app:gxtkApp\r\n\r\nType gxtkApp\r\n\tField ginput:gxtkInput\r\n\tField gaudio:gxtkAudio\r\n\tField ggraphics:gxtkGraphics\r\n\r\n\tField dead:Int=0\r\n\tField suspended:Int=0\r\n\tField vloading:Int=0\r\n\tField maxloading:Int=0\r\n\tField updateRate:Int=0\r\n\tField nextUpdate:Float=0\r\n\tField updatePeriod:Float=0\r\n\tField startMillis:Float=0\r\n\t\r\n\tMethod New()' gxtkApp()\r\n\t\tapp=Self\r\n\t\tggraphics=New gxtkGraphics\r\n\tEndMethod\r\n\t\r\n\tMethod Setup()\r\n\t\tginput=New gxtkInput\r\n\t\tgaudio=New gxtkAudio\r\n\r\n\t\tbb_input__1Set_1Input_1Device(ginput)\r\n\t\tbb_audio__1Set_1Audio_1Device(gaudio)\r\n\t\t\r\n\t\tstartMillis=BlitzMaxMillisecs()\r\n\t\t\r\n\t\tSetFrameRate( 0 )\r\n\t\t\r\n\t\tInvokeOnCreate()\r\n\t\tInvokeOnRender()\r\n\t\tUpdate()\r\n\tEndMethod\r\n\t\r\n\tMethod Update()\r\n\t\tWhile Not AppTerminate()\r\n\t\t\tLocal updates:Int = 0\r\n\t\t\t\r\n\t\t\tLocal cont:Int = 1\r\n\t\t\tWhile (cont)\r\n\t\t\t\tnextUpdate:+updatePeriod\r\n\t\t\t\tInvokeOnUpdate()\r\n\t\t\t\tIf Not updatePeriod Then cont = 0\r\n\t\t\t\tIf nextUpdate>BlitzMaxMillisecs() Then cont = 0\r\n\t\t\t\tupdates:+1\r\n\t\t\t\tIf updates = 7 Then\r\n\t\t\t\t\tnextUpdate = BlitzMaxMillisecs()\r\n\t\t\t\t\tcont = 0\r\n\t\t\t\tEndIf\r\n\t\t\tWend\r\n\t\t\tInvokeOnRender()\r\n\t\tWend\r\n\tEndMethod\r\n\t\r\n\tMethod InvokeOnCreate()\r\n\t\tIf dead Return\r\n\t\tdead = 1\r\n\t\tOnCreate()\r\n\t\tdead = 0\r\n\tEndMethod\r\n\r\n\tMethod InvokeOnUpdate()\r\n\t\tIf dead Or suspended Or Not updateRate Or vloading Return\r\n\t\tOnUpdate()\r\n\tEndMethod\r\n\t\r\n\tMethod InvokeOnRender()\r\n\t\tIf dead Or suspended Return\r\n\t\tggraphics.BeginRender()\r\n\t\tIf vloading\r\n\t\t\tOnLoading()\r\n\t\tElse\r\n\t\t\tOnRender()\r\n\t\tEndIf\r\n\t\tggraphics.EndRender()\r\n\tEndMethod\r\n\t\r\n\t\r\n\tMethod SetFrameRate( fps:Int )\r\n\t\tIf fps\r\n\t\t\tupdatePeriod=1000.0\/fps\r\n\t\t\tnextUpdate=BlitzMaxMillisecs() +updatePeriod\r\n\t\tElse\r\n\t\t\tupdatePeriod=0\r\n\t\tEndIf\r\n\tEndMethod\r\n\r\n\tMethod LoadState:String()\r\n'\t\tvar file:SharedObject=SharedObject.getLocal( \"gxtkapp\" );\r\n'\t\tvar state:String=file.data.state;\r\n'\t\tfile.close();\r\n'\t\tif( state ) return state;\r\n\t\tReturn \"\"\r\n\tEndMethod\r\n\t\r\n\tMethod SaveState:Int( state:String )\r\n'\t\tvar file:SharedObject=SharedObject.getLocal( \"gxtkapp\" );\r\n'\t\tfile.data.state=state;\r\n'\t\tfile.close();\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod LoadString:String( path:String )\r\n\t\tpath = \"data\/\" + path\r\n\t\tReturn LoadText( path )\r\n\tEndMethod\r\n\t\r\n\t' ***** GXTK API *****\r\n\t\r\n\tMethod GraphicsDevice:gxtkGraphics()\r\n\t\tReturn ggraphics\r\n\tEndMethod\r\n\r\n\tMethod InputDevice:gxtkInput()\r\n\t\tReturn ginput\r\n\tEndMethod\r\n\r\n\tMethod AudioDevice:gxtkAudio()\r\n\t\tReturn gaudio\r\n\tEndMethod\r\n\r\n\tMethod SetUpdateRate:Int(hertz:Int)\r\n\t\tupdateRate = hertz\r\n\t\tIf Not vloading Then SetFrameRate(updateRate)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod MilliSecs:Int()\r\n\t\tReturn BlitzMaxMillisecs() - startMillis\r\n\tEndMethod\r\n\t\r\n\tMethod Loading:Int()\r\n\t\tReturn vloading\r\n\tEndMethod\r\n\r\n\tMethod OnCreate:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod OnUpdate:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod OnSuspend:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod OnResume:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod OnRender:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod OnLoading:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkGraphics\r\n\tField gmode:Int = 1\r\n\tField ix:Float=1,iy:Float,jx:Float,jy:Float=1,tx:Float,ty:Float\r\n\tField sx:Float=1,sy:Float=1,rot:Float=0\r\n\t\r\n\tMethod Mode:Int()\r\n\t\tReturn gmode\r\n\tEndMethod\r\n\t\r\n\tMethod Cls:Int(r:Int = 0, g:Int = 0, b:Int = 0)\r\n\t\tBlitzMaxCls(r, g, b)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawPoint:Int(x:Float, y:Float)\r\n\t\tLocal nx:Float = TransX(x,y)\r\n\t\tLocal ny:Float = TransY(x,y)\r\n\t\tPlot nx, ny\r\n\tEndMethod\r\n\t\r\n\tMethod LoadSurface:gxtkSurface(path:String)\r\n\t\tLocal image:TImage = LoadImage(\"data\/\"+path)\r\n\t\tIf image Then\r\n\t\t\tLocal gs:gxtkSurface = New gxtkSurface\r\n\t\t\tgs.setImage(image)\r\n\t\t\tReturn gs\r\n\t\tEndIf\r\n\t\tReturn Null\r\n\tEndMethod\r\n\t\r\n\tMethod BeginRender()\r\n\tEndMethod\r\n\t\r\n\tMethod EndRender()\r\n\t\tFlip\r\n\tEndMethod\r\n\t\r\n\tMethod SetColor:Int(r:Int, g:Int, b:Int)\r\n\t\tBlitzMaxSetColor(r, g, b)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod SetAlpha:Int(a:Float)\r\n\t\tBlitzMaxSetAlpha(a)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod SetBlend:Int(blend:Int)\r\n\t\tBlitzMaxSetBlend(blend)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod Width:Int()\r\n\t\tReturn GraphicsWidth()\r\n\tEndMethod\r\n\t\r\n\tMethod Height:Int()\r\n\t\tReturn GraphicsHeight()\r\n\tEndMethod\r\n\t\r\n\tMethod SetScissor:Int(x:Int, y:Int, w:Int, h:Int)\r\n\t\tSetViewport(x, y, w, h) ' NOT TESTED!\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod TransX:Float(x:Float, y:Float)\r\n\t\tReturn ix*x + jx*y + tx\r\n\tEndMethod\r\n\t\r\n\tMethod TransY:Float(x:Float, y:Float)\r\n\t\tReturn iy*x + jy*y + ty\r\n\tEndMethod\r\n\t\r\n\tMethod SetMatrix:Int(ix:Float,iy:Float,jx:Float,jy:Float,tx:Float,ty:Float)\r\n\t\tSelf.ix = ix ; Self.iy = iy\r\n\t\tSelf.jx = jx ; Self.jy = jy\r\n\t\tSelf.tx = tx ; Self.ty = ty\r\n\t\tsx = Sqr( (ix*ix) + (jx*jx) )\r\n\t\tsy = Sqr( (iy*iy) + (jy*jy) )\r\n\t\trot = -Atan2( jx, ix )\r\n\t\tSetTransform( rot, sx, sy )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawSurface:Int(surface:gxtkSurface,x:Float,y:Float)\r\n\t\tLocal nx:Float = TransX(x,y)\r\n\t\tLocal ny:Float = TransY(x,y)\r\n\t\tDrawImage(surface.image, nx, ny, 0)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawSurface2:Int(surface:gxtkSurface,x:Float,y:Float, srcx:Int, srcy:Int, srcw:Int, srch:Int )\r\n\t\tLocal nx:Float = TransX(x,y)\r\n\t\tLocal ny:Float = TransY(x,y)\r\n\t\tDrawSubImageRect(surface.image, nx, ny, srcw, srch, srcx, srcy, srcw, srch)\t\t\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawLine:Int( x1:Float,y1:Float,x2:Float,y2:Float )\r\n\t\tLocal nx1:Float = TransX(x1,y1)\r\n\t\tLocal ny1:Float = TransY(x1,y1)\r\n\t\tLocal nx2:Float = TransX(x2,y2)\r\n\t\tLocal ny2:Float = TransY(x2,y2)\r\n\t\t' Need to reset transform so that BlitzMax doesn't try to apply rotation\r\n\t\tSetTransform( 0, 1, 1 )\r\n\t\tBlitzMaxDrawLine(nx1, ny1, nx2, ny2)\r\n\t\tSetTransform( rot, sx, sy )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawOval:Int( x:Float, y:Float, w:Float, h:Float )\r\n\t\tLocal nx:Float = TransX(x,y)\r\n\t\tLocal ny:Float = TransY(x,y)\r\n\t\tBlitzMaxDrawOval(nx, ny, w, h)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawPoly:Int(vertices:Float[])\r\n\t\t' setting the origin to use the current rotation translation\r\n\t\tSetOrigin(TransX(0,0), TransY(0,0))\r\n\t\tBlitzMaxDrawPoly( vertices )\r\n\t\tSetOrigin(0, 0)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawRect:Int( x:Float, y:Float, w:Float, h:Float )\r\n\t\tLocal nx:Float = TransX(x,y)\r\n\t\tLocal ny:Float = TransY(x,y)\r\n\t\tBlitzMaxDrawRect(nx, ny, w, h)\r\n\t\tReturn 0\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkInput\r\n\tMethod MouseX:Float()\r\n\t\tReturn BRL.PolledInput.MouseX()\r\n\tEndMethod\r\n\r\n\tMethod MouseY:Float()\r\n\t\tReturn BRL.PolledInput.MouseY()\r\n\tEndMethod\r\n\t\r\n\tMethod KeyDown:Int( key:Int )\r\n\t\tif( key = 384 ) key = 1 ' change TOUCH0 to MOUSE_LMB\r\n\r\n\t\tIf( key >= 1 And key <= 3 )\r\n\t\t\tReturn BRL.PolledInput.MouseDown( key )\r\n\t\tEndIf\r\n\t\tIf key < 256\r\n\t\t\tReturn BRL.PolledInput.KeyDown( key )\r\n\t\tElse\r\n\t\t\tReturn 0\r\n\t\tEndIf\r\n\tEndMethod\r\n\r\n\tMethod KeyHit:Int( key:Int )\r\n\t\tif( key = 384 ) key = 1 ' change TOUCH0 to MOUSE_LMB\r\n\t\tIf( key >= 1 And key <= 3 )\r\n\t\t\tReturn BRL.PolledInput.MouseHit( key )\r\n\t\tEndIf\r\n\t\tIf key < 256\r\n\t\t\tReturn BRL.PolledInput.KeyHit( key )\r\n\t\tElse\r\n\t\t\tReturn 0\r\n\t\tEndIf\r\n\tEndMethod\r\n\r\n\tMethod GetChar:Int()\r\n\t\tReturn BRL.PolledInput.GetChar()\r\n\tEndMethod\r\n\r\n\tMethod JoyX:Int( index:Int )\r\n\t\tReturn Pub.FreeJoy.JoyX( index )\r\n\tEndMethod\r\n\r\n\tMethod JoyY:Int( index:Int )\r\n\t\tReturn Pub.FreeJoy.JoyY( index )\r\n\tEndMethod\r\n\r\n\tMethod JoyZ:Int( index:Int )\r\n\t\tReturn Pub.FreeJoy.JoyZ( index )\r\n\tEndMethod\r\n\r\n\tMethod TouchX:Float( index:Int )\r\n\t\tReturn BRL.PolledInput.MouseX()\r\n\tEndMethod\r\n\r\n\tMethod TouchY:Float( index:Int )\r\n\t\tReturn BRL.PolledInput.MouseY()\r\n\tEndMethod\r\n\t\r\n\tMethod AccelX:Int()\r\n\t\treturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod AccelY:Int()\r\n\t\treturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod AccelZ:Int()\r\n\t\treturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod SetKeyboardEnabled:Int( enabled:int )\r\n\t\tReturn 0\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkChannel\r\n\tField channel:TChannel\t' null then not playing\r\n\tField sample:gxtkSample\r\n\tField loops:int\r\n\t'Field transform:SoundTransform=new SoundTransform()\r\n\t'Field pausepos:Number\r\n\tField state:int\r\n\t\r\n\tMethod New()\r\n\t\tchannel = New TChannel\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkAudio\r\n\tField amusicState:Int = 0\r\n\tField channels:gxtkChannel[] = New gxtkChannel[33]\r\n\t\r\n\tMethod New()\r\n\t\tFor local i:Int = 0 To 33 - 1\r\n\t\t\tchannels[i] = New gxtkChannel\r\n\t\tNext\r\n\tEndMethod\r\n\t\r\n\tMethod MusicState:Int()\r\n'\t\tIf( musicState = 1 And music.isPlaying() = False )\r\n'\t\t\tmusicState = 0;\r\n'\t\tEndif\r\n\t\tReturn amusicState\r\n\tEndMethod\r\n\t\r\n\tMethod PlayMusic:Int( path:String, flags:Int )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod ChannelState:int( channel:int )\r\n\t\tReturn -1\r\n\tEndMethod\r\n\t\r\n\tMethod StopMusic()\r\n\tEndMethod\r\n\t\r\n\tMethod StopChannel( channel:Int )\r\n\tEndMethod\r\n\r\n\tMethod PlaySample( sound:gxtkSample, channel:Int, flags:Int )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\t\r\n\t\t'If chan.state <> 0 Then chan.channel.Stop() <-- this crashes after the first play!?\r\n\t\t\r\n\t\tchan.sample = sound\r\n\t\t'chan.loops = flags ? 0x7fffffff : 0;\r\n\t\t'chan.channel = sample.sound.play( 0,chan.loops,chan.transform );\r\n\t\t'chan.channel = sound\r\n\t\tchan.state=1\r\n\t\r\n\t\tPlaySound( sound.sound, chan.channel )\r\n\tEndMethod\r\n\r\n\tMethod SetPan( channel:Int, pan:Float )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tchan.channel.SetPan(pan)\r\n\tEndMethod\r\n\r\n\tMethod SetRate( channel:Int, rate:Float )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tchan.channel.SetRate(rate)\r\n\tEndMethod\r\n\r\n\tMethod PauseMusic:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod ResumeMusic:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod SetMusicVolume:Int( volume:Float )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod SetVolume:Int( channel:Int, volume:Float )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tchan.channel.SetVolume(volume)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod LoadSample:gxtkSample( path:String )\r\n\t\tLocal extension:String = ExtractExt( path)\r\n\t\tIf extension = \"ogg\" Or extension = \"wav\" Then\r\n\t\t\tLocal sound:TSound = LoadSound(\"data\/\"+path)\r\n\t\t\tIf sound Then\r\n\t\t\t\tLocal gs:gxtkSample = New gxtkSample\r\n\t\t\t\tgs.setSound(sound)\r\n\t\t\t\tReturn gs\r\n\t\t\tEndIf\r\n\t\tElse\r\n\t\t\tRuntimeError \"BlitzMax can only use ogg and wav file formats\"\r\n\t\tEndIf\r\n\t\tReturn Null\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkSample\r\n\tField sound:TSound\r\n\t\r\n\tMethod setSound(sound:TSound)\r\n\t\tSelf.sound = sound\r\n\tEndMethod\r\n\t\r\n\tMethod Discard()\r\n\t\tSelf.sound = null\r\n\tEndMethod\r\nEndType\r\n\r\nFunction BlitzMaxDrawPoly:Int(vertices:Float[])\r\n\tDrawPoly vertices\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxDrawRect:Int( x:Float, y:Float, w:Float, h:Float )\r\n\tDrawRect x, y, w, h\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxDrawOval:Int( x:Float, y:Float, w:Float, h:Float )\r\n\tDrawOval x, y, w, h\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxDrawLine:Int( x1:Float,y1:Float,x2:Float,y2:Float )\r\n\tDrawLine x1, y1, x2, y2\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxMillisecs:Int()\r\n\tReturn MilliSecs()\r\nEndFunction\r\n\r\nFunction BlitzMaxSetColor(r:Int, g:Int, b:Int)\r\n\tSetColor(r, g, b)\r\nEndFunction\r\n\r\nFunction BlitzMaxSetBlend(blend:Int)\r\n\tSelect blend\r\n\t\tCase 0\r\n\t\t\tSetBlend( ALPHABLEND )\r\n\t\tCase 1\r\n\t\t\tSetBlend( LIGHTBLEND )\r\n\tEnd Select\r\nEndFunction\r\n\r\nFunction BlitzMaxSetAlpha(a:Float)\r\n\tSetAlpha(a)\r\nEndFunction\r\n\r\nFunction BlitzMaxCls(r:Int = 0, g:Int = 0, b:Int = 0)\r\n\tSetClsColor(r, g, b)\r\n\tCls\r\nEndFunction\r\n\r\nType gxtkSurface\r\n\tField w:Int, h:Int\r\n\tField image:TImage\r\n\t\r\n\tMethod setImage(image:TImage)\r\n\t\tSelf.image = image\r\n\tEndMethod\r\n\t\r\n\tMethod Width:Int()\r\n\t\tReturn image.Width\r\n\tEndMethod\r\n\t\r\n\tMethod Height:Int()\r\n\t\tReturn image.Height\r\n\tEndMethod\r\n\t\r\n\tMethod Discard()\r\n\tEndMethod\r\nEndType\r\n\r\n' ***** End mojo.bmax.bmx ******\r\n\r\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"d4c2d0c1f73f09ff2721c725426f4b04395157ae","subject":"Maximus bug test 2.","message":"Maximus bug test 2.\n","repos":"kfprimm\/maxb3d,kfprimm\/maxb3d","old_file":"monkeyheadloader.mod\/monkeyheadloader.bmx","new_file":"monkeyheadloader.mod\/monkeyheadloader.bmx","new_contents":"\nStrict\n\nRem\n\tbbdoc: Blenders Suzanne model loader.\nEnd Rem\nModule MaxB3D.MonkeyHeadLoader\n\nImport MaxB3D.Core\nImport \"data.c\"\n\nExtern\n\tFunction get_monkeyhead(verts:Float Ptr Var,normals:Float Ptr Var,tris:Short Ptr Var,vert_count Var,tri_count Var)\nEnd Extern\n\nType TMeshLoaderMONKEYHEAD Extends TMeshLoader\n\tMethod Run(mesh:TMesh,stream:TStream,url:Object)\n\t\tIf String(url)<>\"*monkeyhead*\" Return False\n\t\tGlobal surface:TSurface\n\t\tIf Not surface\n\t\t\tsurface=New TSurface\n\t\t\tLocal v:Float Ptr,n:Float Ptr,t:Short Ptr,vc,tc\n\t\t\tget_monkeyhead v,n,t,vc,tc\n\t\t\tsurface.Resize vc,tc\n\t\t\t\n\t\t\tFor Local i=0 To vc-1\n\t\t\t\tsurface.SetCoord i,v[i*3+0],v[i*3+1],v[i*3+2]\n\t\t\t\t'surface.SetNormal i,-n[i*3+0],-n[i*3+1],-n[i*3+2]\n\t\t\tNext\n\t\t\t\n\t\t\tFor Local i=0 To tc-1\n\t\t\t\tsurface.SetTriangle i,t[i*3+0],t[i*3+1],t[i*3+2]\n\t\t\tNext\n\t\tEndIf\n\t\tmesh.AppendSurface surface.Copy()\n\t\tReturn True\n\tEnd Method\n\t\n\tMethod Name$()\n\t\tReturn \"Suzanne\"\n\tEnd Method\n\tMethod ModuleName$()\n\t\tReturn \"monkeyheadloader\"\n\tEnd Method\nEnd Type\nNew TMeshLoaderMONKEYHEAD\n\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction CreateMonkeyHead:TMesh(parent:TEntity=Null)\n\tReturn _currentworld.AddMesh(\"*monkeyhead*\",parent)\nEnd Function\n","old_contents":"\nStrict\n\nRem\n\tbbdoc: Blender's Suzanne model loader.\nEnd Rem\nModule MaxB3D.MonkeyHeadLoader\n\nImport MaxB3D.Core\nImport \"data.c\"\n\nExtern\n\tFunction get_monkeyhead(verts:Float Ptr Var,normals:Float Ptr Var,tris:Short Ptr Var,vert_count Var,tri_count Var)\nEnd Extern\n\nType TMeshLoaderMONKEYHEAD Extends TMeshLoader\n\tMethod Run(mesh:TMesh,stream:TStream,url:Object)\n\t\tIf String(url)<>\"*monkeyhead*\" Return False\n\t\tGlobal surface:TSurface\n\t\tIf Not surface\n\t\t\tsurface=New TSurface\n\t\t\tLocal v:Float Ptr,n:Float Ptr,t:Short Ptr,vc,tc\n\t\t\tget_monkeyhead v,n,t,vc,tc\n\t\t\tsurface.Resize vc,tc\n\t\t\t\n\t\t\tFor Local i=0 To vc-1\n\t\t\t\tsurface.SetCoord i,v[i*3+0],v[i*3+1],v[i*3+2]\n\t\t\t\t'surface.SetNormal i,-n[i*3+0],-n[i*3+1],-n[i*3+2]\n\t\t\tNext\n\t\t\t\n\t\t\tFor Local i=0 To tc-1\n\t\t\t\tsurface.SetTriangle i,t[i*3+0],t[i*3+1],t[i*3+2]\n\t\t\tNext\n\t\tEndIf\n\t\tmesh.AppendSurface surface.Copy()\n\t\tReturn True\n\tEnd Method\n\t\n\tMethod Name$()\n\t\tReturn \"Suzanne\"\n\tEnd Method\n\tMethod ModuleName$()\n\t\tReturn \"monkeyheadloader\"\n\tEnd Method\nEnd Type\nNew TMeshLoaderMONKEYHEAD\n\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction CreateMonkeyHead:TMesh(parent:TEntity=Null)\n\tReturn _currentworld.AddMesh(\"*monkeyhead*\",parent)\nEnd Function\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"7c0180829879951f3495ed9ab757dd2b0d7dd023","subject":"Added version comparison and source archive fetching.","message":"Added version comparison and source archive fetching.\n","repos":"maximos\/maximus","old_file":"src\/module.bmx","new_file":"src\/module.bmx","new_contents":"\nRem\nCopyright (c) 2010 Tim Howard\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and\/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\nEnd Rem\n\nRem\n\tbbdoc: Maximus module base.\n\tabout: An abstract type for the similarities between module scopes and modules.\nEnd Rem\nType mxModuleBase Abstract\n\t\n\tField m_name:String, m_description:String\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the base's name.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetName(name:String)\n\t\tAssert name, \"(mxModuleBase.SetName) name cannot be Null!\"\n\t\tm_name = name\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the base's name.\n\t\treturns: The base's name.\n\tEnd Rem\n\tMethod GetName:String()\n\t\tReturn m_name\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the base's description.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetDescription(description:String)\n\t\tAssert description, \"(mxModuleBase.SetDescription) description cannot be Null!\"\n\t\tm_description = description\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the base's description.\n\t\treturns: The base's description.\n\tEnd Rem\n\tMethod GetDescription:String()\n\t\tReturn m_description\n\tEnd Method\n\t\n'#end region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set a common field from the given variable.\n\t\treturns: True if the given variable was handled, or False if it was not.\n\tEnd Rem\n\tMethod SetCommonFromVariable:Int(variable:dVariable)\n\t\tSelect variable.GetName().ToLower()\n\t\t\tCase \"desc\"\n\t\t\t\tSetDescription(variable.ValueAsString())\n\t\t\t\tReturn True\n\t\tEnd Select\n\t\tReturn False\n\tEnd Method\n\t\nEnd Type\n\nRem\n\tbbdoc: Maximus module scope.\nEnd Rem\nType mxModuleScope Extends mxModuleBase\n\t\n\tField m_modules:dObjectMap\n\t\n\tMethod New()\n\t\tm_modules = New dObjectMap\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Add the given module to the scope.\n\t\treturns: True if the module was added, or False if it was not (the module is Null).\n\tEnd Rem\n\tMethod AddModule:Int(modul:mxModule)\n\t\tIf modul <> Null\n\t\t\tm_modules._Insert(modul.GetName(), modul)\n\t\t\tmodul.SetParent(Self)\n\t\t\tReturn True\n\t\tEnd If\n\t\tReturn False\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Check if the given module name is found in the scope.\n\t\treturns: True if the given module was found in the scope, or False if it was not.\n\tEnd Rem\n\tMethod HasModule:Int(modname:String)\n\t\tReturn m_modules._Contains(modname)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get a module with the given name.\n\t\treturns: The module with the given name, or Null if there is no module with the given name.\n\tEnd Rem\n\tMethod GetModuleWithName:mxModule(modname:String)\n\t\tReturn mxModule(m_modules._ValueByKey(modname))\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Load the given dJObject into the scope.\n\t\treturns: Itself, or Null if @root is Null.\n\tEnd Rem\n\tMethod FromJSON:mxModuleScope(root:dJObject)\n\t\tIf root <> Null\n\t\t\tSetName(root.GetName())\n\t\t\tFor Local variable:dVariable = EachIn root.GetValues()\n\t\t\t\tIf dJObject(variable)\n\t\t\t\t\tAddModule(New mxModule.FromJSON(dJObject(variable)))\n\t\t\t\tElse\n\t\t\t\t\tSetCommonFromVariable(variable)\n\t\t\t\tEnd If\n\t\t\tNext\n\t\t\tReturn Self\n\t\tEnd If\n\t\tReturn Null\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the module enumerator for the scope.\n\t\treturns: The module enumerator for the scope.\n\tEnd Rem\n\tMethod ModuleEnumerator:TMapEnumerator()\n\t\tReturn m_modules.ValueEnumerator()\n\tEnd Method\n\t\nEnd Type\n\nRem\n\tbbdoc: Maximus module.\nEnd Rem\nType mxModule Extends mxModuleBase\n\t\n\tField m_parent:mxModuleScope\n\tField m_versions:dObjectMap\n\t\n\tMethod New()\n\t\tm_versions = New dObjectMap\n\tEnd Method\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the module's parent.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetParent(parent:mxModuleScope)\n\t\tm_parent = parent\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the module's parent.\n\t\treturns: The module's parent.\n\tEnd Rem\n\tMethod GetParent:mxModuleScope()\n\t\tReturn m_parent\n\tEnd Method\n\t\n'#end region Field accessors\n\t\n\tRem\n\t\tbbdoc: Add the given version to the module.\n\t\treturns: True if the version was added, or False if it was not (the version is Null).\n\tEnd Rem\n\tMethod AddVersion:Int(version:mxModuleVersion)\n\t\tIf version <> Null\n\t\t\tm_versions._Insert(version.GetName(), version)\n\t\t\tversion.SetParent(Self)\n\t\t\tReturn True\n\t\tEnd If\n\t\tReturn False\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Check if there is a version with the given name.\n\t\treturns: True if the version was found, or False if it was not.\n\tEnd Rem\n\tMethod HasVersion:Int(name:String)\n\t\tReturn m_versions._Contains(name)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get a version with the given name.\n\t\treturns: The version with the given name, or Null if there is no version with the given name.\n\tEnd Rem\n\tMethod GetVersionWithName:mxModuleVersion(name:String)\n\t\tReturn mxModuleVersion(m_versions._ValueByKey(name))\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the latest (non-dev) version for this module.\n\t\treturns: The latest version for this module.\n\tEnd Rem\n\tMethod GetLatestVersion:mxModuleVersion()\n\t\tLocal hver:mxModuleVersion\n\t\tFor Local ver:mxModuleVersion = EachIn VersionEnumerator()\n\t\t\tIf ver.GetName() <> \"dev\"\n\t\t\t\tIf hver = Null Or hver.Compare(ver) = 1\n\t\t\t\t\thver = ver\n\t\t\t\tEnd If\n\t\t\tEnd If\n\t\tNext\n\t\tReturn hver\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set a common field from the given variable.\n\t\treturns: True if the given variable was handled, or False if it was not.\n\tEnd Rem\n\tMethod SetCommonFromVariable:Int(variable:dVariable)\n\t\tIf Super.SetCommonFromVariable(variable) = True\n\t\t\tReturn True\n\t\tElse\n\t\t\tSelect variable.GetName().ToLower()\n\t\t\t\tCase \"versions\"\n\t\t\t\t\tFor Local jobj:dJObject = EachIn dJObject(variable).GetValues()\n\t\t\t\t\t\tAddVersion(New mxModuleVersion.FromJSON(jobj))\n\t\t\t\t\tNext\n\t\t\tEnd Select\n\t\t\tReturn False\n\t\tEnd If\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Load the given dJObject into the module.\n\t\treturns: Itself, or Null if @root is Null.\n\tEnd Rem\n\tMethod FromJSON:mxModule(root:dJObject)\n\t\tIf root <> Null\n\t\t\tSetName(root.GetName())\n\t\t\tFor Local variable:dVariable = EachIn root.GetValues()\n\t\t\t\tSetCommonFromVariable(variable)\n\t\t\tNext\n\t\t\tReturn Self\n\t\tEnd If\n\t\tReturn Null\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the version enumerator for the module.\n\t\treturns: The version enumerator for the module.\n\tEnd Rem\n\tMethod VersionEnumerator:TMapEnumerator()\n\t\tReturn m_versions.ValueEnumerator()\n\tEnd Method\n\t\nEnd Type\n\nRem\n\tbbdoc: Maximus module version.\nEnd Rem\nType mxModuleVersion\n\t\n\tField m_parent:mxModule\n\tField m_name:String, m_url:String\n\tField m_dependencies:mxModuleDependencies\n\t\n\tMethod New()\n\t\tm_dependencies = New mxModuleDependencies\n\tEnd Method\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the version's parent.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetParent(parent:mxModule)\n\t\tm_parent = parent\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the version's parent.\n\t\treturns: The version's parent.\n\tEnd Rem\n\tMethod GetParent:mxModule()\n\t\tReturn m_parent\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the version's name.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetName(name:String)\n\t\tAssert name, \"(mxModuleVersion.SetName) name cannot be Null!\"\n\t\tm_name = name\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the version's name.\n\t\treturns: The version's name.\n\tEnd Rem\n\tMethod GetName:String()\n\t\tReturn m_name\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the version's url.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetUrl(url:String)\n\t\tAssert url, \"(mxModuleVersion.SetUrl) url cannot be Null!\"\n\t\tm_url = url\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the version's url.\n\t\treturns: The version's url.\n\tEnd Rem\n\tMethod GetUrl:String()\n\t\tReturn m_url\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the temporary fetch path for the version's source archive.\n\t\treturns: The temporary file path for the version's source archive.\n\tEnd Rem\n\tMethod GetTemporaryFilePath:String()\n\t\tReturn \"tmp\/\" + StripDir(GetUrl())\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the version's dependencies.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetDependencies(dependencies:mxModuleDependencies)\n\t\tm_dependencies = dependencies\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the version's dependencies.\n\t\treturns: The version's dependencies.\n\tEnd Rem\n\tMethod GetDependencies:mxModuleDependencies()\n\t\tReturn m_dependencies\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the version parts for the version.\n\t\treturns: True if the version is development, in which case the parameters are both 0; or False, in which case the parameters are set accordingly.\n\tEnd Rem\n\tMethod GetVersionParts:Int(vmajor:String Var, vminor:String Var)\n\t\tIf m_name <> \"dev\"\n\t\t\tLocal i:Int = m_name.Find(\".\")\n\t\t\tIf i > -1\n\t\t\t\tvmajor = m_name[..i]\n\t\t\t\tvminor = m_name[i + 1..]\n\t\t\tElse\n\t\t\t\tvmajor = m_name ' I'm not sure what other version formats would be used, so I'm just playing a random card here\n\t\t\tEnd If\n\t\t\tReturn False\n\t\tEnd If\n\t\tReturn True\n\tEnd Method\n\t\n'#end region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set a common field from the given variable.\n\t\treturns: True if the given variable was handled, or False if it was not.\n\tEnd Rem\n\tMethod SetCommonFromVariable:Int(variable:dVariable)\n\t\tSelect variable.GetName().ToLower()\n\t\t\tCase \"url\"\n\t\t\t\tSetUrl(variable.ValueAsString())\n\t\t\tCase \"deps\"\n\t\t\t\tm_dependencies.FromJSON(dJArray(variable))\n\t\t\t\tReturn True\n\t\tEnd Select\n\t\tReturn False\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Load the given dJObject into the version.\n\t\treturns: Itself, or Null if @root is Null.\n\tEnd Rem\n\tMethod FromJSON:mxModuleVersion(root:dJObject)\n\t\tIf root <> Null\n\t\t\tSetName(root.GetName())\n\t\t\tFor Local variable:dVariable = EachIn root.GetValues()\n\t\t\t\tSetCommonFromVariable(variable)\n\t\t\tNext\n\t\t\tReturn Self\n\t\tEnd If\n\t\tReturn Null\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the dependency enumerator for the version.\n\t\treturns: The dependency enumerator for the version.\n\tEnd Rem\n\tMethod DependencyEnumerator:TMapEnumerator()\n\t\tReturn m_dependencies.DependencyEnumerator()\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Compare the version with the given version.\n\t\treturns: 0 if the two versions are the same (same in version number alone), 1 if this version is greater than the given, or -1 if the given version is greater than this version.\n\tEnd Rem\n\tMethod Compare:Int(with:Object)\n\t\tLocal ver:mxModuleVersion = mxModuleVersion(with)\n\t\tIf ver <> Null\n\t\t\tIf m_name = ver.m_name\n\t\t\t\tReturn 0\n\t\t\tElse\n\t\t\t\tLocal smajor:String, sminor:String, wmajor:String, wminor:String\n\t\t\t\tLocal sdev:Int = GetVersionParts(smajor, sminor), wdev:Int = ver.GetVersionParts(wmajor, wminor)\n\t\t\t\tIf (sdev = True And wdev = True) Or (smajor = wmajor And sminor = wminor)\n\t\t\t\t\tReturn 0\n\t\t\t\tElse If smajor > wmajor\n\t\t\t\t\tReturn 1\n\t\t\t\tElse If smajor = wmajor\n\t\t\t\t\tIf sminor > wminor\n\t\t\t\t\t\tReturn 1\n\t\t\t\t\tElse\n\t\t\t\t\t\tReturn -1\n\t\t\t\t\tEnd If\n\t\t\t\tElse\n\t\t\t\t\tReturn -1\n\t\t\t\tEnd If\n\t\t\tEnd If\n\t\tEnd If\n\t\tReturn 0\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Fetch the version's source archive.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod FetchSourceArchive()\n\t\tLocal file:String = GetTemporaryFilePath()\n\t\tlogger.LogMessage(\"fetching: \" + GetUrl() + \" -> \" + file + \"~t\", False)\n\t\tIf FileType(file) = FILETYPE_NONE\n\t\t\tLocal stream:TStream = WriteFileExplicitly(file)\n\t\t\tIf stream <> Null\n\t\t\t\tLocal request:TRESTRequest = New TRESTRequest, response:TRESTResponse\n\t\t\t\trequest.SetProgressCallback(_ProgressCallback, New _mxProgressStore)\n\t\t\t\trequest.SetStream(stream)\n\t\t\t\tTry\n\t\t\t\t\tresponse = request.Call(GetUrl(), Null, \"GET\")\n\t\t\t\tCatch e:Object\n\t\t\t\t\tstream.Close()\n\t\t\t\t\tDeleteFile(file)\n\t\t\t\t\tlogger.LogMessage(\"\")\n\t\t\t\t\tThrowError(_s(\"error.fetch.error\", [e.ToString()]))\n\t\t\t\tEnd Try\n\t\t\t\tstream.Close()\n\t\t\t\tIf response.responseCode = 200\n\t\t\t\t\tlogger.LogMessage(_s(\"message.fetch.done\", [String(response.responseCode)]))\n\t\t\t\tElse\n\t\t\t\t\tDeleteFile(file)\n\t\t\t\t\tlogger.LogMessage(\"\")\n\t\t\t\t\tThrowError(_s(\"error.fetch.error\", [\"Bad response code: \" + String(response.responseCode)]))\n\t\t\t\tEnd If\n\t\t\tElse\n\t\t\t\tThrowError(_s(\"error.writeperms\", [file]))\n\t\t\tEnd If\n\t\tElse\n\t\t\tlogger.LogMessage(_s(\"message.fetch.alreadyfetched\"))\n\t\tEnd If\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Progress callback for source archive fetching.\n\t\treturns: Zero (no error).\n\tEnd Rem\n\tFunction _ProgressCallback:Int(data:Object, dltotal:Double, dlnow:Double, ultotal:Double, ulnow:Double)\n\t\tLocal store:_mxProgressStore = _mxProgressStore(data)\n\t\tLocal prog:Int = (dlnow \/ dltotal) * 100\n\t\tIf prog > store.m_progress + 5\n\t\t\tstore.m_progress = prog\n\t\t\tWriteStdOut(\".\")\n\t\tEnd If\n\t\tReturn 0\n\tEnd Function\n\t\nEnd Type\n\nRem\n\tbbdoc: Maximus temporary progress storage for archive fetching.\nEnd Rem\nType _mxProgressStore\n\t\n\tField m_progress:Int = 0\n\t\nEnd Type\n\n","old_contents":"\nRem\nCopyright (c) 2010 Tim Howard\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and\/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\nEnd Rem\n\nRem\n\tbbdoc: Maximus module base.\n\tabout: An abstract type for the similarities between module scopes and modules.\nEnd Rem\nType mxModuleBase Abstract\n\t\n\tField m_name:String, m_description:String\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the base's name.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetName(name:String)\n\t\tAssert name, \"(mxModuleBase.SetName) name cannot be Null!\"\n\t\tm_name = name\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the base's name.\n\t\treturns: The base's name.\n\tEnd Rem\n\tMethod GetName:String()\n\t\tReturn m_name\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the base's description.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetDescription(description:String)\n\t\tAssert description, \"(mxModuleBase.SetDescription) description cannot be Null!\"\n\t\tm_description = description\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the base's description.\n\t\treturns: The base's description.\n\tEnd Rem\n\tMethod GetDescription:String()\n\t\tReturn m_description\n\tEnd Method\n\t\n'#end region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set a common field from the given variable.\n\t\treturns: True if the given variable was handled, or False if it was not.\n\tEnd Rem\n\tMethod SetCommonFromVariable:Int(variable:dVariable)\n\t\tSelect variable.GetName().ToLower()\n\t\t\tCase \"desc\"\n\t\t\t\tSetDescription(variable.ValueAsString())\n\t\t\t\tReturn True\n\t\tEnd Select\n\t\tReturn False\n\tEnd Method\n\t\nEnd Type\n\nRem\n\tbbdoc: Maximus module scope.\nEnd Rem\nType mxModuleScope Extends mxModuleBase\n\t\n\tField m_modules:dObjectMap\n\t\n\tMethod New()\n\t\tm_modules = New dObjectMap\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Add the given module to the scope.\n\t\treturns: True if the module was added, or False if it was not (the module is Null).\n\tEnd Rem\n\tMethod AddModule:Int(modul:mxModule)\n\t\tIf modul <> Null\n\t\t\tm_modules._Insert(modul.GetName(), modul)\n\t\t\tmodul.SetParent(Self)\n\t\t\tReturn True\n\t\tEnd If\n\t\tReturn False\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Check if the given module name is found in the scope.\n\t\treturns: True if the given module was found in the scope, or False if it was not.\n\tEnd Rem\n\tMethod HasModule:Int(modname:String)\n\t\tReturn m_modules._Contains(modname)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get a module with the given name.\n\t\treturns: The module with the given name, or Null if there is no module with the given name.\n\tEnd Rem\n\tMethod GetModuleWithName:mxModule(modname:String)\n\t\tReturn mxModule(m_modules._ValueByKey(modname))\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Load the given dJObject into the scope.\n\t\treturns: Itself, or Null if @root is Null.\n\tEnd Rem\n\tMethod FromJSON:mxModuleScope(root:dJObject)\n\t\tIf root <> Null\n\t\t\tSetName(root.GetName())\n\t\t\tFor Local variable:dVariable = EachIn root.GetValues()\n\t\t\t\tIf dJObject(variable)\n\t\t\t\t\tAddModule(New mxModule.FromJSON(dJObject(variable)))\n\t\t\t\tElse\n\t\t\t\t\tSetCommonFromVariable(variable)\n\t\t\t\tEnd If\n\t\t\tNext\n\t\t\tReturn Self\n\t\tEnd If\n\t\tReturn Null\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the module enumerator for the scope.\n\t\treturns: The module enumerator for the scope.\n\tEnd Rem\n\tMethod ModuleEnumerator:TMapEnumerator()\n\t\tReturn m_modules.ValueEnumerator()\n\tEnd Method\n\t\nEnd Type\n\nRem\n\tbbdoc: Maximus module.\nEnd Rem\nType mxModule Extends mxModuleBase\n\t\n\tField m_parent:mxModuleScope\n\tField m_versions:dObjectMap\n\t\n\tMethod New()\n\t\tm_versions = New dObjectMap\n\tEnd Method\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the module's parent.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetParent(parent:mxModuleScope)\n\t\tm_parent = parent\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the module's parent.\n\t\treturns: The module's parent.\n\tEnd Rem\n\tMethod GetParent:mxModuleScope()\n\t\tReturn m_parent\n\tEnd Method\n\t\n'#end region Field accessors\n\t\n\tRem\n\t\tbbdoc: Add the given version to the module.\n\t\treturns: True if the version was added, or False if it was not (the version is Null).\n\tEnd Rem\n\tMethod AddVersion:Int(version:mxModuleVersion)\n\t\tIf version <> Null\n\t\t\tm_versions._Insert(version.GetName(), version)\n\t\t\tversion.SetParent(Self)\n\t\t\tReturn True\n\t\tEnd If\n\t\tReturn False\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Check if there is a version with the given name.\n\t\treturns: True if the version was found, or False if it was not.\n\tEnd Rem\n\tMethod HasVersion:Int(name:String)\n\t\tReturn m_versions._Contains(name)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get a version with the given name.\n\t\treturns: The version with the given name, or Null if there is no version with the given name.\n\tEnd Rem\n\tMethod GetVersionWithName:mxModuleVersion(name:String)\n\t\tReturn mxModuleVersion(m_versions._ValueByKey(name))\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set a common field from the given variable.\n\t\treturns: True if the given variable was handled, or False if it was not.\n\tEnd Rem\n\tMethod SetCommonFromVariable:Int(variable:dVariable)\n\t\tIf Super.SetCommonFromVariable(variable) = True\n\t\t\tReturn True\n\t\tElse\n\t\t\tSelect variable.GetName().ToLower()\n\t\t\t\tCase \"versions\"\n\t\t\t\t\tFor Local jobj:dJObject = EachIn dJObject(variable).GetValues()\n\t\t\t\t\t\tAddVersion(New mxModuleVersion.FromJSON(jobj))\n\t\t\t\t\tNext\n\t\t\tEnd Select\n\t\t\tReturn False\n\t\tEnd If\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Load the given dJObject into the module.\n\t\treturns: Itself, or Null if @root is Null.\n\tEnd Rem\n\tMethod FromJSON:mxModule(root:dJObject)\n\t\tIf root <> Null\n\t\t\tSetName(root.GetName())\n\t\t\tFor Local variable:dVariable = EachIn root.GetValues()\n\t\t\t\tSetCommonFromVariable(variable)\n\t\t\tNext\n\t\t\tReturn Self\n\t\tEnd If\n\t\tReturn Null\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the version enumerator for the module.\n\t\treturns: The version enumerator for the module.\n\tEnd Rem\n\tMethod VersionEnumerator:TMapEnumerator()\n\t\tReturn m_versions.ValueEnumerator()\n\tEnd Method\n\t\nEnd Type\n\nRem\n\tbbdoc: Maximus module version.\nEnd Rem\nType mxModuleVersion\n\t\n\tField m_parent:mxModule\n\tField m_name:String, m_url:String\n\tField m_dependencies:mxModuleDependencies\n\t\n\tMethod New()\n\t\tm_dependencies = New mxModuleDependencies\n\tEnd Method\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the version's parent.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetParent(parent:mxModule)\n\t\tm_parent = parent\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the version's parent.\n\t\treturns: The version's parent.\n\tEnd Rem\n\tMethod GetParent:mxModule()\n\t\tReturn m_parent\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the version's name.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetName(name:String)\n\t\tAssert name, \"(mxModuleVersion.SetName) name cannot be Null!\"\n\t\tm_name = name\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the version's name.\n\t\treturns: The version's name.\n\tEnd Rem\n\tMethod GetName:String()\n\t\tReturn m_name\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the version's url.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetUrl(url:String)\n\t\tAssert url, \"(mxModuleVersion.SetUrl) url cannot be Null!\"\n\t\tm_url = url\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the version's url.\n\t\treturns: The version's url.\n\tEnd Rem\n\tMethod GetUrl:String()\n\t\tReturn m_url\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the version's dependencies.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetDependencies(dependencies:mxModuleDependencies)\n\t\tm_dependencies = dependencies\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the version's dependencies.\n\t\treturns: The version's dependencies.\n\tEnd Rem\n\tMethod GetDependencies:mxModuleDependencies()\n\t\tReturn m_dependencies\n\tEnd Method\n\t\n'#end region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set a common field from the given variable.\n\t\treturns: True if the given variable was handled, or False if it was not.\n\tEnd Rem\n\tMethod SetCommonFromVariable:Int(variable:dVariable)\n\t\tSelect variable.GetName().ToLower()\n\t\t\tCase \"url\"\n\t\t\t\tSetUrl(variable.ValueAsString())\n\t\t\tCase \"deps\"\n\t\t\t\tm_dependencies.FromJSON(dJArray(variable))\n\t\t\t\tReturn True\n\t\tEnd Select\n\t\tReturn False\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Load the given dJObject into the version.\n\t\treturns: Itself, or Null if @root is Null.\n\tEnd Rem\n\tMethod FromJSON:mxModuleVersion(root:dJObject)\n\t\tIf root <> Null\n\t\t\tSetName(root.GetName())\n\t\t\tFor Local variable:dVariable = EachIn root.GetValues()\n\t\t\t\tSetCommonFromVariable(variable)\n\t\t\tNext\n\t\t\tReturn Self\n\t\tEnd If\n\t\tReturn Null\n\tEnd Method\n\t\nEnd Type\n\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"19c3f6284c3bb67a69795d2a2d1de38c4432e1e4","subject":"BSP loader now accepts TBSPModels.","message":"BSP loader now accepts TBSPModels.\n","repos":"kfprimm\/maxb3d,kfprimm\/maxb3d","old_file":"bsploader.mod\/bsploader.bmx","new_file":"bsploader.mod\/bsploader.bmx","new_contents":"\nStrict\n\nRem\n\tbbdoc: Loads a TBSPTree into a mesh.\nEnd Rem\nModule MaxB3D.BSPLoader\nModuleInfo \"Author: Kevin Primm\"\nModuleInfo \"License: MIT\"\n\nImport MaxB3D.Core\nImport Prime.BSP\n\nType TMeshLoaderBSP Extends TMeshLoader\n\tMethod Run(config:TWorldConfig,mesh:TMesh,stream:TStream,url:Object)\n\t\tLocal tree:TBSPTree=TBSPTree(url)\n\t\tIf TBSPModel(url) tree = TBSPModel(url)._tree\n\t\tIf tree=Null Return False\n\t\t\n\t\tLocal surface:TSurface=mesh.AddSurface()\n\t\tAddTreeToSurface tree,surface\n\t\t\n\t\tReturn True\n\tEnd Method\n\t\n\tFunction AddTreeToSurface(tree:TBSPTree,surface:TSurface)\n\t\tLocal node:TBSPNode=tree.Node\n\t\tIf Not node Return \n\t\tFor Local poly:TBSPPolygon=EachIn node.On\n\t\t\tLocal ptA:TVector=poly.Point[0],v0\n\t\t\tv0=surface.AddVertex(ptA.x,ptA.y,ptA.z)\n\t\t\tFor Local i=1 To poly.Count()-2\n\t\t\t\tLocal ptB:TVector=poly.Point[i],ptC:TVector=poly.Point[i+1]\n\t\t\t\tLocal v1=surface.AddVertex(ptB.x,ptB.y,ptB.z)\n\t\t\t\tLocal v2=surface.AddVertex(ptC.x,ptC.y,ptC.z)\t\t\t\n\t\t\t\tLocal t=surface.AddTriangle(v0,v1,v2)\n\t\t\t\tsurface.SetTriangleNormal t,-poly.Plane.x,-poly.Plane.y,-poly.Plane.z\n\t\t\tNext\n\t\tNext\n\t\tAddTreeToSurface node.In,surface\n\t\tAddTreeToSurface node.Out,surface\n\tEnd Function\n\t\n\tMethod ModuleName$()\n\t\tReturn \"bsploader\"\n\tEnd Method\n\t\n\tMethod Info$()\n\t\tReturn \"BSP Tree|\"\n\tEnd Method\nEnd Type\nNew TMeshLoaderBSP\n","old_contents":"\nStrict\n\nRem\n\tbbdoc: Loads a TBSPTree into a mesh.\nEnd Rem\nModule MaxB3D.BSPLoader\nModuleInfo \"Author: Kevin Primm\"\nModuleInfo \"License: MIT\"\n\nImport MaxB3D.Core\nImport Prime.BSP\n\nType TMeshLoaderBSP Extends TMeshLoader\n\tMethod Run(config:TWorldConfig,mesh:TMesh,stream:TStream,url:Object)\n\t\tLocal tree:TBSPTree=TBSPTree(url)\n\t\tIf tree=Null Return False\n\t\t\n\t\tLocal surface:TSurface=mesh.AddSurface()\n\t\tAddTreeToSurface tree,surface\n\t\t\n\t\tReturn True\n\tEnd Method\n\t\n\tFunction AddTreeToSurface(tree:TBSPTree,surface:TSurface)\n\t\tLocal node:TBSPNode=tree.Node\n\t\tIf Not node Return \n\t\tFor Local poly:TBSPPolygon=EachIn node.On\n\t\t\tLocal ptA:TVector=poly.Point[0],v0\n\t\t\tv0=surface.AddVertex(ptA.x,ptA.y,ptA.z)\n\t\t\tFor Local i=1 To poly.Count()-2\n\t\t\t\tLocal ptB:TVector=poly.Point[i],ptC:TVector=poly.Point[i+1]\n\t\t\t\tLocal v1=surface.AddVertex(ptB.x,ptB.y,ptB.z)\n\t\t\t\tLocal v2=surface.AddVertex(ptC.x,ptC.y,ptC.z)\t\t\t\n\t\t\t\tLocal t=surface.AddTriangle(v0,v1,v2)\n\t\t\t\tsurface.SetTriangleNormal t,-poly.Plane.x,-poly.Plane.y,-poly.Plane.z\n\t\t\tNext\n\t\tNext\n\t\tAddTreeToSurface node.In,surface\n\t\tAddTreeToSurface node.Out,surface\n\tEnd Function\n\t\n\tMethod ModuleName$()\n\t\tReturn \"bsploader\"\n\tEnd Method\n\t\n\tMethod Info$()\n\t\tReturn \"BSP Tree|\"\n\tEnd Method\nEnd Type\nNew TMeshLoaderBSP\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"ca63779c407cf3634be00cbfa7c94158a1132d5d","subject":"Maximus would crash when listing a module that didn't have any versions","message":"Maximus would crash when listing a module that didn't have any versions\n","repos":"maximos\/maximus","old_file":"src\/impl\/list.bmx","new_file":"src\/impl\/list.bmx","new_contents":"\nRem\n\tbbdoc: Maximus 'list' argument implementation.\nEnd Rem\nType mxListImpl Extends dArgumentImplementation\n\t\n\tField m_queuemap:dObjectMap = New dObjectMap\n\t\n\tMethod New()\n\t\tinit([\"list\"])\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Check the current arguments for errors (according to the specific implementation).\n\t\treturns: Nothing.\n\t\tabout: This method will throw an error if the arguments are invalid.\n\tEnd Rem\n\tMethod CheckArgs()\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get a string describing the typical usage of the argument.\n\t\treturns: A string describing the typical usage of the argument.\n\tEnd Rem\n\tMethod GetUsage:String()\n\t\tReturn _s(\"arg.list.usage\")\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Execute the implementation's operation.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod Execute()\n\t\tm_queuemap.Clear()\n\t\tLocal nfounds:TListEx = New TListEx\n\t\tLocal sources:mxSourcesHandler = mainapp.m_sourceshandler\n\t\tIf sources\n\t\t\tIf sources.Count() > 0\n\t\t\t\tIf GetArgumentCount() > 0\n\t\t\t\t\tFor Local variable:dStringVariable = EachIn m_args\n\t\t\t\t\t\tLocal scope:mxModuleScope\n\t\t\t\t\t\tLocal arg:String = variable.Get()\n\t\t\t\t\t\tIf arg.Contains(\".\")\n\t\t\t\t\t\t\tscope = sources.GetScopeWithName(mxModUtils.GetScopeFromID(arg))\n\t\t\t\t\t\t\tIf scope\n\t\t\t\t\t\t\t\tLocal modul:mxModule = scope.GetModuleWithName(mxModUtils.GetNameFromID(arg))\n\t\t\t\t\t\t\t\tIf modul\n\t\t\t\t\t\t\t\t\tQueueModule(modul)\n\t\t\t\t\t\t\t\tElse\n\t\t\t\t\t\t\t\t\tnfounds.AddLast(arg)\n\t\t\t\t\t\t\t\tEnd If\n\t\t\t\t\t\t\tElse\n\t\t\t\t\t\t\t\tnfounds.AddLast(arg)\n\t\t\t\t\t\t\tEnd If\n\t\t\t\t\t\tElse\n\t\t\t\t\t\t\tscope = sources.GetScopeWithName(arg)\n\t\t\t\t\t\t\tIf scope\n\t\t\t\t\t\t\t\tQueueScope(scope)\n\t\t\t\t\t\t\tElse\n\t\t\t\t\t\t\t\tnfounds.AddLast(arg)\n\t\t\t\t\t\t\tEnd If\n\t\t\t\t\t\tEnd If\n\t\t\t\t\tNext\n\t\t\t\tElse\n\t\t\t\t\tFor Local modscope:mxModuleScope = EachIn sources.ValueEnumerator()\n\t\t\t\t\t\tQueueScope(modscope)\n\t\t\t\t\tNext\n\t\t\t\tEnd If\n\t\t\t\tReportQueue()\n\t\t\t\tIf nfounds.Count() > 0\n\t\t\t\t\tLocal a:String\n\t\t\t\t\tlogger.LogWarning(_s(\"arg.list.unfound\"))\n\t\t\t\t\tFor Local b:String = EachIn nfounds\n\t\t\t\t\t\ta:+ b + \" \"\n\t\t\t\t\tNext\n\t\t\t\t\ta = a[..a.Length - 1]\n\t\t\t\t\tlogger.LogMessage(\"~t\" + a)\n\t\t\t\tEnd If\n\t\t\tElse\n\t\t\t\tlogger.LogMessage(_s(\"arg.list.nosources\"))\n\t\t\tEnd If\n\t\tElse\n\t\t\tThrowError(_s(\"error.list.nosources\"))\n\t\tEnd If\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Queue the given module scope's modules for printing.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod QueueScope(modscope:mxModuleScope)\n\t\tIf modscope\n\t\t\tFor Local modul:mxModule = EachIn modscope.ModuleEnumerator()\n\t\t\t\tQueueModule(modul)\n\t\t\tNext\n\t\tEnd If\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Queue the given module for printing.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod QueueModule(modul:mxModule)\n\t\tIf modul\n\t\t\tm_queuemap._Insert(modul.GetName(), modul)\n\t\tEnd If\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Report the module queue.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod ReportQueue()\n\t\tLocal namelen:Int, verlen:Int, modul:mxModule, latest_version:mxModuleVersion\n\t\tLocal str:String\n\t\tFor modul = EachIn m_queuemap.ValueEnumerator()\n\t\t\tstr = modul.GetParent().GetName() + \".\" + modul.GetName()\n\t\t\tIf str.Length > namelen Then namelen = str.Length\n\t\t\tlatest_version:mxModuleVersion = modul.GetLatestVersion()\n\t\t\tIf latest_version Then str = latest_version.GetName()\n\t\t\tIf str.Length > verlen Then verlen = str.Length\n\t\tNext\n\t\tFor modul = EachIn m_queuemap.ValueEnumerator()\n\t\t\tlatest_version:mxModuleVersion = modul.GetLatestVersion()\n\t\t\tIf latest_version Then str = latest_version.GetName()\n\t\t\tIf str <> \"dev\" And modul.HasVersion(\"dev\") Then str:+ \" (has dev)\"\n\t\t\tlogger.LogMessage((modul.GetParent().GetName() + \".\" + modul.GetName())[..namelen] + \" - \" + str[..verlen] + \" - \" + modul.GetDescription())\n\t\tNext\n\tEnd Method\n\t\nEnd Type\n\n","old_contents":"\nRem\n\tbbdoc: Maximus 'list' argument implementation.\nEnd Rem\nType mxListImpl Extends dArgumentImplementation\n\t\n\tField m_queuemap:dObjectMap = New dObjectMap\n\t\n\tMethod New()\n\t\tinit([\"list\"])\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Check the current arguments for errors (according to the specific implementation).\n\t\treturns: Nothing.\n\t\tabout: This method will throw an error if the arguments are invalid.\n\tEnd Rem\n\tMethod CheckArgs()\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get a string describing the typical usage of the argument.\n\t\treturns: A string describing the typical usage of the argument.\n\tEnd Rem\n\tMethod GetUsage:String()\n\t\tReturn _s(\"arg.list.usage\")\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Execute the implementation's operation.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod Execute()\n\t\tm_queuemap.Clear()\n\t\tLocal nfounds:TListEx = New TListEx\n\t\tLocal sources:mxSourcesHandler = mainapp.m_sourceshandler\n\t\tIf sources\n\t\t\tIf sources.Count() > 0\n\t\t\t\tIf GetArgumentCount() > 0\n\t\t\t\t\tFor Local variable:dStringVariable = EachIn m_args\n\t\t\t\t\t\tLocal scope:mxModuleScope\n\t\t\t\t\t\tLocal arg:String = variable.Get()\n\t\t\t\t\t\tIf arg.Contains(\".\")\n\t\t\t\t\t\t\tscope = sources.GetScopeWithName(mxModUtils.GetScopeFromID(arg))\n\t\t\t\t\t\t\tIf scope\n\t\t\t\t\t\t\t\tLocal modul:mxModule = scope.GetModuleWithName(mxModUtils.GetNameFromID(arg))\n\t\t\t\t\t\t\t\tIf modul\n\t\t\t\t\t\t\t\t\tQueueModule(modul)\n\t\t\t\t\t\t\t\tElse\n\t\t\t\t\t\t\t\t\tnfounds.AddLast(arg)\n\t\t\t\t\t\t\t\tEnd If\n\t\t\t\t\t\t\tElse\n\t\t\t\t\t\t\t\tnfounds.AddLast(arg)\n\t\t\t\t\t\t\tEnd If\n\t\t\t\t\t\tElse\n\t\t\t\t\t\t\tscope = sources.GetScopeWithName(arg)\n\t\t\t\t\t\t\tIf scope\n\t\t\t\t\t\t\t\tQueueScope(scope)\n\t\t\t\t\t\t\tElse\n\t\t\t\t\t\t\t\tnfounds.AddLast(arg)\n\t\t\t\t\t\t\tEnd If\n\t\t\t\t\t\tEnd If\n\t\t\t\t\tNext\n\t\t\t\tElse\n\t\t\t\t\tFor Local modscope:mxModuleScope = EachIn sources.ValueEnumerator()\n\t\t\t\t\t\tQueueScope(modscope)\n\t\t\t\t\tNext\n\t\t\t\tEnd If\n\t\t\t\tReportQueue()\n\t\t\t\tIf nfounds.Count() > 0\n\t\t\t\t\tLocal a:String\n\t\t\t\t\tlogger.LogWarning(_s(\"arg.list.unfound\"))\n\t\t\t\t\tFor Local b:String = EachIn nfounds\n\t\t\t\t\t\ta:+ b + \" \"\n\t\t\t\t\tNext\n\t\t\t\t\ta = a[..a.Length - 1]\n\t\t\t\t\tlogger.LogMessage(\"~t\" + a)\n\t\t\t\tEnd If\n\t\t\tElse\n\t\t\t\tlogger.LogMessage(_s(\"arg.list.nosources\"))\n\t\t\tEnd If\n\t\tElse\n\t\t\tThrowError(_s(\"error.list.nosources\"))\n\t\tEnd If\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Queue the given module scope's modules for printing.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod QueueScope(modscope:mxModuleScope)\n\t\tIf modscope\n\t\t\tFor Local modul:mxModule = EachIn modscope.ModuleEnumerator()\n\t\t\t\tQueueModule(modul)\n\t\t\tNext\n\t\tEnd If\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Queue the given module for printing.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod QueueModule(modul:mxModule)\n\t\tIf modul\n\t\t\tm_queuemap._Insert(modul.GetName(), modul)\n\t\tEnd If\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Report the module queue.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod ReportQueue()\n\t\tLocal namelen:Int, verlen:Int, modul:mxModule\n\t\tLocal str:String\n\t\tFor modul = EachIn m_queuemap.ValueEnumerator()\n\t\t\tstr = modul.GetParent().GetName() + \".\" + modul.GetName()\n\t\t\tIf str.Length > namelen Then namelen = str.Length\n\t\t\tstr = modul.GetLatestVersion().GetName()\n\t\t\tIf str <> \"dev\" And modul.HasVersion(\"dev\") Then str:+ \" (has dev)\"\n\t\t\tIf str.Length > verlen Then verlen = str.Length\n\t\tNext\n\t\tFor modul = EachIn m_queuemap.ValueEnumerator()\n\t\t\tstr = modul.GetLatestVersion().GetName()\n\t\t\tIf str <> \"dev\" And modul.HasVersion(\"dev\") Then str:+ \" (has dev)\"\n\t\t\tlogger.LogMessage((modul.GetParent().GetName() + \".\" + modul.GetName())[..namelen] + \" - \" + str[..verlen] + \" - \" + modul.GetDescription())\n\t\tNext\n\tEnd Method\n\t\nEnd Type\n\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"91c18f816a3ed745dd0f7989c36f5dd20c6ec708","subject":"Added an auxiliary method to the LuGI core to bind glue functions to types (so you don't have to call p_lugi_register_method yourself).","message":"Added an auxiliary method to the LuGI core to bind glue functions to types (so you don't have to call p_lugi_register_method yourself).","repos":"nilium\/lugi.mod,nilium\/lugi.mod","old_file":"core.mod\/core.bmx","new_file":"core.mod\/core.bmx","new_contents":"Rem\n\tLuGI - Copyright (c) 2009 Noel R. Cower\n\n\tPermission is hereby granted, free of charge, to any person obtaining a copy\n\tof this software and associated documentation files (the \"Software\"), to deal\n\tin the Software without restriction, including without limitation the rights\n\tto use, copy, modify, merge, publish, distribute, sublicense, and\/or sell\n\tcopies of the Software, and to permit persons to whom the Software is\n\tfurnished to do so, subject to the following conditions:\n\n\tThe above copyright notice and this permission notice shall be included in\n\tall copies or substantial portions of the Software.\n\n\tTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n\tIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n\tFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n\tAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n\tLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n\tOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n\tTHE SOFTWARE.\nEndRem\n\nSuperStrict\n\nModule LuGI.Core\n\nModuleInfo \"Name: LuGI Core\"\nModuleInfo \"Description: Core API provided by LuGI to interact with BMax objects via Lua\"\nModuleInfo \"Version: 0.8.02\"\nModuleInfo \"Author: Noel Cower\"\nModuleInfo \"License: MIT\"\nModuleInfo \"URL:
http:\/\/github.com\/nilium\/lugi.mod\/<\/a>\"\n\n?Threaded\nImport Brl.Threads\n?\nImport Brl.Reflection\nImport Brl.LinkedList\nImport Pub.Lua\nImport \"lgcore.cpp\"\n\nPublic\n\n' LuGI field types - used by LuGI to determine how to access fields at runtime\n' The only reason these are public is because the generated code uses them, otherwise I'd hide\n' them away too. But then if I hide them and use number constants in the generated code, we'll\n' get the chance that changing these later will break existing glue code, and doing that is bad.\nConst LUGI_BYTEFIELD:Int = $0001\nConst LUGI_SHORTFIELD:Int = $0002\nConst LUGI_INTFIELD:Int = $0004\nConst LUGI_FLOATFIELD:Int = $0008\nConst LUGI_LONGFIELD:Int = $0010\nConst LUGI_DOUBLEFIELD:Int = $0020\nConst LUGI_STRINGFIELD:Int = $0040\nConst LUGI_OBJECTFIELD:Int = $0080\nConst LUGI_ARRAYFIELD:Int = $0100\n' Optional flag to specify that an integer field (Int, Short, Byte, or Long) should be treated as a\n' boolean value when passed to Lua\nConst LUGI_BOOLFIELDOPT:Int = $8000\n\nType LuGIInitFunction\n\t\n\t' Registers the callback provided as a pre-init stage routine\n\tMethod PreInit:LuGIInitFunction(cb(vm:Byte Ptr, rfield(off%, typ%, name$, clas@ Ptr), rmethod(fn:Int(state@ Ptr), name$, clas@ Ptr)), requiresState%=True)\n\t\t_cb = cb\n\t\t_reqState = requiresState\n\t\t?Threaded\n\t\tp_lugi_initlock.Lock()\n\t\t?\n\t\tIf p_lugi_preinit_cb = Null Then\n\t\t\tp_lugi_preinit_cb = New TList\n\t\tEndIf\n\t\tp_lugi_preinit_cb.AddLast(Self)\n\t\t?Threaded\n\t\tp_lugi_initlock.Unlock()\n\t\t?\n\t\tReturn Self\n\tEnd Method\n\t\n\t' Registers the callback provided as a post-init stage routine\n\tMethod PostInit:LuGIInitFunction(cb(state:Byte Ptr, constructor:Int(state:Byte Ptr)))\n\t\t_cb = cb\n\t\t?Threaded\n\t\tp_lugi_initlock.Lock()\n\t\t?\n\t\tIf p_lugi_postinit_cb = Null Then\n\t\t\tp_lugi_postinit_cb = New TList\n\t\tEndIf\n\t\tp_lugi_postinit_cb.AddLast(Self)\n\t\t?Threaded\n\t\tp_lugi_initlock.Unlock()\n\t\t?\n\t\tReturn Self\n\tEnd Method\n\t\n\t' #region PRIVATE\n\t\n\tField _cb:Byte Ptr\n\tField _reqState:Int\n\t\n\tMethod Pre(vm:Byte Ptr, rfield(off%, typ%, name$, clas@ Ptr), rmethod(fn:Int(state@ Ptr), name$, clas@ Ptr))\n\t\tLocal cb(vm:Byte Ptr, rfield(off%, typ%, name$, clas@ Ptr), rmethod(fn:Int(state@ Ptr), name$, clas@ Ptr)) = _cb\n\t\tIf Not _reqState Then\n\t\t p_lugi_preinit_cb.Remove(Self)\n\t\t cb(Null, rfield, rmethod) ' No VM is passed, since it's not required\n\t\tElse\n \t\tcb(vm, rfield, rmethod)\n \tEndIf\n\tEnd Method\n\t\n\tMethod Post(vm:Byte Ptr, constructor:Int(state:Byte Ptr))\n\t\tLocal cb(vm:Byte Ptr, constructor:Int(state:Byte Ptr)) = _cb\n\t\tcb(vm, constructor)\n\tEnd Method\n\t\n\t' #endregion\n\t\nEnd Type\n\nPrivate\n\n' There is really no good way to do this in a thread-safe manner, so the best I can do is to make\n' all access to the initialization lists a critical section\n?Threaded\nGlobal p_lugi_initlock:TMutex = TMutex.Create()\n?\nGlobal p_lugi_preinit_cb:TList\nGlobal p_lugi_postinit_cb:TList\n\n' Executes init functions that are to occur prior to creation of any BMax objects, VMTs, etc.\n' Doesn't lock the lists since it's only supposed to be called after the lists have been locked\nFunction PreInitLuGI(vm@ Ptr)\n\tIf Not p_lugi_preinit_cb Then\n\t\tReturn\n\tEndIf\n\tFor Local cb:LuGIInitFunction = EachIn p_lugi_preinit_cb\n\t\tcb.Pre(vm, p_lugi_register_field, p_lugi_register_method)\n\tNext\nEnd Function\n\n' Executes init functions that are to occur following the creation of BMax VMTs, metatables, cache, etc.\n' Doesn't lock the lists since it's only supposed to be called after the lists have been locked\nFunction PostInitLuGI(vm@ Ptr)\n\tIf Not p_lugi_postinit_cb Then\n\t\tReturn\n\tEndIf\n\tFor Local cb:LuGIInitFunction = EachIn p_lugi_postinit_cb\n\t\tcb.Post(vm, p_lugi_new_object)\n\tNext\nEnd Function\n\n' Private\/internal code that shouldn't be directly accessed (only provided)\nExtern \"C\"\n\tFunction p_lugi_register_method(fn:Int(state@ Ptr), name$, clas@ Ptr=Null)\n\tFunction p_lugi_register_field(off%, typ%, name$, clas@ Ptr)\n\t\n\tFunction p_lugi_init(state@ Ptr)\n\t\n\t' Constructor object - push with BBClass for type as upvalue\n\tFunction p_lugi_new_object:Int(state@ Ptr)\nEnd Extern\n\nPublic\n\nExtern \"C\"\n\t' Determining if an object on the stack is a BMax object\n\tFunction lua_isbmaxobject:Int(state@ Ptr, index:Int)\n\t\n\t' Pushing\/getting BBObjects (BBObjects, BBStrings, and BBArrays to tables\/tables to BBArrays respectively)\n\tFunction lua_pushbmaxobject(state@ Ptr, obj:Object)\n\tFunction lua_tobmaxobject:Object(state@ Ptr, index:Int)\n\t\n\t' Pushing\/getting BBArrays (BBArrays to tables\/tables to BBArrays respectively)\n\t' @arr has to be treated as an Object in BMax since passing an Int[] as an Object[] doesn't work\n\tFunction lua_pushbmaxarray(state@ Ptr, arr:Object)\n\tFunction lua_tobmaxarray:Object(state@ Ptr, index:Int)\nEnd Extern\n\n' Initializes the Lua state for use with BMax objects via LuGI\nFunction InitLuGI(vm:Byte Ptr)\n\t?Threaded\n\tp_lugi_initlock.Lock()\n\t?\n\tPreInitLuGI(vm)\n\tp_lugi_init(vm)\n\tPostInitLuGI(vm)\n\t?Threaded\n\tp_lugi_initlock.Unlock()\n\t?\nEnd Function\n\nFunction BindFunctionToType(fn:Int(L@Ptr), as$, typ:TTypeID)\n\tp_lugi_register_method(fn, as, Byte Ptr(typ._class))\nEnd Function\n","old_contents":"Rem\n\tLuGI - Copyright (c) 2009 Noel R. Cower\n\n\tPermission is hereby granted, free of charge, to any person obtaining a copy\n\tof this software and associated documentation files (the \"Software\"), to deal\n\tin the Software without restriction, including without limitation the rights\n\tto use, copy, modify, merge, publish, distribute, sublicense, and\/or sell\n\tcopies of the Software, and to permit persons to whom the Software is\n\tfurnished to do so, subject to the following conditions:\n\n\tThe above copyright notice and this permission notice shall be included in\n\tall copies or substantial portions of the Software.\n\n\tTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n\tIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n\tFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n\tAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n\tLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n\tOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n\tTHE SOFTWARE.\nEndRem\n\nSuperStrict\n\nModule LuGI.Core\n\nModuleInfo \"Name: LuGI Core\"\nModuleInfo \"Description: Core API provided by LuGI to interact with BMax objects via Lua\"\nModuleInfo \"Version: 0.8.02\"\nModuleInfo \"Author: Noel Cower\"\nModuleInfo \"License: MIT\"\nModuleInfo \"URL: http:\/\/github.com\/nilium\/lugi.mod\/<\/a>\"\n\n?Threaded\nImport Brl.Threads\n?\nImport Brl.Reflection\nImport Brl.LinkedList\nImport Pub.Lua\nImport \"lgcore.cpp\"\n\nPublic\n\n' LuGI field types - used by LuGI to determine how to access fields at runtime\n' The only reason these are public is because the generated code uses them, otherwise I'd hide\n' them away too. But then if I hide them and use number constants in the generated code, we'll\n' get the chance that changing these later will break existing glue code, and doing that is bad.\nConst LUGI_BYTEFIELD:Int = $0001\nConst LUGI_SHORTFIELD:Int = $0002\nConst LUGI_INTFIELD:Int = $0004\nConst LUGI_FLOATFIELD:Int = $0008\nConst LUGI_LONGFIELD:Int = $0010\nConst LUGI_DOUBLEFIELD:Int = $0020\nConst LUGI_STRINGFIELD:Int = $0040\nConst LUGI_OBJECTFIELD:Int = $0080\nConst LUGI_ARRAYFIELD:Int = $0100\n' Optional flag to specify that an integer field (Int, Short, Byte, or Long) should be treated as a\n' boolean value when passed to Lua\nConst LUGI_BOOLFIELDOPT:Int = $8000\n\nType LuGIInitFunction\n\t\n\t' Registers the callback provided as a pre-init stage routine\n\tMethod PreInit:LuGIInitFunction(cb(vm:Byte Ptr, rfield(off%, typ%, name$, clas@ Ptr), rmethod(fn:Int(state@ Ptr), name$, clas@ Ptr)), requiresState%=True)\n\t\t_cb = cb\n\t\t_reqState = requiresState\n\t\t?Threaded\n\t\tp_lugi_initlock.Lock()\n\t\t?\n\t\tIf p_lugi_preinit_cb = Null Then\n\t\t\tp_lugi_preinit_cb = New TList\n\t\tEndIf\n\t\tp_lugi_preinit_cb.AddLast(Self)\n\t\t?Threaded\n\t\tp_lugi_initlock.Unlock()\n\t\t?\n\t\tReturn Self\n\tEnd Method\n\t\n\t' Registers the callback provided as a post-init stage routine\n\tMethod PostInit:LuGIInitFunction(cb(state:Byte Ptr, constructor:Int(state:Byte Ptr)))\n\t\t_cb = cb\n\t\t?Threaded\n\t\tp_lugi_initlock.Lock()\n\t\t?\n\t\tIf p_lugi_postinit_cb = Null Then\n\t\t\tp_lugi_postinit_cb = New TList\n\t\tEndIf\n\t\tp_lugi_postinit_cb.AddLast(Self)\n\t\t?Threaded\n\t\tp_lugi_initlock.Unlock()\n\t\t?\n\t\tReturn Self\n\tEnd Method\n\t\n\t' #region PRIVATE\n\t\n\tField _cb:Byte Ptr\n\tField _reqState:Int\n\t\n\tMethod Pre(vm:Byte Ptr, rfield(off%, typ%, name$, clas@ Ptr), rmethod(fn:Int(state@ Ptr), name$, clas@ Ptr))\n\t\tLocal cb(vm:Byte Ptr, rfield(off%, typ%, name$, clas@ Ptr), rmethod(fn:Int(state@ Ptr), name$, clas@ Ptr)) = _cb\n\t\tIf Not _reqState Then\n\t\t p_lugi_preinit_cb.Remove(Self)\n\t\t cb(Null, rfield, rmethod) ' No VM is passed, since it's not required\n\t\tElse\n \t\tcb(vm, rfield, rmethod)\n \tEndIf\n\tEnd Method\n\t\n\tMethod Post(vm:Byte Ptr, constructor:Int(state:Byte Ptr))\n\t\tLocal cb(vm:Byte Ptr, constructor:Int(state:Byte Ptr)) = _cb\n\t\tcb(vm, constructor)\n\tEnd Method\n\t\n\t' #endregion\n\t\nEnd Type\n\nPrivate\n\n' There is really no good way to do this in a thread-safe manner, so the best I can do is to make\n' all access to the initialization lists a critical section\n?Threaded\nGlobal p_lugi_initlock:TMutex = TMutex.Create()\n?\nGlobal p_lugi_preinit_cb:TList\nGlobal p_lugi_postinit_cb:TList\n\n' Executes init functions that are to occur prior to creation of any BMax objects, VMTs, etc.\n' Doesn't lock the lists since it's only supposed to be called after the lists have been locked\nFunction PreInitLuGI(vm@ Ptr)\n\tIf Not p_lugi_preinit_cb Then\n\t\tReturn\n\tEndIf\n\tFor Local cb:LuGIInitFunction = EachIn p_lugi_preinit_cb\n\t\tcb.Pre(vm, p_lugi_register_field, p_lugi_register_method)\n\tNext\nEnd Function\n\n' Executes init functions that are to occur following the creation of BMax VMTs, metatables, cache, etc.\n' Doesn't lock the lists since it's only supposed to be called after the lists have been locked\nFunction PostInitLuGI(vm@ Ptr)\n\tIf Not p_lugi_postinit_cb Then\n\t\tReturn\n\tEndIf\n\tFor Local cb:LuGIInitFunction = EachIn p_lugi_postinit_cb\n\t\tcb.Post(vm, p_lugi_new_object)\n\tNext\nEnd Function\n\n' Private\/internal code that shouldn't be directly accessed (only provided)\nExtern \"C\"\n\tFunction p_lugi_register_method(fn:Int(state@ Ptr), name$, clas@ Ptr=Null)\n\tFunction p_lugi_register_field(off%, typ%, name$, clas@ Ptr)\n\t\n\tFunction p_lugi_init(state@ Ptr)\n\t\n\t' Constructor object - push with BBClass for type as upvalue\n\tFunction p_lugi_new_object:Int(state@ Ptr)\nEnd Extern\n\nPublic\n\nExtern \"C\"\n\t' Determining if an object on the stack is a BMax object\n\tFunction lua_isbmaxobject:Int(state@ Ptr, index:Int)\n\t\n\t' Pushing\/getting BBObjects (BBObjects, BBStrings, and BBArrays to tables\/tables to BBArrays respectively)\n\tFunction lua_pushbmaxobject(state@ Ptr, obj:Object)\n\tFunction lua_tobmaxobject:Object(state@ Ptr, index:Int)\n\t\n\t' Pushing\/getting BBArrays (BBArrays to tables\/tables to BBArrays respectively)\n\t' @arr has to be treated as an Object in BMax since passing an Int[] as an Object[] doesn't work\n\tFunction lua_pushbmaxarray(state@ Ptr, arr:Object)\n\tFunction lua_tobmaxarray:Object(state@ Ptr, index:Int)\nEnd Extern\n\n' Initializes the Lua state for use with BMax objects via LuGI\nFunction InitLuGI(vm:Byte Ptr)\n\t?Threaded\n\tp_lugi_initlock.Lock()\n\t?\n\tPreInitLuGI(vm)\n\tp_lugi_init(vm)\n\tPostInitLuGI(vm)\n\t?Threaded\n\tp_lugi_initlock.Unlock()\n\t?\nEnd Function\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"d9fe5ad42f125abb775dcdf37dbfdb505b8f1b14","subject":"Extra test case for Lexer","message":"Extra test case for Lexer\n","repos":"maximos\/maximus-web,maximos\/maximus-web,maximos\/maximus-web","old_file":"Maximus\/t\/data\/test.mod1\/mod1.bmx","new_file":"Maximus\/t\/data\/test.mod1\/mod1.bmx","new_contents":"SuperStrict\n\nModule test.mod1\nModuleInfo \"Name: test.mod1\"\nModuleInfo \"Version: 1.1.15\"\nModuleInfo \"License: MIT\"\nModuleInfo \"Author: Christiaan Kras\"\n\nFramework brl.basic\nImport htbaapub.rest\nImport brl.retro\n'Import pub.zlib\nRem\n\tImport pub.lua\n\tImport pub.enet\n\tImport \"test.bmx\"\n\tInclude \"test2.bmx\"\nend rem\n\nInclude \"inc\/more_imports.bmx\"\nImport \"inc\/other_imports.bmx\"\n'This include will be ignored by Maximus::Class::Lexer\nInclude \"src\/*.h\"\n","old_contents":"SuperStrict\n\nModule test.mod1\nModuleInfo \"Name: test.mod1\"\nModuleInfo \"Version: 1.1.15\"\nModuleInfo \"License: MIT\"\nModuleInfo \"Author: Christiaan Kras\"\n\nFramework brl.basic\nImport htbaapub.rest\nImport brl.retro\n'Import pub.zlib\nRem\n\tImport pub.lua\n\tImport pub.enet\n\tImport \"test.bmx\"\n\tInclude \"test2.bmx\"\nend rem\n\nInclude \"inc\/more_imports.bmx\"\nImport \"inc\/other_imports.bmx\"","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"0fbdcf014b6c1bd1e16d0714476f46b59d84c07d","subject":"Added newline option to logging methods.","message":"Added newline option to logging methods.\n","repos":"maximos\/maximus","old_file":"src\/logger.bmx","new_file":"src\/logger.bmx","new_contents":"Rem\nCopyright (c) 2010 Tim Howard\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and\/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\nEnd Rem\n\nRem\n\tbbdoc: Maximus basic logger.\nEnd Rem\nType mxLogger\n\t\n\tRem\n\t\tbbdoc: Log a message.\n\t\treturns: Nothing.\n\t\tabout: If @newline is True, a new line will be started, if it is False, a new line will not be started.\n\tEnd Rem\n\tMethod LogMessage(message:String, newline:Int = True)\n\t\tIf newline = True\n\t\t\tPrint(message)\n\t\tElse\n\t\t\tWriteStdOut(message)\n\t\tEnd If\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Log a warning message.\n\t\treturns: Nothing.\n\t\tabout: If @newline is True, a new line will be started, if it is False, a new line will not be started.\n\tEnd Rem\n\tMethod LogWarning(warning:String, newline:Int = True)\n\t\tIf newline = True\n\t\t\tPrint(_s(\"message.warning\", [warning]))\n\t\tElse\n\t\t\tWriteStdOut(_s(\"message.warning\", [warning]))\n\t\tEnd If\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Log an error message.\n\t\treturns: Nothing.\n\t\tabout: If @newline is True, a new line will be started, if it is False, a new line will not be started.\n\tEnd Rem\n\tMethod LogError(error:String, newline:Int = True)\n\t\tIf newline = True\n\t\t\tPrint(_s(\"message.error\", [error]))\n\t\tElse\n\t\t\tWriteStdOut(_s(\"message.error\", [error]))\n\t\tEnd If\n\tEnd Method\n\t\nEnd Type\n\n","old_contents":"Rem\nCopyright (c) 2010 Tim Howard\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and\/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\nEnd Rem\n\nRem\n\tbbdoc: Maximus basic logger.\nEnd Rem\nType mxLogger\n\t\n\tRem\n\t\tbbdoc: Log a message.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod LogMessage(message:String)\n\t\tPrint(message)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Log a warning message.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod LogWarning(warning:String)\n\t\tPrint(_s(\"message.warning\", [warning]))\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Log an error message.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod LogError(error:String)\n\t\tPrint(_s(\"message.error\", [error]))\n\tEnd Method\n\t\nEnd Type\n\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"750b3c2c3541e3c21713e98c5521961d781a54bf","subject":"mxModuleVersion now uses mxVersionObject for sorting","message":"mxModuleVersion now uses mxVersionObject for sorting\n\nrefs gh-1\n","repos":"maximos\/maximus","old_file":"src\/module.bmx","new_file":"src\/module.bmx","new_contents":"\nRem\n\tbbdoc: Maximus module base.\n\tabout: An abstract type for the similarities between module scopes and modules.\nEnd Rem\nType mxModuleBase Abstract\n\t\n\tField m_name:String\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the base's name.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetName(name:String)\n\t\tAssert name, \"(mxModuleBase.SetName) name cannot be Null\"\n\t\tm_name = name\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the base's name.\n\t\treturns: The base's name.\n\tEnd Rem\n\tMethod GetName:String()\n\t\tReturn m_name\n\tEnd Method\n\t\n'#end region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set a common field from the given variable.\n\t\treturns: True if the given variable was handled, or False if it was not.\n\tEnd Rem\n\tMethod SetCommonFromVariable:Int(variable:dVariable)\n\t\tReturn False\n\tEnd Method\n\t\nEnd Type\n\nRem\n\tbbdoc: Maximus module scope.\nEnd Rem\nType mxModuleScope Extends mxModuleBase\n\t\n\tField m_modules:dObjectMap\n\t\n\tMethod New()\n\t\tm_modules = New dObjectMap\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Add the given module to the scope.\n\t\treturns: True if the module was added, or False if it was not (the module is Null).\n\tEnd Rem\n\tMethod AddModule:Int(modul:mxModule)\n\t\tIf modul\n\t\t\tm_modules._Insert(modul.GetName(), modul)\n\t\t\tmodul.SetParent(Self)\n\t\t\tReturn True\n\t\tEnd If\n\t\tReturn False\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Check if the given module name is found in the scope.\n\t\treturns: True if the given module was found in the scope, or False if it was not.\n\tEnd Rem\n\tMethod HasModule:Int(modname:String)\n\t\tReturn m_modules._Contains(modname)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get a module with the given name.\n\t\treturns: The module with the given name, or Null if there is no module with the given name.\n\tEnd Rem\n\tMethod GetModuleWithName:mxModule(modname:String)\n\t\tReturn mxModule(m_modules._ObjectWithKey(modname))\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Load the given dJObject into the scope.\n\t\treturns: Itself, or Null if @root is Null.\n\tEnd Rem\n\tMethod FromJSON:mxModuleScope(root:dJObject)\n\t\tIf root\n\t\t\tSetName(root.GetName())\n\t\t\tFor Local variable:dVariable = EachIn root\n\t\t\t\tIf dJObject(variable)\n\t\t\t\t\tAddModule(New mxModule.FromJSON(dJObject(variable)))\n\t\t\t\t'Else\n\t\t\t\t'\tSetCommonFromVariable(variable)\n\t\t\t\tEnd If\n\t\t\tNext\n\t\t\tReturn Self\n\t\tEnd If\n\t\tReturn Null\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the module enumerator for the scope.\n\t\treturns: The module enumerator for the scope.\n\tEnd Rem\n\tMethod ModuleEnumerator:TMapEnumerator()\n\t\tReturn m_modules.ValueEnumerator()\n\tEnd Method\n\t\nEnd Type\n\nRem\n\tbbdoc: Maximus module.\nEnd Rem\nType mxModule Extends mxModuleBase\n\t\n\tField m_parent:mxModuleScope\n\tField m_description:String\n\tField m_versions:dObjectMap\n\t\n\tMethod New()\n\t\tm_versions = New dObjectMap\n\tEnd Method\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the module's parent.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetParent(parent:mxModuleScope)\n\t\tm_parent = parent\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the module's parent.\n\t\treturns: The module's parent.\n\tEnd Rem\n\tMethod GetParent:mxModuleScope()\n\t\tReturn m_parent\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the full name of the module (e.g. \"modscope.module\").\n\t\treturns: The full name of the module.\n\tEnd Rem\n\tMethod GetFullName:String()\n\t\tReturn m_parent.m_name + \".\" + m_name\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the module's description.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetDescription(description:String)\n\t\tm_description = description\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the module's description.\n\t\treturns: The module's description.\n\tEnd Rem\n\tMethod GetDescription:String()\n\t\tReturn m_description\n\tEnd Method\n\t\n'#end region Field accessors\n\t\n\tRem\n\t\tbbdoc: Get the installed version of the module (if it is installed).\n\t\treturns: The version of the module that is installed, or Null if the module is not installed.\n\tEnd Rem\n\tMethod GetInstalledVersion:mxModuleVersion()\n\t\tLocal version:String = mxModUtils.GetInstalledVersionFromVerID(GetFullName())\n\t\tIf version\n\t\t\tReturn New mxModuleVersion.Create(Self, version, Null)\n\t\tEnd If\n\t\tReturn Null\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Add the given version to the module.\n\t\treturns: True if the version was added, or False if it was not (the version is Null).\n\tEnd Rem\n\tMethod AddVersion:Int(version:mxModuleVersion)\n\t\tIf version\n\t\t\tm_versions._Insert(version.GetName(), version)\n\t\t\tversion.SetParent(Self)\n\t\t\tReturn True\n\t\tEnd If\n\t\tReturn False\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Check if there is a version with the given name.\n\t\treturns: True if the version was found, or False if it was not.\n\tEnd Rem\n\tMethod HasVersion:Int(name:String)\n\t\tReturn m_versions._Contains(name)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get a version with the given name.\n\t\treturns: The version with the given name, or Null if there is no version with the given name.\n\tEnd Rem\n\tMethod GetVersionWithName:mxModuleVersion(name:String)\n\t\tReturn mxModuleVersion(m_versions._ObjectWithKey(name))\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the latest (non-dev if available) version for this module.\n\t\treturns: The latest version for this module.\n\t\tabout: The latest version will be returned, or the dev version if it is the only version.\n\tEnd Rem\n\tMethod GetLatestVersion:mxModuleVersion()\n\t\tLocal hver:mxModuleVersion\n\t\tFor Local ver:mxModuleVersion = EachIn VersionEnumerator()\n\t\t\tIf ver.GetName() <> \"dev\"\n\t\t\t\tIf Not hver Or ver.Compare(hver) = 1\n\t\t\t\t\thver = ver\n\t\t\t\tEnd If\n\t\t\tEnd If\n\t\tNext\n\t\tIf Not hver\n\t\t\thver = GetVersionWithName(\"dev\")\n\t\tEnd If\n\t\tReturn hver\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set a common field from the given variable.\n\t\treturns: True if the given variable was handled, or False if it was not.\n\tEnd Rem\n\tMethod SetCommonFromVariable:Int(variable:dVariable)\n\t\tIf Super.SetCommonFromVariable(variable)\n\t\t\tReturn True\n\t\tElse\n\t\t\tSelect variable.GetName().ToLower()\n\t\t\t\tCase \"desc\"\n\t\t\t\t\tSetDescription(dValueVariable(variable).ValueAsString())\n\t\t\t\tCase \"versions\"\n\t\t\t\t\tFor Local jobj:dJObject = EachIn dJObject(variable)\n\t\t\t\t\t\tAddVersion(New mxModuleVersion.FromJSON(jobj))\n\t\t\t\t\tNext\n\t\t\t\tDefault\n\t\t\t\t\tReturn False\n\t\t\tEnd Select\n\t\t\tReturn True\n\t\tEnd If\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Load the given dJObject into the module.\n\t\treturns: Itself, or Null if @root is Null.\n\tEnd Rem\n\tMethod FromJSON:mxModule(root:dJObject)\n\t\tIf root\n\t\t\tSetName(root.GetName())\n\t\t\tFor Local variable:dVariable = EachIn root\n\t\t\t\tSetCommonFromVariable(variable)\n\t\t\tNext\n\t\t\tReturn Self\n\t\tEnd If\n\t\tReturn Null\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the version enumerator for the module.\n\t\treturns: The version enumerator for the module.\n\tEnd Rem\n\tMethod VersionEnumerator:TMapEnumerator()\n\t\tReturn m_versions.ValueEnumerator()\n\tEnd Method\n\t\nEnd Type\n\nRem\n\tbbdoc: Maximus module version.\nEnd Rem\nType mxModuleVersion\n\t\n\tField m_parent:mxModule\n\tField m_name:String, m_url:String\n\tField m_dependencies:mxModuleDependencies\n\t\n\tMethod New()\n\t\tm_dependencies = New mxModuleDependencies\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Create a module version.\n\t\treturns: Itself.\n\tEnd Rem\n\tMethod Create:mxModuleVersion(parent:mxModule, name:String, url:String)\n\t\tSetParent(parent)\n\t\tSetName(name)\n\t\tSetUrl(url)\n\t\tReturn Self\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Clone the version.\n\t\treturns: A clone of the version.\n\t\tabout: If @withdeps is True (default value), the dependencies will be added as well.\n\tEnd Rem\n\tMethod Clone:mxModuleVersion(withdeps:Int = True)\n\t\tLocal v:mxModuleVersion = New mxModuleVersion.Create(m_parent, m_name, m_url)\n\t\tFor Local dep:mxModuleDependency = EachIn DependencyEnumerator()\n\t\t\tv.m_dependencies.AddDependency(dep)\n\t\tNext\n\t\tReturn v\n\tEnd Method\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the version's parent.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetParent(parent:mxModule)\n\t\tm_parent = parent\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the version's parent.\n\t\treturns: The version's parent.\n\tEnd Rem\n\tMethod GetParent:mxModule()\n\t\tReturn m_parent\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the version's name.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetName(name:String)\n\t\tAssert name, \"(mxModuleVersion.SetName) name cannot be Null!\"\n\t\tm_name = name\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the version's name.\n\t\treturns: The version's name.\n\tEnd Rem\n\tMethod GetName:String()\n\t\tReturn m_name\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the version's url.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetUrl(url:String)\n\t\t'Assert url, \"(mxModuleVersion.SetUrl) url cannot be Null!\"\n\t\tm_url = url\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the version's url.\n\t\treturns: The version's url.\n\tEnd Rem\n\tMethod GetUrl:String()\n\t\tReturn m_url\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the temporary fetch path for the version's source archive.\n\t\treturns: The temporary file path for the version's source archive.\n\tEnd Rem\n\tMethod GetTemporaryFilePath:String()\n\t\tReturn \"tmp\/\" + m_parent.GetFullName() + \"-\" + m_name + \".zip\"\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the version's dependencies.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetDependencies(dependencies:mxModuleDependencies)\n\t\tm_dependencies = dependencies\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the version's dependencies.\n\t\treturns: The version's dependencies.\n\tEnd Rem\n\tMethod GetDependencies:mxModuleDependencies()\n\t\tReturn m_dependencies\n\tEnd Method\n\t\n'#end region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set a common field from the given variable.\n\t\treturns: True if the given variable was handled, or False if it was not.\n\tEnd Rem\n\tMethod SetCommonFromVariable:Int(variable:dVariable)\n\t\tSelect variable.GetName().ToLower()\n\t\t\tCase \"url\"\n\t\t\t\tSetUrl(dValueVariable(variable).ValueAsString())\n\t\t\tCase \"deps\"\n\t\t\t\tm_dependencies.FromJSON(dJArray(variable))\n\t\t\tDefault\n\t\t\t\tReturn False\n\t\tEnd Select\n\t\tReturn True\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Load the given dJObject into the version.\n\t\treturns: Itself, or Null if @root is Null.\n\tEnd Rem\n\tMethod FromJSON:mxModuleVersion(root:dJObject)\n\t\tIf root\n\t\t\tSetName(root.GetName())\n\t\t\tFor Local variable:dVariable = EachIn root\n\t\t\t\tSetCommonFromVariable(variable)\n\t\t\tNext\n\t\t\tReturn Self\n\t\tEnd If\n\t\tReturn Null\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the dependency enumerator for the version.\n\t\treturns: The dependency enumerator for the version.\n\tEnd Rem\n\tMethod DependencyEnumerator:TMapEnumerator()\n\t\tReturn m_dependencies.DependencyEnumerator()\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Compare the version with the given version.\n\t\treturns: 0 if the two versions are the same (same in version number alone), 1 if this version is greater than the given, or -1 if the given version is greater than this version.\n\tEnd Rem\n\tMethod Compare:Int(with:Object)\n\t\tLocal ver:mxModuleVersion = mxModuleVersion(with)\n\t\tIf ver\n\t\t\tLocal version1:mxVersionObject = New mxVersionObject.Parse(m_name)\n\t\t\tLocal version2:mxVersionObject = New mxVersionObject.Parse(ver.m_name)\n\t\t\tReturn version1.Compare(version2)\n\t\tEnd If\n\t\tReturn Super.Compare(with)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Fetch the version's source archive.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod FetchSourceArchive()\n\t\tLocal file:String = GetTemporaryFilePath()\n\t\tlogger.LogMessage(\"fetching: \" + GetUrl() + \" -> \" + file + \" \", False)\n\t\tIf FileType(file) = FILETYPE_NONE\n\t\t\tLocal stream:TStream = WriteFileExplicitly(file)\n\t\t\tIf stream\n\t\t\t\tLocal request:TRESTRequest = New TRESTRequest, response:TRESTResponse\n\t\t\t\trequest.SetProgressCallback(_ProgressCallback, New _mxProgressStore)\n\t\t\t\trequest.SetStream(stream)\n\t\t\t\tTry\n\t\t\t\t\tresponse = request.Call(GetUrl(), [\"User-Agent: \" + mainapp.m_useragent], \"GET\")\n\t\t\t\tCatch e:Object\n\t\t\t\t\tstream.Close()\n\t\t\t\t\tDeleteFile(file)\n\t\t\t\t\tlogger.LogMessage(\"\")\n\t\t\t\t\tThrowError(_s(\"error.fetch.archive\", [e.ToString()]))\n\t\t\t\tEnd Try\n\t\t\t\tstream.Close()\n\t\t\t\tIf response.responseCode = 200\n\t\t\t\t\tlogger.LogMessage(_s(\"message.fetch.done\", [String(response.responseCode)]))\n\t\t\t\tElse\n\t\t\t\t\tDeleteFile(file)\n\t\t\t\t\tlogger.LogMessage(\"\")\n\t\t\t\t\tThrowError(_s(\"error.fetch.archive\", [\"Bad response code: \" + String(response.responseCode)]))\n\t\t\t\tEnd If\n\t\t\tElse\n\t\t\t\tThrowError(_s(\"error.writeperms\", [file]))\n\t\t\tEnd If\n\t\tElse\n\t\t\tlogger.LogMessage(_s(\"message.fetch.alreadyfetched\"))\n\t\tEnd If\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Progress callback for source archive fetching.\n\t\treturns: Zero (no error).\n\tEnd Rem\n\tFunction _ProgressCallback:Int(data:Object, dltotal:Double, dlnow:Double, ultotal:Double, ulnow:Double)\n\t\tLocal store:_mxProgressStore = _mxProgressStore(data)\n\t\tLocal prog:Int = (dlnow \/ dltotal) * 100\n\t\tIf prog > store.m_progress + 5\n\t\t\tstore.m_progress = prog\n\t\t\tWriteStdOut(\".\")\n\t\tEnd If\n\t\tReturn 0\n\tEnd Function\n\t\nEnd Type\n\nRem\n\tbbdoc: A object representing a version, not to be confused with mxModuleVersion\n\tabout: Supported formats are 1, 1.1 and 1.1.1.\n\tDo note that because the version is represented as a Double there's a change\n\tthe precision of the final number is off.\n\t\n\t1.1.2 Would be converted to 1.001002 but when converted to a Double it results\n\tin 1.0010019999999999.\n\t\n\t1.1.12 However would be converted to 1.001012 and when converted to a Double it\n\tresults in 1.0010120000000000.\n\t\n\tA version string of 'dev' will be represented as 99999\nEnd Rem\nType mxVersionObject\n\n\tField m_version:Double\n\n\tRem\n\t\tbbdoc: Parse a version string\n\t\treturns: Itself.\n\tEnd Rem\n\tMethod Parse:mxVersionObject(version:String)\n\t\tIf version = \"dev\"\n\t\t\tm_version = 99999\n\t\t\tReturn Self\n\t\tEnd If\n\n\t\tLocal parts:String[] = version.Split(\".\")\n\t\tLocal converted:String = parts[0]\n\t\tIf parts.Length > 1\n\t\t\tconverted:+\".\"\n\t\t\tFor Local part:String = EachIn parts[1..]\n\t\t\t\tWhile part.Length <> 3\n\t\t\t\t\tpart = \"0\" + part\n\t\t\t\tWEnd\n\t\t\t\tconverted:+part\n\t\t\tNext\n\n\t\t\t'Make sure we format to x.x.x\n\t\t\tIf parts.Length = 2\n\t\t\t\tconverted:+\"000\"\n\t\t\tEnd If\n\t\tEnd If\n\n\t\tm_version = converted.ToDouble()\n\t\tReturn Self\n\tEnd Method\n\n\tRem\n\t\tbbdoc: Compare version numbers\n\tEnd Rem\n\tMethod Compare:Int(withObject:Object)\n\t\tLocal version:mxVersionObject = mxVersionObject(withObject)\n\t\tIf version\n\t\t\tIf m_version = version.m_version\n\t\t\t\tReturn 0\n\t\t\tElse If m_version > version.m_version\n\t\t\t\tReturn 1\n\t\t\tElse If m_version < version.m_version\n\t\t\t\tReturn - 1\n\t\t\tEnd If\n\t\tEnd If\n\t\tReturn Super.Compare(withObject)\n\tEnd Method\nEnd Type\n\nRem\n\tbbdoc: Maximus metafile handler\nEnd Rem\nType mxMetaFile\n\n\tField m_metafile:String\n\tField m_scope:String\n\tField m_name:String\n\tField m_version:String\n\t\n\tRem\n\t\tbbdoc: Create a metafile handler.\n\t\treturns: Itself.\n\tEnd Rem\n\tMethod Create:mxMetaFile(metafile:String)\n\t\tSetMetaFile(metafile)\n\t\tReturn Self\n\tEnd Method\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the metafile file path.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetMetaFile(metafile:String)\n\t\tm_metafile = metafile\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the metafile path.\n\t\treturns: The metafile path.\n\tEnd Rem\n\tMethod GetMetaFile:String()\n\t\tReturn m_metafile\n\tEnd Method\n\t\n'#end region Field accessors\n\t\n\tRem\n\t\tbbdoc: Load the configuration.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod Load()\n\t\tIf FileType(GetMetaFile()) = FILETYPE_FILE\n\t\t\tTry\n\t\t\t\tLocal contents:String = LoadText(GetMetaFile()).Trim()\n\t\t\t\tLocal parts:String[] = contents.Split(\"\/\")\n\t\t\t\t\n\t\t\t\tIf parts.Length <> 2\n\t\t\t\t\tThrow _s(\"error.load.meta.invalid_format\") ;\n\t\t\t\tEnd If\n\t\t\t\t\n\t\t\t\tLocal modinfo:String[] = parts[0].Split(\".\")\n\t\t\t\tm_scope = modinfo[0]\n\t\t\t\tm_name = modinfo[1]\n\t\t\t\tm_version = parts[1]\n\t\t\tCatch e:Object\n\t\t\t\tlogger.LogError(_s(\"error.load.metafile.parse\", [GetMetaFile()]))\n\t\t\t\tlogger.LogError(_s(\"error.load.metafile.parse\", [e.ToString()]))\n\t\t\tEnd Try\n\t\tElse\n\t\t\tlogger.LogWarning(_s(\"error.load.metafile.notfound\", [GetMetaFile()]))\n\t\tEnd If\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Save the configuration\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod Save()\n\t\tIf m_scope.Length = 0 Or m_name.Length = 0 Or m_version.Length = 0\n\t\t\tThrowError(_s(\"error.save.metafile.incomplete\", [m_scope, m_name, m_version]))\n\t\tEnd If\n\t\t\n\t\tLocal stream:TStream = WriteFileExplicitly(GetMetaFile())\n\t\tstream.WriteString(m_scope + \".\" + m_name + \"\/\" + m_version)\n\t\tstream.Close\n\tEnd Method\nEnd Type\n","old_contents":"\nRem\n\tbbdoc: Maximus module base.\n\tabout: An abstract type for the similarities between module scopes and modules.\nEnd Rem\nType mxModuleBase Abstract\n\t\n\tField m_name:String\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the base's name.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetName(name:String)\n\t\tAssert name, \"(mxModuleBase.SetName) name cannot be Null\"\n\t\tm_name = name\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the base's name.\n\t\treturns: The base's name.\n\tEnd Rem\n\tMethod GetName:String()\n\t\tReturn m_name\n\tEnd Method\n\t\n'#end region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set a common field from the given variable.\n\t\treturns: True if the given variable was handled, or False if it was not.\n\tEnd Rem\n\tMethod SetCommonFromVariable:Int(variable:dVariable)\n\t\tReturn False\n\tEnd Method\n\t\nEnd Type\n\nRem\n\tbbdoc: Maximus module scope.\nEnd Rem\nType mxModuleScope Extends mxModuleBase\n\t\n\tField m_modules:dObjectMap\n\t\n\tMethod New()\n\t\tm_modules = New dObjectMap\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Add the given module to the scope.\n\t\treturns: True if the module was added, or False if it was not (the module is Null).\n\tEnd Rem\n\tMethod AddModule:Int(modul:mxModule)\n\t\tIf modul\n\t\t\tm_modules._Insert(modul.GetName(), modul)\n\t\t\tmodul.SetParent(Self)\n\t\t\tReturn True\n\t\tEnd If\n\t\tReturn False\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Check if the given module name is found in the scope.\n\t\treturns: True if the given module was found in the scope, or False if it was not.\n\tEnd Rem\n\tMethod HasModule:Int(modname:String)\n\t\tReturn m_modules._Contains(modname)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get a module with the given name.\n\t\treturns: The module with the given name, or Null if there is no module with the given name.\n\tEnd Rem\n\tMethod GetModuleWithName:mxModule(modname:String)\n\t\tReturn mxModule(m_modules._ObjectWithKey(modname))\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Load the given dJObject into the scope.\n\t\treturns: Itself, or Null if @root is Null.\n\tEnd Rem\n\tMethod FromJSON:mxModuleScope(root:dJObject)\n\t\tIf root\n\t\t\tSetName(root.GetName())\n\t\t\tFor Local variable:dVariable = EachIn root\n\t\t\t\tIf dJObject(variable)\n\t\t\t\t\tAddModule(New mxModule.FromJSON(dJObject(variable)))\n\t\t\t\t'Else\n\t\t\t\t'\tSetCommonFromVariable(variable)\n\t\t\t\tEnd If\n\t\t\tNext\n\t\t\tReturn Self\n\t\tEnd If\n\t\tReturn Null\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the module enumerator for the scope.\n\t\treturns: The module enumerator for the scope.\n\tEnd Rem\n\tMethod ModuleEnumerator:TMapEnumerator()\n\t\tReturn m_modules.ValueEnumerator()\n\tEnd Method\n\t\nEnd Type\n\nRem\n\tbbdoc: Maximus module.\nEnd Rem\nType mxModule Extends mxModuleBase\n\t\n\tField m_parent:mxModuleScope\n\tField m_description:String\n\tField m_versions:dObjectMap\n\t\n\tMethod New()\n\t\tm_versions = New dObjectMap\n\tEnd Method\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the module's parent.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetParent(parent:mxModuleScope)\n\t\tm_parent = parent\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the module's parent.\n\t\treturns: The module's parent.\n\tEnd Rem\n\tMethod GetParent:mxModuleScope()\n\t\tReturn m_parent\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the full name of the module (e.g. \"modscope.module\").\n\t\treturns: The full name of the module.\n\tEnd Rem\n\tMethod GetFullName:String()\n\t\tReturn m_parent.m_name + \".\" + m_name\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the module's description.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetDescription(description:String)\n\t\tm_description = description\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the module's description.\n\t\treturns: The module's description.\n\tEnd Rem\n\tMethod GetDescription:String()\n\t\tReturn m_description\n\tEnd Method\n\t\n'#end region Field accessors\n\t\n\tRem\n\t\tbbdoc: Get the installed version of the module (if it is installed).\n\t\treturns: The version of the module that is installed, or Null if the module is not installed.\n\tEnd Rem\n\tMethod GetInstalledVersion:mxModuleVersion()\n\t\tLocal version:String = mxModUtils.GetInstalledVersionFromVerID(GetFullName())\n\t\tIf version\n\t\t\tReturn New mxModuleVersion.Create(Self, version, Null)\n\t\tEnd If\n\t\tReturn Null\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Add the given version to the module.\n\t\treturns: True if the version was added, or False if it was not (the version is Null).\n\tEnd Rem\n\tMethod AddVersion:Int(version:mxModuleVersion)\n\t\tIf version\n\t\t\tm_versions._Insert(version.GetName(), version)\n\t\t\tversion.SetParent(Self)\n\t\t\tReturn True\n\t\tEnd If\n\t\tReturn False\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Check if there is a version with the given name.\n\t\treturns: True if the version was found, or False if it was not.\n\tEnd Rem\n\tMethod HasVersion:Int(name:String)\n\t\tReturn m_versions._Contains(name)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get a version with the given name.\n\t\treturns: The version with the given name, or Null if there is no version with the given name.\n\tEnd Rem\n\tMethod GetVersionWithName:mxModuleVersion(name:String)\n\t\tReturn mxModuleVersion(m_versions._ObjectWithKey(name))\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the latest (non-dev if available) version for this module.\n\t\treturns: The latest version for this module.\n\t\tabout: The latest version will be returned, or the dev version if it is the only version.\n\tEnd Rem\n\tMethod GetLatestVersion:mxModuleVersion()\n\t\tLocal hver:mxModuleVersion\n\t\tFor Local ver:mxModuleVersion = EachIn VersionEnumerator()\n\t\t\tIf ver.GetName() <> \"dev\"\n\t\t\t\tIf Not hver Or ver.Compare(hver) = 1\n\t\t\t\t\thver = ver\n\t\t\t\tEnd If\n\t\t\tEnd If\n\t\tNext\n\t\tIf Not hver\n\t\t\thver = GetVersionWithName(\"dev\")\n\t\tEnd If\n\t\tReturn hver\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set a common field from the given variable.\n\t\treturns: True if the given variable was handled, or False if it was not.\n\tEnd Rem\n\tMethod SetCommonFromVariable:Int(variable:dVariable)\n\t\tIf Super.SetCommonFromVariable(variable)\n\t\t\tReturn True\n\t\tElse\n\t\t\tSelect variable.GetName().ToLower()\n\t\t\t\tCase \"desc\"\n\t\t\t\t\tSetDescription(dValueVariable(variable).ValueAsString())\n\t\t\t\tCase \"versions\"\n\t\t\t\t\tFor Local jobj:dJObject = EachIn dJObject(variable)\n\t\t\t\t\t\tAddVersion(New mxModuleVersion.FromJSON(jobj))\n\t\t\t\t\tNext\n\t\t\t\tDefault\n\t\t\t\t\tReturn False\n\t\t\tEnd Select\n\t\t\tReturn True\n\t\tEnd If\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Load the given dJObject into the module.\n\t\treturns: Itself, or Null if @root is Null.\n\tEnd Rem\n\tMethod FromJSON:mxModule(root:dJObject)\n\t\tIf root\n\t\t\tSetName(root.GetName())\n\t\t\tFor Local variable:dVariable = EachIn root\n\t\t\t\tSetCommonFromVariable(variable)\n\t\t\tNext\n\t\t\tReturn Self\n\t\tEnd If\n\t\tReturn Null\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the version enumerator for the module.\n\t\treturns: The version enumerator for the module.\n\tEnd Rem\n\tMethod VersionEnumerator:TMapEnumerator()\n\t\tReturn m_versions.ValueEnumerator()\n\tEnd Method\n\t\nEnd Type\n\nRem\n\tbbdoc: Maximus module version.\nEnd Rem\nType mxModuleVersion\n\t\n\tField m_parent:mxModule\n\tField m_name:String, m_url:String\n\tField m_dependencies:mxModuleDependencies\n\t\n\tMethod New()\n\t\tm_dependencies = New mxModuleDependencies\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Create a module version.\n\t\treturns: Itself.\n\tEnd Rem\n\tMethod Create:mxModuleVersion(parent:mxModule, name:String, url:String)\n\t\tSetParent(parent)\n\t\tSetName(name)\n\t\tSetUrl(url)\n\t\tReturn Self\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Clone the version.\n\t\treturns: A clone of the version.\n\t\tabout: If @withdeps is True (default value), the dependencies will be added as well.\n\tEnd Rem\n\tMethod Clone:mxModuleVersion(withdeps:Int = True)\n\t\tLocal v:mxModuleVersion = New mxModuleVersion.Create(m_parent, m_name, m_url)\n\t\tFor Local dep:mxModuleDependency = EachIn DependencyEnumerator()\n\t\t\tv.m_dependencies.AddDependency(dep)\n\t\tNext\n\t\tReturn v\n\tEnd Method\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the version's parent.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetParent(parent:mxModule)\n\t\tm_parent = parent\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the version's parent.\n\t\treturns: The version's parent.\n\tEnd Rem\n\tMethod GetParent:mxModule()\n\t\tReturn m_parent\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the version's name.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetName(name:String)\n\t\tAssert name, \"(mxModuleVersion.SetName) name cannot be Null!\"\n\t\tm_name = name\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the version's name.\n\t\treturns: The version's name.\n\tEnd Rem\n\tMethod GetName:String()\n\t\tReturn m_name\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the version's url.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetUrl(url:String)\n\t\t'Assert url, \"(mxModuleVersion.SetUrl) url cannot be Null!\"\n\t\tm_url = url\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the version's url.\n\t\treturns: The version's url.\n\tEnd Rem\n\tMethod GetUrl:String()\n\t\tReturn m_url\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the temporary fetch path for the version's source archive.\n\t\treturns: The temporary file path for the version's source archive.\n\tEnd Rem\n\tMethod GetTemporaryFilePath:String()\n\t\tReturn \"tmp\/\" + m_parent.GetFullName() + \"-\" + m_name + \".zip\"\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the version's dependencies.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetDependencies(dependencies:mxModuleDependencies)\n\t\tm_dependencies = dependencies\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the version's dependencies.\n\t\treturns: The version's dependencies.\n\tEnd Rem\n\tMethod GetDependencies:mxModuleDependencies()\n\t\tReturn m_dependencies\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the version parts for the version.\n\t\treturns: True if the version is development, in which case the parameters are both 0; or False, in which case the parameters are set accordingly.\n\tEnd Rem\n\tMethod GetVersionParts:Int(vmajor:String Var, vminor:String Var)\n\t\tIf m_name <> \"dev\"\n\t\t\tLocal i:Int = m_name.Find(\".\")\n\t\t\tIf i > -1\n\t\t\t\tvmajor = m_name[..i]\n\t\t\t\tvminor = m_name[i + 1..]\n\t\t\tElse\n\t\t\t\tvmajor = m_name ' I'm not sure what other version formats would be used, so I'm just playing a random card here\n\t\t\tEnd If\n\t\t\tReturn False\n\t\tEnd If\n\t\tReturn True\n\tEnd Method\n\t\n'#end region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set a common field from the given variable.\n\t\treturns: True if the given variable was handled, or False if it was not.\n\tEnd Rem\n\tMethod SetCommonFromVariable:Int(variable:dVariable)\n\t\tSelect variable.GetName().ToLower()\n\t\t\tCase \"url\"\n\t\t\t\tSetUrl(dValueVariable(variable).ValueAsString())\n\t\t\tCase \"deps\"\n\t\t\t\tm_dependencies.FromJSON(dJArray(variable))\n\t\t\tDefault\n\t\t\t\tReturn False\n\t\tEnd Select\n\t\tReturn True\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Load the given dJObject into the version.\n\t\treturns: Itself, or Null if @root is Null.\n\tEnd Rem\n\tMethod FromJSON:mxModuleVersion(root:dJObject)\n\t\tIf root\n\t\t\tSetName(root.GetName())\n\t\t\tFor Local variable:dVariable = EachIn root\n\t\t\t\tSetCommonFromVariable(variable)\n\t\t\tNext\n\t\t\tReturn Self\n\t\tEnd If\n\t\tReturn Null\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the dependency enumerator for the version.\n\t\treturns: The dependency enumerator for the version.\n\tEnd Rem\n\tMethod DependencyEnumerator:TMapEnumerator()\n\t\tReturn m_dependencies.DependencyEnumerator()\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Compare the version with the given version.\n\t\treturns: 0 if the two versions are the same (same in version number alone), 1 if this version is greater than the given, or -1 if the given version is greater than this version.\n\tEnd Rem\n\tMethod Compare:Int(with:Object)\n\t\tLocal ver:mxModuleVersion = mxModuleVersion(with)\n\t\tIf ver\n\t\t\tIf m_name = ver.m_name\n\t\t\t\tReturn 0\n\t\t\tElse\n\t\t\t\tLocal smajor:String, sminor:String, wmajor:String, wminor:String\n\t\t\t\tLocal sdev:Int = GetVersionParts(smajor, sminor), wdev:Int = ver.GetVersionParts(wmajor, wminor)\n\t\t\t\tIf (sdev And wdev) Or (smajor = wmajor And sminor = wminor)\n\t\t\t\t\tReturn 0\n\t\t\t\tElse If smajor > wmajor\n\t\t\t\t\tReturn 1\n\t\t\t\tElse If smajor = wmajor\n\t\t\t\t\tIf sminor > wminor\n\t\t\t\t\t\tReturn 1\n\t\t\t\t\tElse\n\t\t\t\t\t\tReturn -1\n\t\t\t\t\tEnd If\n\t\t\t\tElse\n\t\t\t\t\tReturn -1\n\t\t\t\tEnd If\n\t\t\tEnd If\n\t\tEnd If\n\t\tReturn Super.Compare(with)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Fetch the version's source archive.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod FetchSourceArchive()\n\t\tLocal file:String = GetTemporaryFilePath()\n\t\tlogger.LogMessage(\"fetching: \" + GetUrl() + \" -> \" + file + \" \", False)\n\t\tIf FileType(file) = FILETYPE_NONE\n\t\t\tLocal stream:TStream = WriteFileExplicitly(file)\n\t\t\tIf stream\n\t\t\t\tLocal request:TRESTRequest = New TRESTRequest, response:TRESTResponse\n\t\t\t\trequest.SetProgressCallback(_ProgressCallback, New _mxProgressStore)\n\t\t\t\trequest.SetStream(stream)\n\t\t\t\tTry\n\t\t\t\t\tresponse = request.Call(GetUrl(), [\"User-Agent: \" + mainapp.m_useragent], \"GET\")\n\t\t\t\tCatch e:Object\n\t\t\t\t\tstream.Close()\n\t\t\t\t\tDeleteFile(file)\n\t\t\t\t\tlogger.LogMessage(\"\")\n\t\t\t\t\tThrowError(_s(\"error.fetch.archive\", [e.ToString()]))\n\t\t\t\tEnd Try\n\t\t\t\tstream.Close()\n\t\t\t\tIf response.responseCode = 200\n\t\t\t\t\tlogger.LogMessage(_s(\"message.fetch.done\", [String(response.responseCode)]))\n\t\t\t\tElse\n\t\t\t\t\tDeleteFile(file)\n\t\t\t\t\tlogger.LogMessage(\"\")\n\t\t\t\t\tThrowError(_s(\"error.fetch.archive\", [\"Bad response code: \" + String(response.responseCode)]))\n\t\t\t\tEnd If\n\t\t\tElse\n\t\t\t\tThrowError(_s(\"error.writeperms\", [file]))\n\t\t\tEnd If\n\t\tElse\n\t\t\tlogger.LogMessage(_s(\"message.fetch.alreadyfetched\"))\n\t\tEnd If\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Progress callback for source archive fetching.\n\t\treturns: Zero (no error).\n\tEnd Rem\n\tFunction _ProgressCallback:Int(data:Object, dltotal:Double, dlnow:Double, ultotal:Double, ulnow:Double)\n\t\tLocal store:_mxProgressStore = _mxProgressStore(data)\n\t\tLocal prog:Int = (dlnow \/ dltotal) * 100\n\t\tIf prog > store.m_progress + 5\n\t\t\tstore.m_progress = prog\n\t\t\tWriteStdOut(\".\")\n\t\tEnd If\n\t\tReturn 0\n\tEnd Function\n\t\nEnd Type\n\nRem\n\tbbdoc: A object representing a version, not to be confused with mxModuleVersion\n\tabout: Supported formats are 1, 1.1 and 1.1.1.\n\tDo note that because the version is represented as a Double there's a change\n\tthe precision of the final number is off.\n\t\n\t1.1.2 Would be converted to 1.001002 but when converted to a Double it results\n\tin 1.0010019999999999.\n\t\n\t1.1.12 However would be converted to 1.001012 and when converted to a Double it\n\tresults in 1.0010120000000000.\n\t\n\tA version string of 'dev' will be represented as 99999\nEnd Rem\nType mxVersionObject\n\n\tField m_version:Double\n\n\tRem\n\t\tbbdoc: Parse a version string\n\t\treturns: Itself.\n\tEnd Rem\n\tMethod Parse:mxVersionObject(version:String)\n\t\tIf version = \"dev\"\n\t\t\tm_version = 99999\n\t\t\tReturn Self\n\t\tEnd If\n\n\t\tLocal parts:String[] = version.Split(\".\")\n\t\tLocal converted:String = parts[0]\n\t\tIf parts.Length > 1\n\t\t\tconverted:+\".\"\n\t\t\tFor Local part:String = EachIn parts[1..]\n\t\t\t\tWhile part.Length <> 3\n\t\t\t\t\tpart = \"0\" + part\n\t\t\t\tWEnd\n\t\t\t\tconverted:+part\n\t\t\tNext\n\n\t\t\t'Make sure we format to x.x.x\n\t\t\tIf parts.Length = 2\n\t\t\t\tconverted:+\"000\"\n\t\t\tEnd If\n\t\tEnd If\n\n\t\tm_version = converted.ToDouble()\n\t\tReturn Self\n\tEnd Method\n\n\tRem\n\t\tbbdoc: Compare version numbers\n\tEnd Rem\n\tMethod Compare:Int(withObject:Object)\n\t\tLocal version:mxVersionObject = mxVersionObject(withObject)\n\t\tIf version\n\t\t\tIf m_version = version.m_version\n\t\t\t\tReturn 0\n\t\t\tElse If m_version > version.m_version\n\t\t\t\tReturn 1\n\t\t\tElse If m_version < version.m_version\n\t\t\t\tReturn - 1\n\t\t\tEnd If\n\t\tEnd If\n\t\tReturn Super.Compare(withObject)\n\tEnd Method\nEnd Type\n\nRem\n\tbbdoc: Maximus metafile handler\nEnd Rem\nType mxMetaFile\n\n\tField m_metafile:String\n\tField m_scope:String\n\tField m_name:String\n\tField m_version:String\n\t\n\tRem\n\t\tbbdoc: Create a metafile handler.\n\t\treturns: Itself.\n\tEnd Rem\n\tMethod Create:mxMetaFile(metafile:String)\n\t\tSetMetaFile(metafile)\n\t\tReturn Self\n\tEnd Method\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the metafile file path.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetMetaFile(metafile:String)\n\t\tm_metafile = metafile\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the metafile path.\n\t\treturns: The metafile path.\n\tEnd Rem\n\tMethod GetMetaFile:String()\n\t\tReturn m_metafile\n\tEnd Method\n\t\n'#end region Field accessors\n\t\n\tRem\n\t\tbbdoc: Load the configuration.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod Load()\n\t\tIf FileType(GetMetaFile()) = FILETYPE_FILE\n\t\t\tTry\n\t\t\t\tLocal contents:String = LoadText(GetMetaFile()).Trim()\n\t\t\t\tLocal parts:String[] = contents.Split(\"\/\")\n\t\t\t\t\n\t\t\t\tIf parts.Length <> 2\n\t\t\t\t\tThrow _s(\"error.load.meta.invalid_format\") ;\n\t\t\t\tEnd If\n\t\t\t\t\n\t\t\t\tLocal modinfo:String[] = parts[0].Split(\".\")\n\t\t\t\tm_scope = modinfo[0]\n\t\t\t\tm_name = modinfo[1]\n\t\t\t\tm_version = parts[1]\n\t\t\tCatch e:Object\n\t\t\t\tlogger.LogError(_s(\"error.load.metafile.parse\", [GetMetaFile()]))\n\t\t\t\tlogger.LogError(_s(\"error.load.metafile.parse\", [e.ToString()]))\n\t\t\tEnd Try\n\t\tElse\n\t\t\tlogger.LogWarning(_s(\"error.load.metafile.notfound\", [GetMetaFile()]))\n\t\tEnd If\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Save the configuration\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod Save()\n\t\tIf m_scope.Length = 0 Or m_name.Length = 0 Or m_version.Length = 0\n\t\t\tThrowError(_s(\"error.save.metafile.incomplete\", [m_scope, m_name, m_version]))\n\t\tEnd If\n\t\t\n\t\tLocal stream:TStream = WriteFileExplicitly(GetMetaFile())\n\t\tstream.WriteString(m_scope + \".\" + m_name + \"\/\" + m_version)\n\t\tstream.Close\n\tEnd Method\nEnd Type\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"c50c21cb350f5601785d0375322e1445b04ffe6b","subject":"Removing last remnants of the old shader system.","message":"Removing last remnants of the old shader system.\n","repos":"kfprimm\/maxb3d,kfprimm\/maxb3d","old_file":"shaders.mod\/shaders.bmx","new_file":"shaders.mod\/shaders.bmx","new_contents":"","old_contents":"\r\nStrict\r\n\r\nRem\r\n\tbbdoc: MaxB3D shader drivers\r\nEnd Rem\r\nModule MaxB3D.Shaders\r\nModuleInfo \"Author: Kevin Primm\"\r\nModuleInfo \"License: MIT\"\r\n\r\nImport MaxB3D.GLSL\r\nImport MaxB3D.CgSL\r\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"29919df087c40049ed53ce5599ae87ec051708d3","subject":"Added SetViewPort, Width and Height contents to MonkeyMax","message":"Added SetViewPort, Width and Height contents to MonkeyMax\n","repos":"swoolcock\/diddy,swoolcock\/diddy,swoolcock\/diddy,swoolcock\/diddy,swoolcock\/diddy","old_file":"monkeymax\/modules\/mojo\/native\/mojo.bmax.bmx","new_file":"monkeymax\/modules\/mojo\/native\/mojo.bmax.bmx","new_contents":"' ***** Start mojo.bmax.bmx ******\r\n\r\nGlobal app:gxtkApp;\r\n\r\nType gxtkApp\r\n\tField ginput:gxtkInput;\r\n\tField gaudio:gxtkAudio;\r\n\tField ggraphics:gxtkGraphics;\r\n\r\n\tField dead:Int=0;\r\n\tField suspended:Int=0;\r\n\tField vloading:Int=0;\r\n\tField maxloading:Int=0;\r\n\tField updateRate:Int=0;\r\n\tField nextUpdate:Float=0;\r\n\tField updatePeriod:Float=0;\r\n\tField startMillis:Float=0;\r\n\t\r\n\tMethod New()' gxtkApp()\r\n\t\tapp=Self;\r\n\t\tggraphics=New gxtkGraphics;\r\n\tEndMethod\r\n\t\r\n\tMethod Setup()\r\n\t\tginput=New gxtkInput;\r\n\t\tgaudio=New gxtkAudio;\r\n\r\n\t\tbb_input_SetInputDevice(ginput);\r\n\t\tbb_audio_SetAudioDevice(gaudio);\r\n\t\t\r\n\t\tstartMillis=BlitzMaxMillisecs()\r\n\t\t\r\n\t\tSetFrameRate( 0 );\r\n\t\t\r\n\t\tInvokeOnCreate();\r\n\t\tInvokeOnRender();\r\n\t\tUpdate()\r\n\tEndMethod\r\n\t\r\n\tMethod Update()\r\n\t\tWhile Not AppTerminate()\r\n\t\t\tLocal updates:Int = 0\r\n\t\t\t\r\n\t\t\tLocal cont:Int = 1\r\n\t\t\tWhile (cont)\r\n\t\t\t\tnextUpdate:+updatePeriod\r\n\t\t\t\tInvokeOnUpdate()\r\n\t\t\t\tIf Not updatePeriod Then cont = 0\r\n\t\t\t\tIf nextUpdate>BlitzMaxMillisecs() Then cont = 0\r\n\t\t\t\tupdates:+1\r\n\t\t\t\tIf updates = 7 Then\r\n\t\t\t\t\tnextUpdate = BlitzMaxMillisecs()\r\n\t\t\t\t\tcont = 0\r\n\t\t\t\tEndIf\r\n\t\t\tWend\r\n\t\t\tInvokeOnRender()\r\n\t\tWend\r\n\tEndMethod\r\n\t\r\n\tMethod InvokeOnCreate()\r\n\t\tIf dead Return\r\n\t\tdead = 1\r\n\t\tOnCreate()\r\n\t\tdead = 0\r\n\tEndMethod\r\n\r\n\tMethod InvokeOnUpdate()\r\n\t\tIf dead Or suspended Or Not updateRate Or vloading Return\r\n\t\tOnUpdate()\r\n\tEndMethod\r\n\t\r\n\tMethod InvokeOnRender()\r\n\t\tIf dead Or suspended Return\r\n\t\tggraphics.BeginRender()\r\n\t\tIf vloading\r\n\t\t\tOnLoading()\r\n\t\tElse\r\n\t\t\tOnRender()\r\n\t\tEndIf\r\n\t\tggraphics.EndRender()\r\n\tEndMethod\r\n\t\r\n\t\r\n\tMethod SetFrameRate( fps:Int )\r\n\t\tIf fps\r\n\t\t\tupdatePeriod=1000.0\/fps;\r\n\t\t\tnextUpdate=BlitzMaxMillisecs() +updatePeriod;\r\n\t\tElse\r\n\t\t\tupdatePeriod=0\r\n\t\tEndIf\r\n\tEndMethod\r\n\t\r\n\tMethod LoadString:String( path:String )\r\n\t\tpath = \"data\/\" + path;\r\n\t\tReturn LoadText( path )\r\n\tEndMethod\r\n\t\r\n\t' ***** GXTK API *****\r\n\t\r\n\tMethod GraphicsDevice:gxtkGraphics()\r\n\t\tReturn ggraphics\r\n\tEndMethod\r\n\r\n\tMethod InputDevice:gxtkInput()\r\n\t\tReturn ginput\r\n\tEndMethod\r\n\r\n\tMethod AudioDevice:gxtkAudio()\r\n\t\tReturn gaudio\r\n\tEndMethod\r\n\r\n\tMethod SetUpdateRate:Int(hertz:Int)\r\n\t\tupdateRate = hertz\r\n\t\tIf Not vloading Then SetFrameRate(updateRate)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod MilliSecs:Int()\r\n\t\tReturn BlitzMaxMillisecs() - startMillis\r\n\tEndMethod\r\n\t\r\n\tMethod Loading:Int()\r\n\t\tReturn vloading;\r\n\tEndMethod\r\n\r\n\tMethod OnCreate:Int()\r\n\t\tReturn 0;\r\n\tEndMethod\r\n\r\n\tMethod OnUpdate:Int()\r\n\t\tReturn 0;\r\n\tEndMethod\r\n\t\r\n\tMethod OnSuspend:Int()\r\n\t\tReturn 0;\r\n\tEndMethod\r\n\t\r\n\tMethod OnResume:Int()\r\n\t\tReturn 0;\r\n\tEndMethod\r\n\t\r\n\tMethod OnRender:Int()\r\n\t\tReturn 0;\r\n\tEndMethod\r\n\t\r\n\tMethod OnLoading:Int()\r\n\t\tReturn 0;\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkGraphics\r\n\tField gmode:Int = 1\r\n\r\n\tMethod Mode:Int()\r\n\t\tReturn gmode\r\n\tEndMethod\r\n\t\r\n\tMethod Cls:Int(r:Int = 0, g:Int = 0, b:Int = 0)\r\n\t\tBlitzMaxCls(r, g, b)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod LoadSurface:gxtkSurface(path:String)\r\n\t\tLocal image:TImage = LoadImage(\"data\/\"+path)\r\n\t\tIf image Then\r\n\t\t\tLocal gs:gxtkSurface = New gxtkSurface\r\n\t\t\tgs.setImage(image)\r\n\t\t\tReturn gs\r\n\t\tEndIf\r\n\t\tReturn Null\r\n\tEndMethod\r\n\t\r\n\tMethod BeginRender()\r\n\tEndMethod\r\n\t\r\n\tMethod EndRender()\r\n\t\tFlip\r\n\tEndMethod\r\n\t\r\n\tMethod SetColor:Int(r:Int, g:Int, b:Int)\r\n\t\tBlitzMaxSetColor(r, g, b)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod SetAlpha:Int(a:Float)\r\n\t\tBlitzMaxSetAlpha(a)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod SetBlend:Int(blend:Int)\r\n\t\tBlitzMaxSetBlend(blend)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod Width:Int()\r\n\t\tReturn GraphicsWidth()\r\n\tEndMethod\r\n\t\r\n\tMethod Height:Int()\r\n\t\tReturn GraphicsHeight()\r\n\tEndMethod\r\n\t\r\n\tMethod SetScissor:Int(x:Int, y:Int, w:Int, h:Int)\r\n\t\tSetViewport(x, y, w, h) ' NOT TESTED!\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod SetMatrix:Int(ix:Float,iy:Float,jx:Float,jy:Float,tx:Float,ty:Float)\r\n\t\tLocal sx:Float = Sqr( (ix*ix) + (jx*jx) )\r\n\t\tLocal sy:Float = Sqr( (iy*iy) + (jy*jy) )\r\n\t\tLocal rot:Float = -Atan2( jx, ix )\r\n\t\tSetTransform( rot, sx, sy )\r\n\t\tSetOrigin( tx, ty )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawSurface:Int(surface:gxtkSurface,x:Float,y:Float)\r\n\t\tDrawImage(surface.image, x, y, 0)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawSurface2:Int(surface:gxtkSurface,x:Float,y:Float, srcx:Int, srcy:Int, srcw:Int, srch:Int )\r\n\t\tDrawSubImageRect(surface.image, x, y, srcw, srch, srcx, srcy, srcw, srch)\t\t\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawLine:Int( x1:Float,y1:Float,x2:Float,y2:Float )\r\n\t\tBlitzMaxDrawLine(x1, y1, x2, y2)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawOval:Int( x:Float, y:Float, w:Float, h:Float )\r\n\t\tBlitzMaxDrawOval(x, y, w, h)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawPoly:Int(vertices:Float[])\r\n\t\tBlitzMaxDrawPoly( vertices )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawRect:Int( x:Float, y:Float, w:Float, h:Float )\r\n\t\tBlitzMaxDrawRect(x, y, w, h)\r\n\t\tReturn 0\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkInput\r\n\tMethod MouseX:Float()\r\n\t\tReturn BRL.PolledInput.MouseX()\r\n\tEndMethod\r\n\r\n\tMethod MouseY:Float()\r\n\t\tReturn BRL.PolledInput.MouseY()\r\n\tEndMethod\r\n\t\r\n\tMethod KeyDown:Int( key:Int )\r\n\t\tIf( key >= 1 And key <= 3 )\r\n\t\t\tReturn BRL.PolledInput.MouseDown( key )\r\n\t\tEndIf\r\n\t\tReturn BRL.PolledInput.KeyDown( key )\r\n\tEndMethod\r\n\r\n\tMethod KeyHit:Int( key:Int )\r\n\t\tIf( key >= 1 And key <= 3 )\r\n\t\t\tReturn BRL.PolledInput.MouseHit( key )\r\n\t\tEndIf\r\n\t\tReturn BRL.PolledInput.KeyHit( key )\r\n\tEndMethod\r\n\r\n\tMethod GetChar:Int()\r\n\t\tReturn BRL.PolledInput.GetChar()\r\n\tEndMethod\r\n\r\n\tMethod JoyX:Int( index:Int )\r\n\t\tReturn Pub.FreeJoy.JoyX( index )\r\n\tEndMethod\r\n\r\n\tMethod JoyY:Int( index:Int )\r\n\t\tReturn Pub.FreeJoy.JoyY( index )\r\n\tEndMethod\r\n\r\n\tMethod JoyZ:Int( index:Int )\r\n\t\tReturn Pub.FreeJoy.JoyZ( index )\r\n\tEndMethod\r\n\r\n\tMethod TouchX:Float( index:Int )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod TouchY:Float( index:Int )\r\n\t\tReturn 0\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkChannel\r\n\tField channel:TChannel\t' null then not playing\r\n\tField sample:gxtkSample\r\n\tField loops:int\r\n\t'Field transform:SoundTransform=new SoundTransform()\r\n\t'Field pausepos:Number\r\n\tField state:int\r\n\t\r\n\tMethod New()\r\n\t\tchannel = New TChannel\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkAudio\r\n\tField amusicState:Int = 0;\r\n\tField channels:gxtkChannel[] = New gxtkChannel[33];\r\n\t\r\n\tMethod New()\r\n\t\tFor local i:Int = 0 To 33 - 1\r\n\t\t\tchannels[i] = New gxtkChannel\r\n\t\tNext\r\n\tEndMethod\r\n\t\r\n\tMethod MusicState:Int()\r\n'\t\tIf( musicState = 1 And music.isPlaying() = False )\r\n'\t\t\tmusicState = 0;\r\n'\t\tEndif\r\n\t\tReturn amusicState;\r\n\tEndMethod\r\n\t\r\n\tMethod PlayMusic:Int( path:String, flags:Int )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod StopMusic()\r\n\tEndMethod\r\n\t\r\n\tMethod StopChannel( channel:Int )\r\n\tEndMethod\r\n\r\n\tMethod PlaySample( sound:gxtkSample, channel:Int, flags:Int )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\t\r\n\t\t'If chan.state <> 0 Then chan.channel.Stop() <-- this crashes after the first play!?\r\n\t\t\r\n\t\tchan.sample = sound\r\n\t\t'chan.loops = flags ? 0x7fffffff : 0;\r\n\t\t'chan.channel = sample.sound.play( 0,chan.loops,chan.transform );\r\n\t\t'chan.channel = sound\r\n\t\tchan.state=1\r\n\t\r\n\t\tPlaySound( sound.sound, chan.channel )\r\n\tEndMethod\r\n\r\n\tMethod SetPan( channel:Int, pan:Float )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tchan.channel.SetPan(pan)\r\n\tEndMethod\r\n\r\n\tMethod SetRate( channel:Int, rate:Float )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tchan.channel.SetRate(rate)\r\n\tEndMethod\r\n\r\n\tMethod SetMusicVolume:Int( volume:Float )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod SetVolume:Int( channel:Int, volume:Float )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tchan.channel.SetVolume(volume)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod LoadSample:gxtkSample( path:String )\r\n\t\tLocal sound:TSound = LoadSound(\"data\/\"+path)\r\n\t\tIf sound Then\r\n\t\t\tLocal gs:gxtkSample = New gxtkSample\r\n\t\t\tgs.setSound(sound)\r\n\t\t\tReturn gs\r\n\t\tEndIf\r\n\t\tReturn Null\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkSample\r\n\tField sound:TSound\r\n\t\r\n\tMethod setSound(sound:TSound)\r\n\t\tSelf.sound = sound\r\n\tEndMethod\r\n\t\r\n\tMethod Discard()\r\n\t\tSelf.sound = null\r\n\tEndMethod\r\nEndType\r\n\r\nFunction BlitzMaxDrawPoly:Int(vertices:Float[])\r\n\tDrawPoly vertices\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxDrawRect:Int( x:Float, y:Float, w:Float, h:Float )\r\n\tDrawRect x, y, w, h\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxDrawOval:Int( x:Float, y:Float, w:Float, h:Float )\r\n\tDrawOval x, y, w, h\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxDrawLine:Int( x1:Float,y1:Float,x2:Float,y2:Float )\r\n\tDrawLine x1, y1, x2, y2\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxMillisecs:Int()\r\n\tReturn MilliSecs()\r\nEndFunction\r\n\r\nFunction BlitzMaxSetColor(r:Int, g:Int, b:Int)\r\n\tSetColor(r, g, b)\r\nEndFunction\r\n\r\nFunction BlitzMaxSetBlend(blend:Int)\r\n\tSelect blend\r\n\t\tCase 0\r\n\t\t\tSetBlend( ALPHABLEND )\r\n\t\tCase 1\r\n\t\t\tSetBlend( LIGHTBLEND )\r\n\tEnd Select\r\nEndFunction\r\n\r\nFunction BlitzMaxSetAlpha(a:Float)\r\n\tSetAlpha(a)\r\nEndFunction\r\n\r\nFunction BlitzMaxCls(r:Int = 0, g:Int = 0, b:Int = 0)\r\n\tSetClsColor(r, g, b)\r\n\tCls\r\nEndFunction\r\n\r\nType gxtkSurface\r\n\tField w:Int, h:Int\r\n\tField image:TImage\r\n\t\r\n\tMethod setImage(image:TImage)\r\n\t\tSelf.image = image\r\n\tEndMethod\r\n\t\r\n\tMethod Width:Int()\r\n\t\tReturn image.Width\r\n\tEndMethod\r\n\t\r\n\tMethod Height:Int()\r\n\t\tReturn image.Height\r\n\tEndMethod\r\n\t\r\n\tMethod Discard()\r\n\tEndMethod\r\nEndType\r\n\r\n' ***** End mojo.bmax.bmx ******\r\n\r\n","old_contents":"' ***** Start mojo.bmax.bmx ******\r\n\r\nGlobal app:gxtkApp;\r\n\r\nType gxtkApp\r\n\tField ginput:gxtkInput;\r\n\tField gaudio:gxtkAudio;\r\n\tField ggraphics:gxtkGraphics;\r\n\r\n\tField dead:Int=0;\r\n\tField suspended:Int=0;\r\n\tField vloading:Int=0;\r\n\tField maxloading:Int=0;\r\n\tField updateRate:Int=0;\r\n\tField nextUpdate:Float=0;\r\n\tField updatePeriod:Float=0;\r\n\tField startMillis:Float=0;\r\n\t\r\n\tMethod New()' gxtkApp()\r\n\t\tapp=Self;\r\n\t\tggraphics=New gxtkGraphics;\r\n\tEndMethod\r\n\t\r\n\tMethod Setup()\r\n\t\tginput=New gxtkInput;\r\n\t\tgaudio=New gxtkAudio;\r\n\r\n\t\tbb_input_SetInputDevice(ginput);\r\n\t\tbb_audio_SetAudioDevice(gaudio);\r\n\t\t\r\n\t\tstartMillis=BlitzMaxMillisecs()\r\n\t\t\r\n\t\tSetFrameRate( 0 );\r\n\t\t\r\n\t\tInvokeOnCreate();\r\n\t\tInvokeOnRender();\r\n\t\tUpdate()\r\n\tEndMethod\r\n\t\r\n\tMethod Update()\r\n\t\tWhile Not AppTerminate()\r\n\t\t\tLocal updates:Int = 0\r\n\t\t\t\r\n\t\t\tLocal cont:Int = 1\r\n\t\t\tWhile (cont)\r\n\t\t\t\tnextUpdate:+updatePeriod\r\n\t\t\t\tInvokeOnUpdate()\r\n\t\t\t\tIf Not updatePeriod Then cont = 0\r\n\t\t\t\tIf nextUpdate>BlitzMaxMillisecs() Then cont = 0\r\n\t\t\t\tupdates:+1\r\n\t\t\t\tIf updates = 7 Then\r\n\t\t\t\t\tnextUpdate = BlitzMaxMillisecs()\r\n\t\t\t\t\tcont = 0\r\n\t\t\t\tEndIf\r\n\t\t\tWend\r\n\t\t\tInvokeOnRender()\r\n\t\tWend\r\n\tEndMethod\r\n\t\r\n\tMethod InvokeOnCreate()\r\n\t\tIf dead Return\r\n\t\tdead = 1\r\n\t\tOnCreate()\r\n\t\tdead = 0\r\n\tEndMethod\r\n\r\n\tMethod InvokeOnUpdate()\r\n\t\tIf dead Or suspended Or Not updateRate Or vloading Return\r\n\t\tOnUpdate()\r\n\tEndMethod\r\n\t\r\n\tMethod InvokeOnRender()\r\n\t\tIf dead Or suspended Return\r\n\t\tggraphics.BeginRender()\r\n\t\tIf vloading\r\n\t\t\tOnLoading()\r\n\t\tElse\r\n\t\t\tOnRender()\r\n\t\tEndIf\r\n\t\tggraphics.EndRender()\r\n\tEndMethod\r\n\t\r\n\t\r\n\tMethod SetFrameRate( fps:Int )\r\n\t\tIf fps\r\n\t\t\tupdatePeriod=1000.0\/fps;\r\n\t\t\tnextUpdate=BlitzMaxMillisecs() +updatePeriod;\r\n\t\tElse\r\n\t\t\tupdatePeriod=0\r\n\t\tEndIf\r\n\tEndMethod\r\n\t\r\n\tMethod LoadString:String( path:String )\r\n\t\tpath = \"data\/\" + path;\r\n\t\tReturn LoadText( path )\r\n\tEndMethod\r\n\t\r\n\t' ***** GXTK API *****\r\n\t\r\n\tMethod GraphicsDevice:gxtkGraphics()\r\n\t\tReturn ggraphics\r\n\tEndMethod\r\n\r\n\tMethod InputDevice:gxtkInput()\r\n\t\tReturn ginput\r\n\tEndMethod\r\n\r\n\tMethod AudioDevice:gxtkAudio()\r\n\t\tReturn gaudio\r\n\tEndMethod\r\n\r\n\tMethod SetUpdateRate:Int(hertz:Int)\r\n\t\tupdateRate = hertz\r\n\t\tIf Not vloading Then SetFrameRate(updateRate)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod MilliSecs:Int()\r\n\t\tReturn BlitzMaxMillisecs() - startMillis\r\n\tEndMethod\r\n\t\r\n\tMethod Loading:Int()\r\n\t\tReturn vloading;\r\n\tEndMethod\r\n\r\n\tMethod OnCreate:Int()\r\n\t\tReturn 0;\r\n\tEndMethod\r\n\r\n\tMethod OnUpdate:Int()\r\n\t\tReturn 0;\r\n\tEndMethod\r\n\t\r\n\tMethod OnSuspend:Int()\r\n\t\tReturn 0;\r\n\tEndMethod\r\n\t\r\n\tMethod OnResume:Int()\r\n\t\tReturn 0;\r\n\tEndMethod\r\n\t\r\n\tMethod OnRender:Int()\r\n\t\tReturn 0;\r\n\tEndMethod\r\n\t\r\n\tMethod OnLoading:Int()\r\n\t\tReturn 0;\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkGraphics\r\n\tField gmode:Int = 1\r\n\r\n\tMethod Mode:Int()\r\n\t\tReturn gmode\r\n\tEndMethod\r\n\t\r\n\tMethod Cls:Int(r:Int = 0, g:Int = 0, b:Int = 0)\r\n\t\tBlitzMaxCls(r, g, b)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod LoadSurface:gxtkSurface(path:String)\r\n\t\tLocal image:TImage = LoadImage(\"data\/\"+path)\r\n\t\tIf image Then\r\n\t\t\tLocal gs:gxtkSurface = New gxtkSurface\r\n\t\t\tgs.setImage(image)\r\n\t\t\tReturn gs\r\n\t\tEndIf\r\n\t\tReturn Null\r\n\tEndMethod\r\n\t\r\n\tMethod BeginRender()\r\n\tEndMethod\r\n\t\r\n\tMethod EndRender()\r\n\t\tFlip\r\n\tEndMethod\r\n\t\r\n\tMethod SetColor:Int(r:Int, g:Int, b:Int)\r\n\t\tBlitzMaxSetColor(r, g, b)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod SetAlpha:Int(a:Float)\r\n\t\tBlitzMaxSetAlpha(a)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod SetBlend:Int(blend:Int)\r\n\t\tBlitzMaxSetBlend(blend)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod Width:Int()\r\n\t\t'TO-DO\r\n\t\tReturn 800\r\n\tEndMethod\r\n\t\r\n\tMethod Height:Int()\r\n\t\t'TO-DO\r\n\t\tReturn 480\r\n\tEndMethod\r\n\t\r\n\tMethod SetScissor:Int(x:Int, y:Int, w:Int, h:Int)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod SetMatrix:Int(ix:Float,iy:Float,jx:Float,jy:Float,tx:Float,ty:Float)\r\n\t\tLocal sx:Float = Sqr( (ix*ix) + (jx*jx) )\r\n\t\tLocal sy:Float = Sqr( (iy*iy) + (jy*jy) )\r\n\t\tLocal rot:Float = -Atan2( jx, ix )\r\n\t\tSetTransform( rot, sx, sy )\r\n\t\tSetOrigin( tx, ty )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawSurface:Int(surface:gxtkSurface,x:Float,y:Float)\r\n\t\tDrawImage(surface.image, x, y, 0)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawSurface2:Int(surface:gxtkSurface,x:Float,y:Float, srcx:Int, srcy:Int, srcw:Int, srch:Int )\r\n\t\tDrawSubImageRect(surface.image, x, y, srcw, srch, srcx, srcy, srcw, srch)\t\t\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawLine:Int( x1:Float,y1:Float,x2:Float,y2:Float )\r\n\t\tBlitzMaxDrawLine(x1, y1, x2, y2)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawOval:Int( x:Float, y:Float, w:Float, h:Float )\r\n\t\tBlitzMaxDrawOval(x, y, w, h)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawPoly:Int(vertices:Float[])\r\n\t\tBlitzMaxDrawPoly( vertices )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawRect:Int( x:Float, y:Float, w:Float, h:Float )\r\n\t\tBlitzMaxDrawRect(x, y, w, h)\r\n\t\tReturn 0\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkInput\r\n\tMethod MouseX:Float()\r\n\t\tReturn BRL.PolledInput.MouseX()\r\n\tEndMethod\r\n\r\n\tMethod MouseY:Float()\r\n\t\tReturn BRL.PolledInput.MouseY()\r\n\tEndMethod\r\n\t\r\n\tMethod KeyDown:Int( key:Int )\r\n\t\tIf( key >= 1 And key <= 3 )\r\n\t\t\tReturn BRL.PolledInput.MouseDown( key )\r\n\t\tEndIf\r\n\t\tReturn BRL.PolledInput.KeyDown( key )\r\n\tEndMethod\r\n\r\n\tMethod KeyHit:Int( key:Int )\r\n\t\tIf( key >= 1 And key <= 3 )\r\n\t\t\tReturn BRL.PolledInput.MouseHit( key )\r\n\t\tEndIf\r\n\t\tReturn BRL.PolledInput.KeyHit( key )\r\n\tEndMethod\r\n\r\n\tMethod GetChar:Int()\r\n\t\tReturn BRL.PolledInput.GetChar()\r\n\tEndMethod\r\n\r\n\tMethod JoyX:Int( index:Int )\r\n\t\tReturn Pub.FreeJoy.JoyX( index )\r\n\tEndMethod\r\n\r\n\tMethod JoyY:Int( index:Int )\r\n\t\tReturn Pub.FreeJoy.JoyY( index )\r\n\tEndMethod\r\n\r\n\tMethod JoyZ:Int( index:Int )\r\n\t\tReturn Pub.FreeJoy.JoyZ( index )\r\n\tEndMethod\r\n\r\n\tMethod TouchX:Float( index:Int )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod TouchY:Float( index:Int )\r\n\t\tReturn 0\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkChannel\r\n\tField channel:TChannel\t' null then not playing\r\n\tField sample:gxtkSample\r\n\tField loops:int\r\n\t'Field transform:SoundTransform=new SoundTransform()\r\n\t'Field pausepos:Number\r\n\tField state:int\r\n\t\r\n\tMethod New()\r\n\t\tchannel = New TChannel\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkAudio\r\n\tField amusicState:Int = 0;\r\n\tField channels:gxtkChannel[] = New gxtkChannel[33];\r\n\t\r\n\tMethod New()\r\n\t\tFor local i:Int = 0 To 33 - 1\r\n\t\t\tchannels[i] = New gxtkChannel\r\n\t\tNext\r\n\tEndMethod\r\n\t\r\n\tMethod MusicState:Int()\r\n'\t\tIf( musicState = 1 And music.isPlaying() = False )\r\n'\t\t\tmusicState = 0;\r\n'\t\tEndif\r\n\t\tReturn amusicState;\r\n\tEndMethod\r\n\t\r\n\tMethod PlayMusic:Int( path:String, flags:Int )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod StopMusic()\r\n\tEndMethod\r\n\t\r\n\tMethod StopChannel( channel:Int )\r\n\tEndMethod\r\n\r\n\tMethod PlaySample( sound:gxtkSample, channel:Int, flags:Int )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\t\r\n\t\t'If chan.state <> 0 Then chan.channel.Stop() <-- this crashes after the first play!?\r\n\t\t\r\n\t\tchan.sample = sound\r\n\t\t'chan.loops = flags ? 0x7fffffff : 0;\r\n\t\t'chan.channel = sample.sound.play( 0,chan.loops,chan.transform );\r\n\t\t'chan.channel = sound\r\n\t\tchan.state=1\r\n\t\r\n\t\tPlaySound( sound.sound, chan.channel )\r\n\tEndMethod\r\n\r\n\tMethod SetPan( channel:Int, pan:Float )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tchan.channel.SetPan(pan)\r\n\tEndMethod\r\n\r\n\tMethod SetRate( channel:Int, rate:Float )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tchan.channel.SetRate(rate)\r\n\tEndMethod\r\n\r\n\tMethod SetMusicVolume:Int( volume:Float )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod SetVolume:Int( channel:Int, volume:Float )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tchan.channel.SetVolume(volume)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod LoadSample:gxtkSample( path:String )\r\n\t\tLocal sound:TSound = LoadSound(\"data\/\"+path)\r\n\t\tIf sound Then\r\n\t\t\tLocal gs:gxtkSample = New gxtkSample\r\n\t\t\tgs.setSound(sound)\r\n\t\t\tReturn gs\r\n\t\tEndIf\r\n\t\tReturn Null\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkSample\r\n\tField sound:TSound\r\n\t\r\n\tMethod setSound(sound:TSound)\r\n\t\tSelf.sound = sound\r\n\tEndMethod\r\n\t\r\n\tMethod Discard()\r\n\t\tSelf.sound = null\r\n\tEndMethod\r\nEndType\r\n\r\nFunction BlitzMaxDrawPoly:Int(vertices:Float[])\r\n\tDrawPoly vertices\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxDrawRect:Int( x:Float, y:Float, w:Float, h:Float )\r\n\tDrawRect x, y, w, h\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxDrawOval:Int( x:Float, y:Float, w:Float, h:Float )\r\n\tDrawOval x, y, w, h\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxDrawLine:Int( x1:Float,y1:Float,x2:Float,y2:Float )\r\n\tDrawLine x1, y1, x2, y2\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxMillisecs:Int()\r\n\tReturn MilliSecs()\r\nEndFunction\r\n\r\nFunction BlitzMaxSetColor(r:Int, g:Int, b:Int)\r\n\tSetColor(r, g, b)\r\nEndFunction\r\n\r\nFunction BlitzMaxSetBlend(blend:Int)\r\n\tSelect blend\r\n\t\tCase 0\r\n\t\t\tSetBlend( ALPHABLEND )\r\n\t\tCase 1\r\n\t\t\tSetBlend( LIGHTBLEND )\r\n\tEnd Select\r\nEndFunction\r\n\r\nFunction BlitzMaxSetAlpha(a:Float)\r\n\tSetAlpha(a)\r\nEndFunction\r\n\r\nFunction BlitzMaxCls(r:Int = 0, g:Int = 0, b:Int = 0)\r\n\tSetClsColor(r, g, b)\r\n\tCls\r\nEndFunction\r\n\r\nType gxtkSurface\r\n\tField w:Int, h:Int\r\n\tField image:TImage\r\n\t\r\n\tMethod setImage(image:TImage)\r\n\t\tSelf.image = image\r\n\tEndMethod\r\n\t\r\n\tMethod Width:Int()\r\n\t\tReturn image.Width\r\n\tEndMethod\r\n\t\r\n\tMethod Height:Int()\r\n\t\tReturn image.Height\r\n\tEndMethod\r\n\t\r\n\tMethod Discard()\r\n\tEndMethod\r\nEndType\r\n\r\n' ***** End mojo.bmax.bmx ******\r\n\r\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"48f23be997494556430d9b6d6239f7588e4c396e","subject":"Added a check to see if the TMap that's being passed to TXMLRPC_Response_Data.DebugData() is set","message":"Added a check to see if the TMap that's being passed to TXMLRPC_Response_Data.DebugData() is set\n","repos":"Htbaa\/xmlrpc.mod,Htbaa\/xmlrpc.mod,Htbaa\/xmlrpc.mod,Htbaa\/xmlrpc.mod,Htbaa\/xmlrpc.mod","old_file":"response.bmx","new_file":"response.bmx","new_contents":"Rem\n\tbbdoc: Exception for TXMLRPC_Response_Data\nEnd Rem\nType TXMLRPC_Response_Data_Exception Extends TXMLRPC_Exception\nEnd Type\n\nRem\n\tbbdoc: Data returned from XML-RPC server\nEnd Rem\nType TXMLRPC_Response_Data\n\tRem\n\t\tbbdoc: This field contains all data returned from a response. If a response value was given an ID it can be accessed by its ID. If not it can be accessed with an ID of 0..inf\n\tEnd Rem\n\tField data:TMap\n\t\n\tRem\n\t\tbbdoc: Create a TXMLRPC_Response_Data object by passing the response XML message and the output options.\n\tEnd Rem\n\tMethod Create:TXMLRPC_Response_Data(xmlMessage:String, options:Byte Ptr)\n\t\tLocal message:Byte Ptr = xmlMessage.ToCString()\n\t\tLocal request:Byte Ptr = XMLRPC_REQUEST_FromXML(message, 0, options)\n\n\t\tLocal el:Byte Ptr = XMLRPC_RequestGetData(request)\n\n\t\tSelf.data = TXMLRPC_Response_Data.IterateVector(el)\n\n\t\tMemFree(message)\n\t\t\n\t\tLocal freeIo:Int = 1\n\t\t'Apparently a unhandled memory exception error gets thrown when\n\t\t'xmlMessage only contained 1 value and XMLRPC_RequestFree also\n\t\t'frees the response data.\n\t\tIf Not XMLRPC_VectorRewind(el) Then freeIo = 0\n\t\t\n\t\tXMLRPC_RequestFree(request, freeIo)\n\t\t\n\t\tReturn Self\n\tEnd Method\n\n\tRem\n\t\tbbdoc: Iterate over an XMLRPC vector and add it to a TMap. Private function\n\tEnd Rem\t\n\tFunction IterateVector:TMap(el:Byte Ptr)\n\t\tLocal data:TMap = New TMap\n\n\t\tIf el\n\t\t\t'Rewind vector\n\t\t\tLocal itr:Byte Ptr = XMLRPC_VectorRewind(el)\n\t\t\tIf Not itr\n\t\t\t\tLocal cStr:Byte Ptr = XMLRPC_GetValueID(el)\n\t\t\t\tLocal id:String = \"0\"\n\t\t\t\tIf cStr\n\t\t\t\t\tid = String.FromCString(cStr)\n\t\t\t\t\tXMLRPC_Free(cstr)\n\t\t\t\tEnd If\n\n\t\t\t\tdata.Insert(id, TXMLRPC_Value_Abstract.XMLRPC_To_BlizMax(el))\n\t\t\tElse\n\t\t\t\tLocal dataCounter:Int = 0\n\t\t\t\tWhile itr\n\t\t\t\t\tLocal cStr:Byte Ptr = XMLRPC_GetValueID(itr)\n\t\t\t\t\tLocal id:String = String.FromCString(cStr)\n\t\t\t\t\t\n\t\t\t\t\tIf id.Length = 0\n\t\t\t\t\t\tid = String.FromInt(dataCounter)\n\t\t\t\t\t\tdataCounter:+1\n\t\t\t\t\tEnd If\n\n\t\t\t\t\tdata.Insert(id, TXMLRPC_Value_Abstract.XMLRPC_To_BlizMax(itr))\n\t\t\t\t\tXMLRPC_Free(cStr)\n\n\t\t\t\t\t'Next element\n\t\t\t\t\titr = XMLRPC_VectorNext(el)\n\t\t\t\tWend\n\t\t\tEnd If\n\t\tEnd If\n\t\t\n\t\tReturn data\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Helper function to show what's inside the map\n\tEnd Rem\n\tFunction DebugData:String(map:TMap, pad:Int Var)\n\t\tLocal str:String\n\t\tLocal prefix:String\n\t\tFor Local i:Int = 0 To pad\n\t\t\tprefix:+\"-\"\n\t\tNext\n\t\t\n\t\tIf map\t\n\t\t\tFor Local val:TXMLRPC_Value_Abstract = EachIn map.Values()\n\t\t\t\tstr:+prefix + \" \" + TTypeId.ForObject(val).Name() + \" (\" + val.name + \") = \" + val.ToString() + \"~n\"\n\t\t\t\tIf TXMLRPC_Value_Collection(val)\n\t\t\t\t\tpad:+1\n\t\t\t\t\tstr:+TXMLRPC_Response_Data.DebugData(TXMLRPC_Value_Collection(val).data, pad) + \"~n\"\n\t\t\t\t\tpad:-1\n\t\t\t\tEnd If\n\t\t\tNext\n\t\tEnd If\n\t\tReturn str\n\tEnd Function\nEnd Type\n","old_contents":"Rem\n\tbbdoc: Exception for TXMLRPC_Response_Data\nEnd Rem\nType TXMLRPC_Response_Data_Exception Extends TXMLRPC_Exception\nEnd Type\n\nRem\n\tbbdoc: Data returned from XML-RPC server\nEnd Rem\nType TXMLRPC_Response_Data\n\tRem\n\t\tbbdoc: This field contains all data returned from a response. If a response value was given an ID it can be accessed by its ID. If not it can be accessed with an ID of 0..inf\n\tEnd Rem\n\tField data:TMap\n\t\n\tRem\n\t\tbbdoc: Create a TXMLRPC_Response_Data object by passing the response XML message and the output options.\n\tEnd Rem\n\tMethod Create:TXMLRPC_Response_Data(xmlMessage:String, options:Byte Ptr)\n\t\tLocal message:Byte Ptr = xmlMessage.ToCString()\n\t\tLocal request:Byte Ptr = XMLRPC_REQUEST_FromXML(message, 0, options)\n\n\t\tLocal el:Byte Ptr = XMLRPC_RequestGetData(request)\n\n\t\tSelf.data = TXMLRPC_Response_Data.IterateVector(el)\n\n\t\tMemFree(message)\n\t\t\n\t\tLocal freeIo:Int = 1\n\t\t'Apparently a unhandled memory exception error gets thrown when\n\t\t'xmlMessage only contained 1 value and XMLRPC_RequestFree also\n\t\t'frees the response data.\n\t\tIf Not XMLRPC_VectorRewind(el) Then freeIo = 0\n\t\t\n\t\tXMLRPC_RequestFree(request, freeIo)\n\t\t\n\t\tReturn Self\n\tEnd Method\n\n\tRem\n\t\tbbdoc: Iterate over an XMLRPC vector and add it to a TMap. Private function\n\tEnd Rem\t\n\tFunction IterateVector:TMap(el:Byte Ptr)\n\t\tLocal data:TMap = New TMap\n\n\t\tIf el\n\t\t\t'Rewind vector\n\t\t\tLocal itr:Byte Ptr = XMLRPC_VectorRewind(el)\n\t\t\tIf Not itr\n\t\t\t\tLocal cStr:Byte Ptr = XMLRPC_GetValueID(el)\n\t\t\t\tLocal id:String = \"0\"\n\t\t\t\tIf cStr\n\t\t\t\t\tid = String.FromCString(cStr)\n\t\t\t\t\tXMLRPC_Free(cstr)\n\t\t\t\tEnd If\n\n\t\t\t\tdata.Insert(id, TXMLRPC_Value_Abstract.XMLRPC_To_BlizMax(el))\n\t\t\tElse\n\t\t\t\tLocal dataCounter:Int = 0\n\t\t\t\tWhile itr\n\t\t\t\t\tLocal cStr:Byte Ptr = XMLRPC_GetValueID(itr)\n\t\t\t\t\tLocal id:String = String.FromCString(cStr)\n\t\t\t\t\t\n\t\t\t\t\tIf id.Length = 0\n\t\t\t\t\t\tid = String.FromInt(dataCounter)\n\t\t\t\t\t\tdataCounter:+1\n\t\t\t\t\tEnd If\n\n\t\t\t\t\tdata.Insert(id, TXMLRPC_Value_Abstract.XMLRPC_To_BlizMax(itr))\n\t\t\t\t\tXMLRPC_Free(cStr)\n\n\t\t\t\t\t'Next element\n\t\t\t\t\titr = XMLRPC_VectorNext(el)\n\t\t\t\tWend\n\t\t\tEnd If\n\t\tEnd If\n\t\t\n\t\tReturn data\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Helper function to show what's inside the map\n\tEnd Rem\n\tFunction DebugData:String(map:TMap, pad:Int Var)\n\t\tLocal str:String\n\t\tLocal prefix:String\n\t\tFor Local i:Int = 0 To pad\n\t\t\tprefix:+\"-\"\n\t\tNext\n\t\t\n\t\tFor Local val:TXMLRPC_Value_Abstract = EachIn map.Values()\n\t\t\tstr:+prefix + \" \" + TTypeId.ForObject(val).Name() + \" (\" + val.name + \") = \" + val.ToString() + \"~n\"\n\t\t\tIf TXMLRPC_Value_Collection(val)\n\t\t\t\tpad:+1\n\t\t\t\tstr:+TXMLRPC_Response_Data.DebugData(TXMLRPC_Value_Collection(val).data, pad) + \"~n\"\n\t\t\t\tpad:-1\n\t\t\tEnd If\n\t\tNext\n\t\tReturn str\n\tEnd Function\nEnd Type\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"46d9a2af04e870a2242a81d73d6a8a6566f198c3","subject":"explicit access to _ENV","message":"explicit access to _ENV\n","repos":"Leushenko\/blue-moon","old_file":"bluefoldsemantics.bmx","new_file":"bluefoldsemantics.bmx","new_contents":"\n' Blue Moon\n' FOLD delegates to analyze semantics (build function and variable tables, check for semantic errors)\n\n' this file is a Private Include\n\n'SuperStrict\n\n'Import \"blueerror.bmx\"\n'Import \"TFold.bmx\"\n\n\n' this module folds through the AST to extract function bodies and resolve references to variables and labels\n' local variables are replaced by references to their location in the function's local table (not their stack\n' position, which they hold internally - two variables on the same stack pos may not be identical yet)\n' closure variables are replaced by references to their location in the function's closure table\n\n\nType SemanticFold\n\tField funs:TList, _ft:TList, fcount:Int, tbl:TMap\n\t\n\tFunction Make:SemanticFold(root:Node, tbl:NodeTable)\n\t\tLocal f:SemanticFold = New SemanticFold\n\t\tf.funs = CreateList() ; f._ft = CreateList() ; f.tbl = tbl.leaves\n\t\tFunDef.Toplevel(root, f)\n\t\tReturn f\n\tEnd Function\n\tFunction Close(semf:SemanticFold, r:Node)\n\t\tLocal toplevel:FunDef = FunDef(semf.funs.First())\n\t\ttoplevel.Close(Rose.Make(\"FuncBody\", [Node(Rose.Make(\"NameList\", Null, Null)), r], [\"param\", \"body\"]), semf)\n\tEnd Function\n\t\n\tMethod FuncBody:Node(n:Rose)\t'Add function definition to global list\n\t\tLocal f:FunDef = FunDef.Make(n, Self), params:Rose = Rose(n.arg[0]), pa:Node[] = params.arg[..]\n\t\tIf pa Then f.hasVarargs = (pa[pa.Length - 1].key = \"dotdotdot\")\n\t\tf.vars = New VarDef[pa.Length]\n\t\tFor Local p:Int = 0 Until pa.Length\t'add parameters\n\t\t\tLocal par:Leaf = Leaf(pa[p])\n\t\t\tpa[p] = Leaf.Make(\"param\", par.val)\n\t\t\tIf par.key = \"name\"\n\t\t\t\tf.vars[p] = f.AddVar(par, Self)\n\t\t\tElse\t'drop the ...\n\t\t\t\tpa = pa[..pa.Length - 1] ; f.vars = f.vars[..pa.Length] ; Exit\n\t\t\tEndIf\n\t\tNext\n\t\tf.pcount = pa.Length\n\t\tReturn Rose.Make(n.key, [Node(Rose.Make(params.key, pa)), n.arg[1]], n.id)\n\tEnd Method\n\tMethod FuncBody2:Node(n:Rose)\t'extract body and pop env\n\t\tLocal f:FunDef = FunDef(_ft.RemoveFirst()), env:FunDef = FunDef(_ft.First())\n\t\tf.Close(n, Self)\n\t\tFor Local c:VarDef = EachIn f.clos\n\t\t\tIf Not env._vt.Contains(c) Then env.AddClos(c)\t'make sure all closures are one-level at most\n\t\tNext\n\t\tReturn RefLeaf.Make(\"funref\", NumToStr(f.id))\n\tEnd Method\n\t\n\tMethod Block:Node(n:Rose)\t'enter a scope level\n\t\tLocal f:FunDef = FunDef(_ft.First()) ; f._ev.AddFirst n\n\t\tReturn n\n\tEnd Method\n\tMethod Block2:Node(n:Rose)\t'exit a scope level\n\t\tLocal f:FunDef = FunDef(_ft.First()), n2:Node = Node(f._ev.RemoveFirst()) ; f.CloseBlock n2, Self\t'note that n itself cannot be tested for equality\n\t\tReturn n\n\tEnd Method\n\t\n\tMethod RepeatS:Node(n:Rose)\t'repeat scope extends to the end of the test, need to put that inside it (never need to remove it, either)\n\t\tLocal blk:Rose = Rose.Make(n.arg[0].key, Rose(n.arg[0]).arg + [n.arg[1]])\n\t\tReturn Rose.Make(n.key, [blk])\n\tEnd Method\n\t\n\t'for loops are now replaced during normalization\n'\tMethod ForN:Node(n:Rose) { ForIn }\t'for loops create scope blocks with variables\n'\t\tLocal blk:Node = n.Get(\"block\")\n'\t\tLocal f:FunDef = FunDef(_ft.First()) ; f._ev.AddFirst blk\n'\t\tIf n.key = \"ForN\"\n'\t\t\tLocal arg:Node[] = n.arg[..], v:VarDef = f.AddVar(Leaf(arg[0]), Self)\n'\t\t\targ[0] = RefLeaf.Make(\"l_varref\", NumToStr(v.uid))\n'\t\t\tn = Rose.Make(n.key, arg, n.id)\n'\t\tElse\n'\t\t\tLocal arg:Node[] = Rose(n.arg[0]).arg[..]\n'\t\t\tFor Local i:Int = 0 Until arg.Length\n'\t\t\t\tLocal v:VarDef = f.AddVar(Leaf(arg[i]), Self)\n'\t\t\t\targ[i] = RefLeaf.Make(\"l_varref\", NumToStr(v.uid))\n'\t\t\tNext\n'\t\t\tn = Rose.Make(n.key, [Node(Rose.Make(n.arg[0].key, arg, Null))] + n.arg[1..], n.id)\n'\t\tEndIf\n'\t\tReturn n\n'\tEnd Method\n'\tMethod ForN2:Node(n:Rose) { ForIn2 }\t'pop the scope\n'\t\tLocal f:FunDef = FunDef(_ft.First()) ; f._ev.RemoveFirst()\n'\t\tReturn n\n'\tEnd Method\n\t\n\tMethod LocalVar:Node(n:Rose)\t'prevent declared names from getting in the way\n\t\tLocal vars:Node[] = Rose(n.arg[0]).arg[..]\n\t\tFor Local i:Int = 0 Until vars.Length\n\t\t\tLocal t:Object = tbl.ValueForKey(vars[i]) ; tbl.Remove(vars[i])\t'need to replace nodes in the err table if they're still potential error points\n\t\t\tvars[i] = Leaf.Make(\"lname\", Leaf(vars[i]).val)\n\t\t\ttbl.Insert(vars[i], t)\n\t\tNext\n\t\tReturn Rose.Make(n.key, [Node(Rose.Make(\"VarList\", vars)), n.arg[1]], n.id)\n\tEnd Method\n\tMethod LocalVar2:Node(n:Rose)\t'define vars on the way back up\n\t\tLocal vars0:Node[] = Rose(n.arg[0]).arg, vars:Node[vars0.Length], vr:Node = Rose.Make(\"VarList\", vars)\n\t\tFor Local i:Int = 0 Until vars.Length\n\t\t\tLocal v:VarDef = FunDef(_ft.First()).AddVar(Leaf(vars0[i]), Self)\t'notice we only add the name on the way back up\n\t\t\tvars[vars.Length - (i + 1)] = RefLeaf.Make(\"l_varref\", NumToStr(v.uid))\t'proceed backward to reflect stack discipline\n\t\tNext\n\t\tReturn Rose.Make(n.key, [n.arg[1], vr], [\"vals\", \"vars\"])\t'swap vars and vals so vals are evaluated first\n\tEnd Method\n\t\n\tMethod Assgt2:Node(n:Rose)\t'convert lvalue keys to indicate different action\n\t\tLocal vars0:Node[] = Rose(n.arg[0]).arg, vars:Node[vars0.Length], vr:Node = Rose.Make(\"VarList\", vars)\n\t\tFor Local v:Int = 0 Until vars0.Length\n\t\t\tvars0[v].key = \"l_\" + vars0[v].key ; vars[vars.Length - (v + 1)] = vars0[v]\n\t\tNext\n\t\tReturn Rose.Make(n.key, [n.arg[1], vr], [\"vals\", \"vars\"])\t'swap, as above\n\tEnd Method\n\t\n\tMethod name:Node(n:Leaf)\t'var ref\n\t\tFunction getvar:VarDef(_ft:TList, n:String)\n\t\t\tFor Local f:FunDef = EachIn _ft\n\t\t\t\tFor Local v:VarDef = EachIn f._vt\n\t\t\t\t\tIf v.name = n\n\t\t\t\t\t\tIf f <> _ft.First() Then v.isClosure = True\n\t\t\t\t\t\tReturn v\n\t\t\t\t\tEndIf\n\t\t\t\tNext\n\t\t\t\tFor Local v:VarDef = EachIn f._ct\n\t\t\t\t\tIf v.name = n Then Return v\n\t\t\t\tNext\n\t\t\tNext\n\t\tEnd Function\n\t\tLocal v:VarDef = getvar(_ft, n.val), f:FunDef = FunDef(_ft.First()) ; If v\n\t\t\tIf v.isClosure\n\t\t\t\tLocal id:Int = f.AddClos(v)\t'add to the list of closure vars to retain\n\t\t\t\tReturn RefLeaf.Make(\"closref\", NumToStr(id))\n\t\t\tElse\n\t\t\t\tReturn RefLeaf.Make(\"varref\", NumToStr(v.uid))\n\t\t\tEndIf\n\t\tElse\t'free, i.e. _ENV.n\n\t\t\tv = getvar(_ft, \"_ENV\")\n\t\t\tLocal id:Int = f.AddClos(v), env:Node = RefLeaf.Make(\"closref\", NumToStr(id)), name:Node = Leaf.Make(\"fname\", n.val)\n\t\t\tReturn Rose.Make(\"getfield\", [env, name], Null)\n\t\tEndIf\n\tEnd Method\n\tMethod fcall:Node(n:Rose) { mcall pfcall pmcall tfcall tmcall va_fcall va_mcall }\t'count arguments to function calls\n\t\tLocal ac:Int\n\t\tSelect n.key\n\t\t\tCase \"fcall\", \"pfcall\", \"tfcall\", \"va_fcall\"\n\t\t\t\tac = Rose(n.arg[1]).arg.Length\n\t\t\tDefault\t'*mcall\n\t\t\t\tac = Rose(Rose(n.arg[1]).arg[1]).arg.Length\n\t\tEnd Select\n\t\tReturn Rose.Make(n.key, n.arg + [Leaf.Make(\"acount\", ac)], Null)\n\tEnd Method\n\t\n\tMethod Label:Node(n:Leaf) { GotoS }\t'jump or dest\n\t\tLocal f:FunDef = FunDef(_ft.First()), val:Int\n\t\tIf n.key = \"Label\" Then val = f.AddLabel(n, Self) Else val = f.AddGoto(n)\n\t\tReturn RefLeaf.Make(n.key, NumToStr(val))\n\tEnd Method\n\t\n\tMethod ReturnS2:Node(n:Rose)\t'detect and mark tail calls (on the way up to give the call a chance to process)\n\t\tIf n.arg.Length = 1\n\t\t\tLocal k:String = n.arg[0].key, c:Rose = Rose(n.arg[0])\n\t\t\tIf k = \"fcall\" Or k = \"mcall\"\n\t\t\t\tReturn Rose.Make(\"t\" + k, c.arg, c.id)\n\t\t\tElseIf k = \"dotdotdot\"\n\t\t\t\tReturn Leaf.Make(\"return_va\", \"...\")\n\t\t\tEndIf\n\t\tEndIf\n\t\tReturn n\n\tEnd Method\nEnd Type\n\nType FunDef\n\tField n:Node, id:Int, env:FunDef\n\tField vars:VarDef[], clos:VarDef[], pcount:Int, stksz:Int, vmax:Int, vcount:Int, hasVarargs:Int\n\tField _ev:TList, _vt:TList, _ct:TList, _lt:TList, _gt:TList\n\t\n\tFunction Make:FunDef(blk:Node, in:SemanticFold)\n\t\tLocal f:FunDef = New FunDef\n\t\tf.env = FunDef(in._ft.First())\n\t\tf._vt = CreateList() ; f._ev = CreateList() ; f._ct = CreateList() ; f._lt = CreateList() ; f._gt = CreateList()\n\t\tin.funs.AddLast f ; in._ft.AddFirst f\n\t\tf.id = in.fcount ; in.fcount :+ 1\n\t\tReturn f\n\tEnd Function\n\tFunction Toplevel:FunDef(root:Node, in:SemanticFold)\t'create a chunk toplevel as a function whose sole parameter is _ENV\n\t\tLocal f:FunDef = FunDef.Make(root, in), env:VarDef = VarDef.Make(\"_ENV\", Null, 0, 0, -1)\n\t\tenv.isClosure = True ; f._ct.AddLast env ; Return f\n\tEnd Function\n\tMethod AddVar:VarDef(n:Leaf, in:SemanticFold)\n\t\tLocal blk:Node = Node(_ev.First()), v:VarDef\n\t\tFor v = EachIn _vt\n\t\t\tIf v.blk <> blk Then Exit\t'the error here doesn't actually apply in standard Lua\n\t\t'\tIf v.name = n.val Then Throw CompileError.Make(TToken(in.tbl.ValueForKey(n)), \"duplicate local variable '\" + n.val + \"'\")\n\t\tNext\n\t\tv = VarDef.Make(n.val, blk, stksz, vcount, id) ; vcount :+ 1\n\t\t_vt.AddFirst v ; stksz :+ 1 ; Return v\n\tEnd Method\n\tMethod AddClos:Int(v:VarDef)\n\t\tLocal c:Int\n\t\tFor Local e:VarDef = EachIn _ct\n\t\t\tIf v = e Then Return c Else c :+ 1\n\t\tNext\n\t\t_ct.AddLast v ; Return c\n\tEnd Method\n\tMethod AddLabel:Int(n:Leaf, in:SemanticFold)\n\t\tLocal l:LabelDef = New LabelDef ; l.name = n.val ; l.depth = _ev.Count() ; l.varsvisible = stksz\n\t\tFor Local ln:LabelDef = EachIn _lt\n\t\t\tIf ln.depth = l.depth And ln.name = l.name Then Throw BlueCompileError.Make(TToken(in.tbl.ValueForKey(n)), \"duplicate label '::\" + n.val + \"::'\")\n\t\tNext\n\t\t_lt.AddLast l ; Return _lt.Count() - 1\n\tEnd Method\n\tMethod AddGoto:Int(n:Leaf)\n\t\tLocal g:GotoDef = New GotoDef ; g.name = n.val ; g.depth = _ev.Count() ; g.varsvisible = stksz ; g._n = n\n\t\t_gt.AddLast g ; Return _gt.Count() - 1\n\tEnd Method\n\tMethod ResolveGotos(in:SemanticFold)\n\t\tFunction cmp:Int(l:Object, r:Object)\n\t\t\tIf LabelDef(l).depth > LabelDef(r).depth Return 1 ElseIf LabelDef(l).depth < LabelDef(r).depth Return -1 Else Return 0\n\t\tEnd Function\n\t\t_lt.Sort True, cmp\n\t\tFor Local g:GotoDef = EachIn _gt\n\t\t\tLocal l:LabelDef = Null\n\t\t\tFor Local _l:LabelDef = EachIn _lt\n\t\t\t\tIf g.depth < _l.depth Then Exit\n\t\t\t\tIf g.name = _l.name Then l = _l ; Exit\n\t\t\tNext\n\t\t\tIf l\n\t\t\t\tg.tgt = l ; g._n = Null\n\t\t\tElse\n\t\t\t\tThrow BlueCompileError.Make(TToken(in.tbl.ValueForKey(g._n)), \"label '::\" + g._n.val + \"::' not visible in scope\")\n\t\t\tEndIf\n\t\tNext\n\tEnd Method\n\tMethod CloseBlock(n:Node, in:SemanticFold)\n\t\tvmax = Max(vmax, stksz)\n\t\tLocal c:Int = 0, oldLen:Int = vars.Length\n\t\tFor Local v:VarDef = EachIn _vt\n\t\t\tIf v.blk <> n Then Exit\n\t\t\tc :+ 1 ; v.blk = Null\t'noretain\n\t\tNext\n\t\tvars = New VarDef[c] + vars\n\t\tFor Local i:Int = 0 Until c\n\t\t\tvars[i] = VarDef(_vt.RemoveFirst())\t'pop contained vars\n\t\tNext\n\t\tstksz :- c\n\tEnd Method\n\tMethod Close(_n:Node, in:SemanticFold)\n\t\tn = _n ; clos = VarDef[](_ct.ToArray()) ; ResolveGotos in\n\t\tLocal v2:VarDef[] = New VarDef[vars.Length]\t\t'vars aren't in the right order due to params, sort by uid\n\t\tFor Local vi:Int = 0 Until v2.Length\n\t\t\tLocal v:VarDef = vars[vi] ; v2[v.uid] = v\n\t\tNext\n\t\tvars = v2\n\t\t_vt = Null ; _ev = Null ; _ct = Null '; _lt = Null ; _gt = Null\n\tEnd Method\nEnd Type\n\nType VarDef\n\tField name:String, blk:Node, isClosure:Int, stkpos:Int, uid:Int, fid:Int\n\tFunction Make:VarDef(n:String, b:Node, stkpos:Int, uid:Int, fid:Int)\n\t\tLocal v:VarDef = New VarDef ; v.name = n ; v.stkpos = stkpos ; v.uid = uid ; v.fid = fid ; v.blk = b ; Return v\n\tEnd Function\nEnd Type\n\nType LabelDef\n\tField name:String, depth:Int, varsvisible:Int, insl:TLink, insc:Int = -1\nEnd Type\n\nType GotoDef\n\tField name:String, depth:Int, varsvisible:Int, _n:Leaf, tgt:LabelDef', op:Object\nEnd Type\n\n\nType RefLeaf Extends Leaf\n\tFunction Make:Leaf(key:String, val:String)\n\t\tLocal l:Leaf = New RefLeaf\n\t\tl.key = key ; l.val = val\n\t\tReturn l\n\tEnd Function\n\tMethod ToString:String()\n\t\tReturn \"{ '#\" + StrToNum(val) + \"' : \" + key + \" }\"\n\tEnd Method\nEnd Type\nFunction StrToNum:Int(s:String)\n\tReturn s[0] | (s[1] Shl 8) | (s[2] Shl 16) | (s[3] Shl 24)\nEnd Function\nFunction NumToStr:String(n:Int)\n\tReturn Chr(n & $FF) + Chr((n & $FF00) Shr 8) + Chr((n & $FF0000) Shr 16) + Chr((n & $FF000000) Shr 24)\nEnd Function\n\n\n","old_contents":"\n' Blue Moon\n' FOLD delegates to analyze semantics (build function and variable tables, check for semantic errors)\n\n' this file is a Private Include\n\n'SuperStrict\n\n'Import \"blueerror.bmx\"\n'Import \"TFold.bmx\"\n\n\n' this module folds through the AST to extract function bodies and resolve references to variables and labels\n' local variables are replaced by references to their location in the function's local table (not their stack\n' position, which they hold internally - two variables on the same stack pos may not be identical yet)\n' closure variables are replaced by references to their location in the function's closure table\n\n\nType SemanticFold\n\tField funs:TList, _ft:TList, fcount:Int, tbl:TMap\n\t\n\tFunction Make:SemanticFold(root:Node, tbl:NodeTable)\n\t\tLocal f:SemanticFold = New SemanticFold\n\t\tf.funs = CreateList() ; f._ft = CreateList() ; f.tbl = tbl.leaves\n\t\tFunDef.Toplevel(root, f)\n\t\tReturn f\n\tEnd Function\n\tFunction Close(semf:SemanticFold, r:Node)\n\t\tLocal toplevel:FunDef = FunDef(semf.funs.First())\n\t\ttoplevel.Close(Rose.Make(\"FuncBody\", [Node(Rose.Make(\"NameList\", Null, Null)), r], [\"param\", \"body\"]), semf)\n\tEnd Function\n\t\n\tMethod FuncBody:Node(n:Rose)\t'Add function definition to global list\n\t\tLocal f:FunDef = FunDef.Make(n, Self), params:Rose = Rose(n.arg[0]), pa:Node[] = params.arg[..]\n\t\tIf pa Then f.hasVarargs = (pa[pa.Length - 1].key = \"dotdotdot\")\n\t\tf.vars = New VarDef[pa.Length]\n\t\tFor Local p:Int = 0 Until pa.Length\t'add parameters\n\t\t\tLocal par:Leaf = Leaf(pa[p])\n\t\t\tpa[p] = Leaf.Make(\"param\", par.val)\n\t\t\tIf par.key = \"name\"\n\t\t\t\tf.vars[p] = f.AddVar(par, Self)\n\t\t\tElse\t'drop the ...\n\t\t\t\tpa = pa[..pa.Length - 1] ; f.vars = f.vars[..pa.Length] ; Exit\n\t\t\tEndIf\n\t\tNext\n\t\tf.pcount = pa.Length\n\t\tReturn Rose.Make(n.key, [Node(Rose.Make(params.key, pa)), n.arg[1]], n.id)\n\tEnd Method\n\tMethod FuncBody2:Node(n:Rose)\t'extract body and pop env\n\t\tLocal f:FunDef = FunDef(_ft.RemoveFirst()), env:FunDef = FunDef(_ft.First())\n\t\tf.Close(n, Self)\n\t\tFor Local c:VarDef = EachIn f.clos\n\t\t\tIf Not env._vt.Contains(c) Then env.AddClos(c)\t'make sure all closures are one-level at most\n\t\tNext\n\t\tReturn RefLeaf.Make(\"funref\", NumToStr(f.id))\n\tEnd Method\n\t\n\tMethod Block:Node(n:Rose)\t'enter a scope level\n\t\tLocal f:FunDef = FunDef(_ft.First()) ; f._ev.AddFirst n\n\t\tReturn n\n\tEnd Method\n\tMethod Block2:Node(n:Rose)\t'exit a scope level\n\t\tLocal f:FunDef = FunDef(_ft.First()), n2:Node = Node(f._ev.RemoveFirst()) ; f.CloseBlock n2, Self\t'note that n itself cannot be tested for equality\n\t\tReturn n\n\tEnd Method\n\t\n\tMethod RepeatS:Node(n:Rose)\t'repeat scope extends to the end of the test, need to put that inside it (never need to remove it, either)\n\t\tLocal blk:Rose = Rose.Make(n.arg[0].key, Rose(n.arg[0]).arg + [n.arg[1]])\n\t\tReturn Rose.Make(n.key, [blk])\n\tEnd Method\n\t\n\t'for loops are now replaced during normalization\n'\tMethod ForN:Node(n:Rose) { ForIn }\t'for loops create scope blocks with variables\n'\t\tLocal blk:Node = n.Get(\"block\")\n'\t\tLocal f:FunDef = FunDef(_ft.First()) ; f._ev.AddFirst blk\n'\t\tIf n.key = \"ForN\"\n'\t\t\tLocal arg:Node[] = n.arg[..], v:VarDef = f.AddVar(Leaf(arg[0]), Self)\n'\t\t\targ[0] = RefLeaf.Make(\"l_varref\", NumToStr(v.uid))\n'\t\t\tn = Rose.Make(n.key, arg, n.id)\n'\t\tElse\n'\t\t\tLocal arg:Node[] = Rose(n.arg[0]).arg[..]\n'\t\t\tFor Local i:Int = 0 Until arg.Length\n'\t\t\t\tLocal v:VarDef = f.AddVar(Leaf(arg[i]), Self)\n'\t\t\t\targ[i] = RefLeaf.Make(\"l_varref\", NumToStr(v.uid))\n'\t\t\tNext\n'\t\t\tn = Rose.Make(n.key, [Node(Rose.Make(n.arg[0].key, arg, Null))] + n.arg[1..], n.id)\n'\t\tEndIf\n'\t\tReturn n\n'\tEnd Method\n'\tMethod ForN2:Node(n:Rose) { ForIn2 }\t'pop the scope\n'\t\tLocal f:FunDef = FunDef(_ft.First()) ; f._ev.RemoveFirst()\n'\t\tReturn n\n'\tEnd Method\n\t\n\tMethod LocalVar:Node(n:Rose)\t'prevent declared names from getting in the way\n\t\tLocal vars:Node[] = Rose(n.arg[0]).arg[..]\n\t\tFor Local i:Int = 0 Until vars.Length\n\t\t\tLocal t:Object = tbl.ValueForKey(vars[i]) ; tbl.Remove(vars[i])\t'need to replace nodes in the err table if they're still potential error points\n\t\t\tvars[i] = Leaf.Make(\"lname\", Leaf(vars[i]).val)\n\t\t\ttbl.Insert(vars[i], t)\n\t\tNext\n\t\tReturn Rose.Make(n.key, [Node(Rose.Make(\"VarList\", vars)), n.arg[1]], n.id)\n\tEnd Method\n\tMethod LocalVar2:Node(n:Rose)\t'define vars on the way back up\n\t\tLocal vars0:Node[] = Rose(n.arg[0]).arg, vars:Node[vars0.Length], vr:Node = Rose.Make(\"VarList\", vars)\n\t\tFor Local i:Int = 0 Until vars.Length\n\t\t\tLocal v:VarDef = FunDef(_ft.First()).AddVar(Leaf(vars0[i]), Self)\t'notice we only add the name on the way back up\n\t\t\tvars[vars.Length - (i + 1)] = RefLeaf.Make(\"l_varref\", NumToStr(v.uid))\t'proceed backward to reflect stack discipline\n\t\tNext\n\t\tReturn Rose.Make(n.key, [n.arg[1], vr], [\"vals\", \"vars\"])\t'swap vars and vals so vals are evaluated first\n\tEnd Method\n\t\n\tMethod Assgt2:Node(n:Rose)\t'convert lvalue keys to indicate different action\n\t\tLocal vars0:Node[] = Rose(n.arg[0]).arg, vars:Node[vars0.Length], vr:Node = Rose.Make(\"VarList\", vars)\n\t\tFor Local v:Int = 0 Until vars0.Length\n\t\t\tvars0[v].key = \"l_\" + vars0[v].key ; vars[vars.Length - (v + 1)] = vars0[v]\n\t\tNext\n\t\tReturn Rose.Make(n.key, [n.arg[1], vr], [\"vals\", \"vars\"])\t'swap, as above\n\tEnd Method\n\t\n\tMethod name:Node(n:Leaf)\t'var ref\n\t\tFunction getvar:VarDef(_ft:TList, n:String)\n\t\t\tFor Local f:FunDef = EachIn _ft\n\t\t\t\tFor Local v:VarDef = EachIn f._vt\n\t\t\t\t\tIf v.name = n\n\t\t\t\t\t\tIf f <> _ft.First() Then v.isClosure = True\n\t\t\t\t\t\tReturn v\n\t\t\t\t\tEndIf\n\t\t\t\tNext\n\t\t\t\tFor Local v:VarDef = EachIn f._ct\n\t\t\t\t\tIf v.name = n Then Return v\n\t\t\t\tNext\n\t\t\tNext\n\t\tEnd Function\n\t\tLocal v:VarDef = getvar(_ft, n.val), f:FunDef = FunDef(_ft.First()) ; If v\n\t\t\tIf v.isClosure\n\t\t\t\tLocal id:Int = f.AddClos(v)\t'add to the list of closure vars to retain\n\t\t\t\tReturn RefLeaf.Make(\"closref\", NumToStr(id))\n\t\t\tElse\n\t\t\t\tReturn RefLeaf.Make(\"varref\", NumToStr(v.uid))\n\t\t\tEndIf\n\t\tElse\t'free, i.e. _ENV.n\n\t\t\tv = getvar(_ft, \"_ENV\")\n\t\t\tLocal id:Int = f.AddClos(v), env:Node = RefLeaf.Make(\"closref\", NumToStr(id)), name:Node = Leaf.Make(\"fname\", n.val)\n\t\t\tReturn Rose.Make(\"getfield\", [env, name], Null)\n\t\tEndIf\n\tEnd Method\n\tMethod fcall:Node(n:Rose) { mcall pfcall pmcall tfcall tmcall va_fcall va_mcall }\t'count arguments to function calls\n\t\tLocal ac:Int\n\t\tSelect n.key\n\t\t\tCase \"fcall\", \"pfcall\", \"tfcall\", \"va_fcall\"\n\t\t\t\tac = Rose(n.arg[1]).arg.Length\n\t\t\tDefault\t'*mcall\n\t\t\t\tac = Rose(Rose(n.arg[1]).arg[1]).arg.Length\n\t\tEnd Select\n\t\tReturn Rose.Make(n.key, n.arg + [Leaf.Make(\"acount\", ac)], Null)\n\tEnd Method\n\t\n\tMethod Label:Node(n:Leaf) { GotoS }\t'jump or dest\n\t\tLocal f:FunDef = FunDef(_ft.First()), val:Int\n\t\tIf n.key = \"Label\" Then val = f.AddLabel(n, Self) Else val = f.AddGoto(n)\n\t\tReturn RefLeaf.Make(n.key, NumToStr(val))\n\tEnd Method\n\t\n\tMethod ReturnS2:Node(n:Rose)\t'detect and mark tail calls (on the way up to give the call a chance to process)\n\t\tIf n.arg.Length = 1\n\t\t\tLocal k:String = n.arg[0].key, c:Rose = Rose(n.arg[0])\n\t\t\tIf k = \"fcall\" Or k = \"mcall\"\n\t\t\t\tReturn Rose.Make(\"t\" + k, c.arg, c.id)\n\t\t\tElseIf k = \"dotdotdot\"\n\t\t\t\tReturn Leaf.Make(\"return_va\", \"...\")\n\t\t\tEndIf\n\t\tEndIf\n\t\tReturn n\n\tEnd Method\nEnd Type\n\nType FunDef\n\tField n:Node, id:Int, env:FunDef\n\tField vars:VarDef[], clos:VarDef[], pcount:Int, stksz:Int, vmax:Int, vcount:Int, hasVarargs:Int\n\tField _ev:TList, _vt:TList, _ct:TList, _lt:TList, _gt:TList\n\t\n\tFunction Make:FunDef(blk:Node, in:SemanticFold)\n\t\tLocal f:FunDef = New FunDef\n\t\tf.env = FunDef(in._ft.First())\n\t\tf._vt = CreateList() ; f._ev = CreateList() ; f._ct = CreateList() ; f._lt = CreateList() ; f._gt = CreateList()\n\t\tin.funs.AddLast f ; in._ft.AddFirst f\n\t\tf.id = in.fcount ; in.fcount :+ 1\n\t\tReturn f\n\tEnd Function\n\tFunction Toplevel:FunDef(root:Node, in:SemanticFold)\t'create a chunk toplevel as a function whose sole parameter is _ENV\n\t\tLocal f:FunDef = FunDef.Make(root, in), env:VarDef = VarDef.Make(\"_ENV\", Null, 0, 0, -1)\n\t\tf._ct.AddLast env ; Return f\n\tEnd Function\n\tMethod AddVar:VarDef(n:Leaf, in:SemanticFold)\n\t\tLocal blk:Node = Node(_ev.First()), v:VarDef\n\t\tFor v = EachIn _vt\n\t\t\tIf v.blk <> blk Then Exit\t'the error here doesn't actually apply in standard Lua\n\t\t'\tIf v.name = n.val Then Throw CompileError.Make(TToken(in.tbl.ValueForKey(n)), \"duplicate local variable '\" + n.val + \"'\")\n\t\tNext\n\t\tv = VarDef.Make(n.val, blk, stksz, vcount, id) ; vcount :+ 1\n\t\t_vt.AddFirst v ; stksz :+ 1 ; Return v\n\tEnd Method\n\tMethod AddClos:Int(v:VarDef)\n\t\tLocal c:Int\n\t\tFor Local e:VarDef = EachIn _ct\n\t\t\tIf v = e Then Return c Else c :+ 1\n\t\tNext\n\t\t_ct.AddLast v ; Return c\n\tEnd Method\n\tMethod AddLabel:Int(n:Leaf, in:SemanticFold)\n\t\tLocal l:LabelDef = New LabelDef ; l.name = n.val ; l.depth = _ev.Count() ; l.varsvisible = stksz\n\t\tFor Local ln:LabelDef = EachIn _lt\n\t\t\tIf ln.depth = l.depth And ln.name = l.name Then Throw BlueCompileError.Make(TToken(in.tbl.ValueForKey(n)), \"duplicate label '::\" + n.val + \"::'\")\n\t\tNext\n\t\t_lt.AddLast l ; Return _lt.Count() - 1\n\tEnd Method\n\tMethod AddGoto:Int(n:Leaf)\n\t\tLocal g:GotoDef = New GotoDef ; g.name = n.val ; g.depth = _ev.Count() ; g.varsvisible = stksz ; g._n = n\n\t\t_gt.AddLast g ; Return _gt.Count() - 1\n\tEnd Method\n\tMethod ResolveGotos(in:SemanticFold)\n\t\tFunction cmp:Int(l:Object, r:Object)\n\t\t\tIf LabelDef(l).depth > LabelDef(r).depth Return 1 ElseIf LabelDef(l).depth < LabelDef(r).depth Return -1 Else Return 0\n\t\tEnd Function\n\t\t_lt.Sort True, cmp\n\t\tFor Local g:GotoDef = EachIn _gt\n\t\t\tLocal l:LabelDef = Null\n\t\t\tFor Local _l:LabelDef = EachIn _lt\n\t\t\t\tIf g.depth < _l.depth Then Exit\n\t\t\t\tIf g.name = _l.name Then l = _l ; Exit\n\t\t\tNext\n\t\t\tIf l\n\t\t\t\tg.tgt = l ; g._n = Null\n\t\t\tElse\n\t\t\t\tThrow BlueCompileError.Make(TToken(in.tbl.ValueForKey(g._n)), \"label '::\" + g._n.val + \"::' not visible in scope\")\n\t\t\tEndIf\n\t\tNext\n\tEnd Method\n\tMethod CloseBlock(n:Node, in:SemanticFold)\n\t\tvmax = Max(vmax, stksz)\n\t\tLocal c:Int = 0, oldLen:Int = vars.Length\n\t\tFor Local v:VarDef = EachIn _vt\n\t\t\tIf v.blk <> n Then Exit\n\t\t\tc :+ 1 ; v.blk = Null\t'noretain\n\t\tNext\n\t\tvars = New VarDef[c] + vars\n\t\tFor Local i:Int = 0 Until c\n\t\t\tvars[i] = VarDef(_vt.RemoveFirst())\t'pop contained vars\n\t\tNext\n\t\tstksz :- c\n\tEnd Method\n\tMethod Close(_n:Node, in:SemanticFold)\n\t\tn = _n ; clos = VarDef[](_ct.ToArray()) ; ResolveGotos in\n\t\tLocal v2:VarDef[] = New VarDef[vars.Length]\t\t'vars aren't in the right order due to params, sort by uid\n\t\tFor Local vi:Int = 0 Until v2.Length\n\t\t\tLocal v:VarDef = vars[vi] ; v2[v.uid] = v\n\t\tNext\n\t\tvars = v2\n\t\t_vt = Null ; _ev = Null ; _ct = Null '; _lt = Null ; _gt = Null\n\tEnd Method\nEnd Type\n\nType VarDef\n\tField name:String, blk:Node, isClosure:Int, stkpos:Int, uid:Int, fid:Int\n\tFunction Make:VarDef(n:String, b:Node, stkpos:Int, uid:Int, fid:Int)\n\t\tLocal v:VarDef = New VarDef ; v.name = n ; v.stkpos = stkpos ; v.uid = uid ; v.fid = fid ; v.blk = b ; Return v\n\tEnd Function\nEnd Type\n\nType LabelDef\n\tField name:String, depth:Int, varsvisible:Int, insl:TLink, insc:Int = -1\nEnd Type\n\nType GotoDef\n\tField name:String, depth:Int, varsvisible:Int, _n:Leaf, tgt:LabelDef', op:Object\nEnd Type\n\n\nType RefLeaf Extends Leaf\n\tFunction Make:Leaf(key:String, val:String)\n\t\tLocal l:Leaf = New RefLeaf\n\t\tl.key = key ; l.val = val\n\t\tReturn l\n\tEnd Function\n\tMethod ToString:String()\n\t\tReturn \"{ '#\" + StrToNum(val) + \"' : \" + key + \" }\"\n\tEnd Method\nEnd Type\nFunction StrToNum:Int(s:String)\n\tReturn s[0] | (s[1] Shl 8) | (s[2] Shl 16) | (s[3] Shl 24)\nEnd Function\nFunction NumToStr:String(n:Int)\n\tReturn Chr(n & $FF) + Chr((n & $FF00) Shr 8) + Chr((n & $FF0000) Shr 16) + Chr((n & $FF000000) Shr 24)\nEnd Function\n\n\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"5f79e9930555424399722e099a721fa765774fea","subject":"Removed more '_currentworld' usage in b3dloader.","message":"Removed more '_currentworld' usage in b3dloader.\n","repos":"kfprimm\/maxb3d,kfprimm\/maxb3d","old_file":"b3dloader.mod\/b3dloader.bmx","new_file":"b3dloader.mod\/b3dloader.bmx","new_contents":"\nStrict\n\nRem\n\tbbdoc: Blitz3D model loader for MaxB3D\nEnd Rem\nModule MaxB3D.B3DLoader\nModuleInfo \"Author: Kevin Primm\"\nModuleInfo \"License: MIT\"\n\nImport MaxB3D.Core\nImport MaxB3D.BoneAnimator\nImport Prime.libB3D\n\nType TMeshLoaderB3D Extends TMeshLoader\n\tField _mesh:TMesh\n\t\n\tMethod Run(config:TWorldConfig,mesh:TMesh,stream:TStream,url:Object)\n\t\tLocal model:TBB3DChunk = TBB3DChunk(url)\t\t\n\t\tIf model=Null model = TBB3DChunk.Load(stream)\n\t\tIf model=Null Return False\t\n\t\t\n\t\tLocal olddir$=CurrentDir()\n\t\tIf String(url) ChangeDir(ExtractDir(String(url)))\n\t\t\n\t\tLocal texture:TTexture[model.texs.length]\n\t\tLocal brush:TBrush[model.brus.length]\n\t\t\n\t\tFor Local i=0 To texture.length-1\n\t\t\tLocal chunk:TTEXSChunk=model.texs[i]\t\t\t\n\t\t\ttexture[i]=_currentworld.AddTexture(chunk.file,chunk.flags)\n\t\t\tIf texture[i]\n\t\t\t\ttexture[i].SetBlend chunk.blend\n\t\t\t\ttexture[i].SetPosition chunk.x_pos,chunk.y_pos\n\t\t\t\ttexture[i].SetScale chunk.x_scale,chunk.y_scale\n\t\t\t\ttexture[i].SetRotation chunk.rotation*(180.0\/Pi)\n\t\t\t\tIf chunk.flags&65536 texture[i].SetCoords 1\n\t\t\tEndIf\n\t\tNext\n\t\t\n\t\tFor Local i=0 To brush.length-1\n\t\t\tLocal chunk:TBRUSChunk=model.brus[i]\n\t\t\tbrush[i]=_currentworld.AddBrush()\n\t\t\tbrush[i].SetName chunk.name\n\t\t\tbrush[i].SetColor chunk.red*255,chunk.green*255,chunk.blue*255;brush[i].SetAlpha chunk.alpha\n\t\t\tbrush[i].SetShine chunk.shininess\n\t\t\tbrush[i].SetBlend chunk.blend;brush[i].SetFX chunk.fx\n\t\t\tFor Local j=0 To chunk.n_texs-1\n\t\t\t\tIf chunk.texture_id[j]>-1 brush[i].SetTexture texture[chunk.texture_id[j]],j\n\t\t\tNext\n\t\tNext\t\t\n\t\tChangeDir olddir\n\t\t\n\t\t' model.dump StandardIOStream\n\t\t \n\t\tIf model.node\n\t\t\tParseNode config,model.node,mesh,brush,mesh\n\t\t\t_mesh = Null\n\t\t\tReturn True\n\t\tEndIf\n\t\tReturn False\n\tEnd Method\n\t\n\tMethod ParseNode(config:TWorldConfig,node:TNODEChunk,parent:TEntity,brush:TBrush[],entity:TEntity=Null)\n\t\tLocal meshchunk:TMESHChunk=TMESHChunk(node.kind),bonechunk:TBONEChunk=TBONEChunk(node.kind)\n\t\t\t\t\n\t\tSelect node.kind\n\t\tCase Null\n\t\t\tentity=_currentworld.AddPivot(parent)\n\t\tCase meshchunk\t\t\t\n\t\t\tIf entity=Null entity=New TMesh.Init(config, parent)\n\t\t\tLocal mesh:TMesh=TMesh(entity)\n\t\t\tmesh._animator=New TBoneAnimator\n\t\t\t_mesh=mesh\n\t\t\t\n\t\t\tIf meshchunk.brush_id>-1 entity.SetBrush brush[meshchunk.brush_id]\n\t\t\t\n\t\t\tLocal vrts:TVRTSChunk=meshchunk.vrts\n\t\t\tLocal vertsurface:TSurface=New TSurface\n\t\t\tvertsurface.Resize(vrts.xyz.length\/3,0)\n\t\t\t\n\t\t\tFor Local i=0 To vertsurface.CountVertices()-1\n\t\t\t\tvertsurface.SetCoords i,vrts.xyz[i*3+0],vrts.xyz[i*3+1],vrts.xyz[i*3+2]\n\t\t\t\tIf vrts.nxyz vertsurface.SetNormal i,vrts.nxyz[i*3+0],vrts.nxyz[i*3+1],vrts.nxyz[i*3+2]\n\t\t\t\tIf vrts.rgba vertsurface.SetColor i,vrts.rgba[i*4+0]*255,vrts.rgba[i*4+1]*255,vrts.rgba[i*4+2]*255,vrts.rgba[i*4+3]\n\t\t\t\tIf vrts.SetSize()>1 \n\t\t\t\t\tFor Local j=0 To vrts.SetCount()-1\n\t\t\t\t\t\tvertsurface.SetTexCoords i,1-vrts.tex_coords[i][j,0],vrts.tex_coords[i][j,1],j\n\t\t\t\t\tNext\n\t\t\t\tEndIf\n\t\t\tNext\n\t\t\t\n\t\t\tFor Local i=0 To meshchunk.tris.length-1\n\t\t\t\tLocal tri:TTRISChunk=meshchunk.tris[i]\n\t\t\t\tLocal surface:TSurface=vertsurface.Copy()\n\t\t\t\tsurface.Resize(-1,tri.vertex_id.length\/3)\n\t\t\t\tIf tri.brush_id>-1 surface.SetBrush brush[tri.brush_id]\n\t\t\t\tFor Local t=0 To surface.CountTriangles()-1\n\t\t\t\t\tsurface.SetTriangle t,tri.vertex_id[t*3+0],tri.vertex_id[t*3+1],tri.vertex_id[t*3+2]\n\t\t\t\tNext\n\t\t\t\tIf vrts.nxyz=Null surface.UpdateNormals\t\t\t\n\t\t\t\tmesh.AppendSurface surface\n\t\t\tNext\n\t\tCase bonechunk\n\t\t\tentity=New TBone.Init(config, parent)\n\t\t\tLocal bone:TBone=TBone(entity)\n\t\t\t\n\t\t\tFor Local surface:TSurface=EachIn _mesh._surfaces\n\t\t\t\tbone.AddSurface surface\n\t\t\t\tFor Local i=0 To bonechunk.vertex_id.length-1\n\t\t\t\t\tbone.AddVertex surface,bonechunk.vertex_id[i],bonechunk.weight[i]\n\t\t\t\tNext\n\t\t\tNext\t\t\t\n\t\t\t\n\t\t\tLocal ident_matrix:TMatrix=TMatrix.Identity()\n\t\t\tFor Local chunk:TKEYSChunk=EachIn node.keys\n\t\t\t\tLocal keys:TAnimKey[chunk.frame.length]\n\t\t\t\tLocal pos#[]=chunk.position,rot#[]=chunk.rotation,scl#[]=chunk.scale\n\t\t\t\tFor Local i=0 To chunk.frame.length-1\n\t\t\t\t\tLocal bonekey:TBoneKey=New TBoneKey\n\t\t\t\t\t\n\t\t\t\t\tIf pos.length>0 bonekey._px=pos[i*3+0];bonekey._py=pos[i*3+1];bonekey._pz=pos[i*3+2]\n\t\t\t\t\tIf rot.length>0 bonekey._rw=rot[i*4+0];bonekey._rx=rot[i*4+1];bonekey._ry=rot[i*4+2];bonekey._rz=rot[i*4+3]\n\t\t\t\t\tIf scl.length>0 bonekey._sx=scl[i*3+0];bonekey._sy=scl[i*3+1];bonekey._sz=scl[i*3+2]\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\tLocal key:TAnimKey=New TAnimKey\n\t\t\t\t\tkey._frame=chunk.frame[i]\n\t\t\t\t\tkey._object=bonekey\n\t\t\t\t\tkeys[i]=key\n\t\t\t\tNext\n\t\t\t\tTBoneAnimator(_mesh._animator).AddBone bone,keys\n\t\t\tNext\n\t\tDefault\n\t\t\tentity=New TPivot.Init(config, parent)\n\t\tEnd Select\t\t\n\t\t\n\t\tentity.SetName node.name\n\t\tentity.SetPosition node.position[0],node.position[1],node.position[2]\n\t\tLocal pitch#,yaw#,roll#\n\t\tTQuaternion.Euler node.rotation[0],node.rotation[1],node.rotation[2],node.rotation[3],pitch,yaw,roll\n\t\tentity.SetRotation pitch,yaw,roll\n\t\tentity.SetScale node.scale[0],node.scale[1],node.scale[2]\n\t\t\n\t\tFor Local child:TNODEChunk=EachIn node.node\n\t\t\tParseNode config,child,entity,brush\n\t\tNext\n\t\tIf TMesh(entity) If TBoneAnimator(TMesh(entity)._animator)._root=Null TMesh(entity)._animator=Null\n\t\tIf TBone(entity) TBone(entity)._start_matrix=entity.GetMatrix()\n\tEnd Method\n\t\n\tMethod Info$()\n\t\tReturn \"Blitz3D|b3d\"\n\tEnd Method\n\tMethod ModuleName$()\n\t\tReturn \"b3dloader\"\n\tEnd Method\nEnd Type\nNew TMeshLoaderB3D\n","old_contents":"\nStrict\n\nRem\n\tbbdoc: Blitz3D model loader for MaxB3D\nEnd Rem\nModule MaxB3D.B3DLoader\nModuleInfo \"Author: Kevin Primm\"\nModuleInfo \"License: MIT\"\n\nImport MaxB3D.Core\nImport MaxB3D.BoneAnimator\nImport Prime.libB3D\n\nType TMeshLoaderB3D Extends TMeshLoader\n\tField _mesh:TMesh\n\t\n\tMethod Run(config:TWorldConfig,mesh:TMesh,stream:TStream,url:Object)\n\t\tLocal model:TBB3DChunk = TBB3DChunk(url)\t\t\n\t\tIf model=Null model = TBB3DChunk.Load(stream)\n\t\tIf model=Null Return False\t\n\t\t\n\t\tLocal olddir$=CurrentDir()\n\t\tIf String(url) ChangeDir(ExtractDir(String(url)))\n\t\t\n\t\tLocal texture:TTexture[model.texs.length]\n\t\tLocal brush:TBrush[model.brus.length]\n\t\t\n\t\tFor Local i=0 To texture.length-1\n\t\t\tLocal chunk:TTEXSChunk=model.texs[i]\t\t\t\n\t\t\ttexture[i]=_currentworld.AddTexture(chunk.file,chunk.flags)\n\t\t\tIf texture[i]\n\t\t\t\ttexture[i].SetBlend chunk.blend\n\t\t\t\ttexture[i].SetPosition chunk.x_pos,chunk.y_pos\n\t\t\t\ttexture[i].SetScale chunk.x_scale,chunk.y_scale\n\t\t\t\ttexture[i].SetRotation chunk.rotation*(180.0\/Pi)\n\t\t\t\tIf chunk.flags&65536 texture[i].SetCoords 1\n\t\t\tEndIf\n\t\tNext\n\t\t\n\t\tFor Local i=0 To brush.length-1\n\t\t\tLocal chunk:TBRUSChunk=model.brus[i]\n\t\t\tbrush[i]=_currentworld.AddBrush()\n\t\t\tbrush[i].SetName chunk.name\n\t\t\tbrush[i].SetColor chunk.red*255,chunk.green*255,chunk.blue*255;brush[i].SetAlpha chunk.alpha\n\t\t\tbrush[i].SetShine chunk.shininess\n\t\t\tbrush[i].SetBlend chunk.blend;brush[i].SetFX chunk.fx\n\t\t\tFor Local j=0 To chunk.n_texs-1\n\t\t\t\tIf chunk.texture_id[j]>-1 brush[i].SetTexture texture[chunk.texture_id[j]],j\n\t\t\tNext\n\t\tNext\t\t\n\t\tChangeDir olddir\n\t\t\n\t\t' model.dump StandardIOStream\n\t\t \n\t\tIf model.node\n\t\t\tParseNode config,model.node,mesh,brush,mesh\n\t\t\t_mesh = Null\n\t\t\tReturn True\n\t\tEndIf\n\t\tReturn False\n\tEnd Method\n\t\n\tMethod ParseNode(config:TWorldConfig,node:TNODEChunk,parent:TEntity,brush:TBrush[],entity:TEntity=Null)\n\t\tLocal meshchunk:TMESHChunk=TMESHChunk(node.kind),bonechunk:TBONEChunk=TBONEChunk(node.kind)\n\t\t\t\t\n\t\tSelect node.kind\n\t\tCase Null\n\t\t\tentity=_currentworld.AddPivot(parent)\n\t\tCase meshchunk\t\t\t\n\t\t\tIf entity=Null entity=New TMesh.Init(config, parent)\n\t\t\tLocal mesh:TMesh=TMesh(entity)\n\t\t\tmesh._animator=New TBoneAnimator\n\t\t\t_mesh=mesh\n\t\t\t\n\t\t\tIf meshchunk.brush_id>-1 entity.SetBrush brush[meshchunk.brush_id]\n\t\t\t\n\t\t\tLocal vrts:TVRTSChunk=meshchunk.vrts\n\t\t\tLocal vertsurface:TSurface=New TSurface\n\t\t\tvertsurface.Resize(vrts.xyz.length\/3,0)\n\t\t\t\n\t\t\tFor Local i=0 To vertsurface.CountVertices()-1\n\t\t\t\tvertsurface.SetCoords i,vrts.xyz[i*3+0],vrts.xyz[i*3+1],vrts.xyz[i*3+2]\n\t\t\t\tIf vrts.nxyz vertsurface.SetNormal i,vrts.nxyz[i*3+0],vrts.nxyz[i*3+1],vrts.nxyz[i*3+2]\n\t\t\t\tIf vrts.rgba vertsurface.SetColor i,vrts.rgba[i*4+0]*255,vrts.rgba[i*4+1]*255,vrts.rgba[i*4+2]*255,vrts.rgba[i*4+3]\n\t\t\t\tIf vrts.SetSize()>1 \n\t\t\t\t\tFor Local j=0 To vrts.SetCount()-1\n\t\t\t\t\t\tvertsurface.SetTexCoords i,1-vrts.tex_coords[i][j,0],vrts.tex_coords[i][j,1],j\n\t\t\t\t\tNext\n\t\t\t\tEndIf\n\t\t\tNext\n\t\t\t\n\t\t\tFor Local i=0 To meshchunk.tris.length-1\n\t\t\t\tLocal tri:TTRISChunk=meshchunk.tris[i]\n\t\t\t\tLocal surface:TSurface=vertsurface.Copy()\n\t\t\t\tsurface.Resize(-1,tri.vertex_id.length\/3)\n\t\t\t\tIf tri.brush_id>-1 surface.SetBrush brush[tri.brush_id]\n\t\t\t\tFor Local t=0 To surface.CountTriangles()-1\n\t\t\t\t\tsurface.SetTriangle t,tri.vertex_id[t*3+0],tri.vertex_id[t*3+1],tri.vertex_id[t*3+2]\n\t\t\t\tNext\n\t\t\t\tIf vrts.nxyz=Null surface.UpdateNormals\t\t\t\n\t\t\t\tmesh.AppendSurface surface\n\t\t\tNext\n\t\tCase bonechunk\n\t\t\tentity=_currentworld.AddBone(parent)\n\t\t\tLocal bone:TBone=TBone(entity)\n\t\t\t\n\t\t\tFor Local surface:TSurface=EachIn _mesh._surfaces\n\t\t\t\tbone.AddSurface surface\n\t\t\t\tFor Local i=0 To bonechunk.vertex_id.length-1\n\t\t\t\t\tbone.AddVertex surface,bonechunk.vertex_id[i],bonechunk.weight[i]\n\t\t\t\tNext\n\t\t\tNext\t\t\t\n\t\t\t\n\t\t\tLocal ident_matrix:TMatrix=TMatrix.Identity()\n\t\t\tFor Local chunk:TKEYSChunk=EachIn node.keys\n\t\t\t\tLocal keys:TAnimKey[chunk.frame.length]\n\t\t\t\tLocal pos#[]=chunk.position,rot#[]=chunk.rotation,scl#[]=chunk.scale\n\t\t\t\tFor Local i=0 To chunk.frame.length-1\n\t\t\t\t\tLocal bonekey:TBoneKey=New TBoneKey\n\t\t\t\t\t\n\t\t\t\t\tIf pos.length>0 bonekey._px=pos[i*3+0];bonekey._py=pos[i*3+1];bonekey._pz=pos[i*3+2]\n\t\t\t\t\tIf rot.length>0 bonekey._rw=rot[i*4+0];bonekey._rx=rot[i*4+1];bonekey._ry=rot[i*4+2];bonekey._rz=rot[i*4+3]\n\t\t\t\t\tIf scl.length>0 bonekey._sx=scl[i*3+0];bonekey._sy=scl[i*3+1];bonekey._sz=scl[i*3+2]\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\tLocal key:TAnimKey=New TAnimKey\n\t\t\t\t\tkey._frame=chunk.frame[i]\n\t\t\t\t\tkey._object=bonekey\n\t\t\t\t\tkeys[i]=key\n\t\t\t\tNext\n\t\t\t\tTBoneAnimator(_mesh._animator).AddBone bone,keys\n\t\t\tNext\n\t\tDefault\n\t\t\tentity=_currentworld.AddPivot(parent)\n\t\tEnd Select\t\t\n\t\t\n\t\tentity.SetName node.name\n\t\tentity.SetPosition node.position[0],node.position[1],node.position[2]\n\t\tLocal pitch#,yaw#,roll#\n\t\tTQuaternion.Euler node.rotation[0],node.rotation[1],node.rotation[2],node.rotation[3],pitch,yaw,roll\n\t\tentity.SetRotation pitch,yaw,roll\n\t\tentity.SetScale node.scale[0],node.scale[1],node.scale[2]\n\t\t\n\t\tFor Local child:TNODEChunk=EachIn node.node\n\t\t\tParseNode config,child,entity,brush\n\t\tNext\n\t\tIf TMesh(entity) If TBoneAnimator(TMesh(entity)._animator)._root=Null TMesh(entity)._animator=Null\n\t\tIf TBone(entity) TBone(entity)._start_matrix=entity.GetMatrix()\n\tEnd Method\n\t\n\tMethod Info$()\n\t\tReturn \"Blitz3D|b3d\"\n\tEnd Method\n\tMethod ModuleName$()\n\t\tReturn \"b3dloader\"\n\tEnd Method\nEnd Type\nNew TMeshLoaderB3D\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"2621b5ec39ef2e56ab2b52f5089e834e2203f064","subject":"Added stub SeekMusic to bmax","message":"Added stub SeekMusic to bmax\n","repos":"swoolcock\/diddy,swoolcock\/diddy,swoolcock\/diddy,swoolcock\/diddy,swoolcock\/diddy","old_file":"src\/diddy\/native\/diddy.bmax.bmx","new_file":"src\/diddy\/native\/diddy.bmax.bmx","new_contents":"' ***** Start diddy.bmax.bmx ******\r\nGlobal diddy_mouseWheel:Float = 0.0\r\n\r\nType diddy\r\n\tFunction systemMillisecs:Float()\r\n\t\tReturn Millisecs()\r\n\tEndFunction\r\n\t\r\n\tFunction setGraphics(w:int, h:int, fullScreen:Int = False)\r\n\t\tlocal d% = 0\r\n\t\tif fullScreen then d = 32\r\n\t\tGraphics w, h, d, 60\r\n\tEndFunction\r\n\t\r\n\tFunction setMouse(x:Int, y:Int)\r\n\t\tMoveMouse(x, y)\r\n\tEndFunction\r\n\t\r\n\tFunction showKeyboard()\r\n\tEndFunction\r\n\t\r\n\tFunction launchBrowser(address:String, windowName:String)\r\n\tEndFunction\r\n\t\r\n\tFunction launchEmail(email:String, subject:String, text:String)\r\n\tEndFunction\r\n\t\r\n\tFunction realMod:Float( value:Float, amount:Float )\r\n\t\tReturn value Mod amount\r\n\tEndFunction\r\n\t\r\n\tFunction startVibrate(millisecs:int)\r\n\tEndFunction\r\n\t\r\n\tFunction stopVibrate()\r\n\tEndFunction\r\n\t\r\n\tFunction getDayOfMonth:Int()\r\n\t\tLocal date$ = CurrentDate()\r\n\t\tReturn Int(date[..2])\r\n\tEndFunction\r\n\t\r\n\tFunction getDayOfWeek:Int()\r\n\t\tReturn 0\r\n\tEndFunction\r\n\t\r\n\tFunction getMonth:Int()\r\n\t\tLocal date$ = CurrentDate()\r\n\t\tReturn (Instr(\"JANFEBMARAPRMAYJUNJULAUGSEPOCTNOVDEC\", date$[3..6].ToUpper(), 1) \/ 3) + 1\r\n\tEndFunction\r\n\t\r\n\tFunction getYear:Int()\r\n\t\tLocal date$ = CurrentDate()\r\n\t\tReturn Int(date[date.length - 4..]);\r\n\tEndFunction\r\n\t\r\n\tFunction getHours:Int()\r\n\t\tLocal time$ = CurrentTime()\r\n\t\tReturn Int(time[..2])\r\n\tEndFunction\r\n\t\r\n\tFunction getMinutes:Int()\r\n\t\tLocal time$ = CurrentTime()\r\n\t\tReturn Int(time[3..5])\r\n\tEndFunction\r\n\t\r\n\tFunction getSeconds:Int()\r\n\t\tLocal time$ = CurrentTime()\r\n\t\tReturn Int(time[6..8])\r\n\tEndFunction\r\n\t\r\n\tFunction getMilliSeconds:Int()\r\n\t\tReturn Millisecs()\r\n\tEndFunction\r\n\t\r\n\tFunction startGps()\r\n\tEndFunction\r\n\t\r\n\tFunction getLatitiude:String()\r\n\t\tReturn \"\"\r\n\tEndFunction\r\n\t\r\n\tFunction getLongitude:String()\r\n\t\tReturn \"\"\r\n\tEndFunction\r\n\r\n\tFunction showAlertDialog(title:String, message:String)\r\n\tEndFunction\r\n\t\r\n\tFunction getInputString:String()\r\n\t\tReturn \"\";\r\n\tEndFunction\r\n\t\r\n\tFunction getPixel:Int( x:int, y:int )\r\n'\t\tunsigned char pix[4];\r\n'\t\tglReadPixels(x, app->graphics->height-y ,1 ,1 ,GL_RGBA ,GL_UNSIGNED_BYTE ,pix);\r\n'\t\treturn (pix[3]<<24) | (pix[0]<<16) | (pix[1]<<8) | pix[2];\r\n\t\tReturn 0\r\n\tEndFunction\r\n\t\r\n\tFunction mouseZInit()\r\n\tEndFunction\r\n\r\n\tFunction mouseZ:Float()\r\n\t\tLocal ret:Float = BlitzMaxMouseZ() - diddy_mouseWheel\r\n\t\tdiddy_mouseWheel = BlitzMaxMouseZ()\r\n\t\tReturn ret\r\n\tEndFunction\r\n\t\r\n\tFunction SeekMusic:Int(timeMillis:Int)\r\n\t\tReturn 0\r\n\tEndFunction\r\nEndType\r\n\r\nFunction BlitzMaxMouseZ:Float()\r\n\tReturn MouseZ()\r\nEndFunction\r\n\r\n' ***** End diddy.bmax.bmx ******\r\n\r\n\r\n","old_contents":"' ***** Start diddy.bmax.bmx ******\r\nGlobal diddy_mouseWheel:Float = 0.0\r\n\r\nType diddy\r\n\tFunction systemMillisecs:Float()\r\n\t\tReturn Millisecs()\r\n\tEndFunction\r\n\t\r\n\tFunction setGraphics(w:int, h:int, fullScreen:Int = False)\r\n\t\tlocal d% = 0\r\n\t\tif fullScreen then d = 32\r\n\t\tGraphics w, h, d, 60\r\n\tEndFunction\r\n\t\r\n\tFunction setMouse(x:Int, y:Int)\r\n\t\tMoveMouse(x, y)\r\n\tEndFunction\r\n\t\r\n\tFunction showKeyboard()\r\n\tEndFunction\r\n\t\r\n\tFunction launchBrowser(address:String, windowName:String)\r\n\tEndFunction\r\n\t\r\n\tFunction launchEmail(email:String, subject:String, text:String)\r\n\tEndFunction\r\n\t\r\n\tFunction realMod:Float( value:Float, amount:Float )\r\n\t\tReturn value Mod amount\r\n\tEndFunction\r\n\t\r\n\tFunction startVibrate(millisecs:int)\r\n\tEndFunction\r\n\t\r\n\tFunction stopVibrate()\r\n\tEndFunction\r\n\t\r\n\tFunction getDayOfMonth:Int()\r\n\t\tLocal date$ = CurrentDate()\r\n\t\tReturn Int(date[..2])\r\n\tEndFunction\r\n\t\r\n\tFunction getDayOfWeek:Int()\r\n\t\tReturn 0\r\n\tEndFunction\r\n\t\r\n\tFunction getMonth:Int()\r\n\t\tLocal date$ = CurrentDate()\r\n\t\tReturn (Instr(\"JANFEBMARAPRMAYJUNJULAUGSEPOCTNOVDEC\", date$[3..6].ToUpper(), 1) \/ 3) + 1\r\n\tEndFunction\r\n\t\r\n\tFunction getYear:Int()\r\n\t\tLocal date$ = CurrentDate()\r\n\t\tReturn Int(date[date.length - 4..]);\r\n\tEndFunction\r\n\t\r\n\tFunction getHours:Int()\r\n\t\tLocal time$ = CurrentTime()\r\n\t\tReturn Int(time[..2])\r\n\tEndFunction\r\n\t\r\n\tFunction getMinutes:Int()\r\n\t\tLocal time$ = CurrentTime()\r\n\t\tReturn Int(time[3..5])\r\n\tEndFunction\r\n\t\r\n\tFunction getSeconds:Int()\r\n\t\tLocal time$ = CurrentTime()\r\n\t\tReturn Int(time[6..8])\r\n\tEndFunction\r\n\t\r\n\tFunction getMilliSeconds:Int()\r\n\t\tReturn Millisecs()\r\n\tEndFunction\r\n\t\r\n\tFunction startGps()\r\n\tEndFunction\r\n\t\r\n\tFunction getLatitiude:String()\r\n\t\tReturn \"\"\r\n\tEndFunction\r\n\t\r\n\tFunction getLongitude:String()\r\n\t\tReturn \"\"\r\n\tEndFunction\r\n\r\n\tFunction showAlertDialog(title:String, message:String)\r\n\tEndFunction\r\n\t\r\n\tFunction getInputString:String()\r\n\t\tReturn \"\";\r\n\tEndFunction\r\n\t\r\n\tFunction getPixel:Int( x:int, y:int )\r\n'\t\tunsigned char pix[4];\r\n'\t\tglReadPixels(x, app->graphics->height-y ,1 ,1 ,GL_RGBA ,GL_UNSIGNED_BYTE ,pix);\r\n'\t\treturn (pix[3]<<24) | (pix[0]<<16) | (pix[1]<<8) | pix[2];\r\n\t\tReturn 0\r\n\tEndFunction\r\n\t\r\n\tFunction mouseZInit()\r\n\tEndFunction\r\n\r\n\tFunction mouseZ:Float()\r\n\t\tLocal ret:Float = BlitzMaxMouseZ() - diddy_mouseWheel\r\n\t\tdiddy_mouseWheel = BlitzMaxMouseZ()\r\n\t\tReturn ret\r\n\tEndFunction\r\nEndType\r\n\r\nFunction BlitzMaxMouseZ:Float()\r\n\tReturn MouseZ()\r\nEndFunction\r\n\r\n' ***** End diddy.bmax.bmx ******\r\n\r\n\r\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"a8680634918149de3e93581936ba5b571ef33477","subject":"[json] (v0.2) \tdJNullVariable.ValueAsString now returns Null (instead of \"null\") \tDocumentation correction","message":"[json] (v0.2)\n\tdJNullVariable.ValueAsString now returns Null (instead of \"null\")\n\tDocumentation correction\n","repos":"komiga\/duct-max,komiga\/duct-max,komiga\/duct-max","old_file":"json.mod\/json.bmx","new_file":"json.mod\/json.bmx","new_contents":"\nRem\n\tCopyright (c) 2009 Tim Howard\n\t\n\tPermission is hereby granted, free of charge, to any person obtaining a copy\n\tof this software and associated documentation files (the \"Software\"), to deal\n\tin the Software without restriction, including without limitation the rights\n\tto use, copy, modify, merge, publish, distribute, sublicense, and\/or sell\n\tcopies of the Software, and to permit persons to whom the Software is\n\tfurnished to do so, subject to the following conditions:\n\t\n\tThe above copyright notice and this permission notice shall be included in\n\tall copies or substantial portions of the Software.\n\t\n\tTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n\tIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n\tFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n\tAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n\tLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n\tOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n\tTHE SOFTWARE.\nEnd Rem\n\nSuperStrict\n\nRem\nbbdoc: JSON handler for cower.jonk\nEnd Rem\nModule duct.json\n\nModuleInfo \"Version: 0.2\"\nModuleInfo \"Copyright: Tim Howard\"\nModuleInfo \"License: MIT\"\n\nModuleInfo \"History: Version 0.2\"\nModuleInfo \"History: dJNullVariable.ValueAsString now returns Null (instead of ~qnull~q); documentation correction\"\nModuleInfo \"History: Version 0.1\"\nModuleInfo \"History: Initial version.\"\n\nImport duct.variables\nImport cower.jonk\n\nRem\n\tbbdoc: duct JSON object.\nEnd Rem\nType dJObject Extends TIdentifier\n\t\n\tRem\n\t\tbbdoc: Create a new dJObject.\n\t\treturns: The new dJObject (itself).\n\tEnd Rem\n\tMethod Create:dJObject()\n\t\tSuper.Create()\n\t\tReturn Self\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the object's parent.\n\t\treturns: The object's parent.\n\tEnd Rem\n\tMethod GetParent:dJObject()\n\t\tReturn dJObject(m_parent)\n\tEnd Method\n\t\nEnd Type\n\nRem\n\tbbdoc: duct JSON array.\nEnd Rem\nType dJArray Extends dJObject\n\t\n\tRem\n\t\tbbdoc: Create a new dJArray.\n\t\treturns: The new dJArray (itself).\n\tEnd Rem\n\tMethod Create:dJArray()\n\t\tSuper.Create()\n\t\tReturn Self\n\tEnd Method\n\t\nEnd Type\n\nConst TV_NULL:Int = 100\n\nRem\n\tbbdoc: duct JSON null variable.\nEnd Rem\nType dJNullVariable Extends TVariable\n\t\n\tRem\n\t\tbbdoc: Create a New dJNullVariable.\n\t\treturns: The New dJNullVariable (itself).\n\tEnd Rem\n\tMethod Create:dJNullVariable(name:String = Null)\n\t\tSetName(name)\n\t\tReturn Self\n\tEnd Method\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the value of the variable To the given String (ambiguous).\n\t\treturns: Nothing.\n\t\tabout: This does nothing for dJNullVariable.\n\tEnd Rem\n\tMethod SetAmbiguous(value:String)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Convert the variable to a String.\n\t\treturns: A string representation of the variable.\n\t\tabout: This function is for script output, for in-code use see #ValueAsString.\n\tEnd Rem\n\tMethod ConvToString:String()\n\t\tReturn \"null\"\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the variable as a String.\n\t\treturns: The variable's value converted to a String.\n\tEnd Rem\n\tMethod ValueAsString:String()\n\t\tReturn Null\n\tEnd Method\n\t\n'#end region (Field accessors)\n\t\n'#region Data handling\n\t\n\tRem\n\t\tbbdoc: Create a copy of the variable\n\t\treturns: A clone of the variable.\n\tEnd Rem\n\tMethod Copy:dJNullVariable()\n\t\tReturn New dJNullVariable.Create(m_name)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Serialize the variable to a stream.\n\t\treturns: Nothing.\n\t\tabout: @tv tells the method whether it should serialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod Serialize(stream:TStream, tv:Int = True, name:Int = False)\n\t\tIf tv = True\n\t\t\tstream.WriteByte(TV_INTEGER)\n\t\tEnd If\n\t\tIf name = True\n\t\t\tWriteLString(stream, m_name)\n\t\tEnd If\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Deserialize the variable from a stream.\n\t\treturns: The deserialized variable.\n\t\tabout: @tv tells the method whether it should deserialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod DeSerialize:dJNullVariable(stream:TStream, tv:Int = True, name:Int = False)\n\t\tIf tv = True\n\t\t\tstream.ReadByte()\n\t\tEnd If\n\t\tIf name = True\n\t\t\tm_name = ReadLString(stream)\n\t\tEnd If\n\t\tReturn Self\n\tEnd Method\n\t\n'#end region (Data handling)\n\t\n\tRem\n\t\tbbdoc: Get the type of this variable.\n\t\treturns: The type of this variable (\"null\").\n\tEnd Rem\n\tFunction ReportType:String()\n\t\tReturn \"null\"\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Get the TV type of this variable.\n\t\treturns: The TV_* type of this variable (TV_NULL).\n\tEnd Rem\n\tFunction GetTVType:Int()\n\t\tReturn TV_NULL\n\tEnd Function\n\t\nEnd Type\n\nRem\n\tbbdoc: duct event handler for JONK.\nEnd Rem\nType dJEventHandler Extends JEventHandler\n\t\n\tField m_objname:String\n\tField m_root:dJObject\n\tField m_object:dJObject\n\t\n\tField tmpvar:TVariable\n\t\n\tMethod BeginParsing()\n\t\tm_root = New dJObject.Create()\n\t\tm_object = m_root\n\tEnd Method\n\t\n\tMethod EndParsing()\n\t\tAssert m_object = m_root, \"(dJEventHandler.EndParsing) m_object != m_root!\"\n\t\tm_objname = Null\n\t\tm_object = Null\n\tEnd Method\n\t\n\tMethod ObjectBegin()\n\t\ttmpvar = New dJObject.Create()\n\t\tSetAndClearName(tmpvar)\n\t\tm_object.AddValue(tmpvar)\n\t\tm_object = dJObject(tmpvar)\n\tEnd Method\n\t\n\tMethod ObjectKey(name:String)\n\t\tm_objname = name\n\tEnd Method\n\t\n\tMethod ObjectEnd()\n\t\tm_object = dJObject(m_object.GetParent())\n\tEnd Method\n\t\n\tMethod ArrayBegin()\n\t\ttmpvar = New dJArray.Create()\n\t\tSetAndClearName(tmpvar)\n\t\tm_object.AddValue(tmpvar)\n\t\tm_object = dJObject(tmpvar)\n\tEnd Method\n\t\n\tMethod ArrayEnd()\n\t\tm_object = dJObject(m_object.GetParent())\n\tEnd Method\n\t\n\tMethod NumberValue(number:String, isdecimal:Int)\n\t\tIf isdecimal = True\n\t\t\ttmpvar = New TFloatVariable.Create(Null, Float(number))\n\t\tElse\n\t\t\ttmpvar = New TIntVariable.Create(Null, Int(number))\n\t\tEnd If\n\t\tSetAndClearName(tmpvar)\n\t\tm_object.AddValue(tmpvar)\n\tEnd Method\n\t\n\tMethod StringValue(value:String)\n\t\ttmpvar = New TStringVariable.Create(Null, value)\n\t\tSetAndClearName(tmpvar)\n\t\tm_object.AddValue(tmpvar)\n\tEnd Method\n\t\n\tMethod BooleanValue(value:Int)\n\t\ttmpvar = New TBoolVariable.Create(Null, value)\n\t\tSetAndClearName(tmpvar)\n\t\tm_object.AddValue(tmpvar)\n\tEnd Method\n\t\n\tMethod NullValue()\n\t\ttmpvar = New dJNullVariable.Create(Null)\n\t\tSetAndClearName(tmpvar)\n\t\tm_object.AddValue(tmpvar)\n\tEnd Method\n\t\n\tMethod Error:Int(err:JParserException)\n\t\tReturn False\n\tEnd Method\n\t\n\tMethod SetAndClearName(variable:TVariable)\n\t\tvariable.SetName(m_objname)\n\t\tm_objname = Null\n\tEnd Method\n\t\nEnd Type\n\nRem\n\tbbdoc: duct JSON reader.\nEnd Rem\nType dJReader\n\t\n\tField m_evthandler:dJEventHandler\n\tField m_parser:JParser\n\tField m_root:dJObject\n\t\n\tMethod New()\n\t\tm_evthandler = New dJEventHandler\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Initiate the reader with the given url\/stream.\n\t\treturns: Itself, or Null if the stream could not be opened.\n\tEnd Rem\n\tMethod InitWithStream:dJReader(url:Object, encoding:Int = JSONEncodingUTF8, bufferLength:Int = JParser.JPARSERBUFFER_INITIAL_SIZE)\n\t\tTry\n\t\t\tm_parser = New JParser.InitWithStream(url, m_evthandler, encoding, bufferLength)\n\t\t\tReturn Self\n\t\tCatch e:JException\n\t\t\tReturn Null\n\t\tEnd Try\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Initiate the reader with the given string.\n\t\treturns: Itself.\n\tEnd Rem\n\tMethod InitWithString:dJReader(str:String)\n\t\tm_parser = New JParser.InitWithString(str, m_evthandler)\n\t\tReturn Self\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Parse the reader's data.\n\t\treturns: The root object for the json data.\n\t\tabout: A #JParserException will be thrown if there is an error during parsing.\n\tEnd Rem\n\tMethod Parse:dJObject()\n\t\tm_parser.Parse()\n\t\tReturn m_evthandler.m_root\n\tEnd Method\n\t\nEnd Type\n\n","old_contents":"\nRem\n\tCopyright (c) 2009 Tim Howard\n\t\n\tPermission is hereby granted, free of charge, to any person obtaining a copy\n\tof this software and associated documentation files (the \"Software\"), to deal\n\tin the Software without restriction, including without limitation the rights\n\tto use, copy, modify, merge, publish, distribute, sublicense, and\/or sell\n\tcopies of the Software, and to permit persons to whom the Software is\n\tfurnished to do so, subject to the following conditions:\n\t\n\tThe above copyright notice and this permission notice shall be included in\n\tall copies or substantial portions of the Software.\n\t\n\tTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n\tIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n\tFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n\tAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n\tLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n\tOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n\tTHE SOFTWARE.\nEnd Rem\n\nSuperStrict\n\nRem\nbbdoc: JSON handler for cower.jonk\nEnd Rem\nModule duct.json\n\nModuleInfo \"Version: 0.1\"\nModuleInfo \"Copyright: Tim Howard\"\nModuleInfo \"License: MIT\"\n\nModuleInfo \"History: Version 0.1\"\nModuleInfo \"History: Initial version.\"\n\nImport duct.variables\nImport cower.jonk\n\nRem\n\tbbdoc: duct JSON object.\nEnd Rem\nType dJObject Extends TIdentifier\n\t\n\tRem\n\t\tbbdoc: Create a new dJObject.\n\t\treturns: The new dJObject (itself).\n\tEnd Rem\n\tMethod Create:dJObject()\n\t\tSuper.Create()\n\t\tReturn Self\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the object's parent.\n\t\treturns: The object's parent.\n\tEnd Rem\n\tMethod GetParent:dJObject()\n\t\tReturn dJObject(m_parent)\n\tEnd Method\n\t\nEnd Type\n\nRem\n\tbbdoc: duct JSON array.\nEnd Rem\nType dJArray Extends dJObject\n\t\n\tRem\n\t\tbbdoc: Create a new dJArray.\n\t\treturns: The new dJArray (itself).\n\tEnd Rem\n\tMethod Create:dJArray()\n\t\tSuper.Create()\n\t\tReturn Self\n\tEnd Method\n\t\nEnd Type\n\nConst TV_NULL:Int = 100\n\nRem\n\tbbdoc: duct JSON null variable.\nEnd Rem\nType dJNullVariable Extends TVariable\n\t\n\tRem\n\t\tbbdoc: Create a New dJNullVariable.\n\t\treturns: The New dJNullVariable (itself).\n\tEnd Rem\n\tMethod Create:dJNullVariable(name:String = Null)\n\t\tSetName(name)\n\t\tReturn Self\n\tEnd Method\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the value of the variable To the given String (ambiguous).\n\t\treturns: Nothing.\n\t\tabout: This does nothing for dJNullVariable.\n\tEnd Rem\n\tMethod SetAmbiguous(value:String)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Convert the variable to a String.\n\t\treturns: A string representation of the variable.\n\t\tabout: This function is for script output, for in-code use see #ValueAsString.\n\tEnd Rem\n\tMethod ConvToString:String()\n\t\tReturn \"null\"\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the IntVariable as a String.\n\t\treturns: The variable's value converted to a String.\n\tEnd Rem\n\tMethod ValueAsString:String()\n\t\tReturn \"null\"\n\tEnd Method\n\t\n'#end region (Field accessors)\n\t\n'#region Data handling\n\t\n\tRem\n\t\tbbdoc: Create a copy of the variable\n\t\treturns: A clone of the variable.\n\tEnd Rem\n\tMethod Copy:dJNullVariable()\n\t\tReturn New dJNullVariable.Create(m_name)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Serialize the variable to a stream.\n\t\treturns: Nothing.\n\t\tabout: @tv tells the method whether it should serialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod Serialize(stream:TStream, tv:Int = True, name:Int = False)\n\t\tIf tv = True\n\t\t\tstream.WriteByte(TV_INTEGER)\n\t\tEnd If\n\t\tIf name = True\n\t\t\tWriteLString(stream, m_name)\n\t\tEnd If\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Deserialize the variable from a stream.\n\t\treturns: The deserialized variable.\n\t\tabout: @tv tells the method whether it should deserialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod DeSerialize:dJNullVariable(stream:TStream, tv:Int = True, name:Int = False)\n\t\tIf tv = True\n\t\t\tstream.ReadByte()\n\t\tEnd If\n\t\tIf name = True\n\t\t\tm_name = ReadLString(stream)\n\t\tEnd If\n\t\tReturn Self\n\tEnd Method\n\t\n'#end region (Data handling)\n\t\n\tRem\n\t\tbbdoc: Get the type of this variable.\n\t\treturns: The type of this variable (\"null\").\n\tEnd Rem\n\tFunction ReportType:String()\n\t\tReturn \"null\"\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Get the TV type of this variable.\n\t\treturns: The TV_* type of this variable (TV_NULL).\n\tEnd Rem\n\tFunction GetTVType:Int()\n\t\tReturn TV_NULL\n\tEnd Function\n\t\nEnd Type\n\nRem\n\tbbdoc: duct event handler for JONK.\nEnd Rem\nType dJEventHandler Extends JEventHandler\n\t\n\tField m_objname:String\n\tField m_root:dJObject\n\tField m_object:dJObject\n\t\n\tField tmpvar:TVariable\n\t\n\tMethod BeginParsing()\n\t\tm_root = New dJObject.Create()\n\t\tm_object = m_root\n\tEnd Method\n\t\n\tMethod EndParsing()\n\t\tAssert m_object = m_root, \"(dJEventHandler.EndParsing) m_object != m_root!\"\n\t\tm_objname = Null\n\t\tm_object = Null\n\tEnd Method\n\t\n\tMethod ObjectBegin()\n\t\ttmpvar = New dJObject.Create()\n\t\tSetAndClearName(tmpvar)\n\t\tm_object.AddValue(tmpvar)\n\t\tm_object = dJObject(tmpvar)\n\tEnd Method\n\t\n\tMethod ObjectKey(name:String)\n\t\tm_objname = name\n\tEnd Method\n\t\n\tMethod ObjectEnd()\n\t\tm_object = dJObject(m_object.GetParent())\n\tEnd Method\n\t\n\tMethod ArrayBegin()\n\t\ttmpvar = New dJArray.Create()\n\t\tSetAndClearName(tmpvar)\n\t\tm_object.AddValue(tmpvar)\n\t\tm_object = dJObject(tmpvar)\n\tEnd Method\n\t\n\tMethod ArrayEnd()\n\t\tm_object = dJObject(m_object.GetParent())\n\tEnd Method\n\t\n\tMethod NumberValue(number:String, isdecimal:Int)\n\t\tIf isdecimal = True\n\t\t\ttmpvar = New TFloatVariable.Create(Null, Float(number))\n\t\tElse\n\t\t\ttmpvar = New TIntVariable.Create(Null, Int(number))\n\t\tEnd If\n\t\tSetAndClearName(tmpvar)\n\t\tm_object.AddValue(tmpvar)\n\tEnd Method\n\t\n\tMethod StringValue(value:String)\n\t\ttmpvar = New TStringVariable.Create(Null, value)\n\t\tSetAndClearName(tmpvar)\n\t\tm_object.AddValue(tmpvar)\n\tEnd Method\n\t\n\tMethod BooleanValue(value:Int)\n\t\ttmpvar = New TBoolVariable.Create(Null, value)\n\t\tSetAndClearName(tmpvar)\n\t\tm_object.AddValue(tmpvar)\n\tEnd Method\n\t\n\tMethod NullValue()\n\t\ttmpvar = New dJNullVariable.Create(Null)\n\t\tSetAndClearName(tmpvar)\n\t\tm_object.AddValue(tmpvar)\n\tEnd Method\n\t\n\tMethod Error:Int(err:JParserException)\n\t\tReturn False\n\tEnd Method\n\t\n\tMethod SetAndClearName(variable:TVariable)\n\t\tvariable.SetName(m_objname)\n\t\tm_objname = Null\n\tEnd Method\n\t\nEnd Type\n\nRem\n\tbbdoc: duct JSON reader.\nEnd Rem\nType dJReader\n\t\n\tField m_evthandler:dJEventHandler\n\tField m_parser:JParser\n\tField m_root:dJObject\n\t\n\tMethod New()\n\t\tm_evthandler = New dJEventHandler\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Initiate the reader with the given url\/stream.\n\t\treturns: Itself, or Null if the stream could not be opened.\n\tEnd Rem\n\tMethod InitWithStream:dJReader(url:Object, encoding:Int = JSONEncodingUTF8, bufferLength:Int = JParser.JPARSERBUFFER_INITIAL_SIZE)\n\t\tTry\n\t\t\tm_parser = New JParser.InitWithStream(url, m_evthandler, encoding, bufferLength)\n\t\t\tReturn Self\n\t\tCatch e:JException\n\t\t\tReturn Null\n\t\tEnd Try\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Initiate the reader with the given string.\n\t\treturns: Itself.\n\tEnd Rem\n\tMethod InitWithString:dJReader(str:String)\n\t\tm_parser = New JParser.InitWithString(str, m_evthandler)\n\t\tReturn Self\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Parse the reader's data.\n\t\treturns: The root object for the json data.\n\t\tabout: A #JParserException will be thrown if there is an error during parsing.\n\tEnd Rem\n\tMethod Parse:dJObject()\n\t\tm_parser.Parse()\n\t\tReturn m_evthandler.m_root\n\tEnd Method\n\t\nEnd Type\n\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"3e95f954363838abc699b1f28d0ad4fa4a76cc89","subject":"Added module access methods to mxSourcesHandler.","message":"Added module access methods to mxSourcesHandler.\n","repos":"maximos\/maximus","old_file":"src\/sources.bmx","new_file":"src\/sources.bmx","new_contents":"\nRem\nCopyright (c) 2010 Tim Howard\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and\/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\nEnd Rem\n\nRem\n\tbbdoc: Maximus sources handler.\nEnd Rem\nType mxSourcesHandler Extends dObjectMap\n\t\n\tRem\n\t\tbbdoc: Add the given scope to the handler.\n\t\treturns: True if the scope was added, or False if it was not (scope is Null).\n\tEnd Rem\n\tMethod AddScope:Int(modscope:mxModuleScope)\n\t\tIf modscope <> Null\n\t\t\t_Insert(modscope.GetName(), modscope)\n\t\t\tReturn True\n\t\tEnd If\n\t\tReturn False\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Check if the handler has a scope with the given name.\n\t\treturns: True if a scope with the given name was found, or False if there is no scope with the given name.\n\tEnd Rem\n\tMethod HasScope:Int(scopename:String)\n\t\tReturn _Contains(scopename)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Check if the given module is in the sources.\n\t\treturns: True if the sources contains the given module, or False if it does not.\n\tEnd Rem\n\tMethod HasModule:Int(modid:String)\n\t\tLocal scope:mxModuleScope = GetScopeWithName(mxModUtils.GetScopeFromID(modid))\n\t\tIf scope <> Null\n\t\t\tReturn scope.HasModule(mxModUtils.GetNameFromID(modid))\n\t\tEnd If\n\t\tReturn False\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the scope with the given name.\n\t\treturns: The scope with the given name, or Null if there is no scope with the given name.\n\tEnd Rem\n\tMethod GetScopeWithName:mxModuleScope(scopename:String)\n\t\tReturn mxModuleScope(_ValueByKey(scopename))\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the module with the given id.\n\t\treturns: The module with the given id, or Null if there is no module with the given id.\n\tEnd Rem\n\tMethod GetModuleWithID:mxModule(modid:String)\n\t\tLocal scope:mxModuleScope = GetScopeWithName(mxModUtils.GetScopeFromID(modid))\n\t\tIf scope <> Null\n\t\t\tReturn scope.GetModuleWithName(mxModUtils.GetNameFromID(modid))\n\t\tEnd If\n\t\tReturn Null\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the module version with the given versioned-id.\n\t\treturns: The module version with the given versioned-id, or Null if there is no module\/version with the given versioned-id.\n\tEnd Rem\n\tMethod GetVersionWithVerID:mxModuleVersion(verid:String)\n\t\tLocal modul:mxModule = GetModuleWithID(verid)\n\t\tIf modul <> Null\n\t\t\tReturn modul.GetVersionWithName(mxModUtils.GetVersionFromVerID(verid))\n\t\tEnd If\n\t\tReturn Null\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Load the given file into the handler.\n\t\treturns: Itself, or Null if the given file either could not be opened or does not exist.\n\tEnd Rem\n\tMethod FromFile:mxSourcesHandler(file:String)\n\t\tLocal jreader:dJReader, root:dJObject\n\t\tjreader = New dJReader.InitWithStream(file)\n\t\tIf jreader <> Null\n\t\t\tTry\n\t\t\t\troot = jreader.Parse()\n\t\t\tCatch e:JException\n\t\t\t\tThrowError(_s(\"errors.load.sources.parse\", [e.ToString()]))\n\t\t\tEnd Try\n\t\t\tFromJSON(root)\n\t\t\tReturn Self\n\t\tEnd If\n\t\tReturn Null\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Load the given dJObject into the handler.\n\t\treturns: Itself, or Null if @root is Null.\n\tEnd Rem\n\tMethod FromJSON:mxSourcesHandler(root:dJObject)\n\t\tIf root <> Null\n\t\t\tFor Local obj:dJObject = EachIn root.GetValues()\n\t\t\t\tAddScope(New mxModuleScope.FromJSON(obj))\n\t\t\tNext\n\t\t\tReturn Self\n\t\tEnd If\n\t\tReturn Null\n\tEnd Method\n\t\nEnd Type\n\n","old_contents":"\nRem\nCopyright (c) 2010 Tim Howard\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and\/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\nEnd Rem\n\nRem\n\tbbdoc: Maximus sources handler.\nEnd Rem\nType mxSourcesHandler Extends dObjectMap\n\t\n\tRem\n\t\tbbdoc: Add the given scope to the handler.\n\t\treturns: True if the scope was added, or False if it was not (scope is Null).\n\tEnd Rem\n\tMethod AddScope:Int(modscope:mxModuleScope)\n\t\tIf modscope <> Null\n\t\t\t_Insert(modscope.GetName(), modscope)\n\t\t\tReturn True\n\t\tEnd If\n\t\tReturn False\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Check if the handler has a scope with the given name.\n\t\treturns: True if a scope with the given name was found, or False if there is no scope with the given name.\n\tEnd Rem\n\tMethod HasScope:Int(scopename:String)\n\t\tReturn _Contains(scopename)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the scope with the given name.\n\t\treturns: The scope with the given name, or Null if there is no scope with the given name.\n\tEnd Rem\n\tMethod GetScopeWithName:mxModuleScope(scopename:String)\n\t\tReturn mxModuleScope(_ValueByKey(scopename))\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Load the given file into the handler.\n\t\treturns: Itself, or Null if the given file either could not be opened or does not exist.\n\tEnd Rem\n\tMethod FromFile:mxSourcesHandler(file:String)\n\t\tLocal jreader:dJReader, root:dJObject\n\t\tjreader = New dJReader.InitWithStream(file)\n\t\tIf jreader <> Null\n\t\t\tTry\n\t\t\t\troot = jreader.Parse()\n\t\t\tCatch e:JException\n\t\t\t\tThrowError(_s(\"errors.load.sources.parse\", [e.ToString()]))\n\t\t\tEnd Try\n\t\t\tFromJSON(root)\n\t\t\tReturn Self\n\t\tEnd If\n\t\tReturn Null\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Load the given dJObject into the handler.\n\t\treturns: Itself, or Null if @root is Null.\n\tEnd Rem\n\tMethod FromJSON:mxSourcesHandler(root:dJObject)\n\t\tIf root <> Null\n\t\t\tFor Local obj:dJObject = EachIn root.GetValues()\n\t\t\t\tAddScope(New mxModuleScope.FromJSON(obj))\n\t\t\tNext\n\t\t\tReturn Self\n\t\tEnd If\n\t\tReturn Null\n\tEnd Method\n\t\nEnd Type\n\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"993e69ab44218a28c5680b69d861b1c9afbe1934","subject":"MonkeyMax - Added OnSuspend\/OnResume for gxtkAudio","message":"MonkeyMax - Added OnSuspend\/OnResume for gxtkAudio\n\n--HG--\nextra : convert_revision : svn%3Ae934d3cd-0d57-f34a-94d0-9e8d31ae1c29\/trunk%40412\n","repos":"programmerby\/diddy-mirror,programmerby\/diddy-mirror,programmerby\/diddy-mirror,programmerby\/diddy-mirror","old_file":"monkeymax\/modules\/mojo\/native\/mojo.bmax.bmx","new_file":"monkeymax\/modules\/mojo\/native\/mojo.bmax.bmx","new_contents":"' ***** Start mojo.bmax.bmx ******\r\n\r\nGlobal app:gxtkApp\r\n\r\nType gxtkApp\r\n\tField ginput:gxtkInput\r\n\tField gaudio:gxtkAudio\r\n\tField ggraphics:gxtkGraphics\r\n\r\n\tField dead:Int=0\r\n\tField suspended:Int=0\r\n\tField vloading:Int=0\r\n\tField maxloading:Int=0\r\n\tField updateRate:Int=0\r\n\tField nextUpdate:Float=0\r\n\tField updatePeriod:Float=0\r\n\tField startMillis:Float=0\r\n\t\r\n\tMethod New()' gxtkApp()\r\n\t\tapp=Self\r\n\t\tggraphics=New gxtkGraphics\r\n\tEndMethod\r\n\t\r\n\tMethod Setup()\r\n\t\tginput=New gxtkInput\r\n\t\tgaudio=New gxtkAudio\r\n\r\n\t\tbb_input__1Set_1Input_1Device(ginput)\r\n\t\tbb_audio__1Set_1Audio_1Device(gaudio)\r\n\t\t\r\n\t\tstartMillis=BlitzMaxMillisecs()\r\n\t\t\r\n\t\tSetFrameRate( 0 )\r\n\t\t\r\n\t\tInvokeOnCreate()\r\n\t\tInvokeOnRender()\r\n\t\tUpdate()\r\n\tEndMethod\r\n\t\r\n\tMethod Update()\r\n\t\tWhile Not AppTerminate()\r\n\t\t\tIf Not updatePeriod return\r\n\t\t\tLocal updates:Int = 0\r\n\t\t\t\r\n\t\t\tRepeat\r\n\t\t\t\tnextUpdate:+updatePeriod\r\n\t\t\t\tInvokeOnUpdate()\r\n\t\t\t\tIf Not updatePeriod Then Exit\r\n\t\t\t\tIf nextUpdate>BlitzMaxMillisecs() Then Exit\r\n\t\t\t\tupdates:+1\r\n\t\t\t\tIf updates = 7 Then\r\n\t\t\t\t\tnextUpdate = BlitzMaxMillisecs()\r\n\t\t\t\t\tExit\r\n\t\t\t\tEndIf\r\n\t\t\tForever\r\n\t\t\tInvokeOnRender()\r\n\t\t\tLocal del:Int = nextUpdate - BlitzMaxMillisecs()\r\n\t\t\tIf del < 1 Then del = 1\r\n\t\t\tDelay(del)\r\n\t\tWend\r\n\tEndMethod\r\n\t\r\n\tMethod InvokeOnCreate()\r\n\t\tIf dead Return\r\n\t\tdead = 1\r\n\t\tOnCreate()\r\n\t\tdead = 0\r\n\tEndMethod\r\n\r\n\tMethod InvokeOnUpdate()\r\n\t\tIf dead Or suspended Or Not updateRate Or vloading Return\r\n\t\tOnUpdate()\r\n\tEndMethod\r\n\t\r\n\tMethod InvokeOnRender()\r\n\t\tIf dead Or suspended Return\r\n\t\tggraphics.BeginRender()\r\n\t\tIf vloading\r\n\t\t\tOnLoading()\r\n\t\tElse\r\n\t\t\tOnRender()\r\n\t\tEndIf\r\n\t\tggraphics.EndRender()\r\n\tEndMethod\r\n\t\r\n\t\r\n\tMethod SetFrameRate( fps:Int )\r\n\t\tIf fps\r\n\t\t\tupdatePeriod=1000.0\/fps\r\n\t\t\tnextUpdate=BlitzMaxMillisecs() +updatePeriod\r\n\t\tElse\r\n\t\t\tupdatePeriod=0\r\n\t\tEndIf\r\n\tEndMethod\r\n\r\n\tMethod LoadState:String()\r\n'\t\tvar file:SharedObject=SharedObject.getLocal( \"gxtkapp\" );\r\n'\t\tvar state:String=file.data.state;\r\n'\t\tfile.close();\r\n'\t\tif( state ) return state;\r\n\t\tReturn \"\"\r\n\tEndMethod\r\n\t\r\n\tMethod SaveState:Int( state:String )\r\n'\t\tvar file:SharedObject=SharedObject.getLocal( \"gxtkapp\" );\r\n'\t\tfile.data.state=state;\r\n'\t\tfile.close();\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod LoadString:String( path:String )\r\n\t\tpath = \"data\/\" + path\r\n\t\tTry\r\n\t\t\tReturn LoadText( path )\r\n\t\tCatch ReadFail:Object\r\n\t\t\tReturn Null\r\n\t\tEndTry\r\n\tEndMethod\r\n\t\r\n\t' ***** GXTK API *****\r\n\t\r\n\tMethod GraphicsDevice:gxtkGraphics()\r\n\t\tReturn ggraphics\r\n\tEndMethod\r\n\r\n\tMethod InputDevice:gxtkInput()\r\n\t\tReturn ginput\r\n\tEndMethod\r\n\r\n\tMethod AudioDevice:gxtkAudio()\r\n\t\tReturn gaudio\r\n\tEndMethod\r\n\r\n\tMethod SetUpdateRate:Int(hertz:Int)\r\n\t\tupdateRate = hertz\r\n\t\tIf Not vloading Then SetFrameRate(updateRate)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod MilliSecs:Int()\r\n\t\tReturn BlitzMaxMillisecs() - startMillis\r\n\tEndMethod\r\n\t\r\n\tMethod Loading:Int()\r\n\t\tReturn vloading\r\n\tEndMethod\r\n\r\n\tMethod OnCreate:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod OnUpdate:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod OnSuspend:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod OnResume:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod OnRender:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod OnLoading:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkGraphics\r\n\tField gmode:Int = 1\r\n\tField ix:Float=1,iy:Float,jx:Float,jy:Float=1,tx:Float,ty:Float\r\n\tField sx:Float=1,sy:Float=1,rot:Float=0\r\n\t\r\n\tMethod Mode:Int()\r\n\t\tReturn gmode\r\n\tEndMethod\r\n\t\r\n\tMethod Cls:Int(r:Int = 0, g:Int = 0, b:Int = 0)\r\n\t\tBlitzMaxCls(r, g, b)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawPoint:Int(x:Float, y:Float)\r\n\t\tLocal nx:Float = TransX(x,y)\r\n\t\tLocal ny:Float = TransY(x,y)\r\n\t\tPlot nx, ny\r\n\tEndMethod\r\n\t\r\n\tMethod LoadSurface:gxtkSurface(path:String)\r\n\t\tLocal image:TImage = LoadImage(\"data\/\"+path)\r\n\t\tIf image Then\r\n\t\t\tLocal gs:gxtkSurface = New gxtkSurface\r\n\t\t\tgs.setImage(image)\r\n\t\t\tReturn gs\r\n\t\tEndIf\r\n\t\tReturn Null\r\n\tEndMethod\r\n\t\r\n\tMethod BeginRender()\r\n\tEndMethod\r\n\t\r\n\tMethod EndRender()\r\n\t\tFlip\r\n\tEndMethod\r\n\t\r\n\tMethod SetColor:Int(r:Int, g:Int, b:Int)\r\n\t\tBlitzMaxSetColor(r, g, b)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod SetAlpha:Int(a:Float)\r\n\t\tBlitzMaxSetAlpha(a)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod SetBlend:Int(blend:Int)\r\n\t\tBlitzMaxSetBlend(blend)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod Width:Int()\r\n\t\tReturn GraphicsWidth()\r\n\tEndMethod\r\n\t\r\n\tMethod Height:Int()\r\n\t\tReturn GraphicsHeight()\r\n\tEndMethod\r\n\t\r\n\tMethod SetScissor:Int(x:Int, y:Int, w:Int, h:Int)\r\n\t\tSetViewport(x, y, w, h) ' NOT TESTED!\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod TransX:Float(x:Float, y:Float)\r\n\t\tReturn ix*x + jx*y + tx\r\n\tEndMethod\r\n\t\r\n\tMethod TransY:Float(x:Float, y:Float)\r\n\t\tReturn iy*x + jy*y + ty\r\n\tEndMethod\r\n\t\r\n\tMethod SetMatrix:Int(ix:Float,iy:Float,jx:Float,jy:Float,tx:Float,ty:Float)\r\n\t\tSelf.ix = ix ; Self.iy = iy\r\n\t\tSelf.jx = jx ; Self.jy = jy\r\n\t\tSelf.tx = tx ; Self.ty = ty\r\n\t\tsx = Sqr(ix*ix+iy*iy)\r\n\t\tsy = Sqr(jx*jx+jy*jy)\r\n\t\trot = Atan2( iy, ix )\r\n\t\tIf ix < 0 Then\r\n\t\t\tsx = -sx\r\n\t\t\trot :+ 180\r\n\t\tEndIf\r\n\t\tIf jy < 0 Then sy = -sy\r\n\t\tSetTransform( rot, sx, sy )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawSurface:Int(surface:gxtkSurface,x:Float,y:Float)\r\n\t\tLocal nx:Float = TransX(x,y)\r\n\t\tLocal ny:Float = TransY(x,y)\r\n\t\tDrawImage(surface.image, nx, ny, 0)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawSurface2:Int(surface:gxtkSurface,x:Float,y:Float, srcx:Int, srcy:Int, srcw:Int, srch:Int )\r\n\t\tLocal nx:Float = TransX(x,y)\r\n\t\tLocal ny:Float = TransY(x,y)\r\n\t\tDrawSubImageRect(surface.image, nx, ny, srcw, srch, srcx, srcy, srcw, srch)\t\t\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawLine:Int( x1:Float,y1:Float,x2:Float,y2:Float )\r\n\t\tLocal nx1:Float = TransX(x1,y1)\r\n\t\tLocal ny1:Float = TransY(x1,y1)\r\n\t\tLocal nx2:Float = TransX(x2,y2)\r\n\t\tLocal ny2:Float = TransY(x2,y2)\r\n\t\t' Need to reset transform so that BlitzMax doesn't try to apply rotation\r\n\t\tSetTransform( 0, 1, 1 )\r\n\t\tBlitzMaxDrawLine(nx1, ny1, nx2, ny2)\r\n\t\tSetTransform( rot, sx, sy )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawOval:Int( x:Float, y:Float, w:Float, h:Float )\r\n\t\tLocal nx:Float = TransX(x,y)\r\n\t\tLocal ny:Float = TransY(x,y)\r\n\t\tBlitzMaxDrawOval(nx, ny, w, h)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawPoly:Int(vertices:Float[])\r\n\t\t' setting the origin to use the current rotation translation\r\n\t\tSetOrigin(TransX(0,0), TransY(0,0))\r\n\t\tBlitzMaxDrawPoly( vertices )\r\n\t\tSetOrigin(0, 0)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawRect:Int( x:Float, y:Float, w:Float, h:Float )\r\n\t\tLocal nx:Float = TransX(x,y)\r\n\t\tLocal ny:Float = TransY(x,y)\r\n\t\tBlitzMaxDrawRect(nx, ny, w, h)\r\n\t\tReturn 0\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkInput\r\n\tMethod MouseX:Float()\r\n\t\tReturn BRL.PolledInput.MouseX()\r\n\tEndMethod\r\n\r\n\tMethod MouseY:Float()\r\n\t\tReturn BRL.PolledInput.MouseY()\r\n\tEndMethod\r\n\t\r\n\tMethod KeyDown:Int( key:Int )\r\n\t\tif( key = 384 ) key = 1 ' change TOUCH0 to MOUSE_LMB\r\n\r\n\t\tIf( key >= 1 And key <= 3 )\r\n\t\t\tReturn BRL.PolledInput.MouseDown( key )\r\n\t\tEndIf\r\n\t\tIf key < 256\r\n\t\t\tReturn BRL.PolledInput.KeyDown( key )\r\n\t\tElse\r\n\t\t\tReturn 0\r\n\t\tEndIf\r\n\tEndMethod\r\n\r\n\tMethod KeyHit:Int( key:Int )\r\n\t\tif( key = 384 ) key = 1 ' change TOUCH0 to MOUSE_LMB\r\n\t\tIf( key >= 1 And key <= 3 )\r\n\t\t\tReturn BRL.PolledInput.MouseHit( key )\r\n\t\tEndIf\r\n\t\tIf key < 256\r\n\t\t\tReturn BRL.PolledInput.KeyHit( key )\r\n\t\tElse\r\n\t\t\tReturn 0\r\n\t\tEndIf\r\n\tEndMethod\r\n\r\n\tMethod GetChar:Int()\r\n\t\tReturn BRL.PolledInput.GetChar()\r\n\tEndMethod\r\n\r\n\tMethod JoyX:Int( index:Int )\r\n\t\tReturn Pub.FreeJoy.JoyX( index )\r\n\tEndMethod\r\n\r\n\tMethod JoyY:Int( index:Int )\r\n\t\tReturn Pub.FreeJoy.JoyY( index )\r\n\tEndMethod\r\n\r\n\tMethod JoyZ:Int( index:Int )\r\n\t\tReturn Pub.FreeJoy.JoyZ( index )\r\n\tEndMethod\r\n\r\n\tMethod TouchX:Float( index:Int )\r\n\t\tReturn BRL.PolledInput.MouseX()\r\n\tEndMethod\r\n\r\n\tMethod TouchY:Float( index:Int )\r\n\t\tReturn BRL.PolledInput.MouseY()\r\n\tEndMethod\r\n\t\r\n\tMethod AccelX:Int()\r\n\t\treturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod AccelY:Int()\r\n\t\treturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod AccelZ:Int()\r\n\t\treturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod SetKeyboardEnabled:Int( enabled:int )\r\n\t\tReturn 0\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkChannel\r\n\tField channel:TChannel\t' null then not playing\r\n\tField sample:gxtkSample\r\n\tField loops:int\r\n\t'Field transform:SoundTransform=new SoundTransform()\r\n\t'Field pausepos:Number\r\n\tField state:int\r\n\t\r\n\tMethod New()\r\n\t\tchannel = New TChannel\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkAudio\r\n\tField amusicState:Int = 0\r\n\tField channels:gxtkChannel[] = New gxtkChannel[33]\r\n\tConst MUSIC_CHANNEL:Int = 32\r\n\tField music:gxtkSample\r\n\t\r\n\tMethod New()\r\n\t\tFor local i:Int = 0 To 33 - 1\r\n\t\t\tchannels[i] = New gxtkChannel\r\n\t\t\tchannels[i].channel = AllocChannel()\r\n\t\tNext\r\n\tEndMethod\r\n\t\r\n\tMethod OnSuspend()\r\n\t\tFor Local i:Int = 0 To 33 - 1\r\n\t\t\tLocal chan:gxtkChannel = channels[i]\r\n\t\t\tIf chan.state = 1 Then\r\n\t\t\t\tchan.channel.SetPaused(True)\r\n\t\t\tEndIf\r\n\t\tNext\r\n\tEnd Method\r\n\r\n\tMethod OnResume()\r\n\t\tFor Local i:Int = 0 To 33 - 1\r\n\t\t\tLocal chan:gxtkChannel = channels[i]\r\n\t\t\tIf chan.state = 1 Then\r\n\t\t\t\tchan.channel.SetPaused(False)\r\n\t\t\tEndIf\r\n\t\tNext\r\n\tEnd Method\r\n\t\r\n\tMethod MusicState:Int()\r\n\t\t' Monkey Docs: \t0 if the music is currently stopped\r\n\t\t'\t\t\t\t1 if the music is currently playing\r\n\t\t'\t\t\t\t-1 if the music state cannot be determined\r\n\r\n\t\tLocal chan:gxtkChannel = channels[MUSIC_CHANNEL]\r\n\t\tIf chan.channel <> Null Then\r\n\t\t\tIf ChannelPlaying(chan.channel) Then Return 1 Else Return 0\r\n\t\tEndIf\r\n\t\t\r\n\t\tReturn -1\r\n\tEndMethod\r\n\t\r\n\tMethod PlayMusic:Int( path:String, flags:Int )\r\n\t\tStopMusic()\r\n\t\tmusic = LoadSample( path )\r\n\t\tIf Not music Then Return -1\r\n\t\t\r\n\t\tPlaySample(music, MUSIC_CHANNEL, flags)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod StopMusic:Int()\r\n\t\tStopChannel( MUSIC_CHANNEL )\r\n\t\t\r\n\t\tIf music Then\r\n\t\t\tmusic.Discard()\r\n\t\t\tmusic = null\r\n\t\tEndIf\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod ChannelState:int( channel:int )\r\n\t\t' Monkey Docs: \t0 if the channel is currently stopped\r\n\t\t'\t\t\t\t1 if the channel is currently playing\r\n\t\t'\t\t\t\t2 if the channel is currently paused\r\n\t\t'\t\t\t\t-1 if the channel state cannot be determined\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tIf chan.channel <> Null Then\r\n\t\t\tIf ChannelPlaying(chan.channel) Then Return 1 Else Return 0\r\n\t\tEndIf\r\n\t\t\r\n\t\tReturn -1\r\n\tEndMethod\r\n\t\r\n\tMethod StopChannel( channel:Int )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\t\r\n\t\tIf chan.state <> 0\r\n\t\t\tchan.channel.Stop()\r\n\t\t\tchan.channel=null\r\n\t\t\tchan.sample=null\r\n\t\t\tchan.state=0\r\n\t\tEndIf\r\n\tEndMethod\r\n\t\r\n\tMethod PauseChannel:Int( channel:Int)\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tchan.channel.SetPaused(True)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod ResumeChannel:Int( channel:Int)\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tchan.channel.SetPaused(False)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod PlaySample( sound:gxtkSample, channel:Int, flags:Int )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tIf chan.state <> 0 Then chan.channel.SetPaused(True)\r\n\t\t\r\n\t\tchan.sample = sound\r\n\t\tchan.loops = flags\r\n\t\tchan.state = 1\r\n\t\t\r\n\t\t' if looping, we need to reload the sound with the looping flag\r\n\t\tIf flags <> sound.loop\r\n\t\t\tLocal smp:TSound = LoadSound(sound.path, flags)\r\n\t\t\tsound.setSound(smp)\r\n\t\t\tsound.loop = flags\r\n\t\tEndIf\r\n\t\r\n\t\tPlaySound( sound.sound, chan.channel )\r\n\tEndMethod\r\n\r\n\tMethod SetPan( channel:Int, pan:Float )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tchan.channel.SetPan(pan)\r\n\tEndMethod\r\n\r\n\tMethod SetRate( channel:Int, rate:Float )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tchan.channel.SetRate(rate)\r\n\tEndMethod\r\n\r\n\tMethod PauseMusic:Int()\r\n\t\tLocal chan:gxtkChannel = channels[MUSIC_CHANNEL]\r\n\t\tchan.channel.SetPaused(True)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod ResumeMusic:Int()\r\n\t\tLocal chan:gxtkChannel = channels[MUSIC_CHANNEL]\r\n\t\tchan.channel.SetPaused(False)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod SetMusicVolume:Int( volume:Float )\r\n\t\tSetVolume( MUSIC_CHANNEL, volume )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod SetVolume:Int( channel:Int, volume:Float )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tchan.channel.SetVolume(volume)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod LoadSample:gxtkSample( path:String )\r\n\t\tLocal extension:String = ExtractExt( path)\r\n\t\tIf extension = \"ogg\" Or extension = \"wav\" Then\r\n\t\t\tLocal sound:TSound = LoadSound(\"data\/\"+path)\r\n\t\t\tIf sound Then\r\n\t\t\t\tLocal gs:gxtkSample = New gxtkSample\r\n\t\t\t\tgs.setSound(sound)\r\n\t\t\t\tgs.path = \"data\/\"+path\r\n\t\t\t\tReturn gs\r\n\t\t\tEndIf\r\n\t\tElse\r\n\t\t\tRuntimeError \"BlitzMax can only use ogg and wav file formats\"\r\n\t\tEndIf\r\n\t\tReturn Null\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkSample\r\n\tField sound:TSound\r\n\tField path:String\r\n\tField loop:Int\r\n\t\r\n\tMethod setSound(sound:TSound)\r\n\t\tSelf.sound = sound\r\n\tEndMethod\r\n\t\r\n\tMethod Discard()\r\n\t\tSelf.sound = null\r\n\tEndMethod\r\nEndType\r\n\r\nFunction BlitzMaxDrawPoly:Int(vertices:Float[])\r\n\tDrawPoly vertices\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxDrawRect:Int( x:Float, y:Float, w:Float, h:Float )\r\n\tDrawRect x, y, w, h\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxDrawOval:Int( x:Float, y:Float, w:Float, h:Float )\r\n\tDrawOval x, y, w, h\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxDrawLine:Int( x1:Float,y1:Float,x2:Float,y2:Float )\r\n\tDrawLine x1, y1, x2, y2\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxMillisecs:Int()\r\n\tReturn MilliSecs()\r\nEndFunction\r\n\r\nFunction BlitzMaxSetColor(r:Int, g:Int, b:Int)\r\n\tSetColor(r, g, b)\r\nEndFunction\r\n\r\nFunction BlitzMaxSetBlend(blend:Int)\r\n\tSelect blend\r\n\t\tCase 0\r\n\t\t\tSetBlend( ALPHABLEND )\r\n\t\tCase 1\r\n\t\t\tSetBlend( LIGHTBLEND )\r\n\tEnd Select\r\nEndFunction\r\n\r\nFunction BlitzMaxSetAlpha(a:Float)\r\n\tSetAlpha(a)\r\nEndFunction\r\n\r\nFunction BlitzMaxCls(r:Int = 0, g:Int = 0, b:Int = 0)\r\n\tSetClsColor(r, g, b)\r\n\tCls\r\nEndFunction\r\n\r\nType gxtkSurface\r\n\tField w:Int, h:Int\r\n\tField image:TImage\r\n\t\r\n\tMethod setImage(image:TImage)\r\n\t\tSelf.image = image\r\n\tEndMethod\r\n\t\r\n\tMethod Width:Int()\r\n\t\tReturn image.Width\r\n\tEndMethod\r\n\t\r\n\tMethod Height:Int()\r\n\t\tReturn image.Height\r\n\tEndMethod\r\n\t\r\n\tMethod Discard()\r\n\tEndMethod\r\nEndType\r\n\r\n' ***** End mojo.bmax.bmx ******\r\n\r\n","old_contents":"' ***** Start mojo.bmax.bmx ******\r\n\r\nGlobal app:gxtkApp\r\n\r\nType gxtkApp\r\n\tField ginput:gxtkInput\r\n\tField gaudio:gxtkAudio\r\n\tField ggraphics:gxtkGraphics\r\n\r\n\tField dead:Int=0\r\n\tField suspended:Int=0\r\n\tField vloading:Int=0\r\n\tField maxloading:Int=0\r\n\tField updateRate:Int=0\r\n\tField nextUpdate:Float=0\r\n\tField updatePeriod:Float=0\r\n\tField startMillis:Float=0\r\n\t\r\n\tMethod New()' gxtkApp()\r\n\t\tapp=Self\r\n\t\tggraphics=New gxtkGraphics\r\n\tEndMethod\r\n\t\r\n\tMethod Setup()\r\n\t\tginput=New gxtkInput\r\n\t\tgaudio=New gxtkAudio\r\n\r\n\t\tbb_input__1Set_1Input_1Device(ginput)\r\n\t\tbb_audio__1Set_1Audio_1Device(gaudio)\r\n\t\t\r\n\t\tstartMillis=BlitzMaxMillisecs()\r\n\t\t\r\n\t\tSetFrameRate( 0 )\r\n\t\t\r\n\t\tInvokeOnCreate()\r\n\t\tInvokeOnRender()\r\n\t\tUpdate()\r\n\tEndMethod\r\n\t\r\n\tMethod Update()\r\n\t\tWhile Not AppTerminate()\r\n\t\t\tIf Not updatePeriod return\r\n\t\t\tLocal updates:Int = 0\r\n\t\t\t\r\n\t\t\tRepeat\r\n\t\t\t\tnextUpdate:+updatePeriod\r\n\t\t\t\tInvokeOnUpdate()\r\n\t\t\t\tIf Not updatePeriod Then Exit\r\n\t\t\t\tIf nextUpdate>BlitzMaxMillisecs() Then Exit\r\n\t\t\t\tupdates:+1\r\n\t\t\t\tIf updates = 7 Then\r\n\t\t\t\t\tnextUpdate = BlitzMaxMillisecs()\r\n\t\t\t\t\tExit\r\n\t\t\t\tEndIf\r\n\t\t\tForever\r\n\t\t\tInvokeOnRender()\r\n\t\t\tLocal del:Int = nextUpdate - BlitzMaxMillisecs()\r\n\t\t\tIf del < 1 Then del = 1\r\n\t\t\tDelay(del)\r\n\t\tWend\r\n\tEndMethod\r\n\t\r\n\tMethod InvokeOnCreate()\r\n\t\tIf dead Return\r\n\t\tdead = 1\r\n\t\tOnCreate()\r\n\t\tdead = 0\r\n\tEndMethod\r\n\r\n\tMethod InvokeOnUpdate()\r\n\t\tIf dead Or suspended Or Not updateRate Or vloading Return\r\n\t\tOnUpdate()\r\n\tEndMethod\r\n\t\r\n\tMethod InvokeOnRender()\r\n\t\tIf dead Or suspended Return\r\n\t\tggraphics.BeginRender()\r\n\t\tIf vloading\r\n\t\t\tOnLoading()\r\n\t\tElse\r\n\t\t\tOnRender()\r\n\t\tEndIf\r\n\t\tggraphics.EndRender()\r\n\tEndMethod\r\n\t\r\n\t\r\n\tMethod SetFrameRate( fps:Int )\r\n\t\tIf fps\r\n\t\t\tupdatePeriod=1000.0\/fps\r\n\t\t\tnextUpdate=BlitzMaxMillisecs() +updatePeriod\r\n\t\tElse\r\n\t\t\tupdatePeriod=0\r\n\t\tEndIf\r\n\tEndMethod\r\n\r\n\tMethod LoadState:String()\r\n'\t\tvar file:SharedObject=SharedObject.getLocal( \"gxtkapp\" );\r\n'\t\tvar state:String=file.data.state;\r\n'\t\tfile.close();\r\n'\t\tif( state ) return state;\r\n\t\tReturn \"\"\r\n\tEndMethod\r\n\t\r\n\tMethod SaveState:Int( state:String )\r\n'\t\tvar file:SharedObject=SharedObject.getLocal( \"gxtkapp\" );\r\n'\t\tfile.data.state=state;\r\n'\t\tfile.close();\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod LoadString:String( path:String )\r\n\t\tpath = \"data\/\" + path\r\n\t\tTry\r\n\t\t\tReturn LoadText( path )\r\n\t\tCatch ReadFail:Object\r\n\t\t\tReturn Null\r\n\t\tEndTry\r\n\tEndMethod\r\n\t\r\n\t' ***** GXTK API *****\r\n\t\r\n\tMethod GraphicsDevice:gxtkGraphics()\r\n\t\tReturn ggraphics\r\n\tEndMethod\r\n\r\n\tMethod InputDevice:gxtkInput()\r\n\t\tReturn ginput\r\n\tEndMethod\r\n\r\n\tMethod AudioDevice:gxtkAudio()\r\n\t\tReturn gaudio\r\n\tEndMethod\r\n\r\n\tMethod SetUpdateRate:Int(hertz:Int)\r\n\t\tupdateRate = hertz\r\n\t\tIf Not vloading Then SetFrameRate(updateRate)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod MilliSecs:Int()\r\n\t\tReturn BlitzMaxMillisecs() - startMillis\r\n\tEndMethod\r\n\t\r\n\tMethod Loading:Int()\r\n\t\tReturn vloading\r\n\tEndMethod\r\n\r\n\tMethod OnCreate:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod OnUpdate:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod OnSuspend:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod OnResume:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod OnRender:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod OnLoading:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkGraphics\r\n\tField gmode:Int = 1\r\n\tField ix:Float=1,iy:Float,jx:Float,jy:Float=1,tx:Float,ty:Float\r\n\tField sx:Float=1,sy:Float=1,rot:Float=0\r\n\t\r\n\tMethod Mode:Int()\r\n\t\tReturn gmode\r\n\tEndMethod\r\n\t\r\n\tMethod Cls:Int(r:Int = 0, g:Int = 0, b:Int = 0)\r\n\t\tBlitzMaxCls(r, g, b)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawPoint:Int(x:Float, y:Float)\r\n\t\tLocal nx:Float = TransX(x,y)\r\n\t\tLocal ny:Float = TransY(x,y)\r\n\t\tPlot nx, ny\r\n\tEndMethod\r\n\t\r\n\tMethod LoadSurface:gxtkSurface(path:String)\r\n\t\tLocal image:TImage = LoadImage(\"data\/\"+path)\r\n\t\tIf image Then\r\n\t\t\tLocal gs:gxtkSurface = New gxtkSurface\r\n\t\t\tgs.setImage(image)\r\n\t\t\tReturn gs\r\n\t\tEndIf\r\n\t\tReturn Null\r\n\tEndMethod\r\n\t\r\n\tMethod BeginRender()\r\n\tEndMethod\r\n\t\r\n\tMethod EndRender()\r\n\t\tFlip\r\n\tEndMethod\r\n\t\r\n\tMethod SetColor:Int(r:Int, g:Int, b:Int)\r\n\t\tBlitzMaxSetColor(r, g, b)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod SetAlpha:Int(a:Float)\r\n\t\tBlitzMaxSetAlpha(a)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod SetBlend:Int(blend:Int)\r\n\t\tBlitzMaxSetBlend(blend)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod Width:Int()\r\n\t\tReturn GraphicsWidth()\r\n\tEndMethod\r\n\t\r\n\tMethod Height:Int()\r\n\t\tReturn GraphicsHeight()\r\n\tEndMethod\r\n\t\r\n\tMethod SetScissor:Int(x:Int, y:Int, w:Int, h:Int)\r\n\t\tSetViewport(x, y, w, h) ' NOT TESTED!\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod TransX:Float(x:Float, y:Float)\r\n\t\tReturn ix*x + jx*y + tx\r\n\tEndMethod\r\n\t\r\n\tMethod TransY:Float(x:Float, y:Float)\r\n\t\tReturn iy*x + jy*y + ty\r\n\tEndMethod\r\n\t\r\n\tMethod SetMatrix:Int(ix:Float,iy:Float,jx:Float,jy:Float,tx:Float,ty:Float)\r\n\t\tSelf.ix = ix ; Self.iy = iy\r\n\t\tSelf.jx = jx ; Self.jy = jy\r\n\t\tSelf.tx = tx ; Self.ty = ty\r\n\t\tsx = Sqr(ix*ix+iy*iy)\r\n\t\tsy = Sqr(jx*jx+jy*jy)\r\n\t\trot = Atan2( iy, ix )\r\n\t\tIf ix < 0 Then\r\n\t\t\tsx = -sx\r\n\t\t\trot :+ 180\r\n\t\tEndIf\r\n\t\tIf jy < 0 Then sy = -sy\r\n\t\tSetTransform( rot, sx, sy )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawSurface:Int(surface:gxtkSurface,x:Float,y:Float)\r\n\t\tLocal nx:Float = TransX(x,y)\r\n\t\tLocal ny:Float = TransY(x,y)\r\n\t\tDrawImage(surface.image, nx, ny, 0)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawSurface2:Int(surface:gxtkSurface,x:Float,y:Float, srcx:Int, srcy:Int, srcw:Int, srch:Int )\r\n\t\tLocal nx:Float = TransX(x,y)\r\n\t\tLocal ny:Float = TransY(x,y)\r\n\t\tDrawSubImageRect(surface.image, nx, ny, srcw, srch, srcx, srcy, srcw, srch)\t\t\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawLine:Int( x1:Float,y1:Float,x2:Float,y2:Float )\r\n\t\tLocal nx1:Float = TransX(x1,y1)\r\n\t\tLocal ny1:Float = TransY(x1,y1)\r\n\t\tLocal nx2:Float = TransX(x2,y2)\r\n\t\tLocal ny2:Float = TransY(x2,y2)\r\n\t\t' Need to reset transform so that BlitzMax doesn't try to apply rotation\r\n\t\tSetTransform( 0, 1, 1 )\r\n\t\tBlitzMaxDrawLine(nx1, ny1, nx2, ny2)\r\n\t\tSetTransform( rot, sx, sy )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawOval:Int( x:Float, y:Float, w:Float, h:Float )\r\n\t\tLocal nx:Float = TransX(x,y)\r\n\t\tLocal ny:Float = TransY(x,y)\r\n\t\tBlitzMaxDrawOval(nx, ny, w, h)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawPoly:Int(vertices:Float[])\r\n\t\t' setting the origin to use the current rotation translation\r\n\t\tSetOrigin(TransX(0,0), TransY(0,0))\r\n\t\tBlitzMaxDrawPoly( vertices )\r\n\t\tSetOrigin(0, 0)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawRect:Int( x:Float, y:Float, w:Float, h:Float )\r\n\t\tLocal nx:Float = TransX(x,y)\r\n\t\tLocal ny:Float = TransY(x,y)\r\n\t\tBlitzMaxDrawRect(nx, ny, w, h)\r\n\t\tReturn 0\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkInput\r\n\tMethod MouseX:Float()\r\n\t\tReturn BRL.PolledInput.MouseX()\r\n\tEndMethod\r\n\r\n\tMethod MouseY:Float()\r\n\t\tReturn BRL.PolledInput.MouseY()\r\n\tEndMethod\r\n\t\r\n\tMethod KeyDown:Int( key:Int )\r\n\t\tif( key = 384 ) key = 1 ' change TOUCH0 to MOUSE_LMB\r\n\r\n\t\tIf( key >= 1 And key <= 3 )\r\n\t\t\tReturn BRL.PolledInput.MouseDown( key )\r\n\t\tEndIf\r\n\t\tIf key < 256\r\n\t\t\tReturn BRL.PolledInput.KeyDown( key )\r\n\t\tElse\r\n\t\t\tReturn 0\r\n\t\tEndIf\r\n\tEndMethod\r\n\r\n\tMethod KeyHit:Int( key:Int )\r\n\t\tif( key = 384 ) key = 1 ' change TOUCH0 to MOUSE_LMB\r\n\t\tIf( key >= 1 And key <= 3 )\r\n\t\t\tReturn BRL.PolledInput.MouseHit( key )\r\n\t\tEndIf\r\n\t\tIf key < 256\r\n\t\t\tReturn BRL.PolledInput.KeyHit( key )\r\n\t\tElse\r\n\t\t\tReturn 0\r\n\t\tEndIf\r\n\tEndMethod\r\n\r\n\tMethod GetChar:Int()\r\n\t\tReturn BRL.PolledInput.GetChar()\r\n\tEndMethod\r\n\r\n\tMethod JoyX:Int( index:Int )\r\n\t\tReturn Pub.FreeJoy.JoyX( index )\r\n\tEndMethod\r\n\r\n\tMethod JoyY:Int( index:Int )\r\n\t\tReturn Pub.FreeJoy.JoyY( index )\r\n\tEndMethod\r\n\r\n\tMethod JoyZ:Int( index:Int )\r\n\t\tReturn Pub.FreeJoy.JoyZ( index )\r\n\tEndMethod\r\n\r\n\tMethod TouchX:Float( index:Int )\r\n\t\tReturn BRL.PolledInput.MouseX()\r\n\tEndMethod\r\n\r\n\tMethod TouchY:Float( index:Int )\r\n\t\tReturn BRL.PolledInput.MouseY()\r\n\tEndMethod\r\n\t\r\n\tMethod AccelX:Int()\r\n\t\treturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod AccelY:Int()\r\n\t\treturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod AccelZ:Int()\r\n\t\treturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod SetKeyboardEnabled:Int( enabled:int )\r\n\t\tReturn 0\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkChannel\r\n\tField channel:TChannel\t' null then not playing\r\n\tField sample:gxtkSample\r\n\tField loops:int\r\n\t'Field transform:SoundTransform=new SoundTransform()\r\n\t'Field pausepos:Number\r\n\tField state:int\r\n\t\r\n\tMethod New()\r\n\t\tchannel = New TChannel\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkAudio\r\n\tField amusicState:Int = 0\r\n\tField channels:gxtkChannel[] = New gxtkChannel[33]\r\n\tConst MUSIC_CHANNEL:Int = 32\r\n\tField music:gxtkSample\r\n\t\r\n\tMethod New()\r\n\t\tFor local i:Int = 0 To 33 - 1\r\n\t\t\tchannels[i] = New gxtkChannel\r\n\t\t\tchannels[i].channel = AllocChannel()\r\n\t\tNext\r\n\tEndMethod\r\n\t\r\n\tMethod MusicState:Int()\r\n\t\t' Monkey Docs: \t0 if the music is currently stopped\r\n\t\t'\t\t\t\t1 if the music is currently playing\r\n\t\t'\t\t\t\t-1 if the music state cannot be determined\r\n\r\n\t\tLocal chan:gxtkChannel = channels[MUSIC_CHANNEL]\r\n\t\tIf chan.channel <> Null Then\r\n\t\t\tIf ChannelPlaying(chan.channel) Then Return 1 Else Return 0\r\n\t\tEndIf\r\n\t\t\r\n\t\tReturn -1\r\n\tEndMethod\r\n\t\r\n\tMethod PlayMusic:Int( path:String, flags:Int )\r\n\t\tStopMusic()\r\n\t\tmusic = LoadSample( path )\r\n\t\tIf Not music Then Return -1\r\n\t\t\r\n\t\tPlaySample(music, MUSIC_CHANNEL, flags)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod StopMusic:Int()\r\n\t\tStopChannel( MUSIC_CHANNEL )\r\n\t\t\r\n\t\tIf music Then\r\n\t\t\tmusic.Discard()\r\n\t\t\tmusic = null\r\n\t\tEndIf\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod ChannelState:int( channel:int )\r\n\t\t' Monkey Docs: \t0 if the channel is currently stopped\r\n\t\t'\t\t\t\t1 if the channel is currently playing\r\n\t\t'\t\t\t\t2 if the channel is currently paused\r\n\t\t'\t\t\t\t-1 if the channel state cannot be determined\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tIf chan.channel <> Null Then\r\n\t\t\tIf ChannelPlaying(chan.channel) Then Return 1 Else Return 0\r\n\t\tEndIf\r\n\t\t\r\n\t\tReturn -1\r\n\tEndMethod\r\n\t\r\n\tMethod StopChannel( channel:Int )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\t\r\n\t\tIf chan.state <> 0\r\n\t\t\tchan.channel.Stop()\r\n\t\t\tchan.channel=null\r\n\t\t\tchan.sample=null\r\n\t\t\tchan.state=0\r\n\t\tEndIf\r\n\tEndMethod\r\n\t\r\n\tMethod PauseChannel:Int( channel:Int)\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tchan.channel.SetPaused(True)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod ResumeChannel:Int( channel:Int)\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tchan.channel.SetPaused(False)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod PlaySample( sound:gxtkSample, channel:Int, flags:Int )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tIf chan.state <> 0 Then chan.channel.SetPaused(True)\r\n\t\t\r\n\t\tchan.sample = sound\r\n\t\tchan.loops = flags\r\n\t\tchan.state = 1\r\n\t\t\r\n\t\t' if looping, we need to reload the sound with the looping flag\r\n\t\tIf flags <> sound.loop\r\n\t\t\tLocal smp:TSound = LoadSound(sound.path, flags)\r\n\t\t\tsound.setSound(smp)\r\n\t\t\tsound.loop = flags\r\n\t\tEndIf\r\n\t\r\n\t\tPlaySound( sound.sound, chan.channel )\r\n\tEndMethod\r\n\r\n\tMethod SetPan( channel:Int, pan:Float )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tchan.channel.SetPan(pan)\r\n\tEndMethod\r\n\r\n\tMethod SetRate( channel:Int, rate:Float )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tchan.channel.SetRate(rate)\r\n\tEndMethod\r\n\r\n\tMethod PauseMusic:Int()\r\n\t\tLocal chan:gxtkChannel = channels[MUSIC_CHANNEL]\r\n\t\tchan.channel.SetPaused(True)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod ResumeMusic:Int()\r\n\t\tLocal chan:gxtkChannel = channels[MUSIC_CHANNEL]\r\n\t\tchan.channel.SetPaused(False)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod SetMusicVolume:Int( volume:Float )\r\n\t\tSetVolume( MUSIC_CHANNEL, volume )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod SetVolume:Int( channel:Int, volume:Float )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tchan.channel.SetVolume(volume)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod LoadSample:gxtkSample( path:String )\r\n\t\tLocal extension:String = ExtractExt( path)\r\n\t\tIf extension = \"ogg\" Or extension = \"wav\" Then\r\n\t\t\tLocal sound:TSound = LoadSound(\"data\/\"+path)\r\n\t\t\tIf sound Then\r\n\t\t\t\tLocal gs:gxtkSample = New gxtkSample\r\n\t\t\t\tgs.setSound(sound)\r\n\t\t\t\tgs.path = \"data\/\"+path\r\n\t\t\t\tReturn gs\r\n\t\t\tEndIf\r\n\t\tElse\r\n\t\t\tRuntimeError \"BlitzMax can only use ogg and wav file formats\"\r\n\t\tEndIf\r\n\t\tReturn Null\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkSample\r\n\tField sound:TSound\r\n\tField path:String\r\n\tField loop:Int\r\n\t\r\n\tMethod setSound(sound:TSound)\r\n\t\tSelf.sound = sound\r\n\tEndMethod\r\n\t\r\n\tMethod Discard()\r\n\t\tSelf.sound = null\r\n\tEndMethod\r\nEndType\r\n\r\nFunction BlitzMaxDrawPoly:Int(vertices:Float[])\r\n\tDrawPoly vertices\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxDrawRect:Int( x:Float, y:Float, w:Float, h:Float )\r\n\tDrawRect x, y, w, h\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxDrawOval:Int( x:Float, y:Float, w:Float, h:Float )\r\n\tDrawOval x, y, w, h\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxDrawLine:Int( x1:Float,y1:Float,x2:Float,y2:Float )\r\n\tDrawLine x1, y1, x2, y2\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxMillisecs:Int()\r\n\tReturn MilliSecs()\r\nEndFunction\r\n\r\nFunction BlitzMaxSetColor(r:Int, g:Int, b:Int)\r\n\tSetColor(r, g, b)\r\nEndFunction\r\n\r\nFunction BlitzMaxSetBlend(blend:Int)\r\n\tSelect blend\r\n\t\tCase 0\r\n\t\t\tSetBlend( ALPHABLEND )\r\n\t\tCase 1\r\n\t\t\tSetBlend( LIGHTBLEND )\r\n\tEnd Select\r\nEndFunction\r\n\r\nFunction BlitzMaxSetAlpha(a:Float)\r\n\tSetAlpha(a)\r\nEndFunction\r\n\r\nFunction BlitzMaxCls(r:Int = 0, g:Int = 0, b:Int = 0)\r\n\tSetClsColor(r, g, b)\r\n\tCls\r\nEndFunction\r\n\r\nType gxtkSurface\r\n\tField w:Int, h:Int\r\n\tField image:TImage\r\n\t\r\n\tMethod setImage(image:TImage)\r\n\t\tSelf.image = image\r\n\tEndMethod\r\n\t\r\n\tMethod Width:Int()\r\n\t\tReturn image.Width\r\n\tEndMethod\r\n\t\r\n\tMethod Height:Int()\r\n\t\tReturn image.Height\r\n\tEndMethod\r\n\t\r\n\tMethod Discard()\r\n\tEndMethod\r\nEndType\r\n\r\n' ***** End mojo.bmax.bmx ******\r\n\r\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"aecff25f95af1bd7d7446352b4f59ecde0b91a4c","subject":"reinsert right number of items","message":"reinsert right number of items\n","repos":"Leushenko\/blue-moon","old_file":"bluetable.bmx","new_file":"bluetable.bmx","new_contents":"\n' Blue Moon\n' Lua-table implementation\n' uses simple linear probing for collision resolution and a shockingly naive reallocator\n\n\nSuperStrict\n\nImport \"blueallocator.bmx\"\n\n\nPrivate\nExtern\n\tFunction frexp:Double(d:Double, Exp:Int Ptr) = \"frexp\"\nEnd Extern\nPublic\n\nType BlueTable Final\n\tFunction Get:Long(tbl:Byte Ptr, key:Long)\n\t\tLocal tag:Int = Int Ptr(Varptr(key))[1], idx:Int\n\t\t\n\t\tIf tag = BlueTypeTag.NANBOX | BlueTypeTag.STR\t'string - common case\n\t\t\tidx = Int Ptr(Int(key))[1]\n\t\tElseIf tag & BlueTypeTag.NANBOX_CHK <> BlueTypeTag.NANBOX\t'number\n\t\t\tLocal d:Double ; Long Ptr(Varptr(d))[0] = key ; idx = Abs Int(d)\n\t\t\tIf d = idx\t'int key\n\t\t\t\tLocal arr:Byte Ptr = Byte Ptr Ptr(tbl)[3]\n\t\t\t\tIf arr And idx < Int Ptr(arr)[-1] Then Return Long Ptr(arr)[idx]\t'if this is nil, it won't be in the hash part anyway\n\t\t\tElse\n\t\t\t\td = frexp(d, Varptr(idx)) * ($7fffffff - 1024)\t'INT_MAX - DBL_MAX_EXP\n\t\t\t\tidx = Abs(idx) + Int(d)\n\t\t\tEndIf\n\t\tElseIf tag = BlueTypeTag.NANBOX | BlueTypeTag.NIL\t'nil -> nil\n\t\t\tReturn key\n\t\tElse\t'pointer (needs improvement)\n\t\t\tidx = Int(key) Shr 3\n\t\tEndIf\n\t\t\n\t\tLocal hashpart:Byte Ptr = Byte Ptr Ptr(tbl)[2]\n\t\tIf hashpart\n\t\t\tLocal hsize:Int = 1 Shl Int Ptr(hashpart)[-1]\n\t\t\tidx = idx & (hsize - 1)\t'apparently this is faster than Mod\n\t\t\tFor Local i:Int = idx Until hsize\t'naive linear probe\n\t\t\t\tIf Long Ptr(hashpart)[2 * i] = key Then Return Long Ptr(hashpart)[2 * i + 1]\n\t\t\tNext\n\t\t\tFor Local i:Int = 0 Until idx\t'yep\n\t\t\t\tIf Long Ptr(hashpart)[2 * i] = key Then Return Long Ptr(hashpart)[2 * i + 1]\n\t\t\tNext\n\t\tEndIf\n\t\t\n\t\tLocal ret:Long ; Int Ptr(Varptr(ret))[1] = BlueTypeTag.NANBOX | BlueTypeTag.NIL\t'why can't i shift longs?\n\t\tReturn ret\n\tEnd Function\n\t\n\tFunction Set(mem:BlueVMMemory, tbl:Byte Ptr, key:Long, val:Long)\n\t\tLocal tag:Int = Int Ptr(Varptr(key))[1], idx:Int, slot:Long Ptr = Null, writeKey:Int = False\n\t\tConst NILTAG:Int = BlueTypeTag.NANBOX | BlueTypeTag.NIL\n\t\t\n\t\tIf tag = NILTAG Then Return\t'nil is not a valid key\n\t\t\n\t\tIf tag & BlueTypeTag.NANBOX_CHK <> BlueTypeTag.NANBOX\t'if key is an int and less than arraylength\n\t\t\tLocal d:Double ; Long Ptr(Varptr(d))[0] = key ; idx = Abs Int(d)\n\t\t\tIf d = idx\n\t\t\t\tLocal arraypart:Byte Ptr = Byte Ptr Ptr(tbl)[3]\n\t\t\t\tIf arraypart <> Null And idx < Int Ptr(arraypart)[-1] Then slot = Long Ptr(arraypart) + idx\n\t\t\tEndIf\n\t\tEndIf\n\t\tIf slot = Null\t'elsewise if hashcount < hashsize\n\t\t\tLocal hashpart:Byte Ptr = Byte Ptr Ptr(tbl)[2]\n\t\t\tIf hashpart <> Null\n\t\t\t\tLocal hsize:Int = 1 Shl Int Ptr(hashpart)[-1]\n\t\t\t\tIf Int Ptr(hashpart)[-2] < hsize\t'there's a slot free somewhere\n\t\t\t\t\t\n\t\t\t\t\tIf tag = BlueTypeTag.NANBOX | BlueTypeTag.STR\t'string - common case\n\t\t\t\t\t\tidx = Int Ptr(Int(key))[1]\n\t\t\t\t\tElseIf tag & BlueTypeTag.NANBOX_CHK <> BlueTypeTag.NANBOX\t'non-integer\n\t\t\t\t\t\tLocal d:Double ; Long Ptr(Varptr(d))[0] = key\n\t\t\t\t\t\td = frexp(d, Varptr(idx)) * ($7fffffff - 1024)\t'INT_MAX - DBL_MAX_EXP\n\t\t\t\t\t\tidx = Abs(idx) + Int(d)\n\t\t\t\t\tElse\t'pointer\n\t\t\t\t\t\tidx = Int(key) Shr 3\n\t\t\t\t\tEndIf\n\t\t\t\t\t\n\t\t\t\t\tidx = idx & (hsize - 1)\t'fastmod\n\t\t\t\t\tFor Local i:Int = idx Until hsize\n\t\t\t\t\t\tIf Long Ptr(hashpart)[2 * i] = key Or Int Ptr(hashpart)[4 * i + 1] = NILTAG Then slot = Long Ptr(hashpart) + (2 * i + 1) ; Exit\n\t\t\t\t\tNext\n\t\t\t\t\tIf Not slot\n\t\t\t\t\t\tFor Local i:Int = 0 Until idx\n\t\t\t\t\t\t\tIf Long Ptr(hashpart)[2 * i] = key Or Int Ptr(hashpart)[4 * i + 1] = NILTAG Then slot = Long Ptr(hashpart) + (2 * i + 1) ; Exit\n\t\t\t\t\t\tNext\n\t\t\t\t\tEndIf\n\t\t\t\t\t\n\t\t\t\tEndIf\n\t\t\tEndIf\n\t\t\tIf slot Then Int Ptr(hashpart)[-2] :+ 1\t'no write barrier needed to increment use count (not pointer)\n\t\t\twriteKey = True\n\t\tEndIf\n\t\t\n\t\tIf slot = Null\n\t\t\tResize(mem, tbl, key) ; Set mem, tbl, key, val\n\t\tElse\n\t\t\tmem.Write(slot, val)\n\t\t\tIf writeKey Then mem.Write(slot - 1, key)\n\t\tEndIf\n\tEnd Function\n\t\n\tFunction Resize(mem:BlueVMMemory, tbl:Byte Ptr, key:Long)\n\t\tLocal hashpart:Byte Ptr = Byte Ptr Ptr(tbl)[2], arraypart:Byte Ptr = Byte Ptr Ptr(tbl)[3]\n\t\tConst NILTAG:Int = BlueTypeTag.NANBOX | BlueTypeTag.NIL\n\t\t\n\t\tLocal asize:Int = 0, tsize:Int = 0, numcount:Int[32]\n\t\tIf arraypart\t'compute new array size\n\t\t\tIf Int Ptr(arraypart)[1] <> NILTAG Then numcount[0] = 1\n\t\t\tLocal cell:Int = 1, cellp2:Int = 2 ^ cell\n\t\t\tFor Local i:Int = 1 Until Int Ptr(arraypart)[-1]\n\t\t\t\tIf i >= cellp2 Then cell :+ 1 ; cellp2 = 2 ^ cell\n\t\t\t\tIf Int Ptr(arraypart)[i * 2 + 1] <> NILTAG Then numcount[cell] :+ 1\n\t\t\tNext\n\t\tEndIf\n\t\tIf hashpart\n\t\t\tFor Local i:Int = 0 Until Int Ptr(hashpart)[-2]\n\t\t\t\tLocal tag2:Int = Int Ptr(hashpart)[i * 4 + 1]\n\t\t\t\tIf tag2 & BlueTypeTag.NANBOX_CHK <> BlueTypeTag.NANBOX\n\t\t\t\t\tLocal d:Double = Double Ptr(hashpart)[i * 2]\n\t\t\t\t\tIf d = Abs Int(d) Then numcount[Ceil(Log(d + 1) \/ Log(2))] :+ 1 Else tsize :+ 1\n\t\t\t\tElse\n\t\t\t\t\ttsize :+ 1\t'get started on new table size\n\t\t\t\tEndIf\n\t\t\tNext\n\t\tEndIf\n\t\t\n\t\tLocal tag:Int = Int Ptr(Varptr(key))[1]\t'add key to the appropriate one\n\t\tIf tag & BlueTypeTag.NANBOX_CHK <> BlueTypeTag.NANBOX\n\t\t\tLocal d:Double = Double Ptr(Varptr(key))[0]\n\t\t\tIf d = Abs Int(d) Then numcount[Ceil(Log(d + 1) \/ Log(2))] :+ 1 Else tsize :+ 1\n\t\tElse\n\t\t\ttsize :+ 1\n\t\tEndIf\n\t\tFor Local i:Int = 0 Until 32\t'tally up\n\t\t\tIf i Then numcount[i] :+ numcount[i - 1]\n\t\t\tIf numcount[i] > 2 ^ i \/ 2 Then asize = 2 ^ i\n\t\tNext\n\t\tIf arraypart <> Null\t'complete new table size with any discarded array elements\n\t\t\tFor Local i:Int = asize Until Int Ptr(arraypart)[-1]\n\t\t\t\tIf Int Ptr(arraypart)[i * 2 + 1] <> NILTAG Then tsize :+ 1\n\t\t\tNext\n\t\tEndIf\n\t\t\n\t\tLocal newarray:Byte Ptr = Null, newtable:Byte Ptr = Null\t'allocate and copy\n\t\tLocal oldasize:Int = 0 ; If arraypart Then oldasize = Int Ptr(arraypart)[-1]\n\t\tLocal oldtsize:Int = 0 ; If hashpart Then oldtsize = Int Ptr(hashpart)[-1]\n\t\t\n\t\tIf asize <> oldasize\n\t\t\tnewarray = mem.AllocObject(asize * 8 + 8, BlueTypeTag.ARR) + 8\n\t\t\tFor Local i:Int = 0 Until asize\n\t\t\t\tInt Ptr(newarray)[i * 2 + 1] = NILTAG\n\t\t\tNext\n\t\t\tInt Ptr(newarray)[-1] = asize ; Byte Ptr Ptr(tbl)[3] = newarray\n\t\tElseIf asize = 0\n\t\t\tInt Ptr(tbl)[3] = 0\n\t\tElse\n\t\t\tnewarray = arraypart ; arraypart = Null\n\t\tEndIf\n\t\tIf tsize <> oldtsize\n\t\t\tnewtable = mem.AllocObject(2 ^ tsize * 16 + 8, BlueTypeTag.HASH)\n\t\t\tFor Local i:Int = 0 Until 2 ^ tsize * 2\n\t\t\t\tInt Ptr(newtable)[i * 2 + 1] = NILTAG\n\t\t\tNext\n\t\t\tInt Ptr(newtable)[-1] = tsize ; Int Ptr(newtable)[-2] = 0\n\t\t\tByte Ptr Ptr(tbl)[2] = newtable\n\t\tElseIf tsize = 0\n\t\t\tInt Ptr(tbl)[2] = 0\n\t\tElse\n\t\t\tnewtable = hashpart ; hashpart = Null\n\t\tEndIf\n\t\t\n\t\tIf arraypart\n\t\t\tFor Local i:Int = 0 Until oldasize\t'reinsert values\n\t\t\t\tLocal key:Long ; Double Ptr(Varptr(key))[0] = i\n\t\t\t\tSet mem, tbl, key,Long Ptr(arraypart)[i]\n\t\t\tNext\n\t\tEndIf\n\t\tIf hashpart\n\t\t\tFor Local i:Int = 0 Until 2 ^ oldtsize\n\t\t\t\tSet mem, tbl, Long Ptr(hashpart)[i * 2], Long Ptr(hashpart)[i * 2 + 1]\n\t\t\tNext\n\t\tEndIf\n\tEnd Function\nEnd Type\n\n","old_contents":"\n' Blue Moon\n' Lua-table implementation\n' uses simple linear probing for collision resolution and a shockingly naive reallocator\n\n\nSuperStrict\n\nImport \"blueallocator.bmx\"\n\n\nPrivate\nExtern\n\tFunction frexp:Double(d:Double, Exp:Int Ptr) = \"frexp\"\nEnd Extern\nPublic\n\nType BlueTable Final\n\tFunction Get:Long(tbl:Byte Ptr, key:Long)\n\t\tLocal tag:Int = Int Ptr(Varptr(key))[1], idx:Int\n\t\t\n\t\tIf tag = BlueTypeTag.NANBOX | BlueTypeTag.STR\t'string - common case\n\t\t\tidx = Int Ptr(Int(key))[1]\n\t\tElseIf tag & BlueTypeTag.NANBOX_CHK <> BlueTypeTag.NANBOX\t'number\n\t\t\tLocal d:Double ; Long Ptr(Varptr(d))[0] = key ; idx = Abs Int(d)\n\t\t\tIf d = idx\t'int key\n\t\t\t\tLocal arr:Byte Ptr = Byte Ptr Ptr(tbl)[3]\n\t\t\t\tIf arr And idx < Int Ptr(arr)[-1] Then Return Long Ptr(arr)[idx]\t'if this is nil, it won't be in the hash part anyway\n\t\t\tElse\n\t\t\t\td = frexp(d, Varptr(idx)) * ($7fffffff - 1024)\t'INT_MAX - DBL_MAX_EXP\n\t\t\t\tidx = Abs(idx) + Int(d)\n\t\t\tEndIf\n\t\tElseIf tag = BlueTypeTag.NANBOX | BlueTypeTag.NIL\t'nil -> nil\n\t\t\tReturn key\n\t\tElse\t'pointer (needs improvement)\n\t\t\tidx = Int(key) Shr 3\n\t\tEndIf\n\t\t\n\t\tLocal hashpart:Byte Ptr = Byte Ptr Ptr(tbl)[2]\n\t\tIf hashpart\n\t\t\tLocal hsize:Int = 1 Shl Int Ptr(hashpart)[-1]\n\t\t\tidx = idx & (hsize - 1)\t'apparently this is faster than Mod\n\t\t\tFor Local i:Int = idx Until hsize\t'naive linear probe\n\t\t\t\tIf Long Ptr(hashpart)[2 * i] = key Then Return Long Ptr(hashpart)[2 * i + 1]\n\t\t\tNext\n\t\t\tFor Local i:Int = 0 Until idx\t'yep\n\t\t\t\tIf Long Ptr(hashpart)[2 * i] = key Then Return Long Ptr(hashpart)[2 * i + 1]\n\t\t\tNext\n\t\tEndIf\n\t\t\n\t\tLocal ret:Long ; Int Ptr(Varptr(ret))[1] = BlueTypeTag.NANBOX | BlueTypeTag.NIL\t'why can't i shift longs?\n\t\tReturn ret\n\tEnd Function\n\t\n\tFunction Set(mem:BlueVMMemory, tbl:Byte Ptr, key:Long, val:Long)\n\t\tLocal tag:Int = Int Ptr(Varptr(key))[1], idx:Int, slot:Long Ptr = Null, writeKey:Int = False\n\t\tConst NILTAG:Int = BlueTypeTag.NANBOX | BlueTypeTag.NIL\n\t\t\n\t\tIf tag = NILTAG Then Return\t'nil is not a valid key\n\t\t\n\t\tIf tag & BlueTypeTag.NANBOX_CHK <> BlueTypeTag.NANBOX\t'if key is an int and less than arraylength\n\t\t\tLocal d:Double ; Long Ptr(Varptr(d))[0] = key ; idx = Abs Int(d)\n\t\t\tIf d = idx\n\t\t\t\tLocal arraypart:Byte Ptr = Byte Ptr Ptr(tbl)[3]\n\t\t\t\tIf arraypart <> Null And idx < Int Ptr(arraypart)[-1] Then slot = Long Ptr(arraypart) + idx\n\t\t\tEndIf\n\t\tEndIf\n\t\tIf slot = Null\t'elsewise if hashcount < hashsize\n\t\t\tLocal hashpart:Byte Ptr = Byte Ptr Ptr(tbl)[2]\n\t\t\tIf hashpart <> Null\n\t\t\t\tLocal hsize:Int = 1 Shl Int Ptr(hashpart)[-1]\n\t\t\t\tIf Int Ptr(hashpart)[-2] < hsize\t'there's a slot free somewhere\n\t\t\t\t\t\n\t\t\t\t\tIf tag = BlueTypeTag.NANBOX | BlueTypeTag.STR\t'string - common case\n\t\t\t\t\t\tidx = Int Ptr(Int(key))[1]\n\t\t\t\t\tElseIf tag & BlueTypeTag.NANBOX_CHK <> BlueTypeTag.NANBOX\t'non-integer\n\t\t\t\t\t\tLocal d:Double ; Long Ptr(Varptr(d))[0] = key\n\t\t\t\t\t\td = frexp(d, Varptr(idx)) * ($7fffffff - 1024)\t'INT_MAX - DBL_MAX_EXP\n\t\t\t\t\t\tidx = Abs(idx) + Int(d)\n\t\t\t\t\tElse\t'pointer\n\t\t\t\t\t\tidx = Int(key) Shr 3\n\t\t\t\t\tEndIf\n\t\t\t\t\t\n\t\t\t\t\tidx = idx & (hsize - 1)\t'fastmod\n\t\t\t\t\tFor Local i:Int = idx Until hsize\n\t\t\t\t\t\tIf Long Ptr(hashpart)[2 * i] = key Or Int Ptr(hashpart)[4 * i + 1] = NILTAG Then slot = Long Ptr(hashpart) + (2 * i + 1) ; Exit\n\t\t\t\t\tNext\n\t\t\t\t\tIf Not slot\n\t\t\t\t\t\tFor Local i:Int = 0 Until idx\n\t\t\t\t\t\t\tIf Long Ptr(hashpart)[2 * i] = key Or Int Ptr(hashpart)[4 * i + 1] = NILTAG Then slot = Long Ptr(hashpart) + (2 * i + 1) ; Exit\n\t\t\t\t\t\tNext\n\t\t\t\t\tEndIf\n\t\t\t\t\t\n\t\t\t\tEndIf\n\t\t\tEndIf\n\t\t\tIf slot Then Int Ptr(hashpart)[-2] :+ 1\t'no write barrier needed to increment use count (not pointer)\n\t\t\twriteKey = True\n\t\tEndIf\n\t\t\n\t\tIf slot = Null\n\t\t\tResize(mem, tbl, key) ; Set mem, tbl, key, val\n\t\tElse\n\t\t\tmem.Write(slot, val)\n\t\t\tIf writeKey Then mem.Write(slot - 1, key)\n\t\tEndIf\n\tEnd Function\n\t\n\tFunction Resize(mem:BlueVMMemory, tbl:Byte Ptr, key:Long)\n\t\tLocal hashpart:Byte Ptr = Byte Ptr Ptr(tbl)[2], arraypart:Byte Ptr = Byte Ptr Ptr(tbl)[3]\n\t\tConst NILTAG:Int = BlueTypeTag.NANBOX | BlueTypeTag.NIL\n\t\t\n\t\tLocal asize:Int = 0, tsize:Int = 0, numcount:Int[32]\n\t\tIf arraypart\t'compute new array size\n\t\t\tIf Int Ptr(arraypart)[1] <> NILTAG Then numcount[0] = 1\n\t\t\tLocal cell:Int = 1, cellp2:Int = 2 ^ cell\n\t\t\tFor Local i:Int = 1 Until Int Ptr(arraypart)[-1]\n\t\t\t\tIf i >= cellp2 Then cell :+ 1 ; cellp2 = 2 ^ cell\n\t\t\t\tIf Int Ptr(arraypart)[i * 2 + 1] <> NILTAG Then numcount[cell] :+ 1\n\t\t\tNext\n\t\tEndIf\n\t\tIf hashpart\n\t\t\tFor Local i:Int = 0 Until Int Ptr(hashpart)[-2]\n\t\t\t\tLocal tag2:Int = Int Ptr(hashpart)[i * 4 + 1]\n\t\t\t\tIf tag2 & BlueTypeTag.NANBOX_CHK <> BlueTypeTag.NANBOX\n\t\t\t\t\tLocal d:Double = Double Ptr(hashpart)[i * 2]\n\t\t\t\t\tIf d = Abs Int(d) Then numcount[Ceil(Log(d + 1) \/ Log(2))] :+ 1 Else tsize :+ 1\n\t\t\t\tElse\n\t\t\t\t\ttsize :+ 1\t'get started on new table size\n\t\t\t\tEndIf\n\t\t\tNext\n\t\tEndIf\n\t\t\n\t\tLocal tag:Int = Int Ptr(Varptr(key))[1]\t'add key to the appropriate one\n\t\tIf tag & BlueTypeTag.NANBOX_CHK <> BlueTypeTag.NANBOX\n\t\t\tLocal d:Double = Double Ptr(Varptr(key))[0]\n\t\t\tIf d = Abs Int(d) Then numcount[Ceil(Log(d + 1) \/ Log(2))] :+ 1 Else tsize :+ 1\n\t\tElse\n\t\t\ttsize :+ 1\n\t\tEndIf\n\t\tFor Local i:Int = 0 Until 32\t'tally up\n\t\t\tIf i Then numcount[i] :+ numcount[i - 1]\n\t\t\tIf numcount[i] > 2 ^ i \/ 2 Then asize = 2 ^ i\n\t\tNext\n\t\tIf arraypart <> Null\t'complete new table size with any discarded array elements\n\t\t\tFor Local i:Int = asize Until Int Ptr(arraypart)[-1]\n\t\t\t\tIf Int Ptr(arraypart)[i * 2 + 1] <> NILTAG Then tsize :+ 1\n\t\t\tNext\n\t\tEndIf\n\t\t\n\t\tLocal newarray:Byte Ptr = Null, newtable:Byte Ptr = Null\t'allocate and copy\n\t\tLocal oldasize:Int = 0 ; If arraypart Then oldasize = Int Ptr(arraypart)[-1]\n\t\tLocal oldtsize:Int = 0 ; If hashpart Then oldtsize = Int Ptr(hashpart)[-1]\n\t\t\n\t\tIf asize <> oldasize\n\t\t\tnewarray = mem.AllocObject(asize * 8 + 8, BlueTypeTag.ARR) + 8\n\t\t\tFor Local i:Int = 0 Until asize\n\t\t\t\tInt Ptr(newarray)[i * 2 + 1] = NILTAG\n\t\t\tNext\n\t\t\tInt Ptr(newarray)[-1] = asize ; Byte Ptr Ptr(tbl)[3] = newarray\n\t\tElseIf asize = 0\n\t\t\tInt Ptr(tbl)[3] = 0\n\t\tElse\n\t\t\tnewarray = arraypart ; arraypart = Null\n\t\tEndIf\n\t\tIf tsize <> oldtsize\n\t\t\tnewtable = mem.AllocObject(2 ^ tsize * 16 + 8, BlueTypeTag.HASH)\n\t\t\tFor Local i:Int = 0 Until 2 ^ tsize * 2\n\t\t\t\tInt Ptr(newtable)[i * 2 + 1] = NILTAG\n\t\t\tNext\n\t\t\tInt Ptr(newtable)[-1] = tsize ; Int Ptr(newtable)[-2] = 0\n\t\t\tByte Ptr Ptr(tbl)[2] = newtable\n\t\tElseIf tsize = 0\n\t\t\tInt Ptr(tbl)[2] = 0\n\t\tElse\n\t\t\tnewtable = hashpart ; hashpart = Null\n\t\tEndIf\n\t\t\n\t\tIf arraypart\n\t\t\tFor Local i:Int = 0 Until oldasize\t'reinsert values\n\t\t\t\tLocal key:Long ; Double Ptr(Varptr(key))[0] = i\n\t\t\t\tSet mem, tbl, key,Long Ptr(arraypart)[i]\n\t\t\tNext\n\t\tEndIf\n\t\tIf hashpart\n\t\t\tFor Local i:Int = 0 Until oldtsize\n\t\t\t\tSet mem, tbl, Long Ptr(hashpart)[i * 2], Long Ptr(hashpart)[i * 2 + 1]\n\t\t\tNext\n\t\tEndIf\n\tEnd Function\nEnd Type\n\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"ada51f323042b9397a9161ddb2cb314f1079d53d","subject":"Fixed userAgent string to match module name","message":"Fixed userAgent string to match module name\n","repos":"Htbaa\/xmlrpc.mod,Htbaa\/xmlrpc.mod,Htbaa\/xmlrpc.mod,Htbaa\/xmlrpc.mod,Htbaa\/xmlrpc.mod","old_file":"transport.bmx","new_file":"transport.bmx","new_contents":"Rem\n\tbbdoc: Transport interface. Use this as a blueprint for any other transport layers\nEnd Rem\nType TXMLRPC_Transport_Interface Abstract\n\tRem\n\t\tbbdoc: Send request to XML-RPC server\n\tEnd Rem\n\tMethod DoRequest:String(message:String) Abstract\nEnd Type\n\nRem\n\tbbdoc: A Dummy transport type. Do not use, deprecated\nEnd Rem\nType TXMLRPC_Transport_Dummy Extends TXMLRPC_Transport_Interface\n\tMethod DoRequest:String(message:String)\n\t\tReturn message\n\tEnd Method\nEnd Type\n\nRem\n\tbbdoc: Exception for TXMLRPC_Transport_Http\nEnd Rem\nType TXMLRPC_Transport_Http_Exception Extends TXMLRPC_Exception\nEnd Type\n\nRem\n\tbbdoc: Simple HTTP transport\n\tabout: Needs HTTP error handling. Implementation is very simple at the moment. Only a simple HTTP request is possible. Authenticated pages or HTTPS isn't supported. For HTTPS, write your own.\nEnd Rem\nType TXMLRPC_Transport_Http Extends TXMLRPC_Transport_Interface\n\tField host:String\n\tField path:String\n\tField port:Int\n\n\tRem\n\t\tbbdoc: Set useragent for HTTP request.\n\t\tabout: This string will be used to identify the client with the XML-RPC server\n\tEnd rem\n\tField userAgent:String = \"htbaapub.mod\/xmlrpc.mod\"\n\t\n\tRem\n\t\tbbdoc: Create TXMLRPC_Transport_Http object\n\tEnd Rem\n\tMethod Create:TXMLRPC_Transport_Http(host:String, path:String, port:Int = 80)\n\t\tSelf.host = host\n\t\tSelf.path = path\n\t\tSelf.port = port\n\t\tReturn Self\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Send request over HTTP\n\tEnd Rem\n\tMethod DoRequest:String(message:String)\n\t\tLocal socket:TSocket = CreateTCPSocket()\n\t\t\n\t\tIf Not ConnectSocket(socket, HostIp(Self.host), Self.port)\n\t\t\tThrow New TXMLRPC_Transport_Http_Exception.Create(\"Couldn't open socket to \" + Self.host)\n\t\tEnd If\n\t\t\n\t\tLocal stream:TSocketStream = CreateSocketStream(socket)\n\n\t\tWriteLine(stream, \"POST \" + Self.path + \" HTTP\/1.0\")\n\t\tWriteLine(stream, \"Accept: *\/*\")\n\t\tWriteLine(stream, \"Host: \" + Self.host)\n\t\tWriteLine(stream, \"Content-type: application\/x-www-form-urlencoded\")\n\t\tWriteLine(stream, \"User-agent: \" + Self.userAgent)\n\t\tWriteLine(stream, \"Pragma: no-cache\")\n\t\tWriteLine(stream, \"Connection: keep-alive\")\n\t\tWriteLine(stream, \"Content-length: \" + message.Length + \"~n\")\n\n\t\tWriteLine(stream, message + \"~n~n\")\n\n\t\tFlushStream(stream)\n\n\t\tLocal buffer:String\n\t\tWhile Not Eof(stream)\n\t\t\tLocal line:String = ReadLine(stream)\n\t\t\tbuffer:+line + \"~n\"\n\t\tWend\n\n\t\tCloseSocket(socket)\n\t\tReturn buffer\n\tEnd Method\nEnd Type\n","old_contents":"Rem\n\tbbdoc: Transport interface. Use this as a blueprint for any other transport layers\nEnd Rem\nType TXMLRPC_Transport_Interface Abstract\n\tRem\n\t\tbbdoc: Send request to XML-RPC server\n\tEnd Rem\n\tMethod DoRequest:String(message:String) Abstract\nEnd Type\n\nRem\n\tbbdoc: A Dummy transport type. Do not use, deprecated\nEnd Rem\nType TXMLRPC_Transport_Dummy Extends TXMLRPC_Transport_Interface\n\tMethod DoRequest:String(message:String)\n\t\tReturn message\n\tEnd Method\nEnd Type\n\nRem\n\tbbdoc: Exception for TXMLRPC_Transport_Http\nEnd Rem\nType TXMLRPC_Transport_Http_Exception Extends TXMLRPC_Exception\nEnd Type\n\nRem\n\tbbdoc: Simple HTTP transport\n\tabout: Needs HTTP error handling, as well as a set time out. Implementation is very simple at the moment. Only a simple HTTP request is possible. Authenticated pages or HTTPS isn't supported. For HTTPS, write your own.\nEnd Rem\nType TXMLRPC_Transport_Http Extends TXMLRPC_Transport_Interface\n\tField host:String\n\tField path:String\n\tField port:Int\n\n\tRem\n\t\tbbdoc: Set useragent for HTTP request.\n\t\tabout: This string will be used to identify the client with the XML-RPC server\n\tEnd rem\n\tField userAgent:String = \"htbaa.mod\/xmlrpc.mod\"\n\t\n\tRem\n\t\tbbdoc: Create TXMLRPC_Transport_Http object\n\tEnd Rem\n\tMethod Create:TXMLRPC_Transport_Http(host:String, path:String, port:Int = 80)\n\t\tSelf.host = host\n\t\tSelf.path = path\n\t\tSelf.port = port\n\t\tReturn Self\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Send request over HTTP\n\tEnd Rem\n\tMethod DoRequest:String(message:String)\n\t\tLocal socket:TSocket = CreateTCPSocket()\n\t\t\n\t\tIf Not ConnectSocket(socket, HostIp(Self.host), Self.port)\n\t\t\tThrow New TXMLRPC_Transport_Http_Exception.Create(\"Couldn't open socket to \" + Self.host)\n\t\tEnd If\n\t\t\n\t\tLocal stream:TSocketStream = CreateSocketStream(socket)\n\n\t\tWriteLine(stream, \"POST \" + Self.path + \" HTTP\/1.0\")\n\t\tWriteLine(stream, \"Accept: *\/*\")\n\t\tWriteLine(stream, \"Host: \" + Self.host)\n\t\tWriteLine(stream, \"Content-type: application\/x-www-form-urlencoded\")\n\t\tWriteLine(stream, \"User-agent: \" + Self.userAgent)\n\t\tWriteLine(stream, \"Pragma: no-cache\")\n\t\tWriteLine(stream, \"Connection: keep-alive\")\n\t\tWriteLine(stream, \"Content-length: \" + message.Length + \"~n\")\n\n\t\tWriteLine(stream, message + \"~n~n\")\n\n\t\tFlushStream(stream)\n\n\t\tLocal buffer:String\n\t\tWhile Not Eof(stream)\n\t\t\tLocal line:String = ReadLine(stream)\n\t\t\tbuffer:+line + \"~n\"\n\t\tWend\n\n\t\tCloseSocket(socket)\n\t\tReturn buffer\n\tEnd Method\nEnd Type\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"b021ef6ef7a8f8a6ea98081d143e8394dd641298","subject":"Fixed b3dloader texture coordinate set issues.","message":"Fixed b3dloader texture coordinate set issues.\n","repos":"kfprimm\/maxb3d,kfprimm\/maxb3d","old_file":"b3dloader.mod\/b3dloader.bmx","new_file":"b3dloader.mod\/b3dloader.bmx","new_contents":"\nStrict\n\nRem\n\tbbdoc: Blitz3D model loader for MaxB3D\nEnd Rem\nModule MaxB3D.B3DLoader\nModuleInfo \"Author: Kevin Primm\"\nModuleInfo \"License: MIT\"\n\nImport MaxB3D.Core\nImport MaxB3D.BoneAnimator\nImport Prime.libB3D\n\nType TMeshLoaderB3D Extends TMeshLoader\n\tField _mesh:TMesh\n\t\n\tMethod Run(mesh:TMesh,stream:TStream,url:Object)\n\t\tLocal model:TBB3DChunk=TBB3DChunk.Load(url)\n\t\tIf model=Null Return False\t\n\t\t\n\t\tLocal olddir$=CurrentDir()\n\t\tIf String(url) ChangeDir(ExtractDir(String(url)))\n\t\t\n\t\tLocal texture:TTexture[model.texs.length]\n\t\tLocal brush:TBrush[model.brus.length]\n\t\t\n\t\tFor Local i=0 To texture.length-1\n\t\t\tLocal chunk:TTEXSChunk=model.texs[i]\t\t\t\n\t\t\ttexture[i]=_currentworld.AddTexture(chunk.file,chunk.flags)\n\t\t\tIf texture[i]\n\t\t\t\ttexture[i].SetBlend chunk.blend\n\t\t\t\ttexture[i].SetPosition chunk.x_pos,chunk.y_pos\n\t\t\t\ttexture[i].SetScale chunk.x_scale,chunk.y_scale\n\t\t\t\ttexture[i].SetRotation chunk.rotation*(180.0\/Pi)\n\t\t\t\tIf chunk.flags&65536 texture[i].SetCoords 1\n\t\t\tEndIf\n\t\tNext\n\t\t\n\t\tFor Local i=0 To brush.length-1\n\t\t\tLocal chunk:TBRUSChunk=model.brus[i]\n\t\t\tbrush[i]=_currentworld.AddBrush()\n\t\t\tbrush[i].SetName chunk.name\n\t\t\tbrush[i].SetColor chunk.red*255,chunk.green*255,chunk.blue*255;brush[i].SetAlpha chunk.alpha\n\t\t\tbrush[i].SetShine chunk.shininess\n\t\t\tbrush[i].SetBlend chunk.blend;brush[i].SetFX chunk.fx\n\t\t\tFor Local j=0 To chunk.n_texs-1\n\t\t\t\tIf chunk.texture_id[j]>-1 brush[i].SetTexture texture[chunk.texture_id[j]],j\n\t\t\tNext\n\t\tNext\t\t\n\t\tChangeDir olddir\n\t\t\n\t\t' model.dump StandardIOStream\n\t\t \n\t\tIf model.node\n\t\t\tParseNode model.node,mesh,brush,mesh\n\t\t\tReturn True\n\t\tEndIf\n\t\tReturn False\n\tEnd Method\n\t\n\tMethod ParseNode(node:TNODEChunk,parent:TEntity,brush:TBrush[],entity:TEntity=Null)\n\t\tLocal meshchunk:TMESHChunk=TMESHChunk(node.kind),bonechunk:TBONEChunk=TBONEChunk(node.kind)\n\t\t\t\t\n\t\tSelect node.kind\n\t\tCase Null\n\t\t\tentity=_currentworld.AddPivot(parent)\n\t\tCase meshchunk\t\t\t\n\t\t\tIf entity=Null entity=_currentworld.AddMesh(\"*null*\",parent)\n\t\t\tLocal mesh:TMesh=TMesh(entity)\n\t\t\tmesh._animator=New TBoneAnimator\n\t\t\t_mesh=mesh\n\t\t\t\n\t\t\tIf meshchunk.brush_id>-1 entity.SetBrush brush[meshchunk.brush_id]\n\t\t\t\n\t\t\tLocal vrts:TVRTSChunk=meshchunk.vrts\n\t\t\tLocal vertsurface:TSurface=New TSurface\n\t\t\tvertsurface.Resize(vrts.xyz.length\/3,0)\n\t\t\t\n\t\t\tFor Local i=0 To vertsurface.CountVertices()-1\n\t\t\t\tvertsurface.SetCoords i,vrts.xyz[i*3+0],vrts.xyz[i*3+1],vrts.xyz[i*3+2]\n\t\t\t\tIf vrts.nxyz vertsurface.SetNormal i,vrts.nxyz[i*3+0],vrts.nxyz[i*3+1],vrts.nxyz[i*3+2]\n\t\t\t\tIf vrts.rgba vertsurface.SetColor i,vrts.rgba[i*4+0]*255,vrts.rgba[i*4+1]*255,vrts.rgba[i*4+2]*255,vrts.rgba[i*4+3]\n\t\t\t\tFor Local j=0 To vrts.SetCount()-1\n\t\t\t\t\tLocal u#,v#\n\t\t\t\t\tIf vrts.SetSize()>1 u=vrts.tex_coords[i][j,0];v=vrts.tex_coords[i][j,1]\n\t\t\t\t\tvertsurface.SetTexCoords i,1-u,v,j\n\t\t\t\tNext\n\t\t\tNext\n\t\t\t\n\t\t\tFor Local i=0 To meshchunk.tris.length-1\n\t\t\t\tLocal tri:TTRISChunk=meshchunk.tris[i]\n\t\t\t\tLocal surface:TSurface=vertsurface.Copy()\n\t\t\t\tsurface.Resize(-1,tri.vertex_id.length\/3)\n\t\t\t\tIf tri.brush_id>-1 surface.SetBrush brush[tri.brush_id]\n\t\t\t\tFor Local t=0 To surface.CountTriangles()-1\n\t\t\t\t\tsurface.SetTriangle t,tri.vertex_id[t*3+0],tri.vertex_id[t*3+1],tri.vertex_id[t*3+2]\n\t\t\t\tNext\n\t\t\t\tIf vrts.nxyz=Null surface.UpdateNormals\t\t\t\n\t\t\t\tmesh.AppendSurface surface\n\t\t\tNext\n\t\tCase bonechunk\n\t\t\tentity=_currentworld.AddBone(parent)\n\t\t\tLocal bone:TBone=TBone(entity)\n\t\t\t\n\t\t\tFor Local surface:TSurface=EachIn _mesh._surfaces\n\t\t\t\tbone.AddSurface surface\n\t\t\t\tFor Local i=0 To bonechunk.vertex_id.length-1\n\t\t\t\t\tbone.AddVertex surface,bonechunk.vertex_id[i],bonechunk.weight[i]\n\t\t\t\tNext\n\t\t\tNext\t\t\t\n\t\t\t\n\t\t\tLocal ident_matrix:TMatrix=TMatrix.Identity()\n\t\t\tFor Local chunk:TKEYSChunk=EachIn node.keys\n\t\t\t\tLocal keys:TAnimKey[chunk.frame.length]\n\t\t\t\tLocal pos#[]=chunk.position,rot#[]=chunk.rotation,scl#[]=chunk.scale\n\t\t\t\tFor Local i=0 To chunk.frame.length-1\n\t\t\t\t\tLocal bonekey:TBoneKey=New TBoneKey\n\t\t\t\t\t\n\t\t\t\t\tIf pos.length>0 bonekey._px=pos[i*3+0];bonekey._py=pos[i*3+1];bonekey._pz=pos[i*3+2]\n\t\t\t\t\tIf rot.length>0 bonekey._rw=rot[i*4+0];bonekey._rx=rot[i*4+1];bonekey._ry=rot[i*4+2];bonekey._rz=rot[i*4+3]\n\t\t\t\t\tIf scl.length>0 bonekey._sx=scl[i*3+0];bonekey._sy=scl[i*3+1];bonekey._sz=scl[i*3+2]\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\tLocal key:TAnimKey=New TAnimKey\n\t\t\t\t\tkey._frame=chunk.frame[i]\n\t\t\t\t\tkey._object=bonekey\n\t\t\t\t\tkeys[i]=key\n\t\t\t\tNext\n\t\t\t\tTBoneAnimator(_mesh._animator).AddBone bone,keys\n\t\t\tNext\n\t\tDefault\n\t\t\tentity=_currentworld.AddPivot(parent)\n\t\tEnd Select\t\t\n\t\t\n\t\tentity.SetName node.name\n\t\tentity.SetPosition node.position[0],node.position[1],node.position[2]\n\t\tLocal pitch#,yaw#,roll#\n\t\tTQuaternion.Euler node.rotation[0],node.rotation[1],node.rotation[2],node.rotation[3],pitch,yaw,roll\n\t\tentity.SetRotation pitch,yaw,roll\n\t\tentity.SetScale node.scale[0],node.scale[1],node.scale[2]\n\t\t\n\t\tFor Local child:TNODEChunk=EachIn node.node\n\t\t\tParseNode child,entity,brush\n\t\tNext\n\t\tIf TMesh(entity) If TBoneAnimator(TMesh(entity)._animator)._root=Null TMesh(entity)._animator=Null\n\t\tIf TBone(entity) TBone(entity)._start_matrix=entity.GetMatrix()\n\tEnd Method\n\t\n\tMethod Info$()\n\t\tReturn \"Blitz3D|b3d\"\n\tEnd Method\n\tMethod ModuleName$()\n\t\tReturn \"b3dloader\"\n\tEnd Method\nEnd Type\nNew TMeshLoaderB3D\n","old_contents":"\nStrict\n\nRem\n\tbbdoc: Blitz3D model loader for MaxB3D\nEnd Rem\nModule MaxB3D.B3DLoader\nModuleInfo \"Author: Kevin Primm\"\nModuleInfo \"License: MIT\"\n\nImport MaxB3D.Core\nImport MaxB3D.BoneAnimator\nImport Prime.libB3D\n\nType TMeshLoaderB3D Extends TMeshLoader\n\tField _mesh:TMesh\n\t\n\tMethod Run(mesh:TMesh,stream:TStream,url:Object)\n\t\tLocal model:TBB3DChunk=TBB3DChunk.Load(url)\n\t\tIf model=Null Return False\t\n\t\t\n\t\tLocal olddir$=CurrentDir()\n\t\tIf String(url) ChangeDir(ExtractDir(String(url)))\n\t\t\n\t\tLocal texture:TTexture[model.texs.length]\n\t\tLocal brush:TBrush[model.brus.length]\n\t\t\n\t\tFor Local i=0 To texture.length-1\n\t\t\tLocal chunk:TTEXSChunk=model.texs[i]\t\t\t\n\t\t\ttexture[i]=_currentworld.AddTexture(chunk.file,chunk.flags)\n\t\t\tIf texture[i]\n\t\t\t\ttexture[i].SetBlend chunk.blend\n\t\t\t\ttexture[i].SetPosition chunk.x_pos,chunk.y_pos\n\t\t\t\ttexture[i].SetScale chunk.x_scale,chunk.y_scale\n\t\t\t\ttexture[i].SetRotation chunk.rotation*(180.0\/Pi)\n\t\t\tEndIf\n\t\tNext\n\t\t\n\t\tFor Local i=0 To brush.length-1\n\t\t\tLocal chunk:TBRUSChunk=model.brus[i]\n\t\t\tbrush[i]=_currentworld.AddBrush()\n\t\t\tbrush[i].SetName chunk.name\n\t\t\tbrush[i].SetColor chunk.red*255,chunk.green*255,chunk.blue*255;brush[i].SetAlpha chunk.alpha\n\t\t\tbrush[i].SetShine chunk.shininess\n\t\t\tbrush[i].SetBlend chunk.blend;brush[i].SetFX chunk.fx\n\t\t\tFor Local j=0 To chunk.n_texs-1\n\t\t\t\tIf chunk.texture_id[j]>-1 brush[i].SetTexture texture[chunk.texture_id[j]],j\n\t\t\tNext\n\t\tNext\t\t\n\t\tChangeDir olddir\n\t\t\n\t\t' model.dump StandardIOStream\n\t\t \n\t\tIf model.node\n\t\t\tParseNode model.node,mesh,brush,mesh\n\t\t\tReturn True\n\t\tEndIf\n\t\tReturn False\n\tEnd Method\n\t\n\tMethod ParseNode(node:TNODEChunk,parent:TEntity,brush:TBrush[],entity:TEntity=Null)\n\t\tLocal meshchunk:TMESHChunk=TMESHChunk(node.kind),bonechunk:TBONEChunk=TBONEChunk(node.kind)\n\t\t\t\t\n\t\tSelect node.kind\n\t\tCase Null\n\t\t\tentity=_currentworld.AddPivot(parent)\n\t\tCase meshchunk\t\t\t\n\t\t\tIf entity=Null entity=_currentworld.AddMesh(\"*null*\",parent)\n\t\t\tLocal mesh:TMesh=TMesh(entity)\n\t\t\tmesh._animator=New TBoneAnimator\n\t\t\t_mesh=mesh\n\t\t\t\n\t\t\tIf meshchunk.brush_id>-1 entity.SetBrush brush[meshchunk.brush_id]\n\t\t\t\n\t\t\tLocal vrts:TVRTSChunk=meshchunk.vrts\n\t\t\tLocal vertsurface:TSurface=New TSurface\n\t\t\tvertsurface.Resize(vrts.xyz.length\/3,0)\n\t\t\t\n\t\t\tFor Local i=0 To vertsurface.CountVertices()-1\n\t\t\t\tvertsurface.SetCoords i,vrts.xyz[i*3+0],vrts.xyz[i*3+1],vrts.xyz[i*3+2]\n\t\t\t\tIf vrts.nxyz vertsurface.SetNormal i,vrts.nxyz[i*3+0],vrts.nxyz[i*3+1],vrts.nxyz[i*3+2]\n\t\t\t\tIf vrts.rgba vertsurface.SetColor i,vrts.rgba[i*4+0]*255,vrts.rgba[i*4+1]*255,vrts.rgba[i*4+2]*255,vrts.rgba[i*4+3]\n\t\t\t\tFor Local j=0 To vrts.SetCount()-1\n\t\t\t\t\tLocal u#,v#\n\t\t\t\t\tIf vrts.SetSize()>1 u=vrts.tex_coords[i][j,0];v=vrts.tex_coords[i][j,1]\n\t\t\t\t\tvertsurface.SetTexCoords i,1-u,v\n\t\t\t\tNext\n\t\t\tNext\n\t\t\t\n\t\t\tFor Local i=0 To meshchunk.tris.length-1\n\t\t\t\tLocal tri:TTRISChunk=meshchunk.tris[i]\n\t\t\t\tLocal surface:TSurface=vertsurface.Copy()\n\t\t\t\tsurface.Resize(-1,tri.vertex_id.length\/3)\n\t\t\t\tIf tri.brush_id>-1 surface.SetBrush brush[tri.brush_id]\n\t\t\t\tFor Local t=0 To surface.CountTriangles()-1\n\t\t\t\t\tsurface.SetTriangle t,tri.vertex_id[t*3+0],tri.vertex_id[t*3+1],tri.vertex_id[t*3+2]\n\t\t\t\tNext\n\t\t\t\tIf vrts.nxyz=Null surface.UpdateNormals\t\t\t\n\t\t\t\tmesh.AppendSurface surface\n\t\t\tNext\n\t\tCase bonechunk\n\t\t\tentity=_currentworld.AddBone(parent)\n\t\t\tLocal bone:TBone=TBone(entity)\n\t\t\t\n\t\t\tFor Local surface:TSurface=EachIn _mesh._surfaces\n\t\t\t\tbone.AddSurface surface\n\t\t\t\tFor Local i=0 To bonechunk.vertex_id.length-1\n\t\t\t\t\tbone.AddVertex surface,bonechunk.vertex_id[i],bonechunk.weight[i]\n\t\t\t\tNext\n\t\t\tNext\t\t\t\n\t\t\t\n\t\t\tLocal ident_matrix:TMatrix=TMatrix.Identity()\n\t\t\tFor Local chunk:TKEYSChunk=EachIn node.keys\n\t\t\t\tLocal keys:TAnimKey[chunk.frame.length]\n\t\t\t\tLocal pos#[]=chunk.position,rot#[]=chunk.rotation,scl#[]=chunk.scale\n\t\t\t\tFor Local i=0 To chunk.frame.length-1\n\t\t\t\t\tLocal bonekey:TBoneKey=New TBoneKey\n\t\t\t\t\t\n\t\t\t\t\tIf pos.length>0 bonekey._px=pos[i*3+0];bonekey._py=pos[i*3+1];bonekey._pz=pos[i*3+2]\n\t\t\t\t\tIf rot.length>0 bonekey._rw=rot[i*4+0];bonekey._rx=rot[i*4+1];bonekey._ry=rot[i*4+2];bonekey._rz=rot[i*4+3]\n\t\t\t\t\tIf scl.length>0 bonekey._sx=scl[i*3+0];bonekey._sy=scl[i*3+1];bonekey._sz=scl[i*3+2]\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\tLocal key:TAnimKey=New TAnimKey\n\t\t\t\t\tkey._frame=chunk.frame[i]\n\t\t\t\t\tkey._object=bonekey\n\t\t\t\t\tkeys[i]=key\n\t\t\t\tNext\n\t\t\t\tTBoneAnimator(_mesh._animator).AddBone bone,keys\n\t\t\tNext\n\t\tDefault\n\t\t\tentity=_currentworld.AddPivot(parent)\n\t\tEnd Select\t\t\n\t\t\n\t\tentity.SetName node.name\n\t\tentity.SetPosition node.position[0],node.position[1],node.position[2]\n\t\tLocal pitch#,yaw#,roll#\n\t\tTQuaternion.Euler node.rotation[0],node.rotation[1],node.rotation[2],node.rotation[3],pitch,yaw,roll\n\t\tentity.SetRotation pitch,yaw,roll\n\t\tentity.SetScale node.scale[0],node.scale[1],node.scale[2]\n\t\t\n\t\tFor Local child:TNODEChunk=EachIn node.node\n\t\t\tParseNode child,entity,brush\n\t\tNext\n\t\tIf TMesh(entity) If TBoneAnimator(TMesh(entity)._animator)._root=Null TMesh(entity)._animator=Null\n\t\tIf TBone(entity) TBone(entity)._start_matrix=entity.GetMatrix()\n\tEnd Method\n\t\n\tMethod Info$()\n\t\tReturn \"Blitz3D|b3d\"\n\tEnd Method\n\tMethod ModuleName$()\n\t\tReturn \"b3dloader\"\n\tEnd Method\nEnd Type\nNew TMeshLoaderB3D\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"48e1f32e5700896b977333430823ce27cdd9d039","subject":"remove redundant test","message":"remove redundant test\n","repos":"Leushenko\/blue-moon","old_file":"blue.bmx","new_file":"blue.bmx","new_contents":"\n' Blue Moon\n' an implementation of Lua in pure BlitzMax\n\nSuperStrict\n\n'Framework Brl.Blitz\n'Import Brl.LinkedList\n'Import Brl.Map\n'Import Brl.Reflection\n\nImport \"bluecompiler.bmx\"\nImport \"bluevm.bmx\"\n\n'Const file:String = \"tests\/checktable.lua\"\n'Const file:String = \"tests\/mandelbrot.lua\"\n'Const file:String = \"tests\/sieve.lua\"\n'Const file:String = \"tests\/attrib.lua\"\nConst file:String = \"test1.lua\"\n\nConst outFile:String = \"out.lua.so\"\n\n\nPrint BlueCompiler.ShowBytecode(file)\n\nLocal code:BlueBinary = BlueCompiler.CompileFileForLoad(file)\nLocal vm:BlueVM = New BlueVM\nLocal tl:BlueLuaVal = vm.LoadObjectCode(code)\n\nLocal stk:Stack = BlueJIT.BPtoS(vm.mem.stack)\nstk.retIP = Null ; stk.prevBase = Null\nLocal vc:Int = 10, upvars:Int = 1\nstk.varp = Long Ptr(Byte Ptr(stk) + BlueJIT.STACKFRAME_INC) + upvars\nstk.func = vm.funIndex[0]\nstk.argv = Null\t'may want to add space?\nstk.retv = Null\nstk.argc = 0\nstk.retc = 0\n\nPrint \"running...\"\nLocal t:Int = MilliSecs()\nLocal test:Int(_:Byte Ptr) = stk.func.mcode - BlueJIT.PROLOGUESZ ; test(stk)\nt = MilliSecs() - t\nPrint t\nPrint \"run complete\"\n\n\nPrint \"done.\"\nEnd\n\n\nRem\nLocal files:TList = CreateList()\nLocal as:String, ld:String, showHelp:Int, output:String = \"a.out\", doAssemble:Int = 1\nLocal keepAsm:Int, makeExe:Int = 1, asOpts:String, ldOpts:String, showAST:Int, showVersion:Int\n\n?MacOS\nas = \"clang -m32 -c \" ; ld = \"clang -Wl,-no_pie -m32 -read_only_relocs suppress \"\n?Not MacOS\nas = \"gcc -m32 -c \" ; ld = \"gcc -m32 \"\n?\n\nFor Local a:Int = 1 Until AppArgs.Length\n\tSelect AppArgs[a]\n\t\tCase \"-?\", \"--help\"\n\t\t\tshowHelp = 1\n\t\tCase \"-v\"\n\t\t\tshowVersion = 1\n\t\tCase \"-o\"\n\t\t\tIf makeExe = 0\n\t\t\t\tPrint \"warning: -c and -o are mutually exclusive; -c is overruling -o\"\n\t\t\tElse\n\t\t\t\ta :+ 1 ; output = AppArgs[a] ; makeExe = 2\n\t\t\tEndIf\n\t\tCase \"-c\"\n\t\t\tIf makeExe = 2\n\t\t\t\tPrint \"warning: -o and -c are mutually exclusive; -o is overruling -c\"\n\t\t\tElse\n\t\t\t\tdoAssemble = 1 ; makeExe = 0\n\t\t\tEndIf\n\t\tCase \"-s\"\n\t\t\tkeepAsm = 1\n\t\tCase \"-S\"\n\t\t\tkeepAsm = 1 ; doAssemble = 0 ; makeExe = 0\n\t\tCase \"--as\"\n\t\t\ta :+ 1 ; as = AppArgs[a] + \" \"\n\t\tCase \"--ld\"\n\t\t\ta :+ 1 ; ld = AppArgs[a] + \" \"\n\t\tCase \"--as-opt\"\n\t\t\ta :+ 1 ; asOpts :+ AppArgs[a] + \" \"\n\t\tCase \"--ld-opt\"\n\t\t\ta :+ 1 ; ldOpts :+ AppArgs[a] + \" \"\n\t\tCase \"--tree\"\n\t\t\tshowAST = 1 ; makeExe = 0\n\t\tCase \"-w\" ; YBCodeGen.SetWarningLevel 0\n\t\tCase \"--werr\" ; YBCodeGen.SetWarningLevel 2\n\t\tCase \"--warn\" ; YBCodeGen.SetWarningLevel 1\n\t\tDefault\n\t\t\tfiles.AddLast AppArgs[a]\n\tEnd Select\nNext\nIf AppArgs.Length = 1 Then Print \"ybc: no input files\" ; End\n\nIf showVersion Then DisplayVersion\nIf showHelp Then DisplayHelp\n\n?Win32\nLocal rm:String = \"del \/Q \"\n?Not Win32\nLocal rm:String = \"rm \"\n?\n\nLocal allOFiles:String = \"\"\nFor Local file:String = EachIn files\n\tTry\n\t\tLocal tree:TParseNode = YBParseFile(file)\n\t\tIf showAST\n\t\t\tPrint tree.ToString()\n\t\tElse\n\t\t\tYBCodeGen.Build tree\n\t\t\tYBAssembler.Emit file + \".s\", YBCodeGen.syms, YBCodeGen.funs, YBCodeGen.vars, YBCodeGen.strs\n\t\t\tIf doAssemble\n\t\t\t\tsystem_(as + asOpts + file + \".s -o \" + file + \".o\")\n\t\t\t\tallOFiles :+ file + \".o \"\n\t\t\tEndIf\n\t\t\tIf Not keepAsm\n\t\t\t\tsystem_ rm + file + \".s\"\n\t\t\tEndIf\n\t\tEndIf\n\tCatch e:Object\n\t\tPrint \"Compile error:~n \" + e.ToString()\n\t\tPrint \"Compilation halted.\"\n\t\t?Debug\n\t\tThrow e\n\t\t?\n\t\tEnd\n\tEnd Try\nNext\n\n?Linux\nLocal bLib:String = \"b-lib-linux\"\n?Not Linux\nLocal bLib:String = \"b-lib\"\n?\nIf makeExe\n\tIf Not FileType(\"b-lib.o\") Then system_ as + bLib + \".s -o b-lib.o\"\n\tsystem_(ld + ldOpts + \"-o \" + output + \" \" + allOFiles + \" b-lib.o\")\n\tsystem_(rm + allOFiles)\nEndIf\n\nPrint \"done.\"\nEnd\nEnd Rem\nRem\nFunction DisplayVersion()\n\tPrint \"Shadow SIMD Compiler: version 0.0\"\nEnd Function\n\nFunction DisplayHelp()\n\tPrint \"OVERVIEW: ybc compiler for B~n\"\n\tPrint \"USAGE: ybc [options] ~n\"\n\tPrint \"OPTIONS:~n\"\n\tPrint \" -?, --help Display this message\"\n\tPrint \" -v Show the compiler version\"\n\tPrint \" -o Set the name of the output executable (default 'a.out')\"\n\tPrint \" -c Produce separate .o files instead of an executable\"\n\tPrint \" -s Keep text assembly .s files\"\n\tPrint \" -S Only produce text assembly, do not assemble binaries\"\n\tPrint \" --as Set the command to use as the assembler\"\n\tPrint \" --ld Set the command to use as the linker\"\n\tPrint \" --as-opt Add an option to pass to the assembler (can repeat)\"\n\tPrint \" --ld-opt Add an option to pass to the linker (can repeat)\"\n\tPrint \" --tree Display the AST of the program source instead of compiling\"\n\tPrint \" -w Silence warnings\"\n\tPrint \" --werr Convert warnings to errors\"\n\tPrint \" --warn Notify but do not halt on warnings (default)\"\nEnd Function\nEnd Rem\n","old_contents":"\n' Blue Moon\n' an implementation of Lua in pure BlitzMax\n\nSuperStrict\n\n'Framework Brl.Blitz\n'Import Brl.LinkedList\n'Import Brl.Map\n'Import Brl.Reflection\n\nImport \"bluecompiler.bmx\"\nImport \"bluevm.bmx\"\n\n'Const file:String = \"tests\/checktable.lua\"\n'Const file:String = \"tests\/mandelbrot.lua\"\n'Const file:String = \"tests\/sieve.lua\"\n'Const file:String = \"tests\/attrib.lua\"\nConst file:String = \"test1.lua\"\n\nConst outFile:String = \"out.lua.so\"\n\n\nPrint BlueCompiler.ShowBytecode(file)\n\nLocal code:BlueBinary = BlueCompiler.CompileFileForLoad(file)\nLocal vm:BlueVM = New BlueVM\nLocal tl:BlueLuaVal = vm.LoadObjectCode(code)\n\nLocal stk:Stack = BlueJIT.BPtoS(vm.mem.stack)\nstk.retIP = Null ; stk.prevBase = Null\nLocal vc:Int = 10, upvars:Int = 1\nstk.varp = Long Ptr(Byte Ptr(stk) + BlueJIT.STACKFRAME_INC) + upvars\nstk.func = vm.funIndex[0]\nstk.argv = Null\t'may want to add space?\nstk.retv = Null\nstk.argc = 0\nstk.retc = 0\n\nFunction lpr:Int(vm:BlueVM, argc:Int, argv:Long Ptr, retv:Long Ptr)\n\tPrint vm.mem.ValToMaxString(argv[0])\n\tReturn 0\nEnd Function\nFunction addtri:Int(vm:BlueVM, argc:Int, argv:Long Ptr, retv:Long Ptr)\n\tDouble Ptr(retv)[0] = Double Ptr(argv)[0] + Double Ptr(argv)[1] + Double Ptr(argv)[2]\n\tReturn 1\nEnd Function\nFunction ret3:Int(vm:BlueVM, argc:Int, argv:Long Ptr, retv:Long Ptr)\n\tDouble Ptr(retv)[0] = 21\n\tDouble Ptr(retv)[1] = 23\n\tDouble Ptr(retv)[2] = 25\n\tReturn 3\nEnd Function\nvm._ENV.Set(\"pr\", vm.ValueFromFunction(lpr))\nvm._ENV.Set(\"quux\", vm.ValueFromNumber(7.5))\nvm._ENV.Set(\"addtriple\", vm.ValueFromFunction(addtri))\nvm._ENV.Set(\"ret3\", vm.ValueFromFunction(ret3))\n\nPrint \"running...\"\nLocal t:Int = MilliSecs()\nLocal test:Int(_:Byte Ptr) = stk.func.mcode - BlueJIT.PROLOGUESZ ; test(stk)\nt = MilliSecs() - t\nPrint t\nPrint \"run complete\"\n\n\nPrint \"done.\"\nEnd\n\n\nRem\nLocal files:TList = CreateList()\nLocal as:String, ld:String, showHelp:Int, output:String = \"a.out\", doAssemble:Int = 1\nLocal keepAsm:Int, makeExe:Int = 1, asOpts:String, ldOpts:String, showAST:Int, showVersion:Int\n\n?MacOS\nas = \"clang -m32 -c \" ; ld = \"clang -Wl,-no_pie -m32 -read_only_relocs suppress \"\n?Not MacOS\nas = \"gcc -m32 -c \" ; ld = \"gcc -m32 \"\n?\n\nFor Local a:Int = 1 Until AppArgs.Length\n\tSelect AppArgs[a]\n\t\tCase \"-?\", \"--help\"\n\t\t\tshowHelp = 1\n\t\tCase \"-v\"\n\t\t\tshowVersion = 1\n\t\tCase \"-o\"\n\t\t\tIf makeExe = 0\n\t\t\t\tPrint \"warning: -c and -o are mutually exclusive; -c is overruling -o\"\n\t\t\tElse\n\t\t\t\ta :+ 1 ; output = AppArgs[a] ; makeExe = 2\n\t\t\tEndIf\n\t\tCase \"-c\"\n\t\t\tIf makeExe = 2\n\t\t\t\tPrint \"warning: -o and -c are mutually exclusive; -o is overruling -c\"\n\t\t\tElse\n\t\t\t\tdoAssemble = 1 ; makeExe = 0\n\t\t\tEndIf\n\t\tCase \"-s\"\n\t\t\tkeepAsm = 1\n\t\tCase \"-S\"\n\t\t\tkeepAsm = 1 ; doAssemble = 0 ; makeExe = 0\n\t\tCase \"--as\"\n\t\t\ta :+ 1 ; as = AppArgs[a] + \" \"\n\t\tCase \"--ld\"\n\t\t\ta :+ 1 ; ld = AppArgs[a] + \" \"\n\t\tCase \"--as-opt\"\n\t\t\ta :+ 1 ; asOpts :+ AppArgs[a] + \" \"\n\t\tCase \"--ld-opt\"\n\t\t\ta :+ 1 ; ldOpts :+ AppArgs[a] + \" \"\n\t\tCase \"--tree\"\n\t\t\tshowAST = 1 ; makeExe = 0\n\t\tCase \"-w\" ; YBCodeGen.SetWarningLevel 0\n\t\tCase \"--werr\" ; YBCodeGen.SetWarningLevel 2\n\t\tCase \"--warn\" ; YBCodeGen.SetWarningLevel 1\n\t\tDefault\n\t\t\tfiles.AddLast AppArgs[a]\n\tEnd Select\nNext\nIf AppArgs.Length = 1 Then Print \"ybc: no input files\" ; End\n\nIf showVersion Then DisplayVersion\nIf showHelp Then DisplayHelp\n\n?Win32\nLocal rm:String = \"del \/Q \"\n?Not Win32\nLocal rm:String = \"rm \"\n?\n\nLocal allOFiles:String = \"\"\nFor Local file:String = EachIn files\n\tTry\n\t\tLocal tree:TParseNode = YBParseFile(file)\n\t\tIf showAST\n\t\t\tPrint tree.ToString()\n\t\tElse\n\t\t\tYBCodeGen.Build tree\n\t\t\tYBAssembler.Emit file + \".s\", YBCodeGen.syms, YBCodeGen.funs, YBCodeGen.vars, YBCodeGen.strs\n\t\t\tIf doAssemble\n\t\t\t\tsystem_(as + asOpts + file + \".s -o \" + file + \".o\")\n\t\t\t\tallOFiles :+ file + \".o \"\n\t\t\tEndIf\n\t\t\tIf Not keepAsm\n\t\t\t\tsystem_ rm + file + \".s\"\n\t\t\tEndIf\n\t\tEndIf\n\tCatch e:Object\n\t\tPrint \"Compile error:~n \" + e.ToString()\n\t\tPrint \"Compilation halted.\"\n\t\t?Debug\n\t\tThrow e\n\t\t?\n\t\tEnd\n\tEnd Try\nNext\n\n?Linux\nLocal bLib:String = \"b-lib-linux\"\n?Not Linux\nLocal bLib:String = \"b-lib\"\n?\nIf makeExe\n\tIf Not FileType(\"b-lib.o\") Then system_ as + bLib + \".s -o b-lib.o\"\n\tsystem_(ld + ldOpts + \"-o \" + output + \" \" + allOFiles + \" b-lib.o\")\n\tsystem_(rm + allOFiles)\nEndIf\n\nPrint \"done.\"\nEnd\nEnd Rem\nRem\nFunction DisplayVersion()\n\tPrint \"Shadow SIMD Compiler: version 0.0\"\nEnd Function\n\nFunction DisplayHelp()\n\tPrint \"OVERVIEW: ybc compiler for B~n\"\n\tPrint \"USAGE: ybc [options] ~n\"\n\tPrint \"OPTIONS:~n\"\n\tPrint \" -?, --help Display this message\"\n\tPrint \" -v Show the compiler version\"\n\tPrint \" -o Set the name of the output executable (default 'a.out')\"\n\tPrint \" -c Produce separate .o files instead of an executable\"\n\tPrint \" -s Keep text assembly .s files\"\n\tPrint \" -S Only produce text assembly, do not assemble binaries\"\n\tPrint \" --as Set the command to use as the assembler\"\n\tPrint \" --ld Set the command to use as the linker\"\n\tPrint \" --as-opt Add an option to pass to the assembler (can repeat)\"\n\tPrint \" --ld-opt Add an option to pass to the linker (can repeat)\"\n\tPrint \" --tree Display the AST of the program source instead of compiling\"\n\tPrint \" -w Silence warnings\"\n\tPrint \" --werr Convert warnings to errors\"\n\tPrint \" --warn Notify but do not halt on warnings (default)\"\nEnd Function\nEnd Rem\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"0d08e4c02c08bb45c4c6b39e8230b5670cb38d86","subject":"Changed default resolution to 640x480 to match the other targets (HTML5, Flash and GLFW)","message":"Changed default resolution to 640x480 to match the other targets (HTML5, Flash and GLFW)\n\n--HG--\nextra : convert_revision : svn%3Ae934d3cd-0d57-f34a-94d0-9e8d31ae1c29\/trunk%40388\n","repos":"programmerby\/diddy-mirror,programmerby\/diddy-mirror,programmerby\/diddy-mirror,programmerby\/diddy-mirror","old_file":"monkeymax\/targets\/bmax\/MonkeyGame.bmx","new_file":"monkeymax\/targets\/bmax\/MonkeyGame.bmx","new_contents":"SuperStrict\r\n\r\nGlobal _errStack:TList = New TList;\r\nGlobal _errInfo:String=\"\";\r\n\r\nGraphics 640, 480\r\n\r\nbbInit();\r\nbbMain();\r\n\r\n'${TRANSCODE_BEGIN}\r\n'${TRANSCODE_END}\r\n","old_contents":"SuperStrict\r\n\r\nGlobal _errStack:TList = New TList;\r\nGlobal _errInfo:String=\"\";\r\n\r\nGraphics 800, 600\r\n\r\nbbInit();\r\nbbMain();\r\n\r\n'${TRANSCODE_BEGIN}\r\n'${TRANSCODE_END}\r\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"53de1dab018c110a73c7e436841abb2a46a1264d","subject":"Removed output clutter","message":"Removed output clutter\n\nrefs gh-17\n","repos":"maximos\/maximus","old_file":"src\/logger.bmx","new_file":"src\/logger.bmx","new_contents":"\nRem\n\tbbdoc: Maximus basic logger.\nEnd Rem\nType mxLogger\n\t\n\tField m_observers:TList = New TList\n\t\n\tConst c_message:String = \"message\"\n\tConst c_warning:String = \"warning\"\n\tConst c_error:String = \"error\"\n\n\tRem\n\t\tbbdoc: Log a message.\n\t\treturns: Nothing.\n\t\tabout: If @newline is True, a new line will be started, if it is False, a new line will not be started.\n\tEnd Rem\n\tMethod LogMessage(message:String, newline:Int = True)\n\t\tIf newline Then message:+ \"~n\"\n\t\tMessageObservers(message, c_message)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Log a warning message.\n\t\treturns: Nothing.\n\t\tabout: If @newline is True, a new line will be started, if it is False, a new line will not be started.\n\tEnd Rem\n\tMethod LogWarning(warning:String, newline:Int = True)\n\t\twarning = _s(\"message.warning\", [warning])\n\t\tIf newline Then warning:+ \"~n\"\n\t\tMessageObservers(warning, c_warning)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Log an error message.\n\t\treturns: Nothing.\n\t\tabout: If @newline is True, a new line will be started, if it is False, a new line will not be started.\n\tEnd Rem\n\tMethod LogError(error:String, newline:Int = True)\n\t\terror = _s(\"message.error\", [error])\n\t\tIf newline Then error:+ \"~n\"\n\t\tMessageObservers(error, c_error)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Add an observer\n\t\tReturns: Nothing.\n\tEnd Rem\n\tMethod AddObserver(observer:Object)\n\t\tm_observers.AddLast(observer)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Send messages to observers\n\t\treturns: Nothing.\n\t\tabout: This helper method messages all registered observers with the SendMessage method\n\tEnd Rem\n\tMethod MessageObservers(message:String, context:String)\n\t\tFor Local observer:Object = EachIn m_observers\n\t\t\tobserver.SendMessage(message, context)\n\t\tNext\n\tEnd Method\nEnd Type\n\nRem\n\tbbdoc: This observer for mxLogger will write received messages to StandardIOStream\nEnd Rem\nType mxLoggerObserverIOStream\n\tMethod SendMessage:Object(message:Object, context:Object)\n\t\tStandardIOStream.WriteString(String(message))\n\tEnd Method\nEnd Type\n\nRem\n\tbbdoc: This observer for mxLogger will print received messages with DebugLog\nEnd Rem\nType mxLoggerObserverDebuglog\n\tMethod SendMessage:Object(message:Object, context:Object)\n\t\tDebugLog \"[\" + String(context) + \"] \" + String(message)\n\tEnd Method\nEnd Type","old_contents":"\nRem\n\tbbdoc: Maximus basic logger.\nEnd Rem\nType mxLogger\n\t\n\tField m_observers:TList = New TList\n\t\n\tConst c_message:String = \"message\"\n\tConst c_warning:String = \"warning\"\n\tConst c_error:String = \"error\"\n\n\tRem\n\t\tbbdoc: Log a message.\n\t\treturns: Nothing.\n\t\tabout: If @newline is True, a new line will be started, if it is False, a new line will not be started.\n\tEnd Rem\n\tMethod LogMessage(message:String, newline:Int = True)\n\t\tIf newline Then message:+ \"~n\"\n\t\tMessageObservers(message, c_message)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Log a warning message.\n\t\treturns: Nothing.\n\t\tabout: If @newline is True, a new line will be started, if it is False, a new line will not be started.\n\tEnd Rem\n\tMethod LogWarning(warning:String, newline:Int = True)\n\t\twarning = _s(\"message.warning\", [warning])\n\t\tIf newline Then warning:+ \"~n\"\n\t\tMessageObservers(warning, c_warning)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Log an error message.\n\t\treturns: Nothing.\n\t\tabout: If @newline is True, a new line will be started, if it is False, a new line will not be started.\n\tEnd Rem\n\tMethod LogError(error:String, newline:Int = True)\n\t\terror = _s(\"message.error\", [error])\n\t\tIf newline Then error:+ \"~n\"\n\t\tMessageObservers(error, c_error)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Add an observer\n\t\tReturns: Nothing.\n\tEnd Rem\n\tMethod AddObserver(observer:Object)\n\t\tm_observers.AddLast(observer)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Send messages to observers\n\t\treturns: Nothing.\n\t\tabout: This helper method messages all registered observers with the SendMessage method\n\tEnd Rem\n\tMethod MessageObservers(message:String, context:String)\n\t\tFor Local observer:Object = EachIn m_observers\n\t\t\tobserver.SendMessage(message, context)\n\t\tNext\n\tEnd Method\nEnd Type\n\nRem\n\tbbdoc: This observer for mxLogger will write received messages to StandardIOStream\nEnd Rem\nType mxLoggerObserverIOStream\n\tMethod SendMessage:Object(message:Object, context:Object)\n\t\tStandardIOStream.WriteString(\"iostream:\" + String(message))\n\tEnd Method\nEnd Type\n\nRem\n\tbbdoc: This observer for mxLogger will print received messages with DebugLog\nEnd Rem\nType mxLoggerObserverDebuglog\n\tMethod SendMessage:Object(message:Object, context:Object)\n\t\tDebugLog \"[\" + String(context) + \"] \" + String(message)\n\tEnd Method\nEnd Type","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"a08a40422edf63bb66f88a801c95cfcb8ca766ca","subject":"Version 0.3","message":"Version 0.3\n","repos":"Htbaa\/zmq.mod,Htbaa\/zmq.mod","old_file":"zmq.bmx","new_file":"zmq.bmx","new_contents":"Rem\n\tCopyright (c) 2012 Christiaan Kras\n\t\n\tPermission is hereby granted, free of charge, to any person obtaining a copy\n\tof this software and associated documentation files (the \"Software\"), to deal\n\tin the Software without restriction, including without limitation the rights\n\tto use, copy, modify, merge, publish, distribute, sublicense, and\/or sell\n\tcopies of the Software, and to permit persons to whom the Software is\n\tfurnished to do so, subject to the following conditions:\n\t\n\tThe above copyright notice and this permission notice shall be included in\n\tall copies or substantial portions of the Software.\n\t\n\tTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n\tIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n\tFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n\tAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n\tLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n\tOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n\tTHE SOFTWARE.\nEnd Rem\n\nSuperStrict\n\nRem\n\tbbdoc: htbaapub.zmq\n\tabout: This module is still an early work in progress. If you run into any\n\tbugs please report them at https:\/\/github.com\/Htbaa\/zmq.mod\/issues<\/a>.\nEndRem\nModule htbaapub.zmq\nModuleInfo \"Name: htbaapub.zmq\"\nModuleInfo \"Description: A wrapper for ZeroMQ\"\nModuleInfo \"Version: 0.03\"\nModuleInfo \"License: MIT\"\nModuleInfo \"Author: Christiaan Kras\"\nModuleInfo \"ZeroMQ: http:\/\/www.zeromq.org<\/a>\"\nModuleInfo \"ZeroMQ License: LGPL (see contents of .\/zeromq)\"\nModuleInfo \"Git repository: https:\/\/github.com\/Htbaa\/zmq.mod\/<\/a>\"\nModuleInfo \"Issues: https:\/\/github.com\/Htbaa\/zmq.mod\/issues<\/a>\"\nModuleInfo \"History: 0.03\"\nModuleInfo \"History: Fixed message data corruption for first sent message (gh-3)\"\nModuleInfo \"History: Added TZMQ_Message.CreateFromString to create messages from a String. The TZMQ_Message.Create signature has also changed to accept a Byte Ptr and a length\"\nModuleInfo \"History: Fixed potential memory leak in TZMQ_Socket.Send when an exception would be raised\"\nModuleInfo \"History: Added TZMQ_Socket_Exception and TZMQ_Message_Exception\"\nModuleInfo \"History: Added a couple of unit tests (bah.maxunit required)\"\nModuleInfo \"History: 0.02\"\nModuleInfo \"History: Added more examples; Hello World server and client\"\nModuleInfo \"History: Added more examples; Weather Update server and client\"\nModuleInfo \"History: TZMQ_Socket.SetSockOpt() now properly sets options\"\nModuleInfo \"History: TZMQ_Message.Close() now properly frees up memory\"\nModuleInfo \"History: 0.01\"\nModuleInfo \"History: First release of htbaapub.zmq using ZMQ 2.1.11. No support yet for input\/output multiplexing with zmq_poll()\"\n\n?Linux\n\tImport \"-lzmq\"\n?Win32\n\tImport \"zeromq\/lib\/libzmq.dll.a\"\n?\n\nImport \"glue.c\"\nInclude \"exception.bmx\"\nInclude \"constants.bmx\"\nInclude \"context.bmx\"\nInclude \"socket.bmx\"\nInclude \"message.bmx\"\n\n'Glue\/Helper functions\nExtern \"C\"\n\n\tRem\n\t\tbbdoc: Create an empty zmq_message_t struct\n\t\treturns: Returns a pointer to a new zmq_message_t struct\n\tEnd Rem\n\tFunction bmx_zmq_message_t:Byte Ptr()\n\n\tRem\n\t\tbbdoc: Create a zmq_message_t struct with preset data\n\t\treturns: Returns a pointer to a new zmq_message_t struct with given data\n\tEnd Rem\n\tFunction bmx_zmq_new_message:Byte Ptr(str$z)\n\t\n\tRem\n\t\tbbdoc: Alias for free(), for cleaning up data structures\n\tEnd Rem\n\tFunction bmx_zmq_free(msg:Byte Ptr)\nEnd Extern\n\n'ZeroMQ functions\nExtern\n\tFunction zmq_version(major:Int Var, minor:Int Var, patch:Int Var)\n\n\tFunction zmq_init:Byte Ptr(io_threads:Int)\n\tFunction zmq_term:Int(context:Byte Ptr)\n\t\n\tFunction zmq_errno:Int()\n\tFunction zmq_strerror$z(errnum:Int)\n\t\n\tFunction zmq_socket:Byte Ptr(context:Byte Ptr, socket_type:Int)\n\tFunction zmq_close:Int(s:Byte Ptr)\n\tFunction zmq_setsockopt:Int(s:Byte Ptr, option:Int, optval$z, length:Int)\n\tFunction zmq_getsockopt:Int(s:Byte Ptr, option:Int, optval:Byte Ptr, length:Int Var)\n\t'ZMQ_EXPORT Int zmq_getsockopt (void *s, Int option, void *optval, size_t *optvallen);\n\tFunction zmq_bind(s:Byte Ptr, addr$z)\n\tFunction zmq_connect:Int(s:Byte Ptr, addr$z)\n\tFunction zmq_send:Int(s:Byte Ptr, msg:Byte Ptr, flags:Int)\n\tFunction zmq_recv:Int(s:Byte Ptr, msg:Byte Ptr, flags:Int)\n\n\tFunction zmq_msg_init:Int(msg:Byte Ptr)\n\tFunction zmq_msg_init_size:Int(msg:Byte Ptr, size:Long)\n\tFunction zmq_msg_init_data:Int(msg:Byte Ptr, data:Byte Ptr, size:Long, ffn:Byte Ptr, hint:Byte Ptr)\n\tFunction zmq_msg_close:Int(msg:Byte Ptr)\n\tFunction zmq_msg_move:Int(dest:Byte Ptr, src:Byte Ptr)\n\tFunction zmq_msg_copy:Int(dest:Byte Ptr, src:Byte Ptr)\n\tFunction zmq_msg_data:Byte Ptr(msg:Byte Ptr)\n\tFunction zmq_msg_size:Int(msg:Byte Ptr)\n\t\n\tFunction zmq_poll:Int(items:Byte Ptr, nitems:Int, timeout:Long)\n\t\n\tFunction zmq_device:Int(device:Int, insocket:Byte Ptr, outsocket:Byte Ptr)\nEnd Extern\n\nRem\n\tbbdoc: General ZMQ functions\nEnd Rem\nType TZMQ\n\n\tRem\n\t\tbbdoc: Get ZMQ Version\n\t\treturns: String\n\tEnd Rem\n\tFunction Version:String()\n\t\tLocal major:Int, minor:Int, patch:Int\n\t\tzmq_version(major, minor, patch)\n\t\tReturn major + \".\" + minor + \".\" + patch\n\tEnd Function\n\n\tRem\n\t\tbbdoc: Get current ZMQ error descriptions\n\t\treturns: String\n\tEnd Rem\n\tFunction Error:String()\n\t\tReturn zmq_strerror( TZMQ.ErrorNumber() )\n\tEnd Function\n\n\tRem\n\t\tbbdoc: Get current ZMQ error number\n\t\treturns: Int\n\tEnd Rem\n\tFunction ErrorNumber:Int()\n\t\tReturn zmq_errno()\n\tEnd Function\nEnd Type","old_contents":"Rem\n\tCopyright (c) 2012 Christiaan Kras\n\t\n\tPermission is hereby granted, free of charge, to any person obtaining a copy\n\tof this software and associated documentation files (the \"Software\"), to deal\n\tin the Software without restriction, including without limitation the rights\n\tto use, copy, modify, merge, publish, distribute, sublicense, and\/or sell\n\tcopies of the Software, and to permit persons to whom the Software is\n\tfurnished to do so, subject to the following conditions:\n\t\n\tThe above copyright notice and this permission notice shall be included in\n\tall copies or substantial portions of the Software.\n\t\n\tTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n\tIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n\tFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n\tAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n\tLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n\tOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n\tTHE SOFTWARE.\nEnd Rem\n\nSuperStrict\n\nRem\n\tbbdoc: htbaapub.zmq\n\tabout: This module is still an early work in progress. If you run into any\n\tbugs please report them at https:\/\/github.com\/Htbaa\/zmq.mod\/issues<\/a>.\nEndRem\nModule htbaapub.zmq\nModuleInfo \"Name: htbaapub.zmq\"\nModuleInfo \"Description: A wrapper for ZeroMQ\"\nModuleInfo \"Version: 0.02\"\nModuleInfo \"License: MIT\"\nModuleInfo \"Author: Christiaan Kras\"\nModuleInfo \"ZeroMQ: http:\/\/www.zeromq.org<\/a>\"\nModuleInfo \"ZeroMQ License: LGPL (see contents of .\/zeromq)\"\nModuleInfo \"Git repository: https:\/\/github.com\/Htbaa\/zmq.mod\/<\/a>\"\nModuleInfo \"Issues: https:\/\/github.com\/Htbaa\/zmq.mod\/issues<\/a>\"\nModuleInfo \"History: Fixed message data corruption for first sent message (gh-3)\"\nModuleInfo \"History: Added TZMQ_Message.CreateFromString to create messages from a String. The TZMQ_Message.Create signature has also changed to accept a Byte Ptr and a length\"\nModuleInfo \"History: Fixed potential memory leak in TZMQ_Socket.Send when an exception would be raised\"\nModuleInfo \"History: Added TZMQ_Socket_Exception and TZMQ_Message_Exception\"\nModuleInfo \"History: Added a couple of unit tests (bah.maxunit required)\"\nModuleInfo \"History: 0.02\"\nModuleInfo \"History: Added more examples; Hello World server and client\"\nModuleInfo \"History: Added more examples; Weather Update server and client\"\nModuleInfo \"History: TZMQ_Socket.SetSockOpt() now properly sets options\"\nModuleInfo \"History: TZMQ_Message.Close() now properly frees up memory\"\nModuleInfo \"History: 0.01\"\nModuleInfo \"History: First release of htbaapub.zmq using ZMQ 2.1.11. No support yet for input\/output multiplexing with zmq_poll()\"\n\n?Linux\n\tImport \"-lzmq\"\n?Win32\n\tImport \"zeromq\/lib\/libzmq.dll.a\"\n?\n\nImport \"glue.c\"\nInclude \"exception.bmx\"\nInclude \"constants.bmx\"\nInclude \"context.bmx\"\nInclude \"socket.bmx\"\nInclude \"message.bmx\"\n\n'Glue\/Helper functions\nExtern \"C\"\n\n\tRem\n\t\tbbdoc: Create an empty zmq_message_t struct\n\t\treturns: Returns a pointer to a new zmq_message_t struct\n\tEnd Rem\n\tFunction bmx_zmq_message_t:Byte Ptr()\n\n\tRem\n\t\tbbdoc: Create a zmq_message_t struct with preset data\n\t\treturns: Returns a pointer to a new zmq_message_t struct with given data\n\tEnd Rem\n\tFunction bmx_zmq_new_message:Byte Ptr(str$z)\n\t\n\tRem\n\t\tbbdoc: Alias for free(), for cleaning up data structures\n\tEnd Rem\n\tFunction bmx_zmq_free(msg:Byte Ptr)\nEnd Extern\n\n'ZeroMQ functions\nExtern\n\tFunction zmq_version(major:Int Var, minor:Int Var, patch:Int Var)\n\n\tFunction zmq_init:Byte Ptr(io_threads:Int)\n\tFunction zmq_term:Int(context:Byte Ptr)\n\t\n\tFunction zmq_errno:Int()\n\tFunction zmq_strerror$z(errnum:Int)\n\t\n\tFunction zmq_socket:Byte Ptr(context:Byte Ptr, socket_type:Int)\n\tFunction zmq_close:Int(s:Byte Ptr)\n\tFunction zmq_setsockopt:Int(s:Byte Ptr, option:Int, optval$z, length:Int)\n\tFunction zmq_getsockopt:Int(s:Byte Ptr, option:Int, optval:Byte Ptr, length:Int Var)\n\t'ZMQ_EXPORT Int zmq_getsockopt (void *s, Int option, void *optval, size_t *optvallen);\n\tFunction zmq_bind(s:Byte Ptr, addr$z)\n\tFunction zmq_connect:Int(s:Byte Ptr, addr$z)\n\tFunction zmq_send:Int(s:Byte Ptr, msg:Byte Ptr, flags:Int)\n\tFunction zmq_recv:Int(s:Byte Ptr, msg:Byte Ptr, flags:Int)\n\n\tFunction zmq_msg_init:Int(msg:Byte Ptr)\n\tFunction zmq_msg_init_size:Int(msg:Byte Ptr, size:Long)\n\tFunction zmq_msg_init_data:Int(msg:Byte Ptr, data:Byte Ptr, size:Long, ffn:Byte Ptr, hint:Byte Ptr)\n\tFunction zmq_msg_close:Int(msg:Byte Ptr)\n\tFunction zmq_msg_move:Int(dest:Byte Ptr, src:Byte Ptr)\n\tFunction zmq_msg_copy:Int(dest:Byte Ptr, src:Byte Ptr)\n\tFunction zmq_msg_data:Byte Ptr(msg:Byte Ptr)\n\tFunction zmq_msg_size:Int(msg:Byte Ptr)\n\t\n\tFunction zmq_poll:Int(items:Byte Ptr, nitems:Int, timeout:Long)\n\t\n\tFunction zmq_device:Int(device:Int, insocket:Byte Ptr, outsocket:Byte Ptr)\nEnd Extern\n\nRem\n\tbbdoc: General ZMQ functions\nEnd Rem\nType TZMQ\n\n\tRem\n\t\tbbdoc: Get ZMQ Version\n\t\treturns: String\n\tEnd Rem\n\tFunction Version:String()\n\t\tLocal major:Int, minor:Int, patch:Int\n\t\tzmq_version(major, minor, patch)\n\t\tReturn major + \".\" + minor + \".\" + patch\n\tEnd Function\n\n\tRem\n\t\tbbdoc: Get current ZMQ error descriptions\n\t\treturns: String\n\tEnd Rem\n\tFunction Error:String()\n\t\tReturn zmq_strerror( TZMQ.ErrorNumber() )\n\tEnd Function\n\n\tRem\n\t\tbbdoc: Get current ZMQ error number\n\t\treturns: Int\n\tEnd Rem\n\tFunction ErrorNumber:Int()\n\t\tReturn zmq_errno()\n\tEnd Function\nEnd Type","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"42f88fda36b7c430f00c6c09957c44c68cb49ada","subject":"Added stub SeekMusic to bmax","message":"Added stub SeekMusic to bmax\n","repos":"programmerby\/diddy-mirror,programmerby\/diddy-mirror,programmerby\/diddy-mirror,programmerby\/diddy-mirror","old_file":"src\/diddy\/native\/diddy.bmax.bmx","new_file":"src\/diddy\/native\/diddy.bmax.bmx","new_contents":"' ***** Start diddy.bmax.bmx ******\r\nGlobal diddy_mouseWheel:Float = 0.0\r\n\r\nType diddy\r\n\tFunction systemMillisecs:Float()\r\n\t\tReturn Millisecs()\r\n\tEndFunction\r\n\t\r\n\tFunction setGraphics(w:int, h:int, fullScreen:Int = False)\r\n\t\tlocal d% = 0\r\n\t\tif fullScreen then d = 32\r\n\t\tGraphics w, h, d, 60\r\n\tEndFunction\r\n\t\r\n\tFunction setMouse(x:Int, y:Int)\r\n\t\tMoveMouse(x, y)\r\n\tEndFunction\r\n\t\r\n\tFunction showKeyboard()\r\n\tEndFunction\r\n\t\r\n\tFunction launchBrowser(address:String, windowName:String)\r\n\tEndFunction\r\n\t\r\n\tFunction launchEmail(email:String, subject:String, text:String)\r\n\tEndFunction\r\n\t\r\n\tFunction realMod:Float( value:Float, amount:Float )\r\n\t\tReturn value Mod amount\r\n\tEndFunction\r\n\t\r\n\tFunction startVibrate(millisecs:int)\r\n\tEndFunction\r\n\t\r\n\tFunction stopVibrate()\r\n\tEndFunction\r\n\t\r\n\tFunction getDayOfMonth:Int()\r\n\t\tLocal date$ = CurrentDate()\r\n\t\tReturn Int(date[..2])\r\n\tEndFunction\r\n\t\r\n\tFunction getDayOfWeek:Int()\r\n\t\tReturn 0\r\n\tEndFunction\r\n\t\r\n\tFunction getMonth:Int()\r\n\t\tLocal date$ = CurrentDate()\r\n\t\tReturn (Instr(\"JANFEBMARAPRMAYJUNJULAUGSEPOCTNOVDEC\", date$[3..6].ToUpper(), 1) \/ 3) + 1\r\n\tEndFunction\r\n\t\r\n\tFunction getYear:Int()\r\n\t\tLocal date$ = CurrentDate()\r\n\t\tReturn Int(date[date.length - 4..]);\r\n\tEndFunction\r\n\t\r\n\tFunction getHours:Int()\r\n\t\tLocal time$ = CurrentTime()\r\n\t\tReturn Int(time[..2])\r\n\tEndFunction\r\n\t\r\n\tFunction getMinutes:Int()\r\n\t\tLocal time$ = CurrentTime()\r\n\t\tReturn Int(time[3..5])\r\n\tEndFunction\r\n\t\r\n\tFunction getSeconds:Int()\r\n\t\tLocal time$ = CurrentTime()\r\n\t\tReturn Int(time[6..8])\r\n\tEndFunction\r\n\t\r\n\tFunction getMilliSeconds:Int()\r\n\t\tReturn Millisecs()\r\n\tEndFunction\r\n\t\r\n\tFunction startGps()\r\n\tEndFunction\r\n\t\r\n\tFunction getLatitiude:String()\r\n\t\tReturn \"\"\r\n\tEndFunction\r\n\t\r\n\tFunction getLongitude:String()\r\n\t\tReturn \"\"\r\n\tEndFunction\r\n\r\n\tFunction showAlertDialog(title:String, message:String)\r\n\tEndFunction\r\n\t\r\n\tFunction getInputString:String()\r\n\t\tReturn \"\";\r\n\tEndFunction\r\n\t\r\n\tFunction getPixel:Int( x:int, y:int )\r\n'\t\tunsigned char pix[4];\r\n'\t\tglReadPixels(x, app->graphics->height-y ,1 ,1 ,GL_RGBA ,GL_UNSIGNED_BYTE ,pix);\r\n'\t\treturn (pix[3]<<24) | (pix[0]<<16) | (pix[1]<<8) | pix[2];\r\n\t\tReturn 0\r\n\tEndFunction\r\n\t\r\n\tFunction mouseZInit()\r\n\tEndFunction\r\n\r\n\tFunction mouseZ:Float()\r\n\t\tLocal ret:Float = BlitzMaxMouseZ() - diddy_mouseWheel\r\n\t\tdiddy_mouseWheel = BlitzMaxMouseZ()\r\n\t\tReturn ret\r\n\tEndFunction\r\n\t\r\n\tFunction SeekMusic:Int(timeMillis:Int)\r\n\t\tReturn 0\r\n\tEndFunction\r\nEndType\r\n\r\nFunction BlitzMaxMouseZ:Float()\r\n\tReturn MouseZ()\r\nEndFunction\r\n\r\n' ***** End diddy.bmax.bmx ******\r\n\r\n\r\n","old_contents":"' ***** Start diddy.bmax.bmx ******\r\nGlobal diddy_mouseWheel:Float = 0.0\r\n\r\nType diddy\r\n\tFunction systemMillisecs:Float()\r\n\t\tReturn Millisecs()\r\n\tEndFunction\r\n\t\r\n\tFunction setGraphics(w:int, h:int, fullScreen:Int = False)\r\n\t\tlocal d% = 0\r\n\t\tif fullScreen then d = 32\r\n\t\tGraphics w, h, d, 60\r\n\tEndFunction\r\n\t\r\n\tFunction setMouse(x:Int, y:Int)\r\n\t\tMoveMouse(x, y)\r\n\tEndFunction\r\n\t\r\n\tFunction showKeyboard()\r\n\tEndFunction\r\n\t\r\n\tFunction launchBrowser(address:String, windowName:String)\r\n\tEndFunction\r\n\t\r\n\tFunction launchEmail(email:String, subject:String, text:String)\r\n\tEndFunction\r\n\t\r\n\tFunction realMod:Float( value:Float, amount:Float )\r\n\t\tReturn value Mod amount\r\n\tEndFunction\r\n\t\r\n\tFunction startVibrate(millisecs:int)\r\n\tEndFunction\r\n\t\r\n\tFunction stopVibrate()\r\n\tEndFunction\r\n\t\r\n\tFunction getDayOfMonth:Int()\r\n\t\tLocal date$ = CurrentDate()\r\n\t\tReturn Int(date[..2])\r\n\tEndFunction\r\n\t\r\n\tFunction getDayOfWeek:Int()\r\n\t\tReturn 0\r\n\tEndFunction\r\n\t\r\n\tFunction getMonth:Int()\r\n\t\tLocal date$ = CurrentDate()\r\n\t\tReturn (Instr(\"JANFEBMARAPRMAYJUNJULAUGSEPOCTNOVDEC\", date$[3..6].ToUpper(), 1) \/ 3) + 1\r\n\tEndFunction\r\n\t\r\n\tFunction getYear:Int()\r\n\t\tLocal date$ = CurrentDate()\r\n\t\tReturn Int(date[date.length - 4..]);\r\n\tEndFunction\r\n\t\r\n\tFunction getHours:Int()\r\n\t\tLocal time$ = CurrentTime()\r\n\t\tReturn Int(time[..2])\r\n\tEndFunction\r\n\t\r\n\tFunction getMinutes:Int()\r\n\t\tLocal time$ = CurrentTime()\r\n\t\tReturn Int(time[3..5])\r\n\tEndFunction\r\n\t\r\n\tFunction getSeconds:Int()\r\n\t\tLocal time$ = CurrentTime()\r\n\t\tReturn Int(time[6..8])\r\n\tEndFunction\r\n\t\r\n\tFunction getMilliSeconds:Int()\r\n\t\tReturn Millisecs()\r\n\tEndFunction\r\n\t\r\n\tFunction startGps()\r\n\tEndFunction\r\n\t\r\n\tFunction getLatitiude:String()\r\n\t\tReturn \"\"\r\n\tEndFunction\r\n\t\r\n\tFunction getLongitude:String()\r\n\t\tReturn \"\"\r\n\tEndFunction\r\n\r\n\tFunction showAlertDialog(title:String, message:String)\r\n\tEndFunction\r\n\t\r\n\tFunction getInputString:String()\r\n\t\tReturn \"\";\r\n\tEndFunction\r\n\t\r\n\tFunction getPixel:Int( x:int, y:int )\r\n'\t\tunsigned char pix[4];\r\n'\t\tglReadPixels(x, app->graphics->height-y ,1 ,1 ,GL_RGBA ,GL_UNSIGNED_BYTE ,pix);\r\n'\t\treturn (pix[3]<<24) | (pix[0]<<16) | (pix[1]<<8) | pix[2];\r\n\t\tReturn 0\r\n\tEndFunction\r\n\t\r\n\tFunction mouseZInit()\r\n\tEndFunction\r\n\r\n\tFunction mouseZ:Float()\r\n\t\tLocal ret:Float = BlitzMaxMouseZ() - diddy_mouseWheel\r\n\t\tdiddy_mouseWheel = BlitzMaxMouseZ()\r\n\t\tReturn ret\r\n\tEndFunction\r\nEndType\r\n\r\nFunction BlitzMaxMouseZ:Float()\r\n\tReturn MouseZ()\r\nEndFunction\r\n\r\n' ***** End diddy.bmax.bmx ******\r\n\r\n\r\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"cad31fb11f24052a51df57681b55b229467df3c6","subject":"[variables] \tDocumentation correction","message":"[variables]\n\tDocumentation correction\n","repos":"komiga\/duct-max,komiga\/duct-max,komiga\/duct-max","old_file":"variables.mod\/variables.bmx","new_file":"variables.mod\/variables.bmx","new_contents":"\nRem\n\tCopyright (c) 2009 Tim Howard\n\t\n\tPermission is hereby granted, free of charge, to any person obtaining a copy\n\tof this software and associated documentation files (the \"Software\"), to deal\n\tin the Software without restriction, including without limitation the rights\n\tto use, copy, modify, merge, publish, distribute, sublicense, and\/or sell\n\tcopies of the Software, and to permit persons to whom the Software is\n\tfurnished to do so, subject to the following conditions:\n\t\n\tThe above copyright notice and this permission notice shall be included in\n\tall copies or substantial portions of the Software.\n\t\n\tTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n\tIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n\tFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n\tAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n\tLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n\tOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n\tTHE SOFTWARE.\n\t-----------------------------------------------------------------------------\n\t\n\tvariables.bmx (Contains: TV_INTEGER, TV_STRING, TV_FLOAT, TV_EVAL, TV_BOOL,\n\t\t\t\t\t\t\tTVariable, TStringVariable, TFloatVariable, TIntVariable, TEvalVariable, TBoolVariable, TIdentifier,\n\t\t\t\t\t\t\tTVariableMap, )\n\t\nEnd Rem\n\nSuperStrict\n\nRem\nbbdoc: Variables module\nEnd Rem\nModule duct.variables\n\nModuleInfo \"Version: 0.19\"\nModuleInfo \"Copyright: Tim Howard\"\nModuleInfo \"License: MIT\"\n\nModuleInfo \"History: Version 0.19\"\nModuleInfo \"History: Added TBoolVariable; documentation correction\"\nModuleInfo \"History: Version 0.18\"\nModuleInfo \"History: TIdentifier.AddValue now sets the variable's parent to itself\"\nModuleInfo \"History: Added SetParent and GetParent to TVaraible\"\nModuleInfo \"History: Version 0.17\"\nModuleInfo \"History: General cleanup\"\nModuleInfo \"History: Version 0.16\"\nModuleInfo \"History: Added SetAmbiguous to all TVariable types\"\nModuleInfo \"History: Added option to always use quoting with TStringVariables (on by default)\"\nModuleInfo \"History: Fixed TStringVariable.ConvToString returning of Null strings\"\nModuleInfo \"History: Version 0.15\"\nModuleInfo \"History: Change the Create method definition for easier use\"\nModuleInfo \"History: Changed the '\/eval::' recognizer to '\/e:' (as per SNode format change)\"\nModuleInfo \"History: Added the Copy method to every variable type\"\nModuleInfo \"History: Changed some formatting\"\nModuleInfo \"History: Version 0.14\"\nModuleInfo \"History: Changed type tabbing\"\nModuleInfo \"History: Fixed script output for TStringVariable (quotes are now only added if whitespace is present)\"\nModuleInfo \"History: Fixed script output for TIdentifier (identifier names can now contain whitespace, in which case they must be quoted)\"\nModuleInfo \"History: Version 0.13\"\nModuleInfo \"History: Added the DeSerializeUniversal function to TVariable\"\nModuleInfo \"History: Added Serialize and DeSerialize methods to all variable types\"\nModuleInfo \"History: Version 0.12\"\nModuleInfo \"History: Changed module name from 'variablemap' to 'variables'\"\nModuleInfo \"History: Moved all of duct.utilparser here\"\nModuleInfo \"History: Added the GetTVType function to all variable types\"\nModuleInfo \"History: Moved TV_* constants from duct.template here\"\nModuleInfo \"History: Version 0.11\"\nModuleInfo \"History: Added the ReportType function to all variable types\"\nModuleInfo \"History: Version 0.10\"\nModuleInfo \"History: Added the RawToVariable function to TVariable\"\nModuleInfo \"History: General code cleanup\"\nModuleInfo \"History: Version 0.09\"\nModuleInfo \"History: Corrected usage of syntax (in Returns, Cases, News and Selects)\"\nModuleInfo \"History: Version 0.08\"\nModuleInfo \"History: Added the TEvalVariable type\"\nModuleInfo \"History: Initial release\"\n\nImport brl.stream\nImport brl.linkedlist\n\nImport duct.etc\nImport duct.objectmap\n\nRem\n\tbbdoc: Template variable type for the #TIntVariable type.\nEnd Rem\nConst TV_INTEGER:Int = 1\nRem\n\tbbdoc: Template variable type for the #TStringVariable type.\nEnd Rem\nConst TV_STRING:Int = 2\nRem\n\tbbdoc: Template variable type for the #TFloatVariable type.\nEnd Rem\nConst TV_FLOAT:Int = 3\nRem\n\tbbdoc: Template variable type for the #TEvalVariable type.\nEnd Rem\nConst TV_EVAL:Int = 4\nRem\n\tbbdoc: Template variable type for the #TIdentifier type.\nEnd Rem\nConst TV_IDEN:Int = 5\nRem\n\tbbdoc: Template variable type for the #TBoolVariable type.\nEnd Rem\nConst TV_BOOL:Int = 6\n\nRem\n\tbbdoc: The Variable type.\n\tabout: This is the base variable type, you should extend from this to use it.\nEnd Rem\nType TVariable Abstract\n\t\n\tField m_name:String\n\tField m_parent:TVariable\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the variable's name.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetName(name:String)\n\t\tm_name = name\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the variable's name.\n\t\treturns: The variable's name.\n\tEnd Rem\n\tMethod GetName:String()\n\t\tReturn m_name\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the variable's parent.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetParent(parent:TVariable)\n\t\tm_parent = parent\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the variable's parent.\n\t\treturns: The variable's parent.\n\tEnd Rem\n\tMethod GetParent:TVariable()\n\t\tReturn m_parent\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Base method for setting the value of the variable to the given string (conversion).\n\tEnd Rem\n\tMethod SetAmbiguous(value:String) Abstract\n\t\n\tRem\n\t\tbbdoc: Base method for converting variable data to a script-ready string.\n\tEnd Rem\n\tMethod ConvToString:String() Abstract\n\t\n\tRem\n\t\tbbdoc: Base method for converting variable data to a printable\/usable-in-code string.\n\tEnd Rem\n\tMethod ValueAsString:String() Abstract\n\t\n'#end region (Field accessors)\n\t\n'#region Data handling\n\t\n\tRem\n\t\tbbdoc: Create a copy of the variable.\n\t\treturns: A clone of the variable.\n\tEnd Rem\n\tMethod Copy:TVariable() Abstract\n\t\n\tRem\n\t\tbbdoc: Serialize the variable to a stream.\n\t\treturns: Nothing.\n\t\tabout: @tv tells the method whether it should serialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod Serialize(stream:TStream, tv:Int = True, name:Int = False) Abstract\n\t\n\tRem\n\t\tbbdoc: Deserialize the variable from a stream.\n\t\treturns: The deserialized variable.\n\t\tabout: @tv tells the method whether it should deserialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod DeSerialize:TVariable(stream:TStream, tv:Int = True, name:Int = False) Abstract\n\t\n'#end region (Data handling)\n\t\n\tRem\n\t\tbbdoc: Base method: Get the type of this variable.\n\tEnd Rem\n\tFunction ReportType:String() Abstract\n\t\n\tRem\n\t\tbbdoc: Base method: Get the TV_* type of this variable.\n\tEnd Rem\n\tFunction GetTVType:Int() Abstract\n\t\n\tRem\n\t\tbbdoc: Convert raw data (raw data being things like: \"\/eval::(a+b\/0.4181)*a-b\" - an EvalVariable, \"A String variable1!!\", 3452134 - an IntVariable, 1204.00321 - a FloatVariable) into a Variable.\n\t\treturns: A new Variable, or Null if something whacky occured.\n\t\tabout: @etype is optional, it is used to go automagically to one type of a Variable (1 & 4=String (will check for '\/eval::' - EvalVariables), 2=Integer, 3=Float).
\n\t\t@varname is also an optional parameter. It will be used as the name of the variable.\n\tEnd Rem\n\tFunction RawToVariable:TVariable(vraw:String, etype:Int = 0, varname:String = \"\")\n\t\tLocal variable:TVariable\n\t\t\n\t\tIf vraw = Null\n\t\t\tDebugLog(\"(TVariable.RawToVariable) @vraw = Null; returning StringVariable (with @varname and Null value)\")\n\t\t\tReturn New TStringVariable.Create(varname, Null)\n\t\tEnd If\n\t\t\n\t\t'If etype = 1 ' Explicitly a string\n\t\t'\t\n\t\t'\tvariable = TVariable(New TStringVariable.Create(\"\", vraw))\n\t\t'\t\n\t\tIf etype = 0 ' Determine the value's type (must be either integer, double, or a string with no spaces)\n\t\t\tLocal i:Int\n\t\t\t\n\t\t\t' ASCII '0' to '9' = 48-57; '-' = 45, '+' = 43; and '.' = 46\n\t\t\tFor i = 0 To vraw.Length - 1\n\t\t\t\tLocal c:Int\n\t\t\t\t\n\t\t\t\tc = vraw[i]\n\t\t\t\tIf c >= 48 And c <= 57 Or c = 43 Or c = 45\n\t\t\t\t\tIf etype = 0 ' Leave float and string alone\n\t\t\t\t\t\tetype = 2 ' Integer so far..\n\t\t\t\t\tEnd If\n\t\t\t\tElse If c = 46\n\t\t\t\t\tIf etype = 2 ' Already declared as an integer?\n\t\t\t\t\t\tetype = 3\n\t\t\t\t\tEnd If\n\t\t\t\tElse ' If the character is not numerical there is nothing else to deduce and the value is a string\n\t\t\t\t\tetype = 4\n\t\t\t\t\tExit\n\t\t\t\tEnd If\n\t\t\tNext\n\t\t\t\n\t\t\tSelect etype\n\t\t\t\tCase 2 ' Integer\n\t\t\t\t\tvariable = TVariable(New TIntVariable.Create(varname, Int(vraw)))\n\t\t\t\tCase 3 ' Double\/Float\n\t\t\t\t\tvariable = TVariable(New TFloatVariable.Create(varname, Float(vraw)))\n\t\t\t\t'Case 4 ' String - non-explicit\n\t\t\t\t' Local evaltest:Int = vraw.ToLower().Find(\"\/eval::\")\n\t\t\t\t'\t\n\t\t\t\t'\tIf evaltest >= 0\n\t\t\t\t'\t\tvariable = TVariable(New TEvalVariable.Create(varname, vraw[evaltest + 7..]))\n\t\t\t\t'\tElse\n\t\t\t\t'\t\tvariable = TVariable(New TStringVariable.Create(varname, vraw))\n\t\t\t\t'\tEnd If\n\t\t\tEnd Select\n\t\t\t\n\t\tEnd If\n\t\t\n\t\tIf etype = 1 Or etype = 4\n\t\t\tLocal evaltest:Int = vraw.ToLower().Find(\"\/e:\")\n\t\t\tIf evaltest >= 0\n\t\t\t\tvariable = TVariable(New TEvalVariable.Create(varname, vraw[evaltest + 7..]))\n\t\t\tElse\n\t\t\t\tvariable = TVariable(New TStringVariable.Create(varname, vraw))\n\t\t\tEnd If\n\t\tEnd If\n\t\t' DebugLog(\"TSNode.LoadScriptFromStream().RawToVariable(); vraw = ~q\" + vraw + \"~q \\\" + etype)\n\t\t?Debug\n\t\tIf variable = Null Then DebugLog(\"( TVariable.RawToVariable() ) Unknown error, 'variable' is Null.\")\n\t\t?\n\t\tReturn variable\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Universally deserialize a variable from the given stream.\n\t\treturns: A DeSerialized variable.\n\t\tabout: This will deserialize any variable from the stream.
\n\t\tThis requires the variable to have been serialized with the template type (see #Serialize parameters).
\n\t\t@name tells the further DeSerialize calls if the name should be DeSerialized or not.\n\tEnd Rem\n\tFunction DeSerializeUniversal:TVariable(stream:TStream, name:Int = False)\n\t\tLocal tv:Int\n\t\t\n\t\ttv = Int(stream.ReadByte())\n\t\t\n\t\tSelect tv\n\t\t\tCase TV_INTEGER\n\t\t\t\tReturn New TIntVariable.DeSerialize(stream, True, name)\n\t\t\tCase TV_STRING\n\t\t\t\tReturn New TStringVariable.DeSerialize(stream, True, name)\n\t\t\tCase TV_FLOAT\n\t\t\t\tReturn New TFloatVariable.DeSerialize(stream, True, name)\n\t\t\tCase TV_EVAL\n\t\t\t\tReturn New TEvalVariable.DeSerialize(stream, True, name)\n\t\t\tCase TV_IDEN\n\t\t\t\tReturn New TIdentifier.DeSerialize(stream, True, name)\n\t\t\t\t\n\t\t\tDefault\n\t\t\t\tDebugLog(\"(TVariable.DeSerializeUniversal) Failed to recognize the TV in the stream: \" + tv)\n\t\t\t\t\n\t\tEnd Select\n\t\tReturn Null\n\tEnd Function\n\t\nEnd Type\n\nRem\n\tbbdoc: The TStringVariable type.\nEnd Rem\nType TStringVariable Extends TVariable\n\t\n\tGlobal m_alwaysusequotes:Int = True\n\t\n\tField m_value:String\n\t\n\tRem\n\t\tbbdoc: Create a new StringVariable.\n\t\treturns: The new StringVariable (itself).\n\tEnd Rem\n\tMethod Create:TStringVariable(name:String = Null, value:String)\n\t\tSetName(name)\n\t\tSet(value)\n\t\tReturn Self\n\tEnd Method\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the variable's value.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod Set(value:String)\n\t\tm_value = value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the variable's value.\n\t\treturns: The value of the variable.\n\tEnd Rem\n\tMethod Get:String()\n\t\tReturn m_value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the value of the TStringVariable to the given string (ambiguous).\n\t\treturns: Nothing.\n\t\tabout: For this type, this method is no different than calling #Set.\n\tEnd Rem\n\tMethod SetAmbiguous(value:String)\n\t\tm_value = value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Convert the variable to a String.\n\t\treturns: A String representation of the variable.\n\t\tabout: This function is for script output, for in-code use see #ValueAsString.\n\tEnd Rem\n\tMethod ConvToString:String()\n\t\tIf m_alwaysusequotes = True Or m_value.Contains(\"~t\") Or m_value.Contains(\" \") Or m_value = Null\n\t\t\tReturn \"~q\" + m_value + \"~q\"\n\t\tElse\n\t\t\tReturn m_value\n\t\tEnd If\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the StringVariable as a String.\n\t\treturns: The variable's value converted to a String.\n\t\tabout: Here for complete-ness, no difference to `instance.Get()`.\n\tEnd Rem\n\tMethod ValueAsString:String()\n\t\tReturn m_value\n\tEnd Method\n\t\n'#end region (Field accessors)\n\t\n'#region Data handling\n\t\n\tRem\n\t\tbbdoc: Create a copy of the variable\n\t\treturns: A clone of the variable.\n\tEnd Rem\n\tMethod Copy:TStringVariable()\n\t\tReturn New TStringVariable.Create(m_name, m_value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Serialize the variable to a stream.\n\t\treturns: Nothing.\n\t\tabout: @tv tells the method whether it should serialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod Serialize(stream:TStream, tv:Int = True, name:Int = False)\n\t\tIf tv = True\n\t\t\tstream.WriteByte(TV_STRING)\n\t\tEnd If\n\t\tIf name = True\n\t\t\tWriteLString(stream, m_name)\n\t\tEnd If\n\t\t\n\t\tWriteLString(stream, m_value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Deserialize the variable from a stream.\n\t\treturns: The deserialized variable.\n\t\tabout: @tv tells the method whether it should deserialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod DeSerialize:TStringVariable(stream:TStream, tv:Int = True, name:Int = False)\n\t\tIf tv = True\n\t\t\tstream.ReadByte()\n\t\tEnd If\n\t\tIf name = True\n\t\t\tm_name = ReadLString(stream)\n\t\tEnd If\n\t\t\n\t\tm_value = ReadLString(stream)\n\t\tReturn Self\n\tEnd Method\n\t\n'#end region (Data handling)\n\t\n\tRem\n\t\tbbdoc: Get the type of this variable.\n\t\treturns: The type of this variable (\"string\").\n\tEnd Rem\n\tFunction ReportType:String()\n\t\tReturn \"string\"\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Get the TV type of this variable.\n\t\treturns: The TV_* type of this variable (TV_STRING).\n\tEnd Rem\n\tFunction GetTVType:Int()\n\t\tReturn TV_STRING\n\tEnd Function\n\t\nEnd Type\n\nRem\n\tbbdoc: The TFloatVariable type.\nEnd Rem\nType TFloatVariable Extends TVariable\n\t\n\tField m_value:Float\n\t\n\tRem\n\t\tbbdoc: Create a new FloatVariable.\n\t\treturns: The new FloatVariable (itself).\n\tEnd Rem\n\tMethod Create:TFloatVariable(name:String = Null, value:Float)\n\t\tSetName(name)\n\t\tSet(value)\n\t\tReturn Self\n\tEnd Method\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the variable's value.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod Set(value:Float)\n\t\tm_value = value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the variable's value.\n\t\treturns: The value of the variable.\n\tEnd Rem\n\tMethod Get:Float()\n\t\tReturn m_value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the value of the variable to the given string (ambiguous).\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetAmbiguous(value:String)\n\t\tm_value = Float(value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Convert the variable to a String.\n\t\treturns: A scriptable form of the StringVariable.\n\t\tabout: This function is for script output, for in-code use see #ValueAsString.\n\tEnd Rem\n\tMethod ConvToString:String()\n\t\tLocal conv:String = String(m_value), i:Int, encountered:Int\n\t\t\n\t\tFor i = conv.Find(\".\") To conv.Length - 1\n\t\t\tIf conv[i] = 48\n\t\t\t\tIf encountered = True\n\t\t\t\t\tconv = conv[..i]\n\t\t\t\t\tExit\n\t\t\t\tEnd If\n\t\t\tElse If conv[i] <> 46\n\t\t\t\tencountered = True\n\t\t\tEnd If\n\t\tNext\n\t\t\n\t\tReturn conv\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the FloatVariable as a String.\n\t\treturns: The variable's value converted to a String.\n\tEnd Rem\n\tMethod ValueAsString:String()\n\t\tReturn String(m_value)\n\tEnd Method\n\t\n'#end region (Field accessors)\n\t\n'#region Data handling\n\t\n\tRem\n\t\tbbdoc: Create a copy of the variable\n\t\treturns: A clone of the variable.\n\tEnd Rem\n\tMethod Copy:TFloatVariable()\n\t\tReturn New TFloatVariable.Create(m_name, m_value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Serialize the variable to a stream.\n\t\treturns: Nothing.\n\t\tabout: @tv tells the method whether it should serialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod Serialize(stream:TStream, tv:Int = True, name:Int = False)\n\t\tIf tv = True\n\t\t\tstream.WriteByte(TV_FLOAT)\n\t\tEnd If\n\t\tIf name = True\n\t\t\tWriteLString(stream, m_name)\n\t\tEnd If\n\t\tstream.WriteFloat(m_value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Deserialize the variable from a stream.\n\t\treturns: The deserialized variable.\n\t\tabout: @tv tells the method whether it should deserialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod DeSerialize:TFloatVariable(stream:TStream, tv:Int = True, name:Int = False)\n\t\tIf tv = True\n\t\t\tstream.ReadByte()\n\t\tEnd If\n\t\tIf name = True\n\t\t\tm_name = ReadLString(stream)\n\t\tEnd If\n\t\tm_value = stream.ReadFloat()\n\t\tReturn Self\n\tEnd Method\n\t\n'#end region (Data handling)\n\t\n\tRem\n\t\tbbdoc: Get the type of this variable.\n\t\treturns: The type of this variable (\"float\").\n\tEnd Rem\n\tFunction ReportType:String()\n\t\tReturn \"float\"\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Get the TV type of this variable.\n\t\treturns: The TV_* type of this variable (TV_FLOAT).\n\tEnd Rem\n\tFunction GetTVType:Int()\n\t\tReturn TV_FLOAT\n\tEnd Function\n\t\nEnd Type\n\nRem\n\tbbdoc: The TIntVariable type.\nEnd Rem\nType TIntVariable Extends TVariable\n\t\n\tField m_value:Int\n\t\n\tRem\n\t\tbbdoc: Create a new IntVariable.\n\t\treturns: The new IntVariable (itself).\n\tEnd Rem\n\tMethod Create:TIntVariable(name:String = Null, value:Int)\n\t\tSetName(name)\n\t\tSet(value)\n\t\tReturn Self\n\tEnd Method\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the variable's value.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod Set(value:Int)\n\t\tm_value = value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the variable's value.\n\t\treturns: The value of the variable.\n\tEnd Rem\n\tMethod Get:Int()\n\t\tReturn m_value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the value of the variable to the given string (ambiguous).\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetAmbiguous(value:String)\n\t\tm_value = Int(value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Convert the variable to a String.\n\t\treturns: A string representation of the variable.\n\t\tabout: This function is for script output, for in-code use see #ValueAsString.\n\tEnd Rem\n\tMethod ConvToString:String()\n\t\tReturn String(m_value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the IntVariable as a String.\n\t\treturns: The variable's value converted to a String.\n\tEnd Rem\n\tMethod ValueAsString:String()\n\t\tReturn String(m_value)\n\tEnd Method\n\t\n'#end region (Field accessors)\n\t\n'#region Data handling\n\t\n\tRem\n\t\tbbdoc: Create a copy of the variable\n\t\treturns: A clone of the variable.\n\tEnd Rem\n\tMethod Copy:TIntVariable()\n\t\tReturn New TIntVariable.Create(m_name, m_value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Serialize the variable to a stream.\n\t\treturns: Nothing.\n\t\tabout: @tv tells the method whether it should serialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod Serialize(stream:TStream, tv:Int = True, name:Int = False)\n\t\tIf tv = True\n\t\t\tstream.WriteByte(TV_INTEGER)\n\t\tEnd If\n\t\tIf name = True\n\t\t\tWriteLString(stream, m_name)\n\t\tEnd If\n\t\t\n\t\tstream.WriteInt(m_value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Deserialize the variable from a stream.\n\t\treturns: The deserialized variable.\n\t\tabout: @tv tells the method whether it should deserialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod DeSerialize:TIntVariable(stream:TStream, tv:Int = True, name:Int = False)\n\t\tIf tv = True\n\t\t\tstream.ReadByte()\n\t\tEnd If\n\t\tIf name = True\n\t\t\tm_name = ReadLString(stream)\n\t\tEnd If\n\t\t\n\t\tm_value = stream.ReadInt()\n\t\tReturn Self\n\tEnd Method\n\t\n'#end region (Data handling)\n\t\n\tRem\n\t\tbbdoc: Get the type of this variable.\n\t\treturns: The type of this variable (\"int\").\n\tEnd Rem\n\tFunction ReportType:String()\n\t\tReturn \"int\"\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Get the TV type of this variable.\n\t\treturns: The TV_* type of this variable (TV_INTEGER).\n\tEnd Rem\n\tFunction GetTVType:Int()\n\t\tReturn TV_INTEGER\n\tEnd Function\n\t\nEnd Type\n\nRem\n\tbbdoc: The TEvalVariable type.\nEnd Rem\nType TEvalVariable Extends TVariable\n\t\n\tField m_value:String\n\t\n\tRem\n\t\tbbdoc: Create a new EvalVariable.\n\t\treturns: The new EvalVariable (itself).\n\tEnd Rem\n\tMethod Create:TEvalVariable(name:String = Null, value:String)\n\t\tSetName(name)\n\t\tSet(value)\n\t\tReturn Self\n\tEnd Method\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the equation string for the EvalVariable.\n\t\treturns: Nothing\n\tEnd Rem\n\tMethod Set(value:String)\n\t\tm_value = value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the equation string.\n\t\treturns: The equation string.\n\tEnd Rem\n\tMethod Get:String()\n\t\tReturn m_value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the value of the variable to the given string (ambiguous).\n\t\treturns: Nothing.\n\t\tabout: For this type, this method is no different than calling #Set.\n\tEnd Rem\n\tMethod SetAmbiguous(value:String)\n\t\tm_value = value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Convert the EvalVariable to a visual representation of its data.\n\t\treturns: The scriptable form of the EvalVariable.\n\t\tabout: This function is for script output, for in-code use see #ValueAsString.\n\tEnd Rem\n\tMethod ConvToString:String()\n\t\tReturn \"~q\/e:\" + m_value + \"~q\"\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the EvalVariable as a String.\n\t\treturns: The variable's value converted to a String.\n\tEnd Rem\n\tMethod ValueAsString:String()\n\t\tReturn m_value\n\tEnd Method\n\t\n'#end region (Field accessors)\n\t\n'#region Data handling\n\t\n\tRem\n\t\tbbdoc: Create a copy of the variable\n\t\treturns: A clone of the variable.\n\tEnd Rem\n\tMethod Copy:TEvalVariable()\n\t\tReturn New TEvalVariable.Create(m_name, m_value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Serialize the variable to a stream.\n\t\treturns: Nothing.\n\t\tabout: @tv tells the method whether it should serialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod Serialize(stream:TStream, tv:Int = True, name:Int = False)\n\t\tIf tv = True\n\t\t\tstream.WriteByte(TV_EVAL)\n\t\tEnd If\n\t\tIf name = True\n\t\t\tWriteLString(stream, m_name)\n\t\tEnd If\n\t\t\n\t\tWriteLString(stream, m_value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Deserialize the variable from a stream.\n\t\treturns: The deserialized variable.\n\t\tabout: @tv tells the method whether it should deserialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod DeSerialize:TEvalVariable(stream:TStream, tv:Int = True, name:Int = False)\n\t\tIf tv = True\n\t\t\tstream.ReadByte()\n\t\tEnd If\n\t\tIf name = True\n\t\t\tm_name = ReadLString(stream)\n\t\tEnd If\n\t\t\n\t\tm_value = ReadLString(stream)\n\t\tReturn Self\n\tEnd Method\n\t\n'#end region (Data handling)\n\t\n\tRem\n\t\tbbdoc: Get the type of this variable.\n\t\treturns: The type of this variable (\"eval\").\n\tEnd Rem\n\tFunction ReportType:String()\n\t\tReturn \"eval\"\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Get the TV type of this variable.\n\t\treturns: The TV_* type of this variable (TV_EVAL).\n\tEnd Rem\n\tFunction GetTVType:Int()\n\t\tReturn TV_EVAL\n\tEnd Function\n\t\nEnd Type\n\nRem\n\tbbdoc: The TBoolVariable type.\nEnd Rem\nType TBoolVariable Extends TVariable\n\t\n\tField m_value:Int\n\t\n\tRem\n\t\tbbdoc: Create a new BoolVariable.\n\t\treturns: The new BoolVariable (itself).\n\tEnd Rem\n\tMethod Create:TBoolVariable(name:String = Null, value:Int)\n\t\tSetName(name)\n\t\tSet(value)\n\t\tReturn Self\n\tEnd Method\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the variable's value.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod Set(value:Int)\n\t\tm_value = value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the variable's value.\n\t\treturns: The value of the variable.\n\tEnd Rem\n\tMethod Get:Int()\n\t\tReturn m_value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the value of the variable to the given string (ambiguous).\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetAmbiguous(value:String)\n\t\tm_value = Int(value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Convert the variable to a String.\n\t\treturns: A string representation of the variable.\n\t\tabout: This function is for script output, for in-code use see #ValueAsString.\n\tEnd Rem\n\tMethod ConvToString:String()\n\t\tReturn String(m_value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the TBoolVariable as a String.\n\t\treturns: The variable's value converted to a String.\n\tEnd Rem\n\tMethod ValueAsString:String()\n\t\tReturn String(m_value)\n\tEnd Method\n\t\n'#end region (Field accessors)\n\t\n'#region Data handling\n\t\n\tRem\n\t\tbbdoc: Create a copy of the variable\n\t\treturns: A clone of the variable.\n\tEnd Rem\n\tMethod Copy:TBoolVariable()\n\t\tReturn New TBoolVariable.Create(m_name, m_value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Serialize the variable to a stream.\n\t\treturns: Nothing.\n\t\tabout: @tv tells the method whether it should serialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod Serialize(stream:TStream, tv:Int = True, name:Int = False)\n\t\tIf tv = True\n\t\t\tstream.WriteByte(TV_BOOL)\n\t\tEnd If\n\t\tIf name = True\n\t\t\tWriteLString(stream, m_name)\n\t\tEnd If\n\t\tstream.WriteByte(Byte(m_value))\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Deserialize the variable from a stream.\n\t\treturns: The deserialized variable.\n\t\tabout: @tv tells the method whether it should deserialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod DeSerialize:TBoolVariable(stream:TStream, tv:Int = True, name:Int = False)\n\t\tIf tv = True\n\t\t\tstream.ReadByte()\n\t\tEnd If\n\t\tIf name = True\n\t\t\tm_name = ReadLString(stream)\n\t\tEnd If\n\t\tm_value = Int(stream.ReadByte())\n\t\tReturn Self\n\tEnd Method\n\t\n'#end region (Data handling)\n\t\n\tRem\n\t\tbbdoc: Get the type of this variable.\n\t\treturns: The type of this variable (\"bool\").\n\tEnd Rem\n\tFunction ReportType:String()\n\t\tReturn \"bool\"\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Get the TV type of this variable.\n\t\treturns: The TV_* type of this variable (TV_BOOL).\n\tEnd Rem\n\tFunction GetTVType:Int()\n\t\tReturn TV_BOOL\n\tEnd Function\n\t\nEnd Type\n\nRem\n\tbbdoc: The Identifier type.\nEnd Rem\nType TIdentifier Extends TVariable\n\t\n\tField m_values:TList\n\t\n\tMethod New()\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Create a new Identifier.\n\t\treturns: The new Identfier (itself).\n\tEnd Rem\n\tMethod Create:TIdentifier()\n\t\tm_values = New TList\n\t\tReturn Self\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Create a new Identifier with the given data.\n\t\treturns: The new Identfier (itself).\n\t\tabout: If the @values parameter is Null a new list will be created.\n\tEnd Rem\n\tMethod CreateByData:TIdentifier(name:String, values:TList = Null)\n\t\tSetName(name)\n\t\tIf values = Null\n\t\t\tm_values = New TList\n\t\tElse\n\t\t\tm_values = values\n\t\tEnd If\n\t\tReturn Self\n\tEnd Method\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the Identifier's values.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetValues(values:TList)\n\t\tm_values = values\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the Identifier's values.\n\t\treturns: A list containing the values which the Identifier holds.\n\tEnd Rem\n\tMethod GetValues:TList()\n\t\tReturn m_values\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Deprecated for this type.\n\t\treturns: Nothing.\n\t\tabout: This does nothing.\n\tEnd Rem\n\tMethod SetAmbiguous(value:String)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Convert the identifier to a string.\n\t\treturns: A string representation of the identifier.\n\tEnd Rem\n\tMethod ConvToString:String()\n\t\tLocal op:String, variable:TVariable\n\t\t\n\t\tIf m_name.Contains(\"~t\") = True Or m_name.Contains(\" \") = True\n\t\t\top = \"~q\" + m_name + \"~q \"\n\t\tElse\n\t\t\top = m_name + \" \"\n\t\tEnd If\n\t\t\n\t\tFor variable = EachIn m_values\n\t\t\top:+variable.ConvToString() + \" \"\n\t\tNext\n\t\top = op[..op.Length - 1]\n\t\tReturn op\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the Identifier as a string.\n\t\treturns: The Identifier contents converted to a string.\n\t\tabout: Here for complete-ness, simply calls #ConvToString.\n\tEnd Rem\n\tMethod ValueAsString:String()\n\t\tReturn ConvToString()\n\tEnd Method\n\t\n'#end region (Field accessors)\n\t\n'#region Value handling\n\t\n\tRem\n\t\tbbdoc: Get a value at an index.\n\t\treturns: The value in the identifier's list at the given index, or Null if it could not be retrieved.\n\t\tabout: The index is zero-based.\n\tEnd Rem\n\tMethod GetValueAtIndex:TVariable(index:Int)\n\t\tIf m_values <> Null And index > - 1 And index < m_values.Count()\n\t\t\tReturn TVariable(m_values.ValueAtIndex(index))\n\t\tEnd If\n\t\tReturn Null\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the number of values.\n\t\treturns: The number of values the Identifier contains.\n\tEnd Rem\n\tMethod GetValueCount:Int()\n\t\tIf m_values <> Null\n\t\t\tReturn m_values.Count()\n\t\tEnd If\n\t\tReturn 0\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Add a value to the Identifier.\n\t\treturns: True for success, or False for failure.\n\t\tabout: NOTE: This will set the given value's parent.\n\tEnd Rem\n\tMethod AddValue:Int(value:TVariable)\n\t\tIf m_values <> Null And value <> Null\n\t\t\tm_values.AddLast(value)\n\t\t\tvalue.SetParent(Self)\n\t\t\tReturn True\n\t\tEnd If\n\t\tReturn False\n\tEnd Method\n\t\n'#end region (Value handling)\n\t\n'#region Data handling\n\t\n\tRem\n\t\tbbdoc: Create a copy of the variable\n\t\treturns: A clone of the variable.\n\tEnd Rem\n\tMethod Copy:TIdentifier()\n\t\tLocal clone:TIdentifier\n\t\tclone = New TIdentifier.CreateByData(m_name)\n\t\tFor Local variable:TVariable = EachIn m_values\n\t\t\tclone.AddValue(variable.Copy())\n\t\tNext\n\t\tReturn clone\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Serialize the variable to a stream.\n\t\treturns: Nothing.\n\t\tabout: @tv tells the method whether it should serialize the TV type for the variable, or to not.
\n\t\tIn this case @name tells the method whether it should serialize the values<\/b><\/i>' name (the Identifier's name is always read\/written to the stream).\n\tEnd Rem\n\tMethod Serialize(stream:TStream, tv:Int = True, name:Int = False)\n\t\tLocal variable:TVariable\n\t\t\n\t\tIf tv = True\n\t\t\tstream.WriteByte(TV_STRING)\n\t\tEnd If\n\t\tWriteLString(stream, m_name)\n\t\t\n\t\tIf m_values = Null\n\t\t\tstream.WriteInt(0)\n\t\tElse\n\t\t\tstream.WriteInt(m_values.Count())\n\t\t\tFor variable = EachIn m_values\n\t\t\t\tvariable.Serialize(stream, True, name)\n\t\t\tNext\n\t\tEnd If\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Deserialize the variable from a stream.\n\t\treturns: The deserialized variable.\n\t\tabout: @tv tells the method whether it should deserialize the TV type for the variable, or to not.
\n\t\tIn this case @name tells the method whether it should deserialize the values<\/b><\/i>' name (the Identifier's name is always read\/written to the stream).\n\tEnd Rem\n\tMethod DeSerialize:TIdentifier(stream:TStream, tv:Int = True, name:Int = False)\n\t\tLocal count:Int, n:Int\n\t\t\n\t\tIf tv = True\n\t\t\tstream.ReadByte()\n\t\tEnd If\n\t\tm_name = ReadLString(stream)\n\t\t\n\t\tcount = stream.ReadInt()\n\t\tIf count > 0\n\t\t\tFor n = 0 To count - 1\n\t\t\t\tDeSerializeUniversal(stream, name)\n\t\t\tNext\n\t\tEnd If\n\t\t\n\t\tReturn Self\n\tEnd Method\n\t\n'#end region (Data handling)\n\t\n\tRem\n\t\tbbdoc: Get the type of this variable.\n\t\treturns: The type of this variable (\"identifier\").\n\tEnd Rem\n\tFunction ReportType:String()\n\t\tReturn \"identifier\"\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Get the TV type of this variable.\n\t\treturns: The TV_* type of this variable (TV_IDEN).\n\tEnd Rem\n\tFunction GetTVType:Int()\n\t\tReturn TV_IDEN\n\tEnd Function\n\t\nEnd Type\n\nRem\n\tbbdoc: The VariableMap type.\nEndRem\nType TVariableMap Extends TObjectMap\n\t\n\tRem\n\t\tbbdoc: Create a new VariableMap.\n\t\treturns: The new VariableMap (itself).\n\tEnd Rem\n\tMethod Create:TVariableMap()\n\t\tReturn Self\n\tEnd Method\n\t\n'#region Collections\n\t\n\tRem\n\t\tbbdoc: Insert a variable into the map.\n\t\treturns: True if the variable was added, or False if it was not (the variable's name is Null).\n\tEnd Rem\n\tMethod InsertVariable:Int(variable:TVariable)\n\t\tIf variable.GetName() <> Null\n\t\t\t_Insert(variable.GetName(), variable)\n\t\t\tReturn True\n\t\tEnd If\n\t\tReturn False\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Remove a variable by the name given.\n\t\treturns: True if a variable was removed, or False if it was not (the map contains no variable with the name given).\n\t\tabout: The name is<\/b> case-sensitive.\n\tEnd Rem\n\tMethod RemoveVariableByName:Int(name:String)\n\t\tReturn _Remove(name)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get a variable from the map by its name.\n\t\treturns: The variable object, or if the variable was not found, Null.\n\t\tabout: The name is<\/b> case-sensitive.\n\tEnd Rem\n\tMethod GetVariableByName:TVariable(name:String)\n\t\tReturn TVariable(_ValueByKey(name))\n\tEnd Method\n\t\n'#end region (Collections)\n\t\nEnd Type\n\n","old_contents":"\nRem\n\tCopyright (c) 2009 Tim Howard\n\t\n\tPermission is hereby granted, free of charge, to any person obtaining a copy\n\tof this software and associated documentation files (the \"Software\"), to deal\n\tin the Software without restriction, including without limitation the rights\n\tto use, copy, modify, merge, publish, distribute, sublicense, and\/or sell\n\tcopies of the Software, and to permit persons to whom the Software is\n\tfurnished to do so, subject to the following conditions:\n\t\n\tThe above copyright notice and this permission notice shall be included in\n\tall copies or substantial portions of the Software.\n\t\n\tTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n\tIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n\tFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n\tAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n\tLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n\tOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n\tTHE SOFTWARE.\n\t-----------------------------------------------------------------------------\n\t\n\tvariables.bmx (Contains: TV_INTEGER, TV_STRING, TV_FLOAT, TV_EVAL,\n\t\t\t\t\t\t\tTVariable, TStringVariable, TFloatVariable, TIntVariable, TEvalVariable, TIdentifier,\n\t\t\t\t\t\t\tTVariableMap, )\n\t\nEnd Rem\n\nSuperStrict\n\nRem\nbbdoc: Variables module\nEnd Rem\nModule duct.variables\n\nModuleInfo \"Version: 0.19\"\nModuleInfo \"Copyright: Tim Howard\"\nModuleInfo \"License: MIT\"\n\nModuleInfo \"History: Version 0.19\"\nModuleInfo \"History: Added TBoolVariable; documentation correction\"\nModuleInfo \"History: Version 0.18\"\nModuleInfo \"History: TIdentifier.AddValue now sets the variable's parent to itself\"\nModuleInfo \"History: Added SetParent and GetParent to TVaraible\"\nModuleInfo \"History: Version 0.17\"\nModuleInfo \"History: General cleanup\"\nModuleInfo \"History: Version 0.16\"\nModuleInfo \"History: Added SetAmbiguous to all TVariable types\"\nModuleInfo \"History: Added option to always use quoting with TStringVariables (on by default)\"\nModuleInfo \"History: Fixed TStringVariable.ConvToString returning of Null strings\"\nModuleInfo \"History: Version 0.15\"\nModuleInfo \"History: Change the Create method definition for easier use\"\nModuleInfo \"History: Changed the '\/eval::' recognizer to '\/e:' (as per SNode format change)\"\nModuleInfo \"History: Added the Copy method to every variable type\"\nModuleInfo \"History: Changed some formatting\"\nModuleInfo \"History: Version 0.14\"\nModuleInfo \"History: Changed type tabbing\"\nModuleInfo \"History: Fixed script output for TStringVariable (quotes are now only added if whitespace is present)\"\nModuleInfo \"History: Fixed script output for TIdentifier (identifier names can now contain whitespace, in which case they must be quoted)\"\nModuleInfo \"History: Version 0.13\"\nModuleInfo \"History: Added the DeSerializeUniversal function to TVariable\"\nModuleInfo \"History: Added Serialize and DeSerialize methods to all variable types\"\nModuleInfo \"History: Version 0.12\"\nModuleInfo \"History: Changed module name from 'variablemap' to 'variables'\"\nModuleInfo \"History: Moved all of duct.utilparser here\"\nModuleInfo \"History: Added the GetTVType function to all variable types\"\nModuleInfo \"History: Moved TV_* constants from duct.template here\"\nModuleInfo \"History: Version 0.11\"\nModuleInfo \"History: Added the ReportType function to all variable types\"\nModuleInfo \"History: Version 0.10\"\nModuleInfo \"History: Added the RawToVariable function to TVariable\"\nModuleInfo \"History: General code cleanup\"\nModuleInfo \"History: Version 0.09\"\nModuleInfo \"History: Corrected usage of syntax (in Returns, Cases, News and Selects)\"\nModuleInfo \"History: Version 0.08\"\nModuleInfo \"History: Added the TEvalVariable type\"\nModuleInfo \"History: Initial release\"\n\nImport brl.stream\nImport brl.linkedlist\n\nImport duct.etc\nImport duct.objectmap\n\nRem\n\tbbdoc: Template variable type for the TIntVariable type.\nEnd Rem\nConst TV_INTEGER:Int = 1\nRem\n\tbbdoc: Template variable type for the TTStringVariable type.\nEnd Rem\nConst TV_STRING:Int = 2\nRem\n\tbbdoc: Template variable type for the TFloatVariable type.\nEnd Rem\nConst TV_FLOAT:Int = 3\nRem\n\tbbdoc: Template variable type for the TEvalVariable type.\nEnd Rem\nConst TV_EVAL:Int = 4\nRem\n\tbbdoc: Template variable type for the TIdentifier type.\nEnd Rem\nConst TV_IDEN:Int = 5\nRem\n\tbbdoc: Template variable type for the TIdentifier type.\nEnd Rem\nConst TV_BOOL:Int = 6\n\nRem\n\tbbdoc: The Variable type.\n\tabout: This is the base variable type, you should extend from this to use it.\nEnd Rem\nType TVariable Abstract\n\t\n\tField m_name:String\n\tField m_parent:TVariable\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the variable's name.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetName(name:String)\n\t\tm_name = name\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the variable's name.\n\t\treturns: The variable's name.\n\tEnd Rem\n\tMethod GetName:String()\n\t\tReturn m_name\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the variable's parent.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetParent(parent:TVariable)\n\t\tm_parent = parent\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the variable's parent.\n\t\treturns: The variable's parent.\n\tEnd Rem\n\tMethod GetParent:TVariable()\n\t\tReturn m_parent\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Base method for setting the value of the variable to the given string (conversion).\n\tEnd Rem\n\tMethod SetAmbiguous(value:String) Abstract\n\t\n\tRem\n\t\tbbdoc: Base method for converting variable data to a script-ready string.\n\tEnd Rem\n\tMethod ConvToString:String() Abstract\n\t\n\tRem\n\t\tbbdoc: Base method for converting variable data to a printable\/usable-in-code string.\n\tEnd Rem\n\tMethod ValueAsString:String() Abstract\n\t\n'#end region (Field accessors)\n\t\n'#region Data handling\n\t\n\tRem\n\t\tbbdoc: Create a copy of the variable.\n\t\treturns: A clone of the variable.\n\tEnd Rem\n\tMethod Copy:TVariable() Abstract\n\t\n\tRem\n\t\tbbdoc: Serialize the variable to a stream.\n\t\treturns: Nothing.\n\t\tabout: @tv tells the method whether it should serialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod Serialize(stream:TStream, tv:Int = True, name:Int = False) Abstract\n\t\n\tRem\n\t\tbbdoc: Deserialize the variable from a stream.\n\t\treturns: The deserialized variable.\n\t\tabout: @tv tells the method whether it should deserialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod DeSerialize:TVariable(stream:TStream, tv:Int = True, name:Int = False) Abstract\n\t\n'#end region (Data handling)\n\t\n\tRem\n\t\tbbdoc: Base method: Get the type of this variable.\n\tEnd Rem\n\tFunction ReportType:String() Abstract\n\t\n\tRem\n\t\tbbdoc: Base method: Get the TV_* type of this variable.\n\tEnd Rem\n\tFunction GetTVType:Int() Abstract\n\t\n\tRem\n\t\tbbdoc: Convert raw data (raw data being things like: \"\/eval::(a+b\/0.4181)*a-b\" - an EvalVariable, \"A String variable1!!\", 3452134 - an IntVariable, 1204.00321 - a FloatVariable) into a Variable.\n\t\treturns: A new Variable, or Null if something whacky occured.\n\t\tabout: @etype is optional, it is used to go automagically to one type of a Variable (1 & 4=String (will check for '\/eval::' - EvalVariables), 2=Integer, 3=Float).
\n\t\t@varname is also an optional parameter. It will be used as the name of the variable.\n\tEnd Rem\n\tFunction RawToVariable:TVariable(vraw:String, etype:Int = 0, varname:String = \"\")\n\t\tLocal variable:TVariable\n\t\t\n\t\tIf vraw = Null\n\t\t\tDebugLog(\"(TVariable.RawToVariable) @vraw = Null; returning StringVariable (with @varname and Null value)\")\n\t\t\tReturn New TStringVariable.Create(varname, Null)\n\t\tEnd If\n\t\t\n\t\t'If etype = 1 ' Explicitly a string\n\t\t'\t\n\t\t'\tvariable = TVariable(New TStringVariable.Create(\"\", vraw))\n\t\t'\t\n\t\tIf etype = 0 ' Determine the value's type (must be either integer, double, or a string with no spaces)\n\t\t\tLocal i:Int\n\t\t\t\n\t\t\t' ASCII '0' to '9' = 48-57; '-' = 45, '+' = 43; and '.' = 46\n\t\t\tFor i = 0 To vraw.Length - 1\n\t\t\t\tLocal c:Int\n\t\t\t\t\n\t\t\t\tc = vraw[i]\n\t\t\t\tIf c >= 48 And c <= 57 Or c = 43 Or c = 45\n\t\t\t\t\tIf etype = 0 ' Leave float and string alone\n\t\t\t\t\t\tetype = 2 ' Integer so far..\n\t\t\t\t\tEnd If\n\t\t\t\tElse If c = 46\n\t\t\t\t\tIf etype = 2 ' Already declared as an integer?\n\t\t\t\t\t\tetype = 3\n\t\t\t\t\tEnd If\n\t\t\t\tElse ' If the character is not numerical there is nothing else to deduce and the value is a string\n\t\t\t\t\tetype = 4\n\t\t\t\t\tExit\n\t\t\t\tEnd If\n\t\t\tNext\n\t\t\t\n\t\t\tSelect etype\n\t\t\t\tCase 2 ' Integer\n\t\t\t\t\tvariable = TVariable(New TIntVariable.Create(varname, Int(vraw)))\n\t\t\t\tCase 3 ' Double\/Float\n\t\t\t\t\tvariable = TVariable(New TFloatVariable.Create(varname, Float(vraw)))\n\t\t\t\t'Case 4 ' String - non-explicit\n\t\t\t\t' Local evaltest:Int = vraw.ToLower().Find(\"\/eval::\")\n\t\t\t\t'\t\n\t\t\t\t'\tIf evaltest >= 0\n\t\t\t\t'\t\tvariable = TVariable(New TEvalVariable.Create(varname, vraw[evaltest + 7..]))\n\t\t\t\t'\tElse\n\t\t\t\t'\t\tvariable = TVariable(New TStringVariable.Create(varname, vraw))\n\t\t\t\t'\tEnd If\n\t\t\tEnd Select\n\t\t\t\n\t\tEnd If\n\t\t\n\t\tIf etype = 1 Or etype = 4\n\t\t\tLocal evaltest:Int = vraw.ToLower().Find(\"\/e:\")\n\t\t\tIf evaltest >= 0\n\t\t\t\tvariable = TVariable(New TEvalVariable.Create(varname, vraw[evaltest + 7..]))\n\t\t\tElse\n\t\t\t\tvariable = TVariable(New TStringVariable.Create(varname, vraw))\n\t\t\tEnd If\n\t\tEnd If\n\t\t' DebugLog(\"TSNode.LoadScriptFromStream().RawToVariable(); vraw = ~q\" + vraw + \"~q \\\" + etype)\n\t\t?Debug\n\t\tIf variable = Null Then DebugLog(\"( TVariable.RawToVariable() ) Unknown error, 'variable' is Null.\")\n\t\t?\n\t\tReturn variable\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Universally deserialize a variable from the given stream.\n\t\treturns: A DeSerialized variable.\n\t\tabout: This will deserialize any variable from the stream.
\n\t\tThis requires the variable to have been serialized with the template type (see #Serialize parameters).
\n\t\t@name tells the further DeSerialize calls if the name should be DeSerialized or not.\n\tEnd Rem\n\tFunction DeSerializeUniversal:TVariable(stream:TStream, name:Int = False)\n\t\tLocal tv:Int\n\t\t\n\t\ttv = Int(stream.ReadByte())\n\t\t\n\t\tSelect tv\n\t\t\tCase TV_INTEGER\n\t\t\t\tReturn New TIntVariable.DeSerialize(stream, True, name)\n\t\t\tCase TV_STRING\n\t\t\t\tReturn New TStringVariable.DeSerialize(stream, True, name)\n\t\t\tCase TV_FLOAT\n\t\t\t\tReturn New TFloatVariable.DeSerialize(stream, True, name)\n\t\t\tCase TV_EVAL\n\t\t\t\tReturn New TEvalVariable.DeSerialize(stream, True, name)\n\t\t\tCase TV_IDEN\n\t\t\t\tReturn New TIdentifier.DeSerialize(stream, True, name)\n\t\t\t\t\n\t\t\tDefault\n\t\t\t\tDebugLog(\"(TVariable.DeSerializeUniversal) Failed to recognize the TV in the stream: \" + tv)\n\t\t\t\t\n\t\tEnd Select\n\t\tReturn Null\n\tEnd Function\n\t\nEnd Type\n\nRem\n\tbbdoc: The TStringVariable type.\nEnd Rem\nType TStringVariable Extends TVariable\n\t\n\tGlobal m_alwaysusequotes:Int = True\n\t\n\tField m_value:String\n\t\n\tRem\n\t\tbbdoc: Create a new StringVariable.\n\t\treturns: The new StringVariable (itself).\n\tEnd Rem\n\tMethod Create:TStringVariable(name:String = Null, value:String)\n\t\tSetName(name)\n\t\tSet(value)\n\t\tReturn Self\n\tEnd Method\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the variable's value.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod Set(value:String)\n\t\tm_value = value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the variable's value.\n\t\treturns: The value of the variable.\n\tEnd Rem\n\tMethod Get:String()\n\t\tReturn m_value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the value of the TStringVariable to the given string (ambiguous).\n\t\treturns: Nothing.\n\t\tabout: For this type, this method is no different than calling #Set.\n\tEnd Rem\n\tMethod SetAmbiguous(value:String)\n\t\tm_value = value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Convert the variable to a String.\n\t\treturns: A String representation of the variable.\n\t\tabout: This function is for script output, for in-code use see #ValueAsString.\n\tEnd Rem\n\tMethod ConvToString:String()\n\t\tIf m_alwaysusequotes = True Or m_value.Contains(\"~t\") Or m_value.Contains(\" \") Or m_value = Null\n\t\t\tReturn \"~q\" + m_value + \"~q\"\n\t\tElse\n\t\t\tReturn m_value\n\t\tEnd If\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the StringVariable as a String.\n\t\treturns: The variable's value converted to a String.\n\t\tabout: Here for complete-ness, no difference to `instance.Get()`.\n\tEnd Rem\n\tMethod ValueAsString:String()\n\t\tReturn m_value\n\tEnd Method\n\t\n'#end region (Field accessors)\n\t\n'#region Data handling\n\t\n\tRem\n\t\tbbdoc: Create a copy of the variable\n\t\treturns: A clone of the variable.\n\tEnd Rem\n\tMethod Copy:TStringVariable()\n\t\tReturn New TStringVariable.Create(m_name, m_value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Serialize the variable to a stream.\n\t\treturns: Nothing.\n\t\tabout: @tv tells the method whether it should serialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod Serialize(stream:TStream, tv:Int = True, name:Int = False)\n\t\tIf tv = True\n\t\t\tstream.WriteByte(TV_STRING)\n\t\tEnd If\n\t\tIf name = True\n\t\t\tWriteLString(stream, m_name)\n\t\tEnd If\n\t\t\n\t\tWriteLString(stream, m_value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Deserialize the variable from a stream.\n\t\treturns: The deserialized variable.\n\t\tabout: @tv tells the method whether it should deserialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod DeSerialize:TStringVariable(stream:TStream, tv:Int = True, name:Int = False)\n\t\tIf tv = True\n\t\t\tstream.ReadByte()\n\t\tEnd If\n\t\tIf name = True\n\t\t\tm_name = ReadLString(stream)\n\t\tEnd If\n\t\t\n\t\tm_value = ReadLString(stream)\n\t\tReturn Self\n\tEnd Method\n\t\n'#end region (Data handling)\n\t\n\tRem\n\t\tbbdoc: Get the type of this variable.\n\t\treturns: The type of this variable (\"string\").\n\tEnd Rem\n\tFunction ReportType:String()\n\t\tReturn \"string\"\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Get the TV type of this variable.\n\t\treturns: The TV_* type of this variable (TV_STRING).\n\tEnd Rem\n\tFunction GetTVType:Int()\n\t\tReturn TV_STRING\n\tEnd Function\n\t\nEnd Type\n\nRem\n\tbbdoc: The TFloatVariable type.\nEnd Rem\nType TFloatVariable Extends TVariable\n\t\n\tField m_value:Float\n\t\n\tRem\n\t\tbbdoc: Create a new FloatVariable.\n\t\treturns: The new FloatVariable (itself).\n\tEnd Rem\n\tMethod Create:TFloatVariable(name:String = Null, value:Float)\n\t\tSetName(name)\n\t\tSet(value)\n\t\tReturn Self\n\tEnd Method\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the variable's value.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod Set(value:Float)\n\t\tm_value = value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the variable's value.\n\t\treturns: The value of the variable.\n\tEnd Rem\n\tMethod Get:Float()\n\t\tReturn m_value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the value of the variable to the given string (ambiguous).\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetAmbiguous(value:String)\n\t\tm_value = Float(value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Convert the variable to a String.\n\t\treturns: A scriptable form of the StringVariable.\n\t\tabout: This function is for script output, for in-code use see #ValueAsString.\n\tEnd Rem\n\tMethod ConvToString:String()\n\t\tLocal conv:String = String(m_value), i:Int, encountered:Int\n\t\t\n\t\tFor i = conv.Find(\".\") To conv.Length - 1\n\t\t\tIf conv[i] = 48\n\t\t\t\tIf encountered = True\n\t\t\t\t\tconv = conv[..i]\n\t\t\t\t\tExit\n\t\t\t\tEnd If\n\t\t\tElse If conv[i] <> 46\n\t\t\t\tencountered = True\n\t\t\tEnd If\n\t\tNext\n\t\t\n\t\tReturn conv\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the FloatVariable as a String.\n\t\treturns: The variable's value converted to a String.\n\tEnd Rem\n\tMethod ValueAsString:String()\n\t\tReturn String(m_value)\n\tEnd Method\n\t\n'#end region (Field accessors)\n\t\n'#region Data handling\n\t\n\tRem\n\t\tbbdoc: Create a copy of the variable\n\t\treturns: A clone of the variable.\n\tEnd Rem\n\tMethod Copy:TFloatVariable()\n\t\tReturn New TFloatVariable.Create(m_name, m_value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Serialize the variable to a stream.\n\t\treturns: Nothing.\n\t\tabout: @tv tells the method whether it should serialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod Serialize(stream:TStream, tv:Int = True, name:Int = False)\n\t\tIf tv = True\n\t\t\tstream.WriteByte(TV_FLOAT)\n\t\tEnd If\n\t\tIf name = True\n\t\t\tWriteLString(stream, m_name)\n\t\tEnd If\n\t\tstream.WriteFloat(m_value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Deserialize the variable from a stream.\n\t\treturns: The deserialized variable.\n\t\tabout: @tv tells the method whether it should deserialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod DeSerialize:TFloatVariable(stream:TStream, tv:Int = True, name:Int = False)\n\t\tIf tv = True\n\t\t\tstream.ReadByte()\n\t\tEnd If\n\t\tIf name = True\n\t\t\tm_name = ReadLString(stream)\n\t\tEnd If\n\t\tm_value = stream.ReadFloat()\n\t\tReturn Self\n\tEnd Method\n\t\n'#end region (Data handling)\n\t\n\tRem\n\t\tbbdoc: Get the type of this variable.\n\t\treturns: The type of this variable (\"float\").\n\tEnd Rem\n\tFunction ReportType:String()\n\t\tReturn \"float\"\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Get the TV type of this variable.\n\t\treturns: The TV_* type of this variable (TV_FLOAT).\n\tEnd Rem\n\tFunction GetTVType:Int()\n\t\tReturn TV_FLOAT\n\tEnd Function\n\t\nEnd Type\n\nRem\n\tbbdoc: The TIntVariable type.\nEnd Rem\nType TIntVariable Extends TVariable\n\t\n\tField m_value:Int\n\t\n\tRem\n\t\tbbdoc: Create a new IntVariable.\n\t\treturns: The new IntVariable (itself).\n\tEnd Rem\n\tMethod Create:TIntVariable(name:String = Null, value:Int)\n\t\tSetName(name)\n\t\tSet(value)\n\t\tReturn Self\n\tEnd Method\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the variable's value.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod Set(value:Int)\n\t\tm_value = value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the variable's value.\n\t\treturns: The value of the variable.\n\tEnd Rem\n\tMethod Get:Int()\n\t\tReturn m_value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the value of the variable to the given string (ambiguous).\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetAmbiguous(value:String)\n\t\tm_value = Int(value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Convert the variable to a String.\n\t\treturns: A string representation of the variable.\n\t\tabout: This function is for script output, for in-code use see #ValueAsString.\n\tEnd Rem\n\tMethod ConvToString:String()\n\t\tReturn String(m_value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the IntVariable as a String.\n\t\treturns: The variable's value converted to a String.\n\tEnd Rem\n\tMethod ValueAsString:String()\n\t\tReturn String(m_value)\n\tEnd Method\n\t\n'#end region (Field accessors)\n\t\n'#region Data handling\n\t\n\tRem\n\t\tbbdoc: Create a copy of the variable\n\t\treturns: A clone of the variable.\n\tEnd Rem\n\tMethod Copy:TIntVariable()\n\t\tReturn New TIntVariable.Create(m_name, m_value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Serialize the variable to a stream.\n\t\treturns: Nothing.\n\t\tabout: @tv tells the method whether it should serialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod Serialize(stream:TStream, tv:Int = True, name:Int = False)\n\t\tIf tv = True\n\t\t\tstream.WriteByte(TV_INTEGER)\n\t\tEnd If\n\t\tIf name = True\n\t\t\tWriteLString(stream, m_name)\n\t\tEnd If\n\t\t\n\t\tstream.WriteInt(m_value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Deserialize the variable from a stream.\n\t\treturns: The deserialized variable.\n\t\tabout: @tv tells the method whether it should deserialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod DeSerialize:TIntVariable(stream:TStream, tv:Int = True, name:Int = False)\n\t\tIf tv = True\n\t\t\tstream.ReadByte()\n\t\tEnd If\n\t\tIf name = True\n\t\t\tm_name = ReadLString(stream)\n\t\tEnd If\n\t\t\n\t\tm_value = stream.ReadInt()\n\t\tReturn Self\n\tEnd Method\n\t\n'#end region (Data handling)\n\t\n\tRem\n\t\tbbdoc: Get the type of this variable.\n\t\treturns: The type of this variable (\"int\").\n\tEnd Rem\n\tFunction ReportType:String()\n\t\tReturn \"int\"\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Get the TV type of this variable.\n\t\treturns: The TV_* type of this variable (TV_INTEGER).\n\tEnd Rem\n\tFunction GetTVType:Int()\n\t\tReturn TV_INTEGER\n\tEnd Function\n\t\nEnd Type\n\nRem\n\tbbdoc: The TEvalVariable type.\nEnd Rem\nType TEvalVariable Extends TVariable\n\t\n\tField m_value:String\n\t\n\tRem\n\t\tbbdoc: Create a new EvalVariable.\n\t\treturns: The new EvalVariable (itself).\n\tEnd Rem\n\tMethod Create:TEvalVariable(name:String = Null, value:String)\n\t\tSetName(name)\n\t\tSet(value)\n\t\tReturn Self\n\tEnd Method\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the equation string for the EvalVariable.\n\t\treturns: Nothing\n\tEnd Rem\n\tMethod Set(value:String)\n\t\tm_value = value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the equation string.\n\t\treturns: The equation string.\n\tEnd Rem\n\tMethod Get:String()\n\t\tReturn m_value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the value of the variable to the given string (ambiguous).\n\t\treturns: Nothing.\n\t\tabout: For this type, this method is no different than calling #Set.\n\tEnd Rem\n\tMethod SetAmbiguous(value:String)\n\t\tm_value = value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Convert the EvalVariable to a visual representation of its data.\n\t\treturns: The scriptable form of the EvalVariable.\n\t\tabout: This function is for script output, for in-code use see #ValueAsString.\n\tEnd Rem\n\tMethod ConvToString:String()\n\t\tReturn \"~q\/e:\" + m_value + \"~q\"\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the EvalVariable as a String.\n\t\treturns: The variable's value converted to a String.\n\tEnd Rem\n\tMethod ValueAsString:String()\n\t\tReturn m_value\n\tEnd Method\n\t\n'#end region (Field accessors)\n\t\n'#region Data handling\n\t\n\tRem\n\t\tbbdoc: Create a copy of the variable\n\t\treturns: A clone of the variable.\n\tEnd Rem\n\tMethod Copy:TEvalVariable()\n\t\tReturn New TEvalVariable.Create(m_name, m_value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Serialize the variable to a stream.\n\t\treturns: Nothing.\n\t\tabout: @tv tells the method whether it should serialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod Serialize(stream:TStream, tv:Int = True, name:Int = False)\n\t\tIf tv = True\n\t\t\tstream.WriteByte(TV_EVAL)\n\t\tEnd If\n\t\tIf name = True\n\t\t\tWriteLString(stream, m_name)\n\t\tEnd If\n\t\t\n\t\tWriteLString(stream, m_value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Deserialize the variable from a stream.\n\t\treturns: The deserialized variable.\n\t\tabout: @tv tells the method whether it should deserialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod DeSerialize:TEvalVariable(stream:TStream, tv:Int = True, name:Int = False)\n\t\tIf tv = True\n\t\t\tstream.ReadByte()\n\t\tEnd If\n\t\tIf name = True\n\t\t\tm_name = ReadLString(stream)\n\t\tEnd If\n\t\t\n\t\tm_value = ReadLString(stream)\n\t\tReturn Self\n\tEnd Method\n\t\n'#end region (Data handling)\n\t\n\tRem\n\t\tbbdoc: Get the type of this variable.\n\t\treturns: The type of this variable (\"eval\").\n\tEnd Rem\n\tFunction ReportType:String()\n\t\tReturn \"eval\"\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Get the TV type of this variable.\n\t\treturns: The TV_* type of this variable (TV_EVAL).\n\tEnd Rem\n\tFunction GetTVType:Int()\n\t\tReturn TV_EVAL\n\tEnd Function\n\t\nEnd Type\n\nRem\n\tbbdoc: The TBoolVariable type.\nEnd Rem\nType TBoolVariable Extends TVariable\n\t\n\tField m_value:Int\n\t\n\tRem\n\t\tbbdoc: Create a new BoolVariable.\n\t\treturns: The new BoolVariable (itself).\n\tEnd Rem\n\tMethod Create:TBoolVariable(name:String = Null, value:Int)\n\t\tSetName(name)\n\t\tSet(value)\n\t\tReturn Self\n\tEnd Method\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the variable's value.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod Set(value:Int)\n\t\tm_value = value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the variable's value.\n\t\treturns: The value of the variable.\n\tEnd Rem\n\tMethod Get:Int()\n\t\tReturn m_value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the value of the variable to the given string (ambiguous).\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetAmbiguous(value:String)\n\t\tm_value = Int(value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Convert the variable to a String.\n\t\treturns: A string representation of the variable.\n\t\tabout: This function is for script output, for in-code use see #ValueAsString.\n\tEnd Rem\n\tMethod ConvToString:String()\n\t\tReturn String(m_value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the TBoolVariable as a String.\n\t\treturns: The variable's value converted to a String.\n\tEnd Rem\n\tMethod ValueAsString:String()\n\t\tReturn String(m_value)\n\tEnd Method\n\t\n'#end region (Field accessors)\n\t\n'#region Data handling\n\t\n\tRem\n\t\tbbdoc: Create a copy of the variable\n\t\treturns: A clone of the variable.\n\tEnd Rem\n\tMethod Copy:TBoolVariable()\n\t\tReturn New TBoolVariable.Create(m_name, m_value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Serialize the variable to a stream.\n\t\treturns: Nothing.\n\t\tabout: @tv tells the method whether it should serialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod Serialize(stream:TStream, tv:Int = True, name:Int = False)\n\t\tIf tv = True\n\t\t\tstream.WriteByte(TV_BOOL)\n\t\tEnd If\n\t\tIf name = True\n\t\t\tWriteLString(stream, m_name)\n\t\tEnd If\n\t\tstream.WriteByte(Byte(m_value))\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Deserialize the variable from a stream.\n\t\treturns: The deserialized variable.\n\t\tabout: @tv tells the method whether it should deserialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod DeSerialize:TBoolVariable(stream:TStream, tv:Int = True, name:Int = False)\n\t\tIf tv = True\n\t\t\tstream.ReadByte()\n\t\tEnd If\n\t\tIf name = True\n\t\t\tm_name = ReadLString(stream)\n\t\tEnd If\n\t\tm_value = Int(stream.ReadByte())\n\t\tReturn Self\n\tEnd Method\n\t\n'#end region (Data handling)\n\t\n\tRem\n\t\tbbdoc: Get the type of this variable.\n\t\treturns: The type of this variable (\"bool\").\n\tEnd Rem\n\tFunction ReportType:String()\n\t\tReturn \"bool\"\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Get the TV type of this variable.\n\t\treturns: The TV_* type of this variable (TV_BOOL).\n\tEnd Rem\n\tFunction GetTVType:Int()\n\t\tReturn TV_BOOL\n\tEnd Function\n\t\nEnd Type\n\nRem\n\tbbdoc: The Identifier type.\nEnd Rem\nType TIdentifier Extends TVariable\n\t\n\tField m_values:TList\n\t\n\tMethod New()\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Create a new Identifier.\n\t\treturns: The new Identfier (itself).\n\tEnd Rem\n\tMethod Create:TIdentifier()\n\t\tm_values = New TList\n\t\tReturn Self\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Create a new Identifier with the given data.\n\t\treturns: The new Identfier (itself).\n\t\tabout: If the @values parameter is Null a new list will be created.\n\tEnd Rem\n\tMethod CreateByData:TIdentifier(name:String, values:TList = Null)\n\t\tSetName(name)\n\t\tIf values = Null\n\t\t\tm_values = New TList\n\t\tElse\n\t\t\tm_values = values\n\t\tEnd If\n\t\tReturn Self\n\tEnd Method\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the Identifier's values.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetValues(values:TList)\n\t\tm_values = values\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the Identifier's values.\n\t\treturns: A list containing the values which the Identifier holds.\n\tEnd Rem\n\tMethod GetValues:TList()\n\t\tReturn m_values\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Deprecated for this type.\n\t\treturns: Nothing.\n\t\tabout: This does nothing.\n\tEnd Rem\n\tMethod SetAmbiguous(value:String)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Convert the identifier to a string.\n\t\treturns: A string representation of the identifier.\n\tEnd Rem\n\tMethod ConvToString:String()\n\t\tLocal op:String, variable:TVariable\n\t\t\n\t\tIf m_name.Contains(\"~t\") = True Or m_name.Contains(\" \") = True\n\t\t\top = \"~q\" + m_name + \"~q \"\n\t\tElse\n\t\t\top = m_name + \" \"\n\t\tEnd If\n\t\t\n\t\tFor variable = EachIn m_values\n\t\t\top:+variable.ConvToString() + \" \"\n\t\tNext\n\t\top = op[..op.Length - 1]\n\t\tReturn op\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the Identifier as a string.\n\t\treturns: The Identifier contents converted to a string.\n\t\tabout: Here for complete-ness, simply calls #ConvToString.\n\tEnd Rem\n\tMethod ValueAsString:String()\n\t\tReturn ConvToString()\n\tEnd Method\n\t\n'#end region (Field accessors)\n\t\n'#region Value handling\n\t\n\tRem\n\t\tbbdoc: Get a value at an index.\n\t\treturns: The value in the identifier's list at the given index, or Null if it could not be retrieved.\n\t\tabout: The index is zero-based.\n\tEnd Rem\n\tMethod GetValueAtIndex:TVariable(index:Int)\n\t\tIf m_values <> Null And index > - 1 And index < m_values.Count()\n\t\t\tReturn TVariable(m_values.ValueAtIndex(index))\n\t\tEnd If\n\t\tReturn Null\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the number of values.\n\t\treturns: The number of values the Identifier contains.\n\tEnd Rem\n\tMethod GetValueCount:Int()\n\t\tIf m_values <> Null\n\t\t\tReturn m_values.Count()\n\t\tEnd If\n\t\tReturn 0\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Add a value to the Identifier.\n\t\treturns: True for success, or False for failure.\n\t\tabout: NOTE: This will set the given value's parent.\n\tEnd Rem\n\tMethod AddValue:Int(value:TVariable)\n\t\tIf m_values <> Null And value <> Null\n\t\t\tm_values.AddLast(value)\n\t\t\tvalue.SetParent(Self)\n\t\t\tReturn True\n\t\tEnd If\n\t\tReturn False\n\tEnd Method\n\t\n'#end region (Value handling)\n\t\n'#region Data handling\n\t\n\tRem\n\t\tbbdoc: Create a copy of the variable\n\t\treturns: A clone of the variable.\n\tEnd Rem\n\tMethod Copy:TIdentifier()\n\t\tLocal clone:TIdentifier\n\t\tclone = New TIdentifier.CreateByData(m_name)\n\t\tFor Local variable:TVariable = EachIn m_values\n\t\t\tclone.AddValue(variable.Copy())\n\t\tNext\n\t\tReturn clone\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Serialize the variable to a stream.\n\t\treturns: Nothing.\n\t\tabout: @tv tells the method whether it should serialize the TV type for the variable, or to not.
\n\t\tIn this case @name tells the method whether it should serialize the values<\/b><\/i>' name (the Identifier's name is always read\/written to the stream).\n\tEnd Rem\n\tMethod Serialize(stream:TStream, tv:Int = True, name:Int = False)\n\t\tLocal variable:TVariable\n\t\t\n\t\tIf tv = True\n\t\t\tstream.WriteByte(TV_STRING)\n\t\tEnd If\n\t\tWriteLString(stream, m_name)\n\t\t\n\t\tIf m_values = Null\n\t\t\tstream.WriteInt(0)\n\t\tElse\n\t\t\tstream.WriteInt(m_values.Count())\n\t\t\tFor variable = EachIn m_values\n\t\t\t\tvariable.Serialize(stream, True, name)\n\t\t\tNext\n\t\tEnd If\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Deserialize the variable from a stream.\n\t\treturns: The deserialized variable.\n\t\tabout: @tv tells the method whether it should deserialize the TV type for the variable, or to not.
\n\t\tIn this case @name tells the method whether it should deserialize the values<\/b><\/i>' name (the Identifier's name is always read\/written to the stream).\n\tEnd Rem\n\tMethod DeSerialize:TIdentifier(stream:TStream, tv:Int = True, name:Int = False)\n\t\tLocal count:Int, n:Int\n\t\t\n\t\tIf tv = True\n\t\t\tstream.ReadByte()\n\t\tEnd If\n\t\tm_name = ReadLString(stream)\n\t\t\n\t\tcount = stream.ReadInt()\n\t\tIf count > 0\n\t\t\tFor n = 0 To count - 1\n\t\t\t\tDeSerializeUniversal(stream, name)\n\t\t\tNext\n\t\tEnd If\n\t\t\n\t\tReturn Self\n\tEnd Method\n\t\n'#end region (Data handling)\n\t\n\tRem\n\t\tbbdoc: Get the type of this variable.\n\t\treturns: The type of this variable (\"identifier\").\n\tEnd Rem\n\tFunction ReportType:String()\n\t\tReturn \"identifier\"\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Get the TV type of this variable.\n\t\treturns: The TV_* type of this variable (TV_IDEN).\n\tEnd Rem\n\tFunction GetTVType:Int()\n\t\tReturn TV_IDEN\n\tEnd Function\n\t\nEnd Type\n\nRem\n\tbbdoc: The VariableMap type.\nEndRem\nType TVariableMap Extends TObjectMap\n\t\n\tRem\n\t\tbbdoc: Create a new VariableMap.\n\t\treturns: The new VariableMap (itself).\n\tEnd Rem\n\tMethod Create:TVariableMap()\n\t\tReturn Self\n\tEnd Method\n\t\n'#region Collections\n\t\n\tRem\n\t\tbbdoc: Insert a variable into the map.\n\t\treturns: True if the variable was added, or False if it was not (the variable's name is Null).\n\tEnd Rem\n\tMethod InsertVariable:Int(variable:TVariable)\n\t\tIf variable.GetName() <> Null\n\t\t\t_Insert(variable.GetName(), variable)\n\t\t\tReturn True\n\t\tEnd If\n\t\tReturn False\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Remove a variable by the name given.\n\t\treturns: True if a variable was removed, or False if it was not (the map contains no variable with the name given).\n\t\tabout: The name is<\/b> case-sensitive.\n\tEnd Rem\n\tMethod RemoveVariableByName:Int(name:String)\n\t\tReturn _Remove(name)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get a variable from the map by its name.\n\t\treturns: The variable object, or if the variable was not found, Null.\n\t\tabout: The name is<\/b> case-sensitive.\n\tEnd Rem\n\tMethod GetVariableByName:TVariable(name:String)\n\t\tReturn TVariable(_ValueByKey(name))\n\tEnd Method\n\t\n'#end region (Collections)\n\t\nEnd Type\n\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"e1ae32f7970984f6ec0602117faacc7dafc30f83","subject":"Makes no sense call Close() when msg is Null","message":"Makes no sense call Close() when msg is Null\n","repos":"Htbaa\/zmq.mod,Htbaa\/zmq.mod","old_file":"tests\/main.bmx","new_file":"tests\/main.bmx","new_contents":"SuperStrict\nFramework bah.maxunit\nImport htbaapub.zmq\n\nNew TTestSuite.run()\n\nType TZMQ_Test Extends TTest\n\n\tMethod Setup() {before}\n\tEnd Method\n\t\n\tMethod Teardown() {after}\n\tEnd Method\n\n\tMethod Version() {test}\n\t\tLocal parts:String[] = TZMQ.Version().Split(\".\")\n\t\tassertTrue(parts.Length = 3, \"Version string contains 3 parts\")\n\tEnd Method\n\t\n\t'Make sure recreating an existing context\n\tMethod ContextReCreate() {test}\n\t\tLocal ct:TZMQ_Context = New TZMQ_Context.Create()\n\t\tTry\n\t\t\tct = ct.Create()\n\t\tCatch ex:String\n\t\t\tassertNotNull(ex, \"Recreating context failed properly\")\n\t\tCatch ex:TZMQ_Exception\n\t\t\tfail(ex.ToString())\n\t\tEnd Try\n\t\tct.Term()\n\tEnd Method\n\n\t'Make sure a socket can be created\n\tMethod SocketCreate() {test}\n\t\tLocal ct:TZMQ_Context = New TZMQ_Context.Create()\n\t\tLocal socket:TZMQ_Socket = ct.socket(ZMQ_PUB)\n\t\tassertNotNull(socket, \"Created socket\")\n\t\tassertTrue(socket.socket <> Null, \"Created pointer to socket\")\n\t\tsocket.Close()\n\t\tct.Term()\n\tEnd Method\n\n\t'Make sure created messages contain expected data\n\tMethod MessageCreationIntegrity() {test}\n\t\tFor Local i:Int = 0 To 1000\n\t\t\tLocal text:String = \"Message \" + i\n\t\t\tLocal msg:TZMQ_Message = New TZMQ_Message.Create(text)\n\t\t\tassertEquals(text, msg.ToString(), \"Message text match\")\n\t\t\tassertEqualsI(text.Length, msg.Size(), \"Message size match\")\n\t\t\tmsg.Close()\n\t\tNext\n\tEnd Method\n\t\n\t'Make sure exchanged messages aren't corrupt\n\tMethod MessageExchangingIntegrity() {test}\n\t\tLocal addr:String = \"tcp:\/\/127.0.0.1:6000\"\n\t\tLocal ct:TZMQ_Context = New TZMQ_Context.Create()\n\t\tLocal publisher:TZMQ_Socket = ct.socket(ZMQ_PUB)\n\t\tLocal subscriber:TZMQ_Socket = ct.socket(ZMQ_SUB)\n\t\t\n\t\tpublisher.Bind(addr)\n\t\tsubscriber.Connect(addr)\n\t\tsubscriber.SetSockOpt(ZMQ_SUBSCRIBE, Null)\n\t\t\n\t\tFor Local i:Int = 0 To 100\n\t\t\tDelay 10\n\t\t\tLocal text:String = \"Message \" + i\n\t\t\tpublisher.Send(text)\n\t\t\tLocal msg:TZMQ_Message = subscriber.Recv()\n\t\t\tIf msg = Null Then Continue\n\t\t\tassertEquals(text, msg.ToString(), \"Message \" + i + \" match\")\n\t\t\tassertEqualsI(text.Length, msg.Size(), \"Message \" + i + \" size match\")\n\t\t\tmsg.Close()\n\t\tNext\n\t\t\n\t\tsubscriber.Close()\n\t\tpublisher.Close()\n\t\tct.Term()\n\tEnd Method\nEnd Type\n","old_contents":"SuperStrict\nFramework bah.maxunit\nImport htbaapub.zmq\n\nNew TTestSuite.run()\n\nType TZMQ_Test Extends TTest\n\n\tMethod Setup() {before}\n\tEnd Method\n\t\n\tMethod Teardown() {after}\n\tEnd Method\n\n\tMethod Version() {test}\n\t\tLocal parts:String[] = TZMQ.Version().Split(\".\")\n\t\tassertTrue(parts.Length = 3, \"Version string contains 3 parts\")\n\tEnd Method\n\t\n\t'Make sure recreating an existing context\n\tMethod ContextReCreate() {test}\n\t\tLocal ct:TZMQ_Context = New TZMQ_Context.Create()\n\t\tTry\n\t\t\tct = ct.Create()\n\t\tCatch ex:String\n\t\t\tassertNotNull(ex, \"Recreating context failed properly\")\n\t\tCatch ex:TZMQ_Exception\n\t\t\tfail(ex.ToString())\n\t\tEnd Try\n\t\tct.Term()\n\tEnd Method\n\n\t'Make sure a socket can be created\n\tMethod SocketCreate() {test}\n\t\tLocal ct:TZMQ_Context = New TZMQ_Context.Create()\n\t\tLocal socket:TZMQ_Socket = ct.socket(ZMQ_PUB)\n\t\tassertNotNull(socket, \"Created socket\")\n\t\tassertTrue(socket.socket <> Null, \"Created pointer to socket\")\n\t\tsocket.Close()\n\t\tct.Term()\n\tEnd Method\n\n\t'Make sure created messages contain expected data\n\tMethod MessageCreationIntegrity() {test}\n\t\tFor Local i:Int = 0 To 1000\n\t\t\tLocal text:String = \"Message \" + i\n\t\t\tLocal msg:TZMQ_Message = New TZMQ_Message.Create(text)\n\t\t\tassertEquals(text, msg.ToString(), \"Message text match\")\n\t\t\tassertEqualsI(text.Length, msg.Size(), \"Message size match\")\n\t\t\tmsg.Close()\n\t\tNext\n\tEnd Method\n\t\n\t'Make sure exchanged messages aren't corrupt\n\tMethod MessageExchangingIntegrity() {test}\n\t\tLocal addr:String = \"tcp:\/\/127.0.0.1:6000\"\n\t\tLocal ct:TZMQ_Context = New TZMQ_Context.Create()\n\t\tLocal publisher:TZMQ_Socket = ct.socket(ZMQ_PUB)\n\t\tLocal subscriber:TZMQ_Socket = ct.socket(ZMQ_SUB)\n\t\t\n\t\tpublisher.Bind(addr)\n\t\tsubscriber.Connect(addr)\n\t\tsubscriber.SetSockOpt(ZMQ_SUBSCRIBE, Null)\n\t\t\n\t\tFor Local i:Int = 0 To 100\n\t\t\tDelay 10\n\t\t\tLocal text:String = \"Message \" + i\n\t\t\tpublisher.Send(text)\n\t\t\tLocal msg:TZMQ_Message = subscriber.Recv()\n\t\t\tIf msg = Null Then msg.Close() ; Continue\n\t\t\tassertEquals(text, msg.ToString(), \"Message \" + i + \" match\")\n\t\t\tassertEqualsI(text.Length, msg.Size(), \"Message \" + i + \" size match\")\n\t\t\tmsg.Close()\n\t\tNext\n\t\t\n\t\tsubscriber.Close()\n\t\tpublisher.Close()\n\t\tct.Term()\n\tEnd Method\nEnd Type\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"aaf6327de84278b5cdbfb9eea4254a2574a5b91d","subject":"element removal","message":"element removal\n","repos":"Leushenko\/blue-moon","old_file":"bluetable.bmx","new_file":"bluetable.bmx","new_contents":"\n' Blue Moon\n' Lua-table implementation\n' uses simple linear probing for collision resolution and a shockingly naive reallocator\n\n\nSuperStrict\n\nImport \"blueallocator.bmx\"\n\n\nPrivate\nExtern\n\tFunction frexp:Double(d:Double, Exp:Int Ptr) = \"frexp\"\nEnd Extern\nPublic\n\nType BlueTable Final\n\t' retrieve the slot *for* a key's value, null if no available slot exists (to be used by non-raw index\/set operations)\n\tFunction GetSlot:Long Ptr(tbl:Byte Ptr, key:Long, keyslot:Long Ptr Ptr)\t'keyslot will return the slot for the key if it's not an array-slot\n\t\tLocal tag:Int = Int Ptr(Varptr(key))[1], idx:Int\n\t\tConst NILTAG:Int = BlueTypeTag.NANBOX | BlueTypeTag.NIL\n\t\t\n\t\tIf tag = BlueTypeTag.NANBOX | BlueTypeTag.STR\t'string - common case\n\t\t\tidx = Int Ptr(Int(key))[1]\n\t\tElseIf tag & BlueTypeTag.NANBOX_CHK <> BlueTypeTag.NANBOX\t'number\n\t\t\tLocal d:Double ; Long Ptr(Varptr(d))[0] = key ; idx = Abs Int(d)\n\t\t\tIf d = idx\t'int key\n\t\t\t\tLocal arr:Byte Ptr = Byte Ptr Ptr(tbl)[3]\n\t\t\t\tIf arr And idx < Int Ptr(arr)[-1] Then Return Long Ptr(arr) + idx\t'if this is nil, it won't be in the hash part anyway\n\t\t\tElse\n\t\t\t\td = frexp(d, Varptr(idx)) * ($7fffffff - 1024)\t'INT_MAX - DBL_MAX_EXP\n\t\t\t\tidx = Abs(idx) + Int(d)\n\t\t\tEndIf\n\t\tElseIf tag = NILTAG\t'nil -> nil\n\t\t\tkeyslot[0] = Long Ptr(1) ; Return Null\n\t\tElse\t'pointer (needs improvement)\n\t\t\tidx = Int(key) Shr 3\n\t\tEndIf\n\t\t\n\t\tLocal hashpart:Byte Ptr = Byte Ptr Ptr(tbl)[2]\n\t\tIf hashpart\n\t\t\tLocal hsize:Int = 1 Shl Int Ptr(hashpart)[-1]\n\t\t\tidx = idx & (hsize - 1)\t'apparently this is faster than Mod\n\t\t\tFor Local i:Int = idx Until hsize\t'naive linear probe\n\t\t\t\tLocal kp:Long Ptr = Long Ptr(hashpart) + 2 * i\n\t\t\t\tIf kp[0] = key Or Int Ptr(kp)[1] = NILTAG\n\t\t\t\t\tkeyslot[0] = kp ; Return kp + 1\n\t\t\t\tEndIf\n\t\t\tNext\n\t\t\tFor Local i:Int = 0 Until idx\t'yep\n\t\t\t\tLocal kp:Long Ptr = Long Ptr(hashpart) + 2 * i\n\t\t\t\tIf kp[0] = key Or Int Ptr(kp)[1] = NILTAG\n\t\t\t\t\tkeyslot[0] = kp ; Return kp + 1\n\t\t\t\tEndIf\n\t\t\tNext\n\t\tEndIf\n\t\t\n\t\tReturn Null\n\tEnd Function\n\t\n\t' retrieve a value from a table, or nil\n\tFunction RawGet:Long(tbl:Byte Ptr, key:Long)\n\t\tLocal keyp:Long Ptr = Null, retp:Long Ptr = GetSlot(tbl, key, Varptr(keyp)), ret:Long\n\t\tIf retp And (keyp <> Long Ptr(1))\n\t\t\tret = retp[0]\n\t\tElse\n\t\t\tInt Ptr(Varptr(ret))[1] = BlueTypeTag.NANBOX | BlueTypeTag.NIL\t'why can't i shift longs?\n\t\tEndIf\n\t\tReturn ret\n\tEnd Function\n\t\n\t' put a value into a table, resizing it if necessary\n\tFunction RawSet(mem:BlueVMMemory, tbl:Byte Ptr, key:Long, val:Long)\n\t\tLocal keyp:Long Ptr = Null, valp:Long Ptr = GetSlot(tbl, key, Varptr(keyp))\n\t\tConst NILTAG:Int = BlueTypeTag.NANBOX | BlueTypeTag.NIL\n\t\tIf valp\n\t\t\tmem.Write(valp, val)\n\t\t\tIf keyp\n\t\t\t\tLocal hashpart:Int Ptr = Int Ptr Ptr(tbl)[2]\n\t\t\t\tIf Int Ptr(valp)[1] <> NILTAG\n\t\t\t\t\tIf keyp[0] <> key Then mem.Write(keyp, key) ; hashpart[-2] :+ 1\n\t\t\t\tElse\t'nil value = remove element\n\t\t\t\t\tmem.Write(keyp, val) ; hashpart[-2] :- 1\n\t\t\t\tEndIf\n\t\t\tEndIf\n\t\tElseIf keyp <> Long Ptr(1)\n\t\t\tResize(mem, tbl, key) ; RawSet mem, tbl, key, val\n\t\tEndIf\n\tEnd Function\n\t\n\tFunction Resize(mem:BlueVMMemory, tbl:Byte Ptr, key:Long)\n\t\tLocal hashpart:Byte Ptr = Byte Ptr Ptr(tbl)[2], arraypart:Byte Ptr = Byte Ptr Ptr(tbl)[3]\n\t\tConst NILTAG:Int = BlueTypeTag.NANBOX | BlueTypeTag.NIL\n\t\t\n\t\tLocal asize:Int = 0, tsize:Int = 0, numcount:Int[32]\n\t\tIf arraypart\t'compute new array size\n\t\t\tIf Int Ptr(arraypart)[1] <> NILTAG Then numcount[0] = 1\n\t\t\tLocal cell:Int = 1, cellp2:Int = 2 ^ cell\n\t\t\tFor Local i:Int = 1 Until Int Ptr(arraypart)[-1]\n\t\t\t\tIf i >= cellp2 Then cell :+ 1 ; cellp2 = 2 ^ cell\n\t\t\t\tIf Int Ptr(arraypart)[i * 2 + 1] <> NILTAG Then numcount[cell] :+ 1\n\t\t\tNext\n\t\tEndIf\n\t\tIf hashpart\n\t\t\tFor Local i:Int = 0 Until Int Ptr(hashpart)[-2]\n\t\t\t\tLocal tag2:Int = Int Ptr(hashpart)[i * 4 + 1]\n\t\t\t\tIf tag2 & BlueTypeTag.NANBOX_CHK <> BlueTypeTag.NANBOX\n\t\t\t\t\tLocal d:Double = Double Ptr(hashpart)[i * 2]\n\t\t\t\t\tIf d = Abs Int(d) Then numcount[Ceil(Log(d + 1) \/ Log(2))] :+ 1 Else tsize :+ 1\n\t\t\t\tElse\n\t\t\t\t\ttsize :+ 1\t'get started on new table size\n\t\t\t\tEndIf\n\t\t\tNext\n\t\tEndIf\n\t\t\n\t\tLocal tag:Int = Int Ptr(Varptr(key))[1]\t'add key to the appropriate one\n\t\tIf tag & BlueTypeTag.NANBOX_CHK <> BlueTypeTag.NANBOX\n\t\t\tLocal d:Double = Double Ptr(Varptr(key))[0]\n\t\t\tIf d = Abs Int(d) Then numcount[Ceil(Log(d + 1) \/ Log(2))] :+ 1 Else tsize :+ 1\n\t\tElse\n\t\t\ttsize :+ 1\n\t\tEndIf\n\t\tFor Local i:Int = 0 Until 32\t'tally up\n\t\t\tIf i Then numcount[i] :+ numcount[i - 1]\n\t\t\tIf numcount[i] > 2 ^ i \/ 2 Then asize = 2 ^ i\n\t\tNext\n\t\tIf arraypart <> Null\t'complete new table size with any discarded array elements\n\t\t\tFor Local i:Int = asize Until Int Ptr(arraypart)[-1]\n\t\t\t\tIf Int Ptr(arraypart)[i * 2 + 1] <> NILTAG Then tsize :+ 1\n\t\t\tNext\n\t\tEndIf\n\t\t\n\t\tLocal newarray:Byte Ptr = Null, newtable:Byte Ptr = Null\t'allocate and copy\n\t\tLocal oldasize:Int = 0 ; If arraypart Then oldasize = Int Ptr(arraypart)[-1]\n\t\tLocal oldtsize:Int = 0 ; If hashpart Then oldtsize = Int Ptr(hashpart)[-1]\n\t\t\n\t\tIf asize <> oldasize\n\t\t\tnewarray = mem.AllocObject(asize * 8 + 8, BlueTypeTag.ARR) + 8\n\t\t\tFor Local i:Int = 0 Until asize\n\t\t\t\tInt Ptr(newarray)[i * 2 + 1] = NILTAG\n\t\t\tNext\n\t\t\tInt Ptr(newarray)[-1] = asize ; Byte Ptr Ptr(tbl)[3] = newarray\n\t\tElseIf asize = 0\n\t\t\tInt Ptr(tbl)[3] = 0\n\t\tElse\n\t\t\tnewarray = arraypart ; arraypart = Null\n\t\tEndIf\n\t\tIf tsize <> oldtsize\n\t\t\tnewtable = mem.AllocObject(2 ^ tsize * 16 + 8, BlueTypeTag.HASH)\n\t\t\tFor Local i:Int = 0 Until 2 ^ tsize * 2\n\t\t\t\tInt Ptr(newtable)[i * 2 + 1] = NILTAG\n\t\t\tNext\n\t\t\tInt Ptr(newtable)[-1] = tsize ; Int Ptr(newtable)[-2] = 0\n\t\t\tByte Ptr Ptr(tbl)[2] = newtable\n\t\tElseIf tsize = 0\n\t\t\tInt Ptr(tbl)[2] = 0\n\t\tElse\n\t\t\tnewtable = hashpart ; hashpart = Null\n\t\tEndIf\n\t\t\n\t\tIf arraypart\n\t\t\tFor Local i:Int = 0 Until oldasize\t'reinsert values\n\t\t\t\tLocal key:Long ; Double Ptr(Varptr(key))[0] = i\n\t\t\t\tRawSet mem, tbl, key,Long Ptr(arraypart)[i]\n\t\t\tNext\n\t\tEndIf\n\t\tIf hashpart\n\t\t\tFor Local i:Int = 0 Until 2 ^ oldtsize\n\t\t\t\tRawSet mem, tbl, Long Ptr(hashpart)[i * 2], Long Ptr(hashpart)[i * 2 + 1]\n\t\t\tNext\n\t\tEndIf\n\tEnd Function\nEnd Type\n\n","old_contents":"\n' Blue Moon\n' Lua-table implementation\n' uses simple linear probing for collision resolution and a shockingly naive reallocator\n\n\nSuperStrict\n\nImport \"blueallocator.bmx\"\n\n\nPrivate\nExtern\n\tFunction frexp:Double(d:Double, Exp:Int Ptr) = \"frexp\"\nEnd Extern\nPublic\n\nType BlueTable Final\n\t' retrieve the slot *for* a key's value, null if no available slot exists (to be used by non-raw index\/set operations)\n\tFunction GetSlot:Long Ptr(tbl:Byte Ptr, key:Long, keyslot:Long Ptr Ptr)\t'keyslot will return the slot for the key if it's not an array-slot\n\t\tLocal tag:Int = Int Ptr(Varptr(key))[1], idx:Int\n\t\tConst NILTAG:Int = BlueTypeTag.NANBOX | BlueTypeTag.NIL\n\t\t\n\t\tIf tag = BlueTypeTag.NANBOX | BlueTypeTag.STR\t'string - common case\n\t\t\tidx = Int Ptr(Int(key))[1]\n\t\tElseIf tag & BlueTypeTag.NANBOX_CHK <> BlueTypeTag.NANBOX\t'number\n\t\t\tLocal d:Double ; Long Ptr(Varptr(d))[0] = key ; idx = Abs Int(d)\n\t\t\tIf d = idx\t'int key\n\t\t\t\tLocal arr:Byte Ptr = Byte Ptr Ptr(tbl)[3]\n\t\t\t\tIf arr And idx < Int Ptr(arr)[-1] Then Return Long Ptr(arr) + idx\t'if this is nil, it won't be in the hash part anyway\n\t\t\tElse\n\t\t\t\td = frexp(d, Varptr(idx)) * ($7fffffff - 1024)\t'INT_MAX - DBL_MAX_EXP\n\t\t\t\tidx = Abs(idx) + Int(d)\n\t\t\tEndIf\n\t\tElseIf tag = NILTAG\t'nil -> nil\n\t\t\tkeyslot[0] = Long Ptr(1) ; Return Null\n\t\tElse\t'pointer (needs improvement)\n\t\t\tidx = Int(key) Shr 3\n\t\tEndIf\n\t\t\n\t\tLocal hashpart:Byte Ptr = Byte Ptr Ptr(tbl)[2]\n\t\tIf hashpart\n\t\t\tLocal hsize:Int = 1 Shl Int Ptr(hashpart)[-1]\n\t\t\tidx = idx & (hsize - 1)\t'apparently this is faster than Mod\n\t\t\tFor Local i:Int = idx Until hsize\t'naive linear probe\n\t\t\t\tLocal kp:Long Ptr = Long Ptr(hashpart) + 2 * i\n\t\t\t\tIf kp[0] = key Or Int Ptr(kp)[1] = NILTAG\n\t\t\t\t\tIf Int Ptr(kp)[1] = NILTAG Then keyslot[0] = kp\n\t\t\t\t\tReturn kp + 1\n\t\t\t\tEndIf\n\t\t\tNext\n\t\t\tFor Local i:Int = 0 Until idx\t'yep\n\t\t\t\tLocal kp:Long Ptr = Long Ptr(hashpart) + 2 * i\n\t\t\t\tIf kp[0] = key Or Int Ptr(kp)[1] = NILTAG\n\t\t\t\t\tIf Int Ptr(kp)[1] = NILTAG Then keyslot[0] = kp\n\t\t\t\t\tReturn kp + 1\n\t\t\t\tEndIf\n\t\t\tNext\n\t\tEndIf\n\t\t\n\t\tReturn Null\n\tEnd Function\n\t\n\t' retrieve a value from a table, or nil\n\tFunction RawGet:Long(tbl:Byte Ptr, key:Long)\n\t\tLocal keyp:Long Ptr = Null, retp:Long Ptr = GetSlot(tbl, key, Varptr(keyp)), ret:Long\n\t\tPrint \" valp: \" + Hex(Int(retp))\n\t\tPrint \" keyp: \" + Hex(Int(keyp))\n\t\tIf retp And (keyp = Null)\n\t\t\tret = retp[0]\n\t\tElse\n\t\t\tInt Ptr(Varptr(ret))[1] = BlueTypeTag.NANBOX | BlueTypeTag.NIL\t'why can't i shift longs?\n\t\tEndIf\n\t\tReturn ret\n\tEnd Function\n\t\n\t' put a value into a table, resizing it if necessary\n\tFunction RawSet(mem:BlueVMMemory, tbl:Byte Ptr, key:Long, val:Long)\n\t\tLocal keyp:Long Ptr = Null, valp:Long Ptr = GetSlot(tbl, key, Varptr(keyp))\n\t\tConst NILTAG:Int = BlueTypeTag.NANBOX | BlueTypeTag.NIL\n\t\tIf valp\n\t\t\tPrint \" valp: \" + Hex(Int(valp))\n\t\t\tPrint \" keyp: \" + Hex(Int(keyp))\n\t\t\tmem.Write(valp, val)\n\t\t\tIf keyp\n\t\t\t\tmem.Write(keyp, key)\n\t\t\t\tLocal hashpart:Int Ptr = Int Ptr Ptr(tbl)[2]\t'need to add element removal\n\t\t\t\thashpart[-2] :+ 1\n\t\t\tEndIf\n\t\tElseIf keyp = Null\n\t\t\tResize(mem, tbl, key) ; RawSet mem, tbl, key, val\n\t\tEndIf\n\tEnd Function\n\t\n\tFunction Resize(mem:BlueVMMemory, tbl:Byte Ptr, key:Long)\n\t\tLocal hashpart:Byte Ptr = Byte Ptr Ptr(tbl)[2], arraypart:Byte Ptr = Byte Ptr Ptr(tbl)[3]\n\t\tConst NILTAG:Int = BlueTypeTag.NANBOX | BlueTypeTag.NIL\n\t\t\n\t\tLocal asize:Int = 0, tsize:Int = 0, numcount:Int[32]\n\t\tIf arraypart\t'compute new array size\n\t\t\tIf Int Ptr(arraypart)[1] <> NILTAG Then numcount[0] = 1\n\t\t\tLocal cell:Int = 1, cellp2:Int = 2 ^ cell\n\t\t\tFor Local i:Int = 1 Until Int Ptr(arraypart)[-1]\n\t\t\t\tIf i >= cellp2 Then cell :+ 1 ; cellp2 = 2 ^ cell\n\t\t\t\tIf Int Ptr(arraypart)[i * 2 + 1] <> NILTAG Then numcount[cell] :+ 1\n\t\t\tNext\n\t\tEndIf\n\t\tIf hashpart\n\t\t\tFor Local i:Int = 0 Until Int Ptr(hashpart)[-2]\n\t\t\t\tLocal tag2:Int = Int Ptr(hashpart)[i * 4 + 1]\n\t\t\t\tIf tag2 & BlueTypeTag.NANBOX_CHK <> BlueTypeTag.NANBOX\n\t\t\t\t\tLocal d:Double = Double Ptr(hashpart)[i * 2]\n\t\t\t\t\tIf d = Abs Int(d) Then numcount[Ceil(Log(d + 1) \/ Log(2))] :+ 1 Else tsize :+ 1\n\t\t\t\tElse\n\t\t\t\t\ttsize :+ 1\t'get started on new table size\n\t\t\t\tEndIf\n\t\t\tNext\n\t\tEndIf\n\t\t\n\t\tLocal tag:Int = Int Ptr(Varptr(key))[1]\t'add key to the appropriate one\n\t\tIf tag & BlueTypeTag.NANBOX_CHK <> BlueTypeTag.NANBOX\n\t\t\tLocal d:Double = Double Ptr(Varptr(key))[0]\n\t\t\tIf d = Abs Int(d) Then numcount[Ceil(Log(d + 1) \/ Log(2))] :+ 1 Else tsize :+ 1\n\t\tElse\n\t\t\ttsize :+ 1\n\t\tEndIf\n\t\tFor Local i:Int = 0 Until 32\t'tally up\n\t\t\tIf i Then numcount[i] :+ numcount[i - 1]\n\t\t\tIf numcount[i] > 2 ^ i \/ 2 Then asize = 2 ^ i\n\t\tNext\n\t\tIf arraypart <> Null\t'complete new table size with any discarded array elements\n\t\t\tFor Local i:Int = asize Until Int Ptr(arraypart)[-1]\n\t\t\t\tIf Int Ptr(arraypart)[i * 2 + 1] <> NILTAG Then tsize :+ 1\n\t\t\tNext\n\t\tEndIf\n\t\t\n\t\tLocal newarray:Byte Ptr = Null, newtable:Byte Ptr = Null\t'allocate and copy\n\t\tLocal oldasize:Int = 0 ; If arraypart Then oldasize = Int Ptr(arraypart)[-1]\n\t\tLocal oldtsize:Int = 0 ; If hashpart Then oldtsize = Int Ptr(hashpart)[-1]\n\t\t\n\t\tIf asize <> oldasize\n\t\t\tnewarray = mem.AllocObject(asize * 8 + 8, BlueTypeTag.ARR) + 8\n\t\t\tFor Local i:Int = 0 Until asize\n\t\t\t\tInt Ptr(newarray)[i * 2 + 1] = NILTAG\n\t\t\tNext\n\t\t\tInt Ptr(newarray)[-1] = asize ; Byte Ptr Ptr(tbl)[3] = newarray\n\t\tElseIf asize = 0\n\t\t\tInt Ptr(tbl)[3] = 0\n\t\tElse\n\t\t\tnewarray = arraypart ; arraypart = Null\n\t\tEndIf\n\t\tIf tsize <> oldtsize\n\t\t\tnewtable = mem.AllocObject(2 ^ tsize * 16 + 8, BlueTypeTag.HASH)\n\t\t\tFor Local i:Int = 0 Until 2 ^ tsize * 2\n\t\t\t\tInt Ptr(newtable)[i * 2 + 1] = NILTAG\n\t\t\tNext\n\t\t\tInt Ptr(newtable)[-1] = tsize ; Int Ptr(newtable)[-2] = 0\n\t\t\tByte Ptr Ptr(tbl)[2] = newtable\n\t\tElseIf tsize = 0\n\t\t\tInt Ptr(tbl)[2] = 0\n\t\tElse\n\t\t\tnewtable = hashpart ; hashpart = Null\n\t\tEndIf\n\t\t\n\t\tIf arraypart\n\t\t\tFor Local i:Int = 0 Until oldasize\t'reinsert values\n\t\t\t\tLocal key:Long ; Double Ptr(Varptr(key))[0] = i\n\t\t\t\tRawSet mem, tbl, key,Long Ptr(arraypart)[i]\n\t\t\tNext\n\t\tEndIf\n\t\tIf hashpart\n\t\t\tFor Local i:Int = 0 Until 2 ^ oldtsize\n\t\t\t\tRawSet mem, tbl, Long Ptr(hashpart)[i * 2], Long Ptr(hashpart)[i * 2 + 1]\n\t\t\tNext\n\t\tEndIf\n\tEnd Function\nEnd Type\n\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"67e1f5fb288c83dadf47ad57211b8f804c102da3","subject":"Added TEntity.TransformPoint.","message":"Added TEntity.TransformPoint.\n","repos":"kfprimm\/maxb3d,kfprimm\/maxb3d","old_file":"core.mod\/entity.bmx","new_file":"core.mod\/entity.bmx","new_contents":"\nStrict\n\nImport BRL.LinkedList\nImport MaxB3D.Math\nImport \"brush.bmx\"\nImport \"collision.bmx\"\nImport \"worldconfig.bmx\"\n\nConst PICKMODE_OFF\t\t\t= 0\nConst PICKMODE_SPHERE\t\t= 1\nConst PICKMODE_POLYGON\t= 2\nConst PICKMODE_BOX\t\t\t= 3\n\nType TEntity\n\tField _config:TWorldConfig\n\tField _matrix:TMatrix=TMatrix.Identity(), _lockmatrix\n\t\n\tField _name$\n\tField _px#,_py#,_pz#\n\tField _rx#,_ry#,_rz#\n\tField _sx#,_sy#,_sz#\n\t\t\n\tField _brush:TBrush=New TBrush\n\t\n\tField _parent:TEntity,_childlist:TList=CreateList()\n\tField _hidden,_order\n\t\n\tField _collision:TCollision[]\n\tField _oldx#,_oldy#,_oldz#\n\tField _radiusx#,_radiusy#\n\tField _boxx#,_boxy#,_boxz#,_boxwidth#,_boxheight#,_boxdepth#\n\tField _type,_typelink:TLink\n\tField _pickmode, _obscurer\n\t\n\tField _cullradius#\n\t\n\tField _alphaorder#\n\t\n\tField _linklist:TList=CreateList()\n\t\n\tMethod Init:TEntity(config:TWorldConfig,parent:TEntity)\n\t\t_config = config\n\t\tSetParent parent,False\n\t\tFor Local l=EachIn Lists()\n\t\t\tAddLink _config.AddObject(Self,l)\n\t\tNext\n\t\t\n\t\tSetScale 1,1,1\n\t\t\n\t\tReturn Self\n\tEnd Method\n\t\n\tMethod Free()\n\t\tFor Local child:TEntity=EachIn _childlist\n\t\t\tchild.Free()\n\t\tNext\n\t\tFor Local link:TLink=EachIn _linklist\n\t\t\tRemoveLink link\n\t\tNext\n\tEnd Method\n\t\n\tMethod AddLink(link:TLink)\n\t\t_linklist.AddLast link\n\tEnd Method\n\t\n\tMethod Lists[]()\n\t\tReturn [WORLDLIST_ENTITY]\n\tEnd Method\n\t\n\tMethod CopyData:TEntity(entity:TEntity)\n\t\t_config = entity._config\n\t\tLocal pickmode, obscurer\n\t\tentity.GetPickMode pickmode,obscurer\n\t\t\n\t\tSetBrush entity.GetBrush()\n\t\tSetName entity.GetName()\n\t\tSetPickMode pickmode, obscurer\n\t\tSetType entity.GetType()\n\t\tReturn Self\n\tEnd Method\n\t\n\tMethod Copy_:TEntity(parent:TEntity=Null)\n\t\tReturn New Self.CopyData(Self).Init(_config,parent)\n\tEnd Method\n\t\n\tMethod Copy:TEntity(parent:TEntity=Null) Abstract\n\t\n\tMethod AddParent(parent:TEntity)\n\t\t_parent=parent\n\t\tIf parent\n\t\t\t_matrix.Overwrite parent._matrix\n\t\t\tparent._childlist.AddLast Self\n\t\tEndIf\n\tEnd Method\n\t\n\tMethod GetParent:TEntity()\n\t\tReturn _parent\n\tEnd Method\n\tMethod SetParent(parent:TEntity,glob=True)\n\t\tLocal gpx#,gpy#,gpz#\t\t\n\t\tLocal grx#,gry#,grz#\t\t\n\t\tLocal gsx#,gsy#,gsz#\n\t\t\n\t\tGetPosition gpx,gpy,gpz,True\n\t\tGetRotation grx,gry,grz,True\n\t\tGetScale gsx,gsy,gsz,True\n\t\t\n\t\tIf _parent\n\t\t\tFor Local entity:TEntity=EachIn _parent._childlist\n\t\t\t\tIf entity=Self ListRemove(_parent._childlist,Self)\n\t\t\tNext\n\t\t\t_parent=Null\n\t\tEndIf\n\n\t\t_px=gpx;_py=gpy;_pz=gpz\n\t\t_rx=grx;_ry=gry;_rz=grz\n\t\t_sx=gsx;_sy=gsy;_sz=gsz\n\t\t\n\t\tIf parent=Null UpdateMatrix(True);Return\t\t\n\t\t\n\t\tAddParent(parent)\n\t\tIf glob\t\t\t\t\n\t\t\tSetPosition(gpx,gpy,gpz,True)\n\t\t\tSetRotation(grx,gry,grz,True)\n\t\t\tSetScale(gsx,gsy,gsz,True)\n\t\tElse\t\t\t\n\t\t\tUpdateMatrix(False)\t\t\t\t\n\t\tEndIf\t\t\t\n\tEnd Method\n\t\n\tMethod CountChildren(recursive=False)\n\t\tLocal count\n\t\tIf recursive\n\t\t\tFor Local child:TEntity=EachIn _childlist\n\t\t\t\tcount:+child.CountChildren(True)\n\t\t\tNext\n\t\tEndIf\n\t\tReturn _childlist.Count()+count\n\tEnd Method\n\t\n\tMethod FindChild:TEntity(name$,recursive=False)\n\t\tFor Local child:TEntity=EachIn _childlist\n\t\t\tIf child.GetName()=name Return child\n\t\tNext\n\t\tIf recursive\n\t\t\tFor Local child:TEntity=EachIn _childlist\n\t\t\t\tLocal entity:TEntity = child.FindChild(name, True)\n\t\t\t\tIf entity Return entity\n\t\t\tNext\n\t\tEndIf\n\tEnd Method\n\t\n\tMethod GetName$()\n\t\tReturn _name\n\tEnd Method\n\tMethod SetName(name$)\n\t\t_name=name\n\tEnd Method\n\t\n\tMethod GetBrush:TBrush()\n\t\tReturn _brush.Copy()\n\tEnd Method\n\tMethod SetBrush(brush:TBrush)\n\t\t_brush.Load brush\n\tEnd Method\n\t\n\tMethod GetColor(red Var,green Var,blue Var)\n\t\tReturn _brush.GetColor(red,green,blue)\n\tEnd Method\n\tMethod SetColor(red,green,blue)\n\t\tReturn _brush.SetColor(red,green,blue)\n\tEnd Method\n\t\n\tMethod GetAlpha#()\n\t\tReturn _brush.GetAlpha()\n\tEnd Method\n\tMethod SetAlpha(alpha#)\n\t\t_brush.SetAlpha(alpha)\n\tEnd Method\n\t\n\tMethod GetShine#()\n\t\tReturn _brush.GetShine()\n\tEnd Method\n\tMethod SetShine(shine#)\n\t\t_brush.SetShine(shine)\n\tEnd Method\n\t\n\tMethod GetTexture:TTexture(index)\n\t\tReturn _brush.GetTexture(index)\n\tEnd Method\n\tMethod SetTexture(texture:TTexture,index=0,frame=0)\n\t\tReturn _brush.SetTexture(texture,index,frame)\n\tEnd Method\n\t\n\tMethod GetFX()\n\t\tReturn _brush.GetFX()\n\tEnd Method\n\tMethod SetFX(fx)\n\t\tReturn _brush.SetFX(fx)\n\tEnd Method\n\t\n\tMethod GetBlend()\n\t\tReturn _brush.GetBlend()\n\tEnd Method\n\tMethod SetBlend(blend)\n\t\tReturn _brush.SetBlend(blend)\n\tEnd Method\n\t\n\tMethod GetShader:TShader()\n\t\tReturn _brush.GetShader()\n\tEnd Method\n\tMethod SetShader(shader:TShader)\n\t\tReturn _brush.SetShader(shader)\n\tEnd Method\n\t\n\tMethod GetScale(x# Var,y# Var,z# Var,glob=False)\n\t\tIf glob\n\t\t\tx=_matrix._m[0,0]\n\t\t\ty=_matrix._m[1,1]\n\t\t\tz=_matrix._m[2,2]\n\t\tElse\n\t\t\tx=_sx;y=_sy;z=_sz\n\t\tEndIf\n\tEnd Method\n\tMethod SetScale(x#,y#,z#,glob=False)\n\t\t_sx=x;_sy=y;_sz=z\n\t\tIf glob=True And _parent<>Null\n\t\t\tLocal entity:TEntity=Self\n\t\t\tRepeat\n\t\t\t\t_sx:\/entity._parent._sx\n\t\t\t\t_sy:\/entity._parent._sy\n\t\t\t\t_sz:\/entity._parent._sz\n\t\t\t\tentity=entity._parent\n\t\t\tUntil entity._parent=Null\n\t\tEndIf\n\t\tRefreshMatrix()\t\n\tEnd Method\n\t\n\tMethod Transform(matrix:TMatrix,glob=False)\n\t\tSetMatrix matrix.Multiply(_matrix),glob\n\tEnd Method\n\t\n\tMethod TransformPoint(x# Var,y# Var,z# Var)\n\t\tReturn _matrix.TransformVec3(x,y,z)\n\tEnd Method\n\t\n\tMethod Turn(pitch#,yaw#,roll#,glob=False)\n\t\t_rx:+pitch;_ry:+yaw;_rz:+roll\n\t\tRefreshMatrix()\n\tEnd Method\n\t\n\tMethod Point(target:Object,roll#=0.0)\n\t\tLocal x#,y#,z#,tx#,ty#,tz#\n\t\tGetPosition x,y,z,True\n\t\tGetTargetPosition target,tx,ty,tz \n\n\t\tLocal xdiff#=x-tx,ydiff#=y-ty,zdiff#=z-tz\n\n\t\tLocal dist22#=Sqr((xdiff*xdiff)+(zdiff*zdiff))\n\t\tLocal pitch#=ATan2(ydiff,dist22)\n\t\tLocal yaw#=ATan2(xdiff,-zdiff)\n\n\t\tSetRotation pitch,yaw,roll,True\n\tEnd Method\n\t\n\tMethod GetDistance#(target:Object)\n\t\tLocal x#,y#,z#,tx#,ty#,tz#\n\t\tGetPosition x,y,z,True\n\t\tGetTargetPosition target,tx,ty,tz\t\t\n\t\tReturn Sqr((x-tx)*(x-tx)+(y-ty)*(y-ty)+(z-tz)*(z-tz))\n\tEnd Method\n\t\n\tFunction GetTargetPosition(target:Object,x# Var,y# Var,z# Var)\n\t\tAssert target,\"Null target given.\"\n\t\tIf TEntity(target) TEntity(target).GetPosition x,y,z,True\n\t\tIf Float[](target)\n\t\t\tLocal coords#[]=Float[](target)\n\t\t\tIf coords.length>0 x=coords[0]\n\t\t\tIf coords.length>1 y=coords[1]\n\t\t\tIf coords.length>2 z=coords[2]\n\t\tEndIf\n\t\tAssert \"Invalid target given.\"\n\tEnd Function\t\n\t\n\tMethod GetRotation(pitch# Var,yaw# Var,roll# Var,glob=False)\n\t\tIf glob\n\t\t\t_matrix.GetRotation pitch,yaw,roll\n\t\t\tpitch:*-1\n\t\t\tyaw:*-1\n\t\tElse\n\t\t\tpitch=_rx;yaw=_ry;roll=_rz\n\t\tEndIf\n\tEnd Method\n\tMethod SetRotation(pitch#,yaw#,roll#,glob=False)\n\t\t_rx=pitch;_ry=yaw;_rz=roll\n\t\tIf glob And _parent<>Null\n\t\t\tLocal rx#,ry#,rz#\n\t\t\t_parent.GetRotation rx,ry,rz\n\t\t\t_rx:+rx;_ry:+ry;_rz:+rz\t\t\t\n\t\tEndIf\n\t\tRefreshMatrix()\n\tEnd Method\n\t\t\n\tMethod GetPosition(x# Var,y# Var,z# Var,glob=False)\n\t\tx=_px;y=_py;z=_pz\n\t\tIf glob _matrix.GetPosition x,y,z\n\tEnd Method\n\tMethod SetPosition(x#,y#,z#,glob=False)\n\t\t_px=x;_py=y;_pz=z\n\t\t\n\t\tIf glob And _parent<>Null\n\t\t\tLocal px#,py#,pz#\n\t\t\t_parent.GetPosition px,py,pz,True\n\t\t\t_px:-px;_py:-py;_pz:-pz\n\t\tEndIf\n\t\t\n\t\tRefreshMatrix()\n\tEnd Method\n\t\n\tMethod Move(x#,y#,z#)\n\t\tLocal matrix:TMatrix=TMatrix.Identity()\n\t\tmatrix=TMatrix.YawPitchRoll(-_ry,-_rx,_rz).Multiply(matrix)\n\t\tmatrix=TMatrix.Translation(x,y,z).Multiply(matrix)\n\t\n\t\tmatrix.GetPosition(x,y,z)\t\t\n\t\t_px:+x;_py:+y;_pz:+z\n\n\t\tRefreshMatrix()\n\tEnd Method\n\t\n\tMethod Translate(x#,y#,z#,glob=True)\n\t\tIf glob And _parent\t\t\t\n\t\t\tLocal ax#,ay#,az#\n\t\t\tGetRotation ax,ay,az,True\n\t\t\t\t\t\t\n\t\t\tLocal matrix:TMatrix=TMatrix.Roll(-az)\n\t\t\tmatrix=matrix.Multiply(TMatrix.Pitch(-ax))\n\t\t\tmatrix=matrix.Multiply(TMatrix.Yaw(-ay))\n\t\t\tmatrix=matrix.Multiply(TMatrix.Translation(x,y,z))\n\t\t\t\n\t\t\tmatrix.GetPosition x,y,z\n\t\tEndIf\n\t\t\n\t\t_px:+x;_py:+y;_pz:+z\n\n\t\tRefreshMatrix()\n\tEnd Method\n\t\n\tMethod GetVisible()\n\t\tLocal entity:TEntity=Self\n\t\tWhile entity<>Null\n\t\t\tIf entity._hidden=True Return False\n\t\t\tentity=entity._parent\n\t\tWend\n\t\tReturn True\n\tEnd Method\n\tMethod SetVisible(visible)\n\t\t_hidden=Not visible\n\tEnd Method\n\t\n\tMethod GetOrder()\n\t\tReturn _order\n\tEnd Method\n\tMethod SetOrder(order)\n\t\t_order=order\n\tEnd Method\n\t\n\tMethod GetCollisions:TCollision[]()\n\t\tReturn _collision\n\tEnd Method\n\t\n\tMethod GetRadius(x# Var,y# Var)\n\t\tx=_radiusx;y=_radiusy\n\tEnd Method\n\tMethod SetRadius(x#,y#=-1)\n\t\t_radiusx=x;_radiusy=x\n\t\tIf y>-1 _radiusy=y\n\tEnd Method\n\t\n\tMethod GetBox(x# Var,y# Var,z# Var,width# Var,height# Var,depth# Var)\n\t\tx=_boxx;y=_boxy;z=_boxz\n\t\twidth=_boxwidth;height=_boxheight;depth=_boxdepth\n\tEnd Method\n\tMethod SetBox(x#,y#,z#,width#,height#,depth#)\n\t\t_boxx=x;_boxy=y;_boxz=z\n\t\t_boxwidth=width;_boxheight=height;_boxdepth=depth\n\tEnd Method\n\t\n\tMethod Reset()\n\t\t_collision=Null\n\t\tGetPosition _oldx,_oldy,_oldz,True\n\tEnd Method\n\t\n\tMethod GetType()\n\t\tReturn _type\n\tEnd Method\n\tMethod SetType(typ,recursive=False)\n\t\tIf _typelink\n\t\t\t_linklist.Remove(_typelink)\n\t\t\t_typelink.Remove()\n\t\t\t_typelink=Null\n\t\tEndIf\n\t\t\n\t\tIf typ>0\n\t\t\tIf _config.CollisionType[typ]=Null _config.CollisionType[typ]=CreateList()\n\t\t\t_typelink=_config.CollisionType[typ].AddLast(Self)\n\t\t\tAddLink _typelink\n\t\tEndIf\t\t\n\t\t\n\t\t_type=typ\n\t\tGetPosition _oldx,_oldy,_oldz,True\n\t\t\n\t\tIf recursive\n\t\t\tFor Local child:TEntity=EachIn _childlist\n\t\t\t\tchild.SetType typ,True\n\t\t\tNext\n\t\tEndIf\n\tEnd Method\n\t\n\tMethod GetCullRadius#()\n\t\tReturn Abs(_cullradius)\n\tEnd Method\n\tMethod SetCullRadius(radius#)\n\t\t_cullradius=-radius\n\tEnd Method\n\n\tMethod GetCullParams(x# Var,y# Var,z# Var,radius# Var)\n\t\tGetPosition x,y,z,True\n\t\tradius=GetCullRadius()\n\tEnd Method\n\t\t\n\tMethod GetPickMode(mode Var, obscurer Var)\n\t\tmode = _pickmode\n\t\tobscurer = _obscurer\n\tEnd Method\t\n\tMethod SetPickMode(mode, obscurer=True)\n\t\t_pickmode = mode\n\t\t_obscurer = obscurer\n\tEnd Method\n\t\n\tMethod HasAlpha()\n\t\tReturn _brush.HasAlpha()\n\tEnd Method\n\t\n\tMethod GetMatrix:TMatrix(alternate=False,copy=True)\n\t\tIf copy Return _matrix.Copy()\n\t\tReturn _matrix\n\tEnd Method\n\tMethod SetMatrix(matrix:TMatrix,glob=True)\n\t\tLocal x#,y#,z#,pitch#,yaw#,roll#,sx#,sy#,sz#\n\t\tmatrix.GetPosition x,y,z\n\t\tmatrix.GetRotation pitch,yaw,roll\n\t\tmatrix.GetScale sx,sy,sz\n\t\t\n\t\tLockMatrix\n\t\tSetPosition x,y,z,glob\n\t\tSetRotation pitch,yaw,roll,glob\n\t\tSetScale sx,sy,sz,glob\n\t\tUnlockMatrix\n\tEnd Method\n\t\n\tMethod LockMatrix()\n\t\t_lockmatrix=True\n\tEnd Method\n\tMethod UnlockMatrix()\n\t\t_lockmatrix=False\n\t\tRefreshMatrix()\n\tEnd Method\n\t\n\tMethod RefreshMatrix()\n\t\tIf _lockmatrix Return\n\t\tIf _parent<>Null\n\t\t\t_matrix.Overwrite _parent._matrix\n\t\t\tUpdateMatrix False\n\t\tElse\n\t\t\tUpdateMatrix True\n\t\tEndIf\t\t\n\t\t\n\t\tFor Local child:TEntity=EachIn _childlist\n\t\t\tchild.RefreshMatrix()\n\t\tNext\n\tEnd Method\n\t\n\tMethod UpdateMatrix(loadidentity)\n\t\tIf loadidentity _matrix=TMatrix.Identity()\n\t\t_matrix=TMatrix.Translation(_px,_py,_pz).Multiply(_matrix)\n\t\t_matrix=TMatrix.YawPitchRoll(-_ry,-_rx,_rz).Multiply(_matrix)\n\t\t_matrix=TMatrix.Scale(_sx,_sy,_sz).Multiply(_matrix)\n\tEnd Method\n\t\n\tMethod ObjectEnumerator:Object()\n\t\tReturn TChildrenEnumerator.Create(_childlist)\n\tEnd Method\nEnd Type\n\nType TChildrenEnumerator\n\tField _children:TEntity[],_index=-1\n\t\n\tFunction Create:TChildrenEnumerator(list:TList)\n\t\tLocal enum:TChildrenEnumerator=New TChildrenEnumerator\n\t\tenum._children=TEntity[](list.ToArray())\n\t\tReturn enum\n\tEnd Function\n\t\n\tMethod HasNext()\n\t\tReturn _index>=_children.length-1\n\tEnd Method\n\t\n\tMethod NextObject:Object()\n\t\t_index:+1\n\t\tReturn _children[_index]\n\tEnd Method\nEnd Type\n","old_contents":"\nStrict\n\nImport BRL.LinkedList\nImport MaxB3D.Math\nImport \"brush.bmx\"\nImport \"collision.bmx\"\nImport \"worldconfig.bmx\"\n\nConst PICKMODE_OFF\t\t\t= 0\nConst PICKMODE_SPHERE\t\t= 1\nConst PICKMODE_POLYGON\t= 2\nConst PICKMODE_BOX\t\t\t= 3\n\nType TEntity\n\tField _config:TWorldConfig\n\tField _matrix:TMatrix=TMatrix.Identity(), _lockmatrix\n\t\n\tField _name$\n\tField _px#,_py#,_pz#\n\tField _rx#,_ry#,_rz#\n\tField _sx#,_sy#,_sz#\n\t\t\n\tField _brush:TBrush=New TBrush\n\t\n\tField _parent:TEntity,_childlist:TList=CreateList()\n\tField _hidden,_order\n\t\n\tField _collision:TCollision[]\n\tField _oldx#,_oldy#,_oldz#\n\tField _radiusx#,_radiusy#\n\tField _boxx#,_boxy#,_boxz#,_boxwidth#,_boxheight#,_boxdepth#\n\tField _type,_typelink:TLink\n\tField _pickmode, _obscurer\n\t\n\tField _cullradius#\n\t\n\tField _alphaorder#\n\t\n\tField _linklist:TList=CreateList()\n\t\n\tMethod Init:TEntity(config:TWorldConfig,parent:TEntity)\n\t\t_config = config\n\t\tSetParent parent,False\n\t\tFor Local l=EachIn Lists()\n\t\t\tAddLink _config.AddObject(Self,l)\n\t\tNext\n\t\t\n\t\tSetScale 1,1,1\n\t\t\n\t\tReturn Self\n\tEnd Method\n\t\n\tMethod Free()\n\t\tFor Local child:TEntity=EachIn _childlist\n\t\t\tchild.Free()\n\t\tNext\n\t\tFor Local link:TLink=EachIn _linklist\n\t\t\tRemoveLink link\n\t\tNext\n\tEnd Method\n\t\n\tMethod AddLink(link:TLink)\n\t\t_linklist.AddLast link\n\tEnd Method\n\t\n\tMethod Lists[]()\n\t\tReturn [WORLDLIST_ENTITY]\n\tEnd Method\n\t\n\tMethod CopyData:TEntity(entity:TEntity)\n\t\t_config = entity._config\n\t\tLocal pickmode, obscurer\n\t\tentity.GetPickMode pickmode,obscurer\n\t\t\n\t\tSetBrush entity.GetBrush()\n\t\tSetName entity.GetName()\n\t\tSetPickMode pickmode, obscurer\n\t\tSetType entity.GetType()\n\t\tReturn Self\n\tEnd Method\n\t\n\tMethod Copy_:TEntity(parent:TEntity=Null)\n\t\tReturn New Self.CopyData(Self).Init(_config,parent)\n\tEnd Method\n\t\n\tMethod Copy:TEntity(parent:TEntity=Null) Abstract\n\t\n\tMethod AddParent(parent:TEntity)\n\t\t_parent=parent\n\t\tIf parent\n\t\t\t_matrix.Overwrite parent._matrix\n\t\t\tparent._childlist.AddLast Self\n\t\tEndIf\n\tEnd Method\n\t\n\tMethod GetParent:TEntity()\n\t\tReturn _parent\n\tEnd Method\n\tMethod SetParent(parent:TEntity,glob=True)\n\t\tLocal gpx#,gpy#,gpz#\t\t\n\t\tLocal grx#,gry#,grz#\t\t\n\t\tLocal gsx#,gsy#,gsz#\n\t\t\n\t\tGetPosition gpx,gpy,gpz,True\n\t\tGetRotation grx,gry,grz,True\n\t\tGetScale gsx,gsy,gsz,True\n\t\t\n\t\tIf _parent\n\t\t\tFor Local entity:TEntity=EachIn _parent._childlist\n\t\t\t\tIf entity=Self ListRemove(_parent._childlist,Self)\n\t\t\tNext\n\t\t\t_parent=Null\n\t\tEndIf\n\n\t\t_px=gpx;_py=gpy;_pz=gpz\n\t\t_rx=grx;_ry=gry;_rz=grz\n\t\t_sx=gsx;_sy=gsy;_sz=gsz\n\t\t\n\t\tIf parent=Null UpdateMatrix(True);Return\t\t\n\t\t\n\t\tAddParent(parent)\n\t\tIf glob\t\t\t\t\n\t\t\tSetPosition(gpx,gpy,gpz,True)\n\t\t\tSetRotation(grx,gry,grz,True)\n\t\t\tSetScale(gsx,gsy,gsz,True)\n\t\tElse\t\t\t\n\t\t\tUpdateMatrix(False)\t\t\t\t\n\t\tEndIf\t\t\t\n\tEnd Method\n\t\n\tMethod CountChildren(recursive=False)\n\t\tLocal count\n\t\tIf recursive\n\t\t\tFor Local child:TEntity=EachIn _childlist\n\t\t\t\tcount:+child.CountChildren(True)\n\t\t\tNext\n\t\tEndIf\n\t\tReturn _childlist.Count()+count\n\tEnd Method\n\t\n\tMethod FindChild:TEntity(name$,recursive=False)\n\t\tFor Local child:TEntity=EachIn _childlist\n\t\t\tIf child.GetName()=name Return child\n\t\tNext\n\t\tIf recursive\n\t\t\tFor Local child:TEntity=EachIn _childlist\n\t\t\t\tLocal entity:TEntity = child.FindChild(name, True)\n\t\t\t\tIf entity Return entity\n\t\t\tNext\n\t\tEndIf\n\tEnd Method\n\t\n\tMethod GetName$()\n\t\tReturn _name\n\tEnd Method\n\tMethod SetName(name$)\n\t\t_name=name\n\tEnd Method\n\t\n\tMethod GetBrush:TBrush()\n\t\tReturn _brush.Copy()\n\tEnd Method\n\tMethod SetBrush(brush:TBrush)\n\t\t_brush.Load brush\n\tEnd Method\n\t\n\tMethod GetColor(red Var,green Var,blue Var)\n\t\tReturn _brush.GetColor(red,green,blue)\n\tEnd Method\n\tMethod SetColor(red,green,blue)\n\t\tReturn _brush.SetColor(red,green,blue)\n\tEnd Method\n\t\n\tMethod GetAlpha#()\n\t\tReturn _brush.GetAlpha()\n\tEnd Method\n\tMethod SetAlpha(alpha#)\n\t\t_brush.SetAlpha(alpha)\n\tEnd Method\n\t\n\tMethod GetShine#()\n\t\tReturn _brush.GetShine()\n\tEnd Method\n\tMethod SetShine(shine#)\n\t\t_brush.SetShine(shine)\n\tEnd Method\n\t\n\tMethod GetTexture:TTexture(index)\n\t\tReturn _brush.GetTexture(index)\n\tEnd Method\n\tMethod SetTexture(texture:TTexture,index=0,frame=0)\n\t\tReturn _brush.SetTexture(texture,index,frame)\n\tEnd Method\n\t\n\tMethod GetFX()\n\t\tReturn _brush.GetFX()\n\tEnd Method\n\tMethod SetFX(fx)\n\t\tReturn _brush.SetFX(fx)\n\tEnd Method\n\t\n\tMethod GetBlend()\n\t\tReturn _brush.GetBlend()\n\tEnd Method\n\tMethod SetBlend(blend)\n\t\tReturn _brush.SetBlend(blend)\n\tEnd Method\n\t\n\tMethod GetShader:TShader()\n\t\tReturn _brush.GetShader()\n\tEnd Method\n\tMethod SetShader(shader:TShader)\n\t\tReturn _brush.SetShader(shader)\n\tEnd Method\n\t\n\tMethod GetScale(x# Var,y# Var,z# Var,glob=False)\n\t\tIf glob\n\t\t\tx=_matrix._m[0,0]\n\t\t\ty=_matrix._m[1,1]\n\t\t\tz=_matrix._m[2,2]\n\t\tElse\n\t\t\tx=_sx;y=_sy;z=_sz\n\t\tEndIf\n\tEnd Method\n\tMethod SetScale(x#,y#,z#,glob=False)\n\t\t_sx=x;_sy=y;_sz=z\n\t\tIf glob=True And _parent<>Null\n\t\t\tLocal entity:TEntity=Self\n\t\t\tRepeat\n\t\t\t\t_sx:\/entity._parent._sx\n\t\t\t\t_sy:\/entity._parent._sy\n\t\t\t\t_sz:\/entity._parent._sz\n\t\t\t\tentity=entity._parent\n\t\t\tUntil entity._parent=Null\n\t\tEndIf\n\t\tRefreshMatrix()\t\n\tEnd Method\n\t\n\tMethod Transform(matrix:TMatrix,glob=False)\n\t\tSetMatrix matrix.Multiply(_matrix),glob\n\tEnd Method\n\t\n\tMethod Turn(pitch#,yaw#,roll#,glob=False)\n\t\t_rx:+pitch;_ry:+yaw;_rz:+roll\n\t\tRefreshMatrix()\n\tEnd Method\n\t\n\tMethod Point(target:Object,roll#=0.0)\n\t\tLocal x#,y#,z#,tx#,ty#,tz#\n\t\tGetPosition x,y,z,True\n\t\tGetTargetPosition target,tx,ty,tz \n\n\t\tLocal xdiff#=x-tx,ydiff#=y-ty,zdiff#=z-tz\n\n\t\tLocal dist22#=Sqr((xdiff*xdiff)+(zdiff*zdiff))\n\t\tLocal pitch#=ATan2(ydiff,dist22)\n\t\tLocal yaw#=ATan2(xdiff,-zdiff)\n\n\t\tSetRotation pitch,yaw,roll,True\n\tEnd Method\n\t\n\tMethod GetDistance#(target:Object)\n\t\tLocal x#,y#,z#,tx#,ty#,tz#\n\t\tGetPosition x,y,z,True\n\t\tGetTargetPosition target,tx,ty,tz\t\t\n\t\tReturn Sqr((x-tx)*(x-tx)+(y-ty)*(y-ty)+(z-tz)*(z-tz))\n\tEnd Method\n\t\n\tFunction GetTargetPosition(target:Object,x# Var,y# Var,z# Var)\n\t\tAssert target,\"Null target given.\"\n\t\tIf TEntity(target) TEntity(target).GetPosition x,y,z,True\n\t\tIf Float[](target)\n\t\t\tLocal coords#[]=Float[](target)\n\t\t\tIf coords.length>0 x=coords[0]\n\t\t\tIf coords.length>1 y=coords[1]\n\t\t\tIf coords.length>2 z=coords[2]\n\t\tEndIf\n\t\tAssert \"Invalid target given.\"\n\tEnd Function\t\n\t\n\tMethod GetRotation(pitch# Var,yaw# Var,roll# Var,glob=False)\n\t\tIf glob\n\t\t\t_matrix.GetRotation pitch,yaw,roll\n\t\t\tpitch:*-1\n\t\t\tyaw:*-1\n\t\tElse\n\t\t\tpitch=_rx;yaw=_ry;roll=_rz\n\t\tEndIf\n\tEnd Method\n\tMethod SetRotation(pitch#,yaw#,roll#,glob=False)\n\t\t_rx=pitch;_ry=yaw;_rz=roll\n\t\tIf glob And _parent<>Null\n\t\t\tLocal rx#,ry#,rz#\n\t\t\t_parent.GetRotation rx,ry,rz\n\t\t\t_rx:+rx;_ry:+ry;_rz:+rz\t\t\t\n\t\tEndIf\n\t\tRefreshMatrix()\n\tEnd Method\n\t\t\n\tMethod GetPosition(x# Var,y# Var,z# Var,glob=False)\n\t\tx=_px;y=_py;z=_pz\n\t\tIf glob _matrix.GetPosition x,y,z\n\tEnd Method\n\tMethod SetPosition(x#,y#,z#,glob=False)\n\t\t_px=x;_py=y;_pz=z\n\t\t\n\t\tIf glob And _parent<>Null\n\t\t\tLocal px#,py#,pz#\n\t\t\t_parent.GetPosition px,py,pz,True\n\t\t\t_px:-px;_py:-py;_pz:-pz\n\t\tEndIf\n\t\t\n\t\tRefreshMatrix()\n\tEnd Method\n\t\n\tMethod Move(x#,y#,z#)\n\t\tLocal matrix:TMatrix=TMatrix.Identity()\n\t\tmatrix=TMatrix.YawPitchRoll(-_ry,-_rx,_rz).Multiply(matrix)\n\t\tmatrix=TMatrix.Translation(x,y,z).Multiply(matrix)\n\t\n\t\tmatrix.GetPosition(x,y,z)\t\t\n\t\t_px:+x;_py:+y;_pz:+z\n\n\t\tRefreshMatrix()\n\tEnd Method\n\t\n\tMethod Translate(x#,y#,z#,glob=True)\n\t\tIf glob And _parent\t\t\t\n\t\t\tLocal ax#,ay#,az#\n\t\t\tGetRotation ax,ay,az,True\n\t\t\t\t\t\t\n\t\t\tLocal matrix:TMatrix=TMatrix.Roll(-az)\n\t\t\tmatrix=matrix.Multiply(TMatrix.Pitch(-ax))\n\t\t\tmatrix=matrix.Multiply(TMatrix.Yaw(-ay))\n\t\t\tmatrix=matrix.Multiply(TMatrix.Translation(x,y,z))\n\t\t\t\n\t\t\tmatrix.GetPosition x,y,z\n\t\tEndIf\n\t\t\n\t\t_px:+x;_py:+y;_pz:+z\n\n\t\tRefreshMatrix()\n\tEnd Method\n\t\n\tMethod GetVisible()\n\t\tLocal entity:TEntity=Self\n\t\tWhile entity<>Null\n\t\t\tIf entity._hidden=True Return False\n\t\t\tentity=entity._parent\n\t\tWend\n\t\tReturn True\n\tEnd Method\n\tMethod SetVisible(visible)\n\t\t_hidden=Not visible\n\tEnd Method\n\t\n\tMethod GetOrder()\n\t\tReturn _order\n\tEnd Method\n\tMethod SetOrder(order)\n\t\t_order=order\n\tEnd Method\n\t\n\tMethod GetCollisions:TCollision[]()\n\t\tReturn _collision\n\tEnd Method\n\t\n\tMethod GetRadius(x# Var,y# Var)\n\t\tx=_radiusx;y=_radiusy\n\tEnd Method\n\tMethod SetRadius(x#,y#=-1)\n\t\t_radiusx=x;_radiusy=x\n\t\tIf y>-1 _radiusy=y\n\tEnd Method\n\t\n\tMethod GetBox(x# Var,y# Var,z# Var,width# Var,height# Var,depth# Var)\n\t\tx=_boxx;y=_boxy;z=_boxz\n\t\twidth=_boxwidth;height=_boxheight;depth=_boxdepth\n\tEnd Method\n\tMethod SetBox(x#,y#,z#,width#,height#,depth#)\n\t\t_boxx=x;_boxy=y;_boxz=z\n\t\t_boxwidth=width;_boxheight=height;_boxdepth=depth\n\tEnd Method\n\t\n\tMethod Reset()\n\t\t_collision=Null\n\t\tGetPosition _oldx,_oldy,_oldz,True\n\tEnd Method\n\t\n\tMethod GetType()\n\t\tReturn _type\n\tEnd Method\n\tMethod SetType(typ,recursive=False)\n\t\tIf _typelink\n\t\t\t_linklist.Remove(_typelink)\n\t\t\t_typelink.Remove()\n\t\t\t_typelink=Null\n\t\tEndIf\n\t\t\n\t\tIf typ>0\n\t\t\tIf _config.CollisionType[typ]=Null _config.CollisionType[typ]=CreateList()\n\t\t\t_typelink=_config.CollisionType[typ].AddLast(Self)\n\t\t\tAddLink _typelink\n\t\tEndIf\t\t\n\t\t\n\t\t_type=typ\n\t\tGetPosition _oldx,_oldy,_oldz,True\n\t\t\n\t\tIf recursive\n\t\t\tFor Local child:TEntity=EachIn _childlist\n\t\t\t\tchild.SetType typ,True\n\t\t\tNext\n\t\tEndIf\n\tEnd Method\n\t\n\tMethod GetCullRadius#()\n\t\tReturn Abs(_cullradius)\n\tEnd Method\n\tMethod SetCullRadius(radius#)\n\t\t_cullradius=-radius\n\tEnd Method\n\n\tMethod GetCullParams(x# Var,y# Var,z# Var,radius# Var)\n\t\tGetPosition x,y,z,True\n\t\tradius=GetCullRadius()\n\tEnd Method\n\t\t\n\tMethod GetPickMode(mode Var, obscurer Var)\n\t\tmode = _pickmode\n\t\tobscurer = _obscurer\n\tEnd Method\t\n\tMethod SetPickMode(mode, obscurer=True)\n\t\t_pickmode = mode\n\t\t_obscurer = obscurer\n\tEnd Method\n\t\n\tMethod HasAlpha()\n\t\tReturn _brush.HasAlpha()\n\tEnd Method\n\t\n\tMethod GetMatrix:TMatrix(alternate=False,copy=True)\n\t\tIf copy Return _matrix.Copy()\n\t\tReturn _matrix\n\tEnd Method\n\tMethod SetMatrix(matrix:TMatrix,glob=True)\n\t\tLocal x#,y#,z#,pitch#,yaw#,roll#,sx#,sy#,sz#\n\t\tmatrix.GetPosition x,y,z\n\t\tmatrix.GetRotation pitch,yaw,roll\n\t\tmatrix.GetScale sx,sy,sz\n\t\t\n\t\tLockMatrix\n\t\tSetPosition x,y,z,glob\n\t\tSetRotation pitch,yaw,roll,glob\n\t\tSetScale sx,sy,sz,glob\n\t\tUnlockMatrix\n\tEnd Method\n\t\n\tMethod LockMatrix()\n\t\t_lockmatrix=True\n\tEnd Method\n\tMethod UnlockMatrix()\n\t\t_lockmatrix=False\n\t\tRefreshMatrix()\n\tEnd Method\n\t\n\tMethod RefreshMatrix()\n\t\tIf _lockmatrix Return\n\t\tIf _parent<>Null\n\t\t\t_matrix.Overwrite _parent._matrix\n\t\t\tUpdateMatrix False\n\t\tElse\n\t\t\tUpdateMatrix True\n\t\tEndIf\t\t\n\t\t\n\t\tFor Local child:TEntity=EachIn _childlist\n\t\t\tchild.RefreshMatrix()\n\t\tNext\n\tEnd Method\n\t\n\tMethod UpdateMatrix(loadidentity)\n\t\tIf loadidentity _matrix=TMatrix.Identity()\n\t\t_matrix=TMatrix.Translation(_px,_py,_pz).Multiply(_matrix)\n\t\t_matrix=TMatrix.YawPitchRoll(-_ry,-_rx,_rz).Multiply(_matrix)\n\t\t_matrix=TMatrix.Scale(_sx,_sy,_sz).Multiply(_matrix)\n\tEnd Method\n\t\n\tMethod ObjectEnumerator:Object()\n\t\tReturn TChildrenEnumerator.Create(_childlist)\n\tEnd Method\nEnd Type\n\nType TChildrenEnumerator\n\tField _children:TEntity[],_index=-1\n\t\n\tFunction Create:TChildrenEnumerator(list:TList)\n\t\tLocal enum:TChildrenEnumerator=New TChildrenEnumerator\n\t\tenum._children=TEntity[](list.ToArray())\n\t\tReturn enum\n\tEnd Function\n\t\n\tMethod HasNext()\n\t\tReturn _index>=_children.length-1\n\tEnd Method\n\t\n\tMethod NextObject:Object()\n\t\t_index:+1\n\t\tReturn _children[_index]\n\tEnd Method\nEnd Type\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"9d456dc279fd1ed7a218aecf864c925c4ab59f67","subject":"Added some B3D-style functions.","message":"Added some B3D-style functions.\n","repos":"kfprimm\/maxb3d,kfprimm\/maxb3d","old_file":"retro.mod\/retro.bmx","new_file":"retro.mod\/retro.bmx","new_contents":"\nStrict\n\nRem\n\tbbdoc: Blitz3D style wrapper for MaxB3D\nEnd Rem\nModule MaxB3D.Retro\nModuleInfo \"Author: Kevin Primm\"\nModuleInfo \"License: MIT\"\n\nImport MaxB3D.GLDriver\nImport MaxB3D.D3D9Driver\nImport MaxB3D.Primitives\n\nImport MaxB3D.B3DCollision\n\nImport MaxB3D.A3DSLoader\nImport MaxB3D.B3DLoader\nImport MaxB3D.MD2Loader\n\nPrivate\nGlobal _renderinfo:TRenderInfo = New TRenderInfo\n\nPublic\n\nFunction Graphics3D(width, height, depth = 32, mode = 0)\n\tSelect mode\n\tCase 0\n?Debug\n\t\tdepth = 0 \n?Not Debug\n\t\tdepth = 32\n?\n\tCase 1\n\t\tdepth = 32\n\tCase 2\n\t\tdepth = 0\n\tEnd select\n\tGraphics width,height,depth\nEnd Function\nRem\n# Dither\n# WBuffer\n# AntiAlias\nEnd Rem\nFunction Wireframe(enable)\n\t_currentworld.SetWireFrame enable\nEnd Function\n'# HWMultiTex\nFunction AmbientLight(red, green, blue)\n\t_currentworld.SetAmbientLight red, green, blue\nEnd Function\nRem\n# ClearCollisions\n# Collisions\nEnd Rem\nFunction UpdateWorld(speed#)\n\t_currentworld.Update(speed, speed)\nEnd Function\nFunction RenderWorld(tween#)\n\t_renderinfo = _currentworld.Render(tween)\nEnd Function\nRem\n# CaptureWorld\n# ClearWorld\n# LoaderMatrix\n# TrisRendered\nEnd Rem\nFunction TrisRendered()\n\treturn _renderinfo.triangles\nEnd Function\n\nRem\n# CreateTexture\n# LoadTexture\n# LoadAnimTexture\n# FreeTexture\n# TextureBlend\n# TextureCoords\n# ScaleTexture\n# PositionTexture\n# RotateTexture\n# TextureWidth\n# TextureHeight\n# TextureBuffer\n# TextureName\n# GetBrushTexture\n# ClearTextureFilters\n# TextureFilter\n# SetCubeFace\n# SetCubeMode\n\n# CreateBrush\n# LoadBrush\n# FreeBrush\n# BrushColor\n# BrushAlpha\n# BrushShininess\n# BrushTexture\n# BrushBlend\n# BrushFX\n# GetEntityBrush\n# GetSurfaceBrush\n\n# CreateMesh\n# LoadMesh\n# LoadAnimMesh\n# CreateCube\n# CreateSphere\n# CreateCylinder\n# CreateCone\n# CopyMesh\n# AddMesh\n# FlipMesh\n# PaintMesh\n# LightMesh\n# FitMesh\n# ScaleMesh\n# RotateMesh\n# PositionMesh\n# UpdateNormals\n# MeshesIntersect\n# MeshWidth\n# MeshHeight\n# MeshDepth\n# CountSurfaces\n# GetSurface\n\n# CreateSurface\n# PaintSurface\n# ClearSurface\n# FindSurface\n# AddVertex\n# AddTriangle\n# VertexCoords\n# VertexNormal\n# VertexColor\n# VertexTexCoords\n# CountVertices\n# CountTriangles\n# VertexX\n# VertexY\n# VertexZ\n# VertexNX\n# VertexNY\n# VertexNZ\n# VertexRed\n# VertexGreen\n# VertexBlue\n# VertexAlpha\n# VertexU\n# VertexV\n# VertexW\n# TriangleVertex\n\n# CreateCamera\n# CameraProjMode\n# CameraFogMode\n# CameraFogRange\n# CameraFogColor\n# CameraViewport\n# CameraClsMode\n# CameraClsColor\n# CameraRange\n# CameraZoom\n# CameraPick\n# PickedX\n# PickedY\n# PickedZ\n# PickedNX\n# PickedNY\n# PickedNZ\n# PickedTime\n# PickedEntity\n# PickedSurface\n# PickedTriangle\n# CameraProject\n# ProjectedX\n# ProjectedY\n# ProjectedZ\n# EntityInView\n\n# CreateLight\n# LightRange\n# LightColor\n# LightConeAngles\n\n# CreatePivot\n\n# CreateSprite\n# LoadSprite\n# RotateSprite\n# ScaleSprite\n# HandleSprite\n# SpriteViewMode\n\n# LoadMD2\n# AnimateMD2\n# MD2AnimTime\n# MD2AnimLength\n# MD2Animating\n\n# LoadBSP\n# BSPAmbientLight\n# BSPLighting\n\n# CreatePlane\n\n# CreateMirror\n\n# CreateTerrain\n# LoadTerrain\n# TerrainSize\n# TerrainDetail\n# TerrainShading\n# TerrainHeight\n# ModifyTerrain\n# TerrainX\n# TerrainY\n# TerrainZ\n\n# CreateListener\n# Load3DSound\n# EmitSound\n\n# ScaleEntity\n# PositionEntity\n# MoveEntity\n# TranslateEntity\n# RotateEntity\n# TurnEntity\n# PointEntity\n# AlignToVector\n\n# LoadAnimSeq\n# SetAnimKey\n# AddAnimSeq\n# ExtractAnimSeq\n# Animate\n# SetAnimTime\n# AnimSeq\n# AnimLength\n# AnimTime\n# Animating\nEnd Rem\n\nFunction FreeEntity(entity:TEntity)\n\tReturn entity.Free()\nEnd Function\nFunction CopyEntity:TEntity(entity:TEntity, parent:TEntity = Null)\n\tReturn entity.Copy(parent)\nEnd Function\nFunction EntityColor(entity:TEntity, red, green, blue)\n\tReturn entity.SetColor(red, green, blue)\nEnd Function\nFunction EntityAlpha(entity:TEntity, alpha#)\n\tReturn entity.SetAlpha(alpha)\nEnd Function\nFunction EntityShininess(entity:TEntity, shine#)\n\tReturn entity.SetShine(shine)\nEnd Function\nFunction EntityTexture(entity:TEntity, texture:TTexture, frame = 0, index = 0)\n\tReturn entity.SetTexture(texture, frame, index)\nEnd Function\nFunction EntityBlend(entity:TEntity, blend)\n\tReturn entity.SetBlend(blend)\nEnd Function\nFunction EntityFX(entity:TEntity, fx)\n\tReturn entity.SetFX(fx)\nEnd Function\n'# EntityAutoFade\nFunction PaintEntity(entity:TEntity, brush:TBrush)\n\tReturn entity.SetBrush(brush)\nEnd Function\nFunction EntityOrder(entity:TEntity, order)\n\tReturn entity.SetOrder(order)\nEnd Function\nFunction HideEntity(entity:TEntity)\n\tReturn entity.SetVisible(False)\nEnd Function\nFunction ShowEntity(entity:TEntity)\n\tReturn entity.SetVisible(True)\nEnd Function\nFunction NameEntity(entity:TEntity, name$)\n\tReturn entity.SetName(name)\nEnd Function\nFunction EntityParent(entity:TEntity, parent:TEntity, glob = True)\n\tReturn entity.SetParent(parent, glob)\nEnd Function\nFunction GetParent:TEntity(entity:TEntity)\n\tReturn entity.GetParent()\nEnd Function\n\nFunction EntityX#(entity:TEntity, glob = False)\n\tLocal x#,y#,z#\n\tentity.GetPosition x,y,z,glob\n\tReturn x\nEnd Function\nFunction EntityY#(entity:TEntity, glob = False)\n\tLocal x#,y#,z#\n\tentity.GetPosition x,y,z,glob\n\tReturn y\nEnd Function\nFunction EntityZ#(entity:TEntity, glob = False)\n\tLocal x#,y#,z#\n\tentity.GetPosition x,y,z,glob\n\tReturn z\nEnd Function\nRem\n# EntityRoll\n# EntityYaw\n# EntityPitch\n# EntityClass\n# EntityName\n# CountChildren\n# GetChild\n# FindChild\n# EntityPick\n# LinePick\n# EntityVisible\n# EntityDistance\n# DeltaYaw\n# DeltaPitch\n# TFormPoint\n# TFormVector\n# TFormNormal\n# TFormedX\n# TFormedY\n# TFormedZ\n# GetMatElement\n\n# ResetEntity\n# EntityRadius\n# EntityBox\n# EntityType\n# EntityPickMode\n# EntityCollided\n# CountCollisions\n# CollisionX\n# CollisionY\n# CollisionZ\n# CollisionNX\n# CollisionNY\n# CollisionNZ\n# CollisionTime\n# CollisionEntity\n# CollisionSurface\n# CollisionTriangle\nEnd Rem\nFunction GetEntityType(entity:TEntity)\n\tReturn entity.GetType()\nEnd Function\n\nRem\n# VectorYaw\n# VectorPitch\n\n# CountGfxModes3D\n# GfxMode3D\n# GfxMode3DExists\n# GfxDriver3D\n# GfxDriverCaps3D\n# Windowed3D\n# HWTexUnits\nEnd Rem\n","old_contents":"\nStrict\n\nRem\n\tbbdoc: Blitz3D style wrapper for MaxB3D\nEnd Rem\nModule MaxB3D.Retro\nModuleInfo \"Author: Kevin Primm\"\nModuleInfo \"License: MIT\"\n\nImport MaxB3D.GLDriver\nImport MaxB3D.D3D9Driver\nImport MaxB3D.Primitives\n\nImport MaxB3D.B3DCollision\n\nImport MaxB3D.A3DSLoader\nImport MaxB3D.B3DLoader\nImport MaxB3D.MD2Loader\n\nRem\n# Graphics3D\n# Dither\n# WBuffer\n# AntiAlias\n# Wireframe\n# HWMultiTex\n# AmbientLight\n# ClearCollisions\n# Collisions\n# UpdateWorld\n# CaptureWorld\n# RenderWorld\n# ClearWorld\n# LoaderMatrix\n# TrisRendered\n\n# CreateTexture\n# LoadTexture\n# LoadAnimTexture\n# FreeTexture\n# TextureBlend\n# TextureCoords\n# ScaleTexture\n# PositionTexture\n# RotateTexture\n# TextureWidth\n# TextureHeight\n# TextureBuffer\n# TextureName\n# GetBrushTexture\n# ClearTextureFilters\n# TextureFilter\n# SetCubeFace\n# SetCubeMode\n\n# CreateBrush\n# LoadBrush\n# FreeBrush\n# BrushColor\n# BrushAlpha\n# BrushShininess\n# BrushTexture\n# BrushBlend\n# BrushFX\n# GetEntityBrush\n# GetSurfaceBrush\n\n# CreateMesh\n# LoadMesh\n# LoadAnimMesh\n# CreateCube\n# CreateSphere\n# CreateCylinder\n# CreateCone\n# CopyMesh\n# AddMesh\n# FlipMesh\n# PaintMesh\n# LightMesh\n# FitMesh\n# ScaleMesh\n# RotateMesh\n# PositionMesh\n# UpdateNormals\n# MeshesIntersect\n# MeshWidth\n# MeshHeight\n# MeshDepth\n# CountSurfaces\n# GetSurface\n\n# CreateSurface\n# PaintSurface\n# ClearSurface\n# FindSurface\n# AddVertex\n# AddTriangle\n# VertexCoords\n# VertexNormal\n# VertexColor\n# VertexTexCoords\n# CountVertices\n# CountTriangles\n# VertexX\n# VertexY\n# VertexZ\n# VertexNX\n# VertexNY\n# VertexNZ\n# VertexRed\n# VertexGreen\n# VertexBlue\n# VertexAlpha\n# VertexU\n# VertexV\n# VertexW\n# TriangleVertex\n\n# CreateCamera\n# CameraProjMode\n# CameraFogMode\n# CameraFogRange\n# CameraFogColor\n# CameraViewport\n# CameraClsMode\n# CameraClsColor\n# CameraRange\n# CameraZoom\n# CameraPick\n# PickedX\n# PickedY\n# PickedZ\n# PickedNX\n# PickedNY\n# PickedNZ\n# PickedTime\n# PickedEntity\n# PickedSurface\n# PickedTriangle\n# CameraProject\n# ProjectedX\n# ProjectedY\n# ProjectedZ\n# EntityInView\n\n# CreateLight\n# LightRange\n# LightColor\n# LightConeAngles\n\n# CreatePivot\n\n# CreateSprite\n# LoadSprite\n# RotateSprite\n# ScaleSprite\n# HandleSprite\n# SpriteViewMode\n\n# LoadMD2\n# AnimateMD2\n# MD2AnimTime\n# MD2AnimLength\n# MD2Animating\n\n# LoadBSP\n# BSPAmbientLight\n# BSPLighting\n\n# CreatePlane\n\n# CreateMirror\n\n# CreateTerrain\n# LoadTerrain\n# TerrainSize\n# TerrainDetail\n# TerrainShading\n# TerrainHeight\n# ModifyTerrain\n# TerrainX\n# TerrainY\n# TerrainZ\n\n# CreateListener\n# Load3DSound\n# EmitSound\n\n# ScaleEntity\n# PositionEntity\n# MoveEntity\n# TranslateEntity\n# RotateEntity\n# TurnEntity\n# PointEntity\n# AlignToVector\n\n# LoadAnimSeq\n# SetAnimKey\n# AddAnimSeq\n# ExtractAnimSeq\n# Animate\n# SetAnimTime\n# AnimSeq\n# AnimLength\n# AnimTime\n# Animating\n\n# FreeEntity\n# CopyEntity\n# EntityColor\n# EntityAlpha\n# EntityShininess\n# EntityTexture\n# EntityBlend\n# EntityFX\n# EntityAutoFade\n# PaintEntity\n# EntityOrder\n# ShowEntity\n# HideEntity\n# NameEntity\n# EntityParent\n# GetParent\n\n# EntityX\n# EntityY\n# EntityZ\n# EntityRoll\n# EntityYaw\n# EntityPitch\n# EntityClass\n# EntityName\n# CountChildren\n# GetChild\n# FindChild\n# EntityPick\n# LinePick\n# EntityVisible\n# EntityDistance\n# DeltaYaw\n# DeltaPitch\n# TFormPoint\n# TFormVector\n# TFormNormal\n# TFormedX\n# TFormedY\n# TFormedZ\n# GetMatElement\n\n# ResetEntity\n# EntityRadius\n# EntityBox\n# EntityType\n# EntityPickMode\n# EntityCollided\n# CountCollisions\n# CollisionX\n# CollisionY\n# CollisionZ\n# CollisionNX\n# CollisionNY\n# CollisionNZ\n# CollisionTime\n# CollisionEntity\n# CollisionSurface\n# CollisionTriangle\n# GetEntityType\n\n# VectorYaw\n# VectorPitch\n\n# CountGfxModes3D\n# GfxMode3D\n# GfxMode3DExists\n# GfxDriver3D\n# GfxDriverCaps3D\n# Windowed3D\n# HWTexUnits\nEnd Rem","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"b2e785b72f8c2f29f46a15ec87e400c2c723e05a","subject":"corrected comparison logic","message":"corrected comparison logic\n","repos":"Leushenko\/blue-moon","old_file":"bluefoldcodegen.bmx","new_file":"bluefoldcodegen.bmx","new_contents":"\n' Blue Moon\n' FOLD delegate to generate assembly instructions\n\n' this file is a Private Include\n\n'SuperStrict\n\n\nType CompileFold\n\tField opc:BlueOpcode = New BlueOpcode, bi:BlueInstr = New BlueInstr, f:BlueAssembly, _gq:TList = CreateList()\n\t\n\tFunction Make:CompileFold(f:BlueAssembly)\n\t\tLocal c:CompileFold = New Self ; c.f = f ; Return c\n\tEnd Function\n\t\n\tMethod l_varref:Node(n:Leaf)\n\t\tLocal v:VarDef = f.fd.vars[StrToNum(n.val)], op:Int\n\t\tIf v.isClosure Then op = opc.SETLC Else op = opc.MOV\n\t\tReturn BytecodeNode.MakeL(n.key, bi.Make(op, v.stkpos, f.Pop()), n)\n\tEnd Method\n\tMethod l_closref:Node(n:Leaf)\n\t\tLocal ref:Int = StrToNum(n.val)\n\t\tReturn BytecodeNode.MakeL(n.key, bi.Make(opc.SETUPV, ref, f.Pop()))\n\tEnd Method\n\tMethod l_getfield:Node(n:Rose)\n\t\tLocal r:BytecodeNode = BytecodeNode.Join(n.key, [n.arg[0]])\n\t\tLocal k:Int = f.GetConst(\"1\", Leaf(n.arg[1]).val), tab:Int = f.Pop()\n\t\tr.inst.AddLast bi.Make(opc.SETTAB, tab, f.Pop(), k)\n\t\tReturn r\n\tEnd Method\n\tMethod l_index:Node(n:Rose)\n\t\tLocal r:BytecodeNode = BytecodeNode.Join(n.key, n.arg)\n\t\tLocal ind:Int = f.Pop(), tab:Int = f.Pop(), val:Int = f.Pop()\n\t\tLocal pv:BlueInstr = BlueInstr(r.inst.Last())\n\t\tIf pv.op = opc.LOADSI And Abs(pv.c) < f.VSI_LIMIT And pv.c = Abs pv.c\n\t\t\tpv.op = opc.SETTABSI ; pv.ra = tab ; pv.rb = val\n\t\tElse\n\t\t\tr.inst.AddLast bi.Make(opc.SETTABI, tab, val, ind)\n\t\tEndIf\n\t\tReturn r\n\tEnd Method\n\tMethod l_discard:Node(n:Node)\n\t\tf.Pop() ; Return BytecodeNode.Nil()\n\tEnd Method\n\t\n\tMethod LocalVar:Node(n:Rose)\n\t\tLocal vars:Node[] = Rose(BytecodeNode(n.arg[1]).old).arg\n\t\tLocal r:BytecodeNode = BytecodeNode.Join(n.key, n.arg)\n\t\tFor Local vi:Int = vars.Length - 1 To 0 Step -1\n\t\t\tLocal v:VarDef = f.fd.vars[StrToNum(Leaf(BytecodeNode(vars[vi]).old).val)]\n\t\t\tIf v.isClosure Then r.inst.AddFirst bi.Make(opc.NEWUPV, v.stkpos, 0)\n\t\tNext\n\t\tReturn r\n\tEnd Method\n\t\n\tMethod ReturnS:Node(n:Rose)\n\t\tLocal r:BytecodeNode = BytecodeNode.Join(n.key, n.arg)\n\t\tr.inst.AddLast(bi.MakeK(opc.RET, f.Peek(), n.arg.Length))\n\t\tf.Pop(n.arg.Length) ; Return r\n\tEnd Method\n\tMethod return_va:Node(n:Node)\n\t\tReturn BytecodeNode.MakeL(n.key, bi.Make(opc.RETVA, 0, 0))\n\tEnd Method\n\t\n\tMethod break:Node(n:Node)\n\t\tReturn BytecodeNode.MakeL(n.key, bi.Make(opc.JMP, -1, -1, -1))\n\tEnd Method\n\tMethod RepeatS:Node(n:Rose)\n\t\tLocal r:BytecodeNode = BytecodeNode.Join(n.key, n.arg), _lt:TList = f.fd._lt, _gt:TList = f.fd._gt\n\t\tLocal loopStart:LabelDef = New LabelDef, lsID:Int = _lt.Count(), loop:GotoDef = New GotoDef, lID:Int = _gt.Count()\n\t\tloop.tgt = loopStart ; _lt.AddLast loopStart ; _gt.AddLast loop\n\t\tLocal lastop:BlueInstr = BlueInstr(r.inst.Last()), reg:Int = f.Pop()\n\t\tIf lastop.op = opc.LNOT\n\t\t\tlastop.op = opc.JIF ; lastop.ra = lastop.rb ; lastop.rb = 0 ; lastop.c = lID\t'replace NOT with inverted jump\n\t\tElse\n\t\t\tr.inst.AddLast bi.MakeK(opc.JNOT, reg, lID)\n\t\tEndIf\n\t\tr.inst.AddFirst bi.Make(opc.MOV, 0, 0, lsID)\n\t\tr.inst.AddLast bi.Make(opc.MOV, -1, -1, -1)\n\t\tReturn r\n\tEnd Method\n\tMethod IfS:Node(n:Rose) { WhileS }\n\t\tLocal r:BytecodeNode = BytecodeNode.Join(n.key, [n.arg[0]]), lastop:BlueInstr = BlueInstr(r.inst.Last())\n\t\tLocal before:LabelDef, befID:Int, loopRound:GotoDef, loopID:Int, _lt:TList = f.fd._lt, _gt:TList = f.fd._gt\n\t\tIf n.key = \"WhileS\"\n\t\t\tbefore = New LabelDef ; befID = _lt.Count() ; _lt.AddLast before\n\t\t\tloopRound = New GotoDef ;loopRound.tgt = before ; loopID = _gt.Count() ; _gt.AddLast loopRound\n\t\t\tr.inst.AddFirst bi.Make(opc.MOV, 0, 0, befID)\n\t\tEndIf\n\t\tLocal postThen:LabelDef = New LabelDef, skipThen:GotoDef = New GotoDef, ptID:Int = _lt.Count(), stID:Int = _gt.Count()\n\t\t_lt.AddLast postThen ; skipThen.tgt = postThen ; _gt.AddLast skipThen\n\t\tIf lastop.op = opc.LNOT\n\t\t\tlastop.op = opc.JIF ; lastop.ra = lastop.rb ; lastop.rb = 0 ; lastop.c = stID\t'replace NOT with inverted jump\n\t\tElse\n\t\t\tr.inst.AddLast bi.MakeK(opc.JNOT, f.Peek(), stID)\n\t\tEndIf\n\t\tf.Pop()\n\t\tFor Local op:BlueInstr = EachIn BytecodeNode(n.arg[1]).inst\n\t\t\tr.inst.AddLast op\n\t\tNext\n\t\tLocal postElse:LabelDef, skipElse:GotoDef\n\t\tIf n.arg.Length > 2\t'there's an else\n\t\t\tpostElse = New LabelDef ; skipElse = New GotoDef ; skipElse.tgt = postElse\n\t\t\tLocal peID:Int = _lt.Count(), seID:Int = _gt.Count()\n\t\t\t_lt.AddLast postElse ; _gt.AddLast skipElse\n\t\t\tr.inst.AddLast bi.MakeK(opc.JMP, 0, seID)\n\t\t\tr.inst.AddLast bi.Make(opc.MOV, 0, 0, ptID)\n\t\t\tFor Local op:BlueInstr = EachIn BytecodeNode(n.arg[2]).inst\n\t\t\t\tr.inst.AddLast op\n\t\t\tNext\n\t\t\tr.inst.AddLast bi.Make(opc.MOV, 0, 0, peID)\n\t\tElse\n\t\t\tIf n.key = \"WhileS\" Then r.inst.AddLast bi.MakeK(opc.JMP, 0, loopID) ; r.inst.AddLast bi.Make(opc.MOV, -1, -1, -1)\n\t\t\tr.inst.AddLast bi.Make(opc.MOV, 0, 0, ptID)\n\t\tEndIf\n\t\tReturn r\n\tEnd Method\n\tMethod kand:Node(n:Rose) { kor }\n\t\tLocal r:BytecodeNode = BytecodeNode.Join(n.key, [n.arg[0]]), lastop:BlueInstr = BlueInstr(r.inst.Last())\n\t\tLocal _lt:TList = f.fd._lt, _gt:TList = f.fd._gt\n\t\tLocal postR:LabelDef = New LabelDef, skipR:GotoDef = New GotoDef, prID:Int = _lt.Count(), srID:Int = _gt.Count()\n\t\t_lt.AddLast postR ; skipR.tgt = postR ; _gt.AddLast skipR\n\t\tLocal reg:Int = f.Pop()\n\t\tIf lastop.op = opc.LNOT\n\t\t\tLocal op:Int = opc.JIF ; If n.key = \"kor\" Then op = opc.JNOT\n\t\t\tlastop.op = op ; lastop.ra = lastop.rb ; lastop.rb = 0 ; lastop.c = srID\t'replace NOT with inverted jump\n\t\tElse\n\t\t\tLocal op:Int = opc.JNOT ; If n.key = \"kor\" Then op = opc.JIF\n\t\t\tr.inst.AddLast bi.MakeK(op, reg - 1, srID)\n\t\tEndIf\n\t\tFor Local op:BlueInstr = EachIn BytecodeNode(n.arg[1]).inst\n\t\t\tr.inst.AddLast op\n\t\tNext\n\t\tr.inst.AddLast bi.Make(opc.MOV, reg - 1, reg)\n\t\tr.inst.AddLast bi.Make(opc.MOV, 0, 0, prID)\n\t\tReturn r\n\tEnd Method\n\t\n\tMethod fcall:Node(n:Rose) { pfcall tfcall va_fcall }\t'\"p\" prefix = \"procedure\" i.e. no return value required\n\t\tLocal r:BytecodeNode = BytecodeNode.Join(n.key, n.arg), argc:Int = Int(Leaf(n.arg[3]).val), retc:Int = Int(Leaf(n.arg[2]).val)\n\t\tLocal func:Int = f.Pop(argc + 1), args:Int = func + 1, op:Int = opc.CALL\n\t\tIf n.key = \"tfcall\" Then op = opc.TCALL\n\t\tr.inst.AddLast bi.Make(op, func, args, argc)\n\t\tIf n.key = \"fcall\"\n\t\t\tr.inst.AddLast bi.MakeK(opc.POSTCALL, f.Peek() + 1, retc) ; f.Push(retc)\n\t\tElseIf n.key = \"va_fcall\"\n\t\t\tr.inst.AddLast bi.Make(opc.CALLINIT, -1, 0)\n\t\tEndIf\n\t\tReturn r\n\tEnd Method\n\tMethod mcall:Node(n:Rose) { pmcall tmcall va_mcall }\n\t\tLocal r:BytecodeNode = BytecodeNode.Join(n.key, n.arg), argc:Int = Int(Leaf(n.arg[3]).val), retc:Int = Int(Leaf(n.arg[2]).val)\n\t\tLocal func:Int = f.Push(), argv:Int = f.Pop(argc + 2), op:Int = opc.CALL\n\t\tLocal ks:String = Leaf(Rose(BytecodeNode(n.arg[1]).old).arg[0]).val\t\t'yeesh\n\t\tr.inst.AddLast bi.Make(opc.GETTAB, func, argv, f.GetConst(\"1\", ks))\n\t\tIf n.key = \"tmcall\" Then op = opc.TCALL\n\t\tr.inst.AddLast bi.Make(op, func, argv, argc + 1)\n\t\tIf n.key = \"mcall\"\n\t\t\tr.inst.AddLast bi.MakeK(opc.POSTCALL, argv, retc) ; f.Push(retc)\n\t\tElseIf n.key = \"va_fcall\"\n\t\t\tr.inst.AddLast bi.Make(opc.CALLINIT, -1, 0)\n\t\tEndIf\n\t\tReturn r\n\tEnd Method\n\tMethod dotdotdot:Node(n:Leaf)\n\t\tLocal retc:Int = Int(n.val), r:BytecodeNode\n\t\tr = BytecodeNode.MakeL(n.key, bi.MakeK(opc.VARARG, f.Peek() + 1, retc))\n\t\tf.Push(retc)\n\t\tReturn r\n\tEnd Method\n\t\n\tMethod BinaryOp:Node(n:Rose) { plus minus mul div kmod pow dotdot lt gt leq geq eq neq }\n\t\tLocal r:BytecodeNode = BytecodeNode.Join(n.key, n.arg), op:Int\n\t\tSelect n.key\n\t\t\tCase \"plus\" ; op = opc.ADD\n\t\t\tCase \"minus\" ; op = opc.SUB\n\t\t\tCase \"mul\" ; op = opc.MUL\n\t\t\tCase \"div\" ; op = opc.DIV\n\t\t\tCase \"kmod\" ; op = opc.NMOD\n\t\t\tCase \"pow\" ; op = opc.POW\n\t\t\tCase \"dotdot\" ; op = opc.CAT\n\t\t\t\n\t\t\tCase \"lt\" ; op = opc.LT\n\t\t\tCase \"gt\" ; op = opc.LT\n\t\t\tCase \"leq\" ; op = opc.LEQ\n\t\t\tCase \"geq\" ; op = opc.LEQ\n\t\t\tCase \"eq\" ; op = opc.EQ\n\t\t\tCase \"neq\" ; op = opc.EQ\n\t\tEnd Select\n\t\tLocal lop:Int = f.Pop(), rop:Int = f.Pop()\n\t\tIf n.key = \"geq\" Or n.key = \"gt\"\n\t\t\tr.inst.AddLast bi.Make(op, f.Push(), rop, lop)\t'technically this violates IEEE-754, but it's how Lua defines it\n\t\tElse\n\t\t\tr.inst.AddLast bi.Make(op, f.Push(), lop, rop)\n\t\t\tIf n.key = \"neq\" Then r.inst.AddLast bi.Make(opc.LNOT, f.Peek(), f.Peek())\n\t\tEndIf\n\t\tReturn r\n\tEnd Method\n\tMethod UnaryOp:Node(n:Rose) { negate klen knot }\n\t\tLocal r:BytecodeNode = BytecodeNode.Join(n.key, n.arg), op:Int\n\t\tSelect n.key\n\t\t\tCase \"negate\" ; op = opc.UNM\n\t\t\tCase \"klen\" ; op = opc.ALEN\n\t\t\tCase \"knot\" ; op = opc.LNOT\n\t\t\tCase \"posate\" ; op = opc.UNP\n\t\tEnd Select\n\t\tLocal arg:Int = f.Pop()\n\t\tr.inst.AddLast bi.Make(op, f.Push(), arg)\n\t\tReturn r\n\tEnd Method\n\t\n\tMethod dconst:Node(n:Leaf) { sconst }\n\t\tLocal ki:Int = Int(n.val), op:Int = opc.LOADK\n\t\tIf n.key = \"dconst\" And Abs(ki) < BlueAssembly.SI_LIMIT And Double(n.val) = Double(ki)\n\t\t\top = opc.LOADSI\n\t\tElse\n\t\t\tki = f.GetConst(String(n.key = \"sconst\"), n.val)\n\t\tEndIf\n\t\tReturn BytecodeNode.MakeL(n.key, bi.MakeK(op, f.Push(), ki))\n\tEnd Method\n\tMethod bconst:Node(n:Leaf) { nil }\n\t\tLocal ins:BlueInstr\n\t\tSelect n.val\n\t\t\tCase \"true\" ; ins = bi.MakeK(opc.LOADBOOL, f.Push(), 1)\n\t\t\tCase \"false\" ; ins = bi.MakeK(opc.LOADBOOL, f.Push(), 0)\n\t\t\tCase \"nil\" ; ins = bi.MakeK(opc.LOADNIL, f.Push(), 0)\n\t\tEnd Select\n\t\tReturn BytecodeNode.MakeL(n.key, ins)\n\tEnd Method\n\t\n\tMethod funref:Node(n:Leaf) { varref closref }\n\t\tLocal i:BlueInstr, ref:Int = StrToNum(n.val)\n\t\tSelect n.key\n\t\t\tCase \"funref\" ; i = bi.MakeK(opc.CLOSURE, f.Push(), ref)\n\t\t\tCase \"varref\"\n\t\t\t\tLocal v:VarDef = f.fd.vars[ref], op:Int = opc.MOV ; If v.isClosure Then op = opc.GETLC\n\t\t\t\ti = bi.Make(op, f.Push(), v.stkpos)\n\t\t\tCase \"closref\" ; i = bi.Make(opc.GETUPV, f.Push(), ref)' + f.fd.vmax)\n\t\tEnd Select\n\t\tReturn BytecodeNode.MakeL(n.key, i)\n\tEnd Method\n\tMethod getfield:Node(n:Rose) { index }\n\t\tLocal r:BytecodeNode = BytecodeNode.Join(n.key, n.arg), i:BlueInstr\n\t\tIf n.key = \"getfield\"\n\t\t\tLocal k:Int = f.GetConst(\"1\", Leaf(n.arg[1]).val), tab:Int = f.Pop()\n\t\t\tr.inst.AddLast bi.Make(opc.GETTAB, f.Push(), tab, k)\n\t\tElse\n\t\t\tLocal idx:Int = f.Pop(), tab:Int = f.Pop()\n\t\t\tLocal pv:BlueInstr = BlueInstr(r.inst.Last())\n\t\t\tIf pv.op = opc.LOADSI And Abs(pv.c) < f.VSI_LIMIT And pv.c = Abs pv.c\n\t\t\t\tpv.op = opc.GETTABSI ; pv.ra = f.Push() ; pv.rb = tab\n\t\t\tElse\n\t\t\t\tr.inst.AddLast bi.Make(opc.GETTABI, f.Push(), tab, idx)\n\t\t\tEndIf\n\t\tEndIf\n\t\tReturn r\n\tEnd Method\n\t\n\tMethod TableCons:Node(n:Rose)\n\t\tLocal r:BytecodeNode = BytecodeNode.Join(n.key, n.arg), fld:BytecodeNode = Null\n\t\tLocal rslot:Int = f.Push(), tslot:Int = -1\n\t\tFor fld = EachIn n.arg\t'work out where it's safe to put the table\n\t\t\tFor Local in:BlueInstr = EachIn fld.inst\n\t\t\t\tIf in.ra >= tslot Then tslot = in.ra + 1\n\t\t\tNext\n\t\tNext\n\t\tFor fld = EachIn n.arg\t'then patch the operations to point there\n\t\t\tFor Local in:BlueInstr = EachIn fld.inst\n\t\t\t\tIf in.ra = -1 And (in.op = opc.SETTAB Or in.op = opc.SETTABI ..\n\t\t\t\t\tOr in.op = opc.VAINIT Or in.op = opc.CALLINIT) Then in.ra = tslot\n\t\t\tNext\n\t\tNext\n\t\tIf n.arg\t'pass the ongoing index count to the variable initializer\n\t\t\tfld = BytecodeNode(n.arg[n.arg.Length - 2])\n\t\t\tIf fld.key = \"va_fcall\" Or fld.key = \"va_init\"\n\t\t\t\tLocal in:BlueInstr = BlueInstr(fld.inst.Last())\n\t\t\t\tin.c = Int(Leaf(n.arg[n.arg.Length - 1]).val)\n\t\t\tEndIf\n\t\tEndIf\n\t\tIf tslot = -1 Then tslot = rslot Else tslot = f.Push(tslot - f.Peek())\n\t\tr.inst.AddFirst bi.Make(opc.NEWTAB, tslot, 0)\n\t\tIf tslot <> rslot Then r.inst.AddLast bi.Make(opc.MOV, rslot, tslot)\t'put the resulting table in the expected slot\n\t\tf.Pop(f.Peek() - rslot)\t'...and correct the stack\n\t\tReturn r\n\tEnd Method\n\tMethod FieldIndex:Node(n:Rose) { FieldKey }\n\t\tLocal r:BytecodeNode = BytecodeNode.Join(n.key, n.arg)\n\t\tLocal val:Int = f.Pop(), idx:Int, op:Int\n\t\tIf n.key = \"FieldIndex\"\n\t\t\tidx = f.Pop() ; op = opc.SETTABI\n\t\tElse\n\t\t\tidx = f.GetConst(\"1\", Leaf(n.arg[0]).val) ; op = opc.SETTAB\n\t\tEndIf\n\t\tr.inst.AddLast bi.Make(op, -1, val, idx)\n\t\tReturn r\n\tEnd Method\n\tMethod va_init:Node(n:Node)\n\t\tReturn BytecodeNode.MakeL(n.key, bi.Make(opc.VAINIT, -1, 0))\n\tEnd Method\n\t\n\tMethod Label:Node(n:Leaf)\t'insert dummy instructions to remove in the next pass\n\t\tReturn BytecodeNode.MakeL(n.key, bi.Make(opc.MOV, 0, 0, StrToNum(n.val)))\n\tEnd Method\n\tMethod GotoS:Node(n:Leaf)\t'resolve these in the next pass after removing dummy targets\n\t\tReturn BytecodeNode.MakeL(n.key, bi.MakeK(opc.JMP, 0, StrToNum(n.val)))\n\tEnd Method\n\t\n\tMethod PASSTHROUGH:Node(n:Node) { FuncBody Block ExpList FArgs MArgs NameList VarList Assgt }\n\t\tIf Rose(n)\n\t\t\tReturn BytecodeNode.Join(n.key, Rose(n).arg, n)\t'combine instruction sequences where they exist\n\t\tElse\n\t\t\tReturn BytecodeNode.Nil(n.key, n)\n\t\tEndIf\n\tEnd Method\n\tMethod IGNORE:Node(n:Node) { fname param rcount acount icount }\n\t\tReturn n\t'some things don't represent instructions at all and should be passed as data nodes\n\tEnd Method\n\tMethod any:Node(n:Node)\n\t\tIf Rose(n)\n\t\t\tPrint \"unhandled (passthrough): \" + n.key\n\t\t\tReturn BytecodeNode.Join(n.key, Rose(n).arg, n)\n\t\tElse\n\t\t\tPrint \"unhandled: \" + n.key\n\t\t\tReturn BytecodeNode.Nil(n.key, n)\n\t\tEndIf\n\tEnd Method\nEnd Type\n\nType BytecodeNode Extends Node\n\tField inst:TList, old:Node\n\tFunction MakeL:BytecodeNode(key:String, ins:BlueInstr, old:Node = Null)\n\t\tLocal n:BytecodeNode = New Self ; n.key = key ; n.inst = CreateList() ; n.old = old\n\t\tn.inst.AddLast(ins) ; Return n\n\tEnd Function\n\tFunction MakeR:BytecodeNode(key:String, inst:BlueInstr[], old:Node = Null)\n\t\tLocal n:BytecodeNode = New Self ; n.key = key ; n.inst = TList.FromArray(inst) ; n.old = old ; Return n\n\tEnd Function\n\tFunction Join:BytecodeNode(key:String, els:Node[], old:Node = Null)\n\t\tLocal n:BytecodeNode = New Self ; n.key = key ; n.inst = CreateList() ; n.old = old\n\t\tFor Local e:BytecodeNode = EachIn els\t'use of Eachin is important, as it autocasts\n\t\t\tFor Local o:Object = EachIn e.inst\n\t\t\t\tn.inst.AddLast o\n\t\t\tNext\n\t\tNext\n\t\tReturn n\n\tEnd Function\n\tFunction Nil:BytecodeNode(key:String = \"@\", old:Node = Null)\n\t\tReturn MakeR(key, Null, old)\n\tEnd Function\nEnd Type\n\n","old_contents":"\n' Blue Moon\n' FOLD delegate to generate assembly instructions\n\n' this file is a Private Include\n\n'SuperStrict\n\n\nType CompileFold\n\tField opc:BlueOpcode = New BlueOpcode, bi:BlueInstr = New BlueInstr, f:BlueAssembly, _gq:TList = CreateList()\n\t\n\tFunction Make:CompileFold(f:BlueAssembly)\n\t\tLocal c:CompileFold = New Self ; c.f = f ; Return c\n\tEnd Function\n\t\n\tMethod l_varref:Node(n:Leaf)\n\t\tLocal v:VarDef = f.fd.vars[StrToNum(n.val)], op:Int\n\t\tIf v.isClosure Then op = opc.SETLC Else op = opc.MOV\n\t\tReturn BytecodeNode.MakeL(n.key, bi.Make(op, v.stkpos, f.Pop()), n)\n\tEnd Method\n\tMethod l_closref:Node(n:Leaf)\n\t\tLocal ref:Int = StrToNum(n.val)\n\t\tReturn BytecodeNode.MakeL(n.key, bi.Make(opc.SETUPV, ref, f.Pop()))\n\tEnd Method\n\tMethod l_getfield:Node(n:Rose)\n\t\tLocal r:BytecodeNode = BytecodeNode.Join(n.key, [n.arg[0]])\n\t\tLocal k:Int = f.GetConst(\"1\", Leaf(n.arg[1]).val), tab:Int = f.Pop()\n\t\tr.inst.AddLast bi.Make(opc.SETTAB, tab, f.Pop(), k)\n\t\tReturn r\n\tEnd Method\n\tMethod l_index:Node(n:Rose)\n\t\tLocal r:BytecodeNode = BytecodeNode.Join(n.key, n.arg)\n\t\tLocal ind:Int = f.Pop(), tab:Int = f.Pop(), val:Int = f.Pop()\n\t\tLocal pv:BlueInstr = BlueInstr(r.inst.Last())\n\t\tIf pv.op = opc.LOADSI And Abs(pv.c) < f.VSI_LIMIT And pv.c = Abs pv.c\n\t\t\tpv.op = opc.SETTABSI ; pv.ra = tab ; pv.rb = val\n\t\tElse\n\t\t\tr.inst.AddLast bi.Make(opc.SETTABI, tab, val, ind)\n\t\tEndIf\n\t\tReturn r\n\tEnd Method\n\tMethod l_discard:Node(n:Node)\n\t\tf.Pop() ; Return BytecodeNode.Nil()\n\tEnd Method\n\t\n\tMethod LocalVar:Node(n:Rose)\n\t\tLocal vars:Node[] = Rose(BytecodeNode(n.arg[1]).old).arg\n\t\tLocal r:BytecodeNode = BytecodeNode.Join(n.key, n.arg)\n\t\tFor Local vi:Int = vars.Length - 1 To 0 Step -1\n\t\t\tLocal v:VarDef = f.fd.vars[StrToNum(Leaf(BytecodeNode(vars[vi]).old).val)]\n\t\t\tIf v.isClosure Then r.inst.AddFirst bi.Make(opc.NEWUPV, v.stkpos, 0)\n\t\tNext\n\t\tReturn r\n\tEnd Method\n\t\n\tMethod ReturnS:Node(n:Rose)\n\t\tLocal r:BytecodeNode = BytecodeNode.Join(n.key, n.arg)\n\t\tr.inst.AddLast(bi.MakeK(opc.RET, f.Peek(), n.arg.Length))\n\t\tf.Pop(n.arg.Length) ; Return r\n\tEnd Method\n\tMethod return_va:Node(n:Node)\n\t\tReturn BytecodeNode.MakeL(n.key, bi.Make(opc.RETVA, 0, 0))\n\tEnd Method\n\t\n\tMethod break:Node(n:Node)\n\t\tReturn BytecodeNode.MakeL(n.key, bi.Make(opc.JMP, -1, -1, -1))\n\tEnd Method\n\tMethod RepeatS:Node(n:Rose)\n\t\tLocal r:BytecodeNode = BytecodeNode.Join(n.key, n.arg), _lt:TList = f.fd._lt, _gt:TList = f.fd._gt\n\t\tLocal loopStart:LabelDef = New LabelDef, lsID:Int = _lt.Count(), loop:GotoDef = New GotoDef, lID:Int = _gt.Count()\n\t\tloop.tgt = loopStart ; _lt.AddLast loopStart ; _gt.AddLast loop\n\t\tLocal lastop:BlueInstr = BlueInstr(r.inst.Last()), reg:Int = f.Pop()\n\t\tIf lastop.op = opc.LNOT\n\t\t\tlastop.op = opc.JIF ; lastop.ra = lastop.rb ; lastop.rb = 0 ; lastop.c = lID\t'replace NOT with inverted jump\n\t\tElse\n\t\t\tr.inst.AddLast bi.MakeK(opc.JNOT, reg, lID)\n\t\tEndIf\n\t\tr.inst.AddFirst bi.Make(opc.MOV, 0, 0, lsID)\n\t\tr.inst.AddLast bi.Make(opc.MOV, -1, -1, -1)\n\t\tReturn r\n\tEnd Method\n\tMethod IfS:Node(n:Rose) { WhileS }\n\t\tLocal r:BytecodeNode = BytecodeNode.Join(n.key, [n.arg[0]]), lastop:BlueInstr = BlueInstr(r.inst.Last())\n\t\tLocal before:LabelDef, befID:Int, loopRound:GotoDef, loopID:Int, _lt:TList = f.fd._lt, _gt:TList = f.fd._gt\n\t\tIf n.key = \"WhileS\"\n\t\t\tbefore = New LabelDef ; befID = _lt.Count() ; _lt.AddLast before\n\t\t\tloopRound = New GotoDef ;loopRound.tgt = before ; loopID = _gt.Count() ; _gt.AddLast loopRound\n\t\t\tr.inst.AddFirst bi.Make(opc.MOV, 0, 0, befID)\n\t\tEndIf\n\t\tLocal postThen:LabelDef = New LabelDef, skipThen:GotoDef = New GotoDef, ptID:Int = _lt.Count(), stID:Int = _gt.Count()\n\t\t_lt.AddLast postThen ; skipThen.tgt = postThen ; _gt.AddLast skipThen\n\t\tIf lastop.op = opc.LNOT\n\t\t\tlastop.op = opc.JIF ; lastop.ra = lastop.rb ; lastop.rb = 0 ; lastop.c = stID\t'replace NOT with inverted jump\n\t\tElse\n\t\t\tr.inst.AddLast bi.MakeK(opc.JNOT, f.Peek(), stID)\n\t\tEndIf\n\t\tf.Pop()\n\t\tFor Local op:BlueInstr = EachIn BytecodeNode(n.arg[1]).inst\n\t\t\tr.inst.AddLast op\n\t\tNext\n\t\tLocal postElse:LabelDef, skipElse:GotoDef\n\t\tIf n.arg.Length > 2\t'there's an else\n\t\t\tpostElse = New LabelDef ; skipElse = New GotoDef ; skipElse.tgt = postElse\n\t\t\tLocal peID:Int = _lt.Count(), seID:Int = _gt.Count()\n\t\t\t_lt.AddLast postElse ; _gt.AddLast skipElse\n\t\t\tr.inst.AddLast bi.MakeK(opc.JMP, 0, seID)\n\t\t\tr.inst.AddLast bi.Make(opc.MOV, 0, 0, ptID)\n\t\t\tFor Local op:BlueInstr = EachIn BytecodeNode(n.arg[2]).inst\n\t\t\t\tr.inst.AddLast op\n\t\t\tNext\n\t\t\tr.inst.AddLast bi.Make(opc.MOV, 0, 0, peID)\n\t\tElse\n\t\t\tIf n.key = \"WhileS\" Then r.inst.AddLast bi.MakeK(opc.JMP, 0, loopID) ; r.inst.AddLast bi.Make(opc.MOV, -1, -1, -1)\n\t\t\tr.inst.AddLast bi.Make(opc.MOV, 0, 0, ptID)\n\t\tEndIf\n\t\tReturn r\n\tEnd Method\n\tMethod kand:Node(n:Rose) { kor }\n\t\tLocal r:BytecodeNode = BytecodeNode.Join(n.key, [n.arg[0]]), lastop:BlueInstr = BlueInstr(r.inst.Last())\n\t\tLocal _lt:TList = f.fd._lt, _gt:TList = f.fd._gt\n\t\tLocal postR:LabelDef = New LabelDef, skipR:GotoDef = New GotoDef, prID:Int = _lt.Count(), srID:Int = _gt.Count()\n\t\t_lt.AddLast postR ; skipR.tgt = postR ; _gt.AddLast skipR\n\t\tLocal reg:Int = f.Pop()\n\t\tIf lastop.op = opc.LNOT\n\t\t\tLocal op:Int = opc.JIF ; If n.key = \"kor\" Then op = opc.JNOT\n\t\t\tlastop.op = op ; lastop.ra = lastop.rb ; lastop.rb = 0 ; lastop.c = srID\t'replace NOT with inverted jump\n\t\tElse\n\t\t\tLocal op:Int = opc.JNOT ; If n.key = \"kor\" Then op = opc.JIF\n\t\t\tr.inst.AddLast bi.MakeK(op, reg - 1, srID)\n\t\tEndIf\n\t\tFor Local op:BlueInstr = EachIn BytecodeNode(n.arg[1]).inst\n\t\t\tr.inst.AddLast op\n\t\tNext\n\t\tr.inst.AddLast bi.Make(opc.MOV, reg - 1, reg)\n\t\tr.inst.AddLast bi.Make(opc.MOV, 0, 0, prID)\n\t\tReturn r\n\tEnd Method\n\t\n\tMethod fcall:Node(n:Rose) { pfcall tfcall va_fcall }\t'\"p\" prefix = \"procedure\" i.e. no return value required\n\t\tLocal r:BytecodeNode = BytecodeNode.Join(n.key, n.arg), argc:Int = Int(Leaf(n.arg[3]).val), retc:Int = Int(Leaf(n.arg[2]).val)\n\t\tLocal func:Int = f.Pop(argc + 1), args:Int = func + 1, op:Int = opc.CALL\n\t\tIf n.key = \"tfcall\" Then op = opc.TCALL\n\t\tr.inst.AddLast bi.Make(op, func, args, argc)\n\t\tIf n.key = \"fcall\"\n\t\t\tr.inst.AddLast bi.MakeK(opc.POSTCALL, f.Peek() + 1, retc) ; f.Push(retc)\n\t\tElseIf n.key = \"va_fcall\"\n\t\t\tr.inst.AddLast bi.Make(opc.CALLINIT, -1, 0)\n\t\tEndIf\n\t\tReturn r\n\tEnd Method\n\tMethod mcall:Node(n:Rose) { pmcall tmcall va_mcall }\n\t\tLocal r:BytecodeNode = BytecodeNode.Join(n.key, n.arg), argc:Int = Int(Leaf(n.arg[3]).val), retc:Int = Int(Leaf(n.arg[2]).val)\n\t\tLocal func:Int = f.Push(), argv:Int = f.Pop(argc + 2), op:Int = opc.CALL\n\t\tLocal ks:String = Leaf(Rose(BytecodeNode(n.arg[1]).old).arg[0]).val\t\t'yeesh\n\t\tr.inst.AddLast bi.Make(opc.GETTAB, func, argv, f.GetConst(\"1\", ks))\n\t\tIf n.key = \"tmcall\" Then op = opc.TCALL\n\t\tr.inst.AddLast bi.Make(op, func, argv, argc + 1)\n\t\tIf n.key = \"mcall\"\n\t\t\tr.inst.AddLast bi.MakeK(opc.POSTCALL, argv, retc) ; f.Push(retc)\n\t\tElseIf n.key = \"va_fcall\"\n\t\t\tr.inst.AddLast bi.Make(opc.CALLINIT, -1, 0)\n\t\tEndIf\n\t\tReturn r\n\tEnd Method\n\tMethod dotdotdot:Node(n:Leaf)\n\t\tLocal retc:Int = Int(n.val), r:BytecodeNode\n\t\tr = BytecodeNode.MakeL(n.key, bi.MakeK(opc.VARARG, f.Peek() + 1, retc))\n\t\tf.Push(retc)\n\t\tReturn r\n\tEnd Method\n\t\n\tMethod BinaryOp:Node(n:Rose) { plus minus mul div kmod pow dotdot lt gt leq geq eq neq }\n\t\tLocal r:BytecodeNode = BytecodeNode.Join(n.key, n.arg), op:Int\n\t\tSelect n.key\n\t\t\tCase \"plus\" ; op = opc.ADD\n\t\t\tCase \"minus\" ; op = opc.SUB\n\t\t\tCase \"mul\" ; op = opc.MUL\n\t\t\tCase \"div\" ; op = opc.DIV\n\t\t\tCase \"kmod\" ; op = opc.NMOD\n\t\t\tCase \"pow\" ; op = opc.POW\n\t\t\tCase \"dotdot\" ; op = opc.CAT\n\t\t\t\n\t\t\tCase \"lt\" ; op = opc.LT\n\t\t\tCase \"gt\" ; op = opc.LEQ\n\t\t\tCase \"leq\" ; op = opc.LEQ\n\t\t\tCase \"geq\" ; op = opc.LT\n\t\t\tCase \"eq\" ; op = opc.EQ\n\t\t\tCase \"neq\" ; op = opc.EQ\n\t\tEnd Select\n\t\tLocal lop:Int = f.Pop(), rop:Int = f.Pop()\n\t\tIf n.key = \"geq\" Or n.key = \"gt\"\n\t\t\tr.inst.AddLast bi.Make(op, f.Push(), rop, lop)\t'technically this violates IEEE-754, but it's how Lua defines it\n\t\tElse\n\t\t\tr.inst.AddLast bi.Make(op, f.Push(), lop, rop)\n\t\t\tIf n.key = \"neq\" Then r.inst.AddLast bi.Make(opc.LNOT, f.Peek(), f.Peek())\n\t\tEndIf\n\t\tReturn r\n\tEnd Method\n\tMethod UnaryOp:Node(n:Rose) { negate klen knot }\n\t\tLocal r:BytecodeNode = BytecodeNode.Join(n.key, n.arg), op:Int\n\t\tSelect n.key\n\t\t\tCase \"negate\" ; op = opc.UNM\n\t\t\tCase \"klen\" ; op = opc.ALEN\n\t\t\tCase \"knot\" ; op = opc.LNOT\n\t\t\tCase \"posate\" ; op = opc.UNP\n\t\tEnd Select\n\t\tLocal arg:Int = f.Pop()\n\t\tr.inst.AddLast bi.Make(op, f.Push(), arg)\n\t\tReturn r\n\tEnd Method\n\t\n\tMethod dconst:Node(n:Leaf) { sconst }\n\t\tLocal ki:Int = Int(n.val), op:Int = opc.LOADK\n\t\tIf n.key = \"dconst\" And Abs(ki) < BlueAssembly.SI_LIMIT And Double(n.val) = Double(ki)\n\t\t\top = opc.LOADSI\n\t\tElse\n\t\t\tki = f.GetConst(String(n.key = \"sconst\"), n.val)\n\t\tEndIf\n\t\tReturn BytecodeNode.MakeL(n.key, bi.MakeK(op, f.Push(), ki))\n\tEnd Method\n\tMethod bconst:Node(n:Leaf) { nil }\n\t\tLocal ins:BlueInstr\n\t\tSelect n.val\n\t\t\tCase \"true\" ; ins = bi.MakeK(opc.LOADBOOL, f.Push(), 1)\n\t\t\tCase \"false\" ; ins = bi.MakeK(opc.LOADBOOL, f.Push(), 0)\n\t\t\tCase \"nil\" ; ins = bi.MakeK(opc.LOADNIL, f.Push(), 0)\n\t\tEnd Select\n\t\tReturn BytecodeNode.MakeL(n.key, ins)\n\tEnd Method\n\t\n\tMethod funref:Node(n:Leaf) { varref closref }\n\t\tLocal i:BlueInstr, ref:Int = StrToNum(n.val)\n\t\tSelect n.key\n\t\t\tCase \"funref\" ; i = bi.MakeK(opc.CLOSURE, f.Push(), ref)\n\t\t\tCase \"varref\"\n\t\t\t\tLocal v:VarDef = f.fd.vars[ref], op:Int = opc.MOV ; If v.isClosure Then op = opc.GETLC\n\t\t\t\ti = bi.Make(op, f.Push(), v.stkpos)\n\t\t\tCase \"closref\" ; i = bi.Make(opc.GETUPV, f.Push(), ref)' + f.fd.vmax)\n\t\tEnd Select\n\t\tReturn BytecodeNode.MakeL(n.key, i)\n\tEnd Method\n\tMethod getfield:Node(n:Rose) { index }\n\t\tLocal r:BytecodeNode = BytecodeNode.Join(n.key, n.arg), i:BlueInstr\n\t\tIf n.key = \"getfield\"\n\t\t\tLocal k:Int = f.GetConst(\"1\", Leaf(n.arg[1]).val), tab:Int = f.Pop()\n\t\t\tr.inst.AddLast bi.Make(opc.GETTAB, f.Push(), tab, k)\n\t\tElse\n\t\t\tLocal idx:Int = f.Pop(), tab:Int = f.Pop()\n\t\t\tLocal pv:BlueInstr = BlueInstr(r.inst.Last())\n\t\t\tIf pv.op = opc.LOADSI And Abs(pv.c) < f.VSI_LIMIT And pv.c = Abs pv.c\n\t\t\t\tpv.op = opc.GETTABSI ; pv.ra = f.Push() ; pv.rb = tab\n\t\t\tElse\n\t\t\t\tr.inst.AddLast bi.Make(opc.GETTABI, f.Push(), tab, idx)\n\t\t\tEndIf\n\t\tEndIf\n\t\tReturn r\n\tEnd Method\n\t\n\tMethod TableCons:Node(n:Rose)\n\t\tLocal r:BytecodeNode = BytecodeNode.Join(n.key, n.arg), fld:BytecodeNode = Null\n\t\tLocal rslot:Int = f.Push(), tslot:Int = -1\n\t\tFor fld = EachIn n.arg\t'work out where it's safe to put the table\n\t\t\tFor Local in:BlueInstr = EachIn fld.inst\n\t\t\t\tIf in.ra >= tslot Then tslot = in.ra + 1\n\t\t\tNext\n\t\tNext\n\t\tFor fld = EachIn n.arg\t'then patch the operations to point there\n\t\t\tFor Local in:BlueInstr = EachIn fld.inst\n\t\t\t\tIf in.ra = -1 And (in.op = opc.SETTAB Or in.op = opc.SETTABI ..\n\t\t\t\t\tOr in.op = opc.VAINIT Or in.op = opc.CALLINIT) Then in.ra = tslot\n\t\t\tNext\n\t\tNext\n\t\tIf n.arg\t'pass the ongoing index count to the variable initializer\n\t\t\tfld = BytecodeNode(n.arg[n.arg.Length - 2])\n\t\t\tIf fld.key = \"va_fcall\" Or fld.key = \"va_init\"\n\t\t\t\tLocal in:BlueInstr = BlueInstr(fld.inst.Last())\n\t\t\t\tin.c = Int(Leaf(n.arg[n.arg.Length - 1]).val)\n\t\t\tEndIf\n\t\tEndIf\n\t\tIf tslot = -1 Then tslot = rslot Else tslot = f.Push(tslot - f.Peek())\n\t\tr.inst.AddFirst bi.Make(opc.NEWTAB, tslot, 0)\n\t\tIf tslot <> rslot Then r.inst.AddLast bi.Make(opc.MOV, rslot, tslot)\t'put the resulting table in the expected slot\n\t\tf.Pop(f.Peek() - rslot)\t'...and correct the stack\n\t\tReturn r\n\tEnd Method\n\tMethod FieldIndex:Node(n:Rose) { FieldKey }\n\t\tLocal r:BytecodeNode = BytecodeNode.Join(n.key, n.arg)\n\t\tLocal val:Int = f.Pop(), idx:Int, op:Int\n\t\tIf n.key = \"FieldIndex\"\n\t\t\tidx = f.Pop() ; op = opc.SETTABI\n\t\tElse\n\t\t\tidx = f.GetConst(\"1\", Leaf(n.arg[0]).val) ; op = opc.SETTAB\n\t\tEndIf\n\t\tr.inst.AddLast bi.Make(op, -1, val, idx)\n\t\tReturn r\n\tEnd Method\n\tMethod va_init:Node(n:Node)\n\t\tReturn BytecodeNode.MakeL(n.key, bi.Make(opc.VAINIT, -1, 0))\n\tEnd Method\n\t\n\tMethod Label:Node(n:Leaf)\t'insert dummy instructions to remove in the next pass\n\t\tReturn BytecodeNode.MakeL(n.key, bi.Make(opc.MOV, 0, 0, StrToNum(n.val)))\n\tEnd Method\n\tMethod GotoS:Node(n:Leaf)\t'resolve these in the next pass after removing dummy targets\n\t\tReturn BytecodeNode.MakeL(n.key, bi.MakeK(opc.JMP, 0, StrToNum(n.val)))\n\tEnd Method\n\t\n\tMethod PASSTHROUGH:Node(n:Node) { FuncBody Block ExpList FArgs MArgs NameList VarList Assgt }\n\t\tIf Rose(n)\n\t\t\tReturn BytecodeNode.Join(n.key, Rose(n).arg, n)\t'combine instruction sequences where they exist\n\t\tElse\n\t\t\tReturn BytecodeNode.Nil(n.key, n)\n\t\tEndIf\n\tEnd Method\n\tMethod IGNORE:Node(n:Node) { fname param rcount acount icount }\n\t\tReturn n\t'some things don't represent instructions at all and should be passed as data nodes\n\tEnd Method\n\tMethod any:Node(n:Node)\n\t\tIf Rose(n)\n\t\t\tPrint \"unhandled (passthrough): \" + n.key\n\t\t\tReturn BytecodeNode.Join(n.key, Rose(n).arg, n)\n\t\tElse\n\t\t\tPrint \"unhandled: \" + n.key\n\t\t\tReturn BytecodeNode.Nil(n.key, n)\n\t\tEndIf\n\tEnd Method\nEnd Type\n\nType BytecodeNode Extends Node\n\tField inst:TList, old:Node\n\tFunction MakeL:BytecodeNode(key:String, ins:BlueInstr, old:Node = Null)\n\t\tLocal n:BytecodeNode = New Self ; n.key = key ; n.inst = CreateList() ; n.old = old\n\t\tn.inst.AddLast(ins) ; Return n\n\tEnd Function\n\tFunction MakeR:BytecodeNode(key:String, inst:BlueInstr[], old:Node = Null)\n\t\tLocal n:BytecodeNode = New Self ; n.key = key ; n.inst = TList.FromArray(inst) ; n.old = old ; Return n\n\tEnd Function\n\tFunction Join:BytecodeNode(key:String, els:Node[], old:Node = Null)\n\t\tLocal n:BytecodeNode = New Self ; n.key = key ; n.inst = CreateList() ; n.old = old\n\t\tFor Local e:BytecodeNode = EachIn els\t'use of Eachin is important, as it autocasts\n\t\t\tFor Local o:Object = EachIn e.inst\n\t\t\t\tn.inst.AddLast o\n\t\t\tNext\n\t\tNext\n\t\tReturn n\n\tEnd Function\n\tFunction Nil:BytecodeNode(key:String = \"@\", old:Node = Null)\n\t\tReturn MakeR(key, Null, old)\n\tEnd Function\nEnd Type\n\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"20d41e585a0950458320f6ad339f5c49bed2a3d5","subject":"Moved TCamera.Project\/Unproject math to Prime.Math3D.","message":"Moved TCamera.Project\/Unproject math to Prime.Math3D.\n","repos":"kfprimm\/maxb3d,kfprimm\/maxb3d","old_file":"core.mod\/camera.bmx","new_file":"core.mod\/camera.bmx","new_contents":"\nStrict\n\nImport \"entity.bmx\"\nImport \"worldconfig.bmx\"\n\nConst CAMMODE_NONE\t= 0\nConst CAMMODE_PERSP\t= 1\nConst CAMMODE_ORTHO\t= 2\n\nConst CLSMODE_COLOR\t= 1\nConst CLSMODE_DEPTH\t= 2\n\nConst FOGMODE_NONE\t\t= 0\nConst FOGMODE_LINEAR\t= 1\n\nType TCamera Extends TEntity\n\tField _projmode\n\tField _fogmode,_fogr#,_fogg#,_fogb#,_fognear#,_fogfar#\n\tField _viewx,_viewy,_viewwidth,_viewheight\n\tField _clsmode,_near#,_far#\n\tField _zoom#\n\t\n\tField _modelview:TMatrix=New TMatrix\n\tField _projection:TMatrix=New TMatrix\n\tField _viewport[4]\n\tField _frustum:TFrustum\n\t\n\tMethod Init:TCamera(config:TWorldConfig,parent:TEntity)\n\t\tSuper.Init(config, parent)\n\t\tSetMode CAMMODE_PERSP\n\t\tSetFogMode FOGMODE_NONE\n\t\tSetFogRange 1,1000\n\t\tSetViewport 0,0,_config.Width,_config.Height\n\t\tSetClsMode CLSMODE_COLOR|CLSMODE_DEPTH\n\t\tSetColor 0,0,0\n\t\tSetRange 1,1000\n\t\tSetZoom 1.0\n\t\tReturn Self\n\tEnd Method\n\t\n\tMethod Lists[]()\n\t\tReturn Super.Lists() + [WORLDLIST_CAMERA]\n\tEnd Method\n\n\tMethod CopyData:TEntity(entity:TEntity)\n\t\tLocal camera:TCamera = TCamera(entity)\n\t\tLocal red,green,blue,fognear#,fogfar#,x,y,width,height,near#,far#\n\t\tcamera.GetFogColor red,green,blue\n\t\tcamera.GetFogRange fognear,fogfar\n\t\tcamera.GetViewport x,y,width,height\n\t\tcamera.GetRange near,far\n\t\t\n\t\tSetMode camera.GetMode()\n\t\tSetFogMode camera.GetFogMode()\n\t\tSetFogColor red,green,blue\n\t\tSetFogRange fognear,fogfar\n\t\tSetViewport x,y,width,height\n\t\tSetClsMode camera.GetClsMode()\n\t\tSetRange near,far\n\t\tSetZoom camera.GetZoom()\n\t\tReturn Super.CopyData(entity)\n\tEnd Method\n\t\n\tMethod Copy:TCamera(parent:TEntity=Null)\n\t\tReturn TCamera(Super.Copy_(parent))\n\tEnd Method\n\t\n\tMethod GetMode()\n\t\tReturn _projmode\n\tEnd Method\n\tMethod SetMode(mode)\n\t\t_projmode=mode\n\tEnd Method\t\n\t\n\tMethod GetFogMode()\n\t\tReturn _fogmode\n\tEnd Method\n\tMethod SetFogMode(mode)\n\t\t_fogmode=mode\n\tEnd Method\n\t\n\tMethod GetFogColor(red Var,green Var,blue Var)\n\t\tred=_fogr*255.0;green=_fogg*255.0;blue=_fogb*255.0\n\tEnd Method\n\tMethod SetFogColor(red,green,blue)\n\t\t_fogr=red\/255.0;_fogg=green\/255.0;_fogb=blue\/255.0\n\tEnd Method\n\t\n\tMethod GetFogRange(near# Var,far# Var)\n\t\tnear=_fognear;far=_fogfar\n\tEnd Method\n\tMethod SetFogRange(near#,far#)\n\t\t_fognear=Max(near,0);_fogfar=Max(far,0.001)\n\tEnd Method\n\t\n\tMethod GetViewport(x Var,y Var,width Var,height Var)\n\t\tx=_viewx;y=_viewy;width=_viewwidth;height=_viewheight\n\tEnd Method\n\tMethod SetViewport(x,y,width,height)\n\t\t_viewx=x;_viewy=y;_viewwidth=width;_viewheight=height\n\tEnd Method\n\t\n\tMethod GetClsMode()\n\t\tReturn _clsmode\n\tEnd Method\n\tMethod SetClsMode(mode)\n\t\t_clsmode=mode\n\tEnd Method\n\t\n\tMethod GetRange(near# Var,far# Var)\n\t\tnear=_near;far=_far\n\tEnd Method\n\tMethod SetRange(near#,far#)\n\t\t_near=near;_far=far\n\tEnd Method\t\n\t\n\tMethod GetZoom#()\n\t\tReturn _zoom\n\tEnd Method\n\tMethod SetZoom(zoom#)\n\t\t_zoom=zoom\n\tEnd Method\n\t\n\tMethod GetFOV#()\n\t\tReturn ATan(_zoom \/ 1.0)\n\tEnd Method\n\tMethod SetFOV(angle#)\n\t\t_zoom = 1.0 \/ Tan(angle \/ 2.0)\n\tEnd Method\n\t\n\tMethod GetEye:TRay()\n\t\tLocal x#,y#,z#,dx#,dy#,dz#=1.0,o:TVector,d:TVector\n\t\tGetPosition x,y,z,True\n\t\t_matrix.TransformVec3 dx,dy,dz\n\t\tReturn New TRay.Create(New TVector.Create3(x,y,z),New TVector.Create3(dx-x,dy-y,dz-x))\t\t\n\tEnd Method\n\t\n\tMethod UpdateMatrices()\n\t\t_viewport[0]=_viewx\n\t\t_viewport[1]=_viewy\n\t\t_viewport[2]=_viewwidth\n\t\t_viewport[3]=_viewheight\n\t\t\n\t\t_modelview = _matrix.Inverse()\n\t\t\n\t\tLocal ratio#=(Float(_viewwidth)\/_viewheight)\n\t\t_projection = TMatrix.Scale(1,1,-1).Multiply(TMatrix.PerspectiveFovRH(ATan((1.0\/(_zoom*ratio)))*2.0,ratio,_near,_far))\n\n\t\t_frustum=TFrustum.Extract(_modelview, _projection)\n\tEnd Method\n\t\n\tMethod Project(target:Object,x# Var,y# Var, offset#[] = Null)\n\t\tLocal z#\n\t\tTEntity.GetTargetPosition target,x,y,z\n\t\t\n\t\tIf offset\n\t\t\tx :+ offset[0]\n\t\t\ty :+ offset[1]\n\t\t\tz :+ offset[2]\n\t\tEndIf\n\t\t\n\t\tReturn TMatrix.Project(_modelview,_projection,_viewport,x,y,z)\n\tEnd Method\n\t\n\tMethod Unproject(wx#,wy#,wz#,x# Var,y# Var,z# Var)\n\t\tReturn TMatrix.Unproject(_modelview,_projection,_viewport,wx,wy,wz,x,y,z)\n\tEnd Method\n\t\n\tMethod InView#(target:Object)\n\t\tLocal x#,y#,z#,radius#\n\t\tLocal entity:TEntity=TEntity(target),point#[]=Float[](target)\n\t\tIf entity\n\t\t\tentity.GetCullParams x,y,z,radius\n\t\tElseIf point\n\t\t\tx=point[0];y=point[1];z=point[2];radius=point[3]\n\t\tElse\n\t\t\tReturn 0\n\t\tEndIf\n\t\tReturn _frustum.IntersectsPoint(x,y,z,radius)\n\tEnd Method\nEnd Type\n","old_contents":"\nStrict\n\nImport \"entity.bmx\"\nImport \"worldconfig.bmx\"\n\nConst CAMMODE_NONE\t= 0\nConst CAMMODE_PERSP\t= 1\nConst CAMMODE_ORTHO\t= 2\n\nConst CLSMODE_COLOR\t= 1\nConst CLSMODE_DEPTH\t= 2\n\nConst FOGMODE_NONE\t\t= 0\nConst FOGMODE_LINEAR\t= 1\n\nType TCamera Extends TEntity\n\tField _projmode\n\tField _fogmode,_fogr#,_fogg#,_fogb#,_fognear#,_fogfar#\n\tField _viewx,_viewy,_viewwidth,_viewheight\n\tField _clsmode,_near#,_far#\n\tField _zoom#\n\t\n\tField _modelview:TMatrix=New TMatrix\n\tField _projection:TMatrix=New TMatrix\n\tField _viewport[4]\n\tField _frustum:TFrustum\n\t\n\tMethod Init:TCamera(config:TWorldConfig,parent:TEntity)\n\t\tSuper.Init(config, parent)\n\t\tSetMode CAMMODE_PERSP\n\t\tSetFogMode FOGMODE_NONE\n\t\tSetFogRange 1,1000\n\t\tSetViewport 0,0,_config.Width,_config.Height\n\t\tSetClsMode CLSMODE_COLOR|CLSMODE_DEPTH\n\t\tSetColor 0,0,0\n\t\tSetRange 1,1000\n\t\tSetZoom 1.0\n\t\tReturn Self\n\tEnd Method\n\t\n\tMethod Lists[]()\n\t\tReturn Super.Lists() + [WORLDLIST_CAMERA]\n\tEnd Method\n\n\tMethod CopyData:TEntity(entity:TEntity)\n\t\tLocal camera:TCamera = TCamera(entity)\n\t\tLocal red,green,blue,fognear#,fogfar#,x,y,width,height,near#,far#\n\t\tcamera.GetFogColor red,green,blue\n\t\tcamera.GetFogRange fognear,fogfar\n\t\tcamera.GetViewport x,y,width,height\n\t\tcamera.GetRange near,far\n\t\t\n\t\tSetMode camera.GetMode()\n\t\tSetFogMode camera.GetFogMode()\n\t\tSetFogColor red,green,blue\n\t\tSetFogRange fognear,fogfar\n\t\tSetViewport x,y,width,height\n\t\tSetClsMode camera.GetClsMode()\n\t\tSetRange near,far\n\t\tSetZoom camera.GetZoom()\n\t\tReturn Super.CopyData(entity)\n\tEnd Method\n\t\n\tMethod Copy:TCamera(parent:TEntity=Null)\n\t\tReturn TCamera(Super.Copy_(parent))\n\tEnd Method\n\t\n\tMethod GetMode()\n\t\tReturn _projmode\n\tEnd Method\n\tMethod SetMode(mode)\n\t\t_projmode=mode\n\tEnd Method\t\n\t\n\tMethod GetFogMode()\n\t\tReturn _fogmode\n\tEnd Method\n\tMethod SetFogMode(mode)\n\t\t_fogmode=mode\n\tEnd Method\n\t\n\tMethod GetFogColor(red Var,green Var,blue Var)\n\t\tred=_fogr*255.0;green=_fogg*255.0;blue=_fogb*255.0\n\tEnd Method\n\tMethod SetFogColor(red,green,blue)\n\t\t_fogr=red\/255.0;_fogg=green\/255.0;_fogb=blue\/255.0\n\tEnd Method\n\t\n\tMethod GetFogRange(near# Var,far# Var)\n\t\tnear=_fognear;far=_fogfar\n\tEnd Method\n\tMethod SetFogRange(near#,far#)\n\t\t_fognear=Max(near,0);_fogfar=Max(far,0.001)\n\tEnd Method\n\t\n\tMethod GetViewport(x Var,y Var,width Var,height Var)\n\t\tx=_viewx;y=_viewy;width=_viewwidth;height=_viewheight\n\tEnd Method\n\tMethod SetViewport(x,y,width,height)\n\t\t_viewx=x;_viewy=y;_viewwidth=width;_viewheight=height\n\tEnd Method\n\t\n\tMethod GetClsMode()\n\t\tReturn _clsmode\n\tEnd Method\n\tMethod SetClsMode(mode)\n\t\t_clsmode=mode\n\tEnd Method\n\t\n\tMethod GetRange(near# Var,far# Var)\n\t\tnear=_near;far=_far\n\tEnd Method\n\tMethod SetRange(near#,far#)\n\t\t_near=near;_far=far\n\tEnd Method\t\n\t\n\tMethod GetZoom#()\n\t\tReturn _zoom\n\tEnd Method\n\tMethod SetZoom(zoom#)\n\t\t_zoom=zoom\n\tEnd Method\n\t\n\tMethod GetFOV#()\n\t\tReturn ATan(_zoom \/ 1.0)\n\tEnd Method\n\tMethod SetFOV(angle#)\n\t\t_zoom = 1.0 \/ Tan(angle \/ 2.0)\n\tEnd Method\n\t\n\tMethod GetEye:TRay()\n\t\tLocal x#,y#,z#,dx#,dy#,dz#=1.0,o:TVector,d:TVector\n\t\tGetPosition x,y,z,True\n\t\t_matrix.TransformVec3 dx,dy,dz\n\t\tReturn New TRay.Create(New TVector.Create3(x,y,z),New TVector.Create3(dx-x,dy-y,dz-x))\t\t\n\tEnd Method\n\t\n\tMethod UpdateMatrices()\n\t\t_viewport[0]=_viewx\n\t\t_viewport[1]=_viewy\n\t\t_viewport[2]=_viewwidth\n\t\t_viewport[3]=_viewheight\n\t\t\n\t\t_modelview = _matrix.Inverse()\n\t\t\n\t\tLocal ratio#=(Float(_viewwidth)\/_viewheight)\n\t\t_projection = TMatrix.Scale(1,1,-1).Multiply(TMatrix.PerspectiveFovRH(ATan((1.0\/(_zoom*ratio)))*2.0,ratio,_near,_far))\n\n\t\t_frustum=TFrustum.Extract(_modelview, _projection)\n\tEnd Method\n\t\n\tMethod Project(target:Object,x# Var,y# Var, offset#[] = Null)\n\t\tLocal z#\n\t\tTEntity.GetTargetPosition target,x,y,z\n\t\t\n\t\tIf offset\n\t\t\tx :+ offset[0]\n\t\t\ty :+ offset[1]\n\t\t\tz :+ offset[2]\n\t\tEndIf\n\t\t\n\t\tLocal w#=1.0\n\t\t_modelview.TransformVec4 x,y,z,w\n\t\t_projection.TransformVec4 x,y,z,w\n\t\tIf w=0 Return False\n\t\tx:\/w;y:\/w;z:\/w\n\n\t\tx=x*0.5+0.5;y=-y*0.5+0.5;z=z*0.5+0.5;\n\n\t\tx=x*_viewport[2]+_viewport[0]\n\t\ty=y*_viewport[3]+_viewport[1]\n\t\tReturn True\n\tEnd Method\n\t\n\tMethod Unproject(wx#,wy#,wz#,x# Var,y# Var,z# Var)\n\t\tx=((wx-_viewport[0])*2\/_viewport[2]) - 1\n\t\ty=((wy-_viewport[1])*2\/_viewport[3]) - 1\n\t\tz=wz*2-1\n\t\tLocal w#=1.0\n\t\t_projection.Multiply(_modelview).Inverse().TransformVec4 x,y,z,w\n\t\tIf w=0 Return False\n\t\tx:\/w;y:\/-w;z:\/-w\n\t\tReturn True\n\tEnd Method\n\t\n\tMethod InView#(target:Object)\n\t\tLocal x#,y#,z#,radius#\n\t\tLocal entity:TEntity=TEntity(target),point#[]=Float[](target)\n\t\tIf entity\n\t\t\tentity.GetCullParams x,y,z,radius\n\t\tElseIf point\n\t\t\tx=point[0];y=point[1];z=point[2];radius=point[3]\n\t\tElse\n\t\t\tReturn 0\n\t\tEndIf\n\t\tReturn _frustum.IntersectsPoint(x,y,z,radius)\n\tEnd Method\nEnd Type\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"bb53335e27d098dad041683c663f53ef10f52414","subject":"Patched possible bug","message":"Patched possible bug\n","repos":"kfprimm\/maxb3d,kfprimm\/maxb3d","old_file":"b3dloader.mod\/b3dloader.bmx","new_file":"b3dloader.mod\/b3dloader.bmx","new_contents":"\nStrict\n\nRem\n\tbbdoc: Blitz3D model loader for MaxB3D\nEnd Rem\nModule MaxB3D.B3DLoader\nModuleInfo \"Author: Kevin Primm\"\nModuleInfo \"License: MIT\"\n\nImport MaxB3D.Core\nImport MaxB3D.BoneAnimator\nImport Prime.libB3D\n\nType TMeshLoaderB3D Extends TMeshLoader\n\tField _mesh:TMesh\n\t\n\tMethod Run(mesh:TMesh,stream:TStream,url:Object)\n\t\tLocal model:TBB3DChunk = TBB3DChunk(url)\t\t\n\t\tIf model=Null model = TBB3DChunk.Load(stream)\n\t\tIf model=Null Return False\t\n\t\t\n\t\tLocal olddir$=CurrentDir()\n\t\tIf String(url) ChangeDir(ExtractDir(String(url)))\n\t\t\n\t\tLocal texture:TTexture[model.texs.length]\n\t\tLocal brush:TBrush[model.brus.length]\n\t\t\n\t\tFor Local i=0 To texture.length-1\n\t\t\tLocal chunk:TTEXSChunk=model.texs[i]\t\t\t\n\t\t\ttexture[i]=_currentworld.AddTexture(chunk.file,chunk.flags)\n\t\t\tIf texture[i]\n\t\t\t\ttexture[i].SetBlend chunk.blend\n\t\t\t\ttexture[i].SetPosition chunk.x_pos,chunk.y_pos\n\t\t\t\ttexture[i].SetScale chunk.x_scale,chunk.y_scale\n\t\t\t\ttexture[i].SetRotation chunk.rotation*(180.0\/Pi)\n\t\t\t\tIf chunk.flags&65536 texture[i].SetCoords 1\n\t\t\tEndIf\n\t\tNext\n\t\t\n\t\tFor Local i=0 To brush.length-1\n\t\t\tLocal chunk:TBRUSChunk=model.brus[i]\n\t\t\tbrush[i]=_currentworld.AddBrush()\n\t\t\tbrush[i].SetName chunk.name\n\t\t\tbrush[i].SetColor chunk.red*255,chunk.green*255,chunk.blue*255;brush[i].SetAlpha chunk.alpha\n\t\t\tbrush[i].SetShine chunk.shininess\n\t\t\tbrush[i].SetBlend chunk.blend;brush[i].SetFX chunk.fx\n\t\t\tFor Local j=0 To chunk.n_texs-1\n\t\t\t\tIf chunk.texture_id[j]>-1 brush[i].SetTexture texture[chunk.texture_id[j]],j\n\t\t\tNext\n\t\tNext\t\t\n\t\tChangeDir olddir\n\t\t\n\t\t' model.dump StandardIOStream\n\t\t \n\t\tIf model.node\n\t\t\tParseNode model.node,mesh,brush,mesh\n\t\t\t_mesh = Null\n\t\t\tReturn True\n\t\tEndIf\n\t\tReturn False\n\tEnd Method\n\t\n\tMethod ParseNode(node:TNODEChunk,parent:TEntity,brush:TBrush[],entity:TEntity=Null)\n\t\tLocal meshchunk:TMESHChunk=TMESHChunk(node.kind),bonechunk:TBONEChunk=TBONEChunk(node.kind)\n\t\t\t\t\n\t\tSelect node.kind\n\t\tCase Null\n\t\t\tentity=_currentworld.AddPivot(parent)\n\t\tCase meshchunk\t\t\t\n\t\t\tIf entity=Null entity=_currentworld.AddMesh(\"\/\/empty\",parent)\n\t\t\tLocal mesh:TMesh=TMesh(entity)\n\t\t\tmesh._animator=New TBoneAnimator\n\t\t\t_mesh=mesh\n\t\t\t\n\t\t\tIf meshchunk.brush_id>-1 entity.SetBrush brush[meshchunk.brush_id]\n\t\t\t\n\t\t\tLocal vrts:TVRTSChunk=meshchunk.vrts\n\t\t\tLocal vertsurface:TSurface=New TSurface\n\t\t\tvertsurface.Resize(vrts.xyz.length\/3,0)\n\t\t\t\n\t\t\tFor Local i=0 To vertsurface.CountVertices()-1\n\t\t\t\tvertsurface.SetCoords i,vrts.xyz[i*3+0],vrts.xyz[i*3+1],vrts.xyz[i*3+2]\n\t\t\t\tIf vrts.nxyz vertsurface.SetNormal i,vrts.nxyz[i*3+0],vrts.nxyz[i*3+1],vrts.nxyz[i*3+2]\n\t\t\t\tIf vrts.rgba vertsurface.SetColor i,vrts.rgba[i*4+0]*255,vrts.rgba[i*4+1]*255,vrts.rgba[i*4+2]*255,vrts.rgba[i*4+3]\n\t\t\t\tIf vrts.SetSize()>1 \n\t\t\t\t\tFor Local j=0 To vrts.SetCount()-1\n\t\t\t\t\t\tvertsurface.SetTexCoords i,1-vrts.tex_coords[i][j,0],vrts.tex_coords[i][j,1],j\n\t\t\t\t\tNext\n\t\t\t\tEndIf\n\t\t\tNext\n\t\t\t\n\t\t\tFor Local i=0 To meshchunk.tris.length-1\n\t\t\t\tLocal tri:TTRISChunk=meshchunk.tris[i]\n\t\t\t\tLocal surface:TSurface=vertsurface.Copy()\n\t\t\t\tsurface.Resize(-1,tri.vertex_id.length\/3)\n\t\t\t\tIf tri.brush_id>-1 surface.SetBrush brush[tri.brush_id]\n\t\t\t\tFor Local t=0 To surface.CountTriangles()-1\n\t\t\t\t\tsurface.SetTriangle t,tri.vertex_id[t*3+0],tri.vertex_id[t*3+1],tri.vertex_id[t*3+2]\n\t\t\t\tNext\n\t\t\t\tIf vrts.nxyz=Null surface.UpdateNormals\t\t\t\n\t\t\t\tmesh.AppendSurface surface\n\t\t\tNext\n\t\tCase bonechunk\n\t\t\tentity=_currentworld.AddBone(parent)\n\t\t\tLocal bone:TBone=TBone(entity)\n\t\t\t\n\t\t\tFor Local surface:TSurface=EachIn _mesh._surfaces\n\t\t\t\tbone.AddSurface surface\n\t\t\t\tFor Local i=0 To bonechunk.vertex_id.length-1\n\t\t\t\t\tbone.AddVertex surface,bonechunk.vertex_id[i],bonechunk.weight[i]\n\t\t\t\tNext\n\t\t\tNext\t\t\t\n\t\t\t\n\t\t\tLocal ident_matrix:TMatrix=TMatrix.Identity()\n\t\t\tFor Local chunk:TKEYSChunk=EachIn node.keys\n\t\t\t\tLocal keys:TAnimKey[chunk.frame.length]\n\t\t\t\tLocal pos#[]=chunk.position,rot#[]=chunk.rotation,scl#[]=chunk.scale\n\t\t\t\tFor Local i=0 To chunk.frame.length-1\n\t\t\t\t\tLocal bonekey:TBoneKey=New TBoneKey\n\t\t\t\t\t\n\t\t\t\t\tIf pos.length>0 bonekey._px=pos[i*3+0];bonekey._py=pos[i*3+1];bonekey._pz=pos[i*3+2]\n\t\t\t\t\tIf rot.length>0 bonekey._rw=rot[i*4+0];bonekey._rx=rot[i*4+1];bonekey._ry=rot[i*4+2];bonekey._rz=rot[i*4+3]\n\t\t\t\t\tIf scl.length>0 bonekey._sx=scl[i*3+0];bonekey._sy=scl[i*3+1];bonekey._sz=scl[i*3+2]\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\tLocal key:TAnimKey=New TAnimKey\n\t\t\t\t\tkey._frame=chunk.frame[i]\n\t\t\t\t\tkey._object=bonekey\n\t\t\t\t\tkeys[i]=key\n\t\t\t\tNext\n\t\t\t\tTBoneAnimator(_mesh._animator).AddBone bone,keys\n\t\t\tNext\n\t\tDefault\n\t\t\tentity=_currentworld.AddPivot(parent)\n\t\tEnd Select\t\t\n\t\t\n\t\tentity.SetName node.name\n\t\tentity.SetPosition node.position[0],node.position[1],node.position[2]\n\t\tLocal pitch#,yaw#,roll#\n\t\tTQuaternion.Euler node.rotation[0],node.rotation[1],node.rotation[2],node.rotation[3],pitch,yaw,roll\n\t\tentity.SetRotation pitch,yaw,roll\n\t\tentity.SetScale node.scale[0],node.scale[1],node.scale[2]\n\t\t\n\t\tFor Local child:TNODEChunk=EachIn node.node\n\t\t\tParseNode child,entity,brush\n\t\tNext\n\t\tIf TMesh(entity) If TBoneAnimator(TMesh(entity)._animator)._root=Null TMesh(entity)._animator=Null\n\t\tIf TBone(entity) TBone(entity)._start_matrix=entity.GetMatrix()\n\tEnd Method\n\t\n\tMethod Info$()\n\t\tReturn \"Blitz3D|b3d\"\n\tEnd Method\n\tMethod ModuleName$()\n\t\tReturn \"b3dloader\"\n\tEnd Method\nEnd Type\nNew TMeshLoaderB3D\n","old_contents":"\nStrict\n\nRem\n\tbbdoc: Blitz3D model loader for MaxB3D\nEnd Rem\nModule MaxB3D.B3DLoader\nModuleInfo \"Author: Kevin Primm\"\nModuleInfo \"License: MIT\"\n\nImport MaxB3D.Core\nImport MaxB3D.BoneAnimator\nImport Prime.libB3D\n\nType TMeshLoaderB3D Extends TMeshLoader\n\tField _mesh:TMesh\n\t\n\tMethod Run(mesh:TMesh,stream:TStream,url:Object)\n\t\tLocal model:TBB3DChunk = TBB3DChunk(url)\t\t\n\t\tIf model=Null model = TBB3DChunk.Load(stream)\n\t\tIf model=Null Return False\t\n\t\t\n\t\tLocal olddir$=CurrentDir()\n\t\tIf String(url) ChangeDir(ExtractDir(String(url)))\n\t\t\n\t\tLocal texture:TTexture[model.texs.length]\n\t\tLocal brush:TBrush[model.brus.length]\n\t\t\n\t\tFor Local i=0 To texture.length-1\n\t\t\tLocal chunk:TTEXSChunk=model.texs[i]\t\t\t\n\t\t\ttexture[i]=_currentworld.AddTexture(chunk.file,chunk.flags)\n\t\t\tIf texture[i]\n\t\t\t\ttexture[i].SetBlend chunk.blend\n\t\t\t\ttexture[i].SetPosition chunk.x_pos,chunk.y_pos\n\t\t\t\ttexture[i].SetScale chunk.x_scale,chunk.y_scale\n\t\t\t\ttexture[i].SetRotation chunk.rotation*(180.0\/Pi)\n\t\t\t\tIf chunk.flags&65536 texture[i].SetCoords 1\n\t\t\tEndIf\n\t\tNext\n\t\t\n\t\tFor Local i=0 To brush.length-1\n\t\t\tLocal chunk:TBRUSChunk=model.brus[i]\n\t\t\tbrush[i]=_currentworld.AddBrush()\n\t\t\tbrush[i].SetName chunk.name\n\t\t\tbrush[i].SetColor chunk.red*255,chunk.green*255,chunk.blue*255;brush[i].SetAlpha chunk.alpha\n\t\t\tbrush[i].SetShine chunk.shininess\n\t\t\tbrush[i].SetBlend chunk.blend;brush[i].SetFX chunk.fx\n\t\t\tFor Local j=0 To chunk.n_texs-1\n\t\t\t\tIf chunk.texture_id[j]>-1 brush[i].SetTexture texture[chunk.texture_id[j]],j\n\t\t\tNext\n\t\tNext\t\t\n\t\tChangeDir olddir\n\t\t\n\t\t' model.dump StandardIOStream\n\t\t \n\t\tIf model.node\n\t\t\tParseNode model.node,mesh,brush,mesh\n\t\t\tReturn True\n\t\tEndIf\n\t\tReturn False\n\tEnd Method\n\t\n\tMethod ParseNode(node:TNODEChunk,parent:TEntity,brush:TBrush[],entity:TEntity=Null)\n\t\tLocal meshchunk:TMESHChunk=TMESHChunk(node.kind),bonechunk:TBONEChunk=TBONEChunk(node.kind)\n\t\t\t\t\n\t\tSelect node.kind\n\t\tCase Null\n\t\t\tentity=_currentworld.AddPivot(parent)\n\t\tCase meshchunk\t\t\t\n\t\t\tIf entity=Null entity=_currentworld.AddMesh(\"\/\/empty\",parent)\n\t\t\tLocal mesh:TMesh=TMesh(entity)\n\t\t\tmesh._animator=New TBoneAnimator\n\t\t\t_mesh=mesh\n\t\t\t\n\t\t\tIf meshchunk.brush_id>-1 entity.SetBrush brush[meshchunk.brush_id]\n\t\t\t\n\t\t\tLocal vrts:TVRTSChunk=meshchunk.vrts\n\t\t\tLocal vertsurface:TSurface=New TSurface\n\t\t\tvertsurface.Resize(vrts.xyz.length\/3,0)\n\t\t\t\n\t\t\tFor Local i=0 To vertsurface.CountVertices()-1\n\t\t\t\tvertsurface.SetCoords i,vrts.xyz[i*3+0],vrts.xyz[i*3+1],vrts.xyz[i*3+2]\n\t\t\t\tIf vrts.nxyz vertsurface.SetNormal i,vrts.nxyz[i*3+0],vrts.nxyz[i*3+1],vrts.nxyz[i*3+2]\n\t\t\t\tIf vrts.rgba vertsurface.SetColor i,vrts.rgba[i*4+0]*255,vrts.rgba[i*4+1]*255,vrts.rgba[i*4+2]*255,vrts.rgba[i*4+3]\n\t\t\t\tIf vrts.SetSize()>1 \n\t\t\t\t\tFor Local j=0 To vrts.SetCount()-1\n\t\t\t\t\t\tvertsurface.SetTexCoords i,1-vrts.tex_coords[i][j,0],vrts.tex_coords[i][j,1],j\n\t\t\t\t\tNext\n\t\t\t\tEndIf\n\t\t\tNext\n\t\t\t\n\t\t\tFor Local i=0 To meshchunk.tris.length-1\n\t\t\t\tLocal tri:TTRISChunk=meshchunk.tris[i]\n\t\t\t\tLocal surface:TSurface=vertsurface.Copy()\n\t\t\t\tsurface.Resize(-1,tri.vertex_id.length\/3)\n\t\t\t\tIf tri.brush_id>-1 surface.SetBrush brush[tri.brush_id]\n\t\t\t\tFor Local t=0 To surface.CountTriangles()-1\n\t\t\t\t\tsurface.SetTriangle t,tri.vertex_id[t*3+0],tri.vertex_id[t*3+1],tri.vertex_id[t*3+2]\n\t\t\t\tNext\n\t\t\t\tIf vrts.nxyz=Null surface.UpdateNormals\t\t\t\n\t\t\t\tmesh.AppendSurface surface\n\t\t\tNext\n\t\tCase bonechunk\n\t\t\tentity=_currentworld.AddBone(parent)\n\t\t\tLocal bone:TBone=TBone(entity)\n\t\t\t\n\t\t\tFor Local surface:TSurface=EachIn _mesh._surfaces\n\t\t\t\tbone.AddSurface surface\n\t\t\t\tFor Local i=0 To bonechunk.vertex_id.length-1\n\t\t\t\t\tbone.AddVertex surface,bonechunk.vertex_id[i],bonechunk.weight[i]\n\t\t\t\tNext\n\t\t\tNext\t\t\t\n\t\t\t\n\t\t\tLocal ident_matrix:TMatrix=TMatrix.Identity()\n\t\t\tFor Local chunk:TKEYSChunk=EachIn node.keys\n\t\t\t\tLocal keys:TAnimKey[chunk.frame.length]\n\t\t\t\tLocal pos#[]=chunk.position,rot#[]=chunk.rotation,scl#[]=chunk.scale\n\t\t\t\tFor Local i=0 To chunk.frame.length-1\n\t\t\t\t\tLocal bonekey:TBoneKey=New TBoneKey\n\t\t\t\t\t\n\t\t\t\t\tIf pos.length>0 bonekey._px=pos[i*3+0];bonekey._py=pos[i*3+1];bonekey._pz=pos[i*3+2]\n\t\t\t\t\tIf rot.length>0 bonekey._rw=rot[i*4+0];bonekey._rx=rot[i*4+1];bonekey._ry=rot[i*4+2];bonekey._rz=rot[i*4+3]\n\t\t\t\t\tIf scl.length>0 bonekey._sx=scl[i*3+0];bonekey._sy=scl[i*3+1];bonekey._sz=scl[i*3+2]\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\tLocal key:TAnimKey=New TAnimKey\n\t\t\t\t\tkey._frame=chunk.frame[i]\n\t\t\t\t\tkey._object=bonekey\n\t\t\t\t\tkeys[i]=key\n\t\t\t\tNext\n\t\t\t\tTBoneAnimator(_mesh._animator).AddBone bone,keys\n\t\t\tNext\n\t\tDefault\n\t\t\tentity=_currentworld.AddPivot(parent)\n\t\tEnd Select\t\t\n\t\t\n\t\tentity.SetName node.name\n\t\tentity.SetPosition node.position[0],node.position[1],node.position[2]\n\t\tLocal pitch#,yaw#,roll#\n\t\tTQuaternion.Euler node.rotation[0],node.rotation[1],node.rotation[2],node.rotation[3],pitch,yaw,roll\n\t\tentity.SetRotation pitch,yaw,roll\n\t\tentity.SetScale node.scale[0],node.scale[1],node.scale[2]\n\t\t\n\t\tFor Local child:TNODEChunk=EachIn node.node\n\t\t\tParseNode child,entity,brush\n\t\tNext\n\t\tIf TMesh(entity) If TBoneAnimator(TMesh(entity)._animator)._root=Null TMesh(entity)._animator=Null\n\t\tIf TBone(entity) TBone(entity)._start_matrix=entity.GetMatrix()\n\tEnd Method\n\t\n\tMethod Info$()\n\t\tReturn \"Blitz3D|b3d\"\n\tEnd Method\n\tMethod ModuleName$()\n\t\tReturn \"b3dloader\"\n\tEnd Method\nEnd Type\nNew TMeshLoaderB3D\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"b4102ecc3daa62318c34a9e0771515ef8aa1cf3e","subject":"Removed some test code","message":"Removed some test code\n\nrefs gh-6\n","repos":"maximos\/maximus","old_file":"maximus.bmx","new_file":"maximus.bmx","new_contents":"\nSuperStrict\n\nFramework brl.blitz\nImport brl.standardio\nImport brl.maxutil\nImport brl.ramstream\n\nImport bah.volumes\nImport gman.zipengine\nImport htbaapub.rest\n\nImport duct.variables\nImport duct.objectmap\nImport duct.json\nImport duct.locale\nImport duct.clapp\nImport duct.time\n\nIncbin \"locales\/en.loc\"\n\nInclude \"src\/logger.bmx\"\nInclude \"src\/errors.bmx\"\nInclude \"src\/config.bmx\"\nInclude \"src\/dependencies.bmx\"\nInclude \"src\/module.bmx\"\nInclude \"src\/sources.bmx\"\nInclude \"src\/utils.bmx\"\nInclude \"src\/impl\/help.bmx\"\nInclude \"src\/impl\/version.bmx\"\nInclude \"src\/impl\/modpath.bmx\"\nInclude \"src\/impl\/install.bmx\"\nInclude \"src\/impl\/update.bmx\"\nInclude \"src\/impl\/list.bmx\"\n\nGlobal logger:mxLogger = New mxLogger\nGlobal mainapp:mxApp\nNew mxApp.Create() ' Skip the first element because it is the program's location\nmainapp.SetArgs(AppArgs[1..])\nmainapp.Run()\n\nRem\n\tbbdoc: Maximus app.\n\tabout: This handles the basic flow of the program (initiation, parsing, command calling, exiting..)\nEnd Rem\nType mxApp Extends dCLApp\n\t\n\tConst c_version:String = \"0.9.0\"\n\tConst c_configfile:String = \"maximus.config\"\n\t\n\tField m_apppath:String\n\tField m_maxpath:String, m_binpath:String, m_modpath:String\n\t\n\tField m_confighandler:mxConfigHandler\n\tField m_defaultlocale:dLocale, m_locale:dLocale\n\tField m_sourcesfile:String = \"sources\", m_sourcesurl:String = \"http:\/\/maximus.htbaa.com\/module\/sources\/json\"\n\tField m_useragent:String\n\tField m_autoupdatesources:Int = True\n\t\n\tField m_sourceshandler:mxSourcesHandler\n\t\n\tField m_updateimpl:mxUpdateImpl\n\tField m_sourcesupdated:Int\n\t\n\tRem\n\t\tbbdoc: Create a new mxApp.\n\t\treturns: Itself.\n\tEnd Rem\n\tMethod Create:mxApp()\n\t\tmainapp = Self\n\t\tSuper.Create()\n\t\tReturn Self\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Called when the application is created.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod OnInit()\n\t\tm_apppath = GetUserAppDir() + \"\/\"\n\t\t?Linux\n\t\tm_apppath:+ \".maximus\/\"\n\t\t?Not Linux\n\t\tm_apppath:+ \"maximus\/\"\n\t\t?\n\t\tIf FileType(m_apppath) = FILETYPE_NONE\n\t\t\tIf Not CreateDir(m_apppath, False)\n\t\t\t\tThrowError(_s(\"error.createperms\", [m_apppath]))\n\t\t\tEnd If\n\t\tEnd If\n\t\tChangeDir(m_apppath)\n\t\tm_confighandler = New mxConfigHandler.Create(m_apppath + c_configfile)\n\t\tm_confighandler.LoadDefaultLocale()\n\t\tm_confighandler.Load()\n\t\tIf Not m_maxpath\n\t\t\tTry\n\t\t\t\tSetMaxPath(BlitzMaxPath())\n\t\t\tCatch e:Object\n\t\t\t\tThrowError(_s(\"error.notfound.maxenv\"))\n\t\t\tEnd Try\n\t\tEnd If\n\t\tIf Not m_modpath Then SetModPath(m_maxpath + \"\/mod\", False)\n\t\tm_arghandler = New dArgumentHandler.Create()\n\t\tm_arghandler.AddArgImpl(New mxHelpImpl)\n\t\tm_arghandler.AddArgImpl(New mxVersionImpl)\n\t\tm_arghandler.AddArgImpl(New mxModPathImpl)\n\t\tm_arghandler.AddArgImpl(New mxInstallImpl)\n\t\tm_updateimpl = New mxUpdateImpl\n\t\tm_arghandler.AddArgImpl(m_updateimpl)\n\t\tm_arghandler.AddArgImpl(New mxListImpl)\n\t\tUpdateSources()\n\t\tm_sourceshandler = New mxSourcesHandler.FromFile(m_apppath + m_sourcesfile)\n\t\tIf Not m_sourceshandler\n\t\t\t' Don't throw an error here, the user may be updating the sources (an error will occur otherwise)\n\t\t\tlogger.LogWarning(_s(\"error.load.sources.file\", [m_apppath + m_sourcesfile]))\n\t\tEnd If\n\t\tLocal os:String\n\t\t?Win32\n\t\t\tos = \"Windows\"\n\t\t?Linux\n\t\t\tos = \"Linux\"\n\t\t?MacOS\n\t\t\tos = \"MacOS\"\n\t\t?\n\t\tm_useragent = \"Maximus\/\" + c_version + \" (\" + os + \"; \" + m_locale.GetName() + \")\"\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Called when the application is ended (this includes #ThrowError calls).\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod OnExit()\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Run the application.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod Run()\n\t\tLocal argimpl:dArgumentImplementation, isopt:Int\n\t\tFor Local arg:dIdentifier = EachIn m_arguments\n\t\t\targimpl = m_arghandler.GetArgImplWithAlias(arg.GetName())\n\t\t\tisopt = (arg.GetName()[0] = 45)\n\t\t\tIf argimpl\n\t\t\t\tIf isopt\n\t\t\t\t\targimpl.SetCallConvention(dCallConvention.OPTION)\n\t\t\t\t\targimpl.SetArgs(arg)\n\t\t\t\t\targimpl.CheckArgs()\n\t\t\t\t\targimpl.Execute()\n\t\t\t\tElse\n\t\t\t\t\targimpl.SetCallConvention(dCallConvention.COMMAND)\n\t\t\t\t\targimpl.SetArgs(arg)\n\t\t\t\t\targimpl.CheckArgs()\n\t\t\t\t\targimpl.Execute()\n\t\t\t\t\tExit\n\t\t\t\tEnd If\n\t\t\tElse\n\t\t\t\tIf isopt\n\t\t\t\t\tThrowCommonError(mxOptErrors.UNKNOWN, arg.GetName())\n\t\t\t\tElse\n\t\t\t\t\tThrowCommonError(mxCmdErrors.UNKNOWN, arg.GetName())\n\t\t\t\tEnd If\n\t\t\tEnd If\n\t\tNext\n\n\t\tOnExit()\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Update the sources list.\n\t\treturns: Nothing.\n\t\tabout: Updates when: the sources file is greater than 23 hours old; the sources file does not exist.\n\tEnd Rem\n\tMethod UpdateSources()\n\t\tIf m_autoupdatesources And Not m_sourcesupdated\n\t\t\tLocal ctime:dTime, ftime:dTime\n\t\t\tctime = New dTime.CreateFromCurrent()\n\t\t\tftime = New dTime.CreateFromFile(m_apppath + m_sourcesfile)\n\t\t\t'DebugLog(\"Auto-update file time: c\" + ctime.Get() + \" | \" + ftime.Get() + \", hours: \" + (ctime.Get() - ftime.Get()) \/ 3600)\n\t\t\tIf Not ftime Or (ctime.Get() - ftime.Get()) \/ 3600 > 23\n\t\t\t\tlogger.LogMessage(_s(\"arg.update.autoupdate\"))\n\t\t\t\tm_updateimpl.SetCallConvention(dCallConvention.COMMAND)\n\t\t\t\tm_updateimpl.SetArgs(New dIdentifier.Create())\n\t\t\t\tm_updateimpl.CheckArgs()\n\t\t\t\tm_updateimpl.Execute()\n\t\t\tEnd If\n\t\tEnd If\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the application's arguments.\n\t\treturns: Nothing.\n\t\tabout: NOTE: This will resolve to '--help' if the given args are Null.\n\tEnd Rem\n\tMethod SetArgs(args:String[])\n\t\tIf Not args\n\t\t\targs = [\"--help\"]\n\t\tEnd If\n\t\tParseArguments(args, False, 1)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the module path.\n\t\treturns: Nothing.\n\t\tabout: This will throw an error if the module path could not be found.\n\tEnd Rem\n\tMethod SetModPath(modpath:String, logchange:Int = True)\n\t\tm_modpath = FixPathEnding(modpath, True)\n\t\tIf FileType(m_modpath) = FILETYPE_DIR\n\t\t\tIf logchange Then logger.LogMessage(_s(\"message.setmodpath\", [m_modpath]))\n\t\tElse\n\t\t\tThrowError(_s(\"error.notfound.modpath\", [m_modpath]))\n\t\tEnd If\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the path to the BlitzMax installation.\n\t\treturns: Nothing.\n\t\tabout: This will throw an error if the path could not be found.\n\tEnd Rem\n\tMethod SetMaxPath(maxpath:String)\n\t\tm_maxpath = FixPathEnding(maxpath, True)\n\t\tm_binpath = m_maxpath + \"\/bin\"\n\t\tLocal bmk:String\n\t\t?Win32\n\t\t\tbmk = \"\/bmk.exe\"\n\t\t?Not Win32\n\t\t\tbmk = \"\/bmk\"\n\t\t?\n\t\tIf FileType(m_maxpath) = FILETYPE_NONE\n\t\t\tThrowError(_s(\"error.notfound.maxpath\", [m_maxpath]))\n\t\tElse If FileType(m_binpath + bmk) = FILETYPE_NONE\n\t\t\tThrowError(_s(\"error.notfound.bmk\", [m_binpath + bmk]))\n\t\tEnd If\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the sources url.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetSourcesUrl(url:String)\n\t\tm_sourcesurl = url\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the sources file.\n\t\treturns: Nothing.\n\t\tabout: NOTE: This will throw an error if the path is Null (and, later, a warning will be logged if the path does not exist).\n\tEnd Rem\n\tMethod SetSourcesFile(file:String)\n\t\tIf Not file\n\t\t\tThrowError(_s(\"error.sources.setfile\"))\n\t\tEnd If\n\t\tm_sourcesfile = file\n\tEnd Method\n\t\nEnd Type\n\nRem\n\tbbdoc: Throw an error (terminating the application).\n\treturns: Nothing.\nEnd Rem\nFunction ThrowError(error:String)\n\tlogger.LogError(error)\n\tmainapp.OnExit()\n\tEnd\nEnd Function\n\nRem\n\tbbdoc: Get the localized text for the given identifier.\n\treturns: The translated text.\nEnd Rem\nFunction _s:String(iden:String, extra:String[] = Null)\n\tGlobal replacer:dTextReplacer = New dTextReplacer\n\tLocal ltext:dLocalizedText\n\tIf mainapp.m_locale Then ltext = mainapp.m_locale.TextFromStructureL(iden)\n\tIf ltext Then ltext = mainapp.m_defaultlocale.TextFromStructureL(iden)\n\tIf ltext\n\t\treplacer.SetString(ltext.GetValue())\n\t\treplacer.AutoReplacements(\"{\", \"}\")\n\t\tIf extra\n\t\t\tLocal i:Int\n\t\t\tFor Local rep:dTextReplacement = EachIn replacer.GetList()\n\t\t\t\tIf i > extra.Length Then Exit\n\t\t\t\trep.SetReplacement(extra[i])\n\t\t\t\ti:+ 1\n\t\t\tNext\n\t\tEnd If\n\t\tReturn replacer.DoReplacements()\n\tElse\n\t\tDebugLog(\"Failed to find localized text from structure: ~q\" + iden + \"~q\")\n\tEnd If\n\tReturn Null\nEnd Function\n\n","old_contents":"\nSuperStrict\n\nFramework brl.blitz\nImport brl.standardio\nImport brl.maxutil\nImport brl.ramstream\n\nImport bah.volumes\nImport gman.zipengine\nImport htbaapub.rest\n\nImport duct.variables\nImport duct.objectmap\nImport duct.json\nImport duct.locale\nImport duct.clapp\nImport duct.time\n\nIncbin \"locales\/en.loc\"\n\nInclude \"src\/logger.bmx\"\nInclude \"src\/errors.bmx\"\nInclude \"src\/config.bmx\"\nInclude \"src\/dependencies.bmx\"\nInclude \"src\/module.bmx\"\nInclude \"src\/sources.bmx\"\nInclude \"src\/utils.bmx\"\nInclude \"src\/impl\/help.bmx\"\nInclude \"src\/impl\/version.bmx\"\nInclude \"src\/impl\/modpath.bmx\"\nInclude \"src\/impl\/install.bmx\"\nInclude \"src\/impl\/update.bmx\"\nInclude \"src\/impl\/list.bmx\"\n\nGlobal logger:mxLogger = New mxLogger\nGlobal mainapp:mxApp\nNew mxApp.Create() ' Skip the first element because it is the program's location\nmainapp.SetArgs(AppArgs[1..])\nmainapp.Run()\n\nRem\n\tbbdoc: Maximus app.\n\tabout: This handles the basic flow of the program (initiation, parsing, command calling, exiting..)\nEnd Rem\nType mxApp Extends dCLApp\n\t\n\tConst c_version:String = \"0.9.0\"\n\tConst c_configfile:String = \"maximus.config\"\n\t\n\tField m_apppath:String\n\tField m_maxpath:String, m_binpath:String, m_modpath:String\n\t\n\tField m_confighandler:mxConfigHandler\n\tField m_defaultlocale:dLocale, m_locale:dLocale\n\tField m_sourcesfile:String = \"sources\", m_sourcesurl:String = \"http:\/\/maximus.htbaa.com\/module\/sources\/json\"\n\tField m_useragent:String\n\tField m_autoupdatesources:Int = True\n\t\n\tField m_sourceshandler:mxSourcesHandler\n\t\n\tField m_updateimpl:mxUpdateImpl\n\tField m_sourcesupdated:Int\n\t\n\tRem\n\t\tbbdoc: Create a new mxApp.\n\t\treturns: Itself.\n\tEnd Rem\n\tMethod Create:mxApp()\n\t\tmainapp = Self\n\t\tSuper.Create()\n\t\tReturn Self\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Called when the application is created.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod OnInit()\n\t\tm_apppath = GetUserAppDir() + \"\/\"\n\t\t?Linux\n\t\tm_apppath:+ \".maximus\/\"\n\t\t?Not Linux\n\t\tm_apppath:+ \"maximus\/\"\n\t\t?\n\t\tIf FileType(m_apppath) = FILETYPE_NONE\n\t\t\tIf Not CreateDir(m_apppath, False)\n\t\t\t\tThrowError(_s(\"error.createperms\", [m_apppath]))\n\t\t\tEnd If\n\t\tEnd If\n\t\tChangeDir(m_apppath)\n\t\tm_confighandler = New mxConfigHandler.Create(m_apppath + c_configfile)\n\t\tm_confighandler.LoadDefaultLocale()\n\t\tm_confighandler.Load()\n\t\tIf Not m_maxpath\n\t\t\tTry\n\t\t\t\tSetMaxPath(BlitzMaxPath())\n\t\t\tCatch e:Object\n\t\t\t\tThrowError(_s(\"error.notfound.maxenv\"))\n\t\t\tEnd Try\n\t\tEnd If\n\t\tIf Not m_modpath Then SetModPath(m_maxpath + \"\/mod\", False)\n\t\tm_arghandler = New dArgumentHandler.Create()\n\t\tm_arghandler.AddArgImpl(New mxHelpImpl)\n\t\tm_arghandler.AddArgImpl(New mxVersionImpl)\n\t\tm_arghandler.AddArgImpl(New mxModPathImpl)\n\t\tm_arghandler.AddArgImpl(New mxInstallImpl)\n\t\tm_updateimpl = New mxUpdateImpl\n\t\tm_arghandler.AddArgImpl(m_updateimpl)\n\t\tm_arghandler.AddArgImpl(New mxListImpl)\n\t\tUpdateSources()\n\t\tm_sourceshandler = New mxSourcesHandler.FromFile(m_apppath + m_sourcesfile)\n\t\tIf Not m_sourceshandler\n\t\t\t' Don't throw an error here, the user may be updating the sources (an error will occur otherwise)\n\t\t\tlogger.LogWarning(_s(\"error.load.sources.file\", [m_apppath + m_sourcesfile]))\n\t\tEnd If\n\t\tLocal os:String\n\t\t?Win32\n\t\t\tos = \"Windows\"\n\t\t?Linux\n\t\t\tos = \"Linux\"\n\t\t?MacOS\n\t\t\tos = \"MacOS\"\n\t\t?\n\t\tm_useragent = \"Maximus\/\" + c_version + \" (\" + os + \"; \" + m_locale.GetName() + \")\"\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Called when the application is ended (this includes #ThrowError calls).\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod OnExit()\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Run the application.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod Run()\n\t\tLocal argimpl:dArgumentImplementation, isopt:Int\n\t\tFor Local arg:dIdentifier = EachIn m_arguments\n\t\t\targimpl = m_arghandler.GetArgImplWithAlias(arg.GetName())\n\t\t\tisopt = (arg.GetName()[0] = 45)\n\t\t\tIf argimpl\n\t\t\t\tIf isopt\n\t\t\t\t\targimpl.SetCallConvention(dCallConvention.OPTION)\n\t\t\t\t\targimpl.SetArgs(arg)\n\t\t\t\t\targimpl.CheckArgs()\n\t\t\t\t\targimpl.Execute()\n\t\t\t\tElse\n\t\t\t\t\targimpl.SetCallConvention(dCallConvention.COMMAND)\n\t\t\t\t\targimpl.SetArgs(arg)\n\t\t\t\t\targimpl.CheckArgs()\n\t\t\t\t\targimpl.Execute()\n\t\t\t\t\tExit\n\t\t\t\tEnd If\n\t\t\tElse\n\t\t\t\tIf isopt\n\t\t\t\t\tThrowCommonError(mxOptErrors.UNKNOWN, arg.GetName())\n\t\t\t\tElse\n\t\t\t\t\tThrowCommonError(mxCmdErrors.UNKNOWN, arg.GetName())\n\t\t\t\tEnd If\n\t\t\tEnd If\n\t\tNext\n\t\tRem\n\t\t' Test version snatching\n\t\tLocal time:Int = MilliSecs(), ver:String\n\t\tFor Local modid:String = EachIn mxModUtils.GetModules().KeyEnumerator()\n\t\t\tver = mxModUtils.GetInstalledVersionFromVerID(modid)\n\t\t\tIf ver And Not (ver = \"dev\")\n\t\t\t\tDebugLog(\"versioned-id: ~q\" + modid + \"\/\" + ver + \"~q\")\n\t\t\tElse If Not ver\n\t\t\t\tDebugLog(\"Failed to get version from \" + modid)\n\t\t\tEnd If\n\t\tNext\n\t\tDebugLog(\"timed: \" + mxModUtils.GetModules().Count() + \" modules in \" + (MilliSecs() - time) + \"ms\")\n\t\tEnd Rem\n\t\tOnExit()\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Update the sources list.\n\t\treturns: Nothing.\n\t\tabout: Updates when: the sources file is greater than 23 hours old; the sources file does not exist.\n\tEnd Rem\n\tMethod UpdateSources()\n\t\tIf m_autoupdatesources And Not m_sourcesupdated\n\t\t\tLocal ctime:dTime, ftime:dTime\n\t\t\tctime = New dTime.CreateFromCurrent()\n\t\t\tftime = New dTime.CreateFromFile(m_apppath + m_sourcesfile)\n\t\t\t'DebugLog(\"Auto-update file time: c\" + ctime.Get() + \" | \" + ftime.Get() + \", hours: \" + (ctime.Get() - ftime.Get()) \/ 3600)\n\t\t\tIf Not ftime Or (ctime.Get() - ftime.Get()) \/ 3600 > 23\n\t\t\t\tlogger.LogMessage(_s(\"arg.update.autoupdate\"))\n\t\t\t\tm_updateimpl.SetCallConvention(dCallConvention.COMMAND)\n\t\t\t\tm_updateimpl.SetArgs(New dIdentifier.Create())\n\t\t\t\tm_updateimpl.CheckArgs()\n\t\t\t\tm_updateimpl.Execute()\n\t\t\tEnd If\n\t\tEnd If\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the application's arguments.\n\t\treturns: Nothing.\n\t\tabout: NOTE: This will resolve to '--help' if the given args are Null.\n\tEnd Rem\n\tMethod SetArgs(args:String[])\n\t\tIf Not args\n\t\t\targs = [\"--help\"]\n\t\tEnd If\n\t\tParseArguments(args, False, 1)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the module path.\n\t\treturns: Nothing.\n\t\tabout: This will throw an error if the module path could not be found.\n\tEnd Rem\n\tMethod SetModPath(modpath:String, logchange:Int = True)\n\t\tm_modpath = FixPathEnding(modpath, True)\n\t\tIf FileType(m_modpath) = FILETYPE_DIR\n\t\t\tIf logchange Then logger.LogMessage(_s(\"message.setmodpath\", [m_modpath]))\n\t\tElse\n\t\t\tThrowError(_s(\"error.notfound.modpath\", [m_modpath]))\n\t\tEnd If\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the path to the BlitzMax installation.\n\t\treturns: Nothing.\n\t\tabout: This will throw an error if the path could not be found.\n\tEnd Rem\n\tMethod SetMaxPath(maxpath:String)\n\t\tm_maxpath = FixPathEnding(maxpath, True)\n\t\tm_binpath = m_maxpath + \"\/bin\"\n\t\tLocal bmk:String\n\t\t?Win32\n\t\t\tbmk = \"\/bmk.exe\"\n\t\t?Not Win32\n\t\t\tbmk = \"\/bmk\"\n\t\t?\n\t\tIf FileType(m_maxpath) = FILETYPE_NONE\n\t\t\tThrowError(_s(\"error.notfound.maxpath\", [m_maxpath]))\n\t\tElse If FileType(m_binpath + bmk) = FILETYPE_NONE\n\t\t\tThrowError(_s(\"error.notfound.bmk\", [m_binpath + bmk]))\n\t\tEnd If\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the sources url.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetSourcesUrl(url:String)\n\t\tm_sourcesurl = url\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the sources file.\n\t\treturns: Nothing.\n\t\tabout: NOTE: This will throw an error if the path is Null (and, later, a warning will be logged if the path does not exist).\n\tEnd Rem\n\tMethod SetSourcesFile(file:String)\n\t\tIf Not file\n\t\t\tThrowError(_s(\"error.sources.setfile\"))\n\t\tEnd If\n\t\tm_sourcesfile = file\n\tEnd Method\n\t\nEnd Type\n\nRem\n\tbbdoc: Throw an error (terminating the application).\n\treturns: Nothing.\nEnd Rem\nFunction ThrowError(error:String)\n\tlogger.LogError(error)\n\tmainapp.OnExit()\n\tEnd\nEnd Function\n\nRem\n\tbbdoc: Get the localized text for the given identifier.\n\treturns: The translated text.\nEnd Rem\nFunction _s:String(iden:String, extra:String[] = Null)\n\tGlobal replacer:dTextReplacer = New dTextReplacer\n\tLocal ltext:dLocalizedText\n\tIf mainapp.m_locale Then ltext = mainapp.m_locale.TextFromStructureL(iden)\n\tIf ltext Then ltext = mainapp.m_defaultlocale.TextFromStructureL(iden)\n\tIf ltext\n\t\treplacer.SetString(ltext.GetValue())\n\t\treplacer.AutoReplacements(\"{\", \"}\")\n\t\tIf extra\n\t\t\tLocal i:Int\n\t\t\tFor Local rep:dTextReplacement = EachIn replacer.GetList()\n\t\t\t\tIf i > extra.Length Then Exit\n\t\t\t\trep.SetReplacement(extra[i])\n\t\t\t\ti:+ 1\n\t\t\tNext\n\t\tEnd If\n\t\tReturn replacer.DoReplacements()\n\tElse\n\t\tDebugLog(\"Failed to find localized text from structure: ~q\" + iden + \"~q\")\n\tEnd If\n\tReturn Null\nEnd Function\n\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"35f9f498f04a31b050fe37cb1af6e32c933a75a1","subject":"reducemovs taking proper account of SETTAB*","message":"reducemovs taking proper account of SETTAB*\n","repos":"Leushenko\/blue-moon","old_file":"bluecompiler.bmx","new_file":"bluecompiler.bmx","new_contents":"\n' Blue Moon\n' Bytecode compiler: accepts program fragments as strings, or program files (and outputs)\n\nSuperStrict\n\nImport \"blueparser.bmx\"\nImport \"blueerror.bmx\"\nImport \"blueversion.bmx\"\nPrivate\nInclude \"TFold.bmx\"\nInclude \"bluefoldsyntax.bmx\"\nInclude \"bluefoldsemantics.bmx\"\nInclude \"bluefoldcodegen.bmx\"\nInclude \"debugfold.bmx\"\nPublic\n\nType BlueCompiler\n\tFunction CompileFile(infile:String, outfile:String = \"\")\n\t\tIf outfile = \"\" Then outfile = infile + \".so\"\n\t\tLocal n:TParseNode = BlueParseFile(infile)\n\t\tLocal compiled:BlueBinary = BlueBinary.Make(infile, ASTToAssembly(n))\n\t\tcompiled.WriteObjectFile(outFile)\n\tEnd Function\n\t\n\tFunction CompileFileForLoad:BlueBinary(infile:String)\n\t\tLocal n:TParseNode = BlueParseFile(infile)\n\t\tLocal code:BlueBinary = BlueBinary.Make(infile, ASTToAssembly(n))\n\t\tLocal sz:Int, mem:Byte Ptr = code.WriteMemory(sz)\n\t\tcode = code.ReadMemory(mem, sz) ; MemFree(mem)\n\t\tReturn code\n\tEnd Function\n\t\n'\tFunction CompileString:BlueBinary(program:String)\n'\t\tLocal n:TParseNode = BlueParseString(program)\n'\t\tReturn BlueBinary.Make(\"\", ASTToAssembly(n))\n'\tEnd Function\n\t\n\tFunction ShowBytecode:String(infile:String)\n\t\tLocal n:TParseNode = BlueParseFile(infile), out:String = infile + \":~n\"\n\t\tLocal assemblies:TList = ASTToAssembly(n)\n\t\tFor Local f:BlueAssembly = EachIn assemblies\n\t\t\tout :+ f.ToString()\n\t\tNext\n\t\tReturn out\n\tEnd Function\n\t\n\tFunction ASTToAssembly:TList(n:TParseNode)\n\t\tLocal tbl:NodeTable = Node.FromParse(n), r:Node = tbl.n\n\t\t\n\t\tr = Node.Fold(r, NormalizeFold.Make(tbl))\n\t\t\n\t\tLocal errf:SyntaxErrFold = SyntaxErrFold.Make(tbl)\n\t\tr = Node.Fold(r, errf) ; errf.BreakCheck()\n\t\t\n\t\tr = Node.Fold(r, New ConstantFold)\n\t\t\n\t\tLocal semf:SemanticFold = SemanticFold.Make(r, tbl)\n\t\tr = Node.Fold(r, semf, Node.BOTH)\t'fold both ways to push and pop environments\n\t\tSemanticFold.Close(semf, r)\n\t\t\n\t\tLocal funs:FunDef[] = FunDef[](semf.funs.ToArray()) ; semf = Null\n\t\t\n\t\t' if we wanted a type checker, it would go here\n\t\ttbl = Null\t'source information no longer needed\n\t\t\n\t\tLocal assemblies:TList = CreateList()\n\t\tFor Local f:FunDef = EachIn funs\n\t\t\tLocal com:CompileFold = CompileFold.Make(BlueAssembly.Make(f))\n\t\t'\tPrint \"F #\" + f.id + \": \" + f.n.ToString()\n\t\t\tLocal inst:TList = BytecodeNode(Node.Fold(f.n, com)).inst\n\t\t\tcom.f.Finish(inst, com.opc)\n\t\t\tassemblies.AddLast(com.f)\n\t\tNext\n\t\t\n\t\t?Debug\n\t\tDebug_KeyListFold.Run(funs, CompileFold.Make(Null))\n\t\t?\n\t\tReturn assemblies\n\tEnd Function\nEnd Type\n\nType BlueOpcode Final\n\tField MOV:Int = 0, GETLC:Int = 1, SETLC:Int = 2\t\t'these are constants, ignore their definition as fields\n\tField LOADK:Int = 3, LOADSI:Int = 4, LOADBOOL:Int = 5, LOADNIL:Int = 6\n\t\n\tField GETTAB:Int = 7, GETTABSI:Int = 8, SETTAB:Int = 9, SETTABSI:Int = 10\n\tField GETTABI:Int = 11, SETTABI:Int = 12, GETUPV:Int = 13, SETUPV:Int = 14\n\tField NEWTAB:Int = 15, CLOSURE:Int = 16, NEWUPV:Int = 17\n\t\n\tField ADD:Int = 18, SUB:Int = 19, MUL:Int = 20, DIV:Int = 21, NMOD:Int = 22, POW:Int = 23, CAT:Int = 24\n\tField IDIV:Int = 25, BAND:Int = 26, BOR:Int = 27, BXOR:Int = 28, BSHL:Int = 29, BSHR:Int = 30\n\tField UNM:Int = 31, LNOT:Int = 32, ALEN:Int = 33, BNOT:Int = 34, UNP:Int = 35\n\tField EQ:Int = 36, LT:Int = 37, LEQ:Int = 38\n\t\n\tField JMP:Int = 39, JIF:Int = 40, JNOT:Int = 41\n\tField CALL:Int = 42, TCALL:Int = 43, RET:Int = 44, RETVA:Int = 45\n\tField POSTCALL:Int = 46, VARARG:Int = 47, VAINIT:Int = 48, CALLINIT:Int = 49\n\t\n\tFunction Make:Int(i:BlueInstr)\n\t\tGlobal opc:BlueOpcode = New Self\n\t\tLocal c:Int = i.c\n\t\tSelect i.op\n\t\t\tCase opc.LOADK, opc.LOADSI, opc.LOADBOOL, opc.LOADNIL, opc.JMP, opc.JIF, opc.JNOT, opc.RET\n\t\t\t\tIf c < 0 Then c :& (Int(2^18) - 1)\n\t\t\t\tReturn i.op | ((i.ra & $FF) Shl 6) | (c Shl 14)\n\t\t\tDefault\n\t\t\t\tIf c < 0 Then c :& (Int(2^10) - 1)\n\t\t\t\tReturn i.op | ((i.ra & $FF) Shl 6) | ((i.rb & $FF) Shl 14) | (c Shl 22)\n\t\tEnd Select\n\tEnd Function\n\tFunction Read(i:Int, op:Int Var, ra:Int Var, rb:Int Var, c:Int Var)\n\t\tGlobal opc:BlueOpcode = New Self\n\t\top = i & %111111 ; ra = (i Shr 6) & $FF\n\t\tSelect op\n\t\t\tCase opc.LOADK, opc.LOADSI, opc.LOADBOOL, opc.LOADNIL, opc.JMP, opc.JIF, opc.JNOT, opc.RET\n\t\t\t\trb = 0 ; c = i Sar 14\t'sign-extend (already MSB)\n\t\t\tDefault\n\t\t\t\trb = (i Shr 14) & $FF ; c = i Sar 22\n\t\tEnd Select\n\tEnd Function\nEnd Type\n\nType BlueInstr\n\tField op:Int, ra:Int, rb:Int, c:Int\n\tFunction Make:BlueInstr(op:Int, ra:Int, rb:Int, c:Int = 0)\n\t\tLocal i:BlueInstr = New BlueInstr ; i.op = op ; i.ra = ra ; i.rb = rb ; i.c = c ; Return i\n\tEnd Function\n\tFunction MakeK:BlueInstr(op:Int, ra:Int, c:Int)\n\t\tReturn Make(op, ra, 0, c)\n\tEnd Function\n\tMethod ToString:String()\n\t\tGlobal opc:BlueOpcode = New BlueOpcode\n\t\tLocal n:String = \"??\"\n\t\tFor Local f:TField = EachIn TTypeId.ForObject(opc).Fields()\n\t\t\tIf f.GetInt(opc) = op Then n = f.Name()[..10] ; Exit\n\t\tNext\n\t\tSelect op\n\t\t\tCase opc.LOADNIL, opc.NEWUPV, opc.NEWTAB\n\t\t\t\tReturn n + \" \" + ra\n\t\t\tCase opc.MOV, opc.SETLC, opc.GETLC, opc.SETUPV, opc.GETUPV\n\t\t\t\tReturn n + \" \" + ra + \", \" + rb\n\t\t\tCase opc.LOADK, opc.LOADSI, opc.LOADBOOL, opc.CLOSURE, opc.RET, opc.POSTCALL, opc.VARARG\n\t\t\t\tReturn n + \" \" + ra + \", \" + c\n\t\t\tDefault ; Return n + \" \" + ra + \", \" + rb + \", \" + c\n\t\tEnd Select\n\tEnd Method\nEnd Type\n\nType BlueBinary\n\tConst MAGICNUMBER:Long = 5642816051412814914:Long\t'BLUEMOON\n\tField out:Int[], buf:Int[]\t'out = output bytestream, buf = input\/readable bytestream\n\t\n\tFunction Make:BlueBinary(file:String, funs:TList)\n\t\tLocal b:BlueBinary = New Self, ktbl:TList = CreateList(), kc:Int = 0\n\t\t\n\t\tLocal binSz:Int = 0, fcount:Int = 0\n\t\tFor Local f:BlueAssembly = EachIn funs\n\t\t\tLocal ki:Int = 0\n\t\t\tFor Local k:String = EachIn f.ktbl\n\t\t\t\tf.kidx[ki] = AddKTblEntry(k, ktbl, kc) ; ki :+ 1\t'consolidate constants into single table\n\t\t\tNext\n\t\t\t\n\t\t\tIf f.framesz > f.MAXVARS - 3 Or f.upvars > f.MAXVARS Then Throw ..\n\t\t\t\tBlueAssemblyError.Make(file, \"too many variables\/temporaries in function #\" + f.id ..\n\t\t\t\t+ \"; consider splitting into more blocks or helper functions\")\n\t\t\t\n\t\t\tbinSz :+ (7 ..\t'id, instruction count, k count, param count, var count, upvar count, frame size\n\t\t\t + 2 * f.upvars ..\t'upvar levels and stack positions (interleaved)\n\t\t\t + f.kc ..\t'constant index table\n\t\t\t + f.inst.Count())\t'instructions\n\t\t\tfcount :+ 1\n\t\tNext\n\t\t\n\t\tbinSz :+ (kc + 1)\n\t\tFor Local k:String = EachIn ktbl\n\t\t\tIf k[0] = \"0\"[0] Then binSz :+ 2 Else binSz :+ Ceil((k.Length - 2) \/ 2.0) + 2\n\t\tNext\n\t\t\n\t\tLocal headerSz:Int = 3 + fcount\t'function count, k count, k table offset, function offset list\n\t\tbinSz :+ headerSz\n\t\t\n\t\tLocal out:Int[] = New Int[binSz] ; b.out = out\n\t\tout[0] = fcount\n\t\tout[1] = kc\n\t\t\n\t\tLocal pos:Int = headerSz, opc:BlueOpcode = New BlueOpcode\n\t\tFor Local f:BlueAssembly = EachIn funs\n\t\t\tout[3 + f.id] = pos\n\t\t\tout[pos] = f.id ; out[pos + 1] = f.inst.Count() ; out[pos + 2] = f.kc ; out[pos + 3] = f.params\n\t\t\tout[pos + 4] = f.vars ; out[pos + 5] = f.upvars ; out[pos + 6] = f.framesz\n\t\t\tpos :+ 7\n\t\t\tFor Local v:Int = 0 Until f.upvars\n\t\t\t\tout[pos] = f.upvarTier[v] ; out[pos + 1] = f.upvarStkPos[v] ; pos :+ 2\n\t\t\tNext\n\t\t\tFor Local k:Int = 0 Until f.kc\n\t\t\t\tout[pos] = f.kidx[k] ; pos :+ 1\n\t\t\tNext\n\t\t\tFor Local i:BlueInstr = EachIn f.inst\n\t\t\t\tout[pos] = BlueOpcode.Make(i) ; pos :+ 1\n\t\t\tNext\n\t\tNext\n\t\t\n\t\tout[2] = pos ; Local ktblpos:Int = pos ; pos :+ (kc + 1)\n\t\tFor Local k:String = EachIn ktbl\n\t\t\tLocal d:Double, dp:Byte Ptr = Varptr(d)\n\t\t\tout[ktblpos] = pos ; ktblpos :+ 1\n\t\t\tIf k[0] = \"0\"[0]\n\t\t\t\td = Double(k[2..])\n\t\t\t\tout[pos] = Int Ptr(dp)[0] ; out[pos + 1] = Int Ptr(dp)[1]\n\t\t\t\tpos :+ 2\n\t\t\tElse\n\t\t\t\td = k.Length - 2\n\t\t\t\tout[pos] = Int Ptr(dp)[0] ; out[pos + 1] = Int Ptr(dp)[1] ; pos :+ 2\n\t\t\t\tIf k.Length Mod 2 = 1 Then k :+ \" \"\t'even the length for ease of writing\n\t\t\t\tFor Local c:Int = 2 Until k.Length Step 2\n\t\t\t\t\tout[pos] = Short(k[c]) | (Short(k[c + 1]) Shl 16) ; pos :+ 1\n\t\t\t\tNext\n\t\t\tEndIf\n\t\tNext\n\t\tout[ktblpos] = pos\n\t\tAssert pos = binSz, \"assembly write error: binary size mismatch (critical compiler error)\"\n\t\t\n\t\tReturn b\n\tEnd Function\n\t\n\tFunction AddKTblEntry:Int(k:String, tbl:TList, kc:Int Var)\n\t\tLocal ki:Int = 0\n\t\tFor Local ek:String = EachIn tbl\n\t\t\tIf ek = k Then Return ki\n\t\t\tki :+ 1\n\t\tNext\n\t\ttbl.AddLast(k) ; kc :+ 1'ktbl.Count()\n\t\tReturn ki\n\tEnd Function\n\t\n\tMethod WriteMemory:Byte Ptr(size:Int Var)\n\t\tsize = out.Length * 8 + 16\n\t\tLocal mem:Byte Ptr = MemAlloc(size)\n\t\tAssert mem, \"failed to allocate memory for instruction buffer\"\n\t\tWrite(CreateRamStream(mem, out.Length * 8 + 16, 0, 1))\n\t\tReturn mem\n\tEnd Method\n\t\n\tMethod WriteObjectFile(filename:String)\n\t\tWrite(WriteFile(filename))\n\tEnd Method\n\t\n\tFunction ReadMemory:BlueBinary(mem:Byte Ptr, size:Int)\n\t\tReturn Read(CreateRamStream(mem, size, 1, 0), \"\", size)\n\tEnd Function\n\t\n\tFunction ReadObjectFile:BlueBinary(filename:String)\n\t\tReturn Read(ReadFile(filename), filename, FileSize(filename))\n\tEnd Function\n\t\n\tFunction Read:BlueBinary(file:TStream, filename:String, sz:Int)\n\t\tLocal b:BlueBinary\n\t\tTry\n\t\t\tLocal opc:BlueOpcode = New BlueOpcode\n\t\t\tLocal corrupt:BlueAssemblyError = BlueAssemblyError.Make(filename, \"not a valid Blue Moon binary file (possibly corrupt)\")\n\t\t\tLocal badInst:BlueError = corrupt.Make(filename, \"invalid Blue Moon instruction (out of bounds error); could not load file\")\n\t\t\tsz :- (8 + 8) ; If sz < 12 Or (sz Mod 4 <> 0) Then Throw corrupt\n\t\t\t\n\t\t\tLocal magic:Long = file.ReadLong() ; If magic <> MAGICNUMBER Then Throw corrupt\n\t\t\tLocal major:Int = file.ReadInt()\n\t\t\tIf major <> BlueMoonVersion.MAJORVERSION Then Throw corrupt.Make(filename, \"incompatible major version of interpreter for bytecode\")\n\t\t\tLocal minor:Int = file.ReadInt()\n\t\t\tIf minor > BlueMoonVersion.MINORVERSION Then Throw corrupt.Make(filename, \"incompatible version of interpreter for bytecode\")\n\t\t\t\n\t\t\tLocal fc:Int = file.ReadInt(), kc:Int = file.ReadInt(), koffs:Int = file.ReadInt(), headerSz:Int = 3 + fc\n\t\t\tsz :\/ 4 ; If sz < headerSz + fc * 7 Or sz < koffs + kc * 3 Then Throw corrupt\n\t\t\t\n\t\t\tLocal bufSz:Int = headerSz + (koffs - headerSz) * 2 + (sz - koffs), buf:Int[bufSz]\n\t\t\tbuf[0] = fc ; buf[1] = kc ; buf[2] = koffs\n\t\t\t\n\t\t\tFor Local fi:Int = 0 Until fc\n\t\t\t\tLocal foff:Int = file.ReadInt() ; If sz < foff Then Throw corrupt\n\t\t\t\tbuf[3 + fi] = headerSz + (foff - headerSz) * 2\n\t\t\tNext\n\t\t\t\n\t\t\tLocal pos:Int = headerSz, sizeExtension:Int = 0\n\t\t\tFor Local fi:Int = 0 Until fc\n\t\t\t'binSz :+ (7 ..\t'id, instruction count, k count, param count, var count, upvar count, frame size\n\t\t\t ' + 2 * f.upvars ..\t'upvar levels and stack positions (interleaved)\n\t\t\t ' + f.kc ..\t'constant index table\n\t\t\t ' + f.inst.Count())\t'instructions\n\t\t\t\tLocal id:Int = file.ReadInt(), icount:Int = file.ReadInt(), kcount:Int = file.ReadInt(), pcount:Int = file.ReadInt()\n\t\t\t\tLocal vars:Int = file.ReadInt(), upvars:Int = file.ReadInt(), framesz:Int = file.ReadInt()\n\t\t\t\tIf pos <> buf[3 + fi] Or id <> fi Or (icount|kcount|pcount|vars|upvars|framesz) < 0 Then Throw corrupt\n\t\t\t\tbuf[pos] = id ; buf[pos + 1] = icount ; buf[pos + 2] = kcount ; buf[pos + 3] = pcount\n\t\t\t\tbuf[pos + 4] = vars ; buf[pos + 5] = upvars ; buf[pos + 6] = framesz ; pos :+ 7\n\t\t\t\tIf (pos - sizeExtension) + 2 * upvars + kcount + icount > sz Then Throw corrupt\n\t\t\t\tsizeExtension :+ (7 + 2 * upvars + kcount + icount) * 2\n\t\t\t\t\n\t\t\t\tFor Local up:Int = 0 Until upvars\n\t\t\t\t\tbuf[pos] = file.ReadInt() ; buf[pos + 1] = file.ReadInt() ; pos :+ 2\n\t\t\t\tNext\n\t\t\t\tFor Local ki:Int = 0 Until kcount\n\t\t\t\t\tbuf[pos] = file.ReadInt()\n\t\t\t\t\tIf buf[pos] >= kc Then Throw corrupt\n\t\t\t\t\tpos :+ 1\n\t\t\t\tNext\n\t\t\t\t\n\t\t\t\tFor Local i:Int = 0 Until icount\n\t\t\t\t\tLocal in:Int = file.ReadInt(), op:Int, ra:Int, rb:Int, c:Int\n\t\t\t\t\tBlueOpcode.Read(in, op, ra, rb, c)\n\t\t\t\t\t\n\t\t\t\t\tSelect op\t\t'verify operation as not going out of bounds!\n\t\t\t\t\t\tCase opc.RETVA\t'ignore\n\t\t\t\t\t\tCase opc.JMP, opc.JNOT, opc.JIF\n\t\t\t\t\t\t\tIf i + c >= icount Or i + c < 0 Then Throw badinst\n\t\t\t\t\t\tCase opc.CALL, opc.TCALL\n\t\t\t\t\t\t\tIf Max(ra, rb + c) >= framesz Or Min(ra, Min(rb, c)) < 0 Then Throw badInst\n\t\t\t\t\t\tCase opc.RET, opc.POSTCALL\n\t\t\t\t\t\t\tIf ra + c >= framesz Or ra < 0 Or c < 0 Then Throw badInst\n\t\t\t\t\t\tCase opc.GETUPV\n\t\t\t\t\t\t\tIf ra >= framesz Or ra < 0 Or rb >= upvars Or rb < 0 Then Throw badInst\n\t\t\t\t\t\tCase opc.SETUPV\n\t\t\t\t\t\t\tIf rb >= framesz Or rb < 0 Or ra >= upvars Or ra < 0 Then Throw badInst\n\t\t\t\t\t\tDefault\n\t\t\t\t\t\t\tIf ra >= framesz Or rb >= framesz Or ra < 0 Or rb < 0 Then Throw badInst\n\t\t\t\t\t\t\tIf (op >= opc.ADD And op <= opc.BSHR) Or (op >= opc.EQ And op <= opc.LEQ)\n\t\t\t\t\t\t\t\tIf c >= framesz Or c < 0 Then Throw badInst\n\t\t\t\t\t\t\tElse\n\t\t\t\t\t\t\t\tSelect op\n\t\t\t\t\t\t\t\t\tCase opc.GETTAB, opc.SETTAB, opc.LOADK\n\t\t\t\t\t\t\t\t\t\tIf c >= kcount Or c < 0 Then Throw badInst\n\t\t\t\t\t\t\t\t\tCase opc.VARARG', opc.VAINIT, opc.CALLINIT\n\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\tCase opc.CLOSURE\n\t\t\t\t\t\t\t\t\t\tIf c >= fc Or c < 0 Then Throw badInst\n\t\t\t\t\t\t\t\tEnd Select\n\t\t\t\t\t\t\tEndIf\n\t\t\t\t\tEnd Select\n\t\t\t\t\t\n\t\t\t\t\tbuf[pos] = op | (ra Shl 8) | (rb Shl 16) ; buf[pos + 1] = c\n\t\t\t\t\tpos :+ 2\n\t\t\t\tNext\n\t\t\t\t\n\t\t\t\tpos :+ (7 + 2 * upvars + kcount)\t'unused space because of buffer doubling\n\t\t\tNext\n\t\t\t\n\t\t\tsizeExtension :\/ 2\n\t\t\tIf pos - sizeExtension <> koffs Then Throw corrupt\n\t\t\tbuf[2] = pos\t'update koffs\n\t\t\tFor Local ki:Int = 0 To kc\t'[sic] - we need to copy the end marker too\n\t\t\t\tLocal koff:Int = file.ReadInt() ; If sz < koff Or koff < koffs + kc + 1 Then Throw corrupt\n\t\t\t\tbuf[pos] = koff + sizeExtension ; pos :+ 1\n\t\t\tNext\n\t\t\tFor Local ki:Int = 0 Until kc\n\t\t\t\tLocal d:Double = file.ReadDouble(), dp:Int Ptr = Int Ptr(Varptr(d))\n\t\t\t\tbuf[pos] = dp[0] ; buf[pos + 1] = dp[1] ; pos :+ 2\n\t\t\t\tIf pos <> buf[koffs + sizeExtension + ki + 1]\t'string\n\t\t\t\t\tFor Local c:Int = 0 Until Ceil(d \/ 2)\n\t\t\t\t\t\tbuf[pos + c] = file.ReadInt()\n\t\t\t\t\tNext\n\t\t\t\t\tpos :+ Ceil(d \/ 2)\n\t\t\t\tEndIf\n\t\t\tNext\n\t\t\t\n\t\t\tb = New Self ; b.buf = buf\n\t\tCatch o:Object\n\t\t\tCloseStream(file) ; Throw o\n\t\tEnd Try\n\t\tCloseStream(file)\n\t\tReturn b\n\tEnd Function\n\t\n\tMethod Write(file:TStream)\n\t\tTry\n\t\t\tfile.WriteLong MAGICNUMBER\n\t\t\tfile.WriteInt BlueMoonVersion.MAJORVERSION ; file.WriteInt BlueMoonVersion.MINORVERSION\n\t\t\tFor Local i:Int = 0 Until out.Length\n\t\t\t\tfile.WriteInt out[i]\n\t\t\tNext\n\t\tCatch o:Object\n\t\t\tCloseStream(file) ; Throw o\n\t\tEnd Try\n\t\tCloseStream(file)\n\tEnd Method\nEnd Type\n\nType BlueAssembly\n\tConst MAXVARS:Int = 255, SI_LIMIT:Int = 131071, VSI_LIMIT:Int = 511\n\tField fd:FunDef, id:Int\n\tField vsp:Int\n\tField ktbl:TList, kc:Int, kidx:Int[]\n\tField inst:TList\n\tField lbl:LabelDef[], gto:GotoDef[]\n\tField params:Int, vars:Int, upvars:Int, framesz:Int, upvarTier:Int[], upvarStkPos:Int[]\n\t\n\tFunction Make:BlueAssembly(fd:FunDef)\n\t\tLocal f:BlueAssembly = New BlueAssembly\n\t\tf.fd = fd ; f.id = fd.id\n\t\tf.params = fd.pcount ; f.vars = fd.vmax ; f.upvars = fd.clos.Length\n\t\tf.vsp = f.vars '+ f.upvars\n\t\tf.upvarTier = New Int[f.upvars] ; f.upvarStkPos = New Int[f.upvars]\n\t\tFor Local v:Int = 0 Until f.upvars\n\t\t\tLocal el:Int = 1, env:FunDef = fd.env\n\t\t\tIf env\n\t\t\t\tf.upvarStkPos[v] = -1\n\t\t\t\tFor Local l:Int = 0 Until env.vars.Length\n\t\t\t\t\tIf env.vars[l] = fd.clos[v] Then f.upvarStkPos[v] = l ; Exit\n\t\t\t\tNext\n\t\t\t\tIf f.upvarStkPos[v] = -1\n\t\t\t\t\tFor Local c:Int = 0 Until env.clos.Length\n\t\t\t\t\t\tIf env.clos[c] = fd.clos[v]\n\t\t\t\t\t\t\tf.upvarTier[v] = 1 ; f.upvarStkPos[v] = c ; Exit\n\t\t\t\t\t\tEndIf\n\t\t\t\t\tNext\n\t\t\t\t\tAssert f.upvarStkPos[v] <> -1, \"compile error: unable to resolve closure (critical compiler error)\"\n\t\t\t\tEndIf\n\t\t\tElse\n\t\t\t\tf.upvarTier[v] = -1 ; f.upvarStkPos[v] = 0\n\t\t\tEndIf\n\t\tNext\n\t\tf.ktbl = CreateList() ; f.kc = 0\n\t\tReturn f\n\tEnd Function\n\t\n\tMethod Push:Int(n:Int = 1)\n\t\tvsp :+ n ; Return vsp - 1\n\tEnd Method\n\tMethod Pop:Int(n:Int = 1)\n\t\tvsp :- n ; Return vsp\n\tEnd Method\n\tMethod Peek:Int()\n\t\tReturn vsp - 1\n\tEnd Method\n\t\n\tMethod GetConst:Int(t:String, val:String)\n\t\tReturn BlueBinary.AddKTblEntry(t + \":\" + val, ktbl, kc)\n\tEnd Method\n\t\n\tMethod ToString:String()\n\t\tLocal s:String = \"F: \" + id + \"~n\"\n\t\ts :+ \" Constants:~n\"\n\t\tFor Local k:String = EachIn ktbl\n\t\t\ts :+ \" \" + k + \"~n\"\n\t\tNext\n\t\ts :+ \" Upvars:~n\"\n\t\tFor Local v:Int = 0 Until upvars\n\t\t\ts :+ \" \" + upvarTier[v] + \"\/\" + upvarStkPos[v] + \"~n\"\n\t\tNext\n\t\ts :+ \" Instructions:~n\"\n\t\tFor Local i:BlueInstr = EachIn inst\n\t\t\ts :+ \" \" + i.ToString() + \"~n\"\n\t\tNext\n\t\tReturn s\n\tEnd Method\n\t\n\tMethod Finish(_inst:TList, opc:BlueOpcode)\n\t\tinst = _inst\n\t\tlbl = LabelDef[](fd._lt.ToArray())\n\t\tgto = GotoDef[](fd._gt.ToArray())\n\t\t\n\t\t' allow closures over parameters\n\t\tFor Local p:Int = params - 1 To 0 Step -1\n\t\t\tIf fd.vars[p].isClosure Then inst.AddFirst(BlueInstr.Make(opc.NEWUPV, fd.vars[p].stkpos, 0))\n\t\tNext\n\t\t\n\t\t' add final return so that jumps don't run off the end\n\t\tinst.AddLast BlueInstr.Make(opc.RET, 0, 0, 0)\n\t\t' remove redundant MOV instructions\n\t\tSelf.ReduceMovs(opc)\n\t\t' resolve targeted jumps and remove dummy target instructions\n\t\tSelf.ResolveJumps(opc)\n\t\t' resolve break jumps and remove dummy target instructions\n\t\tSelf.ResolveBreaks(opc)\n\t\t\n\t\tframesz = vars'upvars + vars\n\t\tFor Local i:BlueInstr = EachIn inst\n\t\t\tSelect i.op\n\t\t\t\tCase opc.JMP, opc.VARARG, opc.VAINIT, opc.CALLINIT, opc.RETVA\t'ignore\n\t\t\t\tCase opc.CALL, opc.TCALL\n\t\t\t\t\tframesz = Max(framesz, Max(i.ra, i.rb + i.c) + 1)\n\t\t\t\tCase opc.RET, opc.POSTCALL\n\t\t\t\t\tframesz = Max(framesz, i.ra + i.c + 1)\n\t\t\t\tDefault\n\t\t\t\t\tframesz = Max(framesz, i.ra + 1)\n\t\t\tEnd Select\n\t\tNext\n\t\t\n\t\tkidx = New Int[kc]\n\t\tfd = Null\n\tEnd Method\n\t\n\tMethod ResolveJumps(opc:BlueOpcode)\n\t\tLocal il:TLink = inst.FirstLink(), i:Int = 0\n\t\tWhile il\n\t\t\tLocal in:BlueInstr = BlueInstr(il.Value())\n\t\t\tIf in.op = opc.MOV And in.ra = 0 And in.rb = 0\n\t\t\t\tLocal lab:LabelDef = lbl[in.c]\n\t\t\t\tlab.insl = il ; lab.insc = i\n\t\t\tElseIf Not (in.op = opc.MOV And in.ra = in.rb)\n\t\t\t\ti :+ 1\n\t\t\tEndIf\n\t\t\til = il.NextLink()\n\t\tWend\n\t\ti = 0 ; il = inst.FirstLink()\n\t\tWhile il\n\t\t\tLocal in:BlueInstr = BlueInstr(il.Value())\n\t\t\tIf (in.op >= opc.JMP And in.op <= opc.JNOT) And in.c >= 0\n\t\t\t\tLocal jmp:GotoDef = gto[in.c]\n\t\t\t\tin.c = jmp.tgt.insc - i ; jmp.tgt.insl.Remove()\n\t\t\tEndIf\n\t\t\tIf Not (in.op = opc.MOV And in.ra = in.rb) Then i :+ 1\n\t\t\til = il.NextLink()\n\t\tWend\n\tEnd Method\n\t\n\tMethod ResolveBreaks(opc:BlueOpcode)\n\t\tLocal il:TLink = inst.FirstLink()\n\t\tWhile il\n\t\t\tLocal in:BlueInstr = BlueInstr(il.Value())\n\t\t\tIf in.op = opc.JMP And in.ra = -1\n\t\t\t\tLocal tgl:TLink = il.NextLink(), cnt:Int = 1\n\t\t\t\tWhile True\n\t\t\t\t\tLocal tgt:BlueInstr = BlueInstr(tgl.Value())\n\t\t\t\t\tIf tgt.op = opc.MOV And tgt.c = -1\n\t\t\t\t\t\tin.ra = 0 ; in.rb = 0 ; in.c = cnt ; Exit\n\t\t\t\t\tEndIf\n\t\t\t\t\ttgl = tgl.NextLink() ; cnt :+ 1\n\t\t\t\tWend\n\t\t\tEndIf\n\t\t\til = il.NextLink()\n\t\tWend\n\t\til = inst.FirstLink()\t'remove break point markers\n\t\tWhile il\n\t\t\tLocal in:BlueInstr = BlueInstr(il.Value())\n\t\t\tIf in.op = opc.MOV And in.c = -1 Then il.Remove()\n\t\t\til = il.NextLink()\n\t\tWend\n\tEnd Method\n\t\n\tMethod ReduceMovs(opc:BlueOpcode)\n\t\tFunction replaceMov1:TLink(ml:TLink Var, in:BlueInstr, ra:Int, rb:Int, c:Int)\t'update a later instruction and then go back to look for more MOVs\n\t\t\tLocal ret:TLink = ml.PrevLink()\t'won't be null\n\t\t\tml.Remove() ; ml = Null\n\t\t\tin.ra = ra ; in.rb = rb ; in.c = c\n\t\t\tReturn ret\n\t\tEnd Function\n\t\t\n\t\t'first MOVs from variables to temps\n\t\tLocal ml:TLink, mov:BlueInstr, il:TLink = inst.FirstLink(), vmax:Int = fd.vmax, tmpStk:Int = vmax' + fd.clos.Length\n\t\tWhile il\n\t\t\tLocal in:BlueInstr = BlueInstr(il.Value())\n\t\t\tIf in.op = opc.MOV\t'if it's a move to temp space and nothing is pending\n\t\t\t\tIf in.ra = in.rb\t'jump target; do not cross\n\t\t\t\t\tml = Null\n\t\t\t\tElseIf ml = Null And in.ra >= tmpStk And in.rb < vmax\n\t\t\t\t\tml = il ; mov = BlueInstr(ml.Value())\n\t\t\t\tElseIf ml <> Null And in.rb = mov.ra And in.ra <> mov.rb\n\t\t\t\t\til = replaceMov1(ml, in, in.ra, mov.rb, in.c)\n\t\t\t\tEndIf\n\t\t\tElseIf ml <> Null\n\t\t\t\tIf in.op >= opc.JMP\t'any control-flow related op cancels\n\t\t\t\t\tIf (in.op = opc.JIF Or in.op = opc.JNOT) And mov.ra = in.ra Then il = replaceMov1(ml, in, mov.rb, in.rb, in.c) Else il = ml\n\t\t\t\t\tml = Null\n\t\t\t\tElseIf in.op = opc.GETTAB Or in.op = opc.GETTABSI Or (in.op >= opc.UNM And in.op <= opc.UNP)\n\t\t\t\t\tIf mov.ra = in.rb Then il = replaceMov1(ml, in, in.ra, mov.rb, in.c)\n\t\t\t\tElseIf in.op = opc.SETTAB Or in.op = opc.SETTABSI\n\t\t\t\t\tIf mov.ra = in.ra Then il = replaceMov1(ml, in, mov.rb, in.rb, in.c)\n\t\t\t\tElseIf in.op = opc.GETTABI Or (in.op >= opc.ADD And in.op < opc.UNM) Or (in.op >= opc.EQ And in.op <= opc.LEQ)\n\t\t\t\t\tIf mov.ra = in.rb\n\t\t\t\t\t\til = replaceMov1(ml, in, in.ra, mov.rb, in.c)\n\t\t\t\t\tElseIf mov.ra = in.c\n\t\t\t\t\t\til = replaceMov1(ml, in, in.ra, in.rb, mov.rb)\n\t\t\t\t\tEndIf\n\t\t\t\tElseIf in.op = opc.SETTABI\n\t\t\t\t\tIf mov.ra = in.ra\n\t\t\t\t\t\til = replaceMov1(ml, in, mov.rb, in.rb, in.c)\n\t\t\t\t\tElseIf mov.ra = in.c\n\t\t\t\t\t\til = replaceMov1(ml, in, in.ra, in.rb, mov.rb)\n\t\t\t\t\tEndIf\n\t\t\t\tEndIf\n\t\t\tEndIf\n\t\t\tIf il = Null Then il = inst.FirstLink()\n\t\t\til = il.NextLink()\n\t\tWend\n\t\tml = Null ; il = inst.LastLink()\t'then MOVs from temps to variables\n\t\tWhile il\n\t\t\tLocal in:BlueInstr = BlueInstr(il.Value())\n\t\t\tIf in.op = opc.MOV\n\t\t\t\tIf in.ra = in.rb\n\t\t\t\t\tml = Null\n\t\t\t\tElseIf ml = Null And in.ra < vmax And in.rb >= tmpStk\n\t\t\t\t\tml = il ; mov = BlueInstr(ml.Value())\n\t\t\t\tEndIf\n\t\t\tElseIf ml <> Null\n\t\t\t\tIf in.op >= opc.JMP\n\t\t\t\t\tml = Null\n\t\t\t\tElseIf in.op = opc.GETTAB Or in.op = opc.GETTABI Or in.op = opc.GETTABSI Or in.op = opc.CLOSURE Or ..\n\t\t\t\t\t\t(in.op >= opc.ADD And in.op <= opc.LEQ) Or (in.op >= opc.LOADK And in.op <= opc.LOADNIL)\n\t\t\t\t\tIf mov.rb = in.ra\n\t\t\t\t\t\til = ml.NextLink()\t'won't be null\n\t\t\t\t\t\tml.Remove() ; ml = Null ; in.ra = mov.ra\n\t\t\t\t\tEndIf\n\t\t\t\tEndIf\n\t\t\tEndIf\n\t\t\til = il.PrevLink()\n\t\tWend\n\tEnd Method\nEnd Type\n\n","old_contents":"\n' Blue Moon\n' Bytecode compiler: accepts program fragments as strings, or program files (and outputs)\n\nSuperStrict\n\nImport \"blueparser.bmx\"\nImport \"blueerror.bmx\"\nImport \"blueversion.bmx\"\nPrivate\nInclude \"TFold.bmx\"\nInclude \"bluefoldsyntax.bmx\"\nInclude \"bluefoldsemantics.bmx\"\nInclude \"bluefoldcodegen.bmx\"\nInclude \"debugfold.bmx\"\nPublic\n\nType BlueCompiler\n\tFunction CompileFile(infile:String, outfile:String = \"\")\n\t\tIf outfile = \"\" Then outfile = infile + \".so\"\n\t\tLocal n:TParseNode = BlueParseFile(infile)\n\t\tLocal compiled:BlueBinary = BlueBinary.Make(infile, ASTToAssembly(n))\n\t\tcompiled.WriteObjectFile(outFile)\n\tEnd Function\n\t\n\tFunction CompileFileForLoad:BlueBinary(infile:String)\n\t\tLocal n:TParseNode = BlueParseFile(infile)\n\t\tLocal code:BlueBinary = BlueBinary.Make(infile, ASTToAssembly(n))\n\t\tLocal sz:Int, mem:Byte Ptr = code.WriteMemory(sz)\n\t\tcode = code.ReadMemory(mem, sz) ; MemFree(mem)\n\t\tReturn code\n\tEnd Function\n\t\n'\tFunction CompileString:BlueBinary(program:String)\n'\t\tLocal n:TParseNode = BlueParseString(program)\n'\t\tReturn BlueBinary.Make(\"\", ASTToAssembly(n))\n'\tEnd Function\n\t\n\tFunction ShowBytecode:String(infile:String)\n\t\tLocal n:TParseNode = BlueParseFile(infile), out:String = infile + \":~n\"\n\t\tLocal assemblies:TList = ASTToAssembly(n)\n\t\tFor Local f:BlueAssembly = EachIn assemblies\n\t\t\tout :+ f.ToString()\n\t\tNext\n\t\tReturn out\n\tEnd Function\n\t\n\tFunction ASTToAssembly:TList(n:TParseNode)\n\t\tLocal tbl:NodeTable = Node.FromParse(n), r:Node = tbl.n\n\t\t\n\t\tr = Node.Fold(r, NormalizeFold.Make(tbl))\n\t\t\n\t\tLocal errf:SyntaxErrFold = SyntaxErrFold.Make(tbl)\n\t\tr = Node.Fold(r, errf) ; errf.BreakCheck()\n\t\t\n\t\tr = Node.Fold(r, New ConstantFold)\n\t\t\n\t\tLocal semf:SemanticFold = SemanticFold.Make(r, tbl)\n\t\tr = Node.Fold(r, semf, Node.BOTH)\t'fold both ways to push and pop environments\n\t\tSemanticFold.Close(semf, r)\n\t\t\n\t\tLocal funs:FunDef[] = FunDef[](semf.funs.ToArray()) ; semf = Null\n\t\t\n\t\t' if we wanted a type checker, it would go here\n\t\ttbl = Null\t'source information no longer needed\n\t\t\n\t\tLocal assemblies:TList = CreateList()\n\t\tFor Local f:FunDef = EachIn funs\n\t\t\tLocal com:CompileFold = CompileFold.Make(BlueAssembly.Make(f))\n\t\t'\tPrint \"F #\" + f.id + \": \" + f.n.ToString()\n\t\t\tLocal inst:TList = BytecodeNode(Node.Fold(f.n, com)).inst\n\t\t\tcom.f.Finish(inst, com.opc)\n\t\t\tassemblies.AddLast(com.f)\n\t\tNext\n\t\t\n\t\t?Debug\n\t\tDebug_KeyListFold.Run(funs, CompileFold.Make(Null))\n\t\t?\n\t\tReturn assemblies\n\tEnd Function\nEnd Type\n\nType BlueOpcode Final\n\tField MOV:Int = 0, GETLC:Int = 1, SETLC:Int = 2\t\t'these are constants, ignore their definition as fields\n\tField LOADK:Int = 3, LOADSI:Int = 4, LOADBOOL:Int = 5, LOADNIL:Int = 6\n\t\n\tField GETTAB:Int = 7, GETTABSI:Int = 8, SETTAB:Int = 9, SETTABSI:Int = 10\n\tField GETTABI:Int = 11, SETTABI:Int = 12, GETUPV:Int = 13, SETUPV:Int = 14\n\tField NEWTAB:Int = 15, CLOSURE:Int = 16, NEWUPV:Int = 17\n\t\n\tField ADD:Int = 18, SUB:Int = 19, MUL:Int = 20, DIV:Int = 21, NMOD:Int = 22, POW:Int = 23, CAT:Int = 24\n\tField IDIV:Int = 25, BAND:Int = 26, BOR:Int = 27, BXOR:Int = 28, BSHL:Int = 29, BSHR:Int = 30\n\tField UNM:Int = 31, LNOT:Int = 32, ALEN:Int = 33, BNOT:Int = 34, UNP:Int = 35\n\tField EQ:Int = 36, LT:Int = 37, LEQ:Int = 38\n\t\n\tField JMP:Int = 39, JIF:Int = 40, JNOT:Int = 41\n\tField CALL:Int = 42, TCALL:Int = 43, RET:Int = 44, RETVA:Int = 45\n\tField POSTCALL:Int = 46, VARARG:Int = 47, VAINIT:Int = 48, CALLINIT:Int = 49\n\t\n\tFunction Make:Int(i:BlueInstr)\n\t\tGlobal opc:BlueOpcode = New Self\n\t\tLocal c:Int = i.c\n\t\tSelect i.op\n\t\t\tCase opc.LOADK, opc.LOADSI, opc.LOADBOOL, opc.LOADNIL, opc.JMP, opc.JIF, opc.JNOT, opc.RET\n\t\t\t\tIf c < 0 Then c :& (Int(2^18) - 1)\n\t\t\t\tReturn i.op | ((i.ra & $FF) Shl 6) | (c Shl 14)\n\t\t\tDefault\n\t\t\t\tIf c < 0 Then c :& (Int(2^10) - 1)\n\t\t\t\tReturn i.op | ((i.ra & $FF) Shl 6) | ((i.rb & $FF) Shl 14) | (c Shl 22)\n\t\tEnd Select\n\tEnd Function\n\tFunction Read(i:Int, op:Int Var, ra:Int Var, rb:Int Var, c:Int Var)\n\t\tGlobal opc:BlueOpcode = New Self\n\t\top = i & %111111 ; ra = (i Shr 6) & $FF\n\t\tSelect op\n\t\t\tCase opc.LOADK, opc.LOADSI, opc.LOADBOOL, opc.LOADNIL, opc.JMP, opc.JIF, opc.JNOT, opc.RET\n\t\t\t\trb = 0 ; c = i Sar 14\t'sign-extend (already MSB)\n\t\t\tDefault\n\t\t\t\trb = (i Shr 14) & $FF ; c = i Sar 22\n\t\tEnd Select\n\tEnd Function\nEnd Type\n\nType BlueInstr\n\tField op:Int, ra:Int, rb:Int, c:Int\n\tFunction Make:BlueInstr(op:Int, ra:Int, rb:Int, c:Int = 0)\n\t\tLocal i:BlueInstr = New BlueInstr ; i.op = op ; i.ra = ra ; i.rb = rb ; i.c = c ; Return i\n\tEnd Function\n\tFunction MakeK:BlueInstr(op:Int, ra:Int, c:Int)\n\t\tReturn Make(op, ra, 0, c)\n\tEnd Function\n\tMethod ToString:String()\n\t\tGlobal opc:BlueOpcode = New BlueOpcode\n\t\tLocal n:String = \"??\"\n\t\tFor Local f:TField = EachIn TTypeId.ForObject(opc).Fields()\n\t\t\tIf f.GetInt(opc) = op Then n = f.Name()[..10] ; Exit\n\t\tNext\n\t\tSelect op\n\t\t\tCase opc.LOADNIL, opc.NEWUPV, opc.NEWTAB\n\t\t\t\tReturn n + \" \" + ra\n\t\t\tCase opc.MOV, opc.SETLC, opc.GETLC, opc.SETUPV, opc.GETUPV\n\t\t\t\tReturn n + \" \" + ra + \", \" + rb\n\t\t\tCase opc.LOADK, opc.LOADSI, opc.LOADBOOL, opc.CLOSURE, opc.RET, opc.POSTCALL, opc.VARARG\n\t\t\t\tReturn n + \" \" + ra + \", \" + c\n\t\t\tDefault ; Return n + \" \" + ra + \", \" + rb + \", \" + c\n\t\tEnd Select\n\tEnd Method\nEnd Type\n\nType BlueBinary\n\tConst MAGICNUMBER:Long = 5642816051412814914:Long\t'BLUEMOON\n\tField out:Int[], buf:Int[]\t'out = output bytestream, buf = input\/readable bytestream\n\t\n\tFunction Make:BlueBinary(file:String, funs:TList)\n\t\tLocal b:BlueBinary = New Self, ktbl:TList = CreateList(), kc:Int = 0\n\t\t\n\t\tLocal binSz:Int = 0, fcount:Int = 0\n\t\tFor Local f:BlueAssembly = EachIn funs\n\t\t\tLocal ki:Int = 0\n\t\t\tFor Local k:String = EachIn f.ktbl\n\t\t\t\tf.kidx[ki] = AddKTblEntry(k, ktbl, kc) ; ki :+ 1\t'consolidate constants into single table\n\t\t\tNext\n\t\t\t\n\t\t\tIf f.framesz > f.MAXVARS - 3 Or f.upvars > f.MAXVARS Then Throw ..\n\t\t\t\tBlueAssemblyError.Make(file, \"too many variables\/temporaries in function #\" + f.id ..\n\t\t\t\t+ \"; consider splitting into more blocks or helper functions\")\n\t\t\t\n\t\t\tbinSz :+ (7 ..\t'id, instruction count, k count, param count, var count, upvar count, frame size\n\t\t\t + 2 * f.upvars ..\t'upvar levels and stack positions (interleaved)\n\t\t\t + f.kc ..\t'constant index table\n\t\t\t + f.inst.Count())\t'instructions\n\t\t\tfcount :+ 1\n\t\tNext\n\t\t\n\t\tbinSz :+ (kc + 1)\n\t\tFor Local k:String = EachIn ktbl\n\t\t\tIf k[0] = \"0\"[0] Then binSz :+ 2 Else binSz :+ Ceil((k.Length - 2) \/ 2.0) + 2\n\t\tNext\n\t\t\n\t\tLocal headerSz:Int = 3 + fcount\t'function count, k count, k table offset, function offset list\n\t\tbinSz :+ headerSz\n\t\t\n\t\tLocal out:Int[] = New Int[binSz] ; b.out = out\n\t\tout[0] = fcount\n\t\tout[1] = kc\n\t\t\n\t\tLocal pos:Int = headerSz, opc:BlueOpcode = New BlueOpcode\n\t\tFor Local f:BlueAssembly = EachIn funs\n\t\t\tout[3 + f.id] = pos\n\t\t\tout[pos] = f.id ; out[pos + 1] = f.inst.Count() ; out[pos + 2] = f.kc ; out[pos + 3] = f.params\n\t\t\tout[pos + 4] = f.vars ; out[pos + 5] = f.upvars ; out[pos + 6] = f.framesz\n\t\t\tpos :+ 7\n\t\t\tFor Local v:Int = 0 Until f.upvars\n\t\t\t\tout[pos] = f.upvarTier[v] ; out[pos + 1] = f.upvarStkPos[v] ; pos :+ 2\n\t\t\tNext\n\t\t\tFor Local k:Int = 0 Until f.kc\n\t\t\t\tout[pos] = f.kidx[k] ; pos :+ 1\n\t\t\tNext\n\t\t\tFor Local i:BlueInstr = EachIn f.inst\n\t\t\t\tout[pos] = BlueOpcode.Make(i) ; pos :+ 1\n\t\t\tNext\n\t\tNext\n\t\t\n\t\tout[2] = pos ; Local ktblpos:Int = pos ; pos :+ (kc + 1)\n\t\tFor Local k:String = EachIn ktbl\n\t\t\tLocal d:Double, dp:Byte Ptr = Varptr(d)\n\t\t\tout[ktblpos] = pos ; ktblpos :+ 1\n\t\t\tIf k[0] = \"0\"[0]\n\t\t\t\td = Double(k[2..])\n\t\t\t\tout[pos] = Int Ptr(dp)[0] ; out[pos + 1] = Int Ptr(dp)[1]\n\t\t\t\tpos :+ 2\n\t\t\tElse\n\t\t\t\td = k.Length - 2\n\t\t\t\tout[pos] = Int Ptr(dp)[0] ; out[pos + 1] = Int Ptr(dp)[1] ; pos :+ 2\n\t\t\t\tIf k.Length Mod 2 = 1 Then k :+ \" \"\t'even the length for ease of writing\n\t\t\t\tFor Local c:Int = 2 Until k.Length Step 2\n\t\t\t\t\tout[pos] = Short(k[c]) | (Short(k[c + 1]) Shl 16) ; pos :+ 1\n\t\t\t\tNext\n\t\t\tEndIf\n\t\tNext\n\t\tout[ktblpos] = pos\n\t\tAssert pos = binSz, \"assembly write error: binary size mismatch (critical compiler error)\"\n\t\t\n\t\tReturn b\n\tEnd Function\n\t\n\tFunction AddKTblEntry:Int(k:String, tbl:TList, kc:Int Var)\n\t\tLocal ki:Int = 0\n\t\tFor Local ek:String = EachIn tbl\n\t\t\tIf ek = k Then Return ki\n\t\t\tki :+ 1\n\t\tNext\n\t\ttbl.AddLast(k) ; kc :+ 1'ktbl.Count()\n\t\tReturn ki\n\tEnd Function\n\t\n\tMethod WriteMemory:Byte Ptr(size:Int Var)\n\t\tsize = out.Length * 8 + 16\n\t\tLocal mem:Byte Ptr = MemAlloc(size)\n\t\tAssert mem, \"failed to allocate memory for instruction buffer\"\n\t\tWrite(CreateRamStream(mem, out.Length * 8 + 16, 0, 1))\n\t\tReturn mem\n\tEnd Method\n\t\n\tMethod WriteObjectFile(filename:String)\n\t\tWrite(WriteFile(filename))\n\tEnd Method\n\t\n\tFunction ReadMemory:BlueBinary(mem:Byte Ptr, size:Int)\n\t\tReturn Read(CreateRamStream(mem, size, 1, 0), \"\", size)\n\tEnd Function\n\t\n\tFunction ReadObjectFile:BlueBinary(filename:String)\n\t\tReturn Read(ReadFile(filename), filename, FileSize(filename))\n\tEnd Function\n\t\n\tFunction Read:BlueBinary(file:TStream, filename:String, sz:Int)\n\t\tLocal b:BlueBinary\n\t\tTry\n\t\t\tLocal opc:BlueOpcode = New BlueOpcode\n\t\t\tLocal corrupt:BlueAssemblyError = BlueAssemblyError.Make(filename, \"not a valid Blue Moon binary file (possibly corrupt)\")\n\t\t\tLocal badInst:BlueError = corrupt.Make(filename, \"invalid Blue Moon instruction (out of bounds error); could not load file\")\n\t\t\tsz :- (8 + 8) ; If sz < 12 Or (sz Mod 4 <> 0) Then Throw corrupt\n\t\t\t\n\t\t\tLocal magic:Long = file.ReadLong() ; If magic <> MAGICNUMBER Then Throw corrupt\n\t\t\tLocal major:Int = file.ReadInt()\n\t\t\tIf major <> BlueMoonVersion.MAJORVERSION Then Throw corrupt.Make(filename, \"incompatible major version of interpreter for bytecode\")\n\t\t\tLocal minor:Int = file.ReadInt()\n\t\t\tIf minor > BlueMoonVersion.MINORVERSION Then Throw corrupt.Make(filename, \"incompatible version of interpreter for bytecode\")\n\t\t\t\n\t\t\tLocal fc:Int = file.ReadInt(), kc:Int = file.ReadInt(), koffs:Int = file.ReadInt(), headerSz:Int = 3 + fc\n\t\t\tsz :\/ 4 ; If sz < headerSz + fc * 7 Or sz < koffs + kc * 3 Then Throw corrupt\n\t\t\t\n\t\t\tLocal bufSz:Int = headerSz + (koffs - headerSz) * 2 + (sz - koffs), buf:Int[bufSz]\n\t\t\tbuf[0] = fc ; buf[1] = kc ; buf[2] = koffs\n\t\t\t\n\t\t\tFor Local fi:Int = 0 Until fc\n\t\t\t\tLocal foff:Int = file.ReadInt() ; If sz < foff Then Throw corrupt\n\t\t\t\tbuf[3 + fi] = headerSz + (foff - headerSz) * 2\n\t\t\tNext\n\t\t\t\n\t\t\tLocal pos:Int = headerSz, sizeExtension:Int = 0\n\t\t\tFor Local fi:Int = 0 Until fc\n\t\t\t'binSz :+ (7 ..\t'id, instruction count, k count, param count, var count, upvar count, frame size\n\t\t\t ' + 2 * f.upvars ..\t'upvar levels and stack positions (interleaved)\n\t\t\t ' + f.kc ..\t'constant index table\n\t\t\t ' + f.inst.Count())\t'instructions\n\t\t\t\tLocal id:Int = file.ReadInt(), icount:Int = file.ReadInt(), kcount:Int = file.ReadInt(), pcount:Int = file.ReadInt()\n\t\t\t\tLocal vars:Int = file.ReadInt(), upvars:Int = file.ReadInt(), framesz:Int = file.ReadInt()\n\t\t\t\tIf pos <> buf[3 + fi] Or id <> fi Or (icount|kcount|pcount|vars|upvars|framesz) < 0 Then Throw corrupt\n\t\t\t\tbuf[pos] = id ; buf[pos + 1] = icount ; buf[pos + 2] = kcount ; buf[pos + 3] = pcount\n\t\t\t\tbuf[pos + 4] = vars ; buf[pos + 5] = upvars ; buf[pos + 6] = framesz ; pos :+ 7\n\t\t\t\tIf (pos - sizeExtension) + 2 * upvars + kcount + icount > sz Then Throw corrupt\n\t\t\t\tsizeExtension :+ (7 + 2 * upvars + kcount + icount) * 2\n\t\t\t\t\n\t\t\t\tFor Local up:Int = 0 Until upvars\n\t\t\t\t\tbuf[pos] = file.ReadInt() ; buf[pos + 1] = file.ReadInt() ; pos :+ 2\n\t\t\t\tNext\n\t\t\t\tFor Local ki:Int = 0 Until kcount\n\t\t\t\t\tbuf[pos] = file.ReadInt()\n\t\t\t\t\tIf buf[pos] >= kc Then Throw corrupt\n\t\t\t\t\tpos :+ 1\n\t\t\t\tNext\n\t\t\t\t\n\t\t\t\tFor Local i:Int = 0 Until icount\n\t\t\t\t\tLocal in:Int = file.ReadInt(), op:Int, ra:Int, rb:Int, c:Int\n\t\t\t\t\tBlueOpcode.Read(in, op, ra, rb, c)\n\t\t\t\t\t\n\t\t\t\t\tSelect op\t\t'verify operation as not going out of bounds!\n\t\t\t\t\t\tCase opc.RETVA\t'ignore\n\t\t\t\t\t\tCase opc.JMP, opc.JNOT, opc.JIF\n\t\t\t\t\t\t\tIf i + c >= icount Or i + c < 0 Then Throw badinst\n\t\t\t\t\t\tCase opc.CALL, opc.TCALL\n\t\t\t\t\t\t\tIf Max(ra, rb + c) >= framesz Or Min(ra, Min(rb, c)) < 0 Then Throw badInst\n\t\t\t\t\t\tCase opc.RET, opc.POSTCALL\n\t\t\t\t\t\t\tIf ra + c >= framesz Or ra < 0 Or c < 0 Then Throw badInst\n\t\t\t\t\t\tCase opc.GETUPV\n\t\t\t\t\t\t\tIf ra >= framesz Or ra < 0 Or rb >= upvars Or rb < 0 Then Throw badInst\n\t\t\t\t\t\tCase opc.SETUPV\n\t\t\t\t\t\t\tIf rb >= framesz Or rb < 0 Or ra >= upvars Or ra < 0 Then Throw badInst\n\t\t\t\t\t\tDefault\n\t\t\t\t\t\t\tIf ra >= framesz Or rb >= framesz Or ra < 0 Or rb < 0 Then Throw badInst\n\t\t\t\t\t\t\tIf (op >= opc.ADD And op <= opc.BSHR) Or (op >= opc.EQ And op <= opc.LEQ)\n\t\t\t\t\t\t\t\tIf c >= framesz Or c < 0 Then Throw badInst\n\t\t\t\t\t\t\tElse\n\t\t\t\t\t\t\t\tSelect op\n\t\t\t\t\t\t\t\t\tCase opc.GETTAB, opc.SETTAB, opc.LOADK\n\t\t\t\t\t\t\t\t\t\tIf c >= kcount Or c < 0 Then Throw badInst\n\t\t\t\t\t\t\t\t\tCase opc.VARARG', opc.VAINIT, opc.CALLINIT\n\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\tCase opc.CLOSURE\n\t\t\t\t\t\t\t\t\t\tIf c >= fc Or c < 0 Then Throw badInst\n\t\t\t\t\t\t\t\tEnd Select\n\t\t\t\t\t\t\tEndIf\n\t\t\t\t\tEnd Select\n\t\t\t\t\t\n\t\t\t\t\tbuf[pos] = op | (ra Shl 8) | (rb Shl 16) ; buf[pos + 1] = c\n\t\t\t\t\tpos :+ 2\n\t\t\t\tNext\n\t\t\t\t\n\t\t\t\tpos :+ (7 + 2 * upvars + kcount)\t'unused space because of buffer doubling\n\t\t\tNext\n\t\t\t\n\t\t\tsizeExtension :\/ 2\n\t\t\tIf pos - sizeExtension <> koffs Then Throw corrupt\n\t\t\tbuf[2] = pos\t'update koffs\n\t\t\tFor Local ki:Int = 0 To kc\t'[sic] - we need to copy the end marker too\n\t\t\t\tLocal koff:Int = file.ReadInt() ; If sz < koff Or koff < koffs + kc + 1 Then Throw corrupt\n\t\t\t\tbuf[pos] = koff + sizeExtension ; pos :+ 1\n\t\t\tNext\n\t\t\tFor Local ki:Int = 0 Until kc\n\t\t\t\tLocal d:Double = file.ReadDouble(), dp:Int Ptr = Int Ptr(Varptr(d))\n\t\t\t\tbuf[pos] = dp[0] ; buf[pos + 1] = dp[1] ; pos :+ 2\n\t\t\t\tIf pos <> buf[koffs + sizeExtension + ki + 1]\t'string\n\t\t\t\t\tFor Local c:Int = 0 Until Ceil(d \/ 2)\n\t\t\t\t\t\tbuf[pos + c] = file.ReadInt()\n\t\t\t\t\tNext\n\t\t\t\t\tpos :+ Ceil(d \/ 2)\n\t\t\t\tEndIf\n\t\t\tNext\n\t\t\t\n\t\t\tb = New Self ; b.buf = buf\n\t\tCatch o:Object\n\t\t\tCloseStream(file) ; Throw o\n\t\tEnd Try\n\t\tCloseStream(file)\n\t\tReturn b\n\tEnd Function\n\t\n\tMethod Write(file:TStream)\n\t\tTry\n\t\t\tfile.WriteLong MAGICNUMBER\n\t\t\tfile.WriteInt BlueMoonVersion.MAJORVERSION ; file.WriteInt BlueMoonVersion.MINORVERSION\n\t\t\tFor Local i:Int = 0 Until out.Length\n\t\t\t\tfile.WriteInt out[i]\n\t\t\tNext\n\t\tCatch o:Object\n\t\t\tCloseStream(file) ; Throw o\n\t\tEnd Try\n\t\tCloseStream(file)\n\tEnd Method\nEnd Type\n\nType BlueAssembly\n\tConst MAXVARS:Int = 255, SI_LIMIT:Int = 131071, VSI_LIMIT:Int = 511\n\tField fd:FunDef, id:Int\n\tField vsp:Int\n\tField ktbl:TList, kc:Int, kidx:Int[]\n\tField inst:TList\n\tField lbl:LabelDef[], gto:GotoDef[]\n\tField params:Int, vars:Int, upvars:Int, framesz:Int, upvarTier:Int[], upvarStkPos:Int[]\n\t\n\tFunction Make:BlueAssembly(fd:FunDef)\n\t\tLocal f:BlueAssembly = New BlueAssembly\n\t\tf.fd = fd ; f.id = fd.id\n\t\tf.params = fd.pcount ; f.vars = fd.vmax ; f.upvars = fd.clos.Length\n\t\tf.vsp = f.vars '+ f.upvars\n\t\tf.upvarTier = New Int[f.upvars] ; f.upvarStkPos = New Int[f.upvars]\n\t\tFor Local v:Int = 0 Until f.upvars\n\t\t\tLocal el:Int = 1, env:FunDef = fd.env\n\t\t\tIf env\n\t\t\t\tf.upvarStkPos[v] = -1\n\t\t\t\tFor Local l:Int = 0 Until env.vars.Length\n\t\t\t\t\tIf env.vars[l] = fd.clos[v] Then f.upvarStkPos[v] = l ; Exit\n\t\t\t\tNext\n\t\t\t\tIf f.upvarStkPos[v] = -1\n\t\t\t\t\tFor Local c:Int = 0 Until env.clos.Length\n\t\t\t\t\t\tIf env.clos[c] = fd.clos[v]\n\t\t\t\t\t\t\tf.upvarTier[v] = 1 ; f.upvarStkPos[v] = c ; Exit\n\t\t\t\t\t\tEndIf\n\t\t\t\t\tNext\n\t\t\t\t\tAssert f.upvarStkPos[v] <> -1, \"compile error: unable to resolve closure (critical compiler error)\"\n\t\t\t\tEndIf\n\t\t\tElse\n\t\t\t\tf.upvarTier[v] = -1 ; f.upvarStkPos[v] = 0\n\t\t\tEndIf\n\t\tNext\n\t\tf.ktbl = CreateList() ; f.kc = 0\n\t\tReturn f\n\tEnd Function\n\t\n\tMethod Push:Int(n:Int = 1)\n\t\tvsp :+ n ; Return vsp - 1\n\tEnd Method\n\tMethod Pop:Int(n:Int = 1)\n\t\tvsp :- n ; Return vsp\n\tEnd Method\n\tMethod Peek:Int()\n\t\tReturn vsp - 1\n\tEnd Method\n\t\n\tMethod GetConst:Int(t:String, val:String)\n\t\tReturn BlueBinary.AddKTblEntry(t + \":\" + val, ktbl, kc)\n\tEnd Method\n\t\n\tMethod ToString:String()\n\t\tLocal s:String = \"F: \" + id + \"~n\"\n\t\ts :+ \" Constants:~n\"\n\t\tFor Local k:String = EachIn ktbl\n\t\t\ts :+ \" \" + k + \"~n\"\n\t\tNext\n\t\ts :+ \" Upvars:~n\"\n\t\tFor Local v:Int = 0 Until upvars\n\t\t\ts :+ \" \" + upvarTier[v] + \"\/\" + upvarStkPos[v] + \"~n\"\n\t\tNext\n\t\ts :+ \" Instructions:~n\"\n\t\tFor Local i:BlueInstr = EachIn inst\n\t\t\ts :+ \" \" + i.ToString() + \"~n\"\n\t\tNext\n\t\tReturn s\n\tEnd Method\n\t\n\tMethod Finish(_inst:TList, opc:BlueOpcode)\n\t\tinst = _inst\n\t\tlbl = LabelDef[](fd._lt.ToArray())\n\t\tgto = GotoDef[](fd._gt.ToArray())\n\t\t\n\t\t' allow closures over parameters\n\t\tFor Local p:Int = params - 1 To 0 Step -1\n\t\t\tIf fd.vars[p].isClosure Then inst.AddFirst(BlueInstr.Make(opc.NEWUPV, fd.vars[p].stkpos, 0))\n\t\tNext\n\t\t\n\t\t' add final return so that jumps don't run off the end\n\t\tinst.AddLast BlueInstr.Make(opc.RET, 0, 0, 0)\n\t\t' remove redundant MOV instructions\n\t\tSelf.ReduceMovs(opc)\n\t\t' resolve targeted jumps and remove dummy target instructions\n\t\tSelf.ResolveJumps(opc)\n\t\t' resolve break jumps and remove dummy target instructions\n\t\tSelf.ResolveBreaks(opc)\n\t\t\n\t\tframesz = vars'upvars + vars\n\t\tFor Local i:BlueInstr = EachIn inst\n\t\t\tSelect i.op\n\t\t\t\tCase opc.JMP, opc.VARARG, opc.VAINIT, opc.CALLINIT, opc.RETVA\t'ignore\n\t\t\t\tCase opc.CALL, opc.TCALL\n\t\t\t\t\tframesz = Max(framesz, Max(i.ra, i.rb + i.c) + 1)\n\t\t\t\tCase opc.RET, opc.POSTCALL\n\t\t\t\t\tframesz = Max(framesz, i.ra + i.c + 1)\n\t\t\t\tDefault\n\t\t\t\t\tframesz = Max(framesz, i.ra + 1)\n\t\t\tEnd Select\n\t\tNext\n\t\t\n\t\tkidx = New Int[kc]\n\t\tfd = Null\n\tEnd Method\n\t\n\tMethod ResolveJumps(opc:BlueOpcode)\n\t\tLocal il:TLink = inst.FirstLink(), i:Int = 0\n\t\tWhile il\n\t\t\tLocal in:BlueInstr = BlueInstr(il.Value())\n\t\t\tIf in.op = opc.MOV And in.ra = 0 And in.rb = 0\n\t\t\t\tLocal lab:LabelDef = lbl[in.c]\n\t\t\t\tlab.insl = il ; lab.insc = i\n\t\t\tElseIf Not (in.op = opc.MOV And in.ra = in.rb)\n\t\t\t\ti :+ 1\n\t\t\tEndIf\n\t\t\til = il.NextLink()\n\t\tWend\n\t\ti = 0 ; il = inst.FirstLink()\n\t\tWhile il\n\t\t\tLocal in:BlueInstr = BlueInstr(il.Value())\n\t\t\tIf (in.op >= opc.JMP And in.op <= opc.JNOT) And in.c >= 0\n\t\t\t\tLocal jmp:GotoDef = gto[in.c]\n\t\t\t\tin.c = jmp.tgt.insc - i ; jmp.tgt.insl.Remove()\n\t\t\tEndIf\n\t\t\tIf Not (in.op = opc.MOV And in.ra = in.rb) Then i :+ 1\n\t\t\til = il.NextLink()\n\t\tWend\n\tEnd Method\n\t\n\tMethod ResolveBreaks(opc:BlueOpcode)\n\t\tLocal il:TLink = inst.FirstLink()\n\t\tWhile il\n\t\t\tLocal in:BlueInstr = BlueInstr(il.Value())\n\t\t\tIf in.op = opc.JMP And in.ra = -1\n\t\t\t\tLocal tgl:TLink = il.NextLink(), cnt:Int = 1\n\t\t\t\tWhile True\n\t\t\t\t\tLocal tgt:BlueInstr = BlueInstr(tgl.Value())\n\t\t\t\t\tIf tgt.op = opc.MOV And tgt.c = -1\n\t\t\t\t\t\tin.ra = 0 ; in.rb = 0 ; in.c = cnt ; Exit\n\t\t\t\t\tEndIf\n\t\t\t\t\ttgl = tgl.NextLink() ; cnt :+ 1\n\t\t\t\tWend\n\t\t\tEndIf\n\t\t\til = il.NextLink()\n\t\tWend\n\t\til = inst.FirstLink()\t'remove break point markers\n\t\tWhile il\n\t\t\tLocal in:BlueInstr = BlueInstr(il.Value())\n\t\t\tIf in.op = opc.MOV And in.c = -1 Then il.Remove()\n\t\t\til = il.NextLink()\n\t\tWend\n\tEnd Method\n\t\n\tMethod ReduceMovs(opc:BlueOpcode)\n\t\tFunction replaceMov1:TLink(ml:TLink Var, in:BlueInstr, ra:Int, rb:Int, c:Int)\t'update a later instruction and then go back to look for more MOVs\n\t\t\tLocal ret:TLink = ml.PrevLink()\t'won't be null\n\t\t\tml.Remove() ; ml = Null\n\t\t\tin.ra = ra ; in.rb = rb ; in.c = c\n\t\t\tReturn ret\n\t\tEnd Function\n\t\t\n\t\t'first MOVs from variables to temps\n\t\tLocal ml:TLink, mov:BlueInstr, il:TLink = inst.FirstLink(), vmax:Int = fd.vmax, tmpStk:Int = vmax' + fd.clos.Length\n\t\tWhile il\n\t\t\tLocal in:BlueInstr = BlueInstr(il.Value())\n\t\t\tIf in.op = opc.MOV\t'if it's a move to temp space and nothing is pending\n\t\t\t\tIf in.ra = in.rb\t'jump target; do not cross\n\t\t\t\t\tml = Null\n\t\t\t\tElseIf ml = Null And in.ra >= tmpStk And in.rb < vmax\n\t\t\t\t\tml = il ; mov = BlueInstr(ml.Value())\n\t\t\t\tElseIf ml <> Null And in.rb = mov.ra And in.ra <> mov.rb\n\t\t\t\t\til = replaceMov1(ml, in, in.ra, mov.rb, in.c)\n\t\t\t\tEndIf\n\t\t\tElseIf ml <> Null\n\t\t\t\tIf in.op >= opc.JMP\t'any control-flow related op cancels\n\t\t\t\t\tIf (in.op = opc.JIF Or in.op = opc.JNOT) And mov.ra = in.ra Then il = replaceMov1(ml, in, mov.rb, in.rb, in.c) Else il = ml\n\t\t\t\t\tml = Null\n\t\t\t\tElseIf (in.op >= opc.GETTAB And in.op <= opc.SETTABSI) Or (in.op >= opc.UNM And in.op <= opc.UNP)\n\t\t\t\t\tIf mov.ra = in.rb Then il = replaceMov1(ml, in, in.ra, mov.rb, in.c)\n\t\t\t\tElseIf in.op = opc.GETTABI Or in.op = opc.SETTABI Or (in.op >= opc.ADD And in.op < opc.UNM) Or (in.op >= opc.EQ And in.op <= opc.LEQ)\n\t\t\t\t\tIf mov.ra = in.rb\n\t\t\t\t\t\til = replaceMov1(ml, in, in.ra, mov.rb, in.c)\n\t\t\t\t\tElseIf mov.ra = in.c\n\t\t\t\t\t\til = replaceMov1(ml, in, in.ra, in.rb, mov.rb)\n\t\t\t\t\tEndIf\n\t\t\t\tEndIf\n\t\t\tEndIf\n\t\t\tIf il = Null Then il = inst.FirstLink()\n\t\t\til = il.NextLink()\n\t\tWend\n\t\tml = Null ; il = inst.LastLink()\t'then MOVs from temps to variables\n\t\tWhile il\n\t\t\tLocal in:BlueInstr = BlueInstr(il.Value())\n\t\t\tIf in.op = opc.MOV\n\t\t\t\tIf in.ra = in.rb\n\t\t\t\t\tml = Null\n\t\t\t\tElseIf ml = Null And in.ra < vmax And in.rb >= tmpStk\n\t\t\t\t\tml = il ; mov = BlueInstr(ml.Value())\n\t\t\t\tEndIf\n\t\t\tElseIf ml <> Null\n\t\t\t\tIf in.op >= opc.JMP\n\t\t\t\t\tml = Null\n\t\t\t\tElseIf in.op = opc.GETTAB Or in.op = opc.GETTABI Or in.op = opc.GETTABSI Or in.op = opc.CLOSURE Or ..\n\t\t\t\t\t\t(in.op >= opc.ADD And in.op <= opc.LEQ) Or (in.op >= opc.LOADK And in.op <= opc.LOADNIL)\n\t\t\t\t\tIf mov.rb = in.ra\n\t\t\t\t\t\til = ml.NextLink()\t'won't be null\n\t\t\t\t\t\tml.Remove() ; ml = Null ; in.ra = mov.ra\n\t\t\t\t\tEndIf\n\t\t\t\tEndIf\n\t\t\tEndIf\n\t\t\til = il.PrevLink()\n\t\tWend\n\tEnd Method\nEnd Type\n\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"c625a612815567d0c7302c9a4732a72f039a2622","subject":"Fixed small audio bug.","message":"Fixed small audio bug.\n","repos":"kfprimm\/maxb3d,kfprimm\/maxb3d","old_file":"audio3d.mod\/audio3d.bmx","new_file":"audio3d.mod\/audio3d.bmx","new_contents":"\nStrict\n\nRem\n\tbbdoc: 3D Audio system for MaxB3D\nEnd Rem\nModule MaxB3D.Audio3D\nModuleInfo \"Author: Kevin Primm\"\nModuleInfo \"License: MIT\"\n\nImport MaxB3D.Core\nImport BRL.Audio\n\nPrivate\nGlobal _listener:TListener=New TListener\nGlobal _audio3ddriver:TAudio3DDriver\n\nPublic\n\nType TAudio3DDriver Extends TAudioDriver\n\tField _parent:TAudioDriver\n\t\t\n\tMethod Startup()\n\t\tIf _parent=Null\n\t\t\tLocal driver:TAudioDriver=_succ\n\t\t\tWhile driver\n\t\t\t\tIf driver.Name()=ParentName() Exit\n\t\t\t\tdriver=driver._succ\n\t\t\tWend\n\t\t\tIf driver=Null Return False\n\t\t\t_parent=driver\n\t\tEndIf\n\t\tIf Not _parent.Startup() Return False\n\t\t_audio3ddriver=Self\n\t\tSetListener _listener._matrix\n\t\tReturn OnStartup()\n\tEnd Method\n\t\t\n\tMethod EmitSound(sound:TSound,target:Object)\n\t\tTSound3D(sound).Emit(target)\n\tEnd Method\n\t\t\n\tMethod CreateSound:TSound( sample:TAudioSample,loop_flag )\n\t\tReturn _parent.CreateSound(sample,loop_flag)\n\tEnd Method\n\t\n\tMethod AllocChannel:TChannel() \n\t\tReturn _parent.AllocChannel()\n\tEnd Method\n\n\tMethod LoadSound:TSound( url:Object, flags:Int = 0)\n\t\tReturn TSound3D.FromSound(_parent.LoadSound(url,flags),Self)\n\tEnd Method\n\n\tMethod Name$()\n\t\tReturn \"Audio3D \"+ParentName()\n\tEnd Method\n\n\tMethod OnStartup() Abstract\t\n\tMethod SetListener(matrix:TMatrix) Abstract\n\tMethod SetTarget(target:Object,channel:TChannel) Abstract\n\tMethod ParentName$() Abstract\nEnd Type\n\nType TSound3D Extends TSound\n\tField _driver:TAudio3DDriver\n\tField _parent:TSound\n\t\n\tFunction FromSound:TSound3D(sound:TSound,driver:TAudio3DDriver)\n\t\tIf sound = Null Return\n\t\tLocal sound3d:TSound3D=New TSound3D\n\t\tsound3d._parent=sound\n\t\tsound3d._driver=driver\n\t\tReturn sound3d\n\tEnd Function\n\t\n\tMethod Emit(target:Object)\n\t\tLocal channel:TChannel=_parent.Cue()\n\t\t_driver.SetTarget target,channel\n\t\tchannel.SetPaused False\n\tEnd Method\n\t\n\tMethod Play:TChannel( alloced_channel:TChannel=Null )\n\t\t_driver.SetTarget Null,alloced_channel\n\t\tReturn _parent.Play(alloced_channel)\n\tEnd Method\n\t\n\tMethod Cue:TChannel( alloced_channel:TChannel=Null )\n\t\tReturn _parent.Cue(alloced_channel)\n\tEnd Method\nEnd Type\n\nType TListener Extends TEntity\n\tField _rolloff#,_doppler#,_distance#\n\t\n\tMethod New()\n\t\tAssert _listener=Null, \"Only one listener can exist!\"\n\tEnd Method\n\t\n\tMethod Lists[]()\n\t\tReturn Super.Lists()\n\tEnd Method\n\t\n\tMethod Copy:TListener(parent:TEntity=Null)\n\t\tReturn Null\n\tEnd Method\n\t\t\n\tMethod GetScales(rolloff# Var,doppler# Var,distance# Var)\t\n\t\trolloff=_rolloff;doppler=_doppler;distance=_distance\n\tEnd Method\n\tMethod SetScales(rolloff#,doppler#,distance#)\n\t\t_rolloff=rolloff;_doppler=doppler;_distance=distance\n\tEnd Method\n\t\n\tMethod RefreshMatrix()\n\t\tSuper.RefreshMatrix()\n\t\tIf _audio3ddriver _audio3ddriver.SetListener _matrix\n\tEnd Method\nEnd Type\n\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetListener:TListener()\n\tReturn _listener\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetListener(parent:TEntity,rolloff#=1.0,doppler#=1.0,distance#=1.0)\n\t_listener.SetParent parent\n\t_listener.SetScales rolloff,doppler,distance\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetListenerScales(listener:TListener,rolloff# Var,doppler# Var,distance# Var)\n\tReturn listener.GetScales(rolloff,doppler,distance)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetListenerScales(listener:TListener,rolloff#,doppler#,distance#)\n\tReturn listener.SetScales(rolloff,doppler,distance)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction EmitSound(sound:TSound,target:Object)\n\tReturn _audio3ddriver.EmitSound(sound,target)\nEnd Function\n","old_contents":"\nStrict\n\nRem\n\tbbdoc: 3D Audio system for MaxB3D\nEnd Rem\nModule MaxB3D.Audio3D\nModuleInfo \"Author: Kevin Primm\"\nModuleInfo \"License: MIT\"\n\nImport MaxB3D.Core\nImport BRL.Audio\n\nPrivate\nGlobal _listener:TListener=New TListener\nGlobal _audio3ddriver:TAudio3DDriver\n\nPublic\n\nType TAudio3DDriver Extends TAudioDriver\n\tField _parent:TAudioDriver\n\t\t\n\tMethod Startup()\n\t\tIf _parent=Null\n\t\t\tLocal driver:TAudioDriver=_succ\n\t\t\tWhile driver\n\t\t\t\tIf driver.Name()=ParentName() Exit\n\t\t\t\tdriver=driver._succ\n\t\t\tWend\n\t\t\tIf driver=Null Return False\n\t\t\t_parent=driver\n\t\tEndIf\n\t\tIf Not _parent.Startup() Return False\n\t\t_audio3ddriver=Self\n\t\tSetListener _listener._matrix\n\t\tReturn OnStartup()\n\tEnd Method\n\t\t\n\tMethod EmitSound(sound:TSound,target:Object)\n\t\tTSound3D(sound).Emit(target)\n\tEnd Method\n\t\t\n\tMethod CreateSound:TSound( sample:TAudioSample,loop_flag )\n\t\tReturn _parent.CreateSound(sample,loop_flag)\n\tEnd Method\n\t\n\tMethod AllocChannel:TChannel() \n\t\tReturn _parent.AllocChannel()\n\tEnd Method\n\n\tMethod LoadSound:TSound( url:Object, flags:Int = 0)\n\t\tReturn TSound3D.FromSound(_parent.LoadSound(url,flags),Self)\n\tEnd Method\n\n\tMethod Name$()\n\t\tReturn \"Audio3D \"+ParentName()\n\tEnd Method\n\n\tMethod OnStartup() Abstract\t\n\tMethod SetListener(matrix:TMatrix) Abstract\n\tMethod SetTarget(target:Object,channel:TChannel) Abstract\n\tMethod ParentName$() Abstract\nEnd Type\n\nType TSound3D Extends TSound\n\tField _driver:TAudio3DDriver\n\tField _parent:TSound\n\t\n\tFunction FromSound:TSound3D(sound:TSound,driver:TAudio3DDriver)\n\t\tLocal sound3d:TSound3D=New TSound3D\n\t\tsound3d._parent=sound\n\t\tsound3d._driver=driver\n\t\tReturn sound3d\n\tEnd Function\n\t\n\tMethod Emit(target:Object)\n\t\tLocal channel:TChannel=_parent.Cue()\n\t\t_driver.SetTarget target,channel\n\t\tchannel.SetPaused False\n\tEnd Method\n\t\n\tMethod Play:TChannel( alloced_channel:TChannel=Null )\n\t\t_driver.SetTarget Null,alloced_channel\n\t\tReturn _parent.Play(alloced_channel)\n\tEnd Method\n\t\n\tMethod Cue:TChannel( alloced_channel:TChannel=Null )\n\t\tReturn _parent.Cue(alloced_channel)\n\tEnd Method\nEnd Type\n\nType TListener Extends TEntity\n\tField _rolloff#,_doppler#,_distance#\n\t\n\tMethod New()\n\t\tAssert _listener=Null, \"Only one listener can exist!\"\n\tEnd Method\n\t\n\tMethod Lists[]()\n\t\tReturn Super.Lists()\n\tEnd Method\n\t\n\tMethod Copy:TListener(parent:TEntity=Null)\n\t\tReturn Null\n\tEnd Method\n\t\t\n\tMethod GetScales(rolloff# Var,doppler# Var,distance# Var)\t\n\t\trolloff=_rolloff;doppler=_doppler;distance=_distance\n\tEnd Method\n\tMethod SetScales(rolloff#,doppler#,distance#)\n\t\t_rolloff=rolloff;_doppler=doppler;_distance=distance\n\tEnd Method\n\t\n\tMethod RefreshMatrix()\n\t\tSuper.RefreshMatrix()\n\t\tIf _audio3ddriver _audio3ddriver.SetListener _matrix\n\tEnd Method\nEnd Type\n\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetListener:TListener()\n\tReturn _listener\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetListener(parent:TEntity,rolloff#=1.0,doppler#=1.0,distance#=1.0)\n\t_listener.SetParent parent\n\t_listener.SetScales rolloff,doppler,distance\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction GetListenerScales(listener:TListener,rolloff# Var,doppler# Var,distance# Var)\n\tReturn listener.GetScales(rolloff,doppler,distance)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction SetListenerScales(listener:TListener,rolloff#,doppler#,distance#)\n\tReturn listener.SetScales(rolloff,doppler,distance)\nEnd Function\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction EmitSound(sound:TSound,target:Object)\n\tReturn _audio3ddriver.EmitSound(sound,target)\nEnd Function\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"45d1ae2f71691bb7c3a618cb08af6e5d1df7f308","subject":"lugi.bmx: * Added import for lgcore.c","message":"lugi.bmx:\n* Added import for lgcore.c","repos":"nilium\/lugi.mod,nilium\/lugi.mod","old_file":"Core\/lugi.bmx","new_file":"Core\/lugi.bmx","new_contents":"Strict\n\nImport \"lgcore.c\"\n\nConst BYTEFIELD:Int = 0\nConst SHORTFIELD:Int = 1\nConst INTFIELD:Int = 2\nConst FLOATFIELD:Int = 3\nConst LONGFIELD:Int = 4\nConst DOUBLEFIELD:Int = 5\nConst STRINGFIELD:Int = 6\nConst OBJECTFIELD:Int = 7\nConst ARRAYFIELD:Int = 8\n\nExtern \"C\"\n\tFunction p_lugi_register_method(fn:Int(state@ Ptr), name$, clas@ Ptr=Null)\n\tFunction p_lugi_register_field(off%, typ%, name$, clas@ Ptr)\n\t\n\tFunction p_lugi_init(state@ Ptr)\n\t\n\tFunction lua_pushbmaxobject(state@ Ptr, obj:Object)\n\tFunction lua_tobmaxobject:Object(state@ Ptr, index:Int)\n\t\n\tFunction lua_pushbmaxarray(state@ Ptr, arr:Object)\n\tFunction lua_tobmaxarray:Object(state@ Ptr, index:Int)\n\t\n\t' Constructor object - push with BBClass for type as upvalue\n\tFunction p_lugi_new_object:Int(state@ Ptr)\nEnd Extern\n","old_contents":"Strict\n\nConst BYTEFIELD:Int = 0\nConst SHORTFIELD:Int = 1\nConst INTFIELD:Int = 2\nConst FLOATFIELD:Int = 3\nConst LONGFIELD:Int = 4\nConst DOUBLEFIELD:Int = 5\nConst STRINGFIELD:Int = 6\nConst OBJECTFIELD:Int = 7\nConst ARRAYFIELD:Int = 8\n\nExtern \"C\"\n\tFunction p_lugi_register_method(fn:Int(state@ Ptr), name$, clas@ Ptr=Null)\n\tFunction p_lugi_register_field(off%, typ%, name$, clas@ Ptr)\n\t\n\tFunction p_lugi_init(state@ Ptr)\n\t\n\tFunction lua_pushbmaxobject(state@ Ptr, obj:Object)\n\tFunction lua_tobmaxobject:Object(state@ Ptr, index:Int)\n\t\n\tFunction lua_pushbmaxarray(state@ Ptr, arr:Object)\n\tFunction lua_tobmaxarray:Object(state@ Ptr, index:Int)\n\t\n\t' Constructor object - push with BBClass for type as upvalue\n\tFunction p_lugi_new_object:Int(state@ Ptr)\nEnd Extern\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"c997c13136b58a116ab315e0a4422c25c3886761","subject":"change TOUCH0 to MOUSE_LMB for MonkeyMax","message":"change TOUCH0 to MOUSE_LMB for MonkeyMax\n","repos":"swoolcock\/diddy,swoolcock\/diddy,swoolcock\/diddy,swoolcock\/diddy,swoolcock\/diddy","old_file":"monkeymax\/modules\/mojo\/native\/mojo.bmax.bmx","new_file":"monkeymax\/modules\/mojo\/native\/mojo.bmax.bmx","new_contents":"' ***** Start mojo.bmax.bmx ******\r\n\r\nGlobal app:gxtkApp\r\n\r\nType gxtkApp\r\n\tField ginput:gxtkInput\r\n\tField gaudio:gxtkAudio\r\n\tField ggraphics:gxtkGraphics\r\n\r\n\tField dead:Int=0\r\n\tField suspended:Int=0\r\n\tField vloading:Int=0\r\n\tField maxloading:Int=0\r\n\tField updateRate:Int=0\r\n\tField nextUpdate:Float=0\r\n\tField updatePeriod:Float=0\r\n\tField startMillis:Float=0\r\n\t\r\n\tMethod New()' gxtkApp()\r\n\t\tapp=Self\r\n\t\tggraphics=New gxtkGraphics\r\n\tEndMethod\r\n\t\r\n\tMethod Setup()\r\n\t\tginput=New gxtkInput\r\n\t\tgaudio=New gxtkAudio\r\n\r\n\t\tbb_input_SetInputDevice(ginput)\r\n\t\tbb_audio_SetAudioDevice(gaudio)\r\n\t\t\r\n\t\tstartMillis=BlitzMaxMillisecs()\r\n\t\t\r\n\t\tSetFrameRate( 0 )\r\n\t\t\r\n\t\tInvokeOnCreate()\r\n\t\tInvokeOnRender()\r\n\t\tUpdate()\r\n\tEndMethod\r\n\t\r\n\tMethod Update()\r\n\t\tWhile Not AppTerminate()\r\n\t\t\tLocal updates:Int = 0\r\n\t\t\t\r\n\t\t\tLocal cont:Int = 1\r\n\t\t\tWhile (cont)\r\n\t\t\t\tnextUpdate:+updatePeriod\r\n\t\t\t\tInvokeOnUpdate()\r\n\t\t\t\tIf Not updatePeriod Then cont = 0\r\n\t\t\t\tIf nextUpdate>BlitzMaxMillisecs() Then cont = 0\r\n\t\t\t\tupdates:+1\r\n\t\t\t\tIf updates = 7 Then\r\n\t\t\t\t\tnextUpdate = BlitzMaxMillisecs()\r\n\t\t\t\t\tcont = 0\r\n\t\t\t\tEndIf\r\n\t\t\tWend\r\n\t\t\tInvokeOnRender()\r\n\t\tWend\r\n\tEndMethod\r\n\t\r\n\tMethod InvokeOnCreate()\r\n\t\tIf dead Return\r\n\t\tdead = 1\r\n\t\tOnCreate()\r\n\t\tdead = 0\r\n\tEndMethod\r\n\r\n\tMethod InvokeOnUpdate()\r\n\t\tIf dead Or suspended Or Not updateRate Or vloading Return\r\n\t\tOnUpdate()\r\n\tEndMethod\r\n\t\r\n\tMethod InvokeOnRender()\r\n\t\tIf dead Or suspended Return\r\n\t\tggraphics.BeginRender()\r\n\t\tIf vloading\r\n\t\t\tOnLoading()\r\n\t\tElse\r\n\t\t\tOnRender()\r\n\t\tEndIf\r\n\t\tggraphics.EndRender()\r\n\tEndMethod\r\n\t\r\n\t\r\n\tMethod SetFrameRate( fps:Int )\r\n\t\tIf fps\r\n\t\t\tupdatePeriod=1000.0\/fps\r\n\t\t\tnextUpdate=BlitzMaxMillisecs() +updatePeriod\r\n\t\tElse\r\n\t\t\tupdatePeriod=0\r\n\t\tEndIf\r\n\tEndMethod\r\n\r\n\tMethod LoadState:String()\r\n'\t\tvar file:SharedObject=SharedObject.getLocal( \"gxtkapp\" );\r\n'\t\tvar state:String=file.data.state;\r\n'\t\tfile.close();\r\n'\t\tif( state ) return state;\r\n\t\tReturn \"\"\r\n\tEndMethod\r\n\t\r\n\tMethod SaveState:Int( state:String )\r\n'\t\tvar file:SharedObject=SharedObject.getLocal( \"gxtkapp\" );\r\n'\t\tfile.data.state=state;\r\n'\t\tfile.close();\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod LoadString:String( path:String )\r\n\t\tpath = \"data\/\" + path\r\n\t\tReturn LoadText( path )\r\n\tEndMethod\r\n\t\r\n\t' ***** GXTK API *****\r\n\t\r\n\tMethod GraphicsDevice:gxtkGraphics()\r\n\t\tReturn ggraphics\r\n\tEndMethod\r\n\r\n\tMethod InputDevice:gxtkInput()\r\n\t\tReturn ginput\r\n\tEndMethod\r\n\r\n\tMethod AudioDevice:gxtkAudio()\r\n\t\tReturn gaudio\r\n\tEndMethod\r\n\r\n\tMethod SetUpdateRate:Int(hertz:Int)\r\n\t\tupdateRate = hertz\r\n\t\tIf Not vloading Then SetFrameRate(updateRate)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod MilliSecs:Int()\r\n\t\tReturn BlitzMaxMillisecs() - startMillis\r\n\tEndMethod\r\n\t\r\n\tMethod Loading:Int()\r\n\t\tReturn vloading\r\n\tEndMethod\r\n\r\n\tMethod OnCreate:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod OnUpdate:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod OnSuspend:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod OnResume:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod OnRender:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod OnLoading:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkGraphics\r\n\tField gmode:Int = 1\r\n\r\n\tMethod Mode:Int()\r\n\t\tReturn gmode\r\n\tEndMethod\r\n\t\r\n\tMethod Cls:Int(r:Int = 0, g:Int = 0, b:Int = 0)\r\n\t\tBlitzMaxCls(r, g, b)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawPoint:Int(x:Float, y:Float)\r\n\t\tPlot x, y\r\n\tEndMethod\r\n\t\r\n\tMethod LoadSurface:gxtkSurface(path:String)\r\n\t\tLocal image:TImage = LoadImage(\"data\/\"+path)\r\n\t\tIf image Then\r\n\t\t\tLocal gs:gxtkSurface = New gxtkSurface\r\n\t\t\tgs.setImage(image)\r\n\t\t\tReturn gs\r\n\t\tEndIf\r\n\t\tReturn Null\r\n\tEndMethod\r\n\t\r\n\tMethod BeginRender()\r\n\tEndMethod\r\n\t\r\n\tMethod EndRender()\r\n\t\tFlip\r\n\tEndMethod\r\n\t\r\n\tMethod SetColor:Int(r:Int, g:Int, b:Int)\r\n\t\tBlitzMaxSetColor(r, g, b)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod SetAlpha:Int(a:Float)\r\n\t\tBlitzMaxSetAlpha(a)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod SetBlend:Int(blend:Int)\r\n\t\tBlitzMaxSetBlend(blend)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod Width:Int()\r\n\t\tReturn GraphicsWidth()\r\n\tEndMethod\r\n\t\r\n\tMethod Height:Int()\r\n\t\tReturn GraphicsHeight()\r\n\tEndMethod\r\n\t\r\n\tMethod SetScissor:Int(x:Int, y:Int, w:Int, h:Int)\r\n\t\tSetViewport(x, y, w, h) ' NOT TESTED!\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod SetMatrix:Int(ix:Float,iy:Float,jx:Float,jy:Float,tx:Float,ty:Float)\r\n\t\tLocal sx:Float = Sqr( (ix*ix) + (jx*jx) )\r\n\t\tLocal sy:Float = Sqr( (iy*iy) + (jy*jy) )\r\n\t\tLocal rot:Float = -Atan2( jx, ix )\r\n\t\tSetTransform( rot, sx, sy )\r\n\t\tSetOrigin( tx, ty )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawSurface:Int(surface:gxtkSurface,x:Float,y:Float)\r\n\t\tDrawImage(surface.image, x, y, 0)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawSurface2:Int(surface:gxtkSurface,x:Float,y:Float, srcx:Int, srcy:Int, srcw:Int, srch:Int )\r\n\t\tDrawSubImageRect(surface.image, x, y, srcw, srch, srcx, srcy, srcw, srch)\t\t\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawLine:Int( x1:Float,y1:Float,x2:Float,y2:Float )\r\n\t\tBlitzMaxDrawLine(x1, y1, x2, y2)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawOval:Int( x:Float, y:Float, w:Float, h:Float )\r\n\t\tBlitzMaxDrawOval(x, y, w, h)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawPoly:Int(vertices:Float[])\r\n\t\tBlitzMaxDrawPoly( vertices )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawRect:Int( x:Float, y:Float, w:Float, h:Float )\r\n\t\tBlitzMaxDrawRect(x, y, w, h)\r\n\t\tReturn 0\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkInput\r\n\tMethod MouseX:Float()\r\n\t\tReturn BRL.PolledInput.MouseX()\r\n\tEndMethod\r\n\r\n\tMethod MouseY:Float()\r\n\t\tReturn BRL.PolledInput.MouseY()\r\n\tEndMethod\r\n\t\r\n\tMethod KeyDown:Int( key:Int )\r\n\t\tif( key = 384 ) key = 1 ' change TOUCH0 to MOUSE_LMB\r\n\r\n\t\tIf( key >= 1 And key <= 3 )\r\n\t\t\tReturn BRL.PolledInput.MouseDown( key )\r\n\t\tEndIf\r\n\t\tIf key < 256\r\n\t\t\tReturn BRL.PolledInput.KeyDown( key )\r\n\t\tElse\r\n\t\t\tReturn 0\r\n\t\tEndIf\r\n\tEndMethod\r\n\r\n\tMethod KeyHit:Int( key:Int )\r\n\t\tif( key = 384 ) key = 1 ' change TOUCH0 to MOUSE_LMB\r\n\t\tIf( key >= 1 And key <= 3 )\r\n\t\t\tReturn BRL.PolledInput.MouseHit( key )\r\n\t\tEndIf\r\n\t\tIf key < 256\r\n\t\t\tReturn BRL.PolledInput.KeyHit( key )\r\n\t\tElse\r\n\t\t\tReturn 0\r\n\t\tEndIf\r\n\tEndMethod\r\n\r\n\tMethod GetChar:Int()\r\n\t\tReturn BRL.PolledInput.GetChar()\r\n\tEndMethod\r\n\r\n\tMethod JoyX:Int( index:Int )\r\n\t\tReturn Pub.FreeJoy.JoyX( index )\r\n\tEndMethod\r\n\r\n\tMethod JoyY:Int( index:Int )\r\n\t\tReturn Pub.FreeJoy.JoyY( index )\r\n\tEndMethod\r\n\r\n\tMethod JoyZ:Int( index:Int )\r\n\t\tReturn Pub.FreeJoy.JoyZ( index )\r\n\tEndMethod\r\n\r\n\tMethod TouchX:Float( index:Int )\r\n\t\tReturn BRL.PolledInput.MouseX()\r\n\tEndMethod\r\n\r\n\tMethod TouchY:Float( index:Int )\r\n\t\tReturn BRL.PolledInput.MouseY()\r\n\tEndMethod\r\n\t\r\n\tMethod AccelX:Int()\r\n\t\treturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod AccelY:Int()\r\n\t\treturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod AccelZ:Int()\r\n\t\treturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod SetKeyboardEnabled:Int( enabled:int )\r\n\t\tReturn 0\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkChannel\r\n\tField channel:TChannel\t' null then not playing\r\n\tField sample:gxtkSample\r\n\tField loops:int\r\n\t'Field transform:SoundTransform=new SoundTransform()\r\n\t'Field pausepos:Number\r\n\tField state:int\r\n\t\r\n\tMethod New()\r\n\t\tchannel = New TChannel\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkAudio\r\n\tField amusicState:Int = 0\r\n\tField channels:gxtkChannel[] = New gxtkChannel[33]\r\n\t\r\n\tMethod New()\r\n\t\tFor local i:Int = 0 To 33 - 1\r\n\t\t\tchannels[i] = New gxtkChannel\r\n\t\tNext\r\n\tEndMethod\r\n\t\r\n\tMethod MusicState:Int()\r\n'\t\tIf( musicState = 1 And music.isPlaying() = False )\r\n'\t\t\tmusicState = 0;\r\n'\t\tEndif\r\n\t\tReturn amusicState\r\n\tEndMethod\r\n\t\r\n\tMethod PlayMusic:Int( path:String, flags:Int )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod ChannelState:int( channel:int )\r\n\t\tReturn -1\r\n\tEndMethod\r\n\t\r\n\tMethod StopMusic()\r\n\tEndMethod\r\n\t\r\n\tMethod StopChannel( channel:Int )\r\n\tEndMethod\r\n\r\n\tMethod PlaySample( sound:gxtkSample, channel:Int, flags:Int )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\t\r\n\t\t'If chan.state <> 0 Then chan.channel.Stop() <-- this crashes after the first play!?\r\n\t\t\r\n\t\tchan.sample = sound\r\n\t\t'chan.loops = flags ? 0x7fffffff : 0;\r\n\t\t'chan.channel = sample.sound.play( 0,chan.loops,chan.transform );\r\n\t\t'chan.channel = sound\r\n\t\tchan.state=1\r\n\t\r\n\t\tPlaySound( sound.sound, chan.channel )\r\n\tEndMethod\r\n\r\n\tMethod SetPan( channel:Int, pan:Float )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tchan.channel.SetPan(pan)\r\n\tEndMethod\r\n\r\n\tMethod SetRate( channel:Int, rate:Float )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tchan.channel.SetRate(rate)\r\n\tEndMethod\r\n\r\n\tMethod PauseMusic:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod ResumeMusic:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod SetMusicVolume:Int( volume:Float )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod SetVolume:Int( channel:Int, volume:Float )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tchan.channel.SetVolume(volume)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod LoadSample:gxtkSample( path:String )\r\n\t\tLocal sound:TSound = LoadSound(\"data\/\"+path)\r\n\t\tIf sound Then\r\n\t\t\tLocal gs:gxtkSample = New gxtkSample\r\n\t\t\tgs.setSound(sound)\r\n\t\t\tReturn gs\r\n\t\tEndIf\r\n\t\tReturn Null\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkSample\r\n\tField sound:TSound\r\n\t\r\n\tMethod setSound(sound:TSound)\r\n\t\tSelf.sound = sound\r\n\tEndMethod\r\n\t\r\n\tMethod Discard()\r\n\t\tSelf.sound = null\r\n\tEndMethod\r\nEndType\r\n\r\nFunction BlitzMaxDrawPoly:Int(vertices:Float[])\r\n\tDrawPoly vertices\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxDrawRect:Int( x:Float, y:Float, w:Float, h:Float )\r\n\tDrawRect x, y, w, h\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxDrawOval:Int( x:Float, y:Float, w:Float, h:Float )\r\n\tDrawOval x, y, w, h\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxDrawLine:Int( x1:Float,y1:Float,x2:Float,y2:Float )\r\n\tDrawLine x1, y1, x2, y2\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxMillisecs:Int()\r\n\tReturn MilliSecs()\r\nEndFunction\r\n\r\nFunction BlitzMaxSetColor(r:Int, g:Int, b:Int)\r\n\tSetColor(r, g, b)\r\nEndFunction\r\n\r\nFunction BlitzMaxSetBlend(blend:Int)\r\n\tSelect blend\r\n\t\tCase 0\r\n\t\t\tSetBlend( ALPHABLEND )\r\n\t\tCase 1\r\n\t\t\tSetBlend( LIGHTBLEND )\r\n\tEnd Select\r\nEndFunction\r\n\r\nFunction BlitzMaxSetAlpha(a:Float)\r\n\tSetAlpha(a)\r\nEndFunction\r\n\r\nFunction BlitzMaxCls(r:Int = 0, g:Int = 0, b:Int = 0)\r\n\tSetClsColor(r, g, b)\r\n\tCls\r\nEndFunction\r\n\r\nType gxtkSurface\r\n\tField w:Int, h:Int\r\n\tField image:TImage\r\n\t\r\n\tMethod setImage(image:TImage)\r\n\t\tSelf.image = image\r\n\tEndMethod\r\n\t\r\n\tMethod Width:Int()\r\n\t\tReturn image.Width\r\n\tEndMethod\r\n\t\r\n\tMethod Height:Int()\r\n\t\tReturn image.Height\r\n\tEndMethod\r\n\t\r\n\tMethod Discard()\r\n\tEndMethod\r\nEndType\r\n\r\n' ***** End mojo.bmax.bmx ******\r\n\r\n","old_contents":"' ***** Start mojo.bmax.bmx ******\r\n\r\nGlobal app:gxtkApp\r\n\r\nType gxtkApp\r\n\tField ginput:gxtkInput\r\n\tField gaudio:gxtkAudio\r\n\tField ggraphics:gxtkGraphics\r\n\r\n\tField dead:Int=0\r\n\tField suspended:Int=0\r\n\tField vloading:Int=0\r\n\tField maxloading:Int=0\r\n\tField updateRate:Int=0\r\n\tField nextUpdate:Float=0\r\n\tField updatePeriod:Float=0\r\n\tField startMillis:Float=0\r\n\t\r\n\tMethod New()' gxtkApp()\r\n\t\tapp=Self\r\n\t\tggraphics=New gxtkGraphics\r\n\tEndMethod\r\n\t\r\n\tMethod Setup()\r\n\t\tginput=New gxtkInput\r\n\t\tgaudio=New gxtkAudio\r\n\r\n\t\tbb_input_SetInputDevice(ginput)\r\n\t\tbb_audio_SetAudioDevice(gaudio)\r\n\t\t\r\n\t\tstartMillis=BlitzMaxMillisecs()\r\n\t\t\r\n\t\tSetFrameRate( 0 )\r\n\t\t\r\n\t\tInvokeOnCreate()\r\n\t\tInvokeOnRender()\r\n\t\tUpdate()\r\n\tEndMethod\r\n\t\r\n\tMethod Update()\r\n\t\tWhile Not AppTerminate()\r\n\t\t\tLocal updates:Int = 0\r\n\t\t\t\r\n\t\t\tLocal cont:Int = 1\r\n\t\t\tWhile (cont)\r\n\t\t\t\tnextUpdate:+updatePeriod\r\n\t\t\t\tInvokeOnUpdate()\r\n\t\t\t\tIf Not updatePeriod Then cont = 0\r\n\t\t\t\tIf nextUpdate>BlitzMaxMillisecs() Then cont = 0\r\n\t\t\t\tupdates:+1\r\n\t\t\t\tIf updates = 7 Then\r\n\t\t\t\t\tnextUpdate = BlitzMaxMillisecs()\r\n\t\t\t\t\tcont = 0\r\n\t\t\t\tEndIf\r\n\t\t\tWend\r\n\t\t\tInvokeOnRender()\r\n\t\tWend\r\n\tEndMethod\r\n\t\r\n\tMethod InvokeOnCreate()\r\n\t\tIf dead Return\r\n\t\tdead = 1\r\n\t\tOnCreate()\r\n\t\tdead = 0\r\n\tEndMethod\r\n\r\n\tMethod InvokeOnUpdate()\r\n\t\tIf dead Or suspended Or Not updateRate Or vloading Return\r\n\t\tOnUpdate()\r\n\tEndMethod\r\n\t\r\n\tMethod InvokeOnRender()\r\n\t\tIf dead Or suspended Return\r\n\t\tggraphics.BeginRender()\r\n\t\tIf vloading\r\n\t\t\tOnLoading()\r\n\t\tElse\r\n\t\t\tOnRender()\r\n\t\tEndIf\r\n\t\tggraphics.EndRender()\r\n\tEndMethod\r\n\t\r\n\t\r\n\tMethod SetFrameRate( fps:Int )\r\n\t\tIf fps\r\n\t\t\tupdatePeriod=1000.0\/fps\r\n\t\t\tnextUpdate=BlitzMaxMillisecs() +updatePeriod\r\n\t\tElse\r\n\t\t\tupdatePeriod=0\r\n\t\tEndIf\r\n\tEndMethod\r\n\r\n\tMethod LoadState:String()\r\n'\t\tvar file:SharedObject=SharedObject.getLocal( \"gxtkapp\" );\r\n'\t\tvar state:String=file.data.state;\r\n'\t\tfile.close();\r\n'\t\tif( state ) return state;\r\n\t\tReturn \"\"\r\n\tEndMethod\r\n\t\r\n\tMethod SaveState:Int( state:String )\r\n'\t\tvar file:SharedObject=SharedObject.getLocal( \"gxtkapp\" );\r\n'\t\tfile.data.state=state;\r\n'\t\tfile.close();\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod LoadString:String( path:String )\r\n\t\tpath = \"data\/\" + path\r\n\t\tReturn LoadText( path )\r\n\tEndMethod\r\n\t\r\n\t' ***** GXTK API *****\r\n\t\r\n\tMethod GraphicsDevice:gxtkGraphics()\r\n\t\tReturn ggraphics\r\n\tEndMethod\r\n\r\n\tMethod InputDevice:gxtkInput()\r\n\t\tReturn ginput\r\n\tEndMethod\r\n\r\n\tMethod AudioDevice:gxtkAudio()\r\n\t\tReturn gaudio\r\n\tEndMethod\r\n\r\n\tMethod SetUpdateRate:Int(hertz:Int)\r\n\t\tupdateRate = hertz\r\n\t\tIf Not vloading Then SetFrameRate(updateRate)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod MilliSecs:Int()\r\n\t\tReturn BlitzMaxMillisecs() - startMillis\r\n\tEndMethod\r\n\t\r\n\tMethod Loading:Int()\r\n\t\tReturn vloading\r\n\tEndMethod\r\n\r\n\tMethod OnCreate:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod OnUpdate:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod OnSuspend:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod OnResume:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod OnRender:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod OnLoading:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkGraphics\r\n\tField gmode:Int = 1\r\n\r\n\tMethod Mode:Int()\r\n\t\tReturn gmode\r\n\tEndMethod\r\n\t\r\n\tMethod Cls:Int(r:Int = 0, g:Int = 0, b:Int = 0)\r\n\t\tBlitzMaxCls(r, g, b)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawPoint:Int(x:Float, y:Float)\r\n\t\tPlot x, y\r\n\tEndMethod\r\n\t\r\n\tMethod LoadSurface:gxtkSurface(path:String)\r\n\t\tLocal image:TImage = LoadImage(\"data\/\"+path)\r\n\t\tIf image Then\r\n\t\t\tLocal gs:gxtkSurface = New gxtkSurface\r\n\t\t\tgs.setImage(image)\r\n\t\t\tReturn gs\r\n\t\tEndIf\r\n\t\tReturn Null\r\n\tEndMethod\r\n\t\r\n\tMethod BeginRender()\r\n\tEndMethod\r\n\t\r\n\tMethod EndRender()\r\n\t\tFlip\r\n\tEndMethod\r\n\t\r\n\tMethod SetColor:Int(r:Int, g:Int, b:Int)\r\n\t\tBlitzMaxSetColor(r, g, b)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod SetAlpha:Int(a:Float)\r\n\t\tBlitzMaxSetAlpha(a)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod SetBlend:Int(blend:Int)\r\n\t\tBlitzMaxSetBlend(blend)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod Width:Int()\r\n\t\tReturn GraphicsWidth()\r\n\tEndMethod\r\n\t\r\n\tMethod Height:Int()\r\n\t\tReturn GraphicsHeight()\r\n\tEndMethod\r\n\t\r\n\tMethod SetScissor:Int(x:Int, y:Int, w:Int, h:Int)\r\n\t\tSetViewport(x, y, w, h) ' NOT TESTED!\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod SetMatrix:Int(ix:Float,iy:Float,jx:Float,jy:Float,tx:Float,ty:Float)\r\n\t\tLocal sx:Float = Sqr( (ix*ix) + (jx*jx) )\r\n\t\tLocal sy:Float = Sqr( (iy*iy) + (jy*jy) )\r\n\t\tLocal rot:Float = -Atan2( jx, ix )\r\n\t\tSetTransform( rot, sx, sy )\r\n\t\tSetOrigin( tx, ty )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawSurface:Int(surface:gxtkSurface,x:Float,y:Float)\r\n\t\tDrawImage(surface.image, x, y, 0)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawSurface2:Int(surface:gxtkSurface,x:Float,y:Float, srcx:Int, srcy:Int, srcw:Int, srch:Int )\r\n\t\tDrawSubImageRect(surface.image, x, y, srcw, srch, srcx, srcy, srcw, srch)\t\t\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawLine:Int( x1:Float,y1:Float,x2:Float,y2:Float )\r\n\t\tBlitzMaxDrawLine(x1, y1, x2, y2)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawOval:Int( x:Float, y:Float, w:Float, h:Float )\r\n\t\tBlitzMaxDrawOval(x, y, w, h)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawPoly:Int(vertices:Float[])\r\n\t\tBlitzMaxDrawPoly( vertices )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawRect:Int( x:Float, y:Float, w:Float, h:Float )\r\n\t\tBlitzMaxDrawRect(x, y, w, h)\r\n\t\tReturn 0\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkInput\r\n\tMethod MouseX:Float()\r\n\t\tReturn BRL.PolledInput.MouseX()\r\n\tEndMethod\r\n\r\n\tMethod MouseY:Float()\r\n\t\tReturn BRL.PolledInput.MouseY()\r\n\tEndMethod\r\n\t\r\n\tMethod KeyDown:Int( key:Int )\r\n\t\tIf( key >= 1 And key <= 3 )\r\n\t\t\tReturn BRL.PolledInput.MouseDown( key )\r\n\t\tEndIf\r\n\t\tIf key < 256\r\n\t\t\tReturn BRL.PolledInput.KeyDown( key )\r\n\t\tElse\r\n\t\t\tReturn 0\r\n\t\tEndIf\r\n\tEndMethod\r\n\r\n\tMethod KeyHit:Int( key:Int )\r\n\t\tIf( key >= 1 And key <= 3 )\r\n\t\t\tReturn BRL.PolledInput.MouseHit( key )\r\n\t\tEndIf\r\n\t\tIf key < 256\r\n\t\t\tReturn BRL.PolledInput.KeyHit( key )\r\n\t\tElse\r\n\t\t\tReturn 0\r\n\t\tEndIf\r\n\tEndMethod\r\n\r\n\tMethod GetChar:Int()\r\n\t\tReturn BRL.PolledInput.GetChar()\r\n\tEndMethod\r\n\r\n\tMethod JoyX:Int( index:Int )\r\n\t\tReturn Pub.FreeJoy.JoyX( index )\r\n\tEndMethod\r\n\r\n\tMethod JoyY:Int( index:Int )\r\n\t\tReturn Pub.FreeJoy.JoyY( index )\r\n\tEndMethod\r\n\r\n\tMethod JoyZ:Int( index:Int )\r\n\t\tReturn Pub.FreeJoy.JoyZ( index )\r\n\tEndMethod\r\n\r\n\tMethod TouchX:Float( index:Int )\r\n\t\tReturn BRL.PolledInput.MouseX()\r\n\tEndMethod\r\n\r\n\tMethod TouchY:Float( index:Int )\r\n\t\tReturn BRL.PolledInput.MouseY()\r\n\tEndMethod\r\n\t\r\n\tMethod AccelX:Int()\r\n\t\treturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod AccelY:Int()\r\n\t\treturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod AccelZ:Int()\r\n\t\treturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod SetKeyboardEnabled:Int( enabled:int )\r\n\t\tReturn 0\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkChannel\r\n\tField channel:TChannel\t' null then not playing\r\n\tField sample:gxtkSample\r\n\tField loops:int\r\n\t'Field transform:SoundTransform=new SoundTransform()\r\n\t'Field pausepos:Number\r\n\tField state:int\r\n\t\r\n\tMethod New()\r\n\t\tchannel = New TChannel\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkAudio\r\n\tField amusicState:Int = 0\r\n\tField channels:gxtkChannel[] = New gxtkChannel[33]\r\n\t\r\n\tMethod New()\r\n\t\tFor local i:Int = 0 To 33 - 1\r\n\t\t\tchannels[i] = New gxtkChannel\r\n\t\tNext\r\n\tEndMethod\r\n\t\r\n\tMethod MusicState:Int()\r\n'\t\tIf( musicState = 1 And music.isPlaying() = False )\r\n'\t\t\tmusicState = 0;\r\n'\t\tEndif\r\n\t\tReturn amusicState\r\n\tEndMethod\r\n\t\r\n\tMethod PlayMusic:Int( path:String, flags:Int )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod ChannelState:int( channel:int )\r\n\t\tReturn -1\r\n\tEndMethod\r\n\t\r\n\tMethod StopMusic()\r\n\tEndMethod\r\n\t\r\n\tMethod StopChannel( channel:Int )\r\n\tEndMethod\r\n\r\n\tMethod PlaySample( sound:gxtkSample, channel:Int, flags:Int )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\t\r\n\t\t'If chan.state <> 0 Then chan.channel.Stop() <-- this crashes after the first play!?\r\n\t\t\r\n\t\tchan.sample = sound\r\n\t\t'chan.loops = flags ? 0x7fffffff : 0;\r\n\t\t'chan.channel = sample.sound.play( 0,chan.loops,chan.transform );\r\n\t\t'chan.channel = sound\r\n\t\tchan.state=1\r\n\t\r\n\t\tPlaySound( sound.sound, chan.channel )\r\n\tEndMethod\r\n\r\n\tMethod SetPan( channel:Int, pan:Float )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tchan.channel.SetPan(pan)\r\n\tEndMethod\r\n\r\n\tMethod SetRate( channel:Int, rate:Float )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tchan.channel.SetRate(rate)\r\n\tEndMethod\r\n\r\n\tMethod PauseMusic:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod ResumeMusic:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod SetMusicVolume:Int( volume:Float )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod SetVolume:Int( channel:Int, volume:Float )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tchan.channel.SetVolume(volume)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod LoadSample:gxtkSample( path:String )\r\n\t\tLocal sound:TSound = LoadSound(\"data\/\"+path)\r\n\t\tIf sound Then\r\n\t\t\tLocal gs:gxtkSample = New gxtkSample\r\n\t\t\tgs.setSound(sound)\r\n\t\t\tReturn gs\r\n\t\tEndIf\r\n\t\tReturn Null\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkSample\r\n\tField sound:TSound\r\n\t\r\n\tMethod setSound(sound:TSound)\r\n\t\tSelf.sound = sound\r\n\tEndMethod\r\n\t\r\n\tMethod Discard()\r\n\t\tSelf.sound = null\r\n\tEndMethod\r\nEndType\r\n\r\nFunction BlitzMaxDrawPoly:Int(vertices:Float[])\r\n\tDrawPoly vertices\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxDrawRect:Int( x:Float, y:Float, w:Float, h:Float )\r\n\tDrawRect x, y, w, h\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxDrawOval:Int( x:Float, y:Float, w:Float, h:Float )\r\n\tDrawOval x, y, w, h\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxDrawLine:Int( x1:Float,y1:Float,x2:Float,y2:Float )\r\n\tDrawLine x1, y1, x2, y2\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxMillisecs:Int()\r\n\tReturn MilliSecs()\r\nEndFunction\r\n\r\nFunction BlitzMaxSetColor(r:Int, g:Int, b:Int)\r\n\tSetColor(r, g, b)\r\nEndFunction\r\n\r\nFunction BlitzMaxSetBlend(blend:Int)\r\n\tSelect blend\r\n\t\tCase 0\r\n\t\t\tSetBlend( ALPHABLEND )\r\n\t\tCase 1\r\n\t\t\tSetBlend( LIGHTBLEND )\r\n\tEnd Select\r\nEndFunction\r\n\r\nFunction BlitzMaxSetAlpha(a:Float)\r\n\tSetAlpha(a)\r\nEndFunction\r\n\r\nFunction BlitzMaxCls(r:Int = 0, g:Int = 0, b:Int = 0)\r\n\tSetClsColor(r, g, b)\r\n\tCls\r\nEndFunction\r\n\r\nType gxtkSurface\r\n\tField w:Int, h:Int\r\n\tField image:TImage\r\n\t\r\n\tMethod setImage(image:TImage)\r\n\t\tSelf.image = image\r\n\tEndMethod\r\n\t\r\n\tMethod Width:Int()\r\n\t\tReturn image.Width\r\n\tEndMethod\r\n\t\r\n\tMethod Height:Int()\r\n\t\tReturn image.Height\r\n\tEndMethod\r\n\t\r\n\tMethod Discard()\r\n\tEndMethod\r\nEndType\r\n\r\n' ***** End mojo.bmax.bmx ******\r\n\r\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"6cff5c29c1e597637d8956b7b63449d46bcca87e","subject":"Changed mxUpdateImpl to be a command only","message":"Changed mxUpdateImpl to be a command only\n","repos":"maximos\/maximus","old_file":"src\/impl\/update.bmx","new_file":"src\/impl\/update.bmx","new_contents":"\nRem\nCopyright (c) 2010 Christiaan Kras\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and\/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\nEnd Rem\n\nRem\n\tbbdoc: Maximus 'update' argument implementation.\nEnd Rem\nType mxUpdateImpl Extends mxArgumentImplementation\n\t\n\tMethod New()\n\t\tinit([\"update\"])\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Check the current arguments for errors (according to the specific implementation).\n\t\treturns: Nothing.\n\t\tabout: This method will throw an error if the given arguments are invalid.\n\tEnd Rem\n\tMethod CheckArgs()\n\t\tSelect GetCallConvention()\n\t\t\tCase mxCallConvention.COMMAND ' \"update\"\n\t\t\t\tIf m_args <> Null\n\t\t\t\t\tThrowCommonError(mxCmdErrors.DOESNOTTAKEPARAMS, \"update\")\n\t\t\t\tEnd If\n\t\tEnd Select\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get a string describing the typical usage of the argument.\n\t\treturns: A string describing the typical usage of the argument.\n\tEnd Rem\n\tMethod GetUsage:String()\n\t\tReturn \"description: Retrieve latest sources~n\" + ..\n\t\t\t\t\"usage: maximus update\"\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Execute the implementation's operation.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod Execute()\n\t\tlogger.LogMessage(\"Retrieving sources...\")\n\tEnd Method\n\t\nEnd Type\n\n","old_contents":"\nRem\nCopyright (c) 2010 Christiaan Kras\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and\/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\nEnd Rem\n\nRem\n\tbbdoc: Maximus 'update' argument implementation.\nEnd Rem\nType mxUpdateImpl Extends mxArgumentImplementation\n\t\n\tMethod New()\n\t\tinit([\"update\", \"--update\", \"-u\"])\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Check the current arguments for errors (according to the specific implementation).\n\t\treturns: Nothing.\n\t\tabout: This method will throw an error if the given arguments are invalid.\n\tEnd Rem\n\tMethod CheckArgs()\n\t\tSelect GetCallConvention()\n\t\t\tCase mxCallConvention.COMMAND ' \"update\"\n\t\t\t\tIf m_args <> Null\n\t\t\t\t\tThrowCommonError(mxCmdErrors.DOESNOTTAKEPARAMS, \"update\")\n\t\t\t\tEnd If\n\t\t\tCase mxCallConvention.OPTION ' \"-u\" or \"--update\"\n\t\t\t\tIf m_args <> Null\n\t\t\t\t\tThrowCommonError(mxOptErrors.DOESNOTTAKEPARAMS, \"-u|--update\")\n\t\t\t\tEnd If\n\t\tEnd Select\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get a string describing the typical usage of the argument.\n\t\treturns: A string describing the typical usage of the argument.\n\tEnd Rem\n\tMethod GetUsage:String()\n\t\tReturn \"description: Retrieve latest sources~n\" + ..\n\t\t\t\t\"usage: maximus update (or maximus -u|--update)\"\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Execute the implementation's operation.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod Execute()\n\t\tlogger.LogMessage(\"Retrieving sources...\")\n\tEnd Method\nEnd Type\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"d7e2836041ef62b96860ab0b316b54581f27d07d","subject":"cleanup","message":"cleanup\n","repos":"maximos\/maximus","old_file":"src\/utils.bmx","new_file":"src\/utils.bmx","new_contents":"\nRem\n\tbbdoc: Maximus module utilities.\nEnd Rem\nType mxModUtils\n\t\n\tGlobal g_modules:dObjectMap\n\t\n\tRem\n\t\tbbdoc: Get an object map of the current modules.\n\t\treturns: An object map containing the current modules.\n\t\tabout: @force can be used to force re-enumeration of the modules.\n\tEnd Rem\n\tFunction GetModules:dObjectMap(force:Int = False)\n\t\tIf Not g_modules Or force\n\t\t\tg_modules = EnumModules(Null, Null)\n\t\tEnd If\n\t\tReturn g_modules\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Check if the user currently has the given module.\n\t\treturns: True if the given module was found.\n\tEnd Rem\n\tFunction HasModule:Int(modul:String)\n\t\tReturn GetModules()._Contains(modul)\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Get the path to the given module or modscope.\n\t\treturns: The path to the given module or modscope, or the modules path if the given modid is Null.\n\tEnd Rem\n\tFunction ModulePath:String(modid:String)\n\t\tLocal p:String = mainapp.m_modpath\n\t\tIf modid Then p:+ \"\/\" + modid.Replace(\".\", \".mod\/\") + \".mod\"\n\t\tReturn p\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Get the path to the main source file for the given module id .\n\t\treturns: The path to the given module's main source file, or Null if the given module id is Null.\n\tEnd Rem\n\tFunction SourceFilePath:String(modid:String)\n\t\tIf modid\n\t\t\tReturn ModulePath(modid) + \"\/\" + GetNameFromID(modid) + \".bmx\"\n\t\tEnd If\n\t\tReturn Null\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Get the module scope from the given versioned-module id (for modules with forced versions (or normal ids), e.g. mxModUtils.GetScopeFromID(\"foo.bar\/dev\") would return \"foo\").\n\t\treturns: The scope of the given versioned-module id, or Null if the given versioned-module id was incorrect.\n\tEnd Rem\n\tFunction GetScopeFromID:String(verid:String)\n\t\tverid = GetIDFromVerID(verid)\n\t\tLocal i:Int = verid.Find(\".\")\n\t\tIf i > -1 Then Return verid[..i]\n\t\tReturn Null\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Get the module name from the given versioned-module id (for modules with forced versions (or normal ids), e.g. mxModUtils.GetNameFromID(\"foo.bar\/dev\") would return \"bar\").\n\t\treturns: The name of the given versioned-module id, or Null if the given versioned-module is was incorrect.\n\tEnd Rem\n\tFunction GetNameFromID:String(verid:String)\n\t\tverid = GetIDFromVerID(verid)\n\t\tLocal i:Int = verid.Find(\".\")\n\t\tIf i > -1 Then Return verid[i + 1..]\n\t\tReturn Null\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Get the actual module id from the given versioned-module id (for modules with forced versions (or normal ids), e.g. mxModUtils.GetIDFromVerID(\"foo.bar\/dev\") would return \"foo.bar\").\n\t\treturns: The id of the given versioned-module id.\n\tEnd Rem\n\tFunction GetIDFromVerID:String(verid:String)\n\t\tLocal i:Int = verid.Find(\"\/\")\n\t\tIf i > -1 Then verid = verid[..i]\n\t\tReturn verid\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Get the version from the given versioned-module id (for modules with forced versions, e.g. mxModUtils.GetVersionFromVerID(\"foo.bar\/dev) would return \"dev\").\n\t\treturns: The version of the given versioned-module id (which will be Null if the given value is not versioned).\n\tEnd Rem\n\tFunction GetVersionFromVerID:String(verid:String)\n\t\tLocal i:Int = verid.Find(\"\/\")\n\t\tIf i > -1 Then Return verid[i + 1..]\n\t\tReturn Null\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Get the version of the module from the given versioned-module id, if it is installed.\n\t\treturns: The module's version (which may be \"dev\" if Subversion or git is found controlling the module's directory), or Null if the module was not found.\n\tEnd Rem\n\tFunction GetInstalledVersionFromVerID:String(verid:String)\n\t\tverid = GetIDFromVerID(verid)\n\t\t'DebugLog(\"(mxModUtils.GetInstalledVersionFromVerID) modid: \" + verid)\n\t\tLocal ver:String\n\t\tLocal path:String = mxModUtils.ModulePath(verid) + \"\/\"\n\t\tIf FileType(path) = FILETYPE_DIR\n\t\t\tIf FileType(path + \".git\") = FILETYPE_DIR Or FileType(path + \".svn\") = FILETYPE_DIR\n\t\t\t\tver = \"dev\"\n\t\t\tElse If FileType(path + GetNameFromID(verid) + \".bmx\") = FILETYPE_FILE\n\t\t\t\tLocal stream:TStream = ReadStream(path + GetNameFromID(verid) + \".bmx\")\n\t\t\t\tIf stream\n\t\t\t\t\tLocal line:String\n\t\t\t\t\tWhile Not stream.Eof()\n\t\t\t\t\t\tline = stream.ReadLine().Trim().ToLower()\n\t\t\t\t\t\tIf line.Contains(\"moduleinfo\") And line.Contains(\"version\")\n\t\t\t\t\t\t\tline = line.Replace(\" \", \"\").Replace(\"~q\", \"\")\n\t\t\t\t\t\t\t'Local vp:Int = line.Find(\"moduleinfoversion:\")\n\t\t\t\t\t\t\tIf line.StartsWith(\"moduleinfoversion:\") ' vp > -1 And (vp + 18 <= line.Length)\n\t\t\t\t\t\t\t\tver = line[18..]\n\t\t\t\t\t\t\t\tExit\n\t\t\t\t\t\t\tEnd If\n\t\t\t\t\t\tEnd If\n\t\t\t\t\tEnd While\n\t\t\t\t\tstream.Close()\n\t\t\t\tEnd If\n\t\t\tEnd If\n\t\tEnd If\n\t\tReturn ver\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Enumerate all of the current modules.\n\t\treturns: An object map containing the current modules.\n\tEnd Rem\n\tFunction EnumModules:dObjectMap(modid:String = Null, mods:dObjectMap = Null)\n\t\tIf Not mods Then mods = New dObjectMap\n\t\tLocal dir:String = ModulePath(modid)\n\t\tLocal files:String[] = LoadDir(dir)\n\t\tFor Local file:String = EachIn files\n\t\t\tLocal path:String = dir + \"\/\" + file\n\t\t\tIf file[file.length - 4..] <> \".mod\" Or FileType(path) <> FILETYPE_DIR Then Continue\n\t\t\tLocal t:String = file[..file.length - 4]\n\t\t\tIf modid Then t = modid + \".\" + t\n\t\t\tLocal i:Int = t.Find(\".\")\n\t\t\tIf i > -1 And t.Find(\".\", i + 1) = -1 Then mods._Insert(t, path)\n\t\t\tEnumModules(t, mods)\n\t\tNext\n\t\tReturn mods\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Document all modules, or the modules given (doesn't work yet - all documentation will be built).\n\t\treturns: The exit code from makedocs.\n\tEnd Rem\n\tFunction DocMods:Int(args:String = Null)\n\t\targs = \"docmods \" + args.Trim()\n\t\tlogger.LogMessage(\"run: \" + args)\n\t\tReturn system_(mainapp.m_binpath + \"\/\" + args)\n\tEnd Function\n\t\nEnd Type\n\nRem\n\tbbdoc: Maximus BMK utilities.\nEnd Rem\nType mxBMKUtils\n\t\n\tRem\n\t\tbbdoc: Run BMK with the given arguments.\n\t\treturns: The exit code from bmk (non-zero when an error occured).\n\tEnd Rem\n\tFunction RunBMK:Int(args:String)\n\t\targs = \"bmk \" + args.Trim()\n\t\tlogger.LogMessage(\"run: \" + args)\n\t\tReturn system_(mainapp.m_binpath + \"\/\" + args)\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Make modules with the given arguments.\n\t\treturns: The exit code from bmk (non-zero when an error occured).\n\tEnd Rem\n\tFunction MakeMods:Int(args:String, threaded:Int)\n\t\tLocal opts:String\n\t\tIf threaded Then opts:+ \" -h\"\n\t\tReturn RunBMK(\"makemods\" + opts + \" \" + args)\n\tEnd Function\n\t\nEnd Type\n\nRem\n\tbbdoc: Maximus temporary progress storage for url fetching.\nEnd Rem\nType _mxProgressStore\n\t\n\tField m_progress:Int = 0\n\t\nEnd Type\n\n","old_contents":"\nRem\n\tbbdoc: Maximus module utilities.\nEnd Rem\nType mxModUtils\n\t\n\tGlobal g_modules:dObjectMap\n\t\n\tRem\n\t\tbbdoc: Get an object map of the current modules.\n\t\treturns: An object map containing the current modules.\n\t\tabout: @force can be used to force re-enumeration of the modules.\n\tEnd Rem\n\tFunction GetModules:dObjectMap(force:Int = False)\n\t\tIf Not g_modules Or force\n\t\t\tg_modules = EnumModules(Null, Null)\n\t\tEnd If\n\t\tReturn g_modules\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Check if the user currently has the given module.\n\t\treturns: True if the given module was found.\n\tEnd Rem\n\tFunction HasModule:Int(modul:String)\n\t\tReturn GetModules()._Contains(modul)\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Get the path to the given module or modscope.\n\t\treturns: The path to the given module or modscope, or the modules path if the given modid is Null.\n\tEnd Rem\n\tFunction ModulePath:String(modid:String)\n\t\tLocal p:String = mainapp.m_modpath\n\t\tIf modid Then p:+ \"\/\" + modid.Replace(\".\", \".mod\/\") + \".mod\"\n\t\tReturn p\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Get the path to the main source file for the given module id .\n\t\treturns: The path to the given module's main source file, or Null if the given module id is Null.\n\tEnd Rem\n\tFunction SourceFilePath:String(modid:String)\n\t\tIf modid\n\t\t\tReturn ModulePath(modid) + \"\/\" + GetNameFromID(modid) + \".bmx\"\n\t\tEnd If\n\t\tReturn Null\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Get the module scope from the given versioned-module id (for modules with forced versions (or normal ids), e.g. mxModUtils.GetScopeFromID(\"foo.bar\/dev\") would return \"foo\").\n\t\treturns: The scope of the given versioned-module id, or Null if the given versioned-module id was incorrect.\n\tEnd Rem\n\tFunction GetScopeFromID:String(verid:String)\n\t\tverid = GetIDFromVerID(verid)\n\t\tLocal i:Int = verid.Find(\".\")\n\t\tIf i > -1 Then Return verid[..i]\n\t\tReturn Null\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Get the module name from the given versioned-module id (for modules with forced versions (or normal ids), e.g. mxModUtils.GetNameFromID(\"foo.bar\/dev\") would return \"bar\").\n\t\treturns: The name of the given versioned-module id, or Null if the given versioned-module is was incorrect.\n\tEnd Rem\n\tFunction GetNameFromID:String(verid:String)\n\t\tverid = GetIDFromVerID(verid)\n\t\tLocal i:Int = verid.Find(\".\")\n\t\tIf i > -1 Then Return verid[i + 1..]\n\t\tReturn Null\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Get the actual module id from the given versioned-module id (for modules with forced versions (or normal ids), e.g. mxModUtils.GetIDFromVerID(\"foo.bar\/dev\") would return \"foo.bar\").\n\t\treturns: The id of the given versioned-module id.\n\tEnd Rem\n\tFunction GetIDFromVerID:String(verid:String)\n\t\tLocal i:Int = verid.Find(\"\/\")\n\t\tIf i > -1 Then verid = verid[..i]\n\t\tReturn verid\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Get the version from the given versioned-module id (for modules with forced versions, e.g. mxModUtils.GetVersionFromVerID(\"foo.bar\/dev) would return \"dev\").\n\t\treturns: The version of the given versioned-module id (which will be Null if the given value is not versioned).\n\tEnd Rem\n\tFunction GetVersionFromVerID:String(verid:String)\n\t\tLocal i:Int = verid.Find(\"\/\")\n\t\tIf i > -1 Then Return verid[i + 1..]\n\t\tReturn Null\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Get the version of the module from the given versioned-module id, if it is installed.\n\t\treturns: The module's version (which may be \"dev\" if Subversion or git is found controlling the module's directory), or Null if the module was not found.\n\tEnd Rem\n\tFunction GetInstalledVersionFromVerID:String(verid:String)\n\t\tverid = GetIDFromVerID(verid)\n\t\t'DebugLog(\"(mxModUtils.GetInstalledVersionFromVerID) modid: \" + verid)\n\t\tLocal ver:String\n\t\tLocal path:String = mxModUtils.ModulePath(verid) + \"\/\"\n\t\tIf FileType(path) = FILETYPE_DIR\n\t\t\tIf FileType(path + \".git\") = FILETYPE_DIR Or FileType(path + \".svn\") = FILETYPE_DIR\n\t\t\t\tver = \"dev\"\n\t\t\tElse If FileType(path + GetNameFromID(verid) + \".bmx\") = FILETYPE_FILE\n\t\t\t\tLocal stream:TStream = ReadStream(path + GetNameFromID(verid) + \".bmx\")\n\t\t\t\tIf stream\n\t\t\t\t\tLocal line:String\n\t\t\t\t\tWhile Not stream.Eof()\n\t\t\t\t\t\tline = stream.ReadLine().Trim().ToLower()\n\t\t\t\t\t\tIf line.Contains(\"moduleinfo\") And line.Contains(\"version\")\n\t\t\t\t\t\t\tline = line.Replace(\" \", \"\").Replace(\"~q\", \"\")\n\t\t\t\t\t\t\t'Local vp:Int = line.Find(\"moduleinfoversion:\")\n\t\t\t\t\t\t\tIf line.StartsWith(\"moduleinfoversion:\") ' vp > -1 And (vp + 18 <= line.Length)\n\t\t\t\t\t\t\t\tver = line[18..]\n\t\t\t\t\t\t\t\tExit\n\t\t\t\t\t\t\tEnd If\n\t\t\t\t\t\tEnd If\n\t\t\t\t\tEnd While\n\t\t\t\t\tstream.Close()\n\t\t\t\tEnd If\n\t\t\tEnd If\n\t\tEnd If\n\t\tReturn ver\n\tEnd Function\n\t\n\tRem\n\tFunction GetInstalledVersionFromVerID:String(verid:String)\n\t\tverid = GetIDFromVerID(verid)\n\t\tLocal ver:String\n\t\tLocal path:String = mxModUtils.ModulePath(verid) + \"\/\"\n\t\tIf FileType(path) = FILETYPE_DIR\n\t\t\tIf FileType(path + \".git\") = FILETYPE_DIR Or FileType(path + \".svn\") = FILETYPE_DIR\n\t\t\t\tver = \"dev\"\n\t\t\tElse\n\t\t\t\tDebugLog(\"(mxModUtils.GetInstalledVersionFromVerID) modid: \" + verid + \" path: \" + path + GetNameFromID(verid) + \".bmx\")\n\t\t\t\tLocal text:String = LoadText(path + GetNameFromID(verid) + \".bmx\")\n\t\t\t\tSaveText(text, AppDir + \"\/tmp.tmp\")\n\t\t\t\tLocal lexer:TLexer = New TLexer.InitWithSource(text)\n\t\t\t\tIf lexer.Run()\n\t\t\t\t\tLocal tokens:TToken[] = lexer.GetTokens()\n\t\t\t\t\tFor Local i:Int = 0 Until tokens.Length\n\t\t\t\t\t\tLocal token:TToken = tokens[i]\n\t\t\t\t\t\tIf token.kind = TToken.TOK_MODULEINFO_KW\n\t\t\t\t\t\t\tIf Not (i + 1 >= tokens.Length)\n\t\t\t\t\t\t\t\ttoken = tokens[i + 1]\n\t\t\t\t\t\t\t\tIf token.kind = TToken.TOK_STRING_LIT\n\t\t\t\t\t\t\t\t\tLocal str:String = token.ToString().Replace(\"~q\", \"\").ToLower()\n\t\t\t\t\t\t\t\t\tIf str.Contains(\"version:\")\n\t\t\t\t\t\t\t\t\t\tLocal colon:Int = str.Find(\":\")\n\t\t\t\t\t\t\t\t\t\tver = str[(colon > -1 And colon + 1 Or 0)..].Trim()\n\t\t\t\t\t\t\t\t\t\tExit\n\t\t\t\t\t\t\t\t\tEnd If\n\t\t\t\t\t\t\t\tEnd If\n\t\t\t\t\t\t\tEnd If\n\t\t\t\t\t\tEnd If\n\t\t\t\t\tNext\n\t\t\t\tElse\n\t\t\t\t\tDebugLog(\"(mxModule.GetInstalledVersion) lexer.Run() failed on ~q\" + path + \"~q : \" + lexer.GetError())\n\t\t\t\tEnd If\n\t\t\tEnd If\n\t\tEnd If\n\t\tReturn ver\n\tEnd Function\n\tEnd Rem\n\t\n\tRem\n\t\tbbdoc: Enumerate all of the current modules.\n\t\treturns: An object map containing the current modules.\n\tEnd Rem\n\tFunction EnumModules:dObjectMap(modid:String = Null, mods:dObjectMap = Null)\n\t\tIf Not mods Then mods = New dObjectMap\n\t\tLocal dir:String = ModulePath(modid)\n\t\tLocal files:String[] = LoadDir(dir)\n\t\tFor Local file:String = EachIn files\n\t\t\tLocal path:String = dir + \"\/\" + file\n\t\t\tIf file[file.length - 4..] <> \".mod\" Or FileType(path) <> FILETYPE_DIR Then Continue\n\t\t\tLocal t:String = file[..file.length - 4]\n\t\t\tIf modid Then t = modid + \".\" + t\n\t\t\tLocal i:Int = t.Find(\".\")\n\t\t\tIf i > -1 And t.Find(\".\", i + 1) = -1 Then mods._Insert(t, path)\n\t\t\tEnumModules(t, mods)\n\t\tNext\n\t\tReturn mods\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Document all modules, or the modules given (doesn't work yet - all documentation will be built).\n\t\treturns: The exit code from makedocs.\n\tEnd Rem\n\tFunction DocMods:Int(args:String = Null)\n\t\targs = \"docmods \" + args.Trim()\n\t\tlogger.LogMessage(\"run: \" + args)\n\t\tReturn system_(mainapp.m_binpath + \"\/\" + args)\n\tEnd Function\n\t\nEnd Type\n\nRem\n\tbbdoc: Maximus BMK utilities.\nEnd Rem\nType mxBMKUtils\n\t\n\tRem\n\t\tbbdoc: Run BMK with the given arguments.\n\t\treturns: The exit code from bmk (non-zero when an error occured).\n\tEnd Rem\n\tFunction RunBMK:Int(args:String)\n\t\targs = \"bmk \" + args.Trim()\n\t\tlogger.LogMessage(\"run: \" + args)\n\t\tReturn system_(mainapp.m_binpath + \"\/\" + args)\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Make modules with the given arguments.\n\t\treturns: The exit code from bmk (non-zero when an error occured).\n\tEnd Rem\n\tFunction MakeMods:Int(args:String, threaded:Int)\n\t\tLocal opts:String\n\t\tIf threaded Then opts:+ \" -h\"\n\t\tReturn RunBMK(\"makemods\" + opts + \" \" + args)\n\tEnd Function\n\t\nEnd Type\n\nRem\n\tbbdoc: Maximus temporary progress storage for url fetching.\nEnd Rem\nType _mxProgressStore\n\t\n\tField m_progress:Int = 0\n\t\nEnd Type\n\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"80bea486197466e872d5b568c7ce4c7fa37cb10b","subject":"newtab","message":"newtab\n","repos":"Leushenko\/blue-moon","old_file":"blue.bmx","new_file":"blue.bmx","new_contents":"","old_contents":"","returncode":0,"stderr":"unknown","license":"mit","lang":"BlitzMax"} {"commit":"a45696a75fa5aeb737f2cdb0ffa4f17f12f41208","subject":"Added TEntity.LineIntersects","message":"Added TEntity.LineIntersects\n","repos":"kfprimm\/maxb3d,kfprimm\/maxb3d","old_file":"core.mod\/entity.bmx","new_file":"core.mod\/entity.bmx","new_contents":"\nStrict\n\nImport BRL.LinkedList\nImport MaxB3D.Math\nImport \"brush.bmx\"\nImport \"collision.bmx\"\nImport \"worldconfig.bmx\"\n\nConst PICKMODE_OFF\t\t\t= 0\nConst PICKMODE_SPHERE\t\t= 1\nConst PICKMODE_POLYGON\t= 2\nConst PICKMODE_BOX\t\t\t= 3\n\nType TEntity\n\tField _config:TWorldConfig\n\tField _matrix:TMatrix=TMatrix.Identity(), _lockmatrix\n\t\n\tField _name$\n\tField _px#,_py#,_pz#\n\tField _rx#,_ry#,_rz#\n\tField _sx#,_sy#,_sz#\n\t\t\n\tField _brush:TBrush=New TBrush\n\t\n\tField _parent:TEntity,_childlist:TList=CreateList()\n\tField _hidden,_order\n\t\n\tField _collision:TCollision[]\n\tField _oldx#,_oldy#,_oldz#\n\tField _radiusx#,_radiusy#\n\tField _boxx#,_boxy#,_boxz#,_boxwidth#,_boxheight#,_boxdepth#\n\tField _type,_typelink:TLink\n\tField _pickmode, _obscurer\n\t\n\tField _cullradius#\n\t\n\tField _alphaorder#\n\t\n\tField _linklist:TList=CreateList()\n\t\n\tMethod Init:TEntity(config:TWorldConfig,parent:TEntity)\n\t\t_config = config\n\t\tSetParent parent,False\n\t\tFor Local l=EachIn Lists()\n\t\t\tAddLink _config.AddObject(Self,l)\n\t\tNext\n\t\t\n\t\tSetScale 1,1,1\n\t\t\n\t\tReturn Self\n\tEnd Method\n\t\n\tMethod Free()\n\t\tFor Local child:TEntity=EachIn _childlist\n\t\t\tchild.Free()\n\t\tNext\n\t\tFor Local link:TLink=EachIn _linklist\n\t\t\tRemoveLink link\n\t\tNext\n\tEnd Method\n\t\n\tMethod AddLink(link:TLink)\n\t\t_linklist.AddLast link\n\tEnd Method\n\t\n\tMethod Lists[]()\n\t\tReturn [WORLDLIST_ENTITY]\n\tEnd Method\n\t\n\tMethod CopyData:TEntity(entity:TEntity)\n\t\t_config = entity._config\n\t\tLocal pickmode, obscurer\n\t\tentity.GetPickMode pickmode,obscurer\n\t\t\n\t\tSetBrush entity.GetBrush()\n\t\tSetName entity.GetName()\n\t\tSetPickMode pickmode, obscurer\n\t\tSetType entity.GetType()\n\t\tReturn Self\n\tEnd Method\n\t\n\tMethod Copy_:TEntity(parent:TEntity=Null)\n\t\tReturn New Self.CopyData(Self).Init(_config,parent)\n\tEnd Method\n\t\n\tMethod Copy:TEntity(parent:TEntity=Null) Abstract\n\t\n\tMethod AddParent(parent:TEntity)\n\t\t_parent=parent\n\t\tIf parent\n\t\t\t_matrix.Overwrite parent._matrix\n\t\t\tparent._childlist.AddLast Self\n\t\tEndIf\n\tEnd Method\n\t\n\tMethod GetParent:TEntity()\n\t\tReturn _parent\n\tEnd Method\n\tMethod SetParent(parent:TEntity,glob=True)\n\t\tLocal gpx#,gpy#,gpz#\t\t\n\t\tLocal grx#,gry#,grz#\t\t\n\t\tLocal gsx#,gsy#,gsz#\n\t\t\n\t\tGetPosition gpx,gpy,gpz,True\n\t\tGetRotation grx,gry,grz,True\n\t\tGetScale gsx,gsy,gsz,True\n\t\t\n\t\tIf _parent\n\t\t\tFor Local entity:TEntity=EachIn _parent._childlist\n\t\t\t\tIf entity=Self ListRemove(_parent._childlist,Self)\n\t\t\tNext\n\t\t\t_parent=Null\n\t\tEndIf\n\n\t\t_px=gpx;_py=gpy;_pz=gpz\n\t\t_rx=grx;_ry=gry;_rz=grz\n\t\t_sx=gsx;_sy=gsy;_sz=gsz\n\t\t\n\t\tIf parent=Null UpdateMatrix(True);Return\t\t\n\t\t\n\t\tAddParent(parent)\n\t\tIf glob\t\t\t\t\n\t\t\tSetPosition(gpx,gpy,gpz,True)\n\t\t\tSetRotation(grx,gry,grz,True)\n\t\t\tSetScale(gsx,gsy,gsz,True)\n\t\tElse\t\t\t\n\t\t\tUpdateMatrix(False)\t\t\t\t\n\t\tEndIf\t\t\t\n\tEnd Method\n\t\n\tMethod CountChildren(recursive=False)\n\t\tLocal count\n\t\tIf recursive\n\t\t\tFor Local child:TEntity=EachIn _childlist\n\t\t\t\tcount:+child.CountChildren(True)\n\t\t\tNext\n\t\tEndIf\n\t\tReturn _childlist.Count()+count\n\tEnd Method\n\t\n\tMethod FindChild:TEntity(name$,recursive=False)\n\t\tFor Local child:TEntity=EachIn _childlist\n\t\t\tIf child.GetName()=name Return child\n\t\tNext\n\t\tIf recursive\n\t\t\tFor Local child:TEntity=EachIn _childlist\n\t\t\t\tLocal entity:TEntity = child.FindChild(name, True)\n\t\t\t\tIf entity Return entity\n\t\t\tNext\n\t\tEndIf\n\tEnd Method\n\t\n\tMethod GetName$()\n\t\tReturn _name\n\tEnd Method\n\tMethod SetName(name$)\n\t\t_name=name\n\tEnd Method\n\t\n\tMethod GetBrush:TBrush()\n\t\tReturn _brush.Copy()\n\tEnd Method\n\tMethod SetBrush(brush:TBrush)\n\t\t_brush.Load brush\n\tEnd Method\n\t\n\tMethod GetColor(red Var,green Var,blue Var)\n\t\tReturn _brush.GetColor(red,green,blue)\n\tEnd Method\n\tMethod SetColor(red,green,blue)\n\t\tReturn _brush.SetColor(red,green,blue)\n\tEnd Method\n\t\n\tMethod GetAlpha#()\n\t\tReturn _brush.GetAlpha()\n\tEnd Method\n\tMethod SetAlpha(alpha#)\n\t\t_brush.SetAlpha(alpha)\n\tEnd Method\n\t\n\tMethod GetShine#()\n\t\tReturn _brush.GetShine()\n\tEnd Method\n\tMethod SetShine(shine#)\n\t\t_brush.SetShine(shine)\n\tEnd Method\n\t\n\tMethod GetTexture:TTexture(index)\n\t\tReturn _brush.GetTexture(index)\n\tEnd Method\n\tMethod SetTexture(texture:TTexture,index=0,frame=0)\n\t\tReturn _brush.SetTexture(texture,index,frame)\n\tEnd Method\n\t\n\tMethod GetFX()\n\t\tReturn _brush.GetFX()\n\tEnd Method\n\tMethod SetFX(fx)\n\t\tReturn _brush.SetFX(fx)\n\tEnd Method\n\t\n\tMethod GetBlend()\n\t\tReturn _brush.GetBlend()\n\tEnd Method\n\tMethod SetBlend(blend)\n\t\tReturn _brush.SetBlend(blend)\n\tEnd Method\n\t\n\tMethod GetShader:TShader()\n\t\tReturn _brush.GetShader()\n\tEnd Method\n\tMethod SetShader(shader:TShader)\n\t\tReturn _brush.SetShader(shader)\n\tEnd Method\n\t\n\tMethod GetScale(x# Var,y# Var,z# Var,glob=False)\n\t\tIf glob\n\t\t\tx=_matrix._m[0,0]\n\t\t\ty=_matrix._m[1,1]\n\t\t\tz=_matrix._m[2,2]\n\t\tElse\n\t\t\tx=_sx;y=_sy;z=_sz\n\t\tEndIf\n\tEnd Method\n\tMethod SetScale(x#,y#,z#,glob=False)\n\t\t_sx=x;_sy=y;_sz=z\n\t\tIf glob=True And _parent<>Null\n\t\t\tLocal entity:TEntity=Self\n\t\t\tRepeat\n\t\t\t\t_sx:\/entity._parent._sx\n\t\t\t\t_sy:\/entity._parent._sy\n\t\t\t\t_sz:\/entity._parent._sz\n\t\t\t\tentity=entity._parent\n\t\t\tUntil entity._parent=Null\n\t\tEndIf\n\t\tRefreshMatrix()\t\n\tEnd Method\n\t\n\tMethod Transform(matrix:TMatrix,glob=False)\n\t\tSetMatrix matrix.Multiply(_matrix),glob\n\tEnd Method\n\t\n\tMethod Turn(pitch#,yaw#,roll#,glob=False)\n\t\t_rx:+pitch;_ry:+yaw;_rz:+roll\n\t\tRefreshMatrix()\n\tEnd Method\n\t\n\tMethod Point(target:Object,roll#=0.0)\n\t\tLocal x#,y#,z#,tx#,ty#,tz#\n\t\tGetPosition x,y,z,True\n\t\tGetTargetPosition target,tx,ty,tz \n\n\t\tLocal xdiff#=x-tx,ydiff#=y-ty,zdiff#=z-tz\n\n\t\tLocal dist22#=Sqr((xdiff*xdiff)+(zdiff*zdiff))\n\t\tLocal pitch#=ATan2(ydiff,dist22)\n\t\tLocal yaw#=ATan2(xdiff,-zdiff)\n\n\t\tSetRotation pitch,yaw,roll,True\n\tEnd Method\n\t\n\tMethod GetDistance#(target:Object)\n\t\tLocal x#,y#,z#,tx#,ty#,tz#\n\t\tGetPosition x,y,z,True\n\t\tGetTargetPosition target,tx,ty,tz\t\t\n\t\tReturn Sqr((x-tx)*(x-tx)+(y-ty)*(y-ty)+(z-tz)*(z-tz))\n\tEnd Method\n\t\n\tFunction GetTargetPosition(target:Object,x# Var,y# Var,z# Var)\n\t\tAssert target,\"Null target given.\"\n\t\tIf TEntity(target) TEntity(target).GetPosition x,y,z,True\n\t\tIf Float[](target)\n\t\t\tLocal coords#[]=Float[](target)\n\t\t\tIf coords.length>0 x=coords[0]\n\t\t\tIf coords.length>1 y=coords[1]\n\t\t\tIf coords.length>2 z=coords[2]\n\t\tEndIf\n\t\tAssert \"Invalid target given.\"\n\tEnd Function\t\n\t\n\tMethod GetRotation(pitch# Var,yaw# Var,roll# Var,glob=False)\n\t\tIf glob\n\t\t\t_matrix.GetRotation pitch,yaw,roll\n\t\t\tpitch:*-1\n\t\t\tyaw:*-1\n\t\tElse\n\t\t\tpitch=_rx;yaw=_ry;roll=_rz\n\t\tEndIf\n\tEnd Method\n\tMethod SetRotation(pitch#,yaw#,roll#,glob=False)\n\t\t_rx=pitch;_ry=yaw;_rz=roll\n\t\tIf glob And _parent<>Null\n\t\t\tLocal rx#,ry#,rz#\n\t\t\t_parent.GetRotation rx,ry,rz\n\t\t\t_rx:+rx;_ry:+ry;_rz:+rz\t\t\t\n\t\tEndIf\n\t\tRefreshMatrix()\n\tEnd Method\n\t\t\n\tMethod GetPosition(x# Var,y# Var,z# Var,glob=False)\n\t\tx=_px;y=_py;z=_pz\n\t\tIf glob _matrix.GetPosition x,y,z\n\tEnd Method\n\tMethod SetPosition(x#,y#,z#,glob=False)\n\t\t_px=x;_py=y;_pz=z\n\t\t\n\t\tIf glob And _parent<>Null\n\t\t\tLocal px#,py#,pz#\n\t\t\t_parent.GetPosition px,py,pz,True\n\t\t\t_px:-px;_py:-py;_pz:-pz\n\t\tEndIf\n\t\t\n\t\tRefreshMatrix()\n\tEnd Method\n\t\n\tMethod Move(x#,y#,z#)\n\t\tLocal matrix:TMatrix=TMatrix.Identity()\n\t\tmatrix=TMatrix.YawPitchRoll(-_ry,-_rx,_rz).Multiply(matrix)\n\t\tmatrix=TMatrix.Translation(x,y,z).Multiply(matrix)\n\t\n\t\tmatrix.GetPosition(x,y,z)\t\t\n\t\t_px:+x;_py:+y;_pz:+z\n\n\t\tRefreshMatrix()\n\tEnd Method\n\t\n\tMethod Translate(x#,y#,z#,glob=True)\n\t\tIf glob And _parent\t\t\t\n\t\t\tLocal ax#,ay#,az#\n\t\t\tGetRotation ax,ay,az,True\n\t\t\t\t\t\t\n\t\t\tLocal matrix:TMatrix=TMatrix.Roll(-az)\n\t\t\tmatrix=matrix.Multiply(TMatrix.Pitch(-ax))\n\t\t\tmatrix=matrix.Multiply(TMatrix.Yaw(-ay))\n\t\t\tmatrix=matrix.Multiply(TMatrix.Translation(x,y,z))\n\t\t\t\n\t\t\tmatrix.GetPosition x,y,z\n\t\tEndIf\n\t\t\n\t\t_px:+x;_py:+y;_pz:+z\n\n\t\tRefreshMatrix()\n\tEnd Method\n\t\n\tMethod GetVisible()\n\t\tLocal entity:TEntity=Self\n\t\tWhile entity<>Null\n\t\t\tIf entity._hidden=True Return False\n\t\t\tentity=entity._parent\n\t\tWend\n\t\tReturn True\n\tEnd Method\n\tMethod SetVisible(visible)\n\t\t_hidden=Not visible\n\tEnd Method\n\t\n\tMethod GetOrder()\n\t\tReturn _order\n\tEnd Method\n\tMethod SetOrder(order)\n\t\t_order=order\n\tEnd Method\n\t\n\tMethod GetCollisions:TCollision[]()\n\t\tReturn _collision\n\tEnd Method\n\t\n\tMethod GetRadius(x# Var,y# Var)\n\t\tx=_radiusx;y=_radiusy\n\tEnd Method\n\tMethod SetRadius(x#,y#=-1)\n\t\t_radiusx=x;_radiusy=x\n\t\tIf y>-1 _radiusy=y\n\tEnd Method\n\t\n\tMethod GetBox(x# Var,y# Var,z# Var,width# Var,height# Var,depth# Var)\n\t\tx=_boxx;y=_boxy;z=_boxz\n\t\twidth=_boxwidth;height=_boxheight;depth=_boxdepth\n\tEnd Method\n\tMethod SetBox(x#,y#,z#,width#,height#,depth#)\n\t\t_boxx=x;_boxy=y;_boxz=z\n\t\t_boxwidth=width;_boxheight=height;_boxdepth=depth\n\tEnd Method\n\t\n\tMethod Reset()\n\t\t_collision=Null\n\t\tGetPosition _oldx,_oldy,_oldz,True\n\tEnd Method\n\t\n\tMethod GetType()\n\t\tReturn _type\n\tEnd Method\n\tMethod SetType(typ,recursive=False)\n\t\tIf _typelink\n\t\t\t_linklist.Remove(_typelink)\n\t\t\t_typelink.Remove()\n\t\t\t_typelink=Null\n\t\tEndIf\n\t\t\n\t\tIf typ>0\n\t\t\tIf _config.CollisionType[typ]=Null _config.CollisionType[typ]=CreateList()\n\t\t\t_typelink=_config.CollisionType[typ].AddLast(Self)\n\t\t\tAddLink _typelink\n\t\tEndIf\t\t\n\t\t\n\t\t_type=typ\n\t\tGetPosition _oldx,_oldy,_oldz,True\n\t\t\n\t\tIf recursive\n\t\t\tFor Local child:TEntity=EachIn _childlist\n\t\t\t\tchild.SetType typ,True\n\t\t\tNext\n\t\tEndIf\n\tEnd Method\n\t\n\tMethod GetCullRadius#()\n\t\tReturn Abs(_cullradius)\n\tEnd Method\n\tMethod SetCullRadius(radius#)\n\t\t_cullradius=-radius\n\tEnd Method\n\n\tMethod GetCullParams(x# Var,y# Var,z# Var,radius# Var)\n\t\tGetPosition x,y,z,True\n\t\tradius=GetCullRadius()\n\tEnd Method\n\t\n\tMethod IntersectsLine:TVector(ptA:TVector, ptB:TVector)\n\t\tReturn Null\n\tEnd Method\n\t\n\tMethod GetPickMode(mode Var, obscurer Var)\n\t\tmode = _pickmode\n\t\tobscurer = _obscurer\n\tEnd Method\t\n\tMethod SetPickMode(mode, obscurer=True)\n\t\t_pickmode = mode\n\t\t_obscurer = obscurer\n\tEnd Method\n\t\n\tMethod HasAlpha()\n\t\tReturn _brush.HasAlpha()\n\tEnd Method\n\t\n\tMethod GetMatrix:TMatrix(alternate=False,copy=True)\n\t\tIf copy Return _matrix.Copy()\n\t\tReturn _matrix\n\tEnd Method\n\tMethod SetMatrix(matrix:TMatrix,glob=True)\n\t\tLocal x#,y#,z#,pitch#,yaw#,roll#,sx#,sy#,sz#\n\t\tmatrix.GetPosition x,y,z\n\t\tmatrix.GetRotation pitch,yaw,roll\n\t\tmatrix.GetScale sx,sy,sz\n\t\t\n\t\tLockMatrix\n\t\tSetPosition x,y,z,glob\n\t\tSetRotation pitch,yaw,roll,glob\n\t\tSetScale sx,sy,sz,glob\n\t\tUnlockMatrix\n\tEnd Method\n\t\n\tMethod LockMatrix()\n\t\t_lockmatrix=True\n\tEnd Method\n\tMethod UnlockMatrix()\n\t\t_lockmatrix=False\n\t\tRefreshMatrix()\n\tEnd Method\n\t\n\tMethod RefreshMatrix()\n\t\tIf _lockmatrix Return\n\t\tIf _parent<>Null\n\t\t\t_matrix.Overwrite _parent._matrix\n\t\t\tUpdateMatrix False\n\t\tElse\n\t\t\tUpdateMatrix True\n\t\tEndIf\t\t\n\t\t\n\t\tFor Local child:TEntity=EachIn _childlist\n\t\t\tchild.RefreshMatrix()\n\t\tNext\n\tEnd Method\n\t\n\tMethod UpdateMatrix(loadidentity)\n\t\tIf loadidentity _matrix=TMatrix.Identity()\n\t\t_matrix=TMatrix.Translation(_px,_py,_pz).Multiply(_matrix)\n\t\t_matrix=TMatrix.YawPitchRoll(-_ry,-_rx,_rz).Multiply(_matrix)\n\t\t_matrix=TMatrix.Scale(_sx,_sy,_sz).Multiply(_matrix)\n\tEnd Method\n\t\n\tMethod ObjectEnumerator:Object()\n\t\tReturn TChildrenEnumerator.Create(_childlist)\n\tEnd Method\nEnd Type\n\nType TChildrenEnumerator\n\tField _children:TEntity[],_index=-1\n\t\n\tFunction Create:TChildrenEnumerator(list:TList)\n\t\tLocal enum:TChildrenEnumerator=New TChildrenEnumerator\n\t\tenum._children=TEntity[](list.ToArray())\n\t\tReturn enum\n\tEnd Function\n\t\n\tMethod HasNext()\n\t\tReturn _index>=_children.length-1\n\tEnd Method\n\t\n\tMethod NextObject:Object()\n\t\t_index:+1\n\t\tReturn _children[_index]\n\tEnd Method\nEnd Type\n","old_contents":"\nStrict\n\nImport BRL.LinkedList\nImport MaxB3D.Math\nImport \"brush.bmx\"\nImport \"collision.bmx\"\nImport \"worldconfig.bmx\"\n\nConst PICKMODE_OFF\t\t\t= 0\nConst PICKMODE_SPHERE\t\t= 1\nConst PICKMODE_POLYGON\t= 2\nConst PICKMODE_BOX\t\t\t= 3\n\nType TEntity\n\tField _config:TWorldConfig\n\tField _matrix:TMatrix=TMatrix.Identity(), _lockmatrix\n\t\n\tField _name$\n\tField _px#,_py#,_pz#\n\tField _rx#,_ry#,_rz#\n\tField _sx#,_sy#,_sz#\n\t\t\n\tField _brush:TBrush=New TBrush\n\t\n\tField _parent:TEntity,_childlist:TList=CreateList()\n\tField _hidden,_order\n\t\n\tField _collision:TCollision[]\n\tField _oldx#,_oldy#,_oldz#\n\tField _radiusx#,_radiusy#\n\tField _boxx#,_boxy#,_boxz#,_boxwidth#,_boxheight#,_boxdepth#\n\tField _type,_typelink:TLink\n\tField _pickmode, _obscurer\n\t\n\tField _cullradius#\n\t\n\tField _alphaorder#\n\t\n\tField _linklist:TList=CreateList()\n\t\n\tMethod Init:TEntity(config:TWorldConfig,parent:TEntity)\n\t\t_config = config\n\t\tSetParent parent,False\n\t\tFor Local l=EachIn Lists()\n\t\t\tAddLink _config.AddObject(Self,l)\n\t\tNext\n\t\t\n\t\tSetScale 1,1,1\n\t\t\n\t\tReturn Self\n\tEnd Method\n\t\n\tMethod Free()\n\t\tFor Local child:TEntity=EachIn _childlist\n\t\t\tchild.Free()\n\t\tNext\n\t\tFor Local link:TLink=EachIn _linklist\n\t\t\tRemoveLink link\n\t\tNext\n\tEnd Method\n\t\n\tMethod AddLink(link:TLink)\n\t\t_linklist.AddLast link\n\tEnd Method\n\t\n\tMethod Lists[]()\n\t\tReturn [WORLDLIST_ENTITY]\n\tEnd Method\n\t\n\tMethod CopyData:TEntity(entity:TEntity)\n\t\t_config = entity._config\n\t\tLocal pickmode, obscurer\n\t\tentity.GetPickMode pickmode,obscurer\n\t\t\n\t\tSetBrush entity.GetBrush()\n\t\tSetName entity.GetName()\n\t\tSetPickMode pickmode, obscurer\n\t\tSetType entity.GetType()\n\t\tReturn Self\n\tEnd Method\n\t\n\tMethod Copy_:TEntity(parent:TEntity=Null)\n\t\tReturn New Self.CopyData(Self).Init(_config,parent)\n\tEnd Method\n\t\n\tMethod Copy:TEntity(parent:TEntity=Null) Abstract\n\t\n\tMethod AddParent(parent:TEntity)\n\t\t_parent=parent\n\t\tIf parent\n\t\t\t_matrix.Overwrite parent._matrix\n\t\t\tparent._childlist.AddLast Self\n\t\tEndIf\n\tEnd Method\n\t\n\tMethod GetParent:TEntity()\n\t\tReturn _parent\n\tEnd Method\n\tMethod SetParent(parent:TEntity,glob=True)\n\t\tLocal gpx#,gpy#,gpz#\t\t\n\t\tLocal grx#,gry#,grz#\t\t\n\t\tLocal gsx#,gsy#,gsz#\n\t\t\n\t\tGetPosition gpx,gpy,gpz,True\n\t\tGetRotation grx,gry,grz,True\n\t\tGetScale gsx,gsy,gsz,True\n\t\t\n\t\tIf _parent\n\t\t\tFor Local entity:TEntity=EachIn _parent._childlist\n\t\t\t\tIf entity=Self ListRemove(_parent._childlist,Self)\n\t\t\tNext\n\t\t\t_parent=Null\n\t\tEndIf\n\n\t\t_px=gpx;_py=gpy;_pz=gpz\n\t\t_rx=grx;_ry=gry;_rz=grz\n\t\t_sx=gsx;_sy=gsy;_sz=gsz\n\t\t\n\t\tIf parent=Null UpdateMatrix(True);Return\t\t\n\t\t\n\t\tAddParent(parent)\n\t\tIf glob\t\t\t\t\n\t\t\tSetPosition(gpx,gpy,gpz,True)\n\t\t\tSetRotation(grx,gry,grz,True)\n\t\t\tSetScale(gsx,gsy,gsz,True)\n\t\tElse\t\t\t\n\t\t\tUpdateMatrix(False)\t\t\t\t\n\t\tEndIf\t\t\t\n\tEnd Method\n\t\n\tMethod CountChildren(recursive=False)\n\t\tLocal count\n\t\tIf recursive\n\t\t\tFor Local child:TEntity=EachIn _childlist\n\t\t\t\tcount:+child.CountChildren(True)\n\t\t\tNext\n\t\tEndIf\n\t\tReturn _childlist.Count()+count\n\tEnd Method\n\t\n\tMethod FindChild:TEntity(name$,recursive=False)\n\t\tFor Local child:TEntity=EachIn _childlist\n\t\t\tIf child.GetName()=name Return child\n\t\tNext\n\t\tIf recursive\n\t\t\tFor Local child:TEntity=EachIn _childlist\n\t\t\t\tLocal entity:TEntity = child.FindChild(name, True)\n\t\t\t\tIf entity Return entity\n\t\t\tNext\n\t\tEndIf\n\tEnd Method\n\t\n\tMethod GetName$()\n\t\tReturn _name\n\tEnd Method\n\tMethod SetName(name$)\n\t\t_name=name\n\tEnd Method\n\t\n\tMethod GetBrush:TBrush()\n\t\tReturn _brush.Copy()\n\tEnd Method\n\tMethod SetBrush(brush:TBrush)\n\t\t_brush.Load brush\n\tEnd Method\n\t\n\tMethod GetColor(red Var,green Var,blue Var)\n\t\tReturn _brush.GetColor(red,green,blue)\n\tEnd Method\n\tMethod SetColor(red,green,blue)\n\t\tReturn _brush.SetColor(red,green,blue)\n\tEnd Method\n\t\n\tMethod GetAlpha#()\n\t\tReturn _brush.GetAlpha()\n\tEnd Method\n\tMethod SetAlpha(alpha#)\n\t\t_brush.SetAlpha(alpha)\n\tEnd Method\n\t\n\tMethod GetShine#()\n\t\tReturn _brush.GetShine()\n\tEnd Method\n\tMethod SetShine(shine#)\n\t\t_brush.SetShine(shine)\n\tEnd Method\n\t\n\tMethod GetTexture:TTexture(index)\n\t\tReturn _brush.GetTexture(index)\n\tEnd Method\n\tMethod SetTexture(texture:TTexture,index=0,frame=0)\n\t\tReturn _brush.SetTexture(texture,index,frame)\n\tEnd Method\n\t\n\tMethod GetFX()\n\t\tReturn _brush.GetFX()\n\tEnd Method\n\tMethod SetFX(fx)\n\t\tReturn _brush.SetFX(fx)\n\tEnd Method\n\t\n\tMethod GetBlend()\n\t\tReturn _brush.GetBlend()\n\tEnd Method\n\tMethod SetBlend(blend)\n\t\tReturn _brush.SetBlend(blend)\n\tEnd Method\n\t\n\tMethod GetShader:TShader()\n\t\tReturn _brush.GetShader()\n\tEnd Method\n\tMethod SetShader(shader:TShader)\n\t\tReturn _brush.SetShader(shader)\n\tEnd Method\n\t\n\tMethod GetScale(x# Var,y# Var,z# Var,glob=False)\n\t\tIf glob\n\t\t\tx=_matrix._m[0,0]\n\t\t\ty=_matrix._m[1,1]\n\t\t\tz=_matrix._m[2,2]\n\t\tElse\n\t\t\tx=_sx;y=_sy;z=_sz\n\t\tEndIf\n\tEnd Method\n\tMethod SetScale(x#,y#,z#,glob=False)\n\t\t_sx=x;_sy=y;_sz=z\n\t\tIf glob=True And _parent<>Null\n\t\t\tLocal entity:TEntity=Self\n\t\t\tRepeat\n\t\t\t\t_sx:\/entity._parent._sx\n\t\t\t\t_sy:\/entity._parent._sy\n\t\t\t\t_sz:\/entity._parent._sz\n\t\t\t\tentity=entity._parent\n\t\t\tUntil entity._parent=Null\n\t\tEndIf\n\t\tRefreshMatrix()\t\n\tEnd Method\n\t\n\tMethod Transform(matrix:TMatrix,glob=False)\n\t\tSetMatrix matrix.Multiply(_matrix),glob\n\tEnd Method\n\t\n\tMethod Turn(pitch#,yaw#,roll#,glob=False)\n\t\t_rx:+pitch;_ry:+yaw;_rz:+roll\n\t\tRefreshMatrix()\n\tEnd Method\n\t\n\tMethod Point(target:Object,roll#=0.0)\n\t\tLocal x#,y#,z#,tx#,ty#,tz#\n\t\tGetPosition x,y,z,True\n\t\tGetTargetPosition target,tx,ty,tz \n\n\t\tLocal xdiff#=x-tx,ydiff#=y-ty,zdiff#=z-tz\n\n\t\tLocal dist22#=Sqr((xdiff*xdiff)+(zdiff*zdiff))\n\t\tLocal pitch#=ATan2(ydiff,dist22)\n\t\tLocal yaw#=ATan2(xdiff,-zdiff)\n\n\t\tSetRotation pitch,yaw,roll,True\n\tEnd Method\n\t\n\tMethod GetDistance#(target:Object)\n\t\tLocal x#,y#,z#,tx#,ty#,tz#\n\t\tGetPosition x,y,z,True\n\t\tGetTargetPosition target,tx,ty,tz\t\t\n\t\tReturn Sqr((x-tx)*(x-tx)+(y-ty)*(y-ty)+(z-tz)*(z-tz))\n\tEnd Method\n\t\n\tFunction GetTargetPosition(target:Object,x# Var,y# Var,z# Var)\n\t\tAssert target,\"Null target given.\"\n\t\tIf TEntity(target) TEntity(target).GetPosition x,y,z,True\n\t\tIf Float[](target)\n\t\t\tLocal coords#[]=Float[](target)\n\t\t\tIf coords.length>0 x=coords[0]\n\t\t\tIf coords.length>1 y=coords[1]\n\t\t\tIf coords.length>2 z=coords[2]\n\t\tEndIf\n\t\tAssert \"Invalid target given.\"\n\tEnd Function\t\n\t\n\tMethod GetRotation(pitch# Var,yaw# Var,roll# Var,glob=False)\n\t\tIf glob\n\t\t\t_matrix.GetRotation pitch,yaw,roll\n\t\t\tpitch:*-1\n\t\t\tyaw:*-1\n\t\tElse\n\t\t\tpitch=_rx;yaw=_ry;roll=_rz\n\t\tEndIf\n\tEnd Method\n\tMethod SetRotation(pitch#,yaw#,roll#,glob=False)\n\t\t_rx=pitch;_ry=yaw;_rz=roll\n\t\tIf glob And _parent<>Null\n\t\t\tLocal rx#,ry#,rz#\n\t\t\t_parent.GetRotation rx,ry,rz\n\t\t\t_rx:+rx;_ry:+ry;_rz:+rz\t\t\t\n\t\tEndIf\n\t\tRefreshMatrix()\n\tEnd Method\n\t\t\n\tMethod GetPosition(x# Var,y# Var,z# Var,glob=False)\n\t\tx=_px;y=_py;z=_pz\n\t\tIf glob _matrix.GetPosition x,y,z\n\tEnd Method\n\tMethod SetPosition(x#,y#,z#,glob=False)\n\t\t_px=x;_py=y;_pz=z\n\t\t\n\t\tIf glob And _parent<>Null\n\t\t\tLocal px#,py#,pz#\n\t\t\t_parent.GetPosition px,py,pz,True\n\t\t\t_px:-px;_py:-py;_pz:-pz\n\t\tEndIf\n\t\t\n\t\tRefreshMatrix()\n\tEnd Method\n\t\n\tMethod Move(x#,y#,z#)\n\t\tLocal matrix:TMatrix=TMatrix.Identity()\n\t\tmatrix=TMatrix.YawPitchRoll(-_ry,-_rx,_rz).Multiply(matrix)\n\t\tmatrix=TMatrix.Translation(x,y,z).Multiply(matrix)\n\t\n\t\tmatrix.GetPosition(x,y,z)\t\t\n\t\t_px:+x;_py:+y;_pz:+z\n\n\t\tRefreshMatrix()\n\tEnd Method\n\t\n\tMethod Translate(x#,y#,z#,glob=True)\n\t\tIf glob And _parent\t\t\t\n\t\t\tLocal ax#,ay#,az#\n\t\t\tGetRotation ax,ay,az,True\n\t\t\t\t\t\t\n\t\t\tLocal matrix:TMatrix=TMatrix.Roll(-az)\n\t\t\tmatrix=matrix.Multiply(TMatrix.Pitch(-ax))\n\t\t\tmatrix=matrix.Multiply(TMatrix.Yaw(-ay))\n\t\t\tmatrix=matrix.Multiply(TMatrix.Translation(x,y,z))\n\t\t\t\n\t\t\tmatrix.GetPosition x,y,z\n\t\tEndIf\n\t\t\n\t\t_px:+x;_py:+y;_pz:+z\n\n\t\tRefreshMatrix()\n\tEnd Method\n\t\n\tMethod GetVisible()\n\t\tLocal entity:TEntity=Self\n\t\tWhile entity<>Null\n\t\t\tIf entity._hidden=True Return False\n\t\t\tentity=entity._parent\n\t\tWend\n\t\tReturn True\n\tEnd Method\n\tMethod SetVisible(visible)\n\t\t_hidden=Not visible\n\tEnd Method\n\t\n\tMethod GetOrder()\n\t\tReturn _order\n\tEnd Method\n\tMethod SetOrder(order)\n\t\t_order=order\n\tEnd Method\n\t\n\tMethod GetCollisions:TCollision[]()\n\t\tReturn _collision\n\tEnd Method\n\t\n\tMethod GetRadius(x# Var,y# Var)\n\t\tx=_radiusx;y=_radiusy\n\tEnd Method\n\tMethod SetRadius(x#,y#=-1)\n\t\t_radiusx=x;_radiusy=x\n\t\tIf y>-1 _radiusy=y\n\tEnd Method\n\t\n\tMethod GetBox(x# Var,y# Var,z# Var,width# Var,height# Var,depth# Var)\n\t\tx=_boxx;y=_boxy;z=_boxz\n\t\twidth=_boxwidth;height=_boxheight;depth=_boxdepth\n\tEnd Method\n\tMethod SetBox(x#,y#,z#,width#,height#,depth#)\n\t\t_boxx=x;_boxy=y;_boxz=z\n\t\t_boxwidth=width;_boxheight=height;_boxdepth=depth\n\tEnd Method\n\t\n\tMethod Reset()\n\t\t_collision=Null\n\t\tGetPosition _oldx,_oldy,_oldz,True\n\tEnd Method\n\t\n\tMethod GetType()\n\t\tReturn _type\n\tEnd Method\n\tMethod SetType(typ,recursive=False)\n\t\tIf _typelink\n\t\t\t_linklist.Remove(_typelink)\n\t\t\t_typelink.Remove()\n\t\t\t_typelink=Null\n\t\tEndIf\n\t\t\n\t\tIf typ>0\n\t\t\tIf _config.CollisionType[typ]=Null _config.CollisionType[typ]=CreateList()\n\t\t\t_typelink=_config.CollisionType[typ].AddLast(Self)\n\t\t\tAddLink _typelink\n\t\tEndIf\t\t\n\t\t\n\t\t_type=typ\n\t\tGetPosition _oldx,_oldy,_oldz,True\n\t\t\n\t\tIf recursive\n\t\t\tFor Local child:TEntity=EachIn _childlist\n\t\t\t\tchild.SetType typ,True\n\t\t\tNext\n\t\tEndIf\n\tEnd Method\n\t\n\tMethod GetCullRadius#()\n\t\tReturn Abs(_cullradius)\n\tEnd Method\n\tMethod SetCullRadius(radius#)\n\t\t_cullradius=-radius\n\tEnd Method\n\n\tMethod GetCullParams(x# Var,y# Var,z# Var,radius# Var)\n\t\tGetPosition x,y,z,True\n\t\tradius=GetCullRadius()\n\tEnd Method\n\t\n\tMethod GetPickMode(mode Var, obscurer Var)\n\t\tmode = _pickmode\n\t\tobscurer = _obscurer\n\tEnd Method\t\n\tMethod SetPickMode(mode, obscurer=True)\n\t\t_pickmode = mode\n\t\t_obscurer = obscurer\n\tEnd Method\n\t\n\tMethod HasAlpha()\n\t\tReturn _brush.HasAlpha()\n\tEnd Method\n\t\n\tMethod GetMatrix:TMatrix(alternate=False,copy=True)\n\t\tIf copy Return _matrix.Copy()\n\t\tReturn _matrix\n\tEnd Method\n\tMethod SetMatrix(matrix:TMatrix,glob=True)\n\t\tLocal x#,y#,z#,pitch#,yaw#,roll#,sx#,sy#,sz#\n\t\tmatrix.GetPosition x,y,z\n\t\tmatrix.GetRotation pitch,yaw,roll\n\t\tmatrix.GetScale sx,sy,sz\n\t\t\n\t\tLockMatrix\n\t\tSetPosition x,y,z,glob\n\t\tSetRotation pitch,yaw,roll,glob\n\t\tSetScale sx,sy,sz,glob\n\t\tUnlockMatrix\n\tEnd Method\n\t\n\tMethod LockMatrix()\n\t\t_lockmatrix=True\n\tEnd Method\n\tMethod UnlockMatrix()\n\t\t_lockmatrix=False\n\t\tRefreshMatrix()\n\tEnd Method\n\t\n\tMethod RefreshMatrix()\n\t\tIf _lockmatrix Return\n\t\tIf _parent<>Null\n\t\t\t_matrix.Overwrite _parent._matrix\n\t\t\tUpdateMatrix False\n\t\tElse\n\t\t\tUpdateMatrix True\n\t\tEndIf\t\t\n\t\t\n\t\tFor Local child:TEntity=EachIn _childlist\n\t\t\tchild.RefreshMatrix()\n\t\tNext\n\tEnd Method\n\t\n\tMethod UpdateMatrix(loadidentity)\n\t\tIf loadidentity _matrix=TMatrix.Identity()\n\t\t_matrix=TMatrix.Translation(_px,_py,_pz).Multiply(_matrix)\n\t\t_matrix=TMatrix.YawPitchRoll(-_ry,-_rx,_rz).Multiply(_matrix)\n\t\t_matrix=TMatrix.Scale(_sx,_sy,_sz).Multiply(_matrix)\n\tEnd Method\n\t\n\tMethod ObjectEnumerator:Object()\n\t\tReturn TChildrenEnumerator.Create(_childlist)\n\tEnd Method\nEnd Type\n\nType TChildrenEnumerator\n\tField _children:TEntity[],_index=-1\n\t\n\tFunction Create:TChildrenEnumerator(list:TList)\n\t\tLocal enum:TChildrenEnumerator=New TChildrenEnumerator\n\t\tenum._children=TEntity[](list.ToArray())\n\t\tReturn enum\n\tEnd Function\n\t\n\tMethod HasNext()\n\t\tReturn _index>=_children.length-1\n\tEnd Method\n\t\n\tMethod NextObject:Object()\n\t\t_index:+1\n\t\tReturn _children[_index]\n\tEnd Method\nEnd Type\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"7efaed23fdcc3aad7462e1473cc26717ed658871","subject":"Refresh the GUI when mxLoggerObserverGUI updates text of a TGadget","message":"Refresh the GUI when mxLoggerObserverGUI updates text of a TGadget\n\nrefs gh-17\n","repos":"maximos\/maximus","old_file":"gui\/logger.bmx","new_file":"gui\/logger.bmx","new_contents":"Type mxLoggerObserverGUI\n\n\tField m_output:Object\n\t\n\tMethod Reset()\n\t\tIf TGadget(m_output)\n\t\t\tSetGadgetText(TGadget(m_output), \"\")\n\t\tEnd If\n\tEnd Method\n\n\tMethod SendMessage:Object(message:Object, context:Object)\n\t\tLocal msg:String = String(message)\n\t\tIf String(context) = \"error\"\n\t\t\tNotify(msg, True)\n\t\tElse If TGadget(m_output)\n\t\t\tLocal gadget:TGadget = TGadget(m_output)\n\t\t\tSetGadgetText(gadget, GadgetText(gadget) + \"~n\" + String(message))\n\t\t\t'Refresh GUI\n\t\t\tDriver.Poll\n\t\tElse If m_output = Null\n\t\t\tNotify(msg)\n\t\tEnd If\n\tEnd Method\n\nEnd Type","old_contents":"Type mxLoggerObserverGUI\n\n\tField m_output:Object\n\t\n\tMethod Reset()\n\t\tIf TGadget(m_output)\n\t\t\tSetGadgetText(TGadget(m_output), \"\")\n\t\tEnd If\n\tEnd Method\n\n\tMethod SendMessage:Object(message:Object, context:Object)\n\t\tLocal msg:String = String(message)\n\t\tIf String(context) = \"error\"\n\t\t\tNotify(msg, True)\n\t\tElse If TGadget(m_output)\n\t\t\tLocal gadget:TGadget = TGadget(m_output)\n\t\t\tSetGadgetText(gadget, GadgetText(gadget) + \"~n\" + String(message))\n\t\tElse If m_output = Null\n\t\t\tNotify(msg)\n\t\tEnd If\n\tEnd Method\n\nEnd Type","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"068dc8f4c0a8e6649dcf5e06aad11660a8db9200","subject":"Refactored some tests","message":"Refactored some tests\n","repos":"Htbaa\/zmq.mod,Htbaa\/zmq.mod","old_file":"tests\/main.bmx","new_file":"tests\/main.bmx","new_contents":"SuperStrict\nFramework bah.maxunit\nImport htbaapub.zmq\n\nNew TTestSuite.run()\n\nType TZMQ_Test Extends TTest\n\n\tMethod Setup() {before}\n\tEnd Method\n\t\n\tMethod Teardown() {after}\n\tEnd Method\n\n\tMethod Version() {test}\n\t\tLocal parts:String[] = TZMQ.Version().Split(\".\")\n\t\tassertTrue(parts.Length = 3, \"Version string contains 3 parts\")\n\tEnd Method\n\t\n\t'Make sure recreating an existing context\n\tMethod ContextReCreate() {test}\n\t\tLocal ct:TZMQ_Context = New TZMQ_Context.Create()\n\t\tTry\n\t\t\tct = ct.Create()\n\t\tCatch ex:String\n\t\t\tassertNotNull(ex, \"Recreating context failed properly\")\n\t\tCatch ex:TZMQ_Exception\n\t\t\tfail(ex.ToString())\n\t\tEnd Try\n\t\tct.Term()\n\tEnd Method\n\n\t'Make sure a socket can be created\n\tMethod SocketCreate() {test}\n\t\tLocal ct:TZMQ_Context = New TZMQ_Context.Create()\n\t\tLocal socket:TZMQ_Socket = ct.socket(ZMQ_PUB)\n\t\tassertNotNull(socket, \"Created socket\")\n\t\tassertTrue(socket.socket <> Null, \"Created pointer to socket\")\n\t\tsocket.Close()\n\t\tct.Term()\n\tEnd Method\n\n\t'Make sure created messages contain expected data\n\tMethod MessageCreationIntegrity() {test}\n\t\tFor Local i:Int = 0 To 1000\n\t\t\tLocal text:String = \"Message \" + i\n\t\t\tLocal msg:TZMQ_Message = New TZMQ_Message.Create(text)\n\t\t\tassertEquals(text, msg.ToString(), \"Message text match\")\n\t\t\tassertEqualsI(text.Length, msg.Size(), \"Message size match\")\n\t\t\tmsg.Close()\n\t\tNext\n\tEnd Method\n\t\n\t'Make sure exchanged messages aren't corrupt\n\tMethod MessageExchangingIntegrity() {test}\n\t\tLocal addr:String = \"tcp:\/\/127.0.0.1:6000\"\n\t\tLocal ct:TZMQ_Context = New TZMQ_Context.Create()\n\t\tLocal publisher:TZMQ_Socket = ct.socket(ZMQ_PUB)\n\t\tLocal subscriber:TZMQ_Socket = ct.socket(ZMQ_SUB)\n\t\t\n\t\tpublisher.Bind(addr)\n\t\tsubscriber.Connect(addr)\n\t\tsubscriber.SetSockOpt(ZMQ_SUBSCRIBE, Null)\n\t\t\n\t\tFor Local i:Int = 0 To 100\n\t\t\tDelay 10\n\t\t\tLocal text:String = \"Message \" + i\n\t\t\tpublisher.Send(text)\n\t\t\tLocal msg:TZMQ_Message = subscriber.Recv()\n\t\t\tIf msg = Null Then msg.Close() ; Continue\n\t\t\tassertEquals(text, msg.ToString(), \"Message \" + i + \" match\")\n\t\t\tassertEqualsI(text.Length, msg.Size(), \"Message \" + i + \" size match\")\n\t\t\tmsg.Close()\n\t\tNext\n\t\t\n\t\tsubscriber.Close()\n\t\tpublisher.Close()\n\t\tct.Term()\n\tEnd Method\nEnd Type\n","old_contents":"SuperStrict\nFramework bah.maxunit\nImport htbaapub.zmq\n\nNew TTestSuite.run()\n\nType TZMQ_Test Extends TTest\n\n\tMethod Setup() {before}\n\tEnd Method\n\t\n\tMethod Teardown() {after}\n\tEnd Method\n\n\tMethod Version() {test}\n\t\tLocal parts:String[] = TZMQ.Version().Split(\".\")\n\t\tassertTrue(parts.Length = 3, \"Version string contains 3 parts\")\n\tEnd Method\n\t\n\tMethod ContextReCreate() {test}\n\t\tLocal ct:TZMQ_Context = New TZMQ_Context.Create()\n\t\tTry\n\t\t\tct = ct.Create()\n\t\tCatch ex:String\n\t\t\tassertNotNull(ex, \"Recreating context failed properly\")\n\t\tCatch ex:TZMQ_Exception\n\t\t\tfail(ex.ToString())\n\t\tEnd Try\n\t\tct.Term()\n\tEnd Method\n\n\tMethod SocketCreate() {test}\n\t\tLocal ct:TZMQ_Context = New TZMQ_Context.Create()\n\t\tLocal socket:TZMQ_Socket = ct.socket(ZMQ_PUB)\n\t\tassertNotNull(socket, \"Created socket\")\n\t\tsocket.Close()\n\t\tct.Term()\n\tEnd Method\n\n\tMethod MessageCreationIntegrity() {test}\n\t\tFor Local i:Int = 0 To 1000\n\t\t\tLocal text:String = \"Message \" + i\n\t\t\tLocal msg:TZMQ_Message = New TZMQ_Message.Create(text)\n\t\t\tassertEquals(text, msg.ToString(), \"Message text match\")\n\t\t\tassertEqualsI(text.Length, msg.Size(), \"Message size match\")\n\t\t\tmsg.Close()\n\t\tNext\n\tEnd Method\n\t\n\tMethod MessageExchangingIntegrity() {test}\n\t\tLocal addr:String = \"tcp:\/\/127.0.0.1:6000\"\n\t\tLocal ct:TZMQ_Context = New TZMQ_Context.Create()\n\t\tLocal publisher:TZMQ_Socket = ct.socket(ZMQ_PUB)\n\t\tLocal subscriber:TZMQ_Socket = ct.socket(ZMQ_SUB)\n\t\t\n\t\tpublisher.Bind(addr)\n\t\tsubscriber.Connect(addr)\n\t\tsubscriber.SetSockOpt(ZMQ_SUBSCRIBE, Null)\n\t\t\n\t\tFor Local i:Int = 0 To 100\n\t\t\tDelay 10\n\t\t\tLocal text:String = \"Message \" + i\n\t\t\tpublisher.Send(text)\n\t\t\tLocal msg:TZMQ_Message = subscriber.Recv()\n\t\t\tassertEquals(text, msg.ToString(), \"Message \" + i + \" match\")\n\t\t\tassertEqualsI(text.Length, msg.Size(), \"Message \" + i + \" size match\")\n\t\t\tmsg.Close()\n\t\tNext\n\t\t\n\t\tsubscriber.Close()\n\t\tpublisher.Close()\n\t\tct.Term()\n\tEnd Method\nEnd Type\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"9a8c6ed40d514279c598f4fb2a58775f9b0d0a41","subject":"Fixed setting sources url for update implementation","message":"Fixed setting sources url for update implementation\n","repos":"maximos\/maximus","old_file":"src\/impl\/update.bmx","new_file":"src\/impl\/update.bmx","new_contents":"\nRem\n\tbbdoc: Maximus 'update' argument implementation.\nEnd Rem\nType mxUpdateImpl Extends dArgumentImplementation\n\t\n\tField m_sourcesurl:String\n\t\n\tMethod New()\n\t\tinit([\"update\"])\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Check the current arguments for errors (according to the specific implementation).\n\t\treturns: Nothing.\n\t\tabout: This method will throw an error if the arguments are invalid.\n\tEnd Rem\n\tMethod CheckArgs()\n\t\tCheckOptions()\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get a string describing the typical usage of the argument.\n\t\treturns: A string describing the typical usage of the argument.\n\tEnd Rem\n\tMethod GetUsage:String()\n\t\tReturn _s(\"arg.update.usage\")\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Execute the implementation's operation.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod Execute()\n\t\tIf mainapp.m_sourcesupdated Then Return\n\t\tIf Not m_sourcesurl Then m_sourcesurl = mainapp.m_sourcesurl\n\t\tIf Not m_sourcesurl\n\t\t\tThrowError(_s(\"error.update.nourl\"))\n\t\tEnd If\n\t\tmainapp.m_sourcesupdated = True\n\t\tLocal file:String = mainapp.m_sourcesfile + \".tmp\"\n\t\tlogger.LogMessage(\"fetching: \" + m_sourcesurl + \" -> \" + file + \"~t\", False)\n\t\tLocal stream:TStream = WriteFileExplicitly(file)\n\t\tIf stream\n\t\t\tLocal request:TRESTRequest = New TRESTRequest, response:TRESTResponse\n\t\t\trequest.SetProgressCallback(_ProgressCallback, New _mxProgressStore)\n\t\t\trequest.SetStream(stream)\n\t\t\tTry\n\t\t\t\tresponse = request.Call(m_sourcesurl, [\"User-Agent: \" + mainapp.m_useragent], \"GET\")\n\t\t\tCatch e:Object\n\t\t\t\tstream.Close()\n\t\t\t\tDeleteFile(file)\n\t\t\t\tlogger.LogMessage(\"\")\n\t\t\t\tThrowError(_s(\"error.fetch.sources\", [e.ToString()]))\n\t\t\tEnd Try\n\t\t\tstream.Close()\n\t\t\tIf response.IsSuccess()\n\t\t\t\tlogger.LogMessage(_s(\"message.fetch.done\", [String(response.responseCode)]))\n\t\t\t\tCopyFile(file, mainapp.m_sourcesfile)\n\t\t\t\tDeleteFile(file)\n\t\t\tElse\n\t\t\t\tDeleteFile(file)\n\t\t\t\tlogger.LogMessage(\"\")\n\t\t\t\tThrowError(_s(\"error.fetch.sources\", [\"Bad response code: \" + String(response.responseCode)]))\n\t\t\tEnd If\n\t\tElse\n\t\t\tThrowError(_s(\"error.writeperms\", [file]))\n\t\tEnd If\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Check the options given to the command.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod CheckOptions()\n\t\tm_sourcesurl = Null\n\t\tFor Local opt:dIdentifier = EachIn m_args\n\t\t\tSelect opt.GetName().ToLower()\n\t\t\t\tCase \"--url\"\n\t\t\t\t\tIf opt.GetChildCount() = 1\n\t\t\t\t\t\tm_sourcesurl = dStringVariable(opt.GetValueAtIndex(0)).Get()\n\t\t\t\t\tElse\n\t\t\t\t\t\tThrowCommonError(mxOptErrors.REQUIRESPARAMS, opt.GetName())\n\t\t\t\t\tEnd If\n\t\t\t\tDefault ThrowCommonError(mxOptErrors.UNKNOWN, opt.GetName())\n\t\t\tEnd Select\n\t\tNext\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Progress callback for sources fetching.\n\t\treturns: Zero (no error).\n\tEnd Rem\n\tFunction _ProgressCallback:Int(data:Object, dltotal:Double, dlnow:Double, ultotal:Double, ulnow:Double)\n\t\tLocal store:_mxProgressStore = _mxProgressStore(data)\n\t\tLocal prog:Int = (dlnow \/ dltotal) * 100\n\t\tIf prog > store.m_progress + 5\n\t\t\tstore.m_progress = prog\n\t\t\tWriteStdOut(\".\")\n\t\tEnd If\n\t\tReturn 0\n\tEnd Function\n\t\nEnd Type\n\n","old_contents":"\nRem\n\tbbdoc: Maximus 'update' argument implementation.\nEnd Rem\nType mxUpdateImpl Extends dArgumentImplementation\n\t\n\tField m_sourcesurl:String\n\t\n\tMethod New()\n\t\tinit([\"update\"])\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Check the current arguments for errors (according to the specific implementation).\n\t\treturns: Nothing.\n\t\tabout: This method will throw an error if the arguments are invalid.\n\tEnd Rem\n\tMethod CheckArgs()\n\t\tCheckOptions()\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get a string describing the typical usage of the argument.\n\t\treturns: A string describing the typical usage of the argument.\n\tEnd Rem\n\tMethod GetUsage:String()\n\t\tReturn _s(\"arg.update.usage\")\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Execute the implementation's operation.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod Execute()\n\t\tIf mainapp.m_sourcesupdated Then Return\n\t\tIf m_sourcesurl Then m_sourcesurl = mainapp.m_sourcesurl\n\t\tIf m_sourcesurl\n\t\t\tThrowError(_s(\"error.update.nourl\"))\n\t\tEnd If\n\t\tmainapp.m_sourcesupdated = True\n\t\tLocal file:String = mainapp.m_sourcesfile + \".tmp\"\n\t\tlogger.LogMessage(\"fetching: \" + m_sourcesurl + \" -> \" + file + \"~t\", False)\n\t\tLocal stream:TStream = WriteFileExplicitly(file)\n\t\tIf stream\n\t\t\tLocal request:TRESTRequest = New TRESTRequest, response:TRESTResponse\n\t\t\trequest.SetProgressCallback(_ProgressCallback, New _mxProgressStore)\n\t\t\trequest.SetStream(stream)\n\t\t\tTry\n\t\t\t\tresponse = request.Call(m_sourcesurl, [\"User-Agent: \" + mainapp.m_useragent], \"GET\")\n\t\t\tCatch e:Object\n\t\t\t\tstream.Close()\n\t\t\t\tDeleteFile(file)\n\t\t\t\tlogger.LogMessage(\"\")\n\t\t\t\tThrowError(_s(\"error.fetch.sources\", [e.ToString()]))\n\t\t\tEnd Try\n\t\t\tstream.Close()\n\t\t\tIf response.IsSuccess()\n\t\t\t\tlogger.LogMessage(_s(\"message.fetch.done\", [String(response.responseCode)]))\n\t\t\t\tCopyFile(file, mainapp.m_sourcesfile)\n\t\t\t\tDeleteFile(file)\n\t\t\tElse\n\t\t\t\tDeleteFile(file)\n\t\t\t\tlogger.LogMessage(\"\")\n\t\t\t\tThrowError(_s(\"error.fetch.sources\", [\"Bad response code: \" + String(response.responseCode)]))\n\t\t\tEnd If\n\t\tElse\n\t\t\tThrowError(_s(\"error.writeperms\", [file]))\n\t\tEnd If\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Check the options given to the command.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod CheckOptions()\n\t\tm_sourcesurl = Null\n\t\tFor Local opt:dIdentifier = EachIn m_args\n\t\t\tSelect opt.GetName().ToLower()\n\t\t\t\tCase \"--url\"\n\t\t\t\t\tIf opt.GetChildCount() = 1\n\t\t\t\t\t\tm_sourcesurl = dStringVariable(opt.GetValueAtIndex(0)).Get()\n\t\t\t\t\tElse\n\t\t\t\t\t\tThrowCommonError(mxOptErrors.REQUIRESPARAMS, opt.GetName())\n\t\t\t\t\tEnd If\n\t\t\t\tDefault ThrowCommonError(mxOptErrors.UNKNOWN, opt.GetName())\n\t\t\tEnd Select\n\t\tNext\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Progress callback for sources fetching.\n\t\treturns: Zero (no error).\n\tEnd Rem\n\tFunction _ProgressCallback:Int(data:Object, dltotal:Double, dlnow:Double, ultotal:Double, ulnow:Double)\n\t\tLocal store:_mxProgressStore = _mxProgressStore(data)\n\t\tLocal prog:Int = (dlnow \/ dltotal) * 100\n\t\tIf prog > store.m_progress + 5\n\t\t\tstore.m_progress = prog\n\t\t\tWriteStdOut(\".\")\n\t\tEnd If\n\t\tReturn 0\n\tEnd Function\n\t\nEnd Type\n\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"9a6aeb66179a45dc0e357e2d574e25b1e4e213cb","subject":"Small change to default texture flag now that texture filters have been added.","message":"Small change to default texture flag now that texture filters have been added.\n","repos":"kfprimm\/maxb3d,kfprimm\/maxb3d","old_file":"core.mod\/texture.bmx","new_file":"core.mod\/texture.bmx","new_contents":"\nStrict\n\nImport BRL.Pixmap\nImport \"resource.bmx\"\n\nConst TEXTURE_COLOR\t\t= 1\nConst TEXTURE_ALPHA\t\t= 2\nConst TEXTURE_MASKED\t= 4\nConst TEXTURE_MIPMAP\t= 8\nConst TEXTURE_CLAMPU\t= 16\nConst TEXTURE_CLAMPV\t= 32\nConst TEXTURE_SPHEREMAP\t= 64\nConst TEXTURE_CUBEMAP\t= 128\nConst TEXTURE_VRAM\t\t= 256\nConst TEXTURE_HIGHCOLOR\t= 512\nConst TEXTURE_DEPTH \t= 1024\n\nConst TEXTURE_DEFAULT\t= TEXTURE_COLOR\nConst TEXTURE_CLAMPUV\t= TEXTURE_CLAMPU|TEXTURE_CLAMPV\n\nConst BLEND_NONE = 0\nConst BLEND_ALPHA\t = 1\nConst BLEND_MULTIPLY = 2\nConst BLEND_ADD = 3\nConst BLEND_DOT3 = 4\nConst BLEND_MULTIPLY2 = 5\n\nConst CUBETEX_LEFT = 0\nConst CUBETEX_FRONT = 1\nConst CUBETEX_RIGHT = 2\nConst CUBETEX_BACK = 3\nConst CUBETEX_UP = 4\nConst CUBETEX_DOWN = 5\n\nType TTexture\n\tField _blend=BLEND_MULTIPLY,_coords,_flags\n\tField _px#,_py#,_r#,_sx#=1.0,_sy#=1.0\n\tField _width=-1,_height=-1,_frame:TTextureFrame[]\n\tField _name$\n\t\t\n\tMethod Lock:TPixmap(index=0)\n\t\t_frame[index]._locked=True\n\t\tReturn _frame[index]._pixmap\n\tEnd Method\n\t\n\tMethod Unlock(index=0)\n\t\t_frame[index]._locked=False\n\t\t_frame[index]._updateres=True\n\tEnd Method\n\t\n\tMethod SetPixmap:TPixmap(pixmap:TPixmap,index=0)\n\t\tIf pixmap=Null _frame[index]=Null;Return\n\t\tIf _frame[index]=Null _frame[index]=New TTextureFrame\n\t\t_frame[index]._pixmap=ConvertPixmap(pixmap,PF_BGRA8888)\n\t\t_frame[index]._updateres=True\n\t\t\n\t\tIf (_width<>-1 Or _height<>-1) And (_width<>PixmapWidth(pixmap) Or _height<>PixmapHeight(pixmap))\n\t\t\tThrow \"Pixmap size does not match texture size.\"\n\t\tElse\n\t\t\t_width=PixmapWidth(pixmap)\n\t\t\t_height=PixmapHeight(pixmap)\n\t\tEndIf\n\tEnd Method\n\t\n\tMethod GetFlags()\n\t\tReturn _flags\n\tEnd Method\n\tMethod SetFlags(flags)\n\t\t_flags=flags\n\tEnd Method\t\n\t\n\tMethod GetBlend()\n\t\tReturn _blend\n\tEnd Method\n\tMethod SetBlend(blend)\n\t\t_blend=blend\n\tEnd Method\n\t\n\tMethod GetCoords()\n\t\tReturn _coords\n\tEnd Method\n\tMethod SetCoords(set)\n\t\t_coords=set\n\tEnd Method\n\t\n\tMethod GetScale(x# Var,y# Var)\n\t\tx=1.0\/_sx;y=1.0\/_sy\n\tEnd Method\n\tMethod SetScale(x#,y#)\n\t\t_sx=1.0\/x;_sy=1.0\/y\n\tEnd Method\n\t\n\tMethod GetPosition(x# Var,y# Var)\n\t\tx=_px;y=_py\n\tEnd Method\n\tMethod SetPosition(x#,y#)\n\t\t_px=x;_py=y\n\tEnd Method\n\t\n\tMethod GetRotation#()\n\t\tReturn _r\n\tEnd Method\n\tMethod SetRotation(angle#)\n\t\t_r=angle\n\tEnd Method\n\t\n\tMethod GetSize(width Var,height Var)\n\t\twidth=_width;height=_height\n\tEnd Method\n\tMethod SetSize(width,height,frames)\n\t\t_width=width\n\t\t_height=height\n\t\t_frame=_frame[..frames]\n\tEnd Method\n\n\tMethod GetName$()\n\t\tReturn _name\n\tEnd Method\n\tMethod SetName(name$)\n\t\t_name=name\n\tEnd Method\nEnd Type\n\nType TTextureFrame \n\tField _res:TTextureRes,_updateres\t\n\tField _pixmap:TPixmap,_locked\n\tField _buffer:Object\nEnd Type\n\nType TTextureRes Extends TDriverResource\n\nEnd Type\n\n","old_contents":"\nStrict\n\nImport BRL.Pixmap\nImport \"resource.bmx\"\n\nConst TEXTURE_COLOR\t\t= 1\nConst TEXTURE_ALPHA\t\t= 2\nConst TEXTURE_MASKED\t= 4\nConst TEXTURE_MIPMAP\t= 8\nConst TEXTURE_CLAMPU\t= 16\nConst TEXTURE_CLAMPV\t= 32\nConst TEXTURE_SPHEREMAP\t= 64\nConst TEXTURE_CUBEMAP\t= 128\nConst TEXTURE_VRAM\t\t= 256\nConst TEXTURE_HIGHCOLOR\t= 512\nConst TEXTURE_DEPTH \t= 1024\n\nConst TEXTURE_DEFAULT\t= TEXTURE_COLOR|TEXTURE_MIPMAP\nConst TEXTURE_CLAMPUV\t= TEXTURE_CLAMPU|TEXTURE_CLAMPV\n\nConst BLEND_NONE = 0\nConst BLEND_ALPHA\t = 1\nConst BLEND_MULTIPLY = 2\nConst BLEND_ADD = 3\nConst BLEND_DOT3 = 4\nConst BLEND_MULTIPLY2 = 5\n\nConst CUBETEX_LEFT = 0\nConst CUBETEX_FRONT = 1\nConst CUBETEX_RIGHT = 2\nConst CUBETEX_BACK = 3\nConst CUBETEX_UP = 4\nConst CUBETEX_DOWN = 5\n\nType TTexture\n\tField _blend=BLEND_MULTIPLY,_coords,_flags\n\tField _px#,_py#,_r#,_sx#=1.0,_sy#=1.0\n\tField _width=-1,_height=-1,_frame:TTextureFrame[]\n\tField _name$\n\t\t\n\tMethod Lock:TPixmap(index=0)\n\t\t_frame[index]._locked=True\n\t\tReturn _frame[index]._pixmap\n\tEnd Method\n\t\n\tMethod Unlock(index=0)\n\t\t_frame[index]._locked=False\n\t\t_frame[index]._updateres=True\n\tEnd Method\n\t\n\tMethod SetPixmap:TPixmap(pixmap:TPixmap,index=0)\n\t\tIf pixmap=Null _frame[index]=Null;Return\n\t\tIf _frame[index]=Null _frame[index]=New TTextureFrame\n\t\t_frame[index]._pixmap=ConvertPixmap(pixmap,PF_BGRA8888)\n\t\t_frame[index]._updateres=True\n\t\t\n\t\tIf (_width<>-1 Or _height<>-1) And (_width<>PixmapWidth(pixmap) Or _height<>PixmapHeight(pixmap))\n\t\t\tThrow \"Pixmap size does not match texture size.\"\n\t\tElse\n\t\t\t_width=PixmapWidth(pixmap)\n\t\t\t_height=PixmapHeight(pixmap)\n\t\tEndIf\n\tEnd Method\n\t\n\tMethod GetFlags()\n\t\tReturn _flags\n\tEnd Method\n\tMethod SetFlags(flags)\n\t\t_flags=flags\n\tEnd Method\t\n\t\n\tMethod GetBlend()\n\t\tReturn _blend\n\tEnd Method\n\tMethod SetBlend(blend)\n\t\t_blend=blend\n\tEnd Method\n\t\n\tMethod GetCoords()\n\t\tReturn _coords\n\tEnd Method\n\tMethod SetCoords(set)\n\t\t_coords=set\n\tEnd Method\n\t\n\tMethod GetScale(x# Var,y# Var)\n\t\tx=1.0\/_sx;y=1.0\/_sy\n\tEnd Method\n\tMethod SetScale(x#,y#)\n\t\t_sx=1.0\/x;_sy=1.0\/y\n\tEnd Method\n\t\n\tMethod GetPosition(x# Var,y# Var)\n\t\tx=_px;y=_py\n\tEnd Method\n\tMethod SetPosition(x#,y#)\n\t\t_px=x;_py=y\n\tEnd Method\n\t\n\tMethod GetRotation#()\n\t\tReturn _r\n\tEnd Method\n\tMethod SetRotation(angle#)\n\t\t_r=angle\n\tEnd Method\n\t\n\tMethod GetSize(width Var,height Var)\n\t\twidth=_width;height=_height\n\tEnd Method\n\tMethod SetSize(width,height,frames)\n\t\t_width=width\n\t\t_height=height\n\t\t_frame=_frame[..frames]\n\tEnd Method\n\n\tMethod GetName$()\n\t\tReturn _name\n\tEnd Method\n\tMethod SetName(name$)\n\t\t_name=name\n\tEnd Method\nEnd Type\n\nType TTextureFrame \n\tField _res:TTextureRes,_updateres\t\n\tField _pixmap:TPixmap,_locked\n\tField _buffer:Object\nEnd Type\n\nType TTextureRes Extends TDriverResource\n\nEnd Type\n\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"bb258f1a4d36a6030663146ec1bd3c40eb60700a","subject":"Completed a comment","message":"Completed a comment\n","repos":"Htbaa\/zmq.mod,Htbaa\/zmq.mod","old_file":"tests\/main.bmx","new_file":"tests\/main.bmx","new_contents":"SuperStrict\nFramework bah.maxunit\nImport htbaapub.zmq\n\nNew TTestSuite.run()\n\nType TZMQ_Test Extends TTest\n\n\tMethod Setup() {before}\n\tEnd Method\n\t\n\tMethod Teardown() {after}\n\tEnd Method\n\n\tMethod Version() {test}\n\t\tLocal parts:String[] = TZMQ.Version().Split(\".\")\n\t\tassertTrue(parts.Length = 3, \"Version string contains 3 parts\")\n\tEnd Method\n\t\n\t'Make sure recreating an existing context isn't possible\n\tMethod ContextReCreate() {test}\n\t\tLocal ct:TZMQ_Context = New TZMQ_Context.Create()\n\t\tTry\n\t\t\tct = ct.Create()\n\t\tCatch ex:String\n\t\t\tassertNotNull(ex, \"Recreating context failed properly\")\n\t\tCatch ex:TZMQ_Exception\n\t\t\tfail(ex.ToString())\n\t\tEnd Try\n\t\tct.Term()\n\tEnd Method\n\n\t'Make sure a socket can be created\n\tMethod SocketCreate() {test}\n\t\tLocal ct:TZMQ_Context = New TZMQ_Context.Create()\n\t\tLocal socket:TZMQ_Socket = ct.socket(ZMQ_PUB)\n\t\tassertNotNull(socket, \"Created socket\")\n\t\tassertTrue(socket.socket <> Null, \"Created pointer to socket\")\n\t\tsocket.Close()\n\t\tct.Term()\n\tEnd Method\n\n\t'Make sure created messages contain expected data\n\tMethod MessageCreationFromStringIntegrity() {test}\n\t\tFor Local i:Int = 0 To 1000\n\t\t\tLocal text:String = \"Message \" + i\n\t\t\tLocal msg:TZMQ_Message = New TZMQ_Message.CreateFromString(text)\n\t\t\tassertEquals(text, msg.ToString(), \"Message text match\")\n\t\t\tassertEqualsI(text.Length, msg.Size(), \"Message size match\")\n\t\t\tmsg.Close()\n\t\tNext\n\tEnd Method\n\n\t'Make sure created messages contain expected data\n\tMethod MessageCreationFromPointerIntegrity() {test}\n\t\tFor Local i:Int = 0 To 1000\n\t\t\tLocal text:String = \"Message \" + i\n\t\t\tLocal msg:TZMQ_Message = New TZMQ_Message.Create(text.ToCString(), text.Length)\n\t\t\tassertEquals(text, msg.ToString(), \"Message text match\")\n\t\t\tassertEqualsI(text.Length, msg.Size(), \"Message size match\")\n\t\t\tmsg.Close()\n\t\t\tassertTrue(msg.content = Null, \"Message data freed\")\n\t\tNext\n\tEnd Method\n\t\n\t'Make sure exchanged messages aren't corrupt\n\tMethod MessageExchangingIntegrity() {test}\n\t\tLocal addr:String = \"tcp:\/\/127.0.0.1:6000\"\n\t\tLocal ct:TZMQ_Context = New TZMQ_Context.Create()\n\t\tLocal publisher:TZMQ_Socket = ct.socket(ZMQ_PUB)\n\t\tLocal subscriber:TZMQ_Socket = ct.socket(ZMQ_SUB)\n\t\t\n\t\tpublisher.Bind(addr)\n\t\tsubscriber.Connect(addr)\n\t\tsubscriber.SetSockOpt(ZMQ_SUBSCRIBE , Null)\n\n\t\tDelay 1000\n\t\tFor Local i:Int = 0 To 10\n\t\t\tDelay 10\n\t\t\tLocal text:String = \"Message \" + i\n\t\t\tpublisher.Send(text)\n\t\t\tLocal msg:TZMQ_Message = subscriber.Recv()\n\t\t\tIf msg = Null Then Continue\n\t\t\tassertEquals(text, msg.ToString(), \"Message \" + i + \" match\")\n\t\t\tassertEqualsI(text.Length, msg.Size(), \"Message \" + i + \" size match\")\n\t\t\tmsg.Close()\n\t\tNext\n\t\t\n\t\tsubscriber.Close()\n\t\tpublisher.Close()\n\t\tct.Term()\n\tEnd Method\nEnd Type\n","old_contents":"SuperStrict\nFramework bah.maxunit\nImport htbaapub.zmq\n\nNew TTestSuite.run()\n\nType TZMQ_Test Extends TTest\n\n\tMethod Setup() {before}\n\tEnd Method\n\t\n\tMethod Teardown() {after}\n\tEnd Method\n\n\tMethod Version() {test}\n\t\tLocal parts:String[] = TZMQ.Version().Split(\".\")\n\t\tassertTrue(parts.Length = 3, \"Version string contains 3 parts\")\n\tEnd Method\n\t\n\t'Make sure recreating an existing context\n\tMethod ContextReCreate() {test}\n\t\tLocal ct:TZMQ_Context = New TZMQ_Context.Create()\n\t\tTry\n\t\t\tct = ct.Create()\n\t\tCatch ex:String\n\t\t\tassertNotNull(ex, \"Recreating context failed properly\")\n\t\tCatch ex:TZMQ_Exception\n\t\t\tfail(ex.ToString())\n\t\tEnd Try\n\t\tct.Term()\n\tEnd Method\n\n\t'Make sure a socket can be created\n\tMethod SocketCreate() {test}\n\t\tLocal ct:TZMQ_Context = New TZMQ_Context.Create()\n\t\tLocal socket:TZMQ_Socket = ct.socket(ZMQ_PUB)\n\t\tassertNotNull(socket, \"Created socket\")\n\t\tassertTrue(socket.socket <> Null, \"Created pointer to socket\")\n\t\tsocket.Close()\n\t\tct.Term()\n\tEnd Method\n\n\t'Make sure created messages contain expected data\n\tMethod MessageCreationFromStringIntegrity() {test}\n\t\tFor Local i:Int = 0 To 1000\n\t\t\tLocal text:String = \"Message \" + i\n\t\t\tLocal msg:TZMQ_Message = New TZMQ_Message.CreateFromString(text)\n\t\t\tassertEquals(text, msg.ToString(), \"Message text match\")\n\t\t\tassertEqualsI(text.Length, msg.Size(), \"Message size match\")\n\t\t\tmsg.Close()\n\t\tNext\n\tEnd Method\n\n\t'Make sure created messages contain expected data\n\tMethod MessageCreationFromPointerIntegrity() {test}\n\t\tFor Local i:Int = 0 To 1000\n\t\t\tLocal text:String = \"Message \" + i\n\t\t\tLocal msg:TZMQ_Message = New TZMQ_Message.Create(text.ToCString(), text.Length)\n\t\t\tassertEquals(text, msg.ToString(), \"Message text match\")\n\t\t\tassertEqualsI(text.Length, msg.Size(), \"Message size match\")\n\t\t\tmsg.Close()\n\t\t\tassertTrue(msg.content = Null, \"Message data freed\")\n\t\tNext\n\tEnd Method\n\t\n\t'Make sure exchanged messages aren't corrupt\n\tMethod MessageExchangingIntegrity() {test}\n\t\tLocal addr:String = \"tcp:\/\/127.0.0.1:6000\"\n\t\tLocal ct:TZMQ_Context = New TZMQ_Context.Create()\n\t\tLocal publisher:TZMQ_Socket = ct.socket(ZMQ_PUB)\n\t\tLocal subscriber:TZMQ_Socket = ct.socket(ZMQ_SUB)\n\t\t\n\t\tpublisher.Bind(addr)\n\t\tsubscriber.Connect(addr)\n\t\tsubscriber.SetSockOpt(ZMQ_SUBSCRIBE , Null)\n\n\t\tDelay 1000\n\t\tFor Local i:Int = 0 To 10\n\t\t\tDelay 10\n\t\t\tLocal text:String = \"Message \" + i\n\t\t\tpublisher.Send(text)\n\t\t\tLocal msg:TZMQ_Message = subscriber.Recv()\n\t\t\tIf msg = Null Then Continue\n\t\t\tassertEquals(text, msg.ToString(), \"Message \" + i + \" match\")\n\t\t\tassertEqualsI(text.Length, msg.Size(), \"Message \" + i + \" size match\")\n\t\t\tmsg.Close()\n\t\tNext\n\t\t\n\t\tsubscriber.Close()\n\t\tpublisher.Close()\n\t\tct.Term()\n\tEnd Method\nEnd Type\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"c77b944fa5d24672dd76b73caaadd34750f1c3d8","subject":"Fixed up SetMatrix for MonkeyMax","message":"Fixed up SetMatrix for MonkeyMax\n\n--HG--\nextra : convert_revision : svn%3Ae934d3cd-0d57-f34a-94d0-9e8d31ae1c29\/trunk%40350\n","repos":"programmerby\/diddy-mirror,programmerby\/diddy-mirror,programmerby\/diddy-mirror,programmerby\/diddy-mirror","old_file":"monkeymax\/modules\/mojo\/native\/mojo.bmax.bmx","new_file":"monkeymax\/modules\/mojo\/native\/mojo.bmax.bmx","new_contents":"' ***** Start mojo.bmax.bmx ******\r\n\r\nGlobal app:gxtkApp;\r\n\r\nType gxtkApp\r\n\tField ginput:gxtkInput;\r\n\tField gaudio:gxtkAudio;\r\n\tField ggraphics:gxtkGraphics;\r\n\r\n\tField dead:Int=0;\r\n\tField suspended:Int=0;\r\n\tField vloading:Int=0;\r\n\tField maxloading:Int=0;\r\n\tField updateRate:Int=0;\r\n\tField nextUpdate:Float=0;\r\n\tField updatePeriod:Float=0;\r\n\tField startMillis:Float=0;\r\n\t\r\n\tMethod New()' gxtkApp()\r\n\t\tapp=Self;\r\n\t\tggraphics=New gxtkGraphics;\r\n\tEndMethod\r\n\t\r\n\tMethod Setup()\r\n\t\tginput=New gxtkInput;\r\n\t\tgaudio=New gxtkAudio;\r\n\r\n\t\tbb_input_SetInputDevice(ginput);\r\n\t\tbb_audio_SetAudioDevice(gaudio);\r\n\t\t\r\n\t\tstartMillis=BlitzMaxMillisecs()\r\n\t\t\r\n\t\tSetFrameRate( 0 );\r\n\t\t\r\n\t\tInvokeOnCreate();\r\n\t\tInvokeOnRender();\r\n\t\tUpdate()\r\n\tEndMethod\r\n\t\r\n\tMethod Update()\r\n\t\tWhile Not AppTerminate()\r\n\t\t\tLocal updates:Int = 0\r\n\t\t\t\r\n\t\t\tLocal cont:Int = 1\r\n\t\t\tWhile (cont)\r\n\t\t\t\tnextUpdate:+updatePeriod\r\n\t\t\t\tInvokeOnUpdate()\r\n\t\t\t\tIf Not updatePeriod Then cont = 0\r\n\t\t\t\tIf nextUpdate>BlitzMaxMillisecs() Then cont = 0\r\n\t\t\t\tupdates:+1\r\n\t\t\t\tIf updates = 7 Then\r\n\t\t\t\t\tnextUpdate = BlitzMaxMillisecs()\r\n\t\t\t\t\tcont = 0\r\n\t\t\t\tEndIf\r\n\t\t\tWend\r\n\t\t\tInvokeOnRender()\r\n\t\tWend\r\n\tEndMethod\r\n\t\r\n\tMethod InvokeOnCreate()\r\n\t\tIf dead Return\r\n\t\tdead = 1\r\n\t\tOnCreate()\r\n\t\tdead = 0\r\n\tEndMethod\r\n\r\n\tMethod InvokeOnUpdate()\r\n\t\tIf dead Or suspended Or Not updateRate Or vloading Return\r\n\t\tOnUpdate()\r\n\tEndMethod\r\n\t\r\n\tMethod InvokeOnRender()\r\n\t\tIf dead Or suspended Return\r\n\t\tggraphics.BeginRender()\r\n\t\tIf vloading\r\n\t\t\tOnLoading()\r\n\t\tElse\r\n\t\t\tOnRender()\r\n\t\tEndIf\r\n\t\tggraphics.EndRender()\r\n\tEndMethod\r\n\t\r\n\t\r\n\tMethod SetFrameRate( fps:Int )\r\n\t\tIf fps\r\n\t\t\tupdatePeriod=1000.0\/fps;\r\n\t\t\tnextUpdate=BlitzMaxMillisecs() +updatePeriod;\r\n\t\tElse\r\n\t\t\tupdatePeriod=0\r\n\t\tEndIf\r\n\tEndMethod\r\n\t\r\n\tMethod LoadString:String( path:String )\r\n\t\tpath = \"data\/\" + path;\r\n\t\tReturn LoadText( path )\r\n\tEndMethod\r\n\t\r\n\t' ***** GXTK API *****\r\n\t\r\n\tMethod GraphicsDevice:gxtkGraphics()\r\n\t\tReturn ggraphics\r\n\tEndMethod\r\n\r\n\tMethod InputDevice:gxtkInput()\r\n\t\tReturn ginput\r\n\tEndMethod\r\n\r\n\tMethod AudioDevice:gxtkAudio()\r\n\t\tReturn gaudio\r\n\tEndMethod\r\n\r\n\tMethod SetUpdateRate:Int(hertz:Int)\r\n\t\tupdateRate = hertz\r\n\t\tIf Not vloading Then SetFrameRate(updateRate)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod MilliSecs:Int()\r\n\t\tReturn BlitzMaxMillisecs() - startMillis\r\n\tEndMethod\r\n\t\r\n\tMethod Loading:Int()\r\n\t\tReturn vloading;\r\n\tEndMethod\r\n\r\n\tMethod OnCreate:Int()\r\n\t\tReturn 0;\r\n\tEndMethod\r\n\r\n\tMethod OnUpdate:Int()\r\n\t\tReturn 0;\r\n\tEndMethod\r\n\t\r\n\tMethod OnSuspend:Int()\r\n\t\tReturn 0;\r\n\tEndMethod\r\n\t\r\n\tMethod OnResume:Int()\r\n\t\tReturn 0;\r\n\tEndMethod\r\n\t\r\n\tMethod OnRender:Int()\r\n\t\tReturn 0;\r\n\tEndMethod\r\n\t\r\n\tMethod OnLoading:Int()\r\n\t\tReturn 0;\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkGraphics\r\n\tField gmode:Int = 1\r\n\r\n\tMethod Mode:Int()\r\n\t\tReturn gmode\r\n\tEndMethod\r\n\t\r\n\tMethod Cls:Int(r:Int = 0, g:Int = 0, b:Int = 0)\r\n\t\tBlitzMaxCls(r, g, b)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod LoadSurface:gxtkSurface(path:String)\r\n\t\tLocal image:TImage = LoadImage(\"data\/\"+path)\r\n\t\tIf image Then\r\n\t\t\tLocal gs:gxtkSurface = New gxtkSurface\r\n\t\t\tgs.setImage(image)\r\n\t\t\tReturn gs\r\n\t\tEndIf\r\n\t\tReturn Null\r\n\tEndMethod\r\n\t\r\n\tMethod BeginRender()\r\n\tEndMethod\r\n\t\r\n\tMethod EndRender()\r\n\t\tFlip\r\n\tEndMethod\r\n\t\r\n\tMethod SetColor:Int(r:Int, g:Int, b:Int)\r\n\t\tBlitzMaxSetColor(r, g, b)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod SetAlpha:Int(a:Float)\r\n\t\tBlitzMaxSetAlpha(a)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod SetBlend:Int(blend:Int)\r\n\t\tBlitzMaxSetBlend(blend)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod Width:Int()\r\n\t\t'TO-DO\r\n\t\tReturn 800\r\n\tEndMethod\r\n\t\r\n\tMethod Height:Int()\r\n\t\t'TO-DO\r\n\t\tReturn 480\r\n\tEndMethod\r\n\t\r\n\tMethod SetScissor:Int(x:Int, y:Int, w:Int, h:Int)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod SetMatrix:Int(ix:Float,iy:Float,jx:Float,jy:Float,tx:Float,ty:Float)\r\n\t\tLocal sx:Float = Sqr( (ix*ix) + (jx*jx) )\r\n\t\tLocal sy:Float = Sqr( (iy*iy) + (jy*jy) )\r\n\t\tLocal rot:Float = -Atan2( jx, ix )\r\n\t\tSetTransform( rot, sx, sy )\r\n\t\tSetOrigin( tx, ty )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawSurface:Int(surface:gxtkSurface,x:Float,y:Float)\r\n\t\tDrawImage(surface.image, x, y, 0)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawSurface2:Int(surface:gxtkSurface,x:Float,y:Float, srcx:Int, srcy:Int, srcw:Int, srch:Int )\r\n\t\tDrawSubImageRect(surface.image, x, y, srcw, srch, srcx, srcy, srcw, srch)\t\t\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawLine:Int( x1:Float,y1:Float,x2:Float,y2:Float )\r\n\t\tBlitzMaxDrawLine(x1, y1, x2, y2)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawOval:Int( x:Float, y:Float, w:Float, h:Float )\r\n\t\tBlitzMaxDrawOval(x, y, w, h)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawPoly:Int(vertices:Float[])\r\n\t\tBlitzMaxDrawPoly( vertices )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawRect:Int( x:Float, y:Float, w:Float, h:Float )\r\n\t\tBlitzMaxDrawRect(x, y, w, h)\r\n\t\tReturn 0\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkInput\r\n\tMethod MouseX:Float()\r\n\t\tReturn BRL.PolledInput.MouseX()\r\n\tEndMethod\r\n\r\n\tMethod MouseY:Float()\r\n\t\tReturn BRL.PolledInput.MouseY()\r\n\tEndMethod\r\n\t\r\n\tMethod KeyDown:Int( key:Int )\r\n\t\tIf( key >= 1 And key <= 3 )\r\n\t\t\tReturn BRL.PolledInput.MouseDown( key )\r\n\t\tEndIf\r\n\t\tReturn BRL.PolledInput.KeyDown( key )\r\n\tEndMethod\r\n\r\n\tMethod KeyHit:Int( key:Int )\r\n\t\tIf( key >= 1 And key <= 3 )\r\n\t\t\tReturn BRL.PolledInput.MouseHit( key )\r\n\t\tEndIf\r\n\t\tReturn BRL.PolledInput.KeyHit( key )\r\n\tEndMethod\r\n\r\n\tMethod GetChar:Int()\r\n\t\tReturn BRL.PolledInput.GetChar()\r\n\tEndMethod\r\n\r\n\tMethod JoyX:Int( index:Int )\r\n\t\tReturn Pub.FreeJoy.JoyX( index )\r\n\tEndMethod\r\n\r\n\tMethod JoyY:Int( index:Int )\r\n\t\tReturn Pub.FreeJoy.JoyY( index )\r\n\tEndMethod\r\n\r\n\tMethod JoyZ:Int( index:Int )\r\n\t\tReturn Pub.FreeJoy.JoyZ( index )\r\n\tEndMethod\r\n\r\n\tMethod TouchX:Float( index:Int )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod TouchY:Float( index:Int )\r\n\t\tReturn 0\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkChannel\r\n\tField channel:TChannel\t' null then not playing\r\n\tField sample:gxtkSample\r\n\tField loops:int\r\n\t'Field transform:SoundTransform=new SoundTransform()\r\n\t'Field pausepos:Number\r\n\tField state:int\r\n\t\r\n\tMethod New()\r\n\t\tchannel = New TChannel\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkAudio\r\n\tField amusicState:Int = 0;\r\n\tField channels:gxtkChannel[] = New gxtkChannel[33];\r\n\t\r\n\tMethod New()\r\n\t\tFor local i:Int = 0 To 33 - 1\r\n\t\t\tchannels[i] = New gxtkChannel\r\n\t\tNext\r\n\tEndMethod\r\n\t\r\n\tMethod MusicState:Int()\r\n'\t\tIf( musicState = 1 And music.isPlaying() = False )\r\n'\t\t\tmusicState = 0;\r\n'\t\tEndif\r\n\t\tReturn amusicState;\r\n\tEndMethod\r\n\t\r\n\tMethod PlayMusic:Int( path:String, flags:Int )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod StopMusic()\r\n\tEndMethod\r\n\t\r\n\tMethod StopChannel( channel:Int )\r\n\tEndMethod\r\n\r\n\tMethod PlaySample( sound:gxtkSample, channel:Int, flags:Int )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\t\r\n\t\t'If chan.state <> 0 Then chan.channel.Stop() <-- this crashes after the first play!?\r\n\t\t\r\n\t\tchan.sample = sound\r\n\t\t'chan.loops = flags ? 0x7fffffff : 0;\r\n\t\t'chan.channel = sample.sound.play( 0,chan.loops,chan.transform );\r\n\t\t'chan.channel = sound\r\n\t\tchan.state=1\r\n\t\r\n\t\tPlaySound( sound.sound, chan.channel )\r\n\tEndMethod\r\n\r\n\tMethod SetPan( channel:Int, pan:Float )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tchan.channel.SetPan(pan)\r\n\tEndMethod\r\n\r\n\tMethod SetRate( channel:Int, rate:Float )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tchan.channel.SetRate(rate)\r\n\tEndMethod\r\n\r\n\tMethod SetMusicVolume:Int( volume:Float )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod SetVolume:Int( channel:Int, volume:Float )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tchan.channel.SetVolume(volume)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod LoadSample:gxtkSample( path:String )\r\n\t\tLocal sound:TSound = LoadSound(\"data\/\"+path)\r\n\t\tIf sound Then\r\n\t\t\tLocal gs:gxtkSample = New gxtkSample\r\n\t\t\tgs.setSound(sound)\r\n\t\t\tReturn gs\r\n\t\tEndIf\r\n\t\tReturn Null\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkSample\r\n\tField sound:TSound\r\n\t\r\n\tMethod setSound(sound:TSound)\r\n\t\tSelf.sound = sound\r\n\tEndMethod\r\n\t\r\n\tMethod Discard()\r\n\t\tSelf.sound = null\r\n\tEndMethod\r\nEndType\r\n\r\nFunction BlitzMaxDrawPoly:Int(vertices:Float[])\r\n\tDrawPoly vertices\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxDrawRect:Int( x:Float, y:Float, w:Float, h:Float )\r\n\tDrawRect x, y, w, h\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxDrawOval:Int( x:Float, y:Float, w:Float, h:Float )\r\n\tDrawOval x, y, w, h\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxDrawLine:Int( x1:Float,y1:Float,x2:Float,y2:Float )\r\n\tDrawLine x1, y1, x2, y2\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxMillisecs:Int()\r\n\tReturn MilliSecs()\r\nEndFunction\r\n\r\nFunction BlitzMaxSetColor(r:Int, g:Int, b:Int)\r\n\tSetColor(r, g, b)\r\nEndFunction\r\n\r\nFunction BlitzMaxSetBlend(blend:Int)\r\n\tSelect blend\r\n\t\tCase 0\r\n\t\t\tSetBlend( ALPHABLEND )\r\n\t\tCase 1\r\n\t\t\tSetBlend( LIGHTBLEND )\r\n\tEnd Select\r\nEndFunction\r\n\r\nFunction BlitzMaxSetAlpha(a:Float)\r\n\tSetAlpha(a)\r\nEndFunction\r\n\r\nFunction BlitzMaxCls(r:Int = 0, g:Int = 0, b:Int = 0)\r\n\tSetClsColor(r, g, b)\r\n\tCls\r\nEndFunction\r\n\r\nType gxtkSurface\r\n\tField w:Int, h:Int\r\n\tField image:TImage\r\n\t\r\n\tMethod setImage(image:TImage)\r\n\t\tSelf.image = image\r\n\tEndMethod\r\n\t\r\n\tMethod Width:Int()\r\n\t\tReturn image.Width\r\n\tEndMethod\r\n\t\r\n\tMethod Height:Int()\r\n\t\tReturn image.Height\r\n\tEndMethod\r\n\t\r\n\tMethod Discard()\r\n\tEndMethod\r\nEndType\r\n\r\n' ***** End mojo.bmax.bmx ******\r\n\r\n","old_contents":"' ***** Start mojo.bmax.bmx ******\r\n\r\nGlobal app:gxtkApp;\r\n\r\nType gxtkApp\r\n\tField ginput:gxtkInput;\r\n\tField gaudio:gxtkAudio;\r\n\tField ggraphics:gxtkGraphics;\r\n\r\n\tField dead:Int=0;\r\n\tField suspended:Int=0;\r\n\tField vloading:Int=0;\r\n\tField maxloading:Int=0;\r\n\tField updateRate:Int=0;\r\n\tField nextUpdate:Float=0;\r\n\tField updatePeriod:Float=0;\r\n\tField startMillis:Float=0;\r\n\t\r\n\tMethod New()' gxtkApp()\r\n\t\tapp=Self;\r\n\t\tggraphics=New gxtkGraphics;\r\n\tEndMethod\r\n\t\r\n\tMethod Setup()\r\n\t\tginput=New gxtkInput;\r\n\t\tgaudio=New gxtkAudio;\r\n\r\n\t\tbb_input_SetInputDevice(ginput);\r\n\t\tbb_audio_SetAudioDevice(gaudio);\r\n\t\t\r\n\t\tstartMillis=BlitzMaxMillisecs()\r\n\t\t\r\n\t\tSetFrameRate( 0 );\r\n\t\t\r\n\t\tInvokeOnCreate();\r\n\t\tInvokeOnRender();\r\n\t\tUpdate()\r\n\tEndMethod\r\n\t\r\n\tMethod Update()\r\n\t\tWhile Not AppTerminate()\r\n\t\t\tLocal updates:Int = 0\r\n\t\t\t\r\n\t\t\tLocal cont:Int = 1\r\n\t\t\tWhile (cont)\r\n\t\t\t\tnextUpdate:+updatePeriod\r\n\t\t\t\tInvokeOnUpdate()\r\n\t\t\t\tIf Not updatePeriod Then cont = 0\r\n\t\t\t\tIf nextUpdate>BlitzMaxMillisecs() Then cont = 0\r\n\t\t\t\tupdates:+1\r\n\t\t\t\tIf updates = 7 Then\r\n\t\t\t\t\tnextUpdate = BlitzMaxMillisecs()\r\n\t\t\t\t\tcont = 0\r\n\t\t\t\tEndIf\r\n\t\t\tWend\r\n\t\t\tInvokeOnRender()\r\n\t\tWend\r\n\tEndMethod\r\n\t\r\n\tMethod InvokeOnCreate()\r\n\t\tIf dead Return\r\n\t\tdead = 1\r\n\t\tOnCreate()\r\n\t\tdead = 0\r\n\tEndMethod\r\n\r\n\tMethod InvokeOnUpdate()\r\n\t\tIf dead Or suspended Or Not updateRate Or vloading Return\r\n\t\tOnUpdate()\r\n\tEndMethod\r\n\t\r\n\tMethod InvokeOnRender()\r\n\t\tIf dead Or suspended Return\r\n\t\tggraphics.BeginRender()\r\n\t\tIf vloading\r\n\t\t\tOnLoading()\r\n\t\tElse\r\n\t\t\tOnRender()\r\n\t\tEndIf\r\n\t\tggraphics.EndRender()\r\n\tEndMethod\r\n\t\r\n\t\r\n\tMethod SetFrameRate( fps:Int )\r\n\t\tIf fps\r\n\t\t\tupdatePeriod=1000.0\/fps;\r\n\t\t\tnextUpdate=BlitzMaxMillisecs() +updatePeriod;\r\n\t\tElse\r\n\t\t\tupdatePeriod=0\r\n\t\tEndIf\r\n\tEndMethod\r\n\t\r\n\tMethod LoadString:String( path:String )\r\n\t\tpath = \"data\/\" + path;\r\n\t\tReturn LoadText( path )\r\n\tEndMethod\r\n\t\r\n\t' ***** GXTK API *****\r\n\t\r\n\tMethod GraphicsDevice:gxtkGraphics()\r\n\t\tReturn ggraphics\r\n\tEndMethod\r\n\r\n\tMethod InputDevice:gxtkInput()\r\n\t\tReturn ginput\r\n\tEndMethod\r\n\r\n\tMethod AudioDevice:gxtkAudio()\r\n\t\tReturn gaudio\r\n\tEndMethod\r\n\r\n\tMethod SetUpdateRate:Int(hertz:Int)\r\n\t\tupdateRate = hertz\r\n\t\tIf Not vloading Then SetFrameRate(updateRate)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod MilliSecs:Int()\r\n\t\tReturn BlitzMaxMillisecs() - startMillis\r\n\tEndMethod\r\n\t\r\n\tMethod Loading:Int()\r\n\t\tReturn vloading;\r\n\tEndMethod\r\n\r\n\tMethod OnCreate:Int()\r\n\t\tReturn 0;\r\n\tEndMethod\r\n\r\n\tMethod OnUpdate:Int()\r\n\t\tReturn 0;\r\n\tEndMethod\r\n\t\r\n\tMethod OnSuspend:Int()\r\n\t\tReturn 0;\r\n\tEndMethod\r\n\t\r\n\tMethod OnResume:Int()\r\n\t\tReturn 0;\r\n\tEndMethod\r\n\t\r\n\tMethod OnRender:Int()\r\n\t\tReturn 0;\r\n\tEndMethod\r\n\t\r\n\tMethod OnLoading:Int()\r\n\t\tReturn 0;\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkGraphics\r\n\tField gmode:Int = 1\r\n\r\n\tMethod Mode:Int()\r\n\t\tReturn gmode\r\n\tEndMethod\r\n\t\r\n\tMethod Cls:Int(r:Int = 0, g:Int = 0, b:Int = 0)\r\n\t\tBlitzMaxCls(r, g, b)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod LoadSurface:gxtkSurface(path:String)\r\n\t\tLocal image:TImage = LoadImage(\"data\/\"+path)\r\n\t\tIf image Then\r\n\t\t\tLocal gs:gxtkSurface = New gxtkSurface\r\n\t\t\tgs.setImage(image)\r\n\t\t\tReturn gs\r\n\t\tEndIf\r\n\t\tReturn Null\r\n\tEndMethod\r\n\t\r\n\tMethod BeginRender()\r\n\tEndMethod\r\n\t\r\n\tMethod EndRender()\r\n\t\tFlip\r\n\tEndMethod\r\n\t\r\n\tMethod SetColor:Int(r:Int, g:Int, b:Int)\r\n\t\tBlitzMaxSetColor(r, g, b)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod SetAlpha:Int(a:Float)\r\n\t\tBlitzMaxSetAlpha(a)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod SetBlend:Int(blend:Int)\r\n\t\tBlitzMaxSetBlend(blend)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod Width:Int()\r\n\t\t'TO-DO\r\n\t\tReturn 800\r\n\tEndMethod\r\n\t\r\n\tMethod Height:Int()\r\n\t\t'TO-DO\r\n\t\tReturn 480\r\n\tEndMethod\r\n\t\r\n\tMethod SetScissor:Int(x:Int, y:Int, w:Int, h:Int)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod SetMatrix:Int(ix:Float,iy:Float,jx:Float,jy:Float,tx:Float,ty:Float)\r\n'\t\tLocal sx:Float = Sqr( (ix*ix) + (jx*jx) )\r\n'\t\tLocal sy:Float = Sqr( (iy*iy) + (jy*jy) )\r\n'\t\tLocal rot:Float = Atan2( jx, ix )\r\n'\t\tSetTransform( rot, sx, sy )\r\n\t\tSetTransform( 0, ix, jy )\r\n\t\tSetOrigin( tx, ty )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawSurface:Int(surface:gxtkSurface,x:Float,y:Float)\r\n\t\tDrawImage(surface.image, x, y, 0)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawSurface2:Int(surface:gxtkSurface,x:Float,y:Float, srcx:Int, srcy:Int, srcw:Int, srch:Int )\r\n\t\tDrawSubImageRect(surface.image, x, y, srcw, srch, srcx, srcy, srcw, srch)\t\t\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawLine:Int( x1:Float,y1:Float,x2:Float,y2:Float )\r\n\t\tBlitzMaxDrawLine(x1, y1, x2, y2)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawOval:Int( x:Float, y:Float, w:Float, h:Float )\r\n\t\tBlitzMaxDrawOval(x, y, w, h)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawPoly:Int(vertices:Float[])\r\n\t\tBlitzMaxDrawPoly( vertices )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawRect:Int( x:Float, y:Float, w:Float, h:Float )\r\n\t\tBlitzMaxDrawRect(x, y, w, h)\r\n\t\tReturn 0\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkInput\r\n\tMethod MouseX:Float()\r\n\t\tReturn BRL.PolledInput.MouseX()\r\n\tEndMethod\r\n\r\n\tMethod MouseY:Float()\r\n\t\tReturn BRL.PolledInput.MouseY()\r\n\tEndMethod\r\n\t\r\n\tMethod KeyDown:Int( key:Int )\r\n\t\tIf( key >= 1 And key <= 3 )\r\n\t\t\tReturn BRL.PolledInput.MouseDown( key )\r\n\t\tEndIf\r\n\t\tReturn BRL.PolledInput.KeyDown( key )\r\n\tEndMethod\r\n\r\n\tMethod KeyHit:Int( key:Int )\r\n\t\tIf( key >= 1 And key <= 3 )\r\n\t\t\tReturn BRL.PolledInput.MouseHit( key )\r\n\t\tEndIf\r\n\t\tReturn BRL.PolledInput.KeyHit( key )\r\n\tEndMethod\r\n\r\n\tMethod GetChar:Int()\r\n\t\tReturn BRL.PolledInput.GetChar()\r\n\tEndMethod\r\n\r\n\tMethod JoyX:Int( index:Int )\r\n\t\tReturn Pub.FreeJoy.JoyX( index )\r\n\tEndMethod\r\n\r\n\tMethod JoyY:Int( index:Int )\r\n\t\tReturn Pub.FreeJoy.JoyY( index )\r\n\tEndMethod\r\n\r\n\tMethod JoyZ:Int( index:Int )\r\n\t\tReturn Pub.FreeJoy.JoyZ( index )\r\n\tEndMethod\r\n\r\n\tMethod TouchX:Float( index:Int )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod TouchY:Float( index:Int )\r\n\t\tReturn 0\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkChannel\r\n\tField channel:TChannel\t' null then not playing\r\n\tField sample:gxtkSample\r\n\tField loops:int\r\n\t'Field transform:SoundTransform=new SoundTransform()\r\n\t'Field pausepos:Number\r\n\tField state:int\r\n\t\r\n\tMethod New()\r\n\t\tchannel = New TChannel\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkAudio\r\n\tField amusicState:Int = 0;\r\n\tField channels:gxtkChannel[] = New gxtkChannel[33];\r\n\t\r\n\tMethod New()\r\n\t\tFor local i:Int = 0 To 33 - 1\r\n\t\t\tchannels[i] = New gxtkChannel\r\n\t\tNext\r\n\tEndMethod\r\n\t\r\n\tMethod MusicState:Int()\r\n'\t\tIf( musicState = 1 And music.isPlaying() = False )\r\n'\t\t\tmusicState = 0;\r\n'\t\tEndif\r\n\t\tReturn amusicState;\r\n\tEndMethod\r\n\t\r\n\tMethod PlayMusic:Int( path:String, flags:Int )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod StopMusic()\r\n\tEndMethod\r\n\t\r\n\tMethod StopChannel( channel:Int )\r\n\tEndMethod\r\n\r\n\tMethod PlaySample( sound:gxtkSample, channel:Int, flags:Int )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\t\r\n\t\t'If chan.state <> 0 Then chan.channel.Stop() <-- this crashes after the first play!?\r\n\t\t\r\n\t\tchan.sample = sound\r\n\t\t'chan.loops = flags ? 0x7fffffff : 0;\r\n\t\t'chan.channel = sample.sound.play( 0,chan.loops,chan.transform );\r\n\t\t'chan.channel = sound\r\n\t\tchan.state=1\r\n\t\r\n\t\tPlaySound( sound.sound, chan.channel )\r\n\tEndMethod\r\n\r\n\tMethod SetPan( channel:Int, pan:Float )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tchan.channel.SetPan(pan)\r\n\tEndMethod\r\n\r\n\tMethod SetRate( channel:Int, rate:Float )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tchan.channel.SetRate(rate)\r\n\tEndMethod\r\n\r\n\tMethod SetMusicVolume:Int( volume:Float )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod SetVolume:Int( channel:Int, volume:Float )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tchan.channel.SetVolume(volume)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod LoadSample:gxtkSample( path:String )\r\n\t\tLocal sound:TSound = LoadSound(\"data\/\"+path)\r\n\t\tIf sound Then\r\n\t\t\tLocal gs:gxtkSample = New gxtkSample\r\n\t\t\tgs.setSound(sound)\r\n\t\t\tReturn gs\r\n\t\tEndIf\r\n\t\tReturn Null\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkSample\r\n\tField sound:TSound\r\n\t\r\n\tMethod setSound(sound:TSound)\r\n\t\tSelf.sound = sound\r\n\tEndMethod\r\n\t\r\n\tMethod Discard()\r\n\t\tSelf.sound = null\r\n\tEndMethod\r\nEndType\r\n\r\nFunction BlitzMaxDrawPoly:Int(vertices:Float[])\r\n\tDrawPoly vertices\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxDrawRect:Int( x:Float, y:Float, w:Float, h:Float )\r\n\tDrawRect x, y, w, h\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxDrawOval:Int( x:Float, y:Float, w:Float, h:Float )\r\n\tDrawOval x, y, w, h\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxDrawLine:Int( x1:Float,y1:Float,x2:Float,y2:Float )\r\n\tDrawLine x1, y1, x2, y2\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxMillisecs:Int()\r\n\tReturn MilliSecs()\r\nEndFunction\r\n\r\nFunction BlitzMaxSetColor(r:Int, g:Int, b:Int)\r\n\tSetColor(r, g, b)\r\nEndFunction\r\n\r\nFunction BlitzMaxSetBlend(blend:Int)\r\n\tSelect blend\r\n\t\tCase 0\r\n\t\t\tSetBlend( ALPHABLEND )\r\n\t\tCase 1\r\n\t\t\tSetBlend( LIGHTBLEND )\r\n\tEnd Select\r\nEndFunction\r\n\r\nFunction BlitzMaxSetAlpha(a:Float)\r\n\tSetAlpha(a)\r\nEndFunction\r\n\r\nFunction BlitzMaxCls(r:Int = 0, g:Int = 0, b:Int = 0)\r\n\tSetClsColor(r, g, b)\r\n\tCls\r\nEndFunction\r\n\r\nType gxtkSurface\r\n\tField w:Int, h:Int\r\n\tField image:TImage\r\n\t\r\n\tMethod setImage(image:TImage)\r\n\t\tSelf.image = image\r\n\tEndMethod\r\n\t\r\n\tMethod Width:Int()\r\n\t\tReturn image.Width\r\n\tEndMethod\r\n\t\r\n\tMethod Height:Int()\r\n\t\tReturn image.Height\r\n\tEndMethod\r\n\t\r\n\tMethod Discard()\r\n\tEndMethod\r\nEndType\r\n\r\n' ***** End mojo.bmax.bmx ******\r\n\r\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"6f8723dbca032818dde1940c709e2365f14a74ed","subject":"Fixed example1.bmx","message":"Fixed example1.bmx\n","repos":"Htbaa\/xmlrpc.mod,Htbaa\/xmlrpc.mod,Htbaa\/xmlrpc.mod,Htbaa\/xmlrpc.mod,Htbaa\/xmlrpc.mod","old_file":"examples\/example1.bmx","new_file":"examples\/example1.bmx","new_contents":"SuperStrict\nImport htbaapub.xmlrpc\n\nFor Local a:Int = 0 To 10\n\tGCSuspend()\n\t'create a new request object\n\tLocal request:Byte Ptr = XMLRPC_RequestNew()\n\t\n\t'Set the method name and tell it we are making a request\n\tXMLRPC_RequestSetMethodName(request, String(\"hello\").ToCString())\n\tXMLRPC_RequestSetRequestType(request, xmlrpc_request_call)\n\t\n\t'tell it to write out xml-rpc\n\tbmxXMLRPC_RequestSetOutputOptions(request, xmlrpc_version_1_0)\n\t\n\t'Create a parameter list vector\n\tLocal xParamList:Byte Ptr = XMLRPC_CreateVector(Null, xmlrpc_vector_array)\n\t'Add our name as first param to the parameter list\n\t\n\t\n\tXMLRPC_VectorAppendString(xParamList, Null, \"Htbaa\")\n\tXMLRPC_VectorAppendBase64(xParamList, Null, \"Some Base64 text\")\n\tXMLRPC_VectorAppendBoolean(xParamList, Null, False)\n\tXMLRPC_VectorAppendBoolean(xParamList, Null, True)\n\tXMLRPC_VectorAppendDateTime(xParamList, Null, 1238998067)\n\tXMLRPC_VectorAppendDateTime_ISO8601(xParamList, Null, \"2009-04-05T16:27:03\")\n\tXMLRPC_VectorAppendDouble(xParamList, Null, 20.43)\n\tXMLRPC_VectorAppendInt(xParamList, Null, 19)\n\t\n\tXMLRPC_RequestSetData(request, xParamList)\n\t\n\tTry\n\t\tLocal xmlMessage:Byte Ptr = XMLRPC_REQUEST_ToXML(request, Null)\n\t\tPrint convertUTF8toISO8859(xmlMessage)\n\tCatch ex:Object\n\t\tDebugLog \"error!\"\n\tEnd Try\n\t\n\tXMLRPC_RequestFree(request, 1)\n\n\tGCResume()\n\tGCCollect()\n\t\n\tPrint \"memory allocated: \" + GCMemAlloced()\n\t\nNext","old_contents":"SuperStrict\nImport htbaapub.xmlrpc\n\nFor Local a:Int = 0 To 10\n\tGCSuspend()\n\t'create a new request object\n\tLocal request:Byte Ptr = XMLRPC_RequestNew()\n\t\n\t'Set the method name and tell it we are making a request\n\tXMLRPC_RequestSetMethodName(request, String(\"hello\").ToCString())\n\tXMLRPC_RequestSetRequestType(request, xmlrpc_request_call)\n\t\n\t'tell it to write out xml-rpc (default\n\tLocal output:Byte Ptr = XMLRPC_Create_STRUCT_XMLRPC_REQUEST_OUTPUT_OPTIONS(xmlrpc_version_1_0)\n\tXMLRPC_RequestSetOutputOptions(request, output)\n\t\n\t'Create a parameter list vector\n\tLocal xParamList:Byte Ptr = XMLRPC_CreateVector(Null, xmlrpc_vector_array)\n\t'Add our name as first param to the parameter list\n\t\n\t\n\tXMLRPC_VectorAppendString(xParamList, Null, \"Htbaa\")\n\tXMLRPC_VectorAppendBase64(xParamList, Null, \"Some Base64 text\")\n\tXMLRPC_VectorAppendBoolean(xParamList, Null, False)\n\tXMLRPC_VectorAppendBoolean(xParamList, Null, True)\n\tXMLRPC_VectorAppendDateTime(xParamList, Null, 1238998067)\n\tXMLRPC_VectorAppendDateTime_ISO8601(xParamList, Null, \"2009-04-05T16:27:03\")\n\tXMLRPC_VectorAppendDouble(xParamList, Null, 20.43)\n\tXMLRPC_VectorAppendInt(xParamList, Null, 19)\n\t\n\tXMLRPC_RequestSetData(request, xParamList)\n\t\n\tTry\n\t\tLocal xmlMessage:Byte Ptr = XMLRPC_REQUEST_ToXML(request, Null)\n\t\tPrint convertUTF8toISO8859(xmlMessage)\n\tCatch ex:Object\n\t\tDebugLog \"error!\"\n\tEnd Try\n\t\n\t'DebugLog output\n\tXMLRPC_RequestFree(request, 1)\n\n\tGCResume()\n\tGCCollect()\n\t\n\tPrint \"memory allocated: \" + GCMemAlloced()\n\t\nNext","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"f77a6cef3f3c8922541cecf059f5659958a6bfa0","subject":"[csv] (v0.6) \tAdded RemoveRow and RemoveRecord to dCSVMap, added RemoveRecord to dCSVRow \tUse dStringVariable.Create(, Null) instead of dVariable.RawToVariable(Null) in dCSVRow.InsertRecordsFromString","message":"[csv] (v0.6)\n\tAdded RemoveRow and RemoveRecord to dCSVMap, added RemoveRecord to dCSVRow\n\tUse dStringVariable.Create(, Null) instead of dVariable.RawToVariable(Null) in dCSVRow.InsertRecordsFromString\n","repos":"komiga\/duct-max,komiga\/duct-max,komiga\/duct-max","old_file":"csv.mod\/csv.bmx","new_file":"csv.mod\/csv.bmx","new_contents":"\nRem\nCopyright (c) 2010 Tim Howard\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and\/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\nEnd Rem\n\nSuperStrict\n\nRem\nbbdoc: CSV (comma-separated value) reading\/writing\nEnd Rem\nModule duct.csv\n\nModuleInfo \"Version: 0.6\"\nModuleInfo \"Copyright: Tim Howard\"\nModuleInfo \"License: MIT\"\n\nModuleInfo \"History: Version 0.6\"\nModuleInfo \"History: Added RemoveRow and RemoveRecord to dCSVMap, added RemoveRecord to dCSVRow\"\nModuleInfo \"History: Use dStringVariable.Create(, Null) instead of dVariable.RawToVariable(Null) in dCSVRow.InsertRecordsFromString\"\nModuleInfo \"History: Version 0.5\"\nModuleInfo \"History: dCSVMap rewritten, added serialization\"\nModuleInfo \"History: Added dCSVRow\"\nModuleInfo \"History: Renaming dCSVMap.GetRecordByPosition to dCSVMap.GetRecordFromPosition\"\nModuleInfo \"History: Renamed dCSVMap.InsertRecord to dCSVMap.AddRecord\"\nModuleInfo \"History: Corrected some documentation\"\nModuleInfo \"History: Renamed dCSVMap.CheckRecordAtPosition to dCSVMap.HasRecord\"\nModuleInfo \"History: Renamed module from csvreader to csv\"\nModuleInfo \"History: Version 0.4\"\nModuleInfo \"History: Fixed documentation, license, examples\"\nModuleInfo \"History: Renamed TCSVMap to dCSVMap\"\nModuleInfo \"History: Updated for API change\"\nModuleInfo \"History: Version 0.3\"\nModuleInfo \"History: General cleanup\"\nModuleInfo \"History: Version 0.2\"\nModuleInfo \"History: Moved all code into the main source\"\nModuleInfo \"History: Version 0.1\"\nModuleInfo \"History: Initial release\"\n\nImport brl.stream\nImport duct.etc\nImport duct.variables\nImport duct.intmap\n\nRem\n\tbbdoc: duct CSV (comma-separated value) map for reading CSV files.\nEnd Rem\nType dCSVMap\n\t\n\tField m_rows:dIntMap = New dIntMap\n\t\n\tRem\n\t\tbbdoc: Create a new map.\n\t\treturns: Itself.\n\tEnd Rem\n\tMethod Create:dCSVMap()\n\t\tReturn Self\n\tEnd Method\n\t\n'#region Record handling\n\t\n\tRem\n\t\tbbdoc: Get the number of rows in the map\n\t\treturns: The number of rows in the map.\n\tEnd Rem\n\tMethod GetRowCount:Int()\n\t\tReturn m_rows.Count()\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the number of columns in the header (row -1).\n\t\treturns: The number of columns in the header.\n\tEnd Rem\n\tMethod GetHeaderCount:Int()\n\t\tLocal header:dCSVRow = GetRow(-1, False)\n\t\tIf header\n\t\t\tReturn header.GetCount()\n\t\tEnd If\n\t\tReturn 0\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the number of records in the given row.\n\t\treturns: The number of records in the given row.\n\tEnd Rem\n\tMethod GetRowRecordCount:Int(index:Int)\n\t\tLocal row:dCSVRow = GetRow(index, False)\n\t\tIf row\n\t\t\tReturn row.GetCount()\n\t\tEnd If\n\t\tReturn 0\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the number of records in the map.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod GetRecordCount:Int()\n\t\tLocal count:Int\n\t\tFor Local row:dCSVRow = EachIn m_rows\n\t\t\tcount:+ row.GetCount()\n\t\tNext\n\t\tReturn count\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Insert a row.\n\t\treturns: True if the row was inserted, or False if it was not (Null row).\n\tEnd Rem\n\tMethod InsertRow:Int(row:dCSVRow)\n\t\tIf row\n\t\t\tm_rows.Insert(row.GetIndex(), row)\n\t\t\tReturn True\n\t\tEnd If\n\t\tReturn False\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Insert a record.\n\t\treturns: True if the record was inserted, or False if it was not.\n\tEnd Rem\n\tMethod InsertRecord:Int(record:dCSVRecord, row:Int)\n\t\tIf record\n\t\t\tGetRow(row, True).InsertRecord(record)\n\t\t\tReturn True\n\t\tEnd If\n\t\tReturn False \n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Remove the row at the given index.\n\t\treturns: True if the row was removed, or False if there is no row at the given index.\n\tEnd Rem\n\tMethod RemoveRow:Int(index:Int)\n\t\tReturn m_rows.Remove(index)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Remove the record at the given position.\n\t\treturns: True if the record was removed, or False if there is no record at the given position.\n\tEnd Rem\n\tMethod RemoveRecord:Int(row:Int, column:Int)\n\t\tLocal trow:dCSVRow = GetRow(row, False)\n\t\tIf trow\n\t\t\tReturn trow.RemoveRecord(column)\n\t\tEnd If\n\t\tReturn False\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the row at the given index.\n\t\treturns: The row at the given index, or Null if the given row could not be found (barring the option below).\n\t\tabout: If @docreate is True, the row will be created if it was not found (and returned).\n\tEnd Rem\n\tMethod GetRow:dCSVRow(index:Int, docreate:Int = False)\n\t\tLocal row:dCSVRow = dCSVRow(m_rows.ForKey(index))\n\t\tIf Not row And docreate\n\t\t\trow = New dCSVRow.Create(index)\n\t\t\tInsertRow(row)\n\t\tEnd If\n\t\tReturn row\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the record at the given position.\n\t\treturns: The record at the given position, or Null if the position does not contain a record.\n\tEnd Rem\n\tMethod GetRecord:dCSVRecord(row:Int, column:Int)\n\t\tLocal trow:dCSVRow = GetRow(row)\n\t\tIf trow\n\t\t\tReturn trow.GetRecord(column)\n\t\tEnd If\n\t\tReturn Null\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Check if there is a row at the given index.\n\t\treturns: True if there is a row at the given index, or False if there is not.\n\tEnd Rem\n\tMethod HasRow:Int(index:Int)\n\t\tReturn m_rows.Contains(index)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Check if there is a record at the given position.\n\t\treturns: True if there is a record at the given position, or False if there is not.\n\tEnd Rem\n\tMethod HasRecord:Int(row:Int, column:Int)\n\t\tLocal trow:dCSVRow = GetRow(row)\n\t\tIf trow\n\t\t\tReturn trow.HasRecord(column)\n\t\tEnd If\n\t\tReturn False\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Clear the map.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod Clear()\n\t\tm_rows.Clear()\n\tEnd Method\n\t\n'#end region Record handling\n\t\n\tRem\n\t\tbbdoc: Get the object enumerator (row enumerator) for the map.\n\t\treturns: The map's enumerator.\n\tEnd Rem\n\tMethod ObjectEnumerator:dIntMapStandardEnum()\n\t\tReturn m_rows.ObjectEnumerator()\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the reversed object enumerator (row enumerator) for the map.\n\t\treturns: The map's reverse enumerator.\n\tEnd Rem\n\tMethod ReverseEnumerator:dIntMapReverseEnum()\n\t\tReturn m_rows.ReverseEnumerator()\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Deserialize a CSV map from the given file.\n\t\treturns: Itself, or Null if either the stream or separator is Null.\n\t\tabout: @separator is the separator for columns.
\n\t\tIf @setheader is True, the first column encountered will be the header.\n\tEnd Rem\n\tMethod DeserializeFromFile:dCSVMap(url:String, separator:String = \",\", setheader:Int = True)\n\t\tIf separator\n\t\t\tLocal stream:TStream = ReadStream(url)\n\t\t\tIf stream\n\t\t\t\tDeserialize(stream, separator, setheader)\n\t\t\t\tstream.Close()\n\t\t\t\tReturn Self\n\t\t\tEnd If\n\t\tEnd If\n\t\tReturn Null\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Deserialize a CSV map from the given stream.\n\t\treturns: Itself.\n\t\tabout: The map will be cleared when this method is called.
\n\t\t@separator is the separator for columns.
\n\t\tIf @setheader is True, the first column encountered will be the header (retrievable by row index -1).\n\tEnd Rem\n\tMethod Deserialize:dCSVMap(stream:TStream, separator:String = \",\", setheader:Int = True)\n\t\tClear()\n\t\tLocal row:Int = setheader And -1 Or 0\n\t\tWhile Not stream.Eof()\n\t\t\tGetRow(row, True).Deserialize(stream, separator)\n\t\t\trow:+1\n\t\tEnd While\n\t\tReturn Self\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Serialize the CSV map to the given file.\n\t\treturns: True if the map was serialized, or False if it was not (bad url or Null separator).\n\tEnd Rem\n\tMethod SerializeToFile:Int(url:String, separator:String, forcequoting:Int = False)\n\t\tIf separator\n\t\t\tLocal stream:TStream = WriteStream(url)\n\t\t\tIf stream\n\t\t\t\tSerialize(stream, separator, forcequoting)\n\t\t\t\tstream.Close()\n\t\t\t\tReturn True\n\t\t\tEnd If\n\t\tEnd If\n\t\tReturn False\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Serialize the CSV map to the given stream.\n\t\treturns: Nothing.\n\t\tabout: @separator is the separator for columns.
\n\t\tIf @forcequoting is True, all columns will have quotes around them\n\tEnd Rem\n\tMethod Serialize(stream:TStream, separator:String = \",\", forcequoting:Int = False)\n\t\tFor Local row:dCSVRow = EachIn m_rows\n\t\t\trow.Serialize(stream, separator, forcequoting)\n\t\t\tstream.WriteString(\"~n\")\n\t\tNext\n\tEnd Method\n\t\nEnd Type\n\nRem\n\tbbdoc: duct CSVRow.\nEnd Rem\nType dCSVRow\n\t\n\tField m_records:dIntMap = New dIntMap\n\tField m_index:Int\n\t\n\tRem\n\t\tbbdoc: Create a CSV row.\n\t\treturns: Itself.\n\tEnd Rem\n\tMethod Create:dCSVRow(index:Int)\n\t\tSetIndex(index)\n\t\tReturn Self\n\tEnd Method\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the row's index.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetIndex(index:Int)\n\t\tm_index = index\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the index.\n\t\treturns: The row's index.\n\tEnd Rem\n\tMethod GetIndex:Int()\n\t\tReturn m_index\n\tEnd Method\n\t\n'#end region Field accessors\n\t\n'#region Record handling\n\t\n\tRem\n\t\tbbdoc: Insert the given record.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod InsertRecord:Int(record:dCSVRecord)\n\t\tIf record\n\t\t\tm_records.Insert(record.GetIndex(), record)\n\t\t\tReturn True\n\t\tEnd If\n\t\tReturn False\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Parse and insert the records from the given string, using the given separator.\n\t\treturns: The number of records inserted, or -1 if the given string or separator are Null.\n\t\tabout: If a newline character (ASCII 10) is encountered the parsing will terminate.\n\tEnd Rem\n\tMethod InsertRecordsFromString:Int(line:String, separator:String = \",\")\n\t\tIf line And separator\n\t\t\tLocal char:Int, quote:Int, index:Int, issep:Int, buf:dTempBuf = New dTempBuf\n\t\t\tFor Local n:Int = 0 Until line.Length\n\t\t\t\tchar = line[n]\n\t\t\t\tIf char = 34\n\t\t\t\t\tquote:~1\n\t\t\t\tEnd If\n\t\t\t\tissep = line[n..n + separator.Length] = separator And Not quote\n\t\t\t\tIf Not issep And char <> 34 Then buf.AddChar(char)\n\t\t\t\tIf issep Or n = line.Length - 1 Or char = 10\n\t\t\t\t\tLocal value:String = buf.AsString().Trim(); buf.Clear()\n\t\t\t\t\t'If value\n\t\t\t\t\t\tInsertRecord(New dCSVRecord.Create(index, dVariable.RawToVariable(value)))\n\t\t\t\t\t'End If\n\t\t\t\t\t'n:+ separator.Length\n\t\t\t\t\tindex:+ 1\n\t\t\t\t\tIf issep And n = line.Length - 1\n\t\t\t\t\t\tInsertRecord(New dCSVRecord.Create(index, New dStringVariable.Create(, Null)))\n\t\t\t\t\t\tindex:+ 1\n\t\t\t\t\tEnd If\n\t\t\t\t\tIf char = 10 Then Exit\n\t\t\t\tEnd If\n\t\t\tNext\n\t\t\tReturn index\n\t\tEnd If\n\t\tReturn -1\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Remove the record at the given index.\n\t\treturns: True if the record was removed, or False if there is no record at the given index.\n\tEnd Rem\n\tMethod RemoveRecord:Int(index:Int)\n\t\tReturn m_records.Remove(index)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the record at the given index (column).\n\t\treturns: The record at the given index, or Null if there is no record at the given index.\n\tEnd Rem\n\tMethod GetRecord:dCSVRecord(index:Int)\n\t\tReturn dCSVRecord(m_records.ForKey(index))\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Check if the row has the given record.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod HasRecord:Int(index:Int)\n\t\tReturn m_records.Contains(index)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the number of records in the row.\n\t\treturns: The number of records in the row.\n\t\tabout: NOTE: This will count blank records (goes by the last column).\n\tEnd Rem\n\tMethod GetCount:Int()\n\t\tLocal success:Int\n\t\tReturn m_records.GetLastKey(success) + 1\n\tEnd Method\n\t\n'#end region Record handling\n\t\n\tRem\n\t\tbbdoc: Get the object enumerator (record enumerator) for the map.\n\t\treturns: The row's enumerator.\n\tEnd Rem\n\tMethod ObjectEnumerator:dIntMapStandardEnum()\n\t\tReturn m_records.ObjectEnumerator()\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the object enumerator (record enumerator) for the map.\n\t\treturns: The row's enumerator.\n\tEnd Rem\n\tMethod ReverseEnumerator:dIntMapReverseEnum()\n\t\tReturn m_records.ReverseEnumerator()\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Deserialize a CSV row from the given stream.\n\t\treturns: Itself.\n\tEnd Rem\n\tMethod Deserialize:dCSVRow(stream:TStream, separator:String = \",\")\n\t\t\tInsertRecordsFromString(stream.ReadLine(), separator)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Serialize the row to the given stream.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod Serialize(stream:TStream, separator:String = \",\", forcequoting:Int = False)\n\t\tLocal lastindex:Int\n\t\tFor Local record:dCSVRecord = EachIn m_records\n\t\t\t'DebugLog(\"i, li, sub: \" + record.m_index + \", \" + lastindex + \", \" + (record.m_index - lastindex))\n\t\t\tFor Local i:Int = 0 Until record.m_index - lastindex\n\t\t\t\tstream.WriteString(separator)\n\t\t\tNext\n\t\t\trecord.Serialize(stream, separator, forcequoting)\n\t\t\tlastindex = record.m_index\n\t\tNext\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the row as a string.\n\t\treturns: A string containing all the records in the row, separated by the given separator.\n\tEnd Rem\n\tMethod Report:String(separator:String = \",\", forcequoting:Int = False)\n\t\tLocal build:String, lastindex:Int, str:String\n\t\tFor Local record:dCSVRecord = EachIn m_records\n\t\t\tFor Local i:Int = 0 Until record.m_index - lastindex\n\t\t\t\tbuild:+ separator\n\t\t\tNext\n\t\t\tstr = record.ToString()\n\t\t\tIf str\n\t\t\t\tIf str.Contains(\" \") Or str.Contains(\"~t\") Or str.Contains(separator) Or forcequoting\n\t\t\t\t\tbuild:+ \"~q\" + str + \"~q\"\n\t\t\t\tElse\n\t\t\t\t\tbuild:+ str\n\t\t\t\tEnd If\n\t\t\tElse If forcequoting\n\t\t\t\tbuild:+ \"~q~q\"\n\t\t\tEnd If\n\t\t\tlastindex = record.m_index\n\t\tNext\n\t\tReturn build\n\tEnd Method\n\t\nEnd Type\n\nRem\n\tbbdoc: duct CSVRecord.\nEnd Rem\nType dCSVRecord\n\t\n\tField m_index:Int\n\tField m_variable:dVariable\n\t\n\tMethod New()\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Create a new record.\n\t\treturns: Itself.\n\tEnd Rem\n\tMethod Create:dCSVRecord(index:Int, variable:dVariable)\n\t\tSetIndex(index)\n\t\tSetVariable(variable)\n\t\tReturn Self\n\tEnd Method\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the index for the record.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetIndex(index:Int)\n\t\tm_index = index\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the record's index.\n\t\treturns: The index for the record.\n\tEnd Rem\n\tMethod GetIndex:Int()\n\t\tReturn m_index\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the variable for the record.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetVariable(variable:dVariable)\n\t\tm_variable = variable\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the record's variable.\n\t\treturns: The variable for the record.\n\tEnd Rem\n\tMethod GetVariable:dVariable()\n\t\tReturn m_variable\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the record's header.\n\t\treturns: The header for the record, or Null if the record's variable is Null.\n\tEnd Rem\n\tMethod GetHeader:String()\n\t\tIf m_variable\n\t\t\tReturn m_variable.GetName()\n\t\tEnd If\n\t\tReturn Null\n\tEnd Method\n\t\n'#end region Field accessors\n\t\n\tRem\n\t\tbbdoc: Deserialize a record from the given stream.\n\t\treturns: Itself.\n\tEnd Rem\n\tMethod Deserialize:dCSVRecord()\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Serialize the record to the given stream.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod Serialize(stream:TStream, separator:String = \",\", forcequoting:Int = False)\n\t\tLocal str:String = ToString()\n\t\tIf str\n\t\t\tIf str.Contains(\" \") Or str.Contains(\"~t\") Or str.Contains(separator) Or forcequoting\n\t\t\t\tstream.WriteString(\"~q\" + str + \"~q\")\n\t\t\tElse\n\t\t\t\tstream.WriteString(str)\n\t\t\tEnd If\n\t\tElse If forcequoting\n\t\t\tstream.WriteString(\"~q~q\")\n\t\tEnd If\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the record's value.\n\t\treturns: The record's value.\n\tEnd Rem\n\tMethod ToString:String()\n\t\tIf m_variable Then Return m_variable.ValueAsString() Else Return Null\n\tEnd Method\n\t\nEnd Type\n\nType dTempBuf\n\n\tConst BUFFERINITIAL_SIZE:Int = 128\n\tConst BUFFER_MULTIPLIER:Double = 1.75:Double\n\n\tField m_buffer:Short Ptr = Null, m_bufSize:Int = 0, m_bufLen:Int = 0\n\tField m_bufS:String = Null\n\n\tMethod New()\n\tEnd Method\n\n\tMethod Delete() NoDebug\n\t\tIf m_buffer <> Null\n\t\t\tMemFree(m_buffer)\n\t\t\tm_buffer = Null\n\t\tEnd If\n\tEnd Method\n\n\tMethod Clear()\n\t\tm_bufS = Null\n\t\tm_bufLen = 0\n\tEnd Method\n\n\tMethod AddChar(char:Int)\n\t\tIf m_buffer = Null\n\t\t\tm_bufSize = BUFFERINITIAL_SIZE\n\t\t\tm_buffer = Short Ptr(MemAlloc(m_bufSize * 2))\n\t\t\tm_bufLen = 0\n\t\tElse If m_bufLen = m_bufSize\n\t\t\tLocal newsize:Int = Ceil(m_bufSize * BUFFER_MULTIPLIER)\n\t\t\tIf newSize < m_bufLen\n\t\t\t\tnewSize = Ceil(m_bufLen * BUFFER_MULTIPLIER)\n\t\t\tEnd If\n\t\t\tLocal temp:Short Ptr = Short Ptr(MemAlloc(newSize * 2))\n\t\t\tIf temp = Null\n\t\t\t\tThrow(\"(dTempBuf.AddChar()) Unable To allocate buffer of size \" + (newSize * 2) + \" bytes\")\n\t\t\tEnd If\n\t\t\tm_bufSize = newSize\n\t\t\tMemCopy(temp, m_buffer, m_bufLen * 2)\n\t\t\tMemFree(m_buffer)\n\t\t\tm_buffer = temp\n\t\tEnd If\n\t\tm_buffer[m_bufLen] = char\n\t\tm_bufLen:+1\n\tEnd Method\n\n\tMethod AsString:String()\n\t\tIf m_bufS <> Null And (m_buffer = Null Or m_bufS.Length = m_bufLen)\n\t\t\tReturn m_bufS\n\t\tEnd If\n\t\tm_bufS = String.FromShorts(m_buffer, m_bufLen)\n\t\tReturn m_bufS\n\tEnd Method\n\nEnd Type\n\n","old_contents":"\nRem\nCopyright (c) 2010 Tim Howard\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and\/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\nEnd Rem\n\nSuperStrict\n\nRem\nbbdoc: CSV (comma-separated value) reading\/writing\nEnd Rem\nModule duct.csv\n\nModuleInfo \"Version: 0.5\"\nModuleInfo \"Copyright: Tim Howard\"\nModuleInfo \"License: MIT\"\n\nModuleInfo \"History: Version 0.5\"\nModuleInfo \"History: dCSVMap rewritten, added serialization\"\nModuleInfo \"History: Added dCSVRow\"\nModuleInfo \"History: Renaming dCSVMap.GetRecordByPosition to dCSVMap.GetRecordFromPosition\"\nModuleInfo \"History: Renamed dCSVMap.InsertRecord to dCSVMap.AddRecord\"\nModuleInfo \"History: Corrected some documentation\"\nModuleInfo \"History: Renamed dCSVMap.CheckRecordAtPosition to dCSVMap.HasRecord\"\nModuleInfo \"History: Renamed module from csvreader to csv\"\nModuleInfo \"History: Version 0.4\"\nModuleInfo \"History: Fixed documentation, license, examples\"\nModuleInfo \"History: Renamed TCSVMap to dCSVMap\"\nModuleInfo \"History: Updated for API change\"\nModuleInfo \"History: Version 0.3\"\nModuleInfo \"History: General cleanup\"\nModuleInfo \"History: Version 0.2\"\nModuleInfo \"History: Moved all code into the main source\"\nModuleInfo \"History: Version 0.1\"\nModuleInfo \"History: Initial release\"\n\nImport brl.stream\nImport duct.etc\nImport duct.variables\nImport duct.intmap\n\nRem\n\tbbdoc: duct CSV (comma-separated value) map for reading CSV files.\nEnd Rem\nType dCSVMap\n\t\n\tField m_rows:dIntMap = New dIntMap\n\t\n\tRem\n\t\tbbdoc: Create a new map.\n\t\treturns: Itself.\n\tEnd Rem\n\tMethod Create:dCSVMap()\n\t\tReturn Self\n\tEnd Method\n\t\n'#region Record handling\n\t\n\tRem\n\t\tbbdoc: Get the number of rows in the map\n\t\treturns: The number of rows in the map.\n\tEnd Rem\n\tMethod GetRowCount:Int()\n\t\tReturn m_rows.Count()\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the number of columns in the header (row -1).\n\t\treturns: The number of columns in the header.\n\tEnd Rem\n\tMethod GetHeaderCount:Int()\n\t\tLocal header:dCSVRow = GetRow(-1, False)\n\t\tIf header\n\t\t\tReturn header.GetCount()\n\t\tEnd If\n\t\tReturn 0\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the number of records in the given row.\n\t\treturns: The number of records in the given row.\n\tEnd Rem\n\tMethod GetRowRecordCount:Int(index:Int)\n\t\tLocal row:dCSVRow = GetRow(index, False)\n\t\tIf row\n\t\t\tReturn row.GetCount()\n\t\tEnd If\n\t\tReturn 0\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the number of records in the map.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod GetRecordCount:Int()\n\t\tLocal count:Int\n\t\tFor Local row:dCSVRow = EachIn m_rows\n\t\t\tcount:+ row.GetCount()\n\t\tNext\n\t\tReturn count\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Insert a row.\n\t\treturns: True if the row was inserted, or False if it was not (Null row).\n\tEnd Rem\n\tMethod InsertRow:Int(row:dCSVRow)\n\t\tIf row\n\t\t\tm_rows.Insert(row.GetIndex(), row)\n\t\t\tReturn True\n\t\tEnd If\n\t\tReturn False\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Insert a record.\n\t\treturns: True if the record was inserted, or False if it was not.\n\tEnd Rem\n\tMethod InsertRecord:Int(record:dCSVRecord, row:Int)\n\t\tIf record\n\t\t\tGetRow(row, True).InsertRecord(record)\n\t\t\tReturn True\n\t\tEnd If\n\t\tReturn False \n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the row at the given index.\n\t\treturns: The row at the given index, or Null if the given row could not be found (barring the option below).\n\t\tabout: If @docreate is True, the row will be created if it was not found (and returned).\n\tEnd Rem\n\tMethod GetRow:dCSVRow(index:Int, docreate:Int = False)\n\t\tLocal row:dCSVRow = dCSVRow(m_rows.ForKey(index))\n\t\tIf Not row And docreate\n\t\t\trow = New dCSVRow.Create(index)\n\t\t\tInsertRow(row)\n\t\tEnd If\n\t\tReturn row\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the record at the given position.\n\t\treturns: The record at the given position, or Null if the position does not contain a record.\n\tEnd Rem\n\tMethod GetRecord:dCSVRecord(row:Int, column:Int)\n\t\tLocal trow:dCSVRow = GetRow(row)\n\t\tIf trow\n\t\t\tReturn trow.GetRecord(column)\n\t\tEnd If\n\t\tReturn Null\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Check if there is a row at the given index.\n\t\treturns: True if there is a row at the given index, or False if there is not.\n\tEnd Rem\n\tMethod HasRow:Int(index:Int)\n\t\tReturn m_rows.Contains(index)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Check if there is a record at the given position.\n\t\treturns: True if there is a record at the given position, or False if there is not.\n\tEnd Rem\n\tMethod HasRecord:Int(row:Int, column:Int)\n\t\tLocal trow:dCSVRow = GetRow(row)\n\t\tIf trow\n\t\t\tReturn trow.HasRecord(column)\n\t\tEnd If\n\t\tReturn False\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Clear the map.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod Clear()\n\t\tm_rows.Clear()\n\tEnd Method\n\t\n'#end region Record handling\n\t\n\tRem\n\t\tbbdoc: Get the object enumerator (row enumerator) for the map.\n\t\treturns: The map's enumerator.\n\tEnd Rem\n\tMethod ObjectEnumerator:dIntMapStandardEnum()\n\t\tReturn m_rows.ObjectEnumerator()\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the reversed object enumerator (row enumerator) for the map.\n\t\treturns: The map's reverse enumerator.\n\tEnd Rem\n\tMethod ReverseEnumerator:dIntMapReverseEnum()\n\t\tReturn m_rows.ReverseEnumerator()\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Deserialize a CSV map from the given file.\n\t\treturns: Itself, or Null if either the stream or separator is Null.\n\t\tabout: @separator is the separator for columns.
\n\t\tIf @setheader is True, the first column encountered will be the header.\n\tEnd Rem\n\tMethod DeserializeFromFile:dCSVMap(url:String, separator:String = \",\", setheader:Int = True)\n\t\tIf separator\n\t\t\tLocal stream:TStream = ReadStream(url)\n\t\t\tIf stream\n\t\t\t\tDeserialize(stream, separator, setheader)\n\t\t\t\tstream.Close()\n\t\t\t\tReturn Self\n\t\t\tEnd If\n\t\tEnd If\n\t\tReturn Null\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Deserialize a CSV map from the given stream.\n\t\treturns: Itself.\n\t\tabout: The map will be cleared when this method is called.
\n\t\t@separator is the separator for columns.
\n\t\tIf @setheader is True, the first column encountered will be the header (retrievable by row index -1).\n\tEnd Rem\n\tMethod Deserialize:dCSVMap(stream:TStream, separator:String = \",\", setheader:Int = True)\n\t\tClear()\n\t\tLocal row:Int = setheader And -1 Or 0\n\t\tWhile Not stream.Eof()\n\t\t\tGetRow(row, True).Deserialize(stream, separator)\n\t\t\trow:+1\n\t\tEnd While\n\t\tReturn Self\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Serialize the CSV map to the given file.\n\t\treturns: True if the map was serialized, or False if it was not (bad url or Null separator).\n\tEnd Rem\n\tMethod SerializeToFile:Int(url:String, separator:String, forcequoting:Int = False)\n\t\tIf separator\n\t\t\tLocal stream:TStream = WriteStream(url)\n\t\t\tIf stream\n\t\t\t\tSerialize(stream, separator, forcequoting)\n\t\t\t\tstream.Close()\n\t\t\t\tReturn True\n\t\t\tEnd If\n\t\tEnd If\n\t\tReturn False\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Serialize the CSV map to the given stream.\n\t\treturns: Nothing.\n\t\tabout: @separator is the separator for columns.
\n\t\tIf @forcequoting is True, all columns will have quotes around them\n\tEnd Rem\n\tMethod Serialize(stream:TStream, separator:String = \",\", forcequoting:Int = False)\n\t\tFor Local row:dCSVRow = EachIn m_rows\n\t\t\trow.Serialize(stream, separator, forcequoting)\n\t\t\tstream.WriteString(\"~n\")\n\t\tNext\n\tEnd Method\n\t\nEnd Type\n\nRem\n\tbbdoc: duct CSVRow.\nEnd Rem\nType dCSVRow\n\t\n\tField m_records:dIntMap = New dIntMap\n\tField m_index:Int\n\t\n\tRem\n\t\tbbdoc: Create a CSV row.\n\t\treturns: Itself.\n\tEnd Rem\n\tMethod Create:dCSVRow(index:Int)\n\t\tSetIndex(index)\n\t\tReturn Self\n\tEnd Method\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the row's index.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetIndex(index:Int)\n\t\tm_index = index\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the index.\n\t\treturns: The row's index.\n\tEnd Rem\n\tMethod GetIndex:Int()\n\t\tReturn m_index\n\tEnd Method\n\t\n'#end region Field accessors\n\t\n'#region Record handling\n\t\n\tRem\n\t\tbbdoc: Insert the given record.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod InsertRecord:Int(record:dCSVRecord)\n\t\tIf record\n\t\t\tm_records.Insert(record.GetIndex(), record)\n\t\t\tReturn True\n\t\tEnd If\n\t\tReturn False\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Parse and insert the records from the given string, using the given separator.\n\t\treturns: The number of records inserted, or -1 if the given string or separator are Null.\n\t\tabout: If a newline character (ASCII 10) is encountered the parsing will terminate.\n\tEnd Rem\n\tMethod InsertRecordsFromString:Int(line:String, separator:String = \",\")\n\t\tIf line And separator\n\t\t\tLocal char:Int, quote:Int, index:Int, issep:Int, buf:dTempBuf = New dTempBuf\n\t\t\tFor Local n:Int = 0 Until line.Length\n\t\t\t\tchar = line[n]\n\t\t\t\tIf char = 34\n\t\t\t\t\tquote:~1\n\t\t\t\tEnd If\n\t\t\t\tissep = line[n..n + separator.Length] = separator And Not quote\n\t\t\t\tIf Not issep And char <> 34 Then buf.AddChar(char)\n\t\t\t\tIf issep Or n = line.Length - 1 Or char = 10\n\t\t\t\t\tLocal value:String = buf.AsString().Trim(); buf.Clear()\n\t\t\t\t\t'If value\n\t\t\t\t\t\tInsertRecord(New dCSVRecord.Create(index, dVariable.RawToVariable(value)))\n\t\t\t\t\t'End If\n\t\t\t\t\t'n:+ separator.Length\n\t\t\t\t\tindex:+ 1\n\t\t\t\t\tIf issep And n = line.Length - 1\n\t\t\t\t\t\tInsertRecord(New dCSVRecord.Create(index, dVariable.RawToVariable(\"\")))\n\t\t\t\t\t\tindex:+ 1\n\t\t\t\t\tEnd If\n\t\t\t\t\tIf char = 10 Then Exit\n\t\t\t\tEnd If\n\t\t\tNext\n\t\t\tReturn index\n\t\tEnd If\n\t\tReturn -1\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the record at the given index (column).\n\t\treturns: The record at the given index, or Null if there is no record at the given index.\n\tEnd Rem\n\tMethod GetRecord:dCSVRecord(index:Int)\n\t\tReturn dCSVRecord(m_records.ForKey(index))\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Check if the row has the given record.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod HasRecord:Int(index:Int)\n\t\tReturn m_records.Contains(index)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the number of records in the row.\n\t\treturns: The number of records in the row.\n\t\tabout: NOTE: This will count blank records (goes by the last column).\n\tEnd Rem\n\tMethod GetCount:Int()\n\t\tLocal success:Int\n\t\tReturn m_records.GetLastKey(success) + 1\n\tEnd Method\n\t\n'#end region Record handling\n\t\n\tRem\n\t\tbbdoc: Get the object enumerator (record enumerator) for the map.\n\t\treturns: The row's enumerator.\n\tEnd Rem\n\tMethod ObjectEnumerator:dIntMapStandardEnum()\n\t\tReturn m_records.ObjectEnumerator()\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the object enumerator (record enumerator) for the map.\n\t\treturns: The row's enumerator.\n\tEnd Rem\n\tMethod ReverseEnumerator:dIntMapReverseEnum()\n\t\tReturn m_records.ReverseEnumerator()\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Deserialize a CSV row from the given stream.\n\t\treturns: Itself.\n\tEnd Rem\n\tMethod Deserialize:dCSVRow(stream:TStream, separator:String = \",\")\n\t\t\tInsertRecordsFromString(stream.ReadLine(), separator)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Serialize the row to the given stream.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod Serialize(stream:TStream, separator:String = \",\", forcequoting:Int = False)\n\t\tLocal lastindex:Int\n\t\tFor Local record:dCSVRecord = EachIn m_records\n\t\t\t'DebugLog(\"i, li, sub: \" + record.m_index + \", \" + lastindex + \", \" + (record.m_index - lastindex))\n\t\t\tFor Local i:Int = 0 Until record.m_index - lastindex\n\t\t\t\tstream.WriteString(separator)\n\t\t\tNext\n\t\t\trecord.Serialize(stream, separator, forcequoting)\n\t\t\tlastindex = record.m_index\n\t\tNext\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the row as a string.\n\t\treturns: A string containing all the records in the row, separated by the given separator.\n\tEnd Rem\n\tMethod Report:String(separator:String = \",\", forcequoting:Int = False)\n\t\tLocal build:String, lastindex:Int, str:String\n\t\tFor Local record:dCSVRecord = EachIn m_records\n\t\t\tFor Local i:Int = 0 Until record.m_index - lastindex\n\t\t\t\tbuild:+ separator\n\t\t\tNext\n\t\t\tstr = record.ToString()\n\t\t\tIf str\n\t\t\t\tIf str.Contains(\" \") Or str.Contains(\"~t\") Or str.Contains(separator) Or forcequoting\n\t\t\t\t\tbuild:+ \"~q\" + str + \"~q\"\n\t\t\t\tElse\n\t\t\t\t\tbuild:+ str\n\t\t\t\tEnd If\n\t\t\tElse If forcequoting\n\t\t\t\tbuild:+ \"~q~q\"\n\t\t\tEnd If\n\t\t\tlastindex = record.m_index\n\t\tNext\n\t\tReturn build\n\tEnd Method\n\t\nEnd Type\n\nRem\n\tbbdoc: duct CSVRecord.\nEnd Rem\nType dCSVRecord\n\t\n\tField m_index:Int\n\tField m_variable:dVariable\n\t\n\tMethod New()\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Create a new record.\n\t\treturns: Itself.\n\tEnd Rem\n\tMethod Create:dCSVRecord(index:Int, variable:dVariable)\n\t\tSetIndex(index)\n\t\tSetVariable(variable)\n\t\tReturn Self\n\tEnd Method\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the index for the record.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetIndex(index:Int)\n\t\tm_index = index\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the record's index.\n\t\treturns: The index for the record.\n\tEnd Rem\n\tMethod GetIndex:Int()\n\t\tReturn m_index\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the variable for the record.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetVariable(variable:dVariable)\n\t\tm_variable = variable\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the record's variable.\n\t\treturns: The variable for the record.\n\tEnd Rem\n\tMethod GetVariable:dVariable()\n\t\tReturn m_variable\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the record's header.\n\t\treturns: The header for the record, or Null if the record's variable is Null.\n\tEnd Rem\n\tMethod GetHeader:String()\n\t\tIf m_variable\n\t\t\tReturn m_variable.GetName()\n\t\tEnd If\n\t\tReturn Null\n\tEnd Method\n\t\n'#end region Field accessors\n\t\n\tRem\n\t\tbbdoc: Deserialize a record from the given stream.\n\t\treturns: Itself.\n\tEnd Rem\n\tMethod Deserialize:dCSVRecord()\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Serialize the record to the given stream.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod Serialize(stream:TStream, separator:String = \",\", forcequoting:Int = False)\n\t\tLocal str:String = ToString()\n\t\tIf str\n\t\t\tIf str.Contains(\" \") Or str.Contains(\"~t\") Or str.Contains(separator) Or forcequoting\n\t\t\t\tstream.WriteString(\"~q\" + str + \"~q\")\n\t\t\tElse\n\t\t\t\tstream.WriteString(str)\n\t\t\tEnd If\n\t\tElse If forcequoting\n\t\t\tstream.WriteString(\"~q~q\")\n\t\tEnd If\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the record's value.\n\t\treturns: The record's value.\n\tEnd Rem\n\tMethod ToString:String()\n\t\tIf m_variable Then Return m_variable.ValueAsString() Else Return Null\n\tEnd Method\n\t\nEnd Type\n\nType dTempBuf\n\n\tConst BUFFERINITIAL_SIZE:Int = 128\n\tConst BUFFER_MULTIPLIER:Double = 1.75:Double\n\n\tField m_buffer:Short Ptr = Null, m_bufSize:Int = 0, m_bufLen:Int = 0\n\tField m_bufS:String = Null\n\n\tMethod New()\n\tEnd Method\n\n\tMethod Delete() NoDebug\n\t\tIf m_buffer <> Null\n\t\t\tMemFree(m_buffer)\n\t\t\tm_buffer = Null\n\t\tEnd If\n\tEnd Method\n\n\tMethod Clear()\n\t\tm_bufS = Null\n\t\tm_bufLen = 0\n\tEnd Method\n\n\tMethod AddChar(char:Int)\n\t\tIf m_buffer = Null\n\t\t\tm_bufSize = BUFFERINITIAL_SIZE\n\t\t\tm_buffer = Short Ptr(MemAlloc(m_bufSize * 2))\n\t\t\tm_bufLen = 0\n\t\tElse If m_bufLen = m_bufSize\n\t\t\tLocal newsize:Int = Ceil(m_bufSize * BUFFER_MULTIPLIER)\n\t\t\tIf newSize < m_bufLen\n\t\t\t\tnewSize = Ceil(m_bufLen * BUFFER_MULTIPLIER)\n\t\t\tEnd If\n\t\t\tLocal temp:Short Ptr = Short Ptr(MemAlloc(newSize * 2))\n\t\t\tIf temp = Null\n\t\t\t\tThrow(\"(dTempBuf.AddChar()) Unable To allocate buffer of size \" + (newSize * 2) + \" bytes\")\n\t\t\tEnd If\n\t\t\tm_bufSize = newSize\n\t\t\tMemCopy(temp, m_buffer, m_bufLen * 2)\n\t\t\tMemFree(m_buffer)\n\t\t\tm_buffer = temp\n\t\tEnd If\n\t\tm_buffer[m_bufLen] = char\n\t\tm_bufLen:+1\n\tEnd Method\n\n\tMethod AsString:String()\n\t\tIf m_bufS <> Null And (m_buffer = Null Or m_bufS.Length = m_bufLen)\n\t\t\tReturn m_bufS\n\t\tEnd If\n\t\tm_bufS = String.FromShorts(m_buffer, m_bufLen)\n\t\tReturn m_bufS\n\tEnd Method\n\nEnd Type\n\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"0348bd9de1f5d9ab274f72b4edffeb32713e7b60","subject":"Fixed sprite rendering.","message":"Fixed sprite rendering.\n","repos":"kfprimm\/maxb3d,kfprimm\/maxb3d","old_file":"d3d9driver.mod\/d3d9driver.bmx","new_file":"d3d9driver.mod\/d3d9driver.bmx","new_contents":"\nStrict\n\nRem\n\tbbdoc: Direct3D 9 renderer for MaxB3D\nEnd Rem\nModule MaxB3D.D3D9Driver\nModuleInfo \"Author: Kevin Primm\"\nModuleInfo \"License: MIT\"\n\nImport MaxB3D.Core\nImport Prime.D3D9Max2DEx\nImport Prime.DirectXEx\n\n?Win32\n\nImport \"d3d9.cpp\"\n\nPrivate \n\nExtern \"C\"\n\tFunction maxb3dD3D9VertexElements:Byte Ptr()'=\"_maxb3dD3D9VertexElements@0\"\nEnd Extern\n\nFunction GetD3D9MaxB3DVertexDecl:IDirect3DVertexDeclaration9(d3ddev:IDirect3DDevice9)\n\tGlobal decl:IDirect3DVertexDeclaration9,dev:IDirect3DDevice9\n\tIf decl=Null Or dev<>d3ddev\n\t\tAssert d3ddev.CreateVertexDeclaration(maxb3dD3D9VertexElements(),decl)=D3D_OK,\"Failed to create vertex declaration.\"\n\t\tdev=d3ddev\n\tEndIf\n\tReturn decl\nEnd Function\n\nFunction Pow2Size( n )\n\tLocal t=1\n\tWhile tNull\n\t\t\t_d3ddev=TD3D9Graphics(TMax2DGraphics(g)._graphics).GetDirect3DDevice()\n\t\t\tEndMax2D\n\t\tEndIf\n\tEnd Method\n\t\t\n\tMethod MakeBuffer:TBuffer(src:Object,width,height,flags)\n\t\tReturn TMax2DExDriver(_parent).MakeBuffer(src,width,height,flags)\n\tEnd Method\n\t\n\tMethod GetCaps:TCaps()\n\t\tLocal caps:TCaps=New TCaps\n\t\tReturn caps\n\tEnd Method\n\t\n\tMethod Abbr$()\n\t\tReturn \"d3d9\"\n\tEnd Method\n\t\n\tMethod SetMax2D(enable)\n\t\tIf enable\n\t\t\tGlobal identity:TMatrix=TMatrix.Identity()\n\t\t\tLocal width=GraphicsWidth(),height=GraphicsHeight()\n\t\t\tLocal matrix#[]=[..\n\t\t\t2.0\/width,0.0,0.0,0.0,..\n\t\t\t 0.0,-2.0\/height,0.0,0.0,..\n\t\t\t 0.0,0.0,1.0,0.0,..\n\t\t\t -1-(1.0\/width),1+(1.0\/height),1.0,1.0]\n\t\t\t\n\t\t\tSetBlend -1\n\t\t\tSetBlend SOLIDBLEND\n\t\t\t\n\t\t\t_d3ddev.SetTransform D3DTS_PROJECTION,matrix\n\t\t\t_d3ddev.SetTransform D3DTS_WORLD,identity.ToPtr()\n\t\t\t_d3ddev.SetTransform D3DTS_VIEW,identity.ToPtr()\n\t\t\t_d3ddev.SetTransform D3DTS_TEXTURE0,identity.ToPtr()\n\t\t\t\n\t\t\t_d3ddev.SetVertexDeclaration Null\n\t\t\t_d3ddev.SetIndices Null\n\t\t\t_d3ddev.SetFVF D3DFVF_XYZ|D3DFVF_DIFFUSE|D3DFVF_TEX1\n\t\t\t\n\t\t\t_d3ddev.SetRenderState D3DRS_LIGHTING,False\n\t\t\t_d3ddev.SetRenderState D3DRS_ZENABLE,False\n\t\t\t_d3ddev.SetRenderState D3DRS_SCISSORTESTENABLE,_viewporton\t\t\n\t\t\t\n\t\t\t_d3ddev.SetRenderState D3DRS_ALPHATESTENABLE,True\n\t\t\t\n\t\t\tFor Local i=1 To 7\n\t\t\t\t_d3ddev.SetTexture i,Null\n\t\t\tNext\n\t\t\t\t\n\t\t\t_d3ddev.SetFVF D3DFVF_XYZ|D3DFVF_DIFFUSE|D3DFVF_TEX1\n\t\t\t\n\t\t\t_d3ddev.SetTextureStageState 0,D3DTSS_COLOROP,D3DTOP_MODULATE\n\t\t\t_d3ddev.SetTextureStageState 0,D3DTSS_ALPHAOP,D3DTOP_MODULATE\n\t\t\t\n\t\t\t_d3ddev.SetTextureStageState 0,D3DTSS_ADDRESS,D3DTADDRESS_CLAMP\n\t\t\n\t\t\t_d3ddev.SetTextureStageState 0,D3DTSS_MAGFILTER,D3DTFG_POINT\n\t\t\t_d3ddev.SetTextureStageState 0,D3DTSS_MINFILTER,D3DTFN_POINT\n\t\t\t_d3ddev.SetTextureStageState 0,D3DTSS_MIPFILTER,D3DTFP_POINT\n\t\t\t\n\t\t\t_d3ddev.SetRenderState D3DRS_FOGENABLE,False\n\t\t\t\t\t\t\t\t\n\t\t\t_d3ddev.SetRenderState D3DRS_CULLMODE,D3DCULL_NONE\n\t\t\t_d3ddev.SetRenderState D3DRS_FILLMODE,D3DFILL_SOLID\n\t\tElse\n\t\t\t_d3ddev.SetRenderState D3DRS_ZENABLE,True\n\t\t\t_d3ddev.SetRenderState D3DRS_ZWRITEENABLE,True\n\t\n\t\t\t_d3ddev.GetRenderState D3DRS_SCISSORTESTENABLE,_viewporton\n\t\t\t_d3ddev.SetRenderState D3DRS_SCISSORTESTENABLE,True\n\t\t\t\n\t\t\t_d3ddev.SetRenderState D3DRS_LIGHTING,True\n\t\t\t_d3ddev.SetRenderState D3DRS_NORMALIZENORMALS,True\n\t\t\t\n\t\t\t_d3ddev.SetRenderState D3DRS_COLORVERTEX, True\n\t\t\t\t\t\t\n\t\t\t'_d3ddev.SetRenderState D3DRS_ALPHAREF, 1\n\t\t\t'_d3ddev.SetRenderState D3DRS_ALPHAFUNC, D3DCMP_GREATEREQUAL\n\t\tEndIf\t\n\tEnd Method\n\t\n\tMethod SetCamera(camera:TCamera,config:TWorldConfig)\n\t\t_d3ddev.SetRenderState D3DRS_DITHERENABLE, config.Dither\n\t\t\n\t\tLocal clearflags\t\t\n\t\tIf camera._clsmode&CLSMODE_COLOR clearflags:|D3DCLEAR_TARGET\n\t\tIf camera._clsmode&CLSMODE_DEPTH clearflags:|D3DCLEAR_ZBUFFER\n\n\t\tLocal viewport[]=[camera._viewx,camera._viewy,camera._viewwidth-camera._viewx,camera._viewheight-camera._viewy]\n\t\t_d3ddev.SetScissorRect viewport\n\t\t_d3ddev.Clear(1,viewport,clearflags,D3DCOLOR_XRGB(camera._brush._r*255,camera._brush._g*255,camera._brush._b*255),1.0,0)\n\t\t\t\t\n\t\tSelect camera._fogmode\n\t\tCase FOGMODE_LINEAR\n\t\t\t_d3ddev.SetRenderState D3DRS_FOGENABLE,True\n\t\t\t_d3ddev.SetRenderState D3DRS_FOGSTART,Int(Varptr camera._fognear)\n\t\t\t_d3ddev.SetRenderState D3DRS_FOGEND,Int(Varptr camera._fogfar)\n\t\tDefault\n\t\t\t_d3ddev.SetRenderState D3DRS_FOGENABLE,False\n\t\tEnd Select\n\t\t\n\t\tLocal oldnear# = camera._near ' Ugh, hack. Need to investigate cause.\n\t\tcamera._near :- 0.396250010 \n\t\tcamera.UpdateMatrices()\n\t\tcamera._near = oldnear\n\t\t\n\t\t_d3ddev.SetTransform D3DTS_PROJECTION,camera._projection.ToPtr() \n\t\t_d3ddev.SetTransform D3DTS_VIEW,camera._modelview.ToPtr()\n\tEnd Method\n\t\n\tMethod SetLight(light:TLight,index)\n\t\tIf light=Null \n\t\t\t_d3ddev.LightEnable index,False\n\t\t\tReturn\n\t\tEndIf\n\t\t\n\t\tLocal brush:TBrush=light._brush\n\n\t\tGlobal d3dlight:D3DLIGHT9=New D3DLIGHT9\n\t\td3dlight.Type_=D3DLIGHT_DIRECTIONAL \n\t\td3dlight.Diffuse_r=brush._r;d3dlight.Diffuse_g=brush._g;d3dlight.Diffuse_b=brush._b;d3dlight.Diffuse_a=brush._a\n\t\t'd3dlight.Ambient_r=WorldConfig.AmbientRed\/255.0;d3dlight.Ambient_g=WorldConfig.AmbientGreen\/255.0;d3dlight.Ambient_b=WorldConfig.AmbientBlue\/255.0;d3dlight.Ambient_a=1.0\n\t\t\n\t\td3dlight.Direction_x=0.0;d3dlight.Direction_y=0.0;d3dlight.Direction_z=1.0\n\t\t\t\t\n\t\tLocal matrix:TMatrix=light._matrix\n\t\tmatrix.TransformVec3 d3dlight.Direction_x,d3dlight.Direction_y,d3dlight.Direction_z\n\t\tmatrix.GetPosition d3dlight.Position_x,d3dlight.Position_y,d3dlight.Position_z\t\t\n\t\t\n\t\td3dlight.Range=light._range\t\t\n\t\t\n\t\t_d3ddev.SetLight index,d3dlight\n\t\t_d3ddev.LightEnable index,True\n\tEnd Method\n\t\n\tMethod SetBrush(brush:TBrush,hasalpha,config:TWorldConfig)\t\t\n\t\t_d3ddev.SetRenderState D3DRS_ALPHABLENDENABLE,hasalpha\n\t\t_d3ddev.SetRenderState D3DRS_ZWRITEENABLE,Not hasalpha\n\t\t\n\t\tSelect brush._blend\n\t\tCase BLEND_NONE, BLEND_ALPHA\n\t\t\t_d3ddev.SetRenderState D3DRS_SRCBLEND,D3DBLEND_SRCALPHA\n\t\t\t_d3ddev.SetRenderState D3DRS_DESTBLEND,D3DBLEND_INVSRCALPHA\n\t\tCase BLEND_MULTIPLY\n\t\t\t_d3ddev.SetRenderState D3DRS_SRCBLEND,D3DBLEND_DESTCOLOR\n\t\t\t_d3ddev.SetRenderState D3DRS_DESTBLEND,D3DBLEND_ZERO\n\t\tCase BLEND_ADD\n\t\t\t_d3ddev.SetRenderState D3DRS_SRCBLEND,D3DBLEND_SRCALPHA\n\t\t\t_d3ddev.SetRenderState D3DRS_DESTBLEND,D3DBLEND_ONE\n\t\tEnd Select\n\n\t\tIf brush._fx&FX_FULLBRIGHT\n\t\t\t_d3ddev.SetRenderState D3DRS_AMBIENT,D3DCOLOR_RGB(255,255,255)\n\t\tElse\n\t\t\t_d3ddev.SetRenderState D3DRS_AMBIENT,D3DCOLOR_RGB(config.AmbientRed,config.AmbientGreen,config.AmbientBlue)\n\t\tEndIf\n\t\t\n\t\tIf brush._fx&FX_VERTEXCOLOR\n\t\t\t_d3ddev.SetRenderState D3DRS_DIFFUSEMATERIALSOURCE,D3DMCS_COLOR1\n\t\t\t_d3ddev.SetRenderState D3DRS_AMBIENTMATERIALSOURCE,D3DMCS_COLOR1\n\t\tElse\n\t\t\t_d3ddev.SetRenderState D3DRS_DIFFUSEMATERIALSOURCE,D3DMCS_MATERIAL\n\t\t\t_d3ddev.SetRenderState D3DRS_AMBIENTMATERIALSOURCE,D3DMCS_MATERIAL \n\t\tEndIf\n\t\t\n\t\tIf brush._fx&FX_FLATSHADED\n\t\t\t_d3ddev.SetRenderState D3DRS_SHADEMODE, D3DSHADE_FLAT\n\t\tElse\n\t\t\t_d3ddev.SetRenderState D3DRS_SHADEMODE, D3DSHADE_GOURAUD\n\t\tEndIf\n\n\t\tIf brush._fx&FX_NOCULLING\n\t\t\t_d3ddev.SetRenderState D3DRS_CULLMODE,D3DCULL_NONE\n\t\tElse\n\t\t\t_d3ddev.SetRenderState D3DRS_CULLMODE,D3DCULL_CCW\n\t\tEndIf\n\t\t\n\t\tIf brush._fx&FX_WIREFRAME Or config.Wireframe\n\t\t\t_d3ddev.SetRenderState D3DRS_FILLMODE,D3DFILL_WIREFRAME\n\t\tElse\n\t\t\t_d3ddev.SetRenderState D3DRS_FILLMODE,D3DFILL_SOLID\n\t\tEndIf\n\t\t\n\t\tLocal material:D3DMATERIAL9 = New D3DMATERIAL9\n\t\tmaterial.Diffuse_r=brush._r;material.Diffuse_g=brush._g;material.Diffuse_b=brush._b;material.Diffuse_a=brush._a\n\t\tmaterial.Ambient_r=brush._r;material.Ambient_g=brush._g;material.Ambient_b=brush._b;material.Ambient_a=brush._a\n\t\t\n\t\t_d3ddev.SetMaterial material\n\t\t\n\t\tLocal alpha_test\n\t\tFor Local i=0 To 7\n\t\t\tLocal texture:TTexture=brush._texture[i]\n\t\t\tIf texture=Null Or texture._blend=BLEND_NONE \n\t\t\t\t_d3ddev.SetTexture i,Null\n\t\t\t\tContinue\n\t\t\tEndIf\n\t\t\t\n\t\t\t_d3ddev.SetTexture i,UpdateTextureRes(texture._frame[brush._textureframe[i]],texture._flags)._tex\n\n\t\t\tLocal matrix:TMatrix=TMatrix.Identity()\n\t\t\t'matrix._m[0,0]=-texture._sx\n\t\t\t'matrix._m[1,1]=texture._sy\n\t\t\tmatrix=TMatrix.YawPitchRoll(0,0,-texture._r).Multiply(matrix)\n\t\t\tmatrix=TMatrix.Scale(-texture._sx,texture._sy,1).Multiply(matrix)\n\t\t\tmatrix._m[2,0]=-texture._px\n\t\t\tmatrix._m[2,1]=-texture._py\n\t\t\t\n\t\t\t_d3ddev.SetTransform D3DTS_TEXTURE0+i,matrix.ToPtr()\n\n\t\t\t_d3ddev.SetTextureStageState i,D3DTSS_TEXTURETRANSFORMFLAGS,D3DTTFF_COUNT2\n\t\t\t_d3ddev.SetTextureStageState i,D3DTSS_ADDRESS,0\n\t\t\t\n\t\t\t_d3ddev.SetSamplerState i,D3DSAMP_MAGFILTER,D3DTEXF_LINEAR\n\t\t\t_d3ddev.SetSamplerState i,D3DSAMP_MINFILTER,D3DTEXF_LINEAR\n\t\t\t\t\t\t\n\t\t\t'_d3ddev.SetRenderState D3DRS_WRAP0+i, D3DWRAP_U|D3DWRAP_V\n\t\t\talpha_test :| (texture._flags&TEXTURE_ALPHA Or texture._flags&TEXTURE_MASKED)\n\t\t\t\t\t\n\t\t\tIf texture._flags&TEXTURE_MIPMAP\t\t\t\t\n\t\t\t\t_d3ddev.SetSamplerState i,D3DSAMP_MIPFILTER,D3DTEXF_LINEAR\n\t\t\t\t_d3ddev.SetTextureStageState i,D3DTSS_MAGFILTER,D3DTEXF_LINEAR\n\t\t\t\t_d3ddev.SetTextureStageState i,D3DTSS_MINFILTER,D3DTEXF_LINEAR\n\t\t\tElse\n\t\t\t\t_d3ddev.SetSamplerState i,D3DSAMP_MIPFILTER,D3DTEXF_NONE\n\t\t\t\t_d3ddev.SetTextureStageState i,D3DTSS_MAGFILTER,D3DTEXF_POINT\n\t\t\t\t_d3ddev.SetTextureStageState i,D3DTSS_MINFILTER,D3DTEXF_POINT\n\t\t\tEndIf\n\t\t\t\n\t\t\tIf texture._flags&TEXTURE_CLAMPU\n\t\t\t\t_d3ddev.SetSamplerState i,D3DSAMP_ADDRESSU,D3DTADDRESS_CLAMP\n\t\t\tElse\n\t\t\t\t_d3ddev.SetSamplerState i,D3DSAMP_ADDRESSU,D3DTADDRESS_WRAP\n\t\t\tEndIf\n\n\t\t\tIf texture._flags&TEXTURE_CLAMPV\n\t\t\t\t_d3ddev.SetSamplerState i,D3DSAMP_ADDRESSU,D3DTADDRESS_CLAMP\n\t\t\tElse\n\t\t\t\t_d3ddev.SetSamplerState i,D3DSAMP_ADDRESSV,D3DTADDRESS_WRAP\n\t\t\tEndIf\n\t\t\t\n\t\t\tIf texture._flags&TEXTURE_SPHEREMAP\n\t\t\t\t_d3ddev.SetTextureStageState i,D3DTSS_TEXCOORDINDEX,D3DTSS_TCI_SPHEREMAP\n\t\t\tElse\n\t\t\t\t_d3ddev.SetTextureStageState i,D3DTSS_TEXCOORDINDEX,texture._coords\n\t\t\tEndIf\n\t\t\t\n\t\t\tSelect texture._blend\n\t\t\tCase BLEND_ALPHA\n\t\t\t\t_d3ddev.SetTextureStageState i,D3DTSS_COLOROP,D3DTOP_MODULATE\n\t\t\t\t_d3ddev.SetTextureStageState i,D3DTSS_ALPHAOP,D3DTOP_MODULATE\n\t\t\tCase BLEND_MULTIPLY\n\t\t\t\t_d3ddev.SetTextureStageState i,D3DTSS_COLOROP,D3DTOP_MODULATE\n\t\t\t\t_d3ddev.SetTextureStageState i,D3DTSS_ALPHAOP,D3DTOP_MODULATE\n\t\t\tCase BLEND_ADD\n\t\t\t\t_d3ddev.SetTextureStageState i,D3DTSS_COLOROP,D3DTOP_ADD\n\t\t\t\t_d3ddev.SetTextureStageState i,D3DTSS_ALPHAOP,D3DTOP_ADD\n\t\t\tCase BLEND_DOT3\n\t\t\t\t_d3ddev.SetTextureStageState i,D3DTSS_COLOROP,D3DTOP_DOTPRODUCT3\n\t\t\t\t_d3ddev.SetTextureStageState i,D3DTSS_ALPHAOP,D3DTOP_DOTPRODUCT3\n\t\t\tCase BLEND_MULTIPLY2\n\t\t\t\t_d3ddev.SetTextureStageState i,D3DTSS_COLOROP,D3DTOP_MODULATE2X\n\t\t\t\t_d3ddev.SetTextureStageState i,D3DTSS_ALPHAOP,D3DTOP_MODULATE2X\n\t\t\tDefault\n\t\t\t\t_d3ddev.SetTextureStageState i,D3DTSS_COLOROP,D3DTOP_SELECTARG2\n\t\t\t\t_d3ddev.SetTextureStageState i,D3DTSS_ALPHAOP,D3DTOP_SELECTARG2\n\t\t\tEnd Select\t\t\t\n\t\tNext\n\t\t_d3ddev.SetRenderState D3DRS_ALPHATESTENABLE, alpha_test\n\tEnd Method\n\t\n\tMethod RenderSurface(resource:TSurfaceRes,brush:TBrush)\n\t\tLocal res:TD3D9SurfaceRes=TD3D9SurfaceRes(resource)\n\t\t\n\t\t_d3ddev.SetFVF 0\n\t\t_d3ddev.SetVertexDeclaration GetD3D9MaxB3DVertexDecl(_d3ddev)\n\t\t_d3ddev.SetStreamSource 0,res._pos,0,12\n\t\t_d3ddev.SetStreamSource 1,res._nml,0,12\n\t\t_d3ddev.SetStreamSource 2,res._clr,0,16\n\t\t_d3ddev.SetStreamSource 3,res._tex[0],0,8\n\t\t_d3ddev.SetStreamSource 4,res._tex[1],0,8\n\t\t_d3ddev.SetStreamSource 5,res._tex[2],0,8\n\t\t_d3ddev.SetStreamSource 6,res._tex[3],0,8\n\t\t_d3ddev.SetStreamSource 7,res._tex[4],0,8\n\t\t_d3ddev.SetStreamSource 8,res._tex[5],0,8\n\t\t_d3ddev.SetStreamSource 9,res._tex[6],0,8\n\t\t_d3ddev.SetStreamSource 10,res._tex[7],0,8\n\t\t_d3ddev.SetIndices res._tri\n\t\t_d3ddev.DrawIndexedPrimitive D3DPT_TRIANGLELIST,0,0,res._vertexcnt,0,res._trianglecnt\n\n\t\tReturn res._trianglecnt\n\tEnd Method\n\t\n\tMethod RenderSprite(sprite:TSprite)\t\n\t\tGlobal _data#[]=[ -1.0, 1.0,0.0, 0.0,0.0,1.0, 0.0,0.0, ..\n\t\t\t\t\t\t\t\t\t\t\t-1.0,-1.0,0.0, 0.0,0.0,1.0, 0.0,1.0, ..\n\t\t 1.0, 1.0,0.0, 0.0,0.0,1.0, 1.0,0.0, ..\n\t\t 1.0,-1.0,0.0, 0.0,0.0,1.0, 1.0,1.0 ]\n\t\t\n\t\t_d3ddev.SetVertexDeclaration Null\n\t\t_d3ddev.SetFVF D3DFVF_XYZ|D3DFVF_NORMAL|D3DFVF_TEX1\n\t\t_d3ddev.DrawPrimitiveUP D3DPT_TRIANGLESTRIP,2,_data,8*4\n\tEnd Method\n\t\n\tMethod BeginEntityRender(entity:TEntity)\n\t\t_d3ddev.SetTransform D3DTS_WORLD,entity.GetMatrix(True).ToPtr()\n\tEnd Method\n\t\n\tMethod EndEntityRender(entity:TEntity)\n\tEnd Method\n\t\n\tMethod RenderFlat(flat:TFlat)\n\t\tLocal x#,y#,z#\n\t\tflat.GetScale x,y,z,True\n\n\t\tGlobal _data#[]=[ -1.0,0.0, 1.0, 0.0,1.0,0.0, 0.0,0.0, ..\n\t\t 1.0,0.0, 1.0, 0.0,1.0,0.0, x,0.0, ..\n\t\t -1.0,0.0,-1.0, 0.0,1.0,0.0, 0.0, z, ..\n\t\t 1.0,0.0,-1.0, 0.0,1.0,0.0, x, z ]\t\t\n\t\t\n\t\t_d3ddev.SetVertexDeclaration Null\n\t\t_d3ddev.SetFVF D3DFVF_XYZ|D3DFVF_NORMAL|D3DFVF_TEX1\n\t\t_d3ddev.DrawPrimitiveUP D3DPT_TRIANGLESTRIP,2,_data,8*4\n\tEnd Method\n\t\n\tMethod RenderTerrain(terrain:TTerrain)\n\tEnd Method\n\t\n\tMethod RenderBSPTree(tree:TBSPTree)\n\t\tLocal node:TBSPNode=tree.Node\n\t\tIf node=Null Return\n\t\tLocal triangles\n\t\ttriangles:+RenderBSPTree(node.In)\n\t\t\n\t\t_d3ddev.SetVertexDeclaration Null\n\t\t_d3ddev.SetFVF D3DFVF_XYZ|D3DFVF_NORMAL|D3DFVF_TEX1\n\t\t\t\t\n\t\tFor Local poly:TBSPPolygon=EachIn node.On\n\t\t\tLocal ptA:TVector=poly.Point[0],v0\n\t\t\tLocal trianglecnt=poly.Count()-2\n\t\t\tLocal data#[trianglecnt*24],dataptr:Float Ptr=data\n\t\t\tFor Local i=0 To trianglecnt-1\n\t\t\t\tLocal ptB:TVector=poly.Point[i+1],ptC:TVector=poly.Point[i+2]\n\t\t\t\tdata[i*24+00]=ptA.x;data[i*24+01]=ptA.y;data[i*24+02]=ptA.z;data[i*24+03]=poly.Plane.x;data[i*24+04]=poly.Plane.y;\tdata[i*24+05]=poly.Plane.z;data[i*24+06]=0.0;data[i*24+07]=0.0\n\t\t\t\tdata[i*24+08]=ptB.x;data[i*24+09]=ptB.y;data[i*24+10]=ptB.z;data[i*24+11]=poly.Plane.x;data[i*24+12]=poly.Plane.y;\tdata[i*24+13]=poly.Plane.z;data[i*24+14]=0.0;data[i*24+15]=0.0\n\t\t\t\tdata[i*24+16]=ptC.x;data[i*24+17]=ptC.y;data[i*24+18]=ptC.z;data[i*24+19]=poly.Plane.x;data[i*24+20]=poly.Plane.y;data[i*24+21]=poly.Plane.z;data[i*24+22]=0.0;data[i*24+23]=0.0\n\t\t\tNext\n\t\t\t_d3ddev.DrawPrimitiveUP D3DPT_TRIANGLELIST,trianglecnt,data,8*4\n\t\t\ttriangles:+trianglecnt\n\t\tNext\n\t\t\t\t\n\t\ttriangles:+RenderBSPTree(node.Out)\n\t\tReturn triangles\n\tEnd Method\n\t\n\tMethod UpdateTextureRes:TD3D9TextureRes(frame:TTextureFrame,flags)\n\t\tLocal res:TD3D9TextureRes=TD3D9TextureRes(frame._res)\n\t\tIf res And frame._updateres=False Return res\n\n\t\tIf res=Null res=New TD3D9TextureRes\n\t\tframe._res=res\n\t\t\n\t\tLocal pixmap:TPixmap=frame._pixmap\n\t\tLocal tex_width=Pow2Size(pixmap.width),tex_height=Pow2Size(pixmap.height)\n\t\tpixmap=ConvertPixmap(ResizePixmap(pixmap,tex_width,tex_height),PF_BGRA8888)\n\t\tIf res._tex=Null Assert _d3ddev.CreateTexture(tex_width,tex_height,(flags & TEXTURE_MIPMAP)=0,D3DUSAGE_AUTOGENMIPMAP,D3DFMT_A8R8G8B8,D3DPOOL_MANAGED,res._tex,Null)=D3D_OK\n\t\t\n\t\tLocal rect:D3DLOCKED_RECT=New D3DLOCKED_RECT \n\t\tres._tex.LockRect 0,rect,Null,0\n\t\tMemCopy rect.pBits,pixmap.pixels,pixmap.width*pixmap.height*4\n\t\tres._tex.UnlockRect 0\n\t\t\n\t\tframe._updateres=False\n\t\t\t\t\n\t\tReturn res\n\tEnd Method\n\t\n\tMethod UpdateSurfaceRes:TD3D9SurfaceRes(surface:TSurface)\n\t\tLocal res:TD3D9SurfaceRes=TD3D9SurfaceRes(surface._res)\n\t\tIf res=Null res=New TD3D9SurfaceRes;surface._reset=-1\n\t\t\n\t\tIf surface._reset=0 Return res\t\t\n\t\tIf surface._reset=-1 surface._reset=1|2|4|8|16|32|64|128|256\n\n\t\tIf surface._reset&1 And surface._vertexpos UploadVertexData res._pos,surface._vertexpos\n\t\tIf surface._reset&2 And surface._vertexnml UploadVertexData res._nml,surface._vertexnml\n\t\tIf surface._reset&4 And surface._vertexclr UploadVertexData res._clr,surface._vertexclr\n\t\tIf surface._reset&8 And surface._triangle\n\t\t\tIf res._tri=Null _d3ddev.CreateIndexBuffer(surface._triangle.length*4,0,D3DFMT_INDEX32,D3DPOOL_MANAGED,res._tri,Null)\n\t\t\tLocal dataptr:Byte Ptr\n\t\t\tAssert res._tri.Lock(0,0,dataptr,0)=D3D_OK,\"Failed to lock index buffer.\"\n\t\t\tMemCopy dataptr,surface._triangle,surface._triangle.length*4\t\t\n\t\t\tres._tri.Unlock()\n\t\tEndIf\n\t\t\n\t\tFor Local i=0 To surface._vertextex.length-1\n\t\t\tIf surface._reset&Int(2^(4+i)) UploadVertexData res._tex[i],surface._vertextex[i]\n\t\tNext\n\t\t\n\t\tres._trianglecnt=surface._trianglecnt\n\t\tres._vertexcnt=surface._vertexcnt\n\t\t\n\t\tsurface._reset=0\n\t\tsurface._res=res\n\t\t\n\t\tReturn res\n\tEnd Method\n\n\tMethod MergeSurfaceRes:TSurfaceRes(base:TSurface,animation:TSurface,data)\n\t\tIf animation=Null Return UpdateSurfaceRes(base)\n\t\tLocal base_res:TD3D9SurfaceRes=UpdateSurfaceRes(base)\n\t\tLocal anim_res:TD3D9SurfaceRes=UpdateSurfaceRes(animation)\n\t\tLocal res:TD3D9SurfaceRes=base_res.Copy()\n\t\tres._pos=anim_res._pos\n\t\tReturn res\n\tEnd Method\n\t\n\tMethod UploadVertexData(buffer:IDirect3DVertexBuffer9 Var,data#[])\n\t\tIf buffer=Null _d3ddev.CreateVertexBuffer(data.length*4,0,0,D3DPOOL_MANAGED,buffer,Null)\n\t\tLocal dataptr:Byte Ptr\n\t\tAssert buffer.Lock(0,0,dataptr,0)=D3D_OK,\"Failed to lock vertex buffer.\"\n\t\tMemCopy dataptr,data,data.length*4\t\t\n\t\tbuffer.Unlock()\n\tEnd Method\n\t\nEnd Type\n\nType TD3D9TextureRes Extends TTextureRes\n\tField _tex:IDirect3DTexture9\nEnd Type\n\nType TD3D9SurfaceRes Extends TSurfaceRes\n\tField _pos:IDirect3DVertexBuffer9\n\tField _nml:IDirect3DVertexBuffer9\n\tField _clr:IDirect3DVertexBuffer9\n\tField _tri:IDirect3DIndexBuffer9\n\tField _tex:IDirect3DVertexBuffer9[8]\n\t\n\tMethod Copy:TD3D9SurfaceRes()\n\t\tLocal res:TD3D9SurfaceRes=New TD3D9SurfaceRes\n\t\tres._vertexcnt=_vertexcnt;res._trianglecnt=_trianglecnt\n\t\tres._pos=_pos;res._nml=_nml;res._clr=_clr;res._tri=_tri;\n\t\tFor Local i=0 To 7\n\t\t\tres._tex[i]=_tex[i]\n\t\tNext\n\t\tReturn res\n\tEnd Method\nEnd Type\n\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction D3D9MaxB3DDriver:TD3D9MaxB3DDriver()\n\tIf D3D9Max2DExDriver()\n\t\tGlobal driver:TD3D9MaxB3DDriver=New TD3D9MaxB3DDriver\n\t\tdriver._parent=D3D9Max2DExDriver()\n\t\tReturn driver\n\tEnd If\nEnd Function\n\nRem\n\tbbdoc: Utility function that sets the MaxB3D D3D9 driver and calls Graphics.\nEnd Rem\nFunction D3D9Graphics3D:TGraphics(width,height,depth=0,hertz=0,flags=0)\n\tSetGraphicsDriver D3D9MaxB3DDriver(),GRAPHICS_BACKBUFFER|GRAPHICS_DEPTHBUFFER\n\tReturn Graphics(width,height,depth,hertz,flags)\nEnd Function\n\nLocal driver:TD3D9MaxB3DDriver=D3D9MaxB3DDriver()\nIf driver SetGraphicsDriver driver,GRAPHICS_BACKBUFFER|GRAPHICS_DEPTHBUFFER\n\n?\n","old_contents":"\nStrict\n\nRem\n\tbbdoc: Direct3D 9 renderer for MaxB3D\nEnd Rem\nModule MaxB3D.D3D9Driver\nModuleInfo \"Author: Kevin Primm\"\nModuleInfo \"License: MIT\"\n\nImport MaxB3D.Core\nImport Prime.D3D9Max2DEx\nImport Prime.DirectXEx\n\n?Win32\n\nImport \"d3d9.cpp\"\n\nPrivate \n\nExtern \"C\"\n\tFunction maxb3dD3D9VertexElements:Byte Ptr()'=\"_maxb3dD3D9VertexElements@0\"\nEnd Extern\n\nFunction GetD3D9MaxB3DVertexDecl:IDirect3DVertexDeclaration9(d3ddev:IDirect3DDevice9)\n\tGlobal decl:IDirect3DVertexDeclaration9,dev:IDirect3DDevice9\n\tIf decl=Null Or dev<>d3ddev\n\t\tAssert d3ddev.CreateVertexDeclaration(maxb3dD3D9VertexElements(),decl)=D3D_OK,\"Failed to create vertex declaration.\"\n\t\tdev=d3ddev\n\tEndIf\n\tReturn decl\nEnd Function\n\nFunction Pow2Size( n )\n\tLocal t=1\n\tWhile tNull\n\t\t\t_d3ddev=TD3D9Graphics(TMax2DGraphics(g)._graphics).GetDirect3DDevice()\n\t\t\tEndMax2D\n\t\tEndIf\n\tEnd Method\n\t\t\n\tMethod MakeBuffer:TBuffer(src:Object,width,height,flags)\n\t\tReturn TMax2DExDriver(_parent).MakeBuffer(src,width,height,flags)\n\tEnd Method\n\t\n\tMethod GetCaps:TCaps()\n\t\tLocal caps:TCaps=New TCaps\n\t\tReturn caps\n\tEnd Method\n\t\n\tMethod Abbr$()\n\t\tReturn \"d3d9\"\n\tEnd Method\n\t\n\tMethod SetMax2D(enable)\n\t\tIf enable\n\t\t\tGlobal identity:TMatrix=TMatrix.Identity()\n\t\t\tLocal width=GraphicsWidth(),height=GraphicsHeight()\n\t\t\tLocal matrix#[]=[..\n\t\t\t2.0\/width,0.0,0.0,0.0,..\n\t\t\t 0.0,-2.0\/height,0.0,0.0,..\n\t\t\t 0.0,0.0,1.0,0.0,..\n\t\t\t -1-(1.0\/width),1+(1.0\/height),1.0,1.0]\n\t\t\t\n\t\t\tSetBlend -1\n\t\t\tSetBlend SOLIDBLEND\n\t\t\t\n\t\t\t_d3ddev.SetTransform D3DTS_PROJECTION,matrix\n\t\t\t_d3ddev.SetTransform D3DTS_WORLD,identity.ToPtr()\n\t\t\t_d3ddev.SetTransform D3DTS_VIEW,identity.ToPtr()\n\t\t\t_d3ddev.SetTransform D3DTS_TEXTURE0,identity.ToPtr()\n\t\t\t\n\t\t\t_d3ddev.SetVertexDeclaration Null\n\t\t\t_d3ddev.SetIndices Null\n\t\t\t_d3ddev.SetFVF D3DFVF_XYZ|D3DFVF_DIFFUSE|D3DFVF_TEX1\n\t\t\t\n\t\t\t_d3ddev.SetRenderState D3DRS_LIGHTING,False\n\t\t\t_d3ddev.SetRenderState D3DRS_ZENABLE,False\n\t\t\t_d3ddev.SetRenderState D3DRS_SCISSORTESTENABLE,_viewporton\t\t\n\t\t\t\n\t\t\t_d3ddev.SetRenderState D3DRS_ALPHATESTENABLE,True\n\t\t\t\n\t\t\tFor Local i=1 To 7\n\t\t\t\t_d3ddev.SetTexture i,Null\n\t\t\tNext\n\t\t\t\t\n\t\t\t_d3ddev.SetFVF D3DFVF_XYZ|D3DFVF_DIFFUSE|D3DFVF_TEX1\n\t\t\t\n\t\t\t_d3ddev.SetTextureStageState 0,D3DTSS_COLOROP,D3DTOP_MODULATE\n\t\t\t_d3ddev.SetTextureStageState 0,D3DTSS_ALPHAOP,D3DTOP_MODULATE\n\t\t\t\n\t\t\t_d3ddev.SetTextureStageState 0,D3DTSS_ADDRESS,D3DTADDRESS_CLAMP\n\t\t\n\t\t\t_d3ddev.SetTextureStageState 0,D3DTSS_MAGFILTER,D3DTFG_POINT\n\t\t\t_d3ddev.SetTextureStageState 0,D3DTSS_MINFILTER,D3DTFN_POINT\n\t\t\t_d3ddev.SetTextureStageState 0,D3DTSS_MIPFILTER,D3DTFP_POINT\n\t\t\t\n\t\t\t_d3ddev.SetRenderState D3DRS_FOGENABLE,False\n\t\t\t\t\t\t\t\t\n\t\t\t_d3ddev.SetRenderState D3DRS_CULLMODE,D3DCULL_NONE\n\t\t\t_d3ddev.SetRenderState D3DRS_FILLMODE,D3DFILL_SOLID\n\t\tElse\n\t\t\t_d3ddev.SetRenderState D3DRS_ZENABLE,True\n\t\t\t_d3ddev.SetRenderState D3DRS_ZWRITEENABLE,True\n\t\n\t\t\t_d3ddev.GetRenderState D3DRS_SCISSORTESTENABLE,_viewporton\n\t\t\t_d3ddev.SetRenderState D3DRS_SCISSORTESTENABLE,True\n\t\t\t\n\t\t\t_d3ddev.SetRenderState D3DRS_LIGHTING,True\n\t\t\t_d3ddev.SetRenderState D3DRS_NORMALIZENORMALS,True\n\t\t\t\n\t\t\t_d3ddev.SetRenderState D3DRS_COLORVERTEX, True\n\t\t\t\t\t\t\n\t\t\t'_d3ddev.SetRenderState D3DRS_ALPHAREF, 1\n\t\t\t'_d3ddev.SetRenderState D3DRS_ALPHAFUNC, D3DCMP_GREATEREQUAL\n\t\tEndIf\t\n\tEnd Method\n\t\n\tMethod SetCamera(camera:TCamera,config:TWorldConfig)\n\t\t_d3ddev.SetRenderState D3DRS_DITHERENABLE, config.Dither\n\t\t\n\t\tLocal clearflags\t\t\n\t\tIf camera._clsmode&CLSMODE_COLOR clearflags:|D3DCLEAR_TARGET\n\t\tIf camera._clsmode&CLSMODE_DEPTH clearflags:|D3DCLEAR_ZBUFFER\n\n\t\tLocal viewport[]=[camera._viewx,camera._viewy,camera._viewwidth-camera._viewx,camera._viewheight-camera._viewy]\n\t\t_d3ddev.SetScissorRect viewport\n\t\t_d3ddev.Clear(1,viewport,clearflags,D3DCOLOR_XRGB(camera._brush._r*255,camera._brush._g*255,camera._brush._b*255),1.0,0)\n\t\t\t\t\n\t\tSelect camera._fogmode\n\t\tCase FOGMODE_LINEAR\n\t\t\t_d3ddev.SetRenderState D3DRS_FOGENABLE,True\n\t\t\t_d3ddev.SetRenderState D3DRS_FOGSTART,Int(Varptr camera._fognear)\n\t\t\t_d3ddev.SetRenderState D3DRS_FOGEND,Int(Varptr camera._fogfar)\n\t\tDefault\n\t\t\t_d3ddev.SetRenderState D3DRS_FOGENABLE,False\n\t\tEnd Select\n\t\t\n\t\tLocal oldnear# = camera._near ' Ugh, hack. Need to investigate cause.\n\t\tcamera._near :- 0.396250010 \n\t\tcamera.UpdateMatrices()\n\t\tcamera._near = oldnear\n\t\t\n\t\t_d3ddev.SetTransform D3DTS_PROJECTION,camera._projection.ToPtr() \n\t\t_d3ddev.SetTransform D3DTS_VIEW,camera._modelview.ToPtr()\n\tEnd Method\n\t\n\tMethod SetLight(light:TLight,index)\n\t\tIf light=Null \n\t\t\t_d3ddev.LightEnable index,False\n\t\t\tReturn\n\t\tEndIf\n\t\t\n\t\tLocal brush:TBrush=light._brush\n\n\t\tGlobal d3dlight:D3DLIGHT9=New D3DLIGHT9\n\t\td3dlight.Type_=D3DLIGHT_DIRECTIONAL \n\t\td3dlight.Diffuse_r=brush._r;d3dlight.Diffuse_g=brush._g;d3dlight.Diffuse_b=brush._b;d3dlight.Diffuse_a=brush._a\n\t\t'd3dlight.Ambient_r=WorldConfig.AmbientRed\/255.0;d3dlight.Ambient_g=WorldConfig.AmbientGreen\/255.0;d3dlight.Ambient_b=WorldConfig.AmbientBlue\/255.0;d3dlight.Ambient_a=1.0\n\t\t\n\t\td3dlight.Direction_x=0.0;d3dlight.Direction_y=0.0;d3dlight.Direction_z=1.0\n\t\t\t\t\n\t\tLocal matrix:TMatrix=light._matrix\n\t\tmatrix.TransformVec3 d3dlight.Direction_x,d3dlight.Direction_y,d3dlight.Direction_z\n\t\tmatrix.GetPosition d3dlight.Position_x,d3dlight.Position_y,d3dlight.Position_z\t\t\n\t\t\n\t\td3dlight.Range=light._range\t\t\n\t\t\n\t\t_d3ddev.SetLight index,d3dlight\n\t\t_d3ddev.LightEnable index,True\n\tEnd Method\n\t\n\tMethod SetBrush(brush:TBrush,hasalpha,config:TWorldConfig)\t\t\n\t\t_d3ddev.SetRenderState D3DRS_ALPHABLENDENABLE,hasalpha\n\t\t_d3ddev.SetRenderState D3DRS_ZWRITEENABLE,Not hasalpha\n\t\t\n\t\tSelect brush._blend\n\t\tCase BLEND_NONE, BLEND_ALPHA\n\t\t\t_d3ddev.SetRenderState D3DRS_SRCBLEND,D3DBLEND_SRCALPHA\n\t\t\t_d3ddev.SetRenderState D3DRS_DESTBLEND,D3DBLEND_INVSRCALPHA\n\t\tCase BLEND_MULTIPLY\n\t\t\t_d3ddev.SetRenderState D3DRS_SRCBLEND,D3DBLEND_DESTCOLOR\n\t\t\t_d3ddev.SetRenderState D3DRS_DESTBLEND,D3DBLEND_ZERO\n\t\tCase BLEND_ADD\n\t\t\t_d3ddev.SetRenderState D3DRS_SRCBLEND,D3DBLEND_SRCALPHA\n\t\t\t_d3ddev.SetRenderState D3DRS_DESTBLEND,D3DBLEND_ONE\n\t\tEnd Select\n\n\t\tIf brush._fx&FX_FULLBRIGHT\n\t\t\t_d3ddev.SetRenderState D3DRS_AMBIENT,D3DCOLOR_RGB(255,255,255)\n\t\tElse\n\t\t\t_d3ddev.SetRenderState D3DRS_AMBIENT,D3DCOLOR_RGB(config.AmbientRed,config.AmbientGreen,config.AmbientBlue)\n\t\tEndIf\n\t\t\n\t\tIf brush._fx&FX_VERTEXCOLOR\n\t\t\t_d3ddev.SetRenderState D3DRS_DIFFUSEMATERIALSOURCE,D3DMCS_COLOR1\n\t\t\t_d3ddev.SetRenderState D3DRS_AMBIENTMATERIALSOURCE,D3DMCS_COLOR1\n\t\tElse\n\t\t\t_d3ddev.SetRenderState D3DRS_DIFFUSEMATERIALSOURCE,D3DMCS_MATERIAL\n\t\t\t_d3ddev.SetRenderState D3DRS_AMBIENTMATERIALSOURCE,D3DMCS_MATERIAL \n\t\tEndIf\n\t\t\n\t\tIf brush._fx&FX_FLATSHADED\n\t\t\t_d3ddev.SetRenderState D3DRS_SHADEMODE, D3DSHADE_FLAT\n\t\tElse\n\t\t\t_d3ddev.SetRenderState D3DRS_SHADEMODE, D3DSHADE_GOURAUD\n\t\tEndIf\n\n\t\tIf brush._fx&FX_NOCULLING\n\t\t\t_d3ddev.SetRenderState D3DRS_CULLMODE,D3DCULL_NONE\n\t\tElse\n\t\t\t_d3ddev.SetRenderState D3DRS_CULLMODE,D3DCULL_CCW\n\t\tEndIf\n\t\t\n\t\tIf brush._fx&FX_WIREFRAME Or config.Wireframe\n\t\t\t_d3ddev.SetRenderState D3DRS_FILLMODE,D3DFILL_WIREFRAME\n\t\tElse\n\t\t\t_d3ddev.SetRenderState D3DRS_FILLMODE,D3DFILL_SOLID\n\t\tEndIf\n\t\t\n\t\tLocal material:D3DMATERIAL9 = New D3DMATERIAL9\n\t\tmaterial.Diffuse_r=brush._r;material.Diffuse_g=brush._g;material.Diffuse_b=brush._b;material.Diffuse_a=brush._a\n\t\tmaterial.Ambient_r=brush._r;material.Ambient_g=brush._g;material.Ambient_b=brush._b;material.Ambient_a=brush._a\n\t\t\n\t\t_d3ddev.SetMaterial material\n\t\t\n\t\tLocal alpha_test\n\t\tFor Local i=0 To 7\n\t\t\tLocal texture:TTexture=brush._texture[i]\n\t\t\tIf texture=Null Or texture._blend=BLEND_NONE \n\t\t\t\t_d3ddev.SetTexture i,Null\n\t\t\t\tContinue\n\t\t\tEndIf\n\t\t\t\n\t\t\t_d3ddev.SetTexture i,UpdateTextureRes(texture._frame[brush._textureframe[i]],texture._flags)._tex\n\n\t\t\tLocal matrix:TMatrix=TMatrix.Identity()\n\t\t\t'matrix._m[0,0]=-texture._sx\n\t\t\t'matrix._m[1,1]=texture._sy\n\t\t\tmatrix=TMatrix.YawPitchRoll(0,0,-texture._r).Multiply(matrix)\n\t\t\tmatrix=TMatrix.Scale(-texture._sx,texture._sy,1).Multiply(matrix)\n\t\t\tmatrix._m[2,0]=-texture._px\n\t\t\tmatrix._m[2,1]=-texture._py\n\t\t\t\n\t\t\t_d3ddev.SetTransform D3DTS_TEXTURE0+i,matrix.ToPtr()\n\n\t\t\t_d3ddev.SetTextureStageState i,D3DTSS_TEXTURETRANSFORMFLAGS,D3DTTFF_COUNT2\n\t\t\t_d3ddev.SetTextureStageState i,D3DTSS_ADDRESS,0\n\t\t\t\n\t\t\t_d3ddev.SetSamplerState i,D3DSAMP_MAGFILTER,D3DTEXF_LINEAR\n\t\t\t_d3ddev.SetSamplerState i,D3DSAMP_MINFILTER,D3DTEXF_LINEAR\n\t\t\t\t\t\t\n\t\t\t'_d3ddev.SetRenderState D3DRS_WRAP0+i, D3DWRAP_U|D3DWRAP_V\n\t\t\talpha_test :| (texture._flags&TEXTURE_ALPHA Or texture._flags&TEXTURE_MASKED)\n\t\t\t\t\t\n\t\t\tIf texture._flags&TEXTURE_MIPMAP\t\t\t\t\n\t\t\t\t_d3ddev.SetSamplerState i,D3DSAMP_MIPFILTER,D3DTEXF_LINEAR\n\t\t\t\t_d3ddev.SetTextureStageState i,D3DTSS_MAGFILTER,D3DTEXF_LINEAR\n\t\t\t\t_d3ddev.SetTextureStageState i,D3DTSS_MINFILTER,D3DTEXF_LINEAR\n\t\t\tElse\n\t\t\t\t_d3ddev.SetSamplerState i,D3DSAMP_MIPFILTER,D3DTEXF_NONE\n\t\t\t\t_d3ddev.SetTextureStageState i,D3DTSS_MAGFILTER,D3DTEXF_POINT\n\t\t\t\t_d3ddev.SetTextureStageState i,D3DTSS_MINFILTER,D3DTEXF_POINT\n\t\t\tEndIf\n\t\t\t\n\t\t\tIf texture._flags&TEXTURE_CLAMPU\n\t\t\t\t_d3ddev.SetSamplerState i,D3DSAMP_ADDRESSU,D3DTADDRESS_CLAMP\n\t\t\tElse\n\t\t\t\t_d3ddev.SetSamplerState i,D3DSAMP_ADDRESSU,D3DTADDRESS_WRAP\n\t\t\tEndIf\n\n\t\t\tIf texture._flags&TEXTURE_CLAMPV\n\t\t\t\t_d3ddev.SetSamplerState i,D3DSAMP_ADDRESSU,D3DTADDRESS_CLAMP\n\t\t\tElse\n\t\t\t\t_d3ddev.SetSamplerState i,D3DSAMP_ADDRESSV,D3DTADDRESS_WRAP\n\t\t\tEndIf\n\t\t\t\n\t\t\tIf texture._flags&TEXTURE_SPHEREMAP\n\t\t\t\t_d3ddev.SetTextureStageState i,D3DTSS_TEXCOORDINDEX,D3DTSS_TCI_SPHEREMAP\n\t\t\tElse\n\t\t\t\t_d3ddev.SetTextureStageState i,D3DTSS_TEXCOORDINDEX,texture._coords\n\t\t\tEndIf\n\t\t\t\n\t\t\tSelect texture._blend\n\t\t\tCase BLEND_ALPHA\n\t\t\t\t_d3ddev.SetTextureStageState i,D3DTSS_COLOROP,D3DTOP_MODULATE\n\t\t\t\t_d3ddev.SetTextureStageState i,D3DTSS_ALPHAOP,D3DTOP_MODULATE\n\t\t\tCase BLEND_MULTIPLY\n\t\t\t\t_d3ddev.SetTextureStageState i,D3DTSS_COLOROP,D3DTOP_MODULATE\n\t\t\t\t_d3ddev.SetTextureStageState i,D3DTSS_ALPHAOP,D3DTOP_MODULATE\n\t\t\tCase BLEND_ADD\n\t\t\t\t_d3ddev.SetTextureStageState i,D3DTSS_COLOROP,D3DTOP_ADD\n\t\t\t\t_d3ddev.SetTextureStageState i,D3DTSS_ALPHAOP,D3DTOP_ADD\n\t\t\tCase BLEND_DOT3\n\t\t\t\t_d3ddev.SetTextureStageState i,D3DTSS_COLOROP,D3DTOP_DOTPRODUCT3\n\t\t\t\t_d3ddev.SetTextureStageState i,D3DTSS_ALPHAOP,D3DTOP_DOTPRODUCT3\n\t\t\tCase BLEND_MULTIPLY2\n\t\t\t\t_d3ddev.SetTextureStageState i,D3DTSS_COLOROP,D3DTOP_MODULATE2X\n\t\t\t\t_d3ddev.SetTextureStageState i,D3DTSS_ALPHAOP,D3DTOP_MODULATE2X\n\t\t\tDefault\n\t\t\t\t_d3ddev.SetTextureStageState i,D3DTSS_COLOROP,D3DTOP_SELECTARG2\n\t\t\t\t_d3ddev.SetTextureStageState i,D3DTSS_ALPHAOP,D3DTOP_SELECTARG2\n\t\t\tEnd Select\t\t\t\n\t\tNext\n\t\t_d3ddev.SetRenderState D3DRS_ALPHATESTENABLE, alpha_test\n\tEnd Method\n\t\n\tMethod RenderSurface(resource:TSurfaceRes,brush:TBrush)\n\t\tLocal res:TD3D9SurfaceRes=TD3D9SurfaceRes(resource)\n\t\t\n\t\t_d3ddev.SetFVF 0\n\t\t_d3ddev.SetVertexDeclaration GetD3D9MaxB3DVertexDecl(_d3ddev)\n\t\t_d3ddev.SetStreamSource 0,res._pos,0,12\n\t\t_d3ddev.SetStreamSource 1,res._nml,0,12\n\t\t_d3ddev.SetStreamSource 2,res._clr,0,16\n\t\t_d3ddev.SetStreamSource 3,res._tex[0],0,8\n\t\t_d3ddev.SetStreamSource 4,res._tex[1],0,8\n\t\t_d3ddev.SetStreamSource 5,res._tex[2],0,8\n\t\t_d3ddev.SetStreamSource 6,res._tex[3],0,8\n\t\t_d3ddev.SetStreamSource 7,res._tex[4],0,8\n\t\t_d3ddev.SetStreamSource 8,res._tex[5],0,8\n\t\t_d3ddev.SetStreamSource 9,res._tex[6],0,8\n\t\t_d3ddev.SetStreamSource 10,res._tex[7],0,8\n\t\t_d3ddev.SetIndices res._tri\n\t\t_d3ddev.DrawIndexedPrimitive D3DPT_TRIANGLELIST,0,0,res._vertexcnt,0,res._trianglecnt\n\n\t\tReturn res._trianglecnt\n\tEnd Method\n\t\n\tMethod RenderSprite(sprite:TSprite)\t\n\t\tGlobal _data#[]=[ -1.0, 1.0,0.0, 0.0,0.0,1.0, 0.0,0.0, ..\n\t\t 1.0, 1.0,0.0, 0.0,0.0,1.0, 1.0,0.0, ..\n\t\t -1.0,-1.0,0.0, 0.0,0.0,1.0, 0.0,1.0, ..\n\t\t 1.0,-1.0,0.0, 0.0,0.0,1.0, 1.0,1.0 ]\n\t\t\n\t\t_d3ddev.SetVertexDeclaration Null\n\t\t_d3ddev.SetFVF D3DFVF_XYZ|D3DFVF_NORMAL|D3DFVF_TEX1\n\t\t_d3ddev.DrawPrimitiveUP D3DPT_TRIANGLESTRIP,2,_data,8*4\n\tEnd Method\n\t\n\tMethod BeginEntityRender(entity:TEntity)\n\t\t_d3ddev.SetTransform D3DTS_WORLD,entity.GetMatrix(True).ToPtr()\n\tEnd Method\n\t\n\tMethod EndEntityRender(entity:TEntity)\n\tEnd Method\n\t\n\tMethod RenderFlat(flat:TFlat)\n\t\tLocal x#,y#,z#\n\t\tflat.GetScale x,y,z,True\n\n\t\tGlobal _data#[]=[ -1.0,0.0, 1.0, 0.0,1.0,0.0, 0.0,0.0, ..\n\t\t 1.0,0.0, 1.0, 0.0,1.0,0.0, x,0.0, ..\n\t\t -1.0,0.0,-1.0, 0.0,1.0,0.0, 0.0, z, ..\n\t\t 1.0,0.0,-1.0, 0.0,1.0,0.0, x, z ]\t\t\n\t\t\n\t\t_d3ddev.SetVertexDeclaration Null\n\t\t_d3ddev.SetFVF D3DFVF_XYZ|D3DFVF_NORMAL|D3DFVF_TEX1\n\t\t_d3ddev.DrawPrimitiveUP D3DPT_TRIANGLESTRIP,2,_data,8*4\n\tEnd Method\n\t\n\tMethod RenderTerrain(terrain:TTerrain)\n\tEnd Method\n\t\n\tMethod RenderBSPTree(tree:TBSPTree)\n\t\tLocal node:TBSPNode=tree.Node\n\t\tIf node=Null Return\n\t\tLocal triangles\n\t\ttriangles:+RenderBSPTree(node.In)\n\t\t\n\t\t_d3ddev.SetVertexDeclaration Null\n\t\t_d3ddev.SetFVF D3DFVF_XYZ|D3DFVF_NORMAL|D3DFVF_TEX1\n\t\t\t\t\n\t\tFor Local poly:TBSPPolygon=EachIn node.On\n\t\t\tLocal ptA:TVector=poly.Point[0],v0\n\t\t\tLocal trianglecnt=poly.Count()-2\n\t\t\tLocal data#[trianglecnt*24],dataptr:Float Ptr=data\n\t\t\tFor Local i=0 To trianglecnt-1\n\t\t\t\tLocal ptB:TVector=poly.Point[i+1],ptC:TVector=poly.Point[i+2]\n\t\t\t\tdata[i*24+00]=ptA.x;data[i*24+01]=ptA.y;data[i*24+02]=ptA.z;data[i*24+03]=poly.Plane.x;data[i*24+04]=poly.Plane.y;\tdata[i*24+05]=poly.Plane.z;data[i*24+06]=0.0;data[i*24+07]=0.0\n\t\t\t\tdata[i*24+08]=ptB.x;data[i*24+09]=ptB.y;data[i*24+10]=ptB.z;data[i*24+11]=poly.Plane.x;data[i*24+12]=poly.Plane.y;\tdata[i*24+13]=poly.Plane.z;data[i*24+14]=0.0;data[i*24+15]=0.0\n\t\t\t\tdata[i*24+16]=ptC.x;data[i*24+17]=ptC.y;data[i*24+18]=ptC.z;data[i*24+19]=poly.Plane.x;data[i*24+20]=poly.Plane.y;data[i*24+21]=poly.Plane.z;data[i*24+22]=0.0;data[i*24+23]=0.0\n\t\t\tNext\n\t\t\t_d3ddev.DrawPrimitiveUP D3DPT_TRIANGLELIST,trianglecnt,data,8*4\n\t\t\ttriangles:+trianglecnt\n\t\tNext\n\t\t\t\t\n\t\ttriangles:+RenderBSPTree(node.Out)\n\t\tReturn triangles\n\tEnd Method\n\t\n\tMethod UpdateTextureRes:TD3D9TextureRes(frame:TTextureFrame,flags)\n\t\tLocal res:TD3D9TextureRes=TD3D9TextureRes(frame._res)\n\t\tIf res And frame._updateres=False Return res\n\n\t\tIf res=Null res=New TD3D9TextureRes\n\t\tframe._res=res\n\t\t\n\t\tLocal pixmap:TPixmap=frame._pixmap\n\t\tLocal tex_width=Pow2Size(pixmap.width),tex_height=Pow2Size(pixmap.height)\n\t\tpixmap=ConvertPixmap(ResizePixmap(pixmap,tex_width,tex_height),PF_BGRA8888)\n\t\tIf res._tex=Null Assert _d3ddev.CreateTexture(tex_width,tex_height,(flags & TEXTURE_MIPMAP)=0,D3DUSAGE_AUTOGENMIPMAP,D3DFMT_A8R8G8B8,D3DPOOL_MANAGED,res._tex,Null)=D3D_OK\n\t\t\n\t\tLocal rect:D3DLOCKED_RECT=New D3DLOCKED_RECT \n\t\tres._tex.LockRect 0,rect,Null,0\n\t\tMemCopy rect.pBits,pixmap.pixels,pixmap.width*pixmap.height*4\n\t\tres._tex.UnlockRect 0\n\t\t\n\t\tframe._updateres=False\n\t\t\t\t\n\t\tReturn res\n\tEnd Method\n\t\n\tMethod UpdateSurfaceRes:TD3D9SurfaceRes(surface:TSurface)\n\t\tLocal res:TD3D9SurfaceRes=TD3D9SurfaceRes(surface._res)\n\t\tIf res=Null res=New TD3D9SurfaceRes;surface._reset=-1\n\t\t\n\t\tIf surface._reset=0 Return res\t\t\n\t\tIf surface._reset=-1 surface._reset=1|2|4|8|16|32|64|128|256\n\n\t\tIf surface._reset&1 And surface._vertexpos UploadVertexData res._pos,surface._vertexpos\n\t\tIf surface._reset&2 And surface._vertexnml UploadVertexData res._nml,surface._vertexnml\n\t\tIf surface._reset&4 And surface._vertexclr UploadVertexData res._clr,surface._vertexclr\n\t\tIf surface._reset&8 And surface._triangle\n\t\t\tIf res._tri=Null _d3ddev.CreateIndexBuffer(surface._triangle.length*4,0,D3DFMT_INDEX32,D3DPOOL_MANAGED,res._tri,Null)\n\t\t\tLocal dataptr:Byte Ptr\n\t\t\tAssert res._tri.Lock(0,0,dataptr,0)=D3D_OK,\"Failed to lock index buffer.\"\n\t\t\tMemCopy dataptr,surface._triangle,surface._triangle.length*4\t\t\n\t\t\tres._tri.Unlock()\n\t\tEndIf\n\t\t\n\t\tFor Local i=0 To surface._vertextex.length-1\n\t\t\tIf surface._reset&Int(2^(4+i)) UploadVertexData res._tex[i],surface._vertextex[i]\n\t\tNext\n\t\t\n\t\tres._trianglecnt=surface._trianglecnt\n\t\tres._vertexcnt=surface._vertexcnt\n\t\t\n\t\tsurface._reset=0\n\t\tsurface._res=res\n\t\t\n\t\tReturn res\n\tEnd Method\n\n\tMethod MergeSurfaceRes:TSurfaceRes(base:TSurface,animation:TSurface,data)\n\t\tIf animation=Null Return UpdateSurfaceRes(base)\n\t\tLocal base_res:TD3D9SurfaceRes=UpdateSurfaceRes(base)\n\t\tLocal anim_res:TD3D9SurfaceRes=UpdateSurfaceRes(animation)\n\t\tLocal res:TD3D9SurfaceRes=base_res.Copy()\n\t\tres._pos=anim_res._pos\n\t\tReturn res\n\tEnd Method\n\t\n\tMethod UploadVertexData(buffer:IDirect3DVertexBuffer9 Var,data#[])\n\t\tIf buffer=Null _d3ddev.CreateVertexBuffer(data.length*4,0,0,D3DPOOL_MANAGED,buffer,Null)\n\t\tLocal dataptr:Byte Ptr\n\t\tAssert buffer.Lock(0,0,dataptr,0)=D3D_OK,\"Failed to lock vertex buffer.\"\n\t\tMemCopy dataptr,data,data.length*4\t\t\n\t\tbuffer.Unlock()\n\tEnd Method\n\t\nEnd Type\n\nType TD3D9TextureRes Extends TTextureRes\n\tField _tex:IDirect3DTexture9\nEnd Type\n\nType TD3D9SurfaceRes Extends TSurfaceRes\n\tField _pos:IDirect3DVertexBuffer9\n\tField _nml:IDirect3DVertexBuffer9\n\tField _clr:IDirect3DVertexBuffer9\n\tField _tri:IDirect3DIndexBuffer9\n\tField _tex:IDirect3DVertexBuffer9[8]\n\t\n\tMethod Copy:TD3D9SurfaceRes()\n\t\tLocal res:TD3D9SurfaceRes=New TD3D9SurfaceRes\n\t\tres._vertexcnt=_vertexcnt;res._trianglecnt=_trianglecnt\n\t\tres._pos=_pos;res._nml=_nml;res._clr=_clr;res._tri=_tri;\n\t\tFor Local i=0 To 7\n\t\t\tres._tex[i]=_tex[i]\n\t\tNext\n\t\tReturn res\n\tEnd Method\nEnd Type\n\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction D3D9MaxB3DDriver:TD3D9MaxB3DDriver()\n\tIf D3D9Max2DExDriver()\n\t\tGlobal driver:TD3D9MaxB3DDriver=New TD3D9MaxB3DDriver\n\t\tdriver._parent=D3D9Max2DExDriver()\n\t\tReturn driver\n\tEnd If\nEnd Function\n\nRem\n\tbbdoc: Utility function that sets the MaxB3D D3D9 driver and calls Graphics.\nEnd Rem\nFunction D3D9Graphics3D:TGraphics(width,height,depth=0,hertz=0,flags=0)\n\tSetGraphicsDriver D3D9MaxB3DDriver(),GRAPHICS_BACKBUFFER|GRAPHICS_DEPTHBUFFER\n\tReturn Graphics(width,height,depth,hertz,flags)\nEnd Function\n\nLocal driver:TD3D9MaxB3DDriver=D3D9MaxB3DDriver()\nIf driver SetGraphicsDriver driver,GRAPHICS_BACKBUFFER|GRAPHICS_DEPTHBUFFER\n\n?\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"d49ba616a9164770ed0d0f5651177d18ed6a70b8","subject":"Oops. Quick fix.","message":"Oops. Quick fix.\n","repos":"kfprimm\/maxb3d,kfprimm\/maxb3d","old_file":"d3d9driver.mod\/d3d9driver.bmx","new_file":"d3d9driver.mod\/d3d9driver.bmx","new_contents":"\r\nStrict\r\n\r\nRem\r\n\tbbdoc: Direct3D 9 renderer for MaxB3D\r\nEnd Rem\r\nModule MaxB3D.D3D9Driver\r\nModuleInfo \"Author: Kevin Primm\"\r\nModuleInfo \"License: MIT\"\r\n\r\nImport MaxB3D.Core\r\nImport BRL.D3D9Max2D\r\n\r\n?Win32\r\n\r\nImport \"d3d9.bmx\"\r\n\r\nPrivate \r\nFunction Pow2Size( n )\r\n\tLocal t=1\r\n\tWhile tNull\r\n\t\t\t_d3ddev=TD3D9Graphics(TMax2DGraphics(g)._graphics).GetDirect3DDevice()\r\n\t\t\tEndMax2D\r\n\t\tEndIf\r\n\tEnd Method\r\n\t\r\n\tMethod Flip(sync)\r\n\t\tSuper.Flip(sync)\r\n\t\tIf _d3ddev<>Null EndMax2D ' TODO: Figure out when this needs to be called. Most likely NOT always!\r\n\tEnd Method\r\n\t\r\n\tMethod GetCaps:TCaps()\r\n\t\tLocal caps:TCaps=New TCaps\r\n\t\tReturn caps\r\n\tEnd Method\r\n\t\r\n\tMethod BeginMax2D()\r\n\t\tGlobal identity:TMatrix=TMatrix.Identity()\r\n\t\tLocal width=GraphicsWidth(),height=GraphicsHeight()\r\n\t\tLocal matrix#[]=[..\r\n\t\t2.0\/width,0.0,0.0,0.0,..\r\n\t\t 0.0,-2.0\/height,0.0,0.0,..\r\n\t\t 0.0,0.0,1.0,0.0,..\r\n\t\t -1-(1.0\/width),1+(1.0\/height),1.0,1.0]\r\n\t\t\r\n\t\t_d3ddev.SetTransform D3DTS_PROJECTION,matrix\r\n\t\t_d3ddev.SetTransform D3DTS_WORLD,identity.ToPtr()\r\n\t\t_d3ddev.SetTransform D3DTS_VIEW,identity.ToPtr()\r\n\t\t_d3ddev.SetTransform D3DTS_TEXTURE0,identity.ToPtr()\r\n\t\t\r\n\t\t_d3ddev.SetVertexDeclaration Null\r\n\t\t_d3ddev.SetIndices Null\r\n\t\t_d3ddev.SetFVF D3DFVF_XYZ|D3DFVF_DIFFUSE|D3DFVF_TEX1\r\n\t\t\r\n\t\t_d3ddev.SetRenderState D3DRS_LIGHTING,False\r\n\t\t_d3ddev.SetRenderState D3DRS_ZENABLE,False\r\n\t\t_d3ddev.SetRenderState D3DRS_SCISSORTESTENABLE,_viewporton\t\t\r\n\t\t\r\n\t\t_d3ddev.SetRenderState D3DRS_ALPHATESTENABLE,True\r\n\t\t\r\n\t\t_d3ddev.SetRenderState D3DRS_WRAP0, 0\r\n\t\t\r\n\t\t_d3ddev.SetRenderState D3DRS_FOGENABLE,False\r\n\t\t\r\n\t\tFor Local i=2 To 7\r\n\t\t\t_d3ddev.SetTexture i,Null\r\n\t\tNext\r\n\t\t\r\n\t\t_d3ddev.SetTextureStageState 0,D3DTSS_COLOROP,D3DTOP_MODULATE\r\n\t\t_d3ddev.SetTextureStageState 0,D3DTSS_ALPHAOP,D3DTOP_MODULATE\r\n\t\t\r\n\t\t_d3ddev.SetRenderState D3DRS_CULLMODE,D3DCULL_NONE\r\n\tEnd Method\r\n\t\r\n\tMethod EndMax2D()\r\n\t\t_d3ddev.SetRenderState D3DRS_ZENABLE,True\r\n\t\t_d3ddev.SetRenderState D3DRS_ZWRITEENABLE,True\r\n\r\n\t\t_d3ddev.GetRenderState D3DRS_SCISSORTESTENABLE,_viewporton\r\n\t\t_d3ddev.SetRenderState D3DRS_SCISSORTESTENABLE,True\r\n\t\t\r\n\t\t_d3ddev.SetRenderState D3DRS_LIGHTING,True\r\n\t\t_d3ddev.SetRenderState D3DRS_NORMALIZENORMALS,True\r\n\t\t_d3ddev.SetRenderState D3DRS_AMBIENT,D3DCOLOR_RGB(WorldConfig.AmbientRed,WorldConfig.AmbientGreen,WorldConfig.AmbientBlue)\r\n\t\t_d3ddev.SetRenderState D3DRS_COLORVERTEX, True\r\n\t\t_d3ddev.SetRenderState D3DRS_DIFFUSEMATERIALSOURCE,D3DMCS_MATERIAL\r\n\t\t\r\n\t\t_d3ddev.SetRenderState D3DRS_SHADEMODE,D3DSHADE_GOURAUD\r\n\t\t\r\n\t\t'_d3ddev.SetRenderState D3DRS_ALPHAREF, 1\r\n\t\t'_d3ddev.SetRenderState D3DRS_ALPHAFUNC, D3DCMP_GREATEREQUAL\r\n\t\t\t\t\r\n\t\t_d3ddev.SetRenderState D3DRS_CULLMODE,D3DCULL_CW\t\t\r\n\tEnd Method\r\n\t\r\n\tMethod SetCamera(camera:TCamera)\r\n\t\tLocal clearflags\t\t\r\n\t\tIf camera._clsmode&CLSMODE_COLOR clearflags:|D3DCLEAR_TARGET\r\n\t\tIf camera._clsmode&CLSMODE_DEPTH clearflags:|D3DCLEAR_ZBUFFER\r\n\r\n\t\tLocal viewport[]=[camera._viewx,camera._viewy,camera._viewwidth-camera._viewx,camera._viewheight-camera._viewy]\r\n\t\t_d3ddev.SetScissorRect viewport\r\n\t\t_d3ddev.Clear(1,viewport,clearflags,D3DCOLOR_XRGB(camera._brush._r*255,camera._brush._g*255,camera._brush._b*255),1.0,0)\r\n\t\t\r\n\t\tSelect camera._fogmode\r\n\t\tCase FOGMODE_LINEAR\r\n\t\t\t_d3ddev.SetRenderState D3DRS_FOGENABLE,True\r\n\t\t\t_d3ddev.SetRenderState D3DRS_FOGSTART,Int(Varptr camera._fognear)\r\n\t\t\t_d3ddev.SetRenderState D3DRS_FOGEND,Int(Varptr camera._fogfar)\r\n\t\tDefault\r\n\t\t\t_d3ddev.SetRenderState D3DRS_FOGENABLE,False\r\n\t\tEnd Select\r\n\t\t\r\n\t\tLocal ratio#=(Float(camera._viewwidth)\/camera._viewheight)\t\t\r\n\t\tLocal proj_matrix:TMatrix=TMatrix.PerspectiveFovLH(ATan((1.0\/(camera._zoom*ratio)))*2.0,ratio#,camera._near,camera._far)\r\n\t\tproj_matrix=TMatrix.Scale(-1,1,1).Multiply(proj_matrix)\r\n\t\t_d3ddev.SetTransform D3DTS_PROJECTION,proj_matrix.ToPtr()\r\n\t\t\r\n\t\tLocal matrix:TMatrix=camera._matrix.Inverse()\r\n\t\t_d3ddev.SetTransform D3DTS_VIEW,matrix.ToPtr()\r\n\t\t\r\n\t\tcamera._lastmodelview=matrix\r\n\t\tcamera._lastprojection=proj_matrix\r\n\t\t\r\n\t\tcamera._lastviewport[0]=camera._viewx\r\n\t\tcamera._lastviewport[1]=camera._viewy\r\n\t\tcamera._lastviewport[2]=camera._viewwidth\r\n\t\tcamera._lastviewport[3]=camera._viewheight\r\n\t\t\r\n\t\tcamera._lastfrustum=TFrustum.Extract(camera._lastmodelview,camera._lastprojection)\r\n\tEnd Method\r\n\t\r\n\tMethod SetLight(light:TLight,index)\r\n\t\tIf light=Null \r\n\t\t\t_d3ddev.LightEnable index,False\r\n\t\t\tReturn\r\n\t\tEndIf\r\n\t\t\r\n\t\tLocal brush:TBrush=light._brush\r\n\r\n\t\tGlobal d3dlight:D3DLIGHT9=New D3DLIGHT9\r\n\t\td3dlight.Type_=D3DLIGHT_DIRECTIONAL \r\n\t\td3dlight.Diffuse_r=brush._r;d3dlight.Diffuse_g=brush._g;d3dlight.Diffuse_b=brush._b;d3dlight.Diffuse_a=brush._a\r\n\t\t'd3dlight.Ambient_r=WorldConfig.AmbientRed\/255.0;d3dlight.Ambient_g=WorldConfig.AmbientGreen\/255.0;d3dlight.Ambient_b=WorldConfig.AmbientBlue\/255.0;d3dlight.Ambient_a=1.0\r\n\t\t\r\n\t\td3dlight.Direction_x=0.0;d3dlight.Direction_y=0.0;d3dlight.Direction_z=1.0\r\n\t\t\t\t\r\n\t\tLocal matrix:TMatrix=light._matrix,w#=1\r\n\t\tmatrix.TransformVector d3dlight.Direction_x,d3dlight.Direction_y,d3dlight.Direction_z,w\r\n\t\tmatrix.GetPosition d3dlight.Position_x,d3dlight.Position_y,d3dlight.Position_z\t\t\r\n\t\t\r\n\t\td3dlight.Range=light._range\t\t\r\n\t\t\r\n\t\t_d3ddev.SetLight index,d3dlight\r\n\t\t_d3ddev.LightEnable index,True\r\n\tEnd Method\r\n\t\r\n\tMethod SetBrush(brush:TBrush,hasalpha)\r\n\t\t_d3ddev.SetRenderState D3DRS_ALPHATESTENABLE,False\r\n\t\t\r\n\t\tLocal alpha_blending = (brush._fx&FX_FORCEALPHA Or hasalpha)>0\r\n\t\t_d3ddev.SetRenderState D3DRS_ALPHABLENDENABLE,alpha_blending \r\n\t\t_d3ddev.SetRenderState D3DRS_ZWRITEENABLE,Not alpha_blending \r\n\t\t\r\n\t\tIf brush._fx&FX_FULLBRIGHT\r\n\t\t\t_d3ddev.SetRenderState D3DRS_AMBIENT,$ffffffff\r\n\t\tElse\r\n\t\t\t_d3ddev.SetRenderState D3DRS_AMBIENT,D3DCOLOR_RGB(WorldConfig.AmbientRed,WorldConfig.AmbientGreen,WorldConfig.AmbientBlue)\r\n\t\tEndIf\r\n\t\t\r\n\t\tIf brush._fx&FX_NOCULLING\r\n\t\t\t_d3ddev.SetRenderState D3DRS_CULLMODE,D3DCULL_NONE\r\n\t\tElse\r\n\t\t\t_d3ddev.SetRenderState D3DRS_CULLMODE,D3DCULL_CW\r\n\t\tEndIf\r\n\t\t\r\n\t\tIf brush._fx&FX_WIREFRAME Or WorldConfig.Wireframe\r\n\t\t\t_d3ddev.SetRenderState D3DRS_FILLMODE,D3DFILL_WIREFRAME\r\n\t\tElse\r\n\t\t\t_d3ddev.SetRenderState D3DRS_FILLMODE,D3DFILL_SOLID\r\n\t\tEndIf\r\n\t\t\r\n\t\tLocal material:D3DMATERIAL9 = New D3DMATERIAL9\r\n\t\tmaterial.Diffuse_r=brush._r;material.Diffuse_g=brush._g;material.Diffuse_b=brush._b;material.Diffuse_a=brush._a\r\n\t\tmaterial.Ambient_r=brush._r;material.Ambient_g=brush._g;material.Ambient_b=brush._b;material.Ambient_a=brush._a\r\n\r\n\t\t_d3ddev.SetMaterial material\r\n\t\t\r\n\t\tFor Local i=0 To 7\r\n\t\t\tLocal texture:TTexture=brush._texture[i]\r\n\t\t\tIf texture=Null Or texture._blend=BLEND_NONE \r\n\t\t\t\t_d3ddev.SetTexture i,Null\r\n\t\t\t\tContinue\r\n\t\t\tEndIf\r\n\t\t\t\r\n\t\t\t_d3ddev.SetTexture i,UpdateTextureRes(texture)._tex\r\n\r\n\t\t\tLocal matrix:TMatrix=TMatrix.Identity()\r\n\t\t\t'matrix._m[0,0]=-texture._sx\r\n\t\t\t'matrix._m[1,1]=texture._sy\r\n\t\t\tmatrix=TMatrix.YawPitchRoll(0,0,-texture._r).Multiply(matrix)\r\n\t\t\tmatrix=TMatrix.Scale(-texture._sx,texture._sy,1).Multiply(matrix)\r\n\t\t\tmatrix._m[2,0]=-texture._px\r\n\t\t\tmatrix._m[2,1]=-texture._py\r\n\t\t\t\r\n\t\t\t_d3ddev.SetTransform D3DTS_TEXTURE0+i,matrix.ToPtr()\r\n\r\n\t\t\t_d3ddev.SetTextureStageState i,D3DTSS_TEXTURETRANSFORMFLAGS,D3DTTFF_COUNT2\r\n\t\t\t\r\n\t\t\t_d3ddev.SetSamplerState i,D3DSAMP_MAGFILTER,D3DTEXF_LINEAR\r\n\t\t\t_d3ddev.SetSamplerState i,D3DSAMP_MINFILTER,D3DTEXF_LINEAR\r\n\t\t\t\t\t\t\r\n\t\t\t_d3ddev.SetRenderState D3DRS_ALPHATESTENABLE, texture._flags&TEXTURE_ALPHA\t\t\t\r\n\t\t\t\r\n\t\t\tIf texture._flags&TEXTURE_MIPMAP\t\t\t\t\r\n\t\t\t\t_d3ddev.SetSamplerState i,D3DSAMP_MIPFILTER,D3DTEXF_LINEAR\r\n\t\t\tElse\r\n\t\t\t\t_d3ddev.SetSamplerState i,D3DSAMP_MIPFILTER,D3DTEXF_NONE\r\n\t\t\tEndIf\r\n\t\t\t\r\n\t\t\tIf texture._flags&TEXTURE_CLAMPU\r\n\t\t\t\t_d3ddev.SetSamplerState i,D3DSAMP_ADDRESSU,D3DTADDRESS_CLAMP\r\n\t\t\tElse\r\n\t\t\t\t_d3ddev.SetSamplerState i,D3DSAMP_ADDRESSU,D3DTADDRESS_WRAP\r\n\t\t\tEndIf\r\n\t\t\t\r\n\t\t\tIf texture._flags&TEXTURE_CLAMPV\r\n\t\t\t\t_d3ddev.SetSamplerState i,D3DSAMP_ADDRESSU,D3DTADDRESS_CLAMP\r\n\t\t\tElse\r\n\t\t\t\t_d3ddev.SetSamplerState i,D3DSAMP_ADDRESSV,D3DTADDRESS_WRAP\r\n\t\t\tEndIf\r\n\t\t\t\r\n\t\t\tIf texture._flags&TEXTURE_SPHMAP\r\n\t\t\t\t_d3ddev.SetTextureStageState i,D3DTSS_TEXCOORDINDEX,D3DTSS_TCI_SPHEREMAP\r\n\t\t\tElse\r\n\t\t\t\t_d3ddev.SetTextureStageState i,D3DTSS_TEXCOORDINDEX,texture._coords\r\n\t\t\tEndIf\r\n\t\t\t\r\n\t\t\t'_d3ddev.SetTextureStageState i,D3DTSS_COLOROP,D3DTOP_SELECTARG1\r\n\t\t\t'_d3ddev.SetTextureStageState i,D3DTSS_ALPHAOP,D3DTOP_SELECTARG2\r\n\t\t\t\r\n\t\t\tSelect texture._blend\r\n\t\t\tCase BLEND_ALPHA\r\n\t\t\t\t'glTexEnvf(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_DECAL)\r\n\t\t\tCase BLEND_MULTIPLY\r\n\t\t\t\t_d3ddev.SetTextureStageState i,D3DTSS_COLOROP,D3DTOP_MODULATE\r\n\t\t\t\t_d3ddev.SetTextureStageState i,D3DTSS_ALPHAOP,D3DTOP_MODULATE\r\n\t\t\tCase BLEND_ADD\r\n\t\t\t\t_d3ddev.SetTextureStageState i,D3DTSS_COLOROP,D3DTOP_ADD\r\n\t\t\t\t_d3ddev.SetTextureStageState i,D3DTSS_ALPHAOP,D3DTOP_ADD\r\n\t\t\tCase BLEND_DOT3\r\n\t\t\t\t_d3ddev.SetTextureStageState i,D3DTSS_COLOROP,D3DTOP_DOTPRODUCT3\r\n\t\t\t\t_d3ddev.SetTextureStageState i,D3DTSS_ALPHAOP,D3DTOP_DOTPRODUCT3\r\n\t\t\tCase BLEND_MULTIPLY2\r\n\t\t\t\t_d3ddev.SetTextureStageState i,D3DTSS_COLOROP,D3DTOP_MODULATE2X\r\n\t\t\t\t_d3ddev.SetTextureStageState i,D3DTSS_ALPHAOP,D3DTOP_MODULATE2X\r\n\t\t\tDefault\r\n\t\t\t\t_d3ddev.SetTextureStageState i,D3DTSS_COLOROP,D3DTOP_MODULATE\r\n\t\t\t\t_d3ddev.SetTextureStageState i,D3DTSS_ALPHAOP,D3DTOP_MODULATE\r\n\t\t\tEnd Select\t\t\t\r\n\t\tNext\r\n\tEnd Method\r\n\t\r\n\tMethod RenderSurface(resource:TSurfaceRes,brush:TBrush)\r\n\t\tLocal res:TD3D9SurfaceRes=TD3D9SurfaceRes(resource)\r\n\t\t\r\n\t\t_d3ddev.SetFVF 0\r\n\t\t_d3ddev.SetVertexDeclaration GetD3D9MaxB3DVertexDecl(_d3ddev)\r\n\t\t_d3ddev.SetStreamSource 0,res._pos,0,12\r\n\t\t_d3ddev.SetStreamSource 1,res._nml,0,12\r\n\t\t_d3ddev.SetStreamSource 2,res._clr,0,16\r\n\t\t_d3ddev.SetStreamSource 3,res._tex[0],0,8\r\n\t\t_d3ddev.SetIndices res._tri\r\n\t\t_d3ddev.DrawIndexedPrimitive D3DPT_TRIANGLELIST,0,0,res._vertexcnt,0,res._trianglecnt\r\n\r\n\t\tReturn res._trianglecnt\r\n\tEnd Method\r\n\t\r\n\tMethod RenderSprite(sprite:TSprite)\t\r\n\t\tGlobal _data#[]=[ -1.0, 1.0,0.0, 0.0,0.0,1.0, 0.0,0.0, ..\r\n\t\t 1.0, 1.0,0.0, 0.0,0.0,1.0, 1.0,0.0, ..\r\n\t\t -1.0,-1.0,0.0, 0.0,0.0,1.0, 0.0,1.0, ..\r\n\t\t 1.0,-1.0,0.0, 0.0,0.0,1.0, 1.0,1.0 ]\r\n\t\t\r\n\t\t_d3ddev.SetVertexDeclaration Null\r\n\t\t_d3ddev.SetFVF D3DFVF_XYZ|D3DFVF_NORMAL|D3DFVF_TEX1\r\n\t\t_d3ddev.DrawPrimitiveUP D3DPT_TRIANGLESTRIP,2,_data,8*4\r\n\tEnd Method\r\n\t\r\n\tMethod BeginEntityRender(entity:TEntity)\r\n\t\t_d3ddev.SetTransform D3DTS_WORLD,entity.GetMatrix(True).ToPtr()\r\n\tEnd Method\r\n\t\r\n\tMethod EndEntityRender(entity:TEntity)\r\n\tEnd Method\r\n\t\r\n\tMethod RenderPlane(plane:TPlane)\r\n\t\tLocal x#,y#,z#\r\n\t\tplane.GetScale x,y,z,True\r\n\r\n\t\tGlobal _data#[]=[ -1.0,0.0, 1.0, 0.0,1.0,0.0, 0.0,0.0, ..\r\n\t\t 1.0,0.0, 1.0, 0.0,1.0,0.0, x,0.0, ..\r\n\t\t -1.0,0.0,-1.0, 0.0,1.0,0.0, 0.0, z, ..\r\n\t\t 1.0,0.0,-1.0, 0.0,1.0,0.0, x, z ]\t\t\r\n\t\t\r\n\t\t_d3ddev.SetVertexDeclaration Null\r\n\t\t_d3ddev.SetFVF D3DFVF_XYZ|D3DFVF_NORMAL|D3DFVF_TEX1\r\n\t\t_d3ddev.DrawPrimitiveUP D3DPT_TRIANGLESTRIP,2,_data,8*4\r\n\tEnd Method\r\n\t\r\n\tMethod RenderTerrain(terrain:TTerrain)\r\n\tEnd Method\r\n\t\r\n\tMethod UpdateTextureRes:TD3D9TextureRes(texture:TTexture)\r\n\t\tLocal res:TD3D9TextureRes=TD3D9TextureRes(texture._res)\r\n\t\tIf res And texture._updateres=False Return res\r\n\r\n\t\tIf res=Null res=New TD3D9TextureRes\r\n\t\ttexture._res=res\r\n\t\t\r\n\t\tLocal pixmap:TPixmap=texture._pixmap\r\n\t\tLocal tex_width=Pow2Size(pixmap.width),tex_height=Pow2Size(pixmap.height)\r\n\t\tpixmap=ConvertPixmap(ResizePixmap(pixmap,tex_width,tex_height),PF_BGRA8888)\r\n\t\tIf res._tex=Null Assert _d3ddev.CreateTexture(tex_width,tex_height,(texture._flags & TEXTURE_MIPMAP)=0,D3DUSAGE_AUTOGENMIPMAP,D3DFMT_A8R8G8B8,D3DPOOL_MANAGED,res._tex,Null)=D3D_OK\r\n\t\t\r\n\t\tLocal rect:D3DLOCKED_RECT=New D3DLOCKED_RECT \r\n\t\tres._tex.LockRect 0,rect,Null,0\r\n\t\tMemCopy rect.pBits,pixmap.pixels,pixmap.width*pixmap.height*4\r\n\t\tres._tex.UnlockRect 0\r\n\t\t\r\n\t\ttexture._updateres=False\r\n\t\t\t\t\r\n\t\tReturn res\r\n\tEnd Method\r\n\t\r\n\tMethod UpdateSurfaceRes:TD3D9SurfaceRes(surface:TSurface)\r\n\t\tLocal res:TD3D9SurfaceRes=TD3D9SurfaceRes(surface._res)\r\n\t\tIf res=Null res=New TD3D9SurfaceRes;surface._reset=-1\r\n\t\t\r\n\t\tIf surface._reset=0 Return res\t\t\r\n\t\tIf surface._reset=-1 surface._reset=1|2|4|8|16|32|64|128|256\r\n\r\n\t\tIf surface._reset&1 And surface._vertexpos UploadVertexData res._pos,surface._vertexpos\r\n\t\tIf surface._reset&2 And surface._vertexnml UploadVertexData res._nml,surface._vertexnml\r\n\t\tIf surface._reset&4 And surface._vertexclr UploadVertexData res._clr,surface._vertexclr\r\n\t\tIf surface._reset&8 And surface._triangle\r\n\t\t\tIf res._tri=Null _d3ddev.CreateIndexBuffer(surface._triangle.length*4,0,D3DFMT_INDEX32,D3DPOOL_MANAGED,res._tri,Null)\r\n\t\t\tLocal dataptr:Byte Ptr\r\n\t\t\tAssert res._tri.Lock(0,0,dataptr,0)=D3D_OK,\"Failed to lock index buffer.\"\r\n\t\t\tMemCopy dataptr,surface._triangle,surface._triangle.length*4\t\t\r\n\t\t\tres._tri.Unlock()\r\n\t\tEndIf\r\n\t\t\r\n\t\tFor Local i=0 To surface._vertextex.length-1\r\n\t\t\tIf surface._reset&Int(2^(4+i)) UploadVertexData res._tex[i],surface._vertextex[i]\r\n\t\tNext\r\n\t\t\r\n\t\tres._trianglecnt=surface._trianglecnt\r\n\t\tres._vertexcnt=surface._vertexcnt\r\n\t\t\r\n\t\tsurface._reset=0\r\n\t\tsurface._res=res\r\n\t\t\r\n\t\tReturn res\r\n\tEnd Method\r\n\r\n\tMethod MergeSurfaceRes:TSurfaceRes(base:TSurface,animation:TSurface,data)\r\n\t\tIf animation=Null Return UpdateSurfaceRes(base)\r\n\t\tLocal base_res:TD3D9SurfaceRes=UpdateSurfaceRes(base)\r\n\t\tLocal anim_res:TD3D9SurfaceRes=UpdateSurfaceRes(animation)\r\n\t\tLocal res:TD3D9SurfaceRes=base_res.Copy()\r\n\t\tres._pos=anim_res._pos\r\n\t\tReturn res\r\n\tEnd Method\r\n\t\r\n\tMethod UploadVertexData(buffer:IDirect3DVertexBuffer9 Var,data#[])\r\n\t\tIf buffer=Null _d3ddev.CreateVertexBuffer(data.length*4,0,0,D3DPOOL_MANAGED,buffer,Null)\r\n\t\tLocal dataptr:Byte Ptr\r\n\t\tAssert buffer.Lock(0,0,dataptr,0)=D3D_OK,\"Failed to lock vertex buffer.\"\r\n\t\tMemCopy dataptr,data,data.length*4\t\t\r\n\t\tbuffer.Unlock()\r\n\tEnd Method\r\n\t\r\nEnd Type\r\n\r\nType TD3D9TextureRes Extends TTextureRes\r\n\tField _tex:IDirect3DTexture9\r\nEnd Type\r\n\r\nType TD3D9SurfaceRes Extends TSurfaceRes\r\n\tField _pos:IDirect3DVertexBuffer9\r\n\tField _nml:IDirect3DVertexBuffer9\r\n\tField _clr:IDirect3DVertexBuffer9\r\n\tField _tri:IDirect3DIndexBuffer9\r\n\tField _tex:IDirect3DVertexBuffer9[8]\r\n\t\r\n\tMethod Copy:TD3D9SurfaceRes()\r\n\t\tLocal res:TD3D9SurfaceRes=New TD3D9SurfaceRes\r\n\t\tres._vertexcnt=_vertexcnt;res._trianglecnt=_trianglecnt\r\n\t\tres._pos=_pos;res._nml=_nml;res._clr=_clr;res._tri=_tri;\r\n\t\tFor Local i=0 To 7\r\n\t\t\tres._tex[i]=_tex[i]\r\n\t\tNext\r\n\t\tReturn res\r\n\tEnd Method\r\nEnd Type\r\n\r\nRem\r\n\tbbdoc: Needs documentation. #TODO\r\nEnd Rem\r\nFunction D3D9MaxB3DDriver:TD3D9MaxB3DDriver()\r\n\tIf D3D9Max2DDriver()\r\n\t\tGlobal driver:TD3D9MaxB3DDriver=New TD3D9MaxB3DDriver\r\n\t\tdriver._parent=D3D9Max2DDriver()\r\n\t\tReturn driver\r\n\tEnd If\r\nEnd Function\r\n\r\nRem\r\n\tbbdoc: Utility function that sets the MaxB3D D3D9 driver and calls Graphics.\r\nEnd Rem\r\nFunction D3D9Graphics3D:TGraphics(width,height,depth=0,hertz=0,flags=0)\r\n\tSetGraphicsDriver D3D9MaxB3DDriver(),GRAPHICS_BACKBUFFER|GRAPHICS_DEPTHBUFFER\r\n\tReturn Graphics(width,height,depth,hertz,flags)\r\nEnd Function\r\n\r\nLocal driver:TD3D9MaxB3DDriver=D3D9MaxB3DDriver()\r\nIf driver SetGraphicsDriver driver,GRAPHICS_BACKBUFFER|GRAPHICS_DEPTHBUFFER\r\n\r\n?","old_contents":"\r\nStrict\r\n\r\nRem\r\n\tbbdoc: Direct3D 9 renderer for MaxB3D\r\nEnd Rem\r\nModule MaxB3D.D3D9Driver\r\nModuleInfo \"Author: Kevin Primm\"\r\nModuleInfo \"License: MIT\"\r\n\r\nImport MaxB3D.Core\r\nImport BRL.D3D9Max2D\r\n\r\n?Win32\r\n\r\nImport \"d3d9.bmx\"\r\n\r\nPrivate \r\nFunction Pow2Size( n )\r\n\tLocal t=1\r\n\tWhile tNull\r\n\t\t\t_d3ddev=TD3D9Graphics(TMax2DGraphics(g)._graphics).GetDirect3DDevice()\r\n\t\t\tEndMax2D\r\n\t\tEndIf\r\n\tEnd Method\r\n\t\r\n\tMethod Flip(sync)\r\n\t\tSuper.Flip(sync)\r\n\t\tIf _d3ddev<>Null EndMax2D ' TODO: Figure out when this needs to be called. Most likely NOT always!\r\n\tEnd Method\r\n\t\r\n\tMethod GetCaps:TCaps()\r\n\t\tLocal caps:TCaps=New TCaps\r\n\t\tReturn caps\r\n\tEnd Method\r\n\t\r\n\tMethod BeginMax2D()\r\n\t\tGlobal identity:TMatrix=TMatrix.Identity()\r\n\t\tLocal width=GraphicsWidth(),height=GraphicsHeight()\r\n\t\tLocal matrix#[]=[..\r\n\t\t2.0\/width,0.0,0.0,0.0,..\r\n\t\t 0.0,-2.0\/height,0.0,0.0,..\r\n\t\t 0.0,0.0,1.0,0.0,..\r\n\t\t -1-(1.0\/width),1+(1.0\/height),1.0,1.0]\r\n\t\t\r\n\t\t_d3ddev.SetTransform D3DTS_PROJECTION,matrix\r\n\t\t_d3ddev.SetTransform D3DTS_WORLD,identity.ToPtr()\r\n\t\t_d3ddev.SetTransform D3DTS_VIEW,identity.ToPtr()\r\n\t\t_d3ddev.SetTransform D3DTS_TEXTURE0,identity.ToPtr()\r\n\t\t\r\n\t\t_d3ddev.SetVertexDeclaration Null\r\n\t\t_d3ddev.SetIndices Null\r\n\t\t_d3ddev.SetFVF D3DFVF_XYZ|D3DFVF_DIFFUSE|D3DFVF_TEX1\r\n\t\t\r\n\t\t_d3ddev.SetRenderState D3DRS_LIGHTING,False\r\n\t\t_d3ddev.SetRenderState D3DRS_ZENABLE,False\r\n\t\t_d3ddev.SetRenderState D3DRS_SCISSORTESTENABLE,_viewporton\t\t\r\n\t\t\r\n\t\t_d3ddev.SetRenderState D3DRS_ALPHATESTENABLE,True\r\n\t\t\r\n\t\t_d3ddev.SetRenderState D3DRS_WRAP0, 0\r\n\t\t\r\n\t\t_d3ddev.SetRenderState D3DRS_FOGENABLE,False\r\n\t\t\r\n\t\tFor Local i=2 To 7\r\n\t\t\t_d3ddev.SetTexture i,Null\r\n\t\tNext\r\n\t\t\r\n\t\t_d3ddev.SetTextureStageState 0,D3DTSS_COLOROP,D3DTOP_MODULATE\r\n\t\t_d3ddev.SetTextureStageState 0,D3DTSS_ALPHAOP,D3DTOP_MODULATE\r\n\t\t\r\n\t\t_d3ddev.SetRenderState D3DRS_CULLMODE,D3DCULL_NONE\r\n\tEnd Method\r\n\t\r\n\tMethod EndMax2D()\r\n\t\t_d3ddev.SetRenderState D3DRS_ZENABLE,True\r\n\t\t_d3ddev.SetRenderState D3DRS_ZWRITEENABLE,True\r\n\r\n\t\t_d3ddev.GetRenderState D3DRS_SCISSORTESTENABLE,_viewporton\r\n\t\t_d3ddev.SetRenderState D3DRS_SCISSORTESTENABLE,True\r\n\t\t\r\n\t\t_d3ddev.SetRenderState D3DRS_LIGHTING,True\r\n\t\t_d3ddev.SetRenderState D3DRS_NORMALIZENORMALS,True\r\n\t\t_d3ddev.SetRenderState D3DRS_AMBIENT,D3DCOLOR_RGB(WorldConfig.AmbientRed,WorldConfig.AmbientGreen,WorldConfig.AmbientBlue)\r\n\t\t_d3ddev.SetRenderState D3DRS_COLORVERTEX, True\r\n\t\t_d3ddev.SetRenderState D3DRS_DIFFUSEMATERIALSOURCE,D3DMCS_MATERIAL\r\n\t\t\r\n\t\t_d3ddev.SetRenderState D3DRS_SHADEMODE,D3DSHADE_GOURAUD\r\n\t\t\r\n\t\t'_d3ddev.SetRenderState D3DRS_ALPHAREF, 1\r\n\t\t'_d3ddev.SetRenderState D3DRS_ALPHAFUNC, D3DCMP_GREATEREQUAL\r\n\t\t\t\t\r\n\t\t_d3ddev.SetRenderState D3DRS_CULLMODE,D3DCULL_CW\t\t\r\n\tEnd Method\r\n\t\r\n\tMethod SetCamera(camera:TCamera)\r\n\t\tLocal clearflags\t\t\r\n\t\tIf camera._clsmode&CLSMODE_COLOR clearflags:|D3DCLEAR_TARGET\r\n\t\tIf camera._clsmode&CLSMODE_DEPTH clearflags:|D3DCLEAR_ZBUFFER\r\n\r\n\t\tLocal viewport[]=[camera._viewx,camera._viewy,camera._viewwidth-camera._viewx,camera._viewheight-camera._viewy]\r\n\t\t_d3ddev.SetScissorRect viewport\r\n\t\t_d3ddev.Clear(1,viewport,clearflags,D3DCOLOR_XRGB(camera._brush._r*255,camera._brush._g*255,camera._brush._b*255),1.0,0)\r\n\t\t\r\n\t\tSelect camera._fogmode\r\n\t\tCase FOGMODE_LINEAR\r\n\t\t\t_d3ddev.SetRenderState D3DRS_FOGENABLE,True\r\n\t\t\t_d3ddev.SetRenderState D3DRS_FOGSTART,Int(Varptr camera._fognear)\r\n\t\t\t_d3ddev.SetRenderState D3DRS_FOGEND,Int(Varptr camera._fogfar)\r\n\t\tDefault\r\n\t\t\t_d3ddev.SetRenderState D3DRS_FOGENABLE,False\r\n\t\tEnd Select\r\n\t\t\r\n\t\tLocal ratio#=(Float(camera._viewwidth)\/camera._viewheight)\t\t\r\n\t\tLocal proj_matrix:TMatrix=TMatrix.PerspectiveFovRH(ATan((1.0\/(camera._zoom*ratio)))*2.0,ratio#,camera._near,camera._far)\r\n\t\tproj_matrix=TMatrix.Scale(-1,1,1).Multiply(proj_matrix)\r\n\t\t_d3ddev.SetTransform D3DTS_PROJECTION,proj_matrix.ToPtr()\r\n\t\t\r\n\t\tLocal matrix:TMatrix=camera._matrix.Inverse()\r\n\t\t_d3ddev.SetTransform D3DTS_VIEW,matrix.ToPtr()\r\n\t\t\r\n\t\tcamera._lastmodelview=matrix\r\n\t\tcamera._lastprojection=proj_matrix\r\n\t\t\r\n\t\tcamera._lastviewport[0]=camera._viewx\r\n\t\tcamera._lastviewport[1]=camera._viewy\r\n\t\tcamera._lastviewport[2]=camera._viewwidth\r\n\t\tcamera._lastviewport[3]=camera._viewheight\r\n\t\t\r\n\t\tcamera._lastfrustum=TFrustum.Extract(camera._lastmodelview,camera._lastprojection)\r\n\tEnd Method\r\n\t\r\n\tMethod SetLight(light:TLight,index)\r\n\t\tIf light=Null \r\n\t\t\t_d3ddev.LightEnable index,False\r\n\t\t\tReturn\r\n\t\tEndIf\r\n\t\t\r\n\t\tLocal brush:TBrush=light._brush\r\n\r\n\t\tGlobal d3dlight:D3DLIGHT9=New D3DLIGHT9\r\n\t\td3dlight.Type_=D3DLIGHT_DIRECTIONAL \r\n\t\td3dlight.Diffuse_r=brush._r;d3dlight.Diffuse_g=brush._g;d3dlight.Diffuse_b=brush._b;d3dlight.Diffuse_a=brush._a\r\n\t\t'd3dlight.Ambient_r=WorldConfig.AmbientRed\/255.0;d3dlight.Ambient_g=WorldConfig.AmbientGreen\/255.0;d3dlight.Ambient_b=WorldConfig.AmbientBlue\/255.0;d3dlight.Ambient_a=1.0\r\n\t\t\r\n\t\td3dlight.Direction_x=0.0;d3dlight.Direction_y=0.0;d3dlight.Direction_z=1.0\r\n\t\t\t\t\r\n\t\tLocal matrix:TMatrix=light._matrix,w#=1\r\n\t\tmatrix.TransformVector d3dlight.Direction_x,d3dlight.Direction_y,d3dlight.Direction_z,w\r\n\t\tmatrix.GetPosition d3dlight.Position_x,d3dlight.Position_y,d3dlight.Position_z\t\t\r\n\t\t\r\n\t\td3dlight.Range=light._range\t\t\r\n\t\t\r\n\t\t_d3ddev.SetLight index,d3dlight\r\n\t\t_d3ddev.LightEnable index,True\r\n\tEnd Method\r\n\t\r\n\tMethod SetBrush(brush:TBrush,hasalpha)\r\n\t\t_d3ddev.SetRenderState D3DRS_ALPHATESTENABLE,False\r\n\t\t\r\n\t\tLocal alpha_blending = (brush._fx&FX_FORCEALPHA Or hasalpha)>0\r\n\t\t_d3ddev.SetRenderState D3DRS_ALPHABLENDENABLE,alpha_blending \r\n\t\t_d3ddev.SetRenderState D3DRS_ZWRITEENABLE,Not alpha_blending \r\n\t\t\r\n\t\tIf brush._fx&FX_FULLBRIGHT\r\n\t\t\t_d3ddev.SetRenderState D3DRS_AMBIENT,$ffffffff\r\n\t\tElse\r\n\t\t\t_d3ddev.SetRenderState D3DRS_AMBIENT,D3DCOLOR_RGB(WorldConfig.AmbientRed,WorldConfig.AmbientGreen,WorldConfig.AmbientBlue)\r\n\t\tEndIf\r\n\t\t\r\n\t\tIf brush._fx&FX_NOCULLING\r\n\t\t\t_d3ddev.SetRenderState D3DRS_CULLMODE,D3DCULL_NONE\r\n\t\tElse\r\n\t\t\t_d3ddev.SetRenderState D3DRS_CULLMODE,D3DCULL_CW\r\n\t\tEndIf\r\n\t\t\r\n\t\tIf brush._fx&FX_WIREFRAME Or WorldConfig.Wireframe\r\n\t\t\t_d3ddev.SetRenderState D3DRS_FILLMODE,D3DFILL_WIREFRAME\r\n\t\tElse\r\n\t\t\t_d3ddev.SetRenderState D3DRS_FILLMODE,D3DFILL_SOLID\r\n\t\tEndIf\r\n\t\t\r\n\t\tLocal material:D3DMATERIAL9 = New D3DMATERIAL9\r\n\t\tmaterial.Diffuse_r=brush._r;material.Diffuse_g=brush._g;material.Diffuse_b=brush._b;material.Diffuse_a=brush._a\r\n\t\tmaterial.Ambient_r=brush._r;material.Ambient_g=brush._g;material.Ambient_b=brush._b;material.Ambient_a=brush._a\r\n\r\n\t\t_d3ddev.SetMaterial material\r\n\t\t\r\n\t\tFor Local i=0 To 7\r\n\t\t\tLocal texture:TTexture=brush._texture[i]\r\n\t\t\tIf texture=Null Or texture._blend=BLEND_NONE \r\n\t\t\t\t_d3ddev.SetTexture i,Null\r\n\t\t\t\tContinue\r\n\t\t\tEndIf\r\n\t\t\t\r\n\t\t\t_d3ddev.SetTexture i,UpdateTextureRes(texture)._tex\r\n\r\n\t\t\tLocal matrix:TMatrix=TMatrix.Identity()\r\n\t\t\t'matrix._m[0,0]=-texture._sx\r\n\t\t\t'matrix._m[1,1]=texture._sy\r\n\t\t\tmatrix=TMatrix.YawPitchRoll(0,0,-texture._r).Multiply(matrix)\r\n\t\t\tmatrix=TMatrix.Scale(-texture._sx,texture._sy,1).Multiply(matrix)\r\n\t\t\tmatrix._m[2,0]=-texture._px\r\n\t\t\tmatrix._m[2,1]=-texture._py\r\n\t\t\t\r\n\t\t\t_d3ddev.SetTransform D3DTS_TEXTURE0+i,matrix.ToPtr()\r\n\r\n\t\t\t_d3ddev.SetTextureStageState i,D3DTSS_TEXTURETRANSFORMFLAGS,D3DTTFF_COUNT2\r\n\t\t\t\r\n\t\t\t_d3ddev.SetSamplerState i,D3DSAMP_MAGFILTER,D3DTEXF_LINEAR\r\n\t\t\t_d3ddev.SetSamplerState i,D3DSAMP_MINFILTER,D3DTEXF_LINEAR\r\n\t\t\t\t\t\t\r\n\t\t\t_d3ddev.SetRenderState D3DRS_ALPHATESTENABLE, texture._flags&TEXTURE_ALPHA\t\t\t\r\n\t\t\t\r\n\t\t\tIf texture._flags&TEXTURE_MIPMAP\t\t\t\t\r\n\t\t\t\t_d3ddev.SetSamplerState i,D3DSAMP_MIPFILTER,D3DTEXF_LINEAR\r\n\t\t\tElse\r\n\t\t\t\t_d3ddev.SetSamplerState i,D3DSAMP_MIPFILTER,D3DTEXF_NONE\r\n\t\t\tEndIf\r\n\t\t\t\r\n\t\t\tIf texture._flags&TEXTURE_CLAMPU\r\n\t\t\t\t_d3ddev.SetSamplerState i,D3DSAMP_ADDRESSU,D3DTADDRESS_CLAMP\r\n\t\t\tElse\r\n\t\t\t\t_d3ddev.SetSamplerState i,D3DSAMP_ADDRESSU,D3DTADDRESS_WRAP\r\n\t\t\tEndIf\r\n\t\t\t\r\n\t\t\tIf texture._flags&TEXTURE_CLAMPV\r\n\t\t\t\t_d3ddev.SetSamplerState i,D3DSAMP_ADDRESSU,D3DTADDRESS_CLAMP\r\n\t\t\tElse\r\n\t\t\t\t_d3ddev.SetSamplerState i,D3DSAMP_ADDRESSV,D3DTADDRESS_WRAP\r\n\t\t\tEndIf\r\n\t\t\t\r\n\t\t\tIf texture._flags&TEXTURE_SPHMAP\r\n\t\t\t\t_d3ddev.SetTextureStageState i,D3DTSS_TEXCOORDINDEX,D3DTSS_TCI_SPHEREMAP\r\n\t\t\tElse\r\n\t\t\t\t_d3ddev.SetTextureStageState i,D3DTSS_TEXCOORDINDEX,texture._coords\r\n\t\t\tEndIf\r\n\t\t\t\r\n\t\t\t'_d3ddev.SetTextureStageState i,D3DTSS_COLOROP,D3DTOP_SELECTARG1\r\n\t\t\t'_d3ddev.SetTextureStageState i,D3DTSS_ALPHAOP,D3DTOP_SELECTARG2\r\n\t\t\t\r\n\t\t\tSelect texture._blend\r\n\t\t\tCase BLEND_ALPHA\r\n\t\t\t\t'glTexEnvf(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_DECAL)\r\n\t\t\tCase BLEND_MULTIPLY\r\n\t\t\t\t_d3ddev.SetTextureStageState i,D3DTSS_COLOROP,D3DTOP_MODULATE\r\n\t\t\t\t_d3ddev.SetTextureStageState i,D3DTSS_ALPHAOP,D3DTOP_MODULATE\r\n\t\t\tCase BLEND_ADD\r\n\t\t\t\t_d3ddev.SetTextureStageState i,D3DTSS_COLOROP,D3DTOP_ADD\r\n\t\t\t\t_d3ddev.SetTextureStageState i,D3DTSS_ALPHAOP,D3DTOP_ADD\r\n\t\t\tCase BLEND_DOT3\r\n\t\t\t\t_d3ddev.SetTextureStageState i,D3DTSS_COLOROP,D3DTOP_DOTPRODUCT3\r\n\t\t\t\t_d3ddev.SetTextureStageState i,D3DTSS_ALPHAOP,D3DTOP_DOTPRODUCT3\r\n\t\t\tCase BLEND_MULTIPLY2\r\n\t\t\t\t_d3ddev.SetTextureStageState i,D3DTSS_COLOROP,D3DTOP_MODULATE2X\r\n\t\t\t\t_d3ddev.SetTextureStageState i,D3DTSS_ALPHAOP,D3DTOP_MODULATE2X\r\n\t\t\tDefault\r\n\t\t\t\t_d3ddev.SetTextureStageState i,D3DTSS_COLOROP,D3DTOP_MODULATE\r\n\t\t\t\t_d3ddev.SetTextureStageState i,D3DTSS_ALPHAOP,D3DTOP_MODULATE\r\n\t\t\tEnd Select\t\t\t\r\n\t\tNext\r\n\tEnd Method\r\n\t\r\n\tMethod RenderSurface(resource:TSurfaceRes,brush:TBrush)\r\n\t\tLocal res:TD3D9SurfaceRes=TD3D9SurfaceRes(resource)\r\n\t\t\r\n\t\t_d3ddev.SetFVF 0\r\n\t\t_d3ddev.SetVertexDeclaration GetD3D9MaxB3DVertexDecl(_d3ddev)\r\n\t\t_d3ddev.SetStreamSource 0,res._pos,0,12\r\n\t\t_d3ddev.SetStreamSource 1,res._nml,0,12\r\n\t\t_d3ddev.SetStreamSource 2,res._clr,0,16\r\n\t\t_d3ddev.SetStreamSource 3,res._tex[0],0,8\r\n\t\t_d3ddev.SetIndices res._tri\r\n\t\t_d3ddev.DrawIndexedPrimitive D3DPT_TRIANGLELIST,0,0,res._vertexcnt,0,res._trianglecnt\r\n\r\n\t\tReturn res._trianglecnt\r\n\tEnd Method\r\n\t\r\n\tMethod RenderSprite(sprite:TSprite)\t\r\n\t\tGlobal _data#[]=[ -1.0, 1.0,0.0, 0.0,0.0,1.0, 0.0,0.0, ..\r\n\t\t 1.0, 1.0,0.0, 0.0,0.0,1.0, 1.0,0.0, ..\r\n\t\t -1.0,-1.0,0.0, 0.0,0.0,1.0, 0.0,1.0, ..\r\n\t\t 1.0,-1.0,0.0, 0.0,0.0,1.0, 1.0,1.0 ]\r\n\t\t\r\n\t\t_d3ddev.SetVertexDeclaration Null\r\n\t\t_d3ddev.SetFVF D3DFVF_XYZ|D3DFVF_NORMAL|D3DFVF_TEX1\r\n\t\t_d3ddev.DrawPrimitiveUP D3DPT_TRIANGLESTRIP,2,_data,8*4\r\n\tEnd Method\r\n\t\r\n\tMethod BeginEntityRender(entity:TEntity)\r\n\t\t_d3ddev.SetTransform D3DTS_WORLD,entity.GetMatrix(True).ToPtr()\r\n\tEnd Method\r\n\t\r\n\tMethod EndEntityRender(entity:TEntity)\r\n\tEnd Method\r\n\t\r\n\tMethod RenderPlane(plane:TPlane)\r\n\t\tLocal x#,y#,z#\r\n\t\tplane.GetScale x,y,z,True\r\n\r\n\t\tGlobal _data#[]=[ -1.0,0.0, 1.0, 0.0,1.0,0.0, 0.0,0.0, ..\r\n\t\t 1.0,0.0, 1.0, 0.0,1.0,0.0, x,0.0, ..\r\n\t\t -1.0,0.0,-1.0, 0.0,1.0,0.0, 0.0, z, ..\r\n\t\t 1.0,0.0,-1.0, 0.0,1.0,0.0, x, z ]\t\t\r\n\t\t\r\n\t\t_d3ddev.SetVertexDeclaration Null\r\n\t\t_d3ddev.SetFVF D3DFVF_XYZ|D3DFVF_NORMAL|D3DFVF_TEX1\r\n\t\t_d3ddev.DrawPrimitiveUP D3DPT_TRIANGLESTRIP,2,_data,8*4\r\n\tEnd Method\r\n\t\r\n\tMethod RenderTerrain(terrain:TTerrain)\r\n\tEnd Method\r\n\t\r\n\tMethod UpdateTextureRes:TD3D9TextureRes(texture:TTexture)\r\n\t\tLocal res:TD3D9TextureRes=TD3D9TextureRes(texture._res)\r\n\t\tIf res And texture._updateres=False Return res\r\n\r\n\t\tIf res=Null res=New TD3D9TextureRes\r\n\t\ttexture._res=res\r\n\t\t\r\n\t\tLocal pixmap:TPixmap=texture._pixmap\r\n\t\tLocal tex_width=Pow2Size(pixmap.width),tex_height=Pow2Size(pixmap.height)\r\n\t\tpixmap=ConvertPixmap(ResizePixmap(pixmap,tex_width,tex_height),PF_BGRA8888)\r\n\t\tIf res._tex=Null Assert _d3ddev.CreateTexture(tex_width,tex_height,(texture._flags & TEXTURE_MIPMAP)=0,D3DUSAGE_AUTOGENMIPMAP,D3DFMT_A8R8G8B8,D3DPOOL_MANAGED,res._tex,Null)=D3D_OK\r\n\t\t\r\n\t\tLocal rect:D3DLOCKED_RECT=New D3DLOCKED_RECT \r\n\t\tres._tex.LockRect 0,rect,Null,0\r\n\t\tMemCopy rect.pBits,pixmap.pixels,pixmap.width*pixmap.height*4\r\n\t\tres._tex.UnlockRect 0\r\n\t\t\r\n\t\ttexture._updateres=False\r\n\t\t\t\t\r\n\t\tReturn res\r\n\tEnd Method\r\n\t\r\n\tMethod UpdateSurfaceRes:TD3D9SurfaceRes(surface:TSurface)\r\n\t\tLocal res:TD3D9SurfaceRes=TD3D9SurfaceRes(surface._res)\r\n\t\tIf res=Null res=New TD3D9SurfaceRes;surface._reset=-1\r\n\t\t\r\n\t\tIf surface._reset=0 Return res\t\t\r\n\t\tIf surface._reset=-1 surface._reset=1|2|4|8|16|32|64|128|256\r\n\r\n\t\tIf surface._reset&1 And surface._vertexpos UploadVertexData res._pos,surface._vertexpos\r\n\t\tIf surface._reset&2 And surface._vertexnml UploadVertexData res._nml,surface._vertexnml\r\n\t\tIf surface._reset&4 And surface._vertexclr UploadVertexData res._clr,surface._vertexclr\r\n\t\tIf surface._reset&8 And surface._triangle\r\n\t\t\tIf res._tri=Null _d3ddev.CreateIndexBuffer(surface._triangle.length*4,0,D3DFMT_INDEX32,D3DPOOL_MANAGED,res._tri,Null)\r\n\t\t\tLocal dataptr:Byte Ptr\r\n\t\t\tAssert res._tri.Lock(0,0,dataptr,0)=D3D_OK,\"Failed to lock index buffer.\"\r\n\t\t\tMemCopy dataptr,surface._triangle,surface._triangle.length*4\t\t\r\n\t\t\tres._tri.Unlock()\r\n\t\tEndIf\r\n\t\t\r\n\t\tFor Local i=0 To surface._vertextex.length-1\r\n\t\t\tIf surface._reset&Int(2^(4+i)) UploadVertexData res._tex[i],surface._vertextex[i]\r\n\t\tNext\r\n\t\t\r\n\t\tres._trianglecnt=surface._trianglecnt\r\n\t\tres._vertexcnt=surface._vertexcnt\r\n\t\t\r\n\t\tsurface._reset=0\r\n\t\tsurface._res=res\r\n\t\t\r\n\t\tReturn res\r\n\tEnd Method\r\n\r\n\tMethod MergeSurfaceRes:TSurfaceRes(base:TSurface,animation:TSurface,data)\r\n\t\tIf animation=Null Return UpdateSurfaceRes(base)\r\n\t\tLocal base_res:TD3D9SurfaceRes=UpdateSurfaceRes(base)\r\n\t\tLocal anim_res:TD3D9SurfaceRes=UpdateSurfaceRes(animation)\r\n\t\tLocal res:TD3D9SurfaceRes=base_res.Copy()\r\n\t\tres._pos=anim_res._pos\r\n\t\tReturn res\r\n\tEnd Method\r\n\t\r\n\tMethod UploadVertexData(buffer:IDirect3DVertexBuffer9 Var,data#[])\r\n\t\tIf buffer=Null _d3ddev.CreateVertexBuffer(data.length*4,0,0,D3DPOOL_MANAGED,buffer,Null)\r\n\t\tLocal dataptr:Byte Ptr\r\n\t\tAssert buffer.Lock(0,0,dataptr,0)=D3D_OK,\"Failed to lock vertex buffer.\"\r\n\t\tMemCopy dataptr,data,data.length*4\t\t\r\n\t\tbuffer.Unlock()\r\n\tEnd Method\r\n\t\r\nEnd Type\r\n\r\nType TD3D9TextureRes Extends TTextureRes\r\n\tField _tex:IDirect3DTexture9\r\nEnd Type\r\n\r\nType TD3D9SurfaceRes Extends TSurfaceRes\r\n\tField _pos:IDirect3DVertexBuffer9\r\n\tField _nml:IDirect3DVertexBuffer9\r\n\tField _clr:IDirect3DVertexBuffer9\r\n\tField _tri:IDirect3DIndexBuffer9\r\n\tField _tex:IDirect3DVertexBuffer9[8]\r\n\t\r\n\tMethod Copy:TD3D9SurfaceRes()\r\n\t\tLocal res:TD3D9SurfaceRes=New TD3D9SurfaceRes\r\n\t\tres._vertexcnt=_vertexcnt;res._trianglecnt=_trianglecnt\r\n\t\tres._pos=_pos;res._nml=_nml;res._clr=_clr;res._tri=_tri;\r\n\t\tFor Local i=0 To 7\r\n\t\t\tres._tex[i]=_tex[i]\r\n\t\tNext\r\n\t\tReturn res\r\n\tEnd Method\r\nEnd Type\r\n\r\nRem\r\n\tbbdoc: Needs documentation. #TODO\r\nEnd Rem\r\nFunction D3D9MaxB3DDriver:TD3D9MaxB3DDriver()\r\n\tIf D3D9Max2DDriver()\r\n\t\tGlobal driver:TD3D9MaxB3DDriver=New TD3D9MaxB3DDriver\r\n\t\tdriver._parent=D3D9Max2DDriver()\r\n\t\tReturn driver\r\n\tEnd If\r\nEnd Function\r\n\r\nRem\r\n\tbbdoc: Utility function that sets the MaxB3D D3D9 driver and calls Graphics.\r\nEnd Rem\r\nFunction D3D9Graphics3D:TGraphics(width,height,depth=0,hertz=0,flags=0)\r\n\tSetGraphicsDriver D3D9MaxB3DDriver(),GRAPHICS_BACKBUFFER|GRAPHICS_DEPTHBUFFER\r\n\tReturn Graphics(width,height,depth,hertz,flags)\r\nEnd Function\r\n\r\nLocal driver:TD3D9MaxB3DDriver=D3D9MaxB3DDriver()\r\nIf driver SetGraphicsDriver driver,GRAPHICS_BACKBUFFER|GRAPHICS_DEPTHBUFFER\r\n\r\n?","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"eb3bbd5a4185e93f0e28a6f57ef1b32cf0b62854","subject":"can't optimise that out safely yet","message":"can't optimise that out safely yet\n","repos":"Leushenko\/blue-moon","old_file":"bluefoldsyntax.bmx","new_file":"bluefoldsyntax.bmx","new_contents":"\n' Blue Moon\n' FOLD delegates to normalize and check syntax, fold constant expressions\n\n' this file is a Private Include\n\n'SuperStrict\n\n'Import \"blueerror.bmx\"\n'Import \"TFold.bmx\"\n'Import \"blueparser.bmx\"\n\n\nType NormalizeFold\n\tField tbl:TMap\n\tFunction Make:NormalizeFold(tbl:NodeTable)\n\t\tLocal f:NormalizeFold = New NormalizeFold ; f.tbl = tbl.leaves ; Return f\n\tEnd Function\n\t\n\tMethod LeftAssociative:Node(n:Rose) { SumExpr MulExpr AndExpr RelExpr Expr }\t'restructure left-associative operations from a list to a tree\n\t\tLocal l:Node = n.Get(\"L\"), r:Rose = Rose(n.Get(\"R\"))\n\t\tFor Local c:Int = 0 Until r.arg.Length\n\t\t\tLocal rarg:Rose = Rose(r.arg[c])\n\t\t\tl = Rose.Make(rarg.arg[0].key, [l, rarg.arg[1]], [\"L\", \"R\"])\n\t\tNext\n\t\tReturn l\n\tEnd Method\n\tMethod RightAssociative:Node(n:Rose) { CatExpr PowExpr }\t'properly structure right-associative operations\n\t\tLocal l:Node = n.Get(\"L\"), r:Rose = Rose(n.Get(\"R\"))\n\t\tReturn Rose.Make(r.arg[0].key, [l, r.arg[1]], [\"L\", \"R\"])\n\tEnd Method\n\tMethod UnaryExpr:Node(n:Rose)\t'remove duplicate nots and negations, completely remove unary posate\n\t\tLocal ops:Rose = Rose(n.Get(\"op\")), ret:Node = n.Get(\"arg\")\n\t\tLocal op:String[ops.arg.Length], prevK:String = \"\", count:Int\n\t\tFor Local c:Int = 0 Until ops.arg.Length\n\t\t\tLocal key:String = ops.arg[c].key ; If key = \"minus\" Then key = \"negate\"\n\t\t\tIf prevK = key And (key = \"negate\" Or key = \"knot\")\n\t\t\t\tcount :- 1 ; If count Then prevK = op[count - 1] Else prevK = \"\"\n\t\t\tElseIf key <> \"plus\"\n\t\t\t\top[count] = key ; count :+ 1 ; prevK = key\n\t\t\tEndIf\n\t\tNext\n\t\tFor Local c:Int = count - 1 To 0 Step -1\n\t\t\tret = Rose.Make(op[c], [ret], Null)\n\t\tNext\n\t\tReturn ret\n\tEnd Method\n\tMethod TableCons:Node(n:Rose)\t'remove redundant levels from table constructor expressions\n\t\tn = Rose(n.Get(\"fields\"))\n\t\tIf n\n\t\t\tLocal rst:Int = 0 ; If n.arg.Length > 1 Then rst = Rose(n.arg[1]).arg.Length\n\t\t\tLocal arg:Node[] = New Node[1 + rst]\n\t\t\tFor Local c:Int = 1 Until arg.Length\n\t\t\t\targ[c] = Rose(Rose(n.arg[1]).arg[c - 1]).arg[1]\n\t\t\tNext\n\t\t\targ[0] = n.arg[0]\n\t\t\tLocal icount:Int = 1\n\t\t\tFor Local c:Int = 0 Until arg.Length\n\t\t\t\tLocal ac:Rose = Rose(arg[c])\n\t\t\t\t\n\t\t\t\tIf arg[c].key = \"FieldKey\"\t'these are actually useful unconverted (optimization)\n\t\t\t\t\targ[c] = Rose.Make(\"FieldKey\", [Node(Leaf.Make(\"fname\", Leaf(ac.arg[0]).val)), ac.arg[1]], ac.id)\n\t\t\t\t\t\n\t\t\t\tElseIf c = arg.Length - 1 And arg[c].key = \"dotdotdot\"\t'vararg initialization\n\t\t\t\t\targ[c] = Leaf.Make(\"va_init\", \"...\")\n\t\t\t\t\t\n\t\t\t\tElseIf c = arg.Length - 1 And (arg[c].key = \"fcall\" Or arg[c].key = \"mcall\")\t'var-ret initialization\n\t\t\t\t\targ[c] = Rose.Make(\"va_\" + ac.key, ac.arg, Null)\n\t\t\t\t\t\n\t\t\t\tElseIf arg[c].key <> \"FieldIndex\"\t'convert basic expressions to indexed expressions\n\t\t\t\t\tLocal idx:Node = Leaf.Make(\"dconst\", icount) ; icount :+ 1\n\t\t\t\t\targ[c] = Rose.Make(\"FieldIndex\", [idx, arg[c]], [\"key\", \"val\"])\n\t\t\t\tEndIf\n\t\t\tNext\n\t\t\targ :+ [Leaf.Make(\"icount\", icount)]\n\t\t\tReturn Rose.Make(\"TableCons\", arg)\n\t\tElse\n\t\t\tReturn Rose.Make(\"TableCons\", Null)\n\t\tEndIf\n\tEnd Method\n\t\n\tMethod LocalVar:Node(n:Rose) { Assgt }\t'balance sides of assignment or initialization\n\t\tLocal vals:Rose = Rose(n.Get(\"vals\")), vars:Rose = Rose(n.arg[0])\n\t\tIf vals = Null Then vals = Rose.Make(\"ExpList\", [Leaf.Make(\"nil\", \"nil\")])\n\t\t\n\t\tIf vals.arg.Length < vars.arg.Length\n\t\t\tLocal lastkey:String = vals.arg[vals.arg.Length - 1].key, extend:Int = Max(1, vars.arg.Length - (vals.arg.Length - 1))\n\t\t\t\n\t\t\tIf lastkey <> \"fcall\" And lastkey <> \"mcall\" And lastkey <> \"dotdotdot\"\t'polyvalue assignment doesn't extend\n\t\t\t\tLocal nv:Node[] = vals.arg[..vars.arg.Length], nil:Node = Leaf.Make(\"nil\", \"nil\")\n\t\t\t\tFor Local v:Int = vals.arg.Length Until nv.Length\n\t\t\t\t\tnv[v] = nil\n\t\t\t\tNext\n\t\t\t\tvals = Rose.Make(\"ExpList\", nv)\n\t\t\tElseIf lastkey = \"dotdotdot\"\t'mark required vararg values\n\t\t\t\tLocal valarg:Node[] = vals.arg[..]\n\t\t\t\tvalarg[valarg.Length - 1] = Leaf.Make(\"dotdotdot\", extend)\n\t\t\t\tvals = Rose.Make(vals.key, valarg)\n\t\t\tElse\t'adjust return count\n\t\t\t\tLocal call:Rose = Rose(vals.arg[vals.arg.Length - 1]), carg:Node[] = call.arg[..]\n\t\t\t\tcarg[2] = Leaf.Make(\"rcount\", extend)\n\t\t\t\tcall = Rose.Make(call.key, carg)\n\t\t\t\tLocal valarg:Node[] = vals.arg[..] ; valarg[valarg.Length - 1] = call\n\t\t\t\tvals = Rose.Make(vals.key, valarg)\n\t\t\tEndIf\n\t\t\t\n\t\tElseIf vars.arg.Length < vals.arg.Length\n\t\t\tLocal l:Int = vars.arg.Length ; vars = Rose.Make(vars.key, vars.arg[..vals.arg.Length])\n\t\t\tFor Local v:Int = l Until vals.arg.Length\t\t'too many vals: discard into a fake var\n\t\t\t\tvars.arg[v] = Leaf.Make(\"discard\", \"discard\")\n\t\t\tNext\n\t\tEndIf\n\t\t\n\t\tReturn Rose.Make(n.key, [vars, vals], [\"vars\", \"vals\"])\n\tEnd Method\n\t\n\tMethod Block:Node(n:Rose)\t'remove empty statements\n\t\tLocal old:Rose = Rose(n.arg[0])\n\t\tIf old\n\t\t\tLocal st:Node[] = New Node[old.arg.Length], count:Int = 0\n\t\t\tFor Local s:Int = 0 Until old.arg.Length\n\t\t\t\tLocal k:String = old.arg[s].key ; If k <> \"semicolon\" And k <> \"#Nil\"\n\t\t\t\t\tst[count] = old.arg[s] ; count :+ 1\n\t\t\t\tEndIf\n\t\t\tNext\n\t\t\tIf count\n\t\t\t\tReturn Rose.Make(\"Block\", st[..count])\n\t\t\tElse\n\t\t\t\tReturn Rose.Make(\"Block\", Null)\n\t\t\tEndIf\n\t\tElseIf NilNode(n.arg[0])\n\t\t\tReturn Rose.Make(\"Block\", Null)\n\t\tEndIf\n\t\tReturn n\n\tEnd Method\n\tMethod DoBlk:Node(n:Rose)\t'extract block; reduce indirection\n\t\tReturn n.arg[0]\n\tEnd Method\n\tMethod IfS:Node(n:Rose)\t'rewrite if\/elseif chains into nested regular if\/then\/else\n\t\tLocal elif:Rose = Rose(n.Get(\"elif\")), _else:Node = n.Get(\"else\")\n\t\tIf elif\n\t\t\tFor Local e:Int = elif.arg.Length - 1 To 0 Step -1\n\t\t\t\tIf _else\n\t\t\t\t\t_else = Rose.Make(\"IfS\", Rose(elif.arg[e]).arg + [_else], [\"test\", \"then\", \"else\"])\n\t\t\t\tElse\n\t\t\t\t\t_else = Rose.Make(\"IfS\", Rose(elif.arg[e]).arg, [\"test\", \"then\"])\n\t\t\t\tEndIf\n\t\t\tNext\n\t\t\tReturn Rose.Make(\"IfS\", n.arg[..2] + [_else], [\"test\", \"then\", \"else\"])\n\t'\tElse\n\t'\t\tReturn Rose.Make(\"IfS\", n.arg + [Rose.Make(\"Block\", Null)], [\"test\", \"then\", \"else\"])\n\t\tEndIf\n\t\tReturn n\n\tEnd Method\n\tMethod ForN:Node(n:Rose)\t'convert for loops to equivalent scoped-whiles\n\t\tGlobal rewrite:String = ..\n\t\t\"~n\tlocal var, limit, step = tonumber(e1), tonumber(e2), tonumber(e3)\" +..\t'building this with Make calls would be insane, and increase error surface\n\t\t\"~n\tif not (var and limit and step) then error() end\" +..\n\t\t\"~n\tvar = var - step\" +..\n\t\t\"~n\twhile true do\" +..\n\t\t\"~n\t\tvar = var + step\" +..\n\t\t\"~n\t\tif (step >= 0 and var > limit) or (step < 0 and var < limit) then\" +..\n\t\t\"~n\t\t\tbreak\" +..\n\t \t\"~n\t\tend\" +..\n\t \t\"~n\t\tlocal _var = var\" +..\n\t\t\"~n\t\t--block\" +..\n\t \t\"~n\tend~n\"\n\t\t\n\t\tGlobal rwast:TParseNode ; If rwast = Null Then rwast = BlueParseString(rewrite)\n\t\tLocal rwtbl:NodeTable = Node.FromParse(rwast), rw:Node = rwtbl.n\n\t\trw = Node.Fold(rw, NormalizeFold.Make(rwtbl))\n\t\t\n\t\tLocal v:Node = n.arg[0], f:Node = n.arg[1], t:Node = n.arg[2], s:Node = n.Get(\"step\"), b:Node = n.Get(\"block\")\n\t\tIf s = Null Then s = Leaf.Make(\"dconst\", \"1\")\t'ensure step is present\n\t\trw = Node.Fold(rw, FindReplaceFold.Make( ..\n\t\t\t[\"var\", \"limit\", \"step\", \"e1\", \"e2\", \"e3\", \"_var\"], ..\t'insert actual names and values into template\n\t\t\t[Node(Leaf.Make(\"name\", \"::var\")), Node(Leaf.Make(\"name\", \"::limit\")), Node(Leaf.Make(\"name\", \"::step\")), f, t, s, v]))\n\t\t\n\t\tRose(Rose(Rose(rw).arg[3]).arg[1]).arg :+ [b]\n\t\tReturn rw\n\tEnd Method\n\tMethod ForIn:Node(n:Rose)\n\t\tGlobal rewrite:String = ..\n\t\t\"~n\tlocal f, s, var = explist\" +..\t'doing it this way reduces error surface by reusing more of the same code machinery\n\t\t\"~n\twhile true do\" +..\n\t\t\"~n\t\tlocal var_1, var_2, var_n = f(s, var)\" +..\n\t\t\"~n\t\tif var_1 == nil then break end\" +..\n\t\t\"~n\t\tvar = var_1\" +..\n\t\t\"~n\t\t--block\" +..\n\t\t\"~n\tend~n\"\t'the outer `do` is removed here because it's added implicitly by the parser anyway\n\t\t\n\t\tGlobal rwast:TParseNode ; If rwast = Null Then rwast = BlueParseString(rewrite)\n\t\tLocal rwtbl:NodeTable = Node.FromParse(rwast), rw:Node = rwtbl.n\n\t\trw = Node.Fold(rw, NormalizeFold.Make(rwtbl))\n\t\t\n\t\tLocal va:Node = n.arg[0], v1:Node = Rose(va).arg[0], b:Node = n.arg[2]\n\t\trw = Node.Fold(rw, FindReplaceFold.Make( ..\n\t\t\t[\"f\", \"s\", \"var\", \"var_1\"], ..\t'insert actual names and values into template\n\t\t\t[Node(Leaf.Make(\"name\", \"::f\")), Node(Leaf.Make(\"name\", \"::s\")), Node(Leaf.Make(\"name\", \"::var\")), v1]))\n\t\t\n\t\tRose(Rose(rw).arg[0]).arg[1] = n.arg[1]\t'replace the expression list at declaration of ::f\/::s\/::var\n\t\tLocal wstmts:Node[] = Rose(Rose(Rose(rw).arg[1]).arg[1]).arg\n\t\twstmts :+ [b]\t'add the loop body to the list of statements in the new while loop\n\t\tRose(wstmts[0]).arg[0] = n.arg[0]\t'loop variables\n\t\t\n\t\tReturn rw\n\tEnd Method\n\t\n\tMethod FunDecl:Node(n:Rose)\t'replace function declarations with simple assignment\n\t\tLocal name:Node = n.Get(\"name\"), body:Rose = Rose(n.Get(\"body\"))\n\t\tIf name.key = \"MethodName\"\n\t\t\tLocal params:Rose = Rose(body.arg[0])\n\t\t\tparams = Rose.Make(params.key, [Leaf.Make(\"name\", \"self\")] + params.arg)\n\t\t\tbody = Rose.Make(body.key, [Node(params), body.arg[1]], body.id)\n\t\t\tname = Rose.Make(\"getfield\", Rose(name).arg)\n\t\tEndIf\n\t\tReturn Rose.Make(\"Assgt\", [Rose.Make(\"VarList\", [name]), Rose.Make(\"ExpList\", [body])], [\"vars\", \"vals\"])\n\tEnd Method\n\tMethod FuncName:Node(n:Rose)\t'convert function name expressions to var+fields (but leave trailing method name to FunDecl)\n\t\tLocal r:Node = n.Get(\"n\"), path:Rose = Rose(n.Get(\"path\")), meth:Rose = Rose(n.Get(\"method\"))\n\t\tIf path\n\t\t\tFor Local pe:Rose = EachIn path.arg\n\t\t\t\tLocal acc:Node = Leaf.Make(\"fname\", Leaf(pe.arg[1]).val)\n\t\t\t\tr = Rose.Make(\"getfield\", [r, acc])\n\t\t\tNext\n\t\tEndIf\n\t\tIf meth\n\t\t\tLocal mname:Node = Leaf.Make(\"fname\", Leaf(meth.arg[1]).val)\n\t\t\tr = Rose.Make(\"MethodName\", [r, mname])\t'package for FunDecl to rebrand as a get\n\t\tEndIf\n\t\tReturn r\n\tEnd Method\n\tMethod LocalFun:Node(n:Rose)\t'replace local function declarations with local assignment\n\t\tLocal nam:Node = n.Get(\"name\"), dec:Node = Rose.Make(\"LocalVar\", [..\n\t\t\tRose.Make(\"NameList\", [nam]), Rose.Make(\"ExpList\", [Leaf.Make(\"nil\", \"nil\")])], [\"names\", \"vals\"])\t'nil-init'd\n\t\tLocal asg:Node = Rose.Make(\"Assgt\", [Rose.Make(\"VarList\", [nam]), Rose.Make(\"ExpList\", [n.Get(\"body\")])], [\"vars\", \"vals\"])\n\t\tReturn Rose.Make(\"#EXPAND\", [dec, asg])\n\tEnd Method\n\tMethod FuncBody:Node(n:Rose)\t'reduce indirection on parameter list and straighten out varargs\n\t\tLocal param:Node = Rose(n.arg[0]).arg[0], plist:Rose = Rose(param)\n\t\tIf NilNode(param)\n\t\t\tparam = Rose.Make(\"NameList\", Null)\n\t\tElseIf param.key = \"dotdotdot\"\n\t\t\tparam = Rose.Make(\"NameList\", [param])\n\t\tElseIf plist And plist.arg.Length = 2 And plist.arg[1].key = \"dotdotdot\"\n\t\t\tparam = Rose.Make(\"NameList\", Rose(plist.arg[0]).arg + [plist.arg[1]])\n\t\tEndIf\n\t\tReturn Rose.Make(n.key, [param, n.arg[1]], n.id)\n\tEnd Method\n\t\n\tMethod GotoS:Node(n:Rose) { Label }\n\t\tLocal l:Leaf = Leaf(n.arg[0]), t:Object = tbl.ValueForKey(l) ; tbl.Remove(l)\t'modifying an error-able leaf means updating its error entry\n\t\tl = Leaf.Make(n.key, l.val) ; tbl.Insert(l, t)\n\t\tReturn l\n\tEnd Method\n\tMethod ReturnS:Node(n:Rose)\n\t\tLocal vals:Node[] = Null\n\t\tIf Rose(n.arg[0]) Then vals = Rose(n.arg[0]).arg\n\t\tReturn Rose.Make(n.key, vals)\n\tEnd Method\n\t\n\tMethod PostfixExp:Node(n:Rose)\t'rewrite element access\/function call chains into nested single ops\n\t\tLocal f:Node = n.arg[0], pl:Node[] = Rose(n.arg[1]).arg\n\t\tFor Local e:Int = 0 Until pl.Length\n\t\t\tSelect pl[e].key\n\t\t\t\tCase \"sconst\", \"TableCons\"\n\t\t\t\t\tf = Rose.Make(\"fcall\", [f, Node(Rose.Make(\"FArgs\", [pl[e]])), Node(Leaf.Make(\"rcount\", \"1\"))])\n\t\t\t\tCase \"FArgs\"\n\t\t\t\t\tf = Rose.Make(\"fcall\", [f, pl[e], Node(Leaf.Make(\"rcount\", \"1\"))])\t'add number of returned values\n\t\t\t\tCase \"MArgs\"\n\t\t\t\t\tLeaf(Rose(pl[e]).arg[0]).key = \"fname\"\n\t\t\t\t\tf = Rose.Make(\"mcall\", [f, pl[e], Node(Leaf.Make(\"rcount\", \"1\"))])\n\t\t\t\tCase \"ElemGet\"\n\t\t\t\t\tf = Rose.Make(\"index\", [f, Rose(pl[e]).arg[0]])\n\t\t\t\tCase \"FieldGet\"\n\t\t\t\t\tLocal acc:Node = Rose(pl[e]).arg[0] ; acc = Leaf.Make(\"fname\", Leaf(acc).val)\n\t\t\t\t\tf = Rose.Make(\"getfield\", [f, acc])\n\t\t\tEnd Select\n\t\tNext\n\t\tReturn f\n\tEnd Method\n\tMethod FArgs:Node(n:Rose)\t'clear empty arg lists and reduce indirection\n\t\tLocal al:Rose = Rose(n.arg[0])\n\t\tIf al Then Return Rose.Make(\"FArgs\", al.arg) Else Return Rose.Make(\"FArgs\", Null)\n\tEnd Method\n\t\n\tMethod dotdotdot:Node(n:Leaf)\n\t\tReturn Leaf.Make(\"dotdotdot\", \"1\")\n\tEnd Method\nEnd Type\n\nType FindReplaceFold\n\tField names:String[], vals:Node[]\n\t\n\tFunction Make:FindReplaceFold(names:String[], vals:Node[])\n\t\tLocal f:FindReplaceFold = New Self\n\t\tf.names = names ; f.vals = vals ; Return f\n\tEnd Function\n\t\n\tMethod name:Node(n:Leaf)\t'replace occurrences of names in the name array with the matching vals value\n\t\tFor Local i:Int = 0 Until names.Length\n\t\t\tIf names[i] = n.val Then Return vals[i]\n\t\tNext\n\t\tReturn n\n\tEnd Method\nEnd Type\n\nType ConstantFold\t'fold constant math and logic operations\n\tMethod hconst:Node(n:Leaf) { hfconst }\t'convert hex constants to uniform representation (unnecessary? BlitzMax natively supports 0x1a23p-4 format)\n\t\tReturn Leaf.Make(\"dconst\", String(Double(n.val)))\n\tEnd Method\n\t\n\tMethod BinMathOp:Node(n:Rose) { plus minus mul div kmod pow }\n\t\tConst DK:String = \"dconst\"\n\t\tIf n.arg[0].key = DK And n.arg[1].key = DK\n\t\t\tLocal l:Double = Double(Leaf(n.arg[0]).val), r:Double = Double(Leaf(n.arg[1]).val)\n\t\t\tSelect n.key\n\t\t\t\tCase \"plus\" ; l :+ r\n\t\t\t\tCase \"minus\" ; l :- r\n\t\t\t\tCase \"mul\" ; l :* r\n\t\t\t\tCase \"div\" ; l :\/ r\n\t\t\t\tCase \"kmod\" ; l = l Mod r\n\t\t\t\tCase \"pow\" ; l = l ^ r\n\t\t\tEnd Select\n\t\t\tReturn Leaf.Make(DK, l)\n\t\tElse\n\t\t\tReturn n\n\t\tEndIf\n\tEnd Method\n\tMethod UnaryOp:Node(n:Rose) { negate klen knot }\n\t\tLocal a:Leaf = Leaf(n.arg[0]) ; If a = Null Then Return n\n\t\tSelect n.key\n\t\t\tCase \"negate\"\n\t\t\t\tIf a.key = \"dconst\" Or a.key = \"sconst\"\t\t'BlitzMax natively supports Lua number formats, it's just the C one\n\t\t\t\t\tReturn Leaf.Make(\"dconst\", String(-Double(a.val)))\n\t\t\t\tEndIf\n\t\t\tCase \"not\"\n\t\t\t\tSelect a.key\n\t\t\t\t\tCase \"nil\", \"bconst\"\n\t\t\t\t\t\tIf a.val = \"true\" Then Return Leaf.Make(\"bconst\", \"false\") Else Return Leaf.Make(\"bconst\", \"true\")\n\t\t\t\t\tCase \"dconst\", \"sconst\"\n\t\t\t\t\t\tReturn Leaf.Make(\"bconst\", \"false\")\n\t\t\t\tEnd Select\n\t\tEnd Select\n\t\tReturn n\n\tEnd Method\n\tMethod AndExpr:Node(n:Rose) { Expr }\t'optimize short-circuit operators with constant first operand\n\t\tLocal l:Leaf = Leaf(n.arg[0])\n\t\tIf l\n\t\t\tIf l.key = \"sconst\" Or l.key = \"dconst\" Or (l.key = \"bconst\" And l.val = \"true\")\n\t\t\t\tIf n.key = \"kor\" Then Return l Else Return n.arg[1]\n\t\t\tElseIf l.key = \"nil\" Or (l.key = \"bconst\" And l.val = \"false\")\n\t\t\t\tIf n.key = \"kor\" Then Return n.arg[1] Else Return l\n\t\t\tEndIf\n\t\tEndIf\n\t\tReturn n\n\tEnd Method\n\tMethod eq:Node(n:Rose) { neq }\n\t\tLocal l:Leaf = Leaf(n.arg[0]), r:Leaf = Leaf(n.arg[1])\n\t\tIf l <> Null And r <> Null And l.key = r.key\n\t\t\tGlobal rv:String[] = [\"false\", \"true\"]\n\t\t\tSelect l.key\n\t\t\t\tCase \"bconst\", \"sconst\" ; Return Leaf.Make(\"bconst\", rv[(n.key = \"eq\") * (l.val = r.val)])\n\t\t\t\tCase \"dconst\" ; Return Leaf.Make(\"bconst\", rv[(n.key = \"eq\") * (Double(l.val) = Double(r.val))])\t'it's fine when they're constants\n\t\t\tEnd Select\n\t\tEndIf\n\t\tReturn n\n\tEnd Method\n\tMethod lt:Node(n:Rose) { gt leq geq }\n\t\tLocal l:Leaf = Leaf(n.arg[0]), r:Leaf = Leaf(n.arg[1])\n\t\tIf l <> Null And r <> Null And l.key = \"dconst\" And r.key = \"dconst\"\t'string comparisons are affected by runtime locale\n\t\t\tGlobal rv:String[] = [\"false\", \"true\"] ; Local ret:Int\n\t\t\tSelect n.key\n\t\t\t\tCase \"gt\" ; ret = Double(l.val) > Double(r.val)\n\t\t\t\tCase \"lt\" ; ret = Double(l.val) < Double(r.val)\n\t\t\t\tCase \"geq\" ; ret = Double(l.val) >= Double(r.val)\n\t\t\t\tCase \"neq\" ; ret = Double(l.val) <= Double(r.val)\n\t\t\tEnd Select\n\t\t\tReturn Leaf.Make(\"bconst\", rv[ret])\n\t\tEndIf\n\t\tReturn n\n\tEnd Method\n\t\n\tMethod IfS:Node(n:Rose)\t'unpack constant if structures\n\t\tLocal test:Leaf = Leaf(n.arg[0])\n\t\tIf test\n\t\t\tSelect test.key\n\t\t\t\tCase \"bconst\", \"dconst\", \"sconst\", \"nil\"\n\t\t\t\t\tIf (test.key = \"bconst\" And test.val = \"False\") Or test.key = \"nil\"\n\t\t\t\t\t\tIf n.Get(\"else\") Then Return n.Get(\"else\") Else Return Null\n\t\t\t\t\tElse\n\t\t\t\t\t\tReturn n.Get(\"then\")\n\t\t\t\t\tEndIf\n\t\t\tEnd Select\n\t\tEndIf\n\t\tReturn n\n\tEnd Method\n\tMethod WhileS:Node(n:Rose)\t'remove while(false)\n\t\tLocal test:Leaf = Leaf(n.arg[0])\n\t\tIf test And ((test.key = \"bconst\" And test.val = \"false\") Or (test.key = \"nil\")) Then Return Null\n\t\tReturn n\n\tEnd Method\n\tMethod RepeatS:Node(n:Rose)\t'replace repeat...until(false) with a while\n\t\tLocal t:Leaf = Leaf(n.Get(\"test\"))\n\t\tIf t\n\t\t\tIf t.key = \"nil\" Or (t.key = \"bconst\" And t.val = \"false\")\n\t\t\t\tReturn Rose.Make(\"WhileS\", [Node(Leaf.Make(\"bconst\", \"true\")), n.Get(\"block\")], [\"test\", \"block\"])\n\t\t'\tElseIf t.key = \"dconst\" Or t.key = \"sconst\" Or (t.key = \"bconst\" And t.val = \"true\")\n\t\t'\t\tReturn n.Get(\"block\")\n\t\t\tEndIf\n\t\tEndIf\n\t\tReturn n\n\tEnd Method\nEnd Type\n\nType SyntaxErrFold\t'report any remaining syntax errors\n\tField tbl:TMap, breaks:TList\n\tFunction Make:SyntaxErrFold(tbl:NodeTable)\n\t\tLocal f:SyntaxErrFold = New SyntaxErrFold\n\t\tf.tbl = tbl.leaves ; f.breaks = CreateList()\n\t\tReturn f\n\tEnd Function\n\t\n\tMethod Block:Node(n:Rose)\t'scan for non-statements\n\t\tFor Local s:Int = 0 Until n.arg.Length\n\t\t\tSelect n.arg[s].key\n\t\t\t\tCase \"fcall\", \"mcall\"\n\t\t\t\t\tn.arg[s].key = \"p\" + n.arg[s].key\n\t\t\t\tCase \"Assgt\", \"break\", \"GotoS\", \"Label\", \"Block\", \"WhileS\", \"RepeatS\", \"IfS\", \"LocalVar\", \"ReturnS\"', \"ForN\", \"ForIn\"\n\t\t\t\tDefault\n\t\t\t\t\tThrow BlueCompileError.Make(TToken(tbl.ValueForKey(n.arg[s])), \"invalid statement in statement block\")\n\t\t\tEnd Select\n\t\tNext\n\t\tReturn n\n\tEnd Method\n\t\n\tMethod break:Node(n:Leaf)\t'add breaks to a stack...\n\t\tbreaks.AddFirst(n) ; Return n\n\tEnd Method\n\tMethod AllLoops:Node(n:Rose) { WhileS RepeatS } 'ForN ForIn }\t'...then remove them\n\t\tbreaks.Clear() ; Return n\n\tEnd Method\n\tMethod FuncBody:Node(n:Rose)\t'...and error on any that weren't removed\n\t\tSelf.BreakCheck() ; Return n\n\tEnd Method\n\t\n\tMethod BreakCheck()\t'need to call this externally for toplevel too\n\t\tIf breaks.Count() Then Throw BlueCompileError.Make(TToken(tbl.ValueForKey(breaks.First())), \"'break' statement without containing loop\")\n\tEnd Method\nEnd Type\n\n","old_contents":"\n' Blue Moon\n' FOLD delegates to normalize and check syntax, fold constant expressions\n\n' this file is a Private Include\n\n'SuperStrict\n\n'Import \"blueerror.bmx\"\n'Import \"TFold.bmx\"\n'Import \"blueparser.bmx\"\n\n\nType NormalizeFold\n\tField tbl:TMap\n\tFunction Make:NormalizeFold(tbl:NodeTable)\n\t\tLocal f:NormalizeFold = New NormalizeFold ; f.tbl = tbl.leaves ; Return f\n\tEnd Function\n\t\n\tMethod LeftAssociative:Node(n:Rose) { SumExpr MulExpr AndExpr RelExpr Expr }\t'restructure left-associative operations from a list to a tree\n\t\tLocal l:Node = n.Get(\"L\"), r:Rose = Rose(n.Get(\"R\"))\n\t\tFor Local c:Int = 0 Until r.arg.Length\n\t\t\tLocal rarg:Rose = Rose(r.arg[c])\n\t\t\tl = Rose.Make(rarg.arg[0].key, [l, rarg.arg[1]], [\"L\", \"R\"])\n\t\tNext\n\t\tReturn l\n\tEnd Method\n\tMethod RightAssociative:Node(n:Rose) { CatExpr PowExpr }\t'properly structure right-associative operations\n\t\tLocal l:Node = n.Get(\"L\"), r:Rose = Rose(n.Get(\"R\"))\n\t\tReturn Rose.Make(r.arg[0].key, [l, r.arg[1]], [\"L\", \"R\"])\n\tEnd Method\n\tMethod UnaryExpr:Node(n:Rose)\t'remove duplicate nots and negations, completely remove unary posate\n\t\tLocal ops:Rose = Rose(n.Get(\"op\")), ret:Node = n.Get(\"arg\")\n\t\tLocal op:String[ops.arg.Length], prevK:String = \"\", count:Int\n\t\tFor Local c:Int = 0 Until ops.arg.Length\n\t\t\tLocal key:String = ops.arg[c].key ; If key = \"minus\" Then key = \"negate\"\n\t\t\tIf prevK = key And (key = \"negate\" Or key = \"knot\")\n\t\t\t\tcount :- 1 ; If count Then prevK = op[count - 1] Else prevK = \"\"\n\t\t\tElseIf key <> \"plus\"\n\t\t\t\top[count] = key ; count :+ 1 ; prevK = key\n\t\t\tEndIf\n\t\tNext\n\t\tFor Local c:Int = count - 1 To 0 Step -1\n\t\t\tret = Rose.Make(op[c], [ret], Null)\n\t\tNext\n\t\tReturn ret\n\tEnd Method\n\tMethod TableCons:Node(n:Rose)\t'remove redundant levels from table constructor expressions\n\t\tn = Rose(n.Get(\"fields\"))\n\t\tIf n\n\t\t\tLocal rst:Int = 0 ; If n.arg.Length > 1 Then rst = Rose(n.arg[1]).arg.Length\n\t\t\tLocal arg:Node[] = New Node[1 + rst]\n\t\t\tFor Local c:Int = 1 Until arg.Length\n\t\t\t\targ[c] = Rose(Rose(n.arg[1]).arg[c - 1]).arg[1]\n\t\t\tNext\n\t\t\targ[0] = n.arg[0]\n\t\t\tLocal icount:Int = 1\n\t\t\tFor Local c:Int = 0 Until arg.Length\n\t\t\t\tLocal ac:Rose = Rose(arg[c])\n\t\t\t\t\n\t\t\t\tIf arg[c].key = \"FieldKey\"\t'these are actually useful unconverted (optimization)\n\t\t\t\t\targ[c] = Rose.Make(\"FieldKey\", [Node(Leaf.Make(\"fname\", Leaf(ac.arg[0]).val)), ac.arg[1]], ac.id)\n\t\t\t\t\t\n\t\t\t\tElseIf c = arg.Length - 1 And arg[c].key = \"dotdotdot\"\t'vararg initialization\n\t\t\t\t\targ[c] = Leaf.Make(\"va_init\", \"...\")\n\t\t\t\t\t\n\t\t\t\tElseIf c = arg.Length - 1 And (arg[c].key = \"fcall\" Or arg[c].key = \"mcall\")\t'var-ret initialization\n\t\t\t\t\targ[c] = Rose.Make(\"va_\" + ac.key, ac.arg, Null)\n\t\t\t\t\t\n\t\t\t\tElseIf arg[c].key <> \"FieldIndex\"\t'convert basic expressions to indexed expressions\n\t\t\t\t\tLocal idx:Node = Leaf.Make(\"dconst\", icount) ; icount :+ 1\n\t\t\t\t\targ[c] = Rose.Make(\"FieldIndex\", [idx, arg[c]], [\"key\", \"val\"])\n\t\t\t\tEndIf\n\t\t\tNext\n\t\t\targ :+ [Leaf.Make(\"icount\", icount)]\n\t\t\tReturn Rose.Make(\"TableCons\", arg)\n\t\tElse\n\t\t\tReturn Rose.Make(\"TableCons\", Null)\n\t\tEndIf\n\tEnd Method\n\t\n\tMethod LocalVar:Node(n:Rose) { Assgt }\t'balance sides of assignment or initialization\n\t\tLocal vals:Rose = Rose(n.Get(\"vals\")), vars:Rose = Rose(n.arg[0])\n\t\tIf vals = Null Then vals = Rose.Make(\"ExpList\", [Leaf.Make(\"nil\", \"nil\")])\n\t\t\n\t\tIf vals.arg.Length < vars.arg.Length\n\t\t\tLocal lastkey:String = vals.arg[vals.arg.Length - 1].key, extend:Int = Max(1, vars.arg.Length - (vals.arg.Length - 1))\n\t\t\t\n\t\t\tIf lastkey <> \"fcall\" And lastkey <> \"mcall\" And lastkey <> \"dotdotdot\"\t'polyvalue assignment doesn't extend\n\t\t\t\tLocal nv:Node[] = vals.arg[..vars.arg.Length], nil:Node = Leaf.Make(\"nil\", \"nil\")\n\t\t\t\tFor Local v:Int = vals.arg.Length Until nv.Length\n\t\t\t\t\tnv[v] = nil\n\t\t\t\tNext\n\t\t\t\tvals = Rose.Make(\"ExpList\", nv)\n\t\t\tElseIf lastkey = \"dotdotdot\"\t'mark required vararg values\n\t\t\t\tLocal valarg:Node[] = vals.arg[..]\n\t\t\t\tvalarg[valarg.Length - 1] = Leaf.Make(\"dotdotdot\", extend)\n\t\t\t\tvals = Rose.Make(vals.key, valarg)\n\t\t\tElse\t'adjust return count\n\t\t\t\tLocal call:Rose = Rose(vals.arg[vals.arg.Length - 1]), carg:Node[] = call.arg[..]\n\t\t\t\tcarg[2] = Leaf.Make(\"rcount\", extend)\n\t\t\t\tcall = Rose.Make(call.key, carg)\n\t\t\t\tLocal valarg:Node[] = vals.arg[..] ; valarg[valarg.Length - 1] = call\n\t\t\t\tvals = Rose.Make(vals.key, valarg)\n\t\t\tEndIf\n\t\t\t\n\t\tElseIf vars.arg.Length < vals.arg.Length\n\t\t\tLocal l:Int = vars.arg.Length ; vars = Rose.Make(vars.key, vars.arg[..vals.arg.Length])\n\t\t\tFor Local v:Int = l Until vals.arg.Length\t\t'too many vals: discard into a fake var\n\t\t\t\tvars.arg[v] = Leaf.Make(\"discard\", \"discard\")\n\t\t\tNext\n\t\tEndIf\n\t\t\n\t\tReturn Rose.Make(n.key, [vars, vals], [\"vars\", \"vals\"])\n\tEnd Method\n\t\n\tMethod Block:Node(n:Rose)\t'remove empty statements\n\t\tLocal old:Rose = Rose(n.arg[0])\n\t\tIf old\n\t\t\tLocal st:Node[] = New Node[old.arg.Length], count:Int = 0\n\t\t\tFor Local s:Int = 0 Until old.arg.Length\n\t\t\t\tLocal k:String = old.arg[s].key ; If k <> \"semicolon\" And k <> \"#Nil\"\n\t\t\t\t\tst[count] = old.arg[s] ; count :+ 1\n\t\t\t\tEndIf\n\t\t\tNext\n\t\t\tIf count\n\t\t\t\tReturn Rose.Make(\"Block\", st[..count])\n\t\t\tElse\n\t\t\t\tReturn Rose.Make(\"Block\", Null)\n\t\t\tEndIf\n\t\tElseIf NilNode(n.arg[0])\n\t\t\tReturn Rose.Make(\"Block\", Null)\n\t\tEndIf\n\t\tReturn n\n\tEnd Method\n\tMethod DoBlk:Node(n:Rose)\t'extract block; reduce indirection\n\t\tReturn n.arg[0]\n\tEnd Method\n\tMethod IfS:Node(n:Rose)\t'rewrite if\/elseif chains into nested regular if\/then\/else\n\t\tLocal elif:Rose = Rose(n.Get(\"elif\")), _else:Node = n.Get(\"else\")\n\t\tIf elif\n\t\t\tFor Local e:Int = elif.arg.Length - 1 To 0 Step -1\n\t\t\t\tIf _else\n\t\t\t\t\t_else = Rose.Make(\"IfS\", Rose(elif.arg[e]).arg + [_else], [\"test\", \"then\", \"else\"])\n\t\t\t\tElse\n\t\t\t\t\t_else = Rose.Make(\"IfS\", Rose(elif.arg[e]).arg, [\"test\", \"then\"])\n\t\t\t\tEndIf\n\t\t\tNext\n\t\t\tReturn Rose.Make(\"IfS\", n.arg[..2] + [_else], [\"test\", \"then\", \"else\"])\n\t'\tElse\n\t'\t\tReturn Rose.Make(\"IfS\", n.arg + [Rose.Make(\"Block\", Null)], [\"test\", \"then\", \"else\"])\n\t\tEndIf\n\t\tReturn n\n\tEnd Method\n\tMethod ForN:Node(n:Rose)\t'convert for loops to equivalent scoped-whiles\n\t\tGlobal rewrite:String = ..\n\t\t\"~n\tlocal var, limit, step = tonumber(e1), tonumber(e2), tonumber(e3)\" +..\t'building this with Make calls would be insane, and increase error surface\n\t\t\"~n\tif not (var and limit and step) then error() end\" +..\n\t\t\"~n\tvar = var - step\" +..\n\t\t\"~n\twhile true do\" +..\n\t\t\"~n\t\tvar = var + step\" +..\n\t\t\"~n\t\tif (step >= 0 and var > limit) or (step < 0 and var < limit) then\" +..\n\t\t\"~n\t\t\tbreak\" +..\n\t \t\"~n\t\tend\" +..\n\t \t\"~n\t\tlocal _var = var\" +..\n\t\t\"~n\t\t--block\" +..\n\t \t\"~n\tend~n\"\n\t\t\n\t\tGlobal rwast:TParseNode ; If rwast = Null Then rwast = BlueParseString(rewrite)\n\t\tLocal rwtbl:NodeTable = Node.FromParse(rwast), rw:Node = rwtbl.n\n\t\trw = Node.Fold(rw, NormalizeFold.Make(rwtbl))\n\t\t\n\t\tLocal v:Node = n.arg[0], f:Node = n.arg[1], t:Node = n.arg[2], s:Node = n.Get(\"step\"), b:Node = n.Get(\"block\")\n\t\tIf s = Null Then s = Leaf.Make(\"dconst\", \"1\")\t'ensure step is present\n\t\trw = Node.Fold(rw, FindReplaceFold.Make( ..\n\t\t\t[\"var\", \"limit\", \"step\", \"e1\", \"e2\", \"e3\", \"_var\"], ..\t'insert actual names and values into template\n\t\t\t[Node(Leaf.Make(\"name\", \"::var\")), Node(Leaf.Make(\"name\", \"::limit\")), Node(Leaf.Make(\"name\", \"::step\")), f, t, s, v]))\n\t\t\n\t\tRose(Rose(Rose(rw).arg[3]).arg[1]).arg :+ [b]\n\t\tReturn rw\n\tEnd Method\n\tMethod ForIn:Node(n:Rose)\n\t\tGlobal rewrite:String = ..\n\t\t\"~n\tlocal f, s, var = explist\" +..\t'doing it this way reduces error surface by reusing more of the same code machinery\n\t\t\"~n\twhile true do\" +..\n\t\t\"~n\t\tlocal var_1, var_2, var_n = f(s, var)\" +..\n\t\t\"~n\t\tif var_1 == nil then break end\" +..\n\t\t\"~n\t\tvar = var_1\" +..\n\t\t\"~n\t\t--block\" +..\n\t\t\"~n\tend~n\"\t'the outer `do` is removed here because it's added implicitly by the parser anyway\n\t\t\n\t\tGlobal rwast:TParseNode ; If rwast = Null Then rwast = BlueParseString(rewrite)\n\t\tLocal rwtbl:NodeTable = Node.FromParse(rwast), rw:Node = rwtbl.n\n\t\trw = Node.Fold(rw, NormalizeFold.Make(rwtbl))\n\t\t\n\t\tLocal va:Node = n.arg[0], v1:Node = Rose(va).arg[0], b:Node = n.arg[2]\n\t\trw = Node.Fold(rw, FindReplaceFold.Make( ..\n\t\t\t[\"f\", \"s\", \"var\", \"var_1\"], ..\t'insert actual names and values into template\n\t\t\t[Node(Leaf.Make(\"name\", \"::f\")), Node(Leaf.Make(\"name\", \"::s\")), Node(Leaf.Make(\"name\", \"::var\")), v1]))\n\t\t\n\t\tRose(Rose(rw).arg[0]).arg[1] = n.arg[1]\t'replace the expression list at declaration of ::f\/::s\/::var\n\t\tLocal wstmts:Node[] = Rose(Rose(Rose(rw).arg[1]).arg[1]).arg\n\t\twstmts :+ [b]\t'add the loop body to the list of statements in the new while loop\n\t\tRose(wstmts[0]).arg[0] = n.arg[0]\t'loop variables\n\t\t\n\t\tReturn rw\n\tEnd Method\n\t\n\tMethod FunDecl:Node(n:Rose)\t'replace function declarations with simple assignment\n\t\tLocal name:Node = n.Get(\"name\"), body:Rose = Rose(n.Get(\"body\"))\n\t\tIf name.key = \"MethodName\"\n\t\t\tLocal params:Rose = Rose(body.arg[0])\n\t\t\tparams = Rose.Make(params.key, [Leaf.Make(\"name\", \"self\")] + params.arg)\n\t\t\tbody = Rose.Make(body.key, [Node(params), body.arg[1]], body.id)\n\t\t\tname = Rose.Make(\"getfield\", Rose(name).arg)\n\t\tEndIf\n\t\tReturn Rose.Make(\"Assgt\", [Rose.Make(\"VarList\", [name]), Rose.Make(\"ExpList\", [body])], [\"vars\", \"vals\"])\n\tEnd Method\n\tMethod FuncName:Node(n:Rose)\t'convert function name expressions to var+fields (but leave trailing method name to FunDecl)\n\t\tLocal r:Node = n.Get(\"n\"), path:Rose = Rose(n.Get(\"path\")), meth:Rose = Rose(n.Get(\"method\"))\n\t\tIf path\n\t\t\tFor Local pe:Rose = EachIn path.arg\n\t\t\t\tLocal acc:Node = Leaf.Make(\"fname\", Leaf(pe.arg[1]).val)\n\t\t\t\tr = Rose.Make(\"getfield\", [r, acc])\n\t\t\tNext\n\t\tEndIf\n\t\tIf meth\n\t\t\tLocal mname:Node = Leaf.Make(\"fname\", Leaf(meth.arg[1]).val)\n\t\t\tr = Rose.Make(\"MethodName\", [r, mname])\t'package for FunDecl to rebrand as a get\n\t\tEndIf\n\t\tReturn r\n\tEnd Method\n\tMethod LocalFun:Node(n:Rose)\t'replace local function declarations with local assignment\n\t\tLocal nam:Node = n.Get(\"name\"), dec:Node = Rose.Make(\"LocalVar\", [..\n\t\t\tRose.Make(\"NameList\", [nam]), Rose.Make(\"ExpList\", [Leaf.Make(\"nil\", \"nil\")])], [\"names\", \"vals\"])\t'nil-init'd\n\t\tLocal asg:Node = Rose.Make(\"Assgt\", [Rose.Make(\"VarList\", [nam]), Rose.Make(\"ExpList\", [n.Get(\"body\")])], [\"vars\", \"vals\"])\n\t\tReturn Rose.Make(\"#EXPAND\", [dec, asg])\n\tEnd Method\n\tMethod FuncBody:Node(n:Rose)\t'reduce indirection on parameter list and straighten out varargs\n\t\tLocal param:Node = Rose(n.arg[0]).arg[0], plist:Rose = Rose(param)\n\t\tIf NilNode(param)\n\t\t\tparam = Rose.Make(\"NameList\", Null)\n\t\tElseIf param.key = \"dotdotdot\"\n\t\t\tparam = Rose.Make(\"NameList\", [param])\n\t\tElseIf plist And plist.arg.Length = 2 And plist.arg[1].key = \"dotdotdot\"\n\t\t\tparam = Rose.Make(\"NameList\", Rose(plist.arg[0]).arg + [plist.arg[1]])\n\t\tEndIf\n\t\tReturn Rose.Make(n.key, [param, n.arg[1]], n.id)\n\tEnd Method\n\t\n\tMethod GotoS:Node(n:Rose) { Label }\n\t\tLocal l:Leaf = Leaf(n.arg[0]), t:Object = tbl.ValueForKey(l) ; tbl.Remove(l)\t'modifying an error-able leaf means updating its error entry\n\t\tl = Leaf.Make(n.key, l.val) ; tbl.Insert(l, t)\n\t\tReturn l\n\tEnd Method\n\tMethod ReturnS:Node(n:Rose)\n\t\tLocal vals:Node[] = Null\n\t\tIf Rose(n.arg[0]) Then vals = Rose(n.arg[0]).arg\n\t\tReturn Rose.Make(n.key, vals)\n\tEnd Method\n\t\n\tMethod PostfixExp:Node(n:Rose)\t'rewrite element access\/function call chains into nested single ops\n\t\tLocal f:Node = n.arg[0], pl:Node[] = Rose(n.arg[1]).arg\n\t\tFor Local e:Int = 0 Until pl.Length\n\t\t\tSelect pl[e].key\n\t\t\t\tCase \"sconst\", \"TableCons\"\n\t\t\t\t\tf = Rose.Make(\"fcall\", [f, Node(Rose.Make(\"FArgs\", [pl[e]])), Node(Leaf.Make(\"rcount\", \"1\"))])\n\t\t\t\tCase \"FArgs\"\n\t\t\t\t\tf = Rose.Make(\"fcall\", [f, pl[e], Node(Leaf.Make(\"rcount\", \"1\"))])\t'add number of returned values\n\t\t\t\tCase \"MArgs\"\n\t\t\t\t\tLeaf(Rose(pl[e]).arg[0]).key = \"fname\"\n\t\t\t\t\tf = Rose.Make(\"mcall\", [f, pl[e], Node(Leaf.Make(\"rcount\", \"1\"))])\n\t\t\t\tCase \"ElemGet\"\n\t\t\t\t\tf = Rose.Make(\"index\", [f, Rose(pl[e]).arg[0]])\n\t\t\t\tCase \"FieldGet\"\n\t\t\t\t\tLocal acc:Node = Rose(pl[e]).arg[0] ; acc = Leaf.Make(\"fname\", Leaf(acc).val)\n\t\t\t\t\tf = Rose.Make(\"getfield\", [f, acc])\n\t\t\tEnd Select\n\t\tNext\n\t\tReturn f\n\tEnd Method\n\tMethod FArgs:Node(n:Rose)\t'clear empty arg lists and reduce indirection\n\t\tLocal al:Rose = Rose(n.arg[0])\n\t\tIf al Then Return Rose.Make(\"FArgs\", al.arg) Else Return Rose.Make(\"FArgs\", Null)\n\tEnd Method\n\t\n\tMethod dotdotdot:Node(n:Leaf)\n\t\tReturn Leaf.Make(\"dotdotdot\", \"1\")\n\tEnd Method\nEnd Type\n\nType FindReplaceFold\n\tField names:String[], vals:Node[]\n\t\n\tFunction Make:FindReplaceFold(names:String[], vals:Node[])\n\t\tLocal f:FindReplaceFold = New Self\n\t\tf.names = names ; f.vals = vals ; Return f\n\tEnd Function\n\t\n\tMethod name:Node(n:Leaf)\t'replace occurrences of names in the name array with the matching vals value\n\t\tFor Local i:Int = 0 Until names.Length\n\t\t\tIf names[i] = n.val Then Return vals[i]\n\t\tNext\n\t\tReturn n\n\tEnd Method\nEnd Type\n\nType ConstantFold\t'fold constant math and logic operations\n\tMethod hconst:Node(n:Leaf) { hfconst }\t'convert hex constants to uniform representation (unnecessary? BlitzMax natively supports 0x1a23p-4 format)\n\t\tReturn Leaf.Make(\"dconst\", String(Double(n.val)))\n\tEnd Method\n\t\n\tMethod BinMathOp:Node(n:Rose) { plus minus mul div kmod pow }\n\t\tConst DK:String = \"dconst\"\n\t\tIf n.arg[0].key = DK And n.arg[1].key = DK\n\t\t\tLocal l:Double = Double(Leaf(n.arg[0]).val), r:Double = Double(Leaf(n.arg[1]).val)\n\t\t\tSelect n.key\n\t\t\t\tCase \"plus\" ; l :+ r\n\t\t\t\tCase \"minus\" ; l :- r\n\t\t\t\tCase \"mul\" ; l :* r\n\t\t\t\tCase \"div\" ; l :\/ r\n\t\t\t\tCase \"kmod\" ; l = l Mod r\n\t\t\t\tCase \"pow\" ; l = l ^ r\n\t\t\tEnd Select\n\t\t\tReturn Leaf.Make(DK, l)\n\t\tElse\n\t\t\tReturn n\n\t\tEndIf\n\tEnd Method\n\tMethod UnaryOp:Node(n:Rose) { negate klen knot }\n\t\tLocal a:Leaf = Leaf(n.arg[0]) ; If a = Null Then Return n\n\t\tSelect n.key\n\t\t\tCase \"negate\"\n\t\t\t\tIf a.key = \"dconst\" Or a.key = \"sconst\"\t\t'BlitzMax natively supports Lua number formats, it's just the C one\n\t\t\t\t\tReturn Leaf.Make(\"dconst\", String(-Double(a.val)))\n\t\t\t\tEndIf\n\t\t\tCase \"not\"\n\t\t\t\tSelect a.key\n\t\t\t\t\tCase \"nil\", \"bconst\"\n\t\t\t\t\t\tIf a.val = \"true\" Then Return Leaf.Make(\"bconst\", \"false\") Else Return Leaf.Make(\"bconst\", \"true\")\n\t\t\t\t\tCase \"dconst\", \"sconst\"\n\t\t\t\t\t\tReturn Leaf.Make(\"bconst\", \"false\")\n\t\t\t\tEnd Select\n\t\tEnd Select\n\t\tReturn n\n\tEnd Method\n\tMethod AndExpr:Node(n:Rose) { Expr }\t'optimize short-circuit operators with constant first operand\n\t\tLocal l:Leaf = Leaf(n.arg[0])\n\t\tIf l\n\t\t\tIf l.key = \"sconst\" Or l.key = \"dconst\" Or (l.key = \"bconst\" And l.val = \"true\")\n\t\t\t\tIf n.key = \"kor\" Then Return l Else Return n.arg[1]\n\t\t\tElseIf l.key = \"nil\" Or (l.key = \"bconst\" And l.val = \"false\")\n\t\t\t\tIf n.key = \"kor\" Then Return n.arg[1] Else Return l\n\t\t\tEndIf\n\t\tEndIf\n\t\tReturn n\n\tEnd Method\n\tMethod eq:Node(n:Rose) { neq }\n\t\tLocal l:Leaf = Leaf(n.arg[0]), r:Leaf = Leaf(n.arg[1])\n\t\tIf l <> Null And r <> Null And l.key = r.key\n\t\t\tGlobal rv:String[] = [\"false\", \"true\"]\n\t\t\tSelect l.key\n\t\t\t\tCase \"bconst\", \"sconst\" ; Return Leaf.Make(\"bconst\", rv[(n.key = \"eq\") * (l.val = r.val)])\n\t\t\t\tCase \"dconst\" ; Return Leaf.Make(\"bconst\", rv[(n.key = \"eq\") * (Double(l.val) = Double(r.val))])\t'it's fine when they're constants\n\t\t\tEnd Select\n\t\tEndIf\n\t\tReturn n\n\tEnd Method\n\tMethod lt:Node(n:Rose) { gt leq geq }\n\t\tLocal l:Leaf = Leaf(n.arg[0]), r:Leaf = Leaf(n.arg[1])\n\t\tIf l <> Null And r <> Null And l.key = \"dconst\" And r.key = \"dconst\"\t'string comparisons are affected by runtime locale\n\t\t\tGlobal rv:String[] = [\"false\", \"true\"] ; Local ret:Int\n\t\t\tSelect n.key\n\t\t\t\tCase \"gt\" ; ret = Double(l.val) > Double(r.val)\n\t\t\t\tCase \"lt\" ; ret = Double(l.val) < Double(r.val)\n\t\t\t\tCase \"geq\" ; ret = Double(l.val) >= Double(r.val)\n\t\t\t\tCase \"neq\" ; ret = Double(l.val) <= Double(r.val)\n\t\t\tEnd Select\n\t\t\tReturn Leaf.Make(\"bconst\", rv[ret])\n\t\tEndIf\n\t\tReturn n\n\tEnd Method\n\t\n\tMethod IfS:Node(n:Rose)\t'unpack constant if structures\n\t\tLocal test:Leaf = Leaf(n.arg[0])\n\t\tIf test\n\t\t\tSelect test.key\n\t\t\t\tCase \"bconst\", \"dconst\", \"sconst\", \"nil\"\n\t\t\t\t\tIf (test.key = \"bconst\" And test.val = \"False\") Or test.key = \"nil\"\n\t\t\t\t\t\tIf n.Get(\"else\") Then Return n.Get(\"else\") Else Return Null\n\t\t\t\t\tElse\n\t\t\t\t\t\tReturn n.Get(\"then\")\n\t\t\t\t\tEndIf\n\t\t\tEnd Select\n\t\tEndIf\n\t\tReturn n\n\tEnd Method\n\tMethod WhileS:Node(n:Rose)\t'remove while(false)\n\t\tLocal test:Leaf = Leaf(n.arg[0])\n\t\tIf test And ((test.key = \"bconst\" And test.val = \"false\") Or (test.key = \"nil\")) Then Return Null\n\t\tReturn n\n\tEnd Method\n\tMethod RepeatS:Node(n:Rose)\t'replace repeat...until(true) with a while and replace ...until(false) with a block\n\t\tLocal t:Leaf = Leaf(n.Get(\"test\"))\n\t\tIf t\n\t\t\tIf t.key = \"nil\" Or (t.key = \"bconst\" And t.val = \"false\")\n\t\t\t\tReturn Rose.Make(\"WhileS\", [Node(Leaf.Make(\"bconst\", \"true\")), n.Get(\"block\")], [\"test\", \"block\"])\n\t\t\tElseIf t.key = \"dconst\" Or t.key = \"sconst\" Or (t.key = \"bconst\" And t.val = \"true\")\n\t\t\t\tReturn n.Get(\"block\")\n\t\t\tEndIf\n\t\tEndIf\n\t\tReturn n\n\tEnd Method\nEnd Type\n\nType SyntaxErrFold\t'report any remaining syntax errors\n\tField tbl:TMap, breaks:TList\n\tFunction Make:SyntaxErrFold(tbl:NodeTable)\n\t\tLocal f:SyntaxErrFold = New SyntaxErrFold\n\t\tf.tbl = tbl.leaves ; f.breaks = CreateList()\n\t\tReturn f\n\tEnd Function\n\t\n\tMethod Block:Node(n:Rose)\t'scan for non-statements\n\t\tFor Local s:Int = 0 Until n.arg.Length\n\t\t\tSelect n.arg[s].key\n\t\t\t\tCase \"fcall\", \"mcall\"\n\t\t\t\t\tn.arg[s].key = \"p\" + n.arg[s].key\n\t\t\t\tCase \"Assgt\", \"break\", \"GotoS\", \"Label\", \"Block\", \"WhileS\", \"RepeatS\", \"IfS\", \"LocalVar\", \"ReturnS\"', \"ForN\", \"ForIn\"\n\t\t\t\tDefault\n\t\t\t\t\tThrow BlueCompileError.Make(TToken(tbl.ValueForKey(n.arg[s])), \"invalid statement in statement block\")\n\t\t\tEnd Select\n\t\tNext\n\t\tReturn n\n\tEnd Method\n\t\n\tMethod break:Node(n:Leaf)\t'add breaks to a stack...\n\t\tbreaks.AddFirst(n) ; Return n\n\tEnd Method\n\tMethod AllLoops:Node(n:Rose) { WhileS RepeatS } 'ForN ForIn }\t'...then remove them\n\t\tbreaks.Clear() ; Return n\n\tEnd Method\n\tMethod FuncBody:Node(n:Rose)\t'...and error on any that weren't removed\n\t\tSelf.BreakCheck() ; Return n\n\tEnd Method\n\t\n\tMethod BreakCheck()\t'need to call this externally for toplevel too\n\t\tIf breaks.Count() Then Throw BlueCompileError.Make(TToken(tbl.ValueForKey(breaks.First())), \"'break' statement without containing loop\")\n\tEnd Method\nEnd Type\n\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"3c67fc849306aa15b5744576785ab9c1ded19dc0","subject":"Fixed pickmode constants. Now copies pickmode and types with TEntity.Copy.","message":"Fixed pickmode constants. Now copies pickmode and types with TEntity.Copy.\n","repos":"kfprimm\/maxb3d,kfprimm\/maxb3d","old_file":"core.mod\/entity.bmx","new_file":"core.mod\/entity.bmx","new_contents":"\nStrict\n\nImport BRL.LinkedList\nImport MaxB3D.Math\nImport \"brush.bmx\"\nImport \"collision.bmx\"\nImport \"worldconfig.bmx\"\n\nConst PICKMODE_OFF\t\t\t= 0\nConst PICKMODE_SPHERE\t\t= 1\nConst PICKMODE_POLYGON\t= 2\nConst PICKMODE_BOX\t\t\t= 3\n\nType TEntity\n\tField _config:TWorldConfig\n\tField _matrix:TMatrix=TMatrix.Identity(), _lockmatrix\n\t\n\tField _name$\n\tField _px#,_py#,_pz#\n\tField _rx#,_ry#,_rz#\n\tField _sx#,_sy#,_sz#\n\t\t\n\tField _brush:TBrush=New TBrush\n\t\n\tField _parent:TEntity,_childlist:TList=CreateList()\n\tField _hidden,_order\n\t\n\tField _collision:TCollision[]\n\tField _oldx#,_oldy#,_oldz#\n\tField _radiusx#,_radiusy#\n\tField _boxx#,_boxy#,_boxz#,_boxwidth#,_boxheight#,_boxdepth#\n\tField _type,_typelink:TLink\n\tField _pickmode, _obscurer\n\t\n\tField _cullradius#\n\t\n\tField _alphaorder#\n\t\n\tField _linklist:TList=CreateList()\n\t\n\tMethod Init:TEntity(config:TWorldConfig,parent:TEntity)\n\t\t_config = config\n\t\tSetParent parent,False\n\t\tFor Local l=EachIn Lists()\n\t\t\tAddLink _config.AddObject(Self,l)\n\t\tNext\n\t\t\n\t\tSetScale 1,1,1\n\t\t\n\t\tReturn Self\n\tEnd Method\n\t\n\tMethod Free()\n\t\tFor Local child:TEntity=EachIn _childlist\n\t\t\tchild.Free()\n\t\tNext\n\t\tFor Local link:TLink=EachIn _linklist\n\t\t\tRemoveLink link\n\t\tNext\n\tEnd Method\n\t\n\tMethod AddLink(link:TLink)\n\t\t_linklist.AddLast link\n\tEnd Method\n\t\n\tMethod Lists[]()\n\t\tReturn [WORLDLIST_ENTITY]\n\tEnd Method\n\t\n\tMethod CopyData:TEntity(entity:TEntity)\n\t\t_config = entity._config\n\t\tLocal pickmode, obscurer\n\t\tentity.GetPickMode pickmode,obscurer\n\t\t\n\t\tSetBrush entity.GetBrush()\n\t\tSetName entity.GetName()\n\t\tSetPickMode pickmode, obscurer\n\t\tSetType entity.GetType()\n\t\tReturn Self\n\tEnd Method\n\t\n\tMethod Copy_:TEntity(parent:TEntity=Null)\n\t\tReturn New Self.CopyData(Self).Init(_config,parent)\n\tEnd Method\n\t\n\tMethod Copy:TEntity(parent:TEntity=Null) Abstract\n\t\n\tMethod AddParent(parent:TEntity)\n\t\t_parent=parent\n\t\tIf parent\n\t\t\t_matrix.Overwrite parent._matrix\n\t\t\tparent._childlist.AddLast Self\n\t\tEndIf\n\tEnd Method\n\t\n\tMethod GetParent:TEntity()\n\t\tReturn _parent\n\tEnd Method\n\tMethod SetParent(parent:TEntity,glob=True)\n\t\tLocal gpx#,gpy#,gpz#\t\t\n\t\tLocal grx#,gry#,grz#\t\t\n\t\tLocal gsx#,gsy#,gsz#\n\t\t\n\t\tGetPosition gpx,gpy,gpz,True\n\t\tGetRotation grx,gry,grz,True\n\t\tGetScale gsx,gsy,gsz,True\n\t\t\n\t\tIf _parent\n\t\t\tFor Local entity:TEntity=EachIn _parent._childlist\n\t\t\t\tIf entity=Self ListRemove(_parent._childlist,Self)\n\t\t\tNext\n\t\t\t_parent=Null\n\t\tEndIf\n\n\t\t_px=gpx;_py=gpy;_pz=gpz\n\t\t_rx=grx;_ry=gry;_rz=grz\n\t\t_sx=gsx;_sy=gsy;_sz=gsz\n\t\t\n\t\tIf parent=Null UpdateMatrix(True);Return\t\t\n\t\t\n\t\tAddParent(parent)\n\t\tIf glob\t\t\t\t\n\t\t\tSetPosition(gpx,gpy,gpz,True)\n\t\t\tSetRotation(grx,gry,grz,True)\n\t\t\tSetScale(gsx,gsy,gsz,True)\n\t\tElse\t\t\t\n\t\t\tUpdateMatrix(False)\t\t\t\t\n\t\tEndIf\t\t\t\n\tEnd Method\n\t\n\tMethod CountChildren(recursive=False)\n\t\tLocal count\n\t\tIf recursive\n\t\t\tFor Local child:TEntity=EachIn _childlist\n\t\t\t\tcount:+child.CountChildren(True)\n\t\t\tNext\n\t\tEndIf\n\t\tReturn _childlist.Count()+count\n\tEnd Method\n\t\n\tMethod FindChild:TEntity(name$,recursive=False)\n\t\tFor Local child:TEntity=EachIn _childlist\n\t\t\tIf child.GetName()=name Return child\n\t\tNext\n\t\tIf recursive\n\t\t\tFor Local child:TEntity=EachIn _childlist\n\t\t\t\tLocal entity:TEntity = child.FindChild(name, True)\n\t\t\t\tIf entity Return entity\n\t\t\tNext\n\t\tEndIf\n\tEnd Method\n\t\n\tMethod GetName$()\n\t\tReturn _name\n\tEnd Method\n\tMethod SetName(name$)\n\t\t_name=name\n\tEnd Method\n\t\n\tMethod GetBrush:TBrush()\n\t\tReturn _brush.Copy()\n\tEnd Method\n\tMethod SetBrush(brush:TBrush)\n\t\t_brush.Load brush\n\tEnd Method\n\t\n\tMethod GetColor(red Var,green Var,blue Var)\n\t\tReturn _brush.GetColor(red,green,blue)\n\tEnd Method\n\tMethod SetColor(red,green,blue)\n\t\tReturn _brush.SetColor(red,green,blue)\n\tEnd Method\n\t\n\tMethod GetAlpha#()\n\t\tReturn _brush.GetAlpha()\n\tEnd Method\n\tMethod SetAlpha(alpha#)\n\t\t_brush.SetAlpha(alpha)\n\tEnd Method\n\t\n\tMethod GetShine#()\n\t\tReturn _brush.GetShine()\n\tEnd Method\n\tMethod SetShine(shine#)\n\t\t_brush.SetShine(shine)\n\tEnd Method\n\t\n\tMethod GetTexture:TTexture(index)\n\t\tReturn _brush.GetTexture(index)\n\tEnd Method\n\tMethod SetTexture(texture:TTexture,index=0,frame=0)\n\t\tReturn _brush.SetTexture(texture,index,frame)\n\tEnd Method\n\t\n\tMethod GetFX()\n\t\tReturn _brush.GetFX()\n\tEnd Method\n\tMethod SetFX(fx)\n\t\tReturn _brush.SetFX(fx)\n\tEnd Method\n\t\n\tMethod GetBlend()\n\t\tReturn _brush.GetBlend()\n\tEnd Method\n\tMethod SetBlend(blend)\n\t\tReturn _brush.SetBlend(blend)\n\tEnd Method\n\t\n\tMethod GetShader:TShader()\n\t\tReturn _brush.GetShader()\n\tEnd Method\n\tMethod SetShader(shader:TShader)\n\t\tReturn _brush.SetShader(shader)\n\tEnd Method\n\t\n\tMethod GetScale(x# Var,y# Var,z# Var,glob=False)\n\t\tIf glob\n\t\t\tx=_matrix._m[0,0]\n\t\t\ty=_matrix._m[1,1]\n\t\t\tz=_matrix._m[2,2]\n\t\tElse\n\t\t\tx=_sx;y=_sy;z=_sz\n\t\tEndIf\n\tEnd Method\n\tMethod SetScale(x#,y#,z#,glob=False)\n\t\t_sx=x;_sy=y;_sz=z\n\t\tIf glob=True And _parent<>Null\n\t\t\tLocal entity:TEntity=Self\n\t\t\tRepeat\n\t\t\t\t_sx:\/entity._parent._sx\n\t\t\t\t_sy:\/entity._parent._sy\n\t\t\t\t_sz:\/entity._parent._sz\n\t\t\t\tentity=entity._parent\n\t\t\tUntil entity._parent=Null\n\t\tEndIf\n\t\tRefreshMatrix()\t\n\tEnd Method\n\t\n\tMethod Transform(matrix:TMatrix,glob=False)\n\t\tSetMatrix matrix.Multiply(_matrix),glob\n\tEnd Method\n\t\n\tMethod Turn(pitch#,yaw#,roll#,glob=False)\n\t\t_rx:+pitch;_ry:+yaw;_rz:+roll\n\t\tRefreshMatrix()\n\tEnd Method\n\t\n\tMethod Point(target:Object,roll#=0.0)\n\t\tLocal x#,y#,z#,tx#,ty#,tz#\n\t\tGetPosition x,y,z,True\n\t\tGetTargetPosition target,tx,ty,tz \n\n\t\tLocal xdiff#=x-tx,ydiff#=y-ty,zdiff#=z-tz\n\n\t\tLocal dist22#=Sqr((xdiff*xdiff)+(zdiff*zdiff))\n\t\tLocal pitch#=ATan2(ydiff,dist22)\n\t\tLocal yaw#=ATan2(xdiff,-zdiff)\n\n\t\tSetRotation pitch,yaw,roll,True\n\tEnd Method\n\t\n\tMethod GetDistance#(target:Object)\n\t\tLocal x#,y#,z#,tx#,ty#,tz#\n\t\tGetPosition x,y,z,True\n\t\tGetTargetPosition target,tx,ty,tz\t\t\n\t\tReturn Sqr((x-tx)*(x-tx)+(y-ty)*(y-ty)+(z-tz)*(z-tz))\n\tEnd Method\n\t\n\tFunction GetTargetPosition(target:Object,x# Var,y# Var,z# Var)\n\t\tAssert target,\"Null target given.\"\n\t\tIf TEntity(target) TEntity(target).GetPosition x,y,z,True\n\t\tIf Float[](target)\n\t\t\tLocal coords#[]=Float[](target)\n\t\t\tIf coords.length>0 x=coords[0]\n\t\t\tIf coords.length>1 y=coords[1]\n\t\t\tIf coords.length>2 z=coords[2]\n\t\tEndIf\n\t\tAssert \"Invalid target given.\"\n\tEnd Function\t\n\t\n\tMethod GetRotation(pitch# Var,yaw# Var,roll# Var,glob=False)\n\t\tIf glob\n\t\t\t_matrix.GetRotation pitch,yaw,roll\n\t\t\tpitch:*-1\n\t\t\tyaw:*-1\n\t\tElse\n\t\t\tpitch=_rx;yaw=_ry;roll=_rz\n\t\tEndIf\n\tEnd Method\n\tMethod SetRotation(pitch#,yaw#,roll#,glob=False)\n\t\t_rx=pitch;_ry=yaw;_rz=roll\n\t\tIf glob And _parent<>Null\n\t\t\tLocal rx#,ry#,rz#\n\t\t\t_parent.GetRotation rx,ry,rz\n\t\t\t_rx:+rx;_ry:+ry;_rz:+rz\t\t\t\n\t\tEndIf\n\t\tRefreshMatrix()\n\tEnd Method\n\t\t\n\tMethod GetPosition(x# Var,y# Var,z# Var,glob=False)\n\t\tx=_px;y=_py;z=_pz\n\t\tIf glob _matrix.GetPosition x,y,z\n\tEnd Method\n\tMethod SetPosition(x#,y#,z#,glob=False)\n\t\t_px=x;_py=y;_pz=z\n\t\t\n\t\tIf glob And _parent<>Null\n\t\t\tLocal px#,py#,pz#\n\t\t\t_parent.GetPosition px,py,pz,True\n\t\t\t_px:-px;_py:-py;_pz:-pz\n\t\tEndIf\n\t\t\n\t\tRefreshMatrix()\n\tEnd Method\n\t\n\tMethod Move(x#,y#,z#)\n\t\tLocal matrix:TMatrix=TMatrix.Identity()\n\t\tmatrix=TMatrix.YawPitchRoll(-_ry,-_rx,_rz).Multiply(matrix)\n\t\tmatrix=TMatrix.Translation(x,y,z).Multiply(matrix)\n\t\n\t\tmatrix.GetPosition(x,y,z)\t\t\n\t\t_px:+x;_py:+y;_pz:+z\n\n\t\tRefreshMatrix()\n\tEnd Method\n\t\n\tMethod Translate(x#,y#,z#,glob=True)\n\t\tIf glob And _parent\t\t\t\n\t\t\tLocal ax#,ay#,az#\n\t\t\tGetRotation ax,ay,az,True\n\t\t\t\t\t\t\n\t\t\tLocal matrix:TMatrix=TMatrix.Roll(-az)\n\t\t\tmatrix=matrix.Multiply(TMatrix.Pitch(-ax))\n\t\t\tmatrix=matrix.Multiply(TMatrix.Yaw(-ay))\n\t\t\tmatrix=matrix.Multiply(TMatrix.Translation(x,y,z))\n\t\t\t\n\t\t\tmatrix.GetPosition x,y,z\n\t\tEndIf\n\t\t\n\t\t_px:+x;_py:+y;_pz:+z\n\n\t\tRefreshMatrix()\n\tEnd Method\n\t\n\tMethod GetVisible()\n\t\tLocal entity:TEntity=Self\n\t\tWhile entity<>Null\n\t\t\tIf entity._hidden=True Return False\n\t\t\tentity=entity._parent\n\t\tWend\n\t\tReturn True\n\tEnd Method\n\tMethod SetVisible(visible)\n\t\t_hidden=Not visible\n\tEnd Method\n\t\n\tMethod GetOrder()\n\t\tReturn _order\n\tEnd Method\n\tMethod SetOrder(order)\n\t\t_order=order\n\tEnd Method\n\t\n\tMethod GetCollisions:TCollision[]()\n\t\tReturn _collision\n\tEnd Method\n\t\n\tMethod GetRadius(x# Var,y# Var)\n\t\tx=_radiusx;y=_radiusy\n\tEnd Method\n\tMethod SetRadius(x#,y#=-1)\n\t\t_radiusx=x;_radiusy=x\n\t\tIf y>-1 _radiusy=y\n\tEnd Method\n\t\n\tMethod GetBox(x# Var,y# Var,z# Var,width# Var,height# Var,depth# Var)\n\t\tx=_boxx;y=_boxy;z=_boxz\n\t\twidth=_boxwidth;height=_boxheight;depth=_boxdepth\n\tEnd Method\n\tMethod SetBox(x#,y#,z#,width#,height#,depth#)\n\t\t_boxx=x;_boxy=y;_boxz=z\n\t\t_boxwidth=width;_boxheight=height;_boxdepth=depth\n\tEnd Method\n\t\n\tMethod Reset()\n\t\t_collision=Null\n\t\tGetPosition _oldx,_oldy,_oldz,True\n\tEnd Method\n\t\n\tMethod GetType()\n\t\tReturn _type\n\tEnd Method\n\tMethod SetType(typ,recursive=False)\n\t\tIf _typelink\n\t\t\t_linklist.Remove(_typelink)\n\t\t\t_typelink.Remove()\n\t\t\t_typelink=Null\n\t\tEndIf\n\t\t\n\t\tIf typ>0\n\t\t\tIf _config.CollisionType[typ]=Null _config.CollisionType[typ]=CreateList()\n\t\t\t_typelink=_config.CollisionType[typ].AddLast(Self)\n\t\t\tAddLink _typelink\n\t\tEndIf\t\t\n\t\t\n\t\t_type=typ\n\t\tGetPosition _oldx,_oldy,_oldz,True\n\t\t\n\t\tIf recursive\n\t\t\tFor Local child:TEntity=EachIn _childlist\n\t\t\t\tchild.SetType typ,True\n\t\t\tNext\n\t\tEndIf\n\tEnd Method\n\t\n\tMethod GetCullRadius#()\n\t\tReturn Abs(_cullradius)\n\tEnd Method\n\tMethod SetCullRadius(radius#)\n\t\t_cullradius=-radius\n\tEnd Method\n\n\tMethod GetCullParams(x# Var,y# Var,z# Var,radius# Var)\n\t\tGetPosition x,y,z,True\n\t\tradius=GetCullRadius()\n\tEnd Method\n\t\n\tMethod GetPickMode(mode Var, obscurer Var)\n\t\tmode = _pickmode\n\t\tobscurer = _obscurer\n\tEnd Method\t\n\tMethod SetPickMode(mode, obscurer=True)\n\t\t_pickmode = mode\n\t\t_obscurer = obscurer\n\tEnd Method\n\t\n\tMethod HasAlpha()\n\t\tReturn _brush.HasAlpha()\n\tEnd Method\n\t\n\tMethod GetMatrix:TMatrix(alternate=False,copy=True)\n\t\tIf copy Return _matrix.Copy()\n\t\tReturn _matrix\n\tEnd Method\n\tMethod SetMatrix(matrix:TMatrix,glob=True)\n\t\tLocal x#,y#,z#,pitch#,yaw#,roll#,sx#,sy#,sz#\n\t\tmatrix.GetPosition x,y,z\n\t\tmatrix.GetRotation pitch,yaw,roll\n\t\tmatrix.GetScale sx,sy,sz\n\t\t\n\t\tLockMatrix\n\t\tSetPosition x,y,z,glob\n\t\tSetRotation pitch,yaw,roll,glob\n\t\tSetScale sx,sy,sz,glob\n\t\tUnlockMatrix\n\tEnd Method\n\t\n\tMethod LockMatrix()\n\t\t_lockmatrix=True\n\tEnd Method\n\tMethod UnlockMatrix()\n\t\t_lockmatrix=False\n\t\tRefreshMatrix()\n\tEnd Method\n\t\n\tMethod RefreshMatrix()\n\t\tIf _lockmatrix Return\n\t\tIf _parent<>Null\n\t\t\t_matrix.Overwrite _parent._matrix\n\t\t\tUpdateMatrix False\n\t\tElse\n\t\t\tUpdateMatrix True\n\t\tEndIf\t\t\n\t\t\n\t\tFor Local child:TEntity=EachIn _childlist\n\t\t\tchild.RefreshMatrix()\n\t\tNext\n\tEnd Method\n\t\n\tMethod UpdateMatrix(loadidentity)\n\t\tIf loadidentity _matrix=TMatrix.Identity()\n\t\t_matrix=TMatrix.Translation(_px,_py,_pz).Multiply(_matrix)\n\t\t_matrix=TMatrix.YawPitchRoll(-_ry,-_rx,_rz).Multiply(_matrix)\n\t\t_matrix=TMatrix.Scale(_sx,_sy,_sz).Multiply(_matrix)\n\tEnd Method\n\t\n\tMethod ObjectEnumerator:Object()\n\t\tReturn TChildrenEnumerator.Create(_childlist)\n\tEnd Method\nEnd Type\n\nType TChildrenEnumerator\n\tField _children:TEntity[],_index=-1\n\t\n\tFunction Create:TChildrenEnumerator(list:TList)\n\t\tLocal enum:TChildrenEnumerator=New TChildrenEnumerator\n\t\tenum._children=TEntity[](list.ToArray())\n\t\tReturn enum\n\tEnd Function\n\t\n\tMethod HasNext()\n\t\tReturn _index>=_children.length-1\n\tEnd Method\n\t\n\tMethod NextObject:Object()\n\t\t_index:+1\n\t\tReturn _children[_index]\n\tEnd Method\nEnd Type\n","old_contents":"\nStrict\n\nImport BRL.LinkedList\nImport MaxB3D.Math\nImport \"brush.bmx\"\nImport \"collision.bmx\"\nImport \"worldconfig.bmx\"\n\nConst PICKMODE_OFF\t\t= 1\nConst PICKMODE_SPHERE\t= 2\nConst PICKMODE_POLYGON\t= 3\nConst PICKMODE_BOX\t\t= 4\n\nType TEntity\n\tField _config:TWorldConfig\n\tField _matrix:TMatrix=TMatrix.Identity(), _lockmatrix\n\t\n\tField _name$\n\tField _px#,_py#,_pz#\n\tField _rx#,_ry#,_rz#\n\tField _sx#,_sy#,_sz#\n\t\t\n\tField _brush:TBrush=New TBrush\n\t\n\tField _parent:TEntity,_childlist:TList=CreateList()\n\tField _hidden,_order\n\t\n\tField _collision:TCollision[]\n\tField _oldx#,_oldy#,_oldz#\n\tField _radiusx#,_radiusy#\n\tField _boxx#,_boxy#,_boxz#,_boxwidth#,_boxheight#,_boxdepth#\n\tField _type,_typelink:TLink\n\tField _pickmode, _obscurer\n\t\n\tField _cullradius#\n\t\n\tField _alphaorder#\n\t\n\tField _linklist:TList=CreateList()\n\t\n\tMethod Init:TEntity(config:TWorldConfig,parent:TEntity)\n\t\t_config = config\n\t\tSetParent parent,False\n\t\tFor Local l=EachIn Lists()\n\t\t\tAddLink _config.AddObject(Self,l)\n\t\tNext\n\t\t\n\t\tSetScale 1,1,1\n\t\t\n\t\tReturn Self\n\tEnd Method\n\t\n\tMethod Free()\n\t\tFor Local child:TEntity=EachIn _childlist\n\t\t\tchild.Free()\n\t\tNext\n\t\tFor Local link:TLink=EachIn _linklist\n\t\t\tRemoveLink link\n\t\tNext\n\tEnd Method\n\t\n\tMethod AddLink(link:TLink)\n\t\t_linklist.AddLast link\n\tEnd Method\n\t\n\tMethod Lists[]()\n\t\tReturn [WORLDLIST_ENTITY]\n\tEnd Method\n\t\n\tMethod CopyData:TEntity(entity:TEntity)\n\t\tSetBrush entity.GetBrush()\n\t\tSetName entity.GetName()\n\t\tReturn Self\n\tEnd Method\n\t\n\tMethod Copy_:TEntity(parent:TEntity=Null)\n\t\tReturn New Self.CopyData(Self).Init(_config,parent)\n\tEnd Method\n\t\n\tMethod Copy:TEntity(parent:TEntity=Null) Abstract\n\t\n\tMethod AddParent(parent:TEntity)\n\t\t_parent=parent\n\t\tIf parent\n\t\t\t_matrix.Overwrite parent._matrix\n\t\t\tparent._childlist.AddLast Self\n\t\tEndIf\n\tEnd Method\n\t\n\tMethod GetParent:TEntity()\n\t\tReturn _parent\n\tEnd Method\n\tMethod SetParent(parent:TEntity,glob=True)\n\t\tLocal gpx#,gpy#,gpz#\t\t\n\t\tLocal grx#,gry#,grz#\t\t\n\t\tLocal gsx#,gsy#,gsz#\n\t\t\n\t\tGetPosition gpx,gpy,gpz,True\n\t\tGetRotation grx,gry,grz,True\n\t\tGetScale gsx,gsy,gsz,True\n\t\t\n\t\tIf _parent\n\t\t\tFor Local entity:TEntity=EachIn _parent._childlist\n\t\t\t\tIf entity=Self ListRemove(_parent._childlist,Self)\n\t\t\tNext\n\t\t\t_parent=Null\n\t\tEndIf\n\n\t\t_px=gpx;_py=gpy;_pz=gpz\n\t\t_rx=grx;_ry=gry;_rz=grz\n\t\t_sx=gsx;_sy=gsy;_sz=gsz\n\t\t\n\t\tIf parent=Null UpdateMatrix(True);Return\t\t\n\t\t\n\t\tAddParent(parent)\n\t\tIf glob\t\t\t\t\n\t\t\tSetPosition(gpx,gpy,gpz,True)\n\t\t\tSetRotation(grx,gry,grz,True)\n\t\t\tSetScale(gsx,gsy,gsz,True)\n\t\tElse\t\t\t\n\t\t\tUpdateMatrix(False)\t\t\t\t\n\t\tEndIf\t\t\t\n\tEnd Method\n\t\n\tMethod CountChildren(recursive=False)\n\t\tLocal count\n\t\tIf recursive\n\t\t\tFor Local child:TEntity=EachIn _childlist\n\t\t\t\tcount:+child.CountChildren(True)\n\t\t\tNext\n\t\tEndIf\n\t\tReturn _childlist.Count()+count\n\tEnd Method\n\t\n\tMethod FindChild:TEntity(name$,recursive=False)\n\t\tFor Local child:TEntity=EachIn _childlist\n\t\t\tIf child.GetName()=name Return child\n\t\tNext\n\t\tIf recursive\n\t\t\tFor Local child:TEntity=EachIn _childlist\n\t\t\t\tLocal entity:TEntity = child.FindChild(name, True)\n\t\t\t\tIf entity Return entity\n\t\t\tNext\n\t\tEndIf\n\tEnd Method\n\t\n\tMethod GetName$()\n\t\tReturn _name\n\tEnd Method\n\tMethod SetName(name$)\n\t\t_name=name\n\tEnd Method\n\t\n\tMethod GetBrush:TBrush()\n\t\tReturn _brush.Copy()\n\tEnd Method\n\tMethod SetBrush(brush:TBrush)\n\t\t_brush.Load brush\n\tEnd Method\n\t\n\tMethod GetColor(red Var,green Var,blue Var)\n\t\tReturn _brush.GetColor(red,green,blue)\n\tEnd Method\n\tMethod SetColor(red,green,blue)\n\t\tReturn _brush.SetColor(red,green,blue)\n\tEnd Method\n\t\n\tMethod GetAlpha#()\n\t\tReturn _brush.GetAlpha()\n\tEnd Method\n\tMethod SetAlpha(alpha#)\n\t\t_brush.SetAlpha(alpha)\n\tEnd Method\n\t\n\tMethod GetShine#()\n\t\tReturn _brush.GetShine()\n\tEnd Method\n\tMethod SetShine(shine#)\n\t\t_brush.SetShine(shine)\n\tEnd Method\n\t\n\tMethod GetTexture:TTexture(index)\n\t\tReturn _brush.GetTexture(index)\n\tEnd Method\n\tMethod SetTexture(texture:TTexture,index=0,frame=0)\n\t\tReturn _brush.SetTexture(texture,index,frame)\n\tEnd Method\n\t\n\tMethod GetFX()\n\t\tReturn _brush.GetFX()\n\tEnd Method\n\tMethod SetFX(fx)\n\t\tReturn _brush.SetFX(fx)\n\tEnd Method\n\t\n\tMethod GetBlend()\n\t\tReturn _brush.GetBlend()\n\tEnd Method\n\tMethod SetBlend(blend)\n\t\tReturn _brush.SetBlend(blend)\n\tEnd Method\n\t\n\tMethod GetShader:TShader()\n\t\tReturn _brush.GetShader()\n\tEnd Method\n\tMethod SetShader(shader:TShader)\n\t\tReturn _brush.SetShader(shader)\n\tEnd Method\n\t\n\tMethod GetScale(x# Var,y# Var,z# Var,glob=False)\n\t\tIf glob\n\t\t\tx=_matrix._m[0,0]\n\t\t\ty=_matrix._m[1,1]\n\t\t\tz=_matrix._m[2,2]\n\t\tElse\n\t\t\tx=_sx;y=_sy;z=_sz\n\t\tEndIf\n\tEnd Method\n\tMethod SetScale(x#,y#,z#,glob=False)\n\t\t_sx=x;_sy=y;_sz=z\n\t\tIf glob=True And _parent<>Null\n\t\t\tLocal entity:TEntity=Self\n\t\t\tRepeat\n\t\t\t\t_sx:\/entity._parent._sx\n\t\t\t\t_sy:\/entity._parent._sy\n\t\t\t\t_sz:\/entity._parent._sz\n\t\t\t\tentity=entity._parent\n\t\t\tUntil entity._parent=Null\n\t\tEndIf\n\t\tRefreshMatrix()\t\n\tEnd Method\n\t\n\tMethod Transform(matrix:TMatrix,glob=False)\n\t\tSetMatrix matrix.Multiply(_matrix),glob\n\tEnd Method\n\t\n\tMethod Turn(pitch#,yaw#,roll#,glob=False)\n\t\t_rx:+pitch;_ry:+yaw;_rz:+roll\n\t\tRefreshMatrix()\n\tEnd Method\n\t\n\tMethod Point(target:Object,roll#=0.0)\n\t\tLocal x#,y#,z#,tx#,ty#,tz#\n\t\tGetPosition x,y,z,True\n\t\tGetTargetPosition target,tx,ty,tz \n\n\t\tLocal xdiff#=x-tx,ydiff#=y-ty,zdiff#=z-tz\n\n\t\tLocal dist22#=Sqr((xdiff*xdiff)+(zdiff*zdiff))\n\t\tLocal pitch#=ATan2(ydiff,dist22)\n\t\tLocal yaw#=ATan2(xdiff,-zdiff)\n\n\t\tSetRotation pitch,yaw,roll,True\n\tEnd Method\n\t\n\tMethod GetDistance#(target:Object)\n\t\tLocal x#,y#,z#,tx#,ty#,tz#\n\t\tGetPosition x,y,z,True\n\t\tGetTargetPosition target,tx,ty,tz\t\t\n\t\tReturn Sqr((x-tx)*(x-tx)+(y-ty)*(y-ty)+(z-tz)*(z-tz))\n\tEnd Method\n\t\n\tFunction GetTargetPosition(target:Object,x# Var,y# Var,z# Var)\n\t\tAssert target,\"Null target given.\"\n\t\tIf TEntity(target) TEntity(target).GetPosition x,y,z,True\n\t\tIf Float[](target)\n\t\t\tLocal coords#[]=Float[](target)\n\t\t\tIf coords.length>0 x=coords[0]\n\t\t\tIf coords.length>1 y=coords[1]\n\t\t\tIf coords.length>2 z=coords[2]\n\t\tEndIf\n\t\tAssert \"Invalid target given.\"\n\tEnd Function\t\n\t\n\tMethod GetRotation(pitch# Var,yaw# Var,roll# Var,glob=False)\n\t\tIf glob\n\t\t\t_matrix.GetRotation pitch,yaw,roll\n\t\t\tpitch:*-1\n\t\t\tyaw:*-1\n\t\tElse\n\t\t\tpitch=_rx;yaw=_ry;roll=_rz\n\t\tEndIf\n\tEnd Method\n\tMethod SetRotation(pitch#,yaw#,roll#,glob=False)\n\t\t_rx=pitch;_ry=yaw;_rz=roll\n\t\tIf glob And _parent<>Null\n\t\t\tLocal rx#,ry#,rz#\n\t\t\t_parent.GetRotation rx,ry,rz\n\t\t\t_rx:+rx;_ry:+ry;_rz:+rz\t\t\t\n\t\tEndIf\n\t\tRefreshMatrix()\n\tEnd Method\n\t\t\n\tMethod GetPosition(x# Var,y# Var,z# Var,glob=False)\n\t\tx=_px;y=_py;z=_pz\n\t\tIf glob _matrix.GetPosition x,y,z\n\tEnd Method\n\tMethod SetPosition(x#,y#,z#,glob=False)\n\t\t_px=x;_py=y;_pz=z\n\t\t\n\t\tIf glob And _parent<>Null\n\t\t\tLocal px#,py#,pz#\n\t\t\t_parent.GetPosition px,py,pz,True\n\t\t\t_px:-px;_py:-py;_pz:-pz\n\t\tEndIf\n\t\t\n\t\tRefreshMatrix()\n\tEnd Method\n\t\n\tMethod Move(x#,y#,z#)\n\t\tLocal matrix:TMatrix=TMatrix.Identity()\n\t\tmatrix=TMatrix.YawPitchRoll(-_ry,-_rx,_rz).Multiply(matrix)\n\t\tmatrix=TMatrix.Translation(x,y,z).Multiply(matrix)\n\t\n\t\tmatrix.GetPosition(x,y,z)\t\t\n\t\t_px:+x;_py:+y;_pz:+z\n\n\t\tRefreshMatrix()\n\tEnd Method\n\t\n\tMethod Translate(x#,y#,z#,glob=True)\n\t\tIf glob And _parent\t\t\t\n\t\t\tLocal ax#,ay#,az#\n\t\t\tGetRotation ax,ay,az,True\n\t\t\t\t\t\t\n\t\t\tLocal matrix:TMatrix=TMatrix.Roll(-az)\n\t\t\tmatrix=matrix.Multiply(TMatrix.Pitch(-ax))\n\t\t\tmatrix=matrix.Multiply(TMatrix.Yaw(-ay))\n\t\t\tmatrix=matrix.Multiply(TMatrix.Translation(x,y,z))\n\t\t\t\n\t\t\tmatrix.GetPosition x,y,z\n\t\tEndIf\n\t\t\n\t\t_px:+x;_py:+y;_pz:+z\n\n\t\tRefreshMatrix()\n\tEnd Method\n\t\n\tMethod GetVisible()\n\t\tLocal entity:TEntity=Self\n\t\tWhile entity<>Null\n\t\t\tIf entity._hidden=True Return False\n\t\t\tentity=entity._parent\n\t\tWend\n\t\tReturn True\n\tEnd Method\n\tMethod SetVisible(visible)\n\t\t_hidden=Not visible\n\tEnd Method\n\t\n\tMethod GetOrder()\n\t\tReturn _order\n\tEnd Method\n\tMethod SetOrder(order)\n\t\t_order=order\n\tEnd Method\n\t\n\tMethod GetCollisions:TCollision[]()\n\t\tReturn _collision\n\tEnd Method\n\t\n\tMethod GetRadius(x# Var,y# Var)\n\t\tx=_radiusx;y=_radiusy\n\tEnd Method\n\tMethod SetRadius(x#,y#=-1)\n\t\t_radiusx=x;_radiusy=x\n\t\tIf y>-1 _radiusy=y\n\tEnd Method\n\t\n\tMethod GetBox(x# Var,y# Var,z# Var,width# Var,height# Var,depth# Var)\n\t\tx=_boxx;y=_boxy;z=_boxz\n\t\twidth=_boxwidth;height=_boxheight;depth=_boxdepth\n\tEnd Method\n\tMethod SetBox(x#,y#,z#,width#,height#,depth#)\n\t\t_boxx=x;_boxy=y;_boxz=z\n\t\t_boxwidth=width;_boxheight=height;_boxdepth=depth\n\tEnd Method\n\t\n\tMethod Reset()\n\t\t_collision=Null\n\t\tGetPosition _oldx,_oldy,_oldz,True\n\tEnd Method\n\t\n\tMethod GetType()\n\t\tReturn _type\n\tEnd Method\n\tMethod SetType(typ,recursive=False)\n\t\tIf _typelink\n\t\t\t_linklist.Remove(_typelink)\n\t\t\t_typelink.Remove()\n\t\t\t_typelink=Null\n\t\tEndIf\n\t\t\n\t\tIf typ>0\n\t\t\tIf _config.CollisionType[typ]=Null _config.CollisionType[typ]=CreateList()\n\t\t\t_typelink=_config.CollisionType[typ].AddLast(Self)\n\t\t\tAddLink _typelink\n\t\tEndIf\t\t\n\t\t\n\t\t_type=typ\n\t\tGetPosition _oldx,_oldy,_oldz,True\n\t\t\n\t\tIf recursive\n\t\t\tFor Local child:TEntity=EachIn _childlist\n\t\t\t\tchild.SetType typ,True\n\t\t\tNext\n\t\tEndIf\n\tEnd Method\n\t\n\tMethod GetCullRadius#()\n\t\tReturn Abs(_cullradius)\n\tEnd Method\n\tMethod SetCullRadius(radius#)\n\t\t_cullradius=-radius\n\tEnd Method\n\n\tMethod GetCullParams(x# Var,y# Var,z# Var,radius# Var)\n\t\tGetPosition x,y,z,True\n\t\tradius=GetCullRadius()\n\tEnd Method\n\t\n\tMethod GetPickMode(mode Var, obscurer Var)\n\t\tmode = _pickmode\n\t\tobscurer = _obscurer\n\tEnd Method\t\n\tMethod SetPickMode(mode, obscurer=True)\n\t\t_pickmode = mode\n\t\t_obscurer = obscurer\n\tEnd Method\n\t\n\tMethod HasAlpha()\n\t\tReturn _brush.HasAlpha()\n\tEnd Method\n\t\n\tMethod GetMatrix:TMatrix(alternate=False,copy=True)\n\t\tIf copy Return _matrix.Copy()\n\t\tReturn _matrix\n\tEnd Method\n\tMethod SetMatrix(matrix:TMatrix,glob=True)\n\t\tLocal x#,y#,z#,pitch#,yaw#,roll#,sx#,sy#,sz#\n\t\tmatrix.GetPosition x,y,z\n\t\tmatrix.GetRotation pitch,yaw,roll\n\t\tmatrix.GetScale sx,sy,sz\n\t\t\n\t\tLockMatrix\n\t\tSetPosition x,y,z,glob\n\t\tSetRotation pitch,yaw,roll,glob\n\t\tSetScale sx,sy,sz,glob\n\t\tUnlockMatrix\n\tEnd Method\n\t\n\tMethod LockMatrix()\n\t\t_lockmatrix=True\n\tEnd Method\n\tMethod UnlockMatrix()\n\t\t_lockmatrix=False\n\t\tRefreshMatrix()\n\tEnd Method\n\t\n\tMethod RefreshMatrix()\n\t\tIf _lockmatrix Return\n\t\tIf _parent<>Null\n\t\t\t_matrix.Overwrite _parent._matrix\n\t\t\tUpdateMatrix False\n\t\tElse\n\t\t\tUpdateMatrix True\n\t\tEndIf\t\t\n\t\t\n\t\tFor Local child:TEntity=EachIn _childlist\n\t\t\tchild.RefreshMatrix()\n\t\tNext\n\tEnd Method\n\t\n\tMethod UpdateMatrix(loadidentity)\n\t\tIf loadidentity _matrix=TMatrix.Identity()\n\t\t_matrix=TMatrix.Translation(_px,_py,_pz).Multiply(_matrix)\n\t\t_matrix=TMatrix.YawPitchRoll(-_ry,-_rx,_rz).Multiply(_matrix)\n\t\t_matrix=TMatrix.Scale(_sx,_sy,_sz).Multiply(_matrix)\n\tEnd Method\n\t\n\tMethod ObjectEnumerator:Object()\n\t\tReturn TChildrenEnumerator.Create(_childlist)\n\tEnd Method\nEnd Type\n\nType TChildrenEnumerator\n\tField _children:TEntity[],_index=-1\n\t\n\tFunction Create:TChildrenEnumerator(list:TList)\n\t\tLocal enum:TChildrenEnumerator=New TChildrenEnumerator\n\t\tenum._children=TEntity[](list.ToArray())\n\t\tReturn enum\n\tEnd Function\n\t\n\tMethod HasNext()\n\t\tReturn _index>=_children.length-1\n\tEnd Method\n\t\n\tMethod NextObject:Object()\n\t\t_index:+1\n\t\tReturn _children[_index]\n\tEnd Method\nEnd Type\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"a429b49cb6c338077877600add6545d9600c26b3","subject":"Added more retro functions.","message":"Added more retro functions.\n","repos":"kfprimm\/maxb3d,kfprimm\/maxb3d","old_file":"retro.mod\/retro.bmx","new_file":"retro.mod\/retro.bmx","new_contents":"\nStrict\n\nRem\n\tbbdoc: Blitz3D style wrapper for MaxB3D\nEnd Rem\nModule MaxB3D.Retro\nModuleInfo \"Author: Kevin Primm\"\nModuleInfo \"License: MIT\"\n\nImport MaxB3D.GLDriver\nImport MaxB3D.D3D9Driver\nImport MaxB3D.Primitives\n\nImport MaxB3D.B3DCollision\n\nImport MaxB3D.A3DSLoader\nImport MaxB3D.B3DLoader\nImport MaxB3D.MD2Loader\nImport MaxB3D.XLoader\n\nImport BRL.BMPLoader\nImport BRL.JPGLoader\nImport BRL.PNGLoader\nImport BRL.TGALoader\n\nPrivate\nGlobal _currentworld:TWorld\nGlobal _renderinfo:TRenderInfo = New TRenderInfo\nGlobal tform_x#, tform_y#, tform_z#\n\nPublic\n\nFunction Graphics3D(width, height, depth = 32, mode = 0)\n\tSelect mode\n\tCase 0\n?Debug\n\t\tdepth = 0 \n?Not Debug\n\t\tdepth = 32\n?\n\tCase 1\n\t\tdepth = 32\n\tCase 2\n\t\tdepth = 0\n\tEnd Select\n\tGraphics width,height,depth\nEnd Function\n' Dither\n' WBuffer\n' AntiAlias\nFunction Wireframe(enable)\n\t_currentworld.SetWireFrame enable\nEnd Function\n' HWMultiTex\nFunction AmbientLight(red, green, blue)\n\t_currentworld.SetAmbientLight red, green, blue\nEnd Function\n' ClearCollisions\n' Collisions\nFunction UpdateWorld(speed# = 1.0)\n\t_currentworld.Update(speed)\nEnd Function\nFunction RenderWorld(tween# = 1.0)\n\t_renderinfo = _currentworld.Render(tween)\nEnd Function\n' CaptureWorld\n' ClearWorld\n' LoaderMatrix\nFunction TrisRendered()\n\tReturn _renderinfo.triangles\nEnd Function\n\n' CreateTexture\nFunction LoadTexture:TTexture(url:Object,flags=TEXTURE_COLOR)\n\tReturn CurrentWorld().AddTexture(url,flags)\nEnd Function\n' LoadAnimTexture\nFunction FreeTexture(texture:TTexture)\n\tReturn texture.Free()\nEnd FUnction\n' TextureBlend\nFunction TextureCoords(texture:TTexture, coords)\n\tReturn texture.SetCoords(coords)\nEnd Function\n' ScaleTexture\n' PositionTexture\n' RotateTexture\nFunction TextureWidth(texture:TTexture)\n\tLocal width,height\n\ttexture.GetSize width,height\n\tReturn width\nEnd Function\nFunction TextureHeight(texture:TTexture)\n\tLocal width,height\n\ttexture.GetSize width,height\n\tReturn height\nEnd Function\n' TextureName\n' GetBrushTexture\nFunction ClearTextureFilters()\n\tReturn _currentworld.ClearTextureFilters()\nEnd Function\nFunction TextureFilter(text$, flags)\n\tReturn _currentworld.AddTextureFilter(text, flags)\nEnd Function\n' SetCubeFace\n' SetCubeMode\n\nFunction CreateBrush:TBrush(red=255,green=255,blue=255)\n\tReturn _currentworld.AddBrush([red,green,blue])\nEnd Function\nFunction CopyBrush:TBrush(brush:TBrush)\n\tReturn brush.Copy()\nEnd Function\nFunction BrushColor(brush:TBrush,red,green,blue)\n\tReturn brush.SetColor(red,green,blue)\nEnd Function\nFunction BrushAlpha(brush:TBrush,alpha#)\n\tReturn brush.SetAlpha(alpha)\nEnd Function\nFunction BrushShininess(brush:TBrush,shine#)\n\tReturn brush.SetShine(shine)\nEnd Function\nFunction BrushTexture(brush:TBrush,texture:TTexture,index=0,frame=0)\n\tReturn brush.SetTexture(texture,index,frame)\nEnd Function\nFunction BrushFX(brush:TBrush,fx)\n\tReturn brush.SetFX(fx)\nEnd Function\nFunction BrushBlend(brush:TBrush,fx)\n\tReturn brush.SetBlend(fx)\nEnd Function\n\nRem\n' LoadBrush\n' FreeBrush\n' GetEntityBrush\n' GetSurfaceBrush\n\n' CreateMesh\n' LoadMesh\n' LoadAnimMesh\n' CreateCube\n' CreateSphere\n' CreateCylinder\n' CreateCone\n' CopyMesh\n' AddMesh\n' FlipMesh\n' PaintMesh\n' LightMesh\n' FitMesh\n' ScaleMesh\n' RotateMesh\n' PositionMesh\n' UpdateNormals\n' MeshesIntersect\n' MeshWidth\n' MeshHeight\n' MeshDepth\nEnd Rem\nFunction CountSurfaces(mesh:TMesh)\n\tReturn mesh.CountSurfaces()\nEnd Function\nFunction GetSurface:TSurface(mesh:TMesh,index)\n\tReturn mesh.GetSurface(index-1)\nEnd Function\nRem\n\n' CreateSurface\n' PaintSurface\n' ClearSurface\n' FindSurface\n' AddVertex\n' AddTriangle\n' VertexCoords\n' VertexNormal\n' VertexColor\n' VertexTexCoords\nEnd Rem\nFunction CountVertices(surface:TSurface)\n\tReturn surface.CountVertices()\nEnd Function\nFunction CountTriangles(surface:TSurface)\n\tReturn surface.CountTriangles()\nEnd Function\nFunction VertexX#(surface:TSurface, index)\n\tLocal x#,y#,z#\n\tsurface.GetCoords index,x,y,z\n\tReturn x\nEnd Function\nFunction VertexY#(surface:TSurface, index)\n\tLocal x#,y#,z#\n\tsurface.GetCoords index,x,y,z\n\tReturn y\nEnd Function\nFunction VertexZ#(surface:TSurface, index)\n\tLocal x#,y#,z#\n\tsurface.GetCoords index,x,y,z\n\tReturn z\nEnd Function\nFunction VertexNX#(surface:TSurface, index)\n\tLocal nx#,ny#,nz#\n\tsurface.GetNormal index,nx,ny,nz\n\tReturn nx\nEnd Function\nFunction VertexNY#(surface:TSurface, index)\n\tLocal nx#,ny#,nz#\n\tsurface.GetNormal index,nx,ny,nz\n\tReturn ny\nEnd Function\nFunction VertexNZ#(surface:TSurface, index)\n\tLocal nx#,ny#,nz#\n\tsurface.GetNormal index,nx,ny,nz\n\tReturn nz\nEnd Function\nFunction VertexRed(surface:TSurface, index)\n\tLocal red,green,blue,alpha#\n\tsurface.GetColor index,red,green,blue,alpha\n\tReturn red\nEnd Function\nFunction VertexGreen(surface:TSurface, index)\n\tLocal red,green,blue,alpha#\n\tsurface.GetColor index,red,green,blue,alpha\n\tReturn green\nEnd Function\nFunction VertexBlue(surface:TSurface, index)\n\tLocal red,green,blue,alpha#\n\tsurface.GetColor index,red,green,blue,alpha\n\tReturn blue\nEnd Function\nFunction VertexAlpha#(surface:TSurface, index)\n\tLocal red,green,blue,alpha#\n\tsurface.GetColor index,red,green,blue,alpha\n\tReturn alpha\nEnd Function\nFunction VertexU(surface:TSurface, index, set = 0)\n\tLocal u#,v#\n\tsurface.GetTexCoords index,u,v,set\n\tReturn u\nEnd Function\nFunction VertexV(surface:TSurface, index, set = 0)\n\tLocal u#,v#\n\tsurface.GetTexCoords index,u,v,set\n\tReturn v\nEnd Function\nFunction VertexW(surface:TSurface, index)\n\tThrow \"Support for 3d tex coords not implemented!\"\nEnd Function\nFunction TriangleVertex(surface:TSurface, index, corner)\n\tReturn surface._triangle[index*3+corner]\nEnd Function\n\nRem\n\n' CreateCamera\n' CameraProjMode\n' CameraFogMode\n' CameraFogRange\n' CameraFogColor\n' CameraViewport\n' CameraClsMode\n' CameraClsColor\n' CameraRange\n' CameraZoom\n' CameraPick\n' PickedX\n' PickedY\n' PickedZ\n' PickedNX\n' PickedNY\n' PickedNZ\n' PickedTime\n' PickedEntity\n' PickedSurface\n' PickedTriangle\n' CameraProject\n' ProjectedX\n' ProjectedY\n' ProjectedZ\n' EntityInView\n\nEnd Rem\n\nFunction CreateLight:TLight(typ=LIGHT_DIRECTIONAL,parent:TEntity=Null)\n\tReturn _currentworld.AddLight(typ,parent)\nEnd Function\nFunction LightRange(light:TLight,range#)\n\tReturn light.SetRange(range)\nEnd Function\nFunction LightColor(light:TLight,red,green,blue)\n\tReturn light.SetColor(red,green,blue)\nEnd Function\nFunction LightConeAngles(light:TLight,inner#,outer#)\n\tReturn light.SetAngles(inner,outer)\nEnd Function\n\nFunction CreatePivot:TPivot(parent:TEntity=Null)\n\tReturn _currentworld.AddPivot(parent)\nEnd Function\n\nRem\n' CreateSprite\n' LoadSprite\n' RotateSprite\n' ScaleSprite\n' HandleSprite\n' SpriteViewMode\n\n' LoadMD2\n' AnimateMD2\n' MD2AnimTime\n' MD2AnimLength\n' MD2Animating\n\n' LoadBSP\n' BSPAmbientLight\n' BSPLighting\n\n' CreatePlane\n\n' CreateMirror\n\n' CreateTerrain\n' LoadTerrain\n' TerrainSize\n' TerrainDetail\n' TerrainShading\n' TerrainHeight\n' ModifyTerrain\n' TerrainX\n' TerrainY\n' TerrainZ\n\n' CreateListener\n' Load3DSound\n' EmitSound\n\n' ScaleEntity\n' PositionEntity\n' MoveEntity\n' TranslateEntity\n' RotateEntity\n' TurnEntity\n' PointEntity\n' AlignToVector\n\n' LoadAnimSeq\n' SetAnimKey\n' AddAnimSeq\n' ExtractAnimSeq\n' Animate\n' SetAnimTime\n' AnimSeq\n' AnimLength\n' AnimTime\n' Animating\nEnd Rem\n\nFunction FreeEntity(entity:TEntity)\n\tReturn entity.Free()\nEnd Function\nFunction CopyEntity:TEntity(entity:TEntity, parent:TEntity = Null)\n\tReturn entity.Copy(parent)\nEnd Function\nFunction EntityColor(entity:TEntity, red, green, blue)\n\tReturn entity.SetColor(red, green, blue)\nEnd Function\nFunction EntityAlpha(entity:TEntity, alpha#)\n\tReturn entity.SetAlpha(alpha)\nEnd Function\nFunction EntityShininess(entity:TEntity, shine#)\n\tReturn entity.SetShine(shine)\nEnd Function\nFunction EntityTexture(entity:TEntity, texture:TTexture, frame = 0, index = 0)\n\tReturn entity.SetTexture(texture, frame, index)\nEnd Function\nFunction EntityBlend(entity:TEntity, blend)\n\tReturn entity.SetBlend(blend)\nEnd Function\nFunction EntityFX(entity:TEntity, fx)\n\tReturn entity.SetFX(fx)\nEnd Function\n' EntityAutoFade\nFunction PaintEntity(entity:TEntity, brush:TBrush)\n\tReturn entity.SetBrush(brush)\nEnd Function\nFunction EntityOrder(entity:TEntity, order)\n\tReturn entity.SetOrder(order)\nEnd Function\nFunction HideEntity(entity:TEntity)\n\tReturn entity.SetVisible(False)\nEnd Function\nFunction ShowEntity(entity:TEntity)\n\tReturn entity.SetVisible(True)\nEnd Function\nFunction NameEntity(entity:TEntity, name$)\n\tReturn entity.SetName(name)\nEnd Function\nFunction EntityParent(entity:TEntity, parent:TEntity, glob = True)\n\tReturn entity.SetParent(parent, glob)\nEnd Function\nFunction GetParent:TEntity(entity:TEntity)\n\tReturn entity.GetParent()\nEnd Function\n\nFunction EntityX#(entity:TEntity, glob = False)\n\tLocal x#,y#,z#\n\tentity.GetPosition x,y,z,glob\n\tReturn x\nEnd Function\nFunction EntityY#(entity:TEntity, glob = False)\n\tLocal x#,y#,z#\n\tentity.GetPosition x,y,z,glob\n\tReturn y\nEnd Function\nFunction EntityZ#(entity:TEntity, glob = False)\n\tLocal x#,y#,z#\n\tentity.GetPosition x,y,z,glob\n\tReturn z\nEnd Function\n' EntityRoll\n' EntityYaw\n' EntityPitch\n' EntityClass\n' EntityName\n' CountChildren\n' GetChild\n' FindChild\n' EntityPick\n' LinePick\n' EntityVisible\n' EntityDistance\n' DeltaYaw\n' DeltaPitch\n\n\nFunction TFormPoint(x#,y#,z#,src:TEntity,dest:TEntity)\n\tLocal matrix:TMatrix = src.GetMatrix()\n\tmatrix.TransformVec3 x,y,z\n\ttform_x = x\n\ttform_y = y\n\ttform_z = z\nEnd Function\n' TFormVector\n' TFormNormal\nFunction TFormedX#()\n\tReturn tform_x\nEnd Function\nFunction TFormedY#()\n\tReturn tform_y\nEnd Function\nFunction TFormedZ#()\n\tReturn tform_z\nEnd Function\n\n' GetMatElement\n\n' ResetEntity\n' EntityRadius\n' EntityBox\n' EntityType\n' EntityPickMode\n' EntityCollided\n' CountCollisions\n' CollisionX\n' CollisionY\n' CollisionZ\n' CollisionNX\n' CollisionNY\n' CollisionNZ\n' CollisionTime\n' CollisionEntity\n' CollisionSurface\n' CollisionTriangle\nFunction GetEntityType(entity:TEntity)\n\tReturn entity.GetType()\nEnd Function\n\n' VectorYaw\n' VectorPitch\n\n' CountGfxModes3D\n' GfxMode3D\n' GfxMode3DExists\n' GfxDriver3D\n' GfxDriverCaps3D\n' Windowed3D\n' HWTexUnits\n\nFunction ClsColor(red,green,blue)\t\n\tReturn SetClsColor(red,green,blue)\nEnd Function\n\nSetWorld CreateWorld()\n","old_contents":"\nStrict\n\nRem\n\tbbdoc: Blitz3D style wrapper for MaxB3D\nEnd Rem\nModule MaxB3D.Retro\nModuleInfo \"Author: Kevin Primm\"\nModuleInfo \"License: MIT\"\n\nImport MaxB3D.GLDriver\nImport MaxB3D.D3D9Driver\nImport MaxB3D.Primitives\n\nImport MaxB3D.B3DCollision\n\nImport MaxB3D.A3DSLoader\nImport MaxB3D.B3DLoader\nImport MaxB3D.MD2Loader\nImport MaxB3D.XLoader\n\nImport BRL.BMPLoader\nImport BRL.JPGLoader\nImport BRL.PNGLoader\nImport BRL.TGALoader\n\nPrivate\nGlobal _currentworld:TWorld\nGlobal _renderinfo:TRenderInfo = New TRenderInfo\n\nPublic\n\nFunction Graphics3D(width, height, depth = 32, mode = 0)\n\tSelect mode\n\tCase 0\n?Debug\n\t\tdepth = 0 \n?Not Debug\n\t\tdepth = 32\n?\n\tCase 1\n\t\tdepth = 32\n\tCase 2\n\t\tdepth = 0\n\tEnd Select\n\tGraphics width,height,depth\nEnd Function\nRem\n# Dither\n# WBuffer\n# AntiAlias\nEnd Rem\nFunction Wireframe(enable)\n\t_currentworld.SetWireFrame enable\nEnd Function\n'# HWMultiTex\nFunction AmbientLight(red, green, blue)\n\t_currentworld.SetAmbientLight red, green, blue\nEnd Function\nRem\n# ClearCollisions\n# Collisions\nEnd Rem\nFunction UpdateWorld(speed# = 1.0)\n\t_currentworld.Update(speed)\nEnd Function\nFunction RenderWorld(tween# = 1.0)\n\t_renderinfo = _currentworld.Render(tween)\nEnd Function\nRem\n# CaptureWorld\n# ClearWorld\n# LoaderMatrix\nEnd Rem\nFunction TrisRendered()\n\tReturn _renderinfo.triangles\nEnd Function\n\nRem\n# CreateTexture\n# LoadTexture\n# LoadAnimTexture\n# FreeTexture\n# TextureBlend\n# TextureCoords\n# ScaleTexture\n# PositionTexture\n# RotateTexture\nEnd Rem\nFunction TextureWidth(texture:TTexture)\n\tLocal width,height\n\ttexture.GetSize width,height\n\tReturn width\nEnd Function\nFunction TextureHeight(texture:TTexture)\n\tLocal width,height\n\ttexture.GetSize width,height\n\tReturn height\nEnd Function\nRem\n# TextureName\n# GetBrushTexture\nEnd Rem\nFunction ClearTextureFilters()\n\tReturn _currentworld.ClearTextureFilters()\nEnd Function\nFunction TextureFilter(text$, flags)\n\tReturn _currentworld.AddTextureFilter(text, flags)\nEnd Function\nRem\n# SetCubeFace\n# SetCubeMode\nEnd Rem\n\nFunction CreateBrush:TBrush(red=255,green=255,blue=255)\n\tReturn _currentworld.AddBrush([red,green,blue])\nEnd Function\nFunction CopyBrush:TBrush(brush:TBrush)\n\tReturn brush.Copy()\nEnd Function\nFunction BrushColor(brush:TBrush,red,green,blue)\n\tReturn brush.SetColor(red,green,blue)\nEnd Function\nFunction BrushAlpha(brush:TBrush,alpha#)\n\tReturn brush.SetAlpha(alpha)\nEnd Function\nFunction BrushShininess(brush:TBrush,shine#)\n\tReturn brush.SetShine(shine)\nEnd Function\nFunction BrushTexture(brush:TBrush,texture:TTexture,index=0,frame=0)\n\tReturn brush.SetTexture(texture,index,frame)\nEnd Function\nFunction BrushFX(brush:TBrush,fx)\n\tReturn brush.SetFX(fx)\nEnd Function\nFunction BrushBlend(brush:TBrush,fx)\n\tReturn brush.SetBlend(fx)\nEnd Function\n\nRem\n# LoadBrush\n# FreeBrush\n# GetEntityBrush\n# GetSurfaceBrush\n\n# CreateMesh\n# LoadMesh\n# LoadAnimMesh\n# CreateCube\n# CreateSphere\n# CreateCylinder\n# CreateCone\n# CopyMesh\n# AddMesh\n# FlipMesh\n# PaintMesh\n# LightMesh\n# FitMesh\n# ScaleMesh\n# RotateMesh\n# PositionMesh\n# UpdateNormals\n# MeshesIntersect\n# MeshWidth\n# MeshHeight\n# MeshDepth\n# CountSurfaces\n# GetSurface\n\n# CreateSurface\n# PaintSurface\n# ClearSurface\n# FindSurface\n# AddVertex\n# AddTriangle\n# VertexCoords\n# VertexNormal\n# VertexColor\n# VertexTexCoords\n# CountVertices\n# CountTriangles\n# VertexX\n# VertexY\n# VertexZ\n# VertexNX\n# VertexNY\n# VertexNZ\n# VertexRed\n# VertexGreen\n# VertexBlue\n# VertexAlpha\n# VertexU\n# VertexV\n# VertexW\n# TriangleVertex\n\n# CreateCamera\n# CameraProjMode\n# CameraFogMode\n# CameraFogRange\n# CameraFogColor\n# CameraViewport\n# CameraClsMode\n# CameraClsColor\n# CameraRange\n# CameraZoom\n# CameraPick\n# PickedX\n# PickedY\n# PickedZ\n# PickedNX\n# PickedNY\n# PickedNZ\n# PickedTime\n# PickedEntity\n# PickedSurface\n# PickedTriangle\n# CameraProject\n# ProjectedX\n# ProjectedY\n# ProjectedZ\n# EntityInView\n\nEnd Rem\n\nFunction CreateLight:TLight(typ=LIGHT_DIRECTIONAL,parent:TEntity=Null)\n\tReturn _currentworld.AddLight(typ,parent)\nEnd Function\nFunction LightRange(light:TLight,range#)\n\tReturn light.SetRange(range)\nEnd Function\nFunction LightColor(light:TLight,red,green,blue)\n\tReturn light.SetColor(red,green,blue)\nEnd Function\nFunction LightConeAngles(light:TLight,inner#,outer#)\n\tReturn light.SetAngles(inner,outer)\nEnd Function\n\nFunction CreatePivot:TPivot(parent:TEntity=Null)\n\tReturn _currentworld.AddPivot(parent)\nEnd Function\n\nRem\n# CreateSprite\n# LoadSprite\n# RotateSprite\n# ScaleSprite\n# HandleSprite\n# SpriteViewMode\n\n# LoadMD2\n# AnimateMD2\n# MD2AnimTime\n# MD2AnimLength\n# MD2Animating\n\n# LoadBSP\n# BSPAmbientLight\n# BSPLighting\n\n# CreatePlane\n\n# CreateMirror\n\n# CreateTerrain\n# LoadTerrain\n# TerrainSize\n# TerrainDetail\n# TerrainShading\n# TerrainHeight\n# ModifyTerrain\n# TerrainX\n# TerrainY\n# TerrainZ\n\n# CreateListener\n# Load3DSound\n# EmitSound\n\n# ScaleEntity\n# PositionEntity\n# MoveEntity\n# TranslateEntity\n# RotateEntity\n# TurnEntity\n# PointEntity\n# AlignToVector\n\n# LoadAnimSeq\n# SetAnimKey\n# AddAnimSeq\n# ExtractAnimSeq\n# Animate\n# SetAnimTime\n# AnimSeq\n# AnimLength\n# AnimTime\n# Animating\nEnd Rem\n\nFunction FreeEntity(entity:TEntity)\n\tReturn entity.Free()\nEnd Function\nFunction CopyEntity:TEntity(entity:TEntity, parent:TEntity = Null)\n\tReturn entity.Copy(parent)\nEnd Function\nFunction EntityColor(entity:TEntity, red, green, blue)\n\tReturn entity.SetColor(red, green, blue)\nEnd Function\nFunction EntityAlpha(entity:TEntity, alpha#)\n\tReturn entity.SetAlpha(alpha)\nEnd Function\nFunction EntityShininess(entity:TEntity, shine#)\n\tReturn entity.SetShine(shine)\nEnd Function\nFunction EntityTexture(entity:TEntity, texture:TTexture, frame = 0, index = 0)\n\tReturn entity.SetTexture(texture, frame, index)\nEnd Function\nFunction EntityBlend(entity:TEntity, blend)\n\tReturn entity.SetBlend(blend)\nEnd Function\nFunction EntityFX(entity:TEntity, fx)\n\tReturn entity.SetFX(fx)\nEnd Function\n'# EntityAutoFade\nFunction PaintEntity(entity:TEntity, brush:TBrush)\n\tReturn entity.SetBrush(brush)\nEnd Function\nFunction EntityOrder(entity:TEntity, order)\n\tReturn entity.SetOrder(order)\nEnd Function\nFunction HideEntity(entity:TEntity)\n\tReturn entity.SetVisible(False)\nEnd Function\nFunction ShowEntity(entity:TEntity)\n\tReturn entity.SetVisible(True)\nEnd Function\nFunction NameEntity(entity:TEntity, name$)\n\tReturn entity.SetName(name)\nEnd Function\nFunction EntityParent(entity:TEntity, parent:TEntity, glob = True)\n\tReturn entity.SetParent(parent, glob)\nEnd Function\nFunction GetParent:TEntity(entity:TEntity)\n\tReturn entity.GetParent()\nEnd Function\n\nFunction EntityX#(entity:TEntity, glob = False)\n\tLocal x#,y#,z#\n\tentity.GetPosition x,y,z,glob\n\tReturn x\nEnd Function\nFunction EntityY#(entity:TEntity, glob = False)\n\tLocal x#,y#,z#\n\tentity.GetPosition x,y,z,glob\n\tReturn y\nEnd Function\nFunction EntityZ#(entity:TEntity, glob = False)\n\tLocal x#,y#,z#\n\tentity.GetPosition x,y,z,glob\n\tReturn z\nEnd Function\nRem\n# EntityRoll\n# EntityYaw\n# EntityPitch\n# EntityClass\n# EntityName\n# CountChildren\n# GetChild\n# FindChild\n# EntityPick\n# LinePick\n# EntityVisible\n# EntityDistance\n# DeltaYaw\n# DeltaPitch\n# TFormPoint\n# TFormVector\n# TFormNormal\n# TFormedX\n# TFormedY\n# TFormedZ\n# GetMatElement\n\n# ResetEntity\n# EntityRadius\n# EntityBox\n# EntityType\n# EntityPickMode\n# EntityCollided\n# CountCollisions\n# CollisionX\n# CollisionY\n# CollisionZ\n# CollisionNX\n# CollisionNY\n# CollisionNZ\n# CollisionTime\n# CollisionEntity\n# CollisionSurface\n# CollisionTriangle\nEnd Rem\nFunction GetEntityType(entity:TEntity)\n\tReturn entity.GetType()\nEnd Function\n\nRem\n# VectorYaw\n# VectorPitch\n\n# CountGfxModes3D\n# GfxMode3D\n# GfxMode3DExists\n# GfxDriver3D\n# GfxDriverCaps3D\n# Windowed3D\n# HWTexUnits\nEnd Rem\n\nSetWorld CreateWorld()\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"2a0ed0448189fa850e5f931b4a93ef8362f87019","subject":"Added TTexture.Free","message":"Added TTexture.Free\n","repos":"kfprimm\/maxb3d,kfprimm\/maxb3d","old_file":"core.mod\/texture.bmx","new_file":"core.mod\/texture.bmx","new_contents":"\nStrict\n\nImport MaxB3D.Logging\nImport BRL.Pixmap\nImport \"worldconfig.bmx\"\nImport \"resource.bmx\"\n\nPrivate\nFunction ModuleLog(message$)\n\tTMaxB3DLogger.Write \"core\/texture\",message\nEnd Function\n\nPublic\n\nConst TEXTURE_COLOR\t\t= 1\nConst TEXTURE_ALPHA\t\t= 2\nConst TEXTURE_MASKED\t= 4\nConst TEXTURE_MIPMAP\t= 8\nConst TEXTURE_CLAMPU\t= 16\nConst TEXTURE_CLAMPV\t= 32\nConst TEXTURE_SPHEREMAP\t= 64\nConst TEXTURE_CUBEMAP\t= 128\nConst TEXTURE_VRAM\t\t= 256\nConst TEXTURE_HIGHCOLOR\t= 512\nConst TEXTURE_DEPTH \t= 1024\n\nConst TEXTURE_DEFAULT\t= TEXTURE_COLOR\nConst TEXTURE_CLAMPUV\t= TEXTURE_CLAMPU|TEXTURE_CLAMPV\n\nConst BLEND_NONE = 0\nConst BLEND_ALPHA\t = 1\nConst BLEND_MULTIPLY = 2\nConst BLEND_ADD = 3\nConst BLEND_DOT3 = 4\nConst BLEND_MULTIPLY2 = 5\n\nConst CUBETEX_LEFT = 0\nConst CUBETEX_FRONT = 1\nConst CUBETEX_RIGHT = 2\nConst CUBETEX_BACK = 3\nConst CUBETEX_UP = 4\nConst CUBETEX_DOWN = 5\n\nType TTexture\n\tField _blend=BLEND_MULTIPLY,_coords,_flags\n\tField _px#,_py#,_r#,_sx#=1.0,_sy#=1.0\n\tField _width=-1,_height=-1,_frame:TTextureFrame[]\n\tField _name$\n\t\n\tField _linklist:TList = New TList\n\t\n\tMethod Free()\n\t\tFor Local link:TLink = EachIn _linklist\n\t\t\tRemoveLink link\n\t\tNext\n\tEnd Method\n\t\n\tMethod Init:TTexture(config:TWorldConfig,url:Object,flags)\n\t\tLocal pixmap:TPixmap[]\n\t\t\n\t\tIf Int[](url)\n\t\t\tLocal arr[]=Int[](url),width,height,frames=1\n\t\t\tIf arr.length=0 Return Null\n\t\t\tIf arr.length=1 width=arr[0];height=arr[0]\n\t\t\tIf arr.length>1 width=arr[0];height=arr[1]\n\t\t\tIf arr.length>2 frames=arr[2]\t\n\t\t\tpixmap=New TPixmap[frames]\n\t\t\tFor Local i=0 To frames-1\n\t\t\t\tpixmap[i]=CreatePixmap(width,height,PF_BGRA8888)\n\t\t\tNext\n\t\tElseIf TPixmap(url) \n\t\t\tpixmap=[TPixmap(url)]\n\t\t\tIf pixmap[0]=Null \n\t\t\t\tIf url ModuleLog \"Invalid texture url passed. (\"+url.ToString()+\")\" Else ModuleLog \"Invalid texture url passed.\"\n\t\t\t\tReturn Null\n\t\t\tEndIf\n\t\tElse\n\t\t\tpixmap=[LoadPixmap(config.GetStream(url))]\n\t\t\tIf pixmap[0]=Null \n\t\t\t\tIf url ModuleLog \"Invalid texture url passed. (\"+url.ToString()+\")\" Else ModuleLog \"Invalid texture url passed.\"\n\t\t\t\tReturn Null\n\t\t\tEndIf\n\t\tEndIf\n\t\t\n\t\tIf pixmap.length=0\n\t\t\tIf url ModuleLog \"Invalid texture url passed. (\"+url.ToString()+\")\" Else ModuleLog \"Invalid texture url passed.\"\n\t\t\tReturn Null\n\t\tEndIf\n\t\t\n\t\tIf String(url) flags = config.ProcessTextureFilters(String(url),flags)\n\t\t\n\t\tSetName url.ToString()\n\t\tSetSize -1,-1,pixmap.length\n\t\tFor Local i=0 To pixmap.length-1\n\t\t\tIf flags&TEXTURE_MASKED pixmap[i] = MaskPixmap(pixmap[i],0,0,0)\n\t\t\tSetPixmap pixmap[i],i\n\t\tNext\t\t\t\n\t\tSetFlags flags\n\t\tconfig.AddObject Self,WORLDLIST_TEXTURE\n\t\t\n\t\tReturn Self\n\tEnd Method\n\t\n\t\t\n\tMethod Lock:TPixmap(index=0)\n\t\t_frame[index]._locked=True\n\t\tReturn _frame[index]._pixmap\n\tEnd Method\n\t\n\tMethod Unlock(index=0)\n\t\t_frame[index]._locked=False\n\t\t_frame[index]._updateres=True\n\tEnd Method\n\t\n\tMethod SetPixmap(pixmap:TPixmap,index=0)\n\t\tIf pixmap=Null _frame[index]=Null;Return\n\t\tIf _frame[index]=Null _frame[index]=New TTextureFrame\n\t\t_frame[index]._pixmap=ConvertPixmap(pixmap,PF_BGRA8888)\n\t\t_frame[index]._updateres=True\n\t\t\n\t\tIf (_width<>-1 Or _height<>-1) And (_width<>PixmapWidth(pixmap) Or _height<>PixmapHeight(pixmap))\n\t\t\tThrow \"Pixmap size does not match texture size.\"\n\t\tElse\n\t\t\t_width=PixmapWidth(pixmap)\n\t\t\t_height=PixmapHeight(pixmap)\n\t\tEndIf\n\tEnd Method\n\t\n\tMethod GetFlags()\n\t\tReturn _flags\n\tEnd Method\n\tMethod SetFlags(flags)\n\t\t_flags=flags\n\tEnd Method\t\n\t\n\tMethod GetBlend()\n\t\tReturn _blend\n\tEnd Method\n\tMethod SetBlend(blend)\n\t\t_blend=blend\n\tEnd Method\n\t\n\tMethod GetCoords()\n\t\tReturn _coords\n\tEnd Method\n\tMethod SetCoords(set)\n\t\t_coords=set\n\tEnd Method\n\t\n\tMethod GetScale(x# Var,y# Var)\n\t\tx=1.0\/_sx;y=1.0\/_sy\n\tEnd Method\n\tMethod SetScale(x#,y#)\n\t\t_sx=1.0\/x;_sy=1.0\/y\n\tEnd Method\n\t\n\tMethod GetPosition(x# Var,y# Var)\n\t\tx=_px;y=_py\n\tEnd Method\n\tMethod SetPosition(x#,y#)\n\t\t_px=x;_py=y\n\tEnd Method\n\t\n\tMethod GetRotation#()\n\t\tReturn _r\n\tEnd Method\n\tMethod SetRotation(angle#)\n\t\t_r=angle\n\tEnd Method\n\t\n\tMethod GetSize(width Var,height Var)\n\t\twidth=_width;height=_height\n\tEnd Method\n\tMethod SetSize(width,height,frames)\n\t\t_width=width\n\t\t_height=height\n\t\t_frame=_frame[..frames]\n\tEnd Method\n\n\tMethod GetName$()\n\t\tReturn _name\n\tEnd Method\n\tMethod SetName(name$)\n\t\t_name=name\n\tEnd Method\nEnd Type\n\nType TTextureFrame \n\tField _res:TTextureRes,_updateres\t\n\tField _pixmap:TPixmap,_locked\n\tField _buffer:Object\nEnd Type\n\nType TTextureRes Extends TDriverResource\n\nEnd Type\n\n","old_contents":"\nStrict\n\nImport MaxB3D.Logging\nImport BRL.Pixmap\nImport \"worldconfig.bmx\"\nImport \"resource.bmx\"\n\nPrivate\nFunction ModuleLog(message$)\n\tTMaxB3DLogger.Write \"core\/texture\",message\nEnd Function\n\nPublic\n\nConst TEXTURE_COLOR\t\t= 1\nConst TEXTURE_ALPHA\t\t= 2\nConst TEXTURE_MASKED\t= 4\nConst TEXTURE_MIPMAP\t= 8\nConst TEXTURE_CLAMPU\t= 16\nConst TEXTURE_CLAMPV\t= 32\nConst TEXTURE_SPHEREMAP\t= 64\nConst TEXTURE_CUBEMAP\t= 128\nConst TEXTURE_VRAM\t\t= 256\nConst TEXTURE_HIGHCOLOR\t= 512\nConst TEXTURE_DEPTH \t= 1024\n\nConst TEXTURE_DEFAULT\t= TEXTURE_COLOR\nConst TEXTURE_CLAMPUV\t= TEXTURE_CLAMPU|TEXTURE_CLAMPV\n\nConst BLEND_NONE = 0\nConst BLEND_ALPHA\t = 1\nConst BLEND_MULTIPLY = 2\nConst BLEND_ADD = 3\nConst BLEND_DOT3 = 4\nConst BLEND_MULTIPLY2 = 5\n\nConst CUBETEX_LEFT = 0\nConst CUBETEX_FRONT = 1\nConst CUBETEX_RIGHT = 2\nConst CUBETEX_BACK = 3\nConst CUBETEX_UP = 4\nConst CUBETEX_DOWN = 5\n\nType TTexture\n\tField _blend=BLEND_MULTIPLY,_coords,_flags\n\tField _px#,_py#,_r#,_sx#=1.0,_sy#=1.0\n\tField _width=-1,_height=-1,_frame:TTextureFrame[]\n\tField _name$\n\t\n\tMethod Init:TTexture(config:TWorldConfig,url:Object,flags)\n\t\tLocal pixmap:TPixmap[]\n\t\t\n\t\tIf Int[](url)\n\t\t\tLocal arr[]=Int[](url),width,height,frames=1\n\t\t\tIf arr.length=0 Return Null\n\t\t\tIf arr.length=1 width=arr[0];height=arr[0]\n\t\t\tIf arr.length>1 width=arr[0];height=arr[1]\n\t\t\tIf arr.length>2 frames=arr[2]\t\n\t\t\tpixmap=New TPixmap[frames]\n\t\t\tFor Local i=0 To frames-1\n\t\t\t\tpixmap[i]=CreatePixmap(width,height,PF_BGRA8888)\n\t\t\tNext\n\t\tElseIf TPixmap(url) \n\t\t\tpixmap=[TPixmap(url)]\n\t\t\tIf pixmap[0]=Null \n\t\t\t\tIf url ModuleLog \"Invalid texture url passed. (\"+url.ToString()+\")\" Else ModuleLog \"Invalid texture url passed.\"\n\t\t\t\tReturn Null\n\t\t\tEndIf\n\t\tElse\n\t\t\tpixmap=[LoadPixmap(config.GetStream(url))]\n\t\t\tIf pixmap[0]=Null \n\t\t\t\tIf url ModuleLog \"Invalid texture url passed. (\"+url.ToString()+\")\" Else ModuleLog \"Invalid texture url passed.\"\n\t\t\t\tReturn Null\n\t\t\tEndIf\n\t\tEndIf\n\t\t\n\t\tIf pixmap.length=0\n\t\t\tIf url ModuleLog \"Invalid texture url passed. (\"+url.ToString()+\")\" Else ModuleLog \"Invalid texture url passed.\"\n\t\t\tReturn Null\n\t\tEndIf\n\t\t\n\t\tIf String(url) flags = config.ProcessTextureFilters(String(url),flags)\n\t\t\n\t\tSetName url.ToString()\n\t\tSetSize -1,-1,pixmap.length\n\t\tFor Local i=0 To pixmap.length-1\n\t\t\tIf flags&TEXTURE_MASKED pixmap[i] = MaskPixmap(pixmap[i],0,0,0)\n\t\t\tSetPixmap pixmap[i],i\n\t\tNext\t\t\t\n\t\tSetFlags flags\n\t\tconfig.AddObject Self,WORLDLIST_TEXTURE\n\t\t\n\t\tReturn Self\n\tEnd Method\n\t\n\t\t\n\tMethod Lock:TPixmap(index=0)\n\t\t_frame[index]._locked=True\n\t\tReturn _frame[index]._pixmap\n\tEnd Method\n\t\n\tMethod Unlock(index=0)\n\t\t_frame[index]._locked=False\n\t\t_frame[index]._updateres=True\n\tEnd Method\n\t\n\tMethod SetPixmap(pixmap:TPixmap,index=0)\n\t\tIf pixmap=Null _frame[index]=Null;Return\n\t\tIf _frame[index]=Null _frame[index]=New TTextureFrame\n\t\t_frame[index]._pixmap=ConvertPixmap(pixmap,PF_BGRA8888)\n\t\t_frame[index]._updateres=True\n\t\t\n\t\tIf (_width<>-1 Or _height<>-1) And (_width<>PixmapWidth(pixmap) Or _height<>PixmapHeight(pixmap))\n\t\t\tThrow \"Pixmap size does not match texture size.\"\n\t\tElse\n\t\t\t_width=PixmapWidth(pixmap)\n\t\t\t_height=PixmapHeight(pixmap)\n\t\tEndIf\n\tEnd Method\n\t\n\tMethod GetFlags()\n\t\tReturn _flags\n\tEnd Method\n\tMethod SetFlags(flags)\n\t\t_flags=flags\n\tEnd Method\t\n\t\n\tMethod GetBlend()\n\t\tReturn _blend\n\tEnd Method\n\tMethod SetBlend(blend)\n\t\t_blend=blend\n\tEnd Method\n\t\n\tMethod GetCoords()\n\t\tReturn _coords\n\tEnd Method\n\tMethod SetCoords(set)\n\t\t_coords=set\n\tEnd Method\n\t\n\tMethod GetScale(x# Var,y# Var)\n\t\tx=1.0\/_sx;y=1.0\/_sy\n\tEnd Method\n\tMethod SetScale(x#,y#)\n\t\t_sx=1.0\/x;_sy=1.0\/y\n\tEnd Method\n\t\n\tMethod GetPosition(x# Var,y# Var)\n\t\tx=_px;y=_py\n\tEnd Method\n\tMethod SetPosition(x#,y#)\n\t\t_px=x;_py=y\n\tEnd Method\n\t\n\tMethod GetRotation#()\n\t\tReturn _r\n\tEnd Method\n\tMethod SetRotation(angle#)\n\t\t_r=angle\n\tEnd Method\n\t\n\tMethod GetSize(width Var,height Var)\n\t\twidth=_width;height=_height\n\tEnd Method\n\tMethod SetSize(width,height,frames)\n\t\t_width=width\n\t\t_height=height\n\t\t_frame=_frame[..frames]\n\tEnd Method\n\n\tMethod GetName$()\n\t\tReturn _name\n\tEnd Method\n\tMethod SetName(name$)\n\t\t_name=name\n\tEnd Method\nEnd Type\n\nType TTextureFrame \n\tField _res:TTextureRes,_updateres\t\n\tField _pixmap:TPixmap,_locked\n\tField _buffer:Object\nEnd Type\n\nType TTextureRes Extends TDriverResource\n\nEnd Type\n\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"6ac974dd26b5a29e4f433a6a2882052b4fc89a74","subject":"method.bmx: * Added line breaks to the end of the method implementation and removed them from the concatenation operations.","message":"method.bmx:\n* Added line breaks to the end of the method implementation and removed them from the concatenation operations.","repos":"nilium\/lugi.mod,nilium\/lugi.mod","old_file":"Generator\/method.bmx","new_file":"Generator\/method.bmx","new_contents":"Strict\n\nImport \"metadata.bmx\"\n\nPrivate\n\nConst METH_PREFIX$=\"_lugi_glue\"\t' An _ will always follow this\n\nPublic\n\nType LExposedMethod\n\tField methodid:TMethod\n\tField owner:TTypeId\n\tField name$\n\tField hidden%\n\tField tag$\n\t\n\tMethod New()\n\t\tConst TAGCHARS$=\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_\"\n\t\t\n\t\t' generate a short tag to follow the method name, just to reduce the chance of conflicts\n\t\tLocal tagbuff:Short[7]\n\t\ttagbuff[0] = 95 ' underscore\n\t\tFor Local i:Int = 1 Until tagbuff.Length\n\t\t\ttagbuff[i] = TAGCHARS[Rand(0,62)]\n\t\tNext\n\t\ttag = String.FromShorts(tagbuff, tagbuff.Length)\n\tEnd Method\n\t\n\tMethod InitWithMethod:LExposedMethod(meth:TMethod, owner:TTypeId)\n\t\tmethodid = meth\n\t\tSelf.owner = owner\n\t\t\n\t\t' get metadata\n\t\thidden = methodid.Metadata(LUGI_META_HIDDEN).ToInt()>0\n\t\t\n\t\tname = methodid.Metadata(LUGI_META_RENAME).Trim()\n\t\tIf Not name Then\n\t\t\tname = methodid.Name()\n\t\tEndIf\n\t\t\n\t\tReturn Self\n\tEnd Method\n\t\n\tMethod PreInitBlock:String()\n\tEnd Method\n\t\n\tMethod PostInitBlock:String()\n\tEnd Method\n\t\n\tMethod ImplementationName$()\n\t\tReturn METH_PREFIX+\"_\"+owner.Name()+\"_\"+name+tag\n\tEnd Method\n\t\n\tMethod Implementation:String( instanceMethod:Int )\n\t\tIf hidden Then\n\t\t\tReturn Null\n\t\tEndIf\n\t\t\n\t\tLocal head$ = \"Function \"+ImplementationName()+\"(lua_vm:Byte Ptr)~n\"\n\t\tLocal tail$ = \"End Function~n\"\n\t\t\n\t\tIf instanceMethod Then\n\t\t\tReturn head+__instanceImp()+tail\n\t\tElse\n\t\t\tReturn head+__noclassImp()+tail\n\t\tEndIf\n\tEnd Method\n\t\n\t' Implementation for instances\/static types\n\tMethod __instanceImp:String()\n\tEnd Method\n\t\n\t' Implementation for types without classes\n\tMethod __noclassImp:String()\n\t\t\n\tEnd Method\nEnd Type\n","old_contents":"Strict\n\nImport \"metadata.bmx\"\n\nPrivate\n\nConst METH_PREFIX$=\"_lugi_glue\"\t' An _ will always follow this\n\nPublic\n\nType LExposedMethod\n\tField methodid:TMethod\n\tField owner:TTypeId\n\tField name$\n\tField hidden%\n\tField tag$\n\t\n\tMethod New()\n\t\tConst TAGCHARS$=\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_\"\n\t\t\n\t\t' generate a short tag to follow the method name, just to reduce the chance of conflicts\n\t\tLocal tagbuff:Short[7]\n\t\ttagbuff[0] = 95 ' underscore\n\t\tFor Local i:Int = 1 Until tagbuff.Length\n\t\t\ttagbuff[i] = TAGCHARS[Rand(0,62)]\n\t\tNext\n\t\ttag = String.FromShorts(tagbuff, tagbuff.Length)\n\tEnd Method\n\t\n\tMethod InitWithMethod:LExposedMethod(meth:TMethod, owner:TTypeId)\n\t\tmethodid = meth\n\t\tSelf.owner = owner\n\t\t\n\t\t' get metadata\n\t\thidden = methodid.Metadata(LUGI_META_HIDDEN).ToInt()>0\n\t\t\n\t\tname = methodid.Metadata(LUGI_META_RENAME).Trim()\n\t\tIf Not name Then\n\t\t\tname = methodid.Name()\n\t\tEndIf\n\t\t\n\t\tReturn Self\n\tEnd Method\n\t\n\tMethod PreInitBlock:String()\n\tEnd Method\n\t\n\tMethod PostInitBlock:String()\n\tEnd Method\n\t\n\tMethod ImplementationName$()\n\t\tReturn METH_PREFIX+\"_\"+owner.Name()+\"_\"+name+tag\n\tEnd Method\n\t\n\tMethod Implementation:String( instanceMethod:Int )\n\t\tIf hidden Then\n\t\t\tReturn Null\n\t\tEndIf\n\t\t\n\t\tLocal head$ = \"Function \"+ImplementationName()+\"(lua_vm:Byte Ptr)\"\n\t\tLocal tail$ = \"End Function\"\n\t\t\n\t\tIf instanceMethod Then\n\t\t\tReturn head+\"~n\"+__instanceImp()+\"~n\"+tail\n\t\tElse\n\t\t\tReturn head+\"~n\"+__noclassImp()+\"~n\"+tail\n\t\tEndIf\n\tEnd Method\n\t\n\t' Implementation for instances\/static types\n\tMethod __instanceImp:String()\n\tEnd Method\n\t\n\t' Implementation for types without classes\n\tMethod __noclassImp:String()\n\t\t\n\tEnd Method\nEnd Type\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"72cb2857289f9fa2e5a338bacc6740f3464cfcbd","subject":"Removed leftover DebugLog","message":"Removed leftover DebugLog\n","repos":"kfprimm\/maxb3d,kfprimm\/maxb3d","old_file":"core.mod\/terrain.bmx","new_file":"core.mod\/terrain.bmx","new_contents":"\nStrict\n\n'Derived from Warner's engine.\n'http:\/\/code.google.com\/p\/warner-engine\/\n\nImport \"entity.bmx\"\nImport \"roamstep4d.c\"\n\nImport BRL.Random\n\nType TTerrain Extends TEntity\n\tField _heights#[], _size, _lmax, _max_tris, _clmax#\n\tField _handle:Byte Ptr, _data:Float Ptr,_count\n\tField _update\n\t\n\tMethod New()\n\t\t\tSetDetail 14,12000 \n\tEnd Method\n\t\n\tMethod Free()\n\t\tSuper.Free\n\t\t\n\t\t_heights = Null\n\t\t\n\t\tIf _handle\n\t\t\troam_free _handle\n\t\t\t_handle = Null\n\t\tEndIf\n\tEnd Method\n\t\n\tMethod Lists[]()\n\t\tReturn Super.Lists()+[WORLDLIST_TERRAIN, WORLDLIST_RENDER]\n\tEnd Method\n\t\n\tMethod CopyData:TEntity(entity:TEntity)\n\t\tLocal terrain:TTerrain = TTerrain(entity)\n\t\tReturn Super.CopyData(entity)\n\tEnd Method\n\t\n\tMethod Copy:TTerrain(parent:TEntity=Null)\n\t\tReturn TTerrain(Super.Copy_(parent))\n\tEnd Method\n\t\n\tMethod SetMap(url:Object)\n\t\tLocal pixmap:TPixmap=TPixmap(url)\n\t\tIf pixmap=Null pixmap=LoadPixmap(url)\t\t\n\t\tIf pixmap\n\t\t\t_size=Max(PixmapWidth(pixmap),PixmapHeight(pixmap))\n\t\t\tLocal s=1\n\t\t\tWhile s<_size;s:*2;Wend\n\t\t\t_size=s\n\t\t\t_heights=New Float[_size*_size]\n\t\t\tpixmap=ResizePixmap(pixmap,_size,_size)\n\t\t\tFor Local i = 0 To _size-1\n\t\t\t\tFor Local j = 0 To _size-1\n\t\t\t\t\tSetHeight ((ReadPixel(pixmap, i, j) & $FF)\/255.0)*3,j,i\n\t\t\t\tNext\n\t\t\tNext\n\t\tElseIf Int[](url)\n\t\t\t_size = Int[](url)[0]\n\t\t\t_heights=New Float[_size*_size]\n\t\tElse\n\t\t\t_heights=New Float[_size*_size]\n\t\tEndIf\n\t\t_update=True\n\tEnd Method\n\t\n\tMethod GetHeight#(x,z)\n\t\tReturn _heights[(z*_size)+x]\n\tEnd Method\n\tMethod SetHeight(height#,x,z)\n\t\t_heights[(z*_size)+x]=height\t\t\t\n\tEnd Method\t\n\t\n\tMethod GetSize()\n\t\tReturn _size\n\tEnd Method\n\t\n\tMethod SetDetail(lmax, max_tris, clmax=-1)\n\t\tIf clmax = -1 clmax = lmax\n\t\t_lmax = Min(lmax,44)\n\t\t_max_tris = max_tris\n\t\t_clmax = Min(clmax,44)\n\t\t\n\t\tIf _handle\n\t\t\troam_set_lmax _handle, lmax\n\t\t\troam_set_tricntmax _handle, _max_tris\n\t\t\t\t\t\n\t\t\tFor Local l = 0 To 44\n\t\t\t\troam_set_displacement _handle,l,0.3\/Sqr(1 Shl l)\n\t\t\tNext\n\t\tEndIf\n\tEnd Method\n\t\n\tMethod Update(x#,y#,z#,frustrum:Float Ptr)\n\t\tIf _handle = Null\n\t\t\t_handle=roam_create(_heights, _size)\n\t\t\tSetDetail _lmax,_max_tris,_clmax\t\n\t\tEndIf\n\t\t\n\t\tIf _update\n\t\t\troam_set_heightdata _handle, _heights, _size\n\t\t\troam_update_heightdata _handle\n\t\t\t_update = False\n\t\tEndIf\n\t\t\n\t\t_matrix.TransformVec3 x,y,z\n\t\troam_set_frustum _handle,x,y,z,frustrum\n\t\troam_optimize _handle\t\n\t\t_data=roam_getdata(_handle, _count)\n\tEnd Method\nEnd Type\n\nExtern \"C\"\n\tFunction roam_create:Byte Ptr(heightdata:Float Ptr, size:Int)\n\tFunction roam_set_frustum( terrain:Byte Ptr, cx#,cy#,cz#, frustum:Float Ptr )\n\tFunction roam_set_lmax( terrain:Byte Ptr, lmax% )\n\tFunction roam_draw( terrain:Byte Ptr )\n\tFunction roam_set_tricntmax( terrain:Byte Ptr, lmax% )\n\tFunction roam_set_iqfine( terrain:Byte Ptr, lmax% )\n\t\n\tFunction roam_optimize( terrain:Byte Ptr )\t\n\tFunction roam_set_heightdata( terrain:Byte Ptr, heightdata:Float Ptr, size% )\n\tFunction roam_update_heightdata( terrain:Byte Ptr )\n\t\n\tFunction roam_getdata:Float Ptr( terrain:Byte Ptr, count% Var )\t\n\tFunction roam_set_displacement( terrain:Byte Ptr, index%, displacement#)\n\t\n\tFunction getHeight#( terrain:Byte Ptr, x#,y# )\n\tFunction roam_free( terrain:Byte Ptr )\nEnd Extern\n","old_contents":"\nStrict\n\n'Derived from Warner's engine.\n'http:\/\/code.google.com\/p\/warner-engine\/\n\nImport \"entity.bmx\"\nImport \"roamstep4d.c\"\n\nImport BRL.Random\n\nType TTerrain Extends TEntity\n\tField _heights#[], _size, _lmax, _max_tris, _clmax#\n\tField _handle:Byte Ptr, _data:Float Ptr,_count\n\tField _update\n\t\n\tMethod New()\n\t\t\tSetDetail 14,12000 \n\tEnd Method\n\t\n\tMethod Free()\n\t\tSuper.Free\n\t\t\n\t\t_heights = Null\n\t\t\n\t\tIf _handle\n\t\t\troam_free _handle\n\t\t\t_handle = Null\n\t\tEndIf\n\tEnd Method\n\t\n\tMethod Lists[]()\n\t\tReturn Super.Lists()+[WORLDLIST_TERRAIN, WORLDLIST_RENDER]\n\tEnd Method\n\t\n\tMethod CopyData:TEntity(entity:TEntity)\n\t\tLocal terrain:TTerrain = TTerrain(entity)\n\t\tReturn Super.CopyData(entity)\n\tEnd Method\n\t\n\tMethod Copy:TTerrain(parent:TEntity=Null)\n\t\tReturn TTerrain(Super.Copy_(parent))\n\tEnd Method\n\t\n\tMethod SetMap(url:Object)\n\t\tLocal pixmap:TPixmap=TPixmap(url)\n\t\tIf pixmap=Null pixmap=LoadPixmap(url)\t\t\n\t\tIf pixmap\n\t\t\t_size=Max(PixmapWidth(pixmap),PixmapHeight(pixmap))\n\t\t\tLocal s=1\n\t\t\tWhile s<_size;s:*2;Wend\n\t\t\t_size=s\n\t\t\t_heights=New Float[_size*_size]\n\t\t\tpixmap=ResizePixmap(pixmap,_size,_size)\n\t\t\tFor Local i = 0 To _size-1\n\t\t\t\tFor Local j = 0 To _size-1\n\t\t\t\t\tSetHeight ((ReadPixel(pixmap, i, j) & $FF)\/255.0)*3,j,i\n\t\t\t\tNext\n\t\t\tNext\n\t\tElseIf Int[](url)\n\t\t\t_size = Int[](url)[0]\n\t\t\t_heights=New Float[_size*_size]\n\t\tElse\n\t\t\t_heights=New Float[_size*_size]\n\t\tEndIf\n\t\t_update=True\n\tEnd Method\n\t\n\tMethod GetHeight#(x,z)\n\t\tReturn _heights[(z*_size)+x]\n\tEnd Method\n\tMethod SetHeight(height#,x,z)\n\t\t_heights[(z*_size)+x]=height\t\t\t\n\tEnd Method\t\n\t\n\tMethod GetSize()\n\t\tReturn _size\n\tEnd Method\n\t\n\tMethod SetDetail(lmax, max_tris, clmax=-1)\n\t\tIf clmax = -1 clmax = lmax\n\t\t_lmax = Min(lmax,44)\n\t\t_max_tris = max_tris\n\t\t_clmax = Min(clmax,44)\n\t\t\n\t\tIf _handle\n\t\t\troam_set_lmax _handle, lmax\n\t\t\troam_set_tricntmax _handle, _max_tris\n\t\t\t\t\t\n\t\t\tFor Local l = 0 To 44\n\t\t\t\troam_set_displacement _handle,l,0.3\/Sqr(1 Shl l)\n\t\t\tNext\n\t\tEndIf\n\tEnd Method\n\t\n\tMethod Update(x#,y#,z#,frustrum:Float Ptr)\n\t\tDebugLog \"lde\"\n\t\tIf _handle = Null\n\t\t\t_handle=roam_create(_heights, _size)\n\t\t\tSetDetail _lmax,_max_tris,_clmax\t\n\t\tEndIf\n\t\t\n\t\tIf _update\n\t\t\troam_set_heightdata _handle, _heights, _size\n\t\t\troam_update_heightdata _handle\n\t\t\t_update = False\n\t\tEndIf\n\t\t\n\t\t_matrix.TransformVec3 x,y,z\n\t\troam_set_frustum _handle,x,y,z,frustrum\n\t\troam_optimize _handle\t\n\t\t_data=roam_getdata(_handle, _count)\n\tEnd Method\nEnd Type\n\nExtern \"C\"\n\tFunction roam_create:Byte Ptr(heightdata:Float Ptr, size:Int)\n\tFunction roam_set_frustum( terrain:Byte Ptr, cx#,cy#,cz#, frustum:Float Ptr )\n\tFunction roam_set_lmax( terrain:Byte Ptr, lmax% )\n\tFunction roam_draw( terrain:Byte Ptr )\n\tFunction roam_set_tricntmax( terrain:Byte Ptr, lmax% )\n\tFunction roam_set_iqfine( terrain:Byte Ptr, lmax% )\n\t\n\tFunction roam_optimize( terrain:Byte Ptr )\t\n\tFunction roam_set_heightdata( terrain:Byte Ptr, heightdata:Float Ptr, size% )\n\tFunction roam_update_heightdata( terrain:Byte Ptr )\n\t\n\tFunction roam_getdata:Float Ptr( terrain:Byte Ptr, count% Var )\t\n\tFunction roam_set_displacement( terrain:Byte Ptr, index%, displacement#)\n\t\n\tFunction getHeight#( terrain:Byte Ptr, x#,y# )\n\tFunction roam_free( terrain:Byte Ptr )\nEnd Extern\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"b6a089282af3659e7e626ac285f15049630fc568","subject":"avoid use of Double as transfer type","message":"avoid use of Double as transfer type\n","repos":"Leushenko\/blue-moon","old_file":"blue.bmx","new_file":"blue.bmx","new_contents":"\n' Blue Moon\n' an implementation of Lua in pure BlitzMax\n\nSuperStrict\n\n'Framework Brl.Blitz\n'Import Brl.LinkedList\n'Import Brl.Map\n'Import Brl.Reflection\n\nImport \"bluecompiler.bmx\"\nImport \"blueallocator.bmx\"\nRem\nImport \"blueasm.o\"\nExtern\nFunction ADD:Int(s:Stack, b:Bytecode, r:Byte Ptr) = \"ADD2\"\nFunction EQ:Int(s:Stack, b:Bytecode, r:Byte Ptr) = \"EQ2\"\nFunction GETUPV:Int(s:Stack, b:Bytecode, r:Byte Ptr) = \"GETUPV2\"\nFunction JIF:Int(s:Stack, b:Bytecode, r:Byte Ptr) = \"JIF2\"\nFunction LOADBOOL:Int(s:Stack, b:Bytecode, r:Byte Ptr) = \"LOADBOOL2\"\nFunction LOADK:Int(s:Stack, b:Bytecode, r:Byte Ptr) = \"LOADK2\"\nFunction LOADNIL:Int(s:Stack, b:Bytecode, r:Byte Ptr) = \"LOADNIL2\"\nFunction LOADSI:Int(s:Stack, b:Bytecode, r:Byte Ptr) = \"LOADSI2\"\nFunction MOV:Int(s:Stack, b:Bytecode, r:Byte Ptr) = \"MOV2\"\nFunction NEWUPV:Int(s:Stack, b:Bytecode, r:Byte Ptr) = \"NEWUPV2\"\nFunction SETLC:Int(s:Stack, b:Bytecode, r:Byte Ptr) = \"SETLC2\"\nEnd Extern\nEnd Rem\n'Const file:String = \"tests\/checktable.lua\"\n'Const file:String = \"tests\/mandelbrot.lua\"\n'Const file:String = \"tests\/sieve.lua\"\n'Const file:String = \"tests\/attrib.lua\"\nConst file:String = \"test.lua\"\n\nConst outFile:String = \"out.lua.so\"\n\n\nPrint BlueCompiler.ShowBytecode(file)\n\nRem\nBlueJIT.InitOpTbl()\n'BlueJIT.opTbl[BlueJIT.opc.ADD] = ADD\n'BlueJIT.opTbl[BlueJIT.opc.EQ] = EQ\n'BlueJIT.opTbl[BlueJIT.opc.GETUPV] = GETUPV\n'BlueJIT.opTbl[BlueJIT.opc.JIF] = JIF\n'BlueJIT.opTbl[BlueJIT.opc.LOADBOOL] = LOADBOOL\n'BlueJIT.opTbl[BlueJIT.opc.LOADK] = LOADK\n'BlueJIT.opTbl[BlueJIT.opc.LOADNIL] = LOADNIL\n'BlueJIT.opTbl[BlueJIT.opc.LOADSI] = LOADSI\nBlueJIT.opTbl[BlueJIT.opc.MOV] = MOV\n'BlueJIT.opTbl[BlueJIT.opc.NEWUPV] = NEWUPV\n'BlueJIT.opTbl[BlueJIT.opc.SETLC] = SETLC\nEnd Rem\n\nLocal code:BlueBinary = BlueCompiler.CompileFileForLoad(file)\nLocal vm:BlueVM = New BlueVM\nLocal tl:BlueLuaVal = vm.LoadObjectCode(code)\n'tl.Call()\n\nLocal stk:Stack = BlueJIT.BPtoS(vm.mem.stack)\nstk.retIP = Null ; stk.prevBase = Null\nLocal vc:Int = 10, upvars:Int = 1\nstk.varp = Long Ptr(Byte Ptr(stk) + BlueJIT.STACKFRAME_INC) + upvars\nstk.func = vm.funIndex[0]\n'stk.IP = 0\nstk.argv = Null\t'may want to add space?\nstk.retv = Null\nstk.argc = 0\nstk.retc = 0\n\nPrint \"running...\"\nLocal t:Int = MilliSecs()\nLocal test:Int(_:Byte Ptr) = stk.func.mcode - BlueJIT.PROLOGUESZ ; test(stk)\nt = MilliSecs() - t\nPrint t\nPrint \"run complete\"\n\n\nPrint \"done.\"\nEnd\n\n' notes:\n' - string constants and bytecode are loaded directly into oldSpc, since they'll be needed often\n' - the structure of a bytecode object is:\n' [ machine code ptr ][ id-offset ][ #k ][ #param ][ #upvar ][ frame sz ][ #instrs ][ vm ][ instructions... ][ upvar table... ][ k table... ]\n' initial fields are all 32b; instructions are each 64b; upvar table is pairs of 32b values (level, pos); k table is NaN-box values\n\n' - the structure of a closure object (actual Lua value representing a function) is:\n' [ bytecode ptr ][ upvar values... ]\n\nType BlueVM\n\tField mem:BlueVMMemory, _ENV:BlueLuaVal\n\tField idMod:Int, funIndex:Bytecode Ptr, _fiSz:Int\n\t\n\tMethod New()\n\t\tmem = New BlueVMMemory\n\tEnd Method\n\t\n\t' Load the procedures and constants of a compiled binary into the VM, returning the function representing the program toplevel\n\tMethod LoadObjectCode:BlueLuaVal(code:BlueBinary)\n\t\tLocal buf:Int[] = code.buf\n\t\tLocal fcount:Int = buf[0], kcount:Int = buf[1], ktblpos:Int = buf[2], ktbl:Long[kcount]\n\t\tLocal convert:Byte Ptr(o:Object) = Byte Ptr(BlueJIT.Identity)\n\t\t\n\t\tFor Local k:Int = 0 Until kcount\n\t\t\tLocal koff:Int = buf[ktblpos + k], sz:Int = buf[ktblpos + k + 1] - koff\n\t\t\tIf sz > 2\t'strings have size > 2\n\t\t\t\tLocal length:Double, lp:Int Ptr = Int Ptr(Varptr(length))\n\t\t\t\tlp[0] = buf[koff] ; lp[1] = buf[koff + 1]\n\t\t\t\tLocal s:Byte Ptr = mem.AllocString(length, Short Ptr(Varptr(buf[koff + 2])))\n\t\t\t\tktbl[k] = mem.PtrToVal(s, BlueTypeTag.STR)\n\t\t\tElse\n\t\t\t\tLocal d:Double, dp:Int Ptr = Int Ptr(Varptr(d))\n\t\t\t\tdp[0] = buf[koff] ; dp[1] = buf[koff + 1]\n\t\t\t\tDouble Ptr(Varptr(ktbl[k]))[0] = d\n\t\t\tEndIf\n\t\tNext\n\t\t\n\t\tExtendFunIndex(idMod + fcount)\n\t\tFor Local f:Int = 0 Until fcount\n\t\t\tLocal foff:Int = buf[3 + f]\n\t\t\tLocal ic:Int = buf[foff + 1], kc:Int = buf[foff + 2], pc:Int = buf[foff + 3], uc:Int = buf[foff + 5], fsz:Int = buf[foff + 6]\n\t\t\t\n\t\t\tLocal b:Bytecode = BPtoBC(mem.AllocObjectOldSpace(mem.oldStrSpace, (8 + 2 * (uc + uc Mod 2) + 2 * kc + 2 * ic) * 4, BlueTypeTag.BCODE))\n\t\t\tb.idMod = idMod ; b.kcount = kc ; b.pcount = pc ; b.upvars = uc + (uc Mod 2)\t'round up for alignment\n\t\t\tb.frameSz = BlueJIT.STACKFRAMESZ + b.upvars * 8 + fsz * 8 ; b.icount = ic ; b.vm = convert(Self)\n\t\t\t\n\t\t\tLocal ib:Int Ptr = Int Ptr(Byte Ptr(b) + 4) + 8 + 2 * ic\n\t\t\tFor Local u:Int = 0 Until uc\n\t\t\t\tLocal uoff:Int = 7 + u * 2\n\t\t\t\tib[u * 2] = buf[foff + uoff] ; ib[u * 2 + 1] = buf[foff + uoff + 1]\n\t\t\tNext\n\t\t\tIf uc <> b.upvars\t'ensure padding is safe by copying the first one\n\t\t\t\tib[uc * 2] = buf[foff + 7] ; ib[uc * 2 + 1] = buf[foff + 7 + 1]\n\t\t\tEndIf\n\t\t\t\n\t\t\tLocal db:Long Ptr = Long Ptr(ib + 2 * b.upvars)\n\t\t\tFor Local k:Int = 0 Until kc\n\t\t\t\tdb[k] = ktbl[buf[foff + 7 + uc * 2 + k]]\n\t\t\tNext\n\t\t\t\n\t\t\tLocal ioff:Int = 7 + 2 * uc + kc ; ib = Int Ptr(Byte Ptr(b) + BlueJIT.BYTECODE_INC)\n\t\t\t\n\t\t\tFor Local i:Int = 0 Until ic * 2\n\t\t\t\tib[i] = buf[foff + ioff + i]\n\t\t\tNext\n\t\t\t\n\t\t\tb.mcode = BlueJIT.Compile(Self, ib, ic, b) + BlueJIT.PROLOGUESZ\n\t\t\tfunIndex[idMod + f] = b\n\t\tNext\n\t\t\n\t\tidMod :+ fcount\n\t\tReturn New BlueLuaVal\n\tEnd Method\n\t\n\tMethod ExtendFunIndex(sz:Int)\t'hack: BlitzMax has a bug with arrays of extern types! so we need to use C-style arrays for now\n\t\tLocal newFI:Bytecode Ptr = Bytecode Ptr(MemAlloc(sz * 4))\n\t\tIf _fiSz\n\t\t\tFor Local b:Int = 0 Until _fiSz\n\t\t\t\tnewFI[b] = funIndex[b]\n\t\t\tNext\n\t\t\tMemFree(funIndex)\n\t\t\tFor Local b:Int = _fiSz Until sz\n\t\t\t\tnewFI[b] = Null\n\t\t\tNext\n\t\tEndIf\n\t\tfunIndex = newFI ; _fiSz = sz\n\tEnd Method\n\t\n\tMethod CallToLua()\n\tEnd Method\n\t\n\tGlobal BPtoBC:Bytecode(p:Byte Ptr) = Byte Ptr(BlueJIT.PointerToExtType)\nEnd Type\n\nPrivate\nExtern\n\tType Stack\n\t\tField retIP:Byte Ptr, prevBase:Stack, varp:Long Ptr, func:Bytecode, _IP:Int, argv:Long Ptr, retv:Long Ptr, argc:Short, retc:Short\n\tEnd Type\n\tType Bytecode\n\t\tField mcode:Byte Ptr, idMod:Int, kcount:Int, pcount:Int, upvars:Int, frameSz:Int, icount:Int, vm:Byte Ptr\n\tEnd Type\nEnd Extern\nPublic\n\nType BlueJIT Final\n\tConst PROLOGUESZ:Int = 25, ISIZE:Int = 5\n\t\n\tGlobal opTbl:Int(s:Stack, b:Bytecode, r:Byte Ptr)[], opc:BlueOpcode\n\tGlobal Prologue:Int[] = [ ..\n\t\t$90, $90, ..\n\t\t$8b, $44, $24, $04, .. 'mov 4(%esp), %eax\n\t\t$89, $44, $24, $f4, .. 'mov %eax, -12(%esp)\n\t\t$c7, $44, $24, $f8, $FF, $FF, $FF, $FF, .. 'movl ########, -8(%esp)\n\t\t$89, $64, $24, $fc, .. 'mov %esp, -4(%esp)\n\t\t$83, $ec, $0c.. 'sub $12, %esp\n\t]\n\t\n\tFunction Compile:Byte Ptr(vm:BlueVM, ins:Byte Ptr, icount:Int, bytecode:Bytecode)\n\t\t?Not x86\n\t\tRuntimeError \"The Blue Moon JIT does not support your platform (x86-32 only at this time)\"\n\t\t?\n\t\tAssert SizeOf(0:Long) = SizeOf(0:Double) And SizeOf(0:Int) = 4 And SizeOf(0:Long) = 8 And SizeOf(Byte Ptr(0)) = 4, ..\n\t\t\t\"assumptions about platform datatype sizes are invalid\"\n\t\t\n\t\tIf opTbl = Null Then InitOpTbl()\n\t\t\n\t\tLocal sz:Int = PROLOGUESZ + icount * ISIZE\n\t\t\n\t\t' allocate executable space\n\t\tLocal blocks:Int[] = vm.mem.AllocCodeBlock(PROLOGUESZ + icount * ISIZE)\n\t\tLocal code:Byte Ptr = Byte Ptr(blocks[0]), rsize:Int = blocks[1] - (blocks[1] Mod ISIZE)\n\t\t\n\t\tFor Local p:Int = 0 Until PROLOGUESZ\t'emplace prologue (used for calling in from native only)\n\t\t\tcode[p] = Prologue[p]\n\t\tNext\n\t\tByte Ptr Ptr(code + 14)[0] = Byte Ptr(bytecode)\t'replace the ########\n\t\tcode :+ PROLOGUESZ ; rsize :- PROLOGUESZ\t'easier to not have to take this into account below\n\t\t\n\t\tLocal codePage:Int Ptr = Int Ptr(Int(code) & ((Int(2^12)-1) Shl 20))\t'return-to-native for the page\n\t\tcodePage[1] = $c30cc483\t'add $12, %esp ; ret - i.e. restore the stack to normal\n\t\t\n\t\t' generate machine code!\n\t\tRepeat\n\t\t\t\n\t\t\tFor Local i:Int = 0 Until rsize \/ ISIZE\t'emplace opcode calls and supporting bytecode data\n\t\t\t\tLocal codep:Byte Ptr = code + i * ISIZE, bytecodep:Byte Ptr = Byte Ptr(Int(codep) + vm.mem.PAGESZ)\n\t\t\t\tcodep[0] = $e8\t'call\n\t\t\t\tLocal bi:Int = i * 8, op:Int = ins[bi], ip:Int Ptr = Int Ptr(ins + bi), func:Byte Ptr = opTbl[op]\n\t\t\t\tByte Ptr Ptr(codep + 1)[0] = func - Int(codep + ISIZE)\n\t\t\t\t\n\t\t\t\tSelect op\n\t\t\t\t\tCase opc.LOADSI, opc.CLOSURE, opc.RET, opc.POSTCALL\n\t\t\t\t\t\tbytecodep[0] = ins[bi + 1] ; Int Ptr(bytecodep + 1)[0] = Int Ptr(ins + bi)[1]\n\t\t\t\t\t\t\n\t\t\t\t\tCase opc.LOADK\n\t\t\t\t\t\tLocal kp:Double Ptr = Double Ptr(ins + 8 * bytecode.icount + 8 * bytecode.upvars) + ip[1]\n\t\t\t\t\t\tbytecodep[0] = ins[bi + 1] ; Double Ptr Ptr(bytecodep + 1)[0] = kp\n\t\t\t\t\t\t\n\t\t\t\t\tCase opc.CALL\n\t\t\t\t\t\tbytecodep[0] = ins[bi + 1] ; bytecodep[1] = ins[bi + 2]\n\t\t\t\t\t\tShort Ptr(bytecodep)[1] = Int Ptr(ins + bi)[1]\n\t\t\t\t\t\t\n\t\t\t\t\tCase opc.JIF, opc.JNOT\n\t\t\t\t\t\tbytecodep[0] = ins[bi + 1]\n\t\t\t\t\t\tInt Ptr(bytecodep + 1)[0] = Int(codep) + ISIZE * Int Ptr(ins + bi)[1]\n\t\t\t\t\t\t\n\t\t\t\t\tCase opc.JMP\n\t\t\t\t\t\tcodep[0] = $e9\t'use a true jump\n\t\t\t\t\t\tInt Ptr(codep + 1)[0] = ISIZE * (Int Ptr(ins + bi)[1] - 1)\n\t\t\t\t\t\t\n\t\t\t\t\tDefault\t'binary operations A = B op C\n\t\t\t\t\t\tbytecodep[0] = ins[bi + 1] ; bytecodep[1] = ins[bi + 2] ; bytecodep[2] = Int Ptr(ins + bi)[1]\n\t\t\t\tEnd Select\n\t\t\tNext\n\t\t\t\n\t\t\tExit\t'deal with overflowing code sections here\n\t\tForever\n\t\t\n\t\tReturn code - PROLOGUESZ\n\tEnd Function\n\t\n\t\n\tConst STACKFRAMESZ:Int = 8 * 4, BYTECODESZ:Int = 8 * 4, STACKFRAME_INC:Int = STACKFRAMESZ + 4, BYTECODE_INC:Int = BYTECODESZ + 4\n\tConst IP_OFFSET:Int = BlueVMMemory.PAGESZ - ISIZE\n\t\n\t\n\t'note: extern vars must take into account the vtbl offset, so that converting from a typed pointer can be a simple cast (faster)\t\n\t\n\tFunction MOV(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"MOV \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tvarp[rp[0]] = varp[rp[1]]\t'assigning through Double is unsafe as it can corrupt the bit pattern\n\tEnd Function\n\tFunction GETLC(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction SETLC(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"SETLC \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLong Ptr Ptr(varp + rp[0])[0][0] = varp[rp[1]]\n\tEnd Function\n\tFunction LOADK(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"LOADK \/\/\"\n\t\tLocal rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET, varp:Long Ptr = stk.varp + rp[0], kp:Long Ptr = Long Ptr Ptr(rp + 1)[0]\n\t\tvarp[0] = kp[0]\n\tEnd Function\n\tFunction LOADSI(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"LOADSI \/\/\"\n\t\tLocal rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal val:Int = Int Ptr(rp + 1)[0]\n\t\tDouble Ptr(stk.varp)[rp[0]] = Double(val)\n\tEnd Function\n\tFunction LOADBOOL(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"LOADBOOL \/\/\"\n\t\tLocal rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET, vp:Int Ptr = Int Ptr(stk.varp + rp[0])\n\t\tvp[1] = BlueTypeTag.NANBOX | BlueTypeTag.BOOL\n\t\tvp[0] = Int Ptr(rp + 1)[0]\n\tEnd Function\n\tFunction LOADNIL(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"LOADNIL \/\/\"\n\t\tLocal rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tInt Ptr(stk.varp + rp[0])[1] = BlueTypeTag.NANBOX | BlueTypeTag.NIL\n\tEnd Function\n\t\n\tFunction GETTAB(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction GETTABSI(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction SETTAB(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction SETTABSI(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction GETTABI(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction SETTABI(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction GETUPV(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"GETUPV \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, upvp:Byte Ptr Ptr = Byte Ptr Ptr(Byte Ptr(stk) + STACKFRAME_INC)\n\t\tLocal rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET, valp:Long Ptr = Long Ptr(upvp[rp[1]])\n\t\tvarp[rp[0]] = valp[0]\n\tEnd Function\n\tFunction SETUPV(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction NEWTAB(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"NEWTAB \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal convert:BlueVM(p:Byte Ptr) = Byte Ptr(Identity), vm:BlueVM = convert(bc.vm)\n\t\tLocal tab:Byte Ptr = vm.mem.AllocTable(Null)\n\t\tLocal d:Int Ptr = Int Ptr(varp + rp[0])\n\t\td[0] = Int(tab) ; d[1] = BlueTypeTag.NANBOX | BlueTypeTag.TBL\n\tEnd Function\n\tFunction CLOSURE(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"CLOSURE \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal convert:BlueVM(p:Byte Ptr) = Byte Ptr(Identity), vm:BlueVM = convert(bc.vm)\n\t\tLocal d:Int Ptr = Int Ptr(varp + rp[0])\n\t\tLocal cbytecode:Bytecode = vm.funIndex[Int Ptr(rp + 1)[0]], upvp:Int Ptr = Int Ptr(Byte Ptr(cbytecode) + BYTECODE_INC + 8 * cbytecode.icount)\n\t\tLocal closure:Byte Ptr = vm.mem.AllocClosure(cbytecode, cbytecode.upvars)\t'upvars is always even (alignment)\n\t\t\n\t\t'get upvalues off the stack\n\t\tFor Local u:Int = 0 Until cbytecode.upvars\n\t\t\tIf upvp[2 * u]\n\t\t\t\tByte Ptr Ptr(closure)[2 + u] = Byte Ptr Ptr(Byte Ptr(stk) + STACKFRAME_INC)[upvp[2 * u + 1]]\n\t\t\tElse\n\t\t\t\tByte Ptr Ptr(closure)[2 + u] = Byte Ptr Ptr(varp + upvp[2 * u + 1])[0]\n\t\t\tEndIf\n\t\tNext\n\t\t\n\t\td[0] = Int(closure) ; d[1] = BlueTypeTag.NANBOX | BlueTypeTag.FUN\n\tEnd Function\n\tFunction NEWUPV(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"NEWUPV \/\/\"\n\t\tLocal rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal convert:BlueVM(p:Byte Ptr) = Byte Ptr(Identity), vm:BlueVM = convert(bc.vm)\n\t\tLocal upv:Byte Ptr = vm.mem.AllocObject(8, BlueTypeTag.UPV), d:Int Ptr = Int Ptr(stk.varp + rp[0])\n\t\tLong Ptr(upv)[0] = Long Ptr(d)[0]\t'promote a value if it existed (useful for parameters)\n\t\td[0] = Int(upv) ; d[1] = BlueTypeTag.NANBOX | BlueTypeTag.UPV\n\tEnd Function\n\t\n\tFunction ADD(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"ADD \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal d:Double Ptr = Double Ptr(varp + rp[0])\n\t\tLocal r:Int Ptr = Int Ptr(varp + rp[1]), l:Int Ptr = Int Ptr(varp + rp[2])\n\t\tIf l[1] & BlueTypeTag.NANBOX_CHK = BlueTypeTag.NANBOX Or r[1] & BlueTypeTag.NANBOX_CHK = BlueTypeTag.NANBOX\n\t\t\tDebugStop\n\t\tElse\n\t\t\td[0] = Double Ptr(l)[0] + Double Ptr(r)[0]\n\t\tEndIf\n\tEnd Function\n\tFunction SUB(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction MUL(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction DIV(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction NMOD(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction POW(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction CAT(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction IDIV(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction BAND(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction BOR(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction BXOR(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction BSHL(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction BSHR(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction UNM(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction LNOT(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction ALEN(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction BNOT(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction UNP(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction EQ(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"EQ \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = (Byte Ptr Ptr(retptr) - 4)[0] + IP_OFFSET\n\t\tLocal r:Double = Double Ptr(varp)[rp[1]]\n\t\tLocal l:Double = Double Ptr(varp)[rp[2]]\n\t\tInt Ptr(varp + rp[0])[0] = l = r\n\tEnd Function\n\tFunction LT(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction LEQ(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\t\n\tFunction JMP(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t\tPrint \"wait, why are we here?\"\n\tEnd Function\n\tFunction JIF(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"JIF \/\/\"\n\t\tLocal rp:Byte Ptr = (Byte Ptr Ptr(retptr) - 4)[0] + IP_OFFSET\n\t\tIf Int Ptr(stk.varp + rp[0])[0]\n\t\t\tLocal target:Int = Int Ptr(rp + 1)[0]\n\t\t\tInt Ptr(retptr)[-4] = target\n\t\tEndIf\n\tEnd Function\n\tFunction JNOT(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction CALL(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"CALL \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal fp:Int Ptr = Int Ptr(varp + rp[0])\n\t\tIf Not PrepareCall(fp, stk, rp, varp, retptr)\t'PrepareCall sets everything up so there's nothing else to do to make the call happen\n\t\t\t'__call metamethod\n\t\tEndIf\n\tEnd Function\n\tFunction TCALL(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction RET:Byte Ptr(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"RET \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp\n\t\tLocal rp0:Byte Ptr = Byte Ptr Ptr(retptr)[-4], rp:Byte Ptr = rp0 + IP_OFFSET\n\t\t\n\t\tLocal oldStk:Stack = stk.prevBase\n\t\tLocal retv:Long Ptr = varp + rp[0]\n\t\tIf oldStk\n\t\t\toldStk.retv = retv\n\t\t\toldStk.retc = Int Ptr(rp + 1)[0]\n\t\t\tByte Ptr Ptr(retptr)[-4] = stk.retIP\n\t\t\tByte Ptr Ptr(retptr)[-3] = Byte Ptr(oldStk)\n\t\t\tByte Ptr Ptr(retptr)[-2] = Byte Ptr(oldStk.func) + BYTECODE_INC\n\t\tElse\t'return to native code\n\t\t\tLocal codePage:Byte Ptr = Byte Ptr(Int(rp0) & ((Int(2^12)-1) Shl 20))\n\t\t\tByte Ptr Ptr(retptr)[-4] = codePage + 4\n\t\t\tReturn retv\n\t\tEndIf\n\tEnd Function\n\tFunction RETVA(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction POSTCALL(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"POSTCALL \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp\n\t\tLocal rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\t\n\t\tFor Local r:Int = 0 Until Min(Int Ptr(rp + 1)[0], stk.retc)\n\t\t\t(varp + rp[0])[r] = stk.retv[r]\n\t\t'\tPrint \" return \" + r + \": \" + Double Ptr(stk.retv)[r]\n\t\tNext\n\tEnd Function\n\tFunction VARARG(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction VAINIT(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction CALLINIT(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\t\n\t\n\tFunction PrepareCall:Int(fp:Int Ptr, stk:Stack, rp:Byte Ptr, varp:Long Ptr, retptr:Byte Ptr)\n\t\tIf fp[1] = BlueTypeTag.NANBOX | BlueTypeTag.FUN\n\t\t\tLocal newStk0:Stack ; Byte Ptr Ptr(Varptr(newStk0))[0] = Byte Ptr(stk) + stk.func.frameSz\n\t\t\tLocal newStk:Stack = newStk0\t'micro-opt: newStk0 can't be a register because of the unwieldy conversion\n\t\t\t\n\t\t\tnewStk.retIP = Byte Ptr Ptr(retptr)[-4]\n\t\t\tnewStk.prevBase = stk\n\t\t\tLocal closure:Byte Ptr = Byte Ptr(fp[0])\n\t\t\tLocal newBC:Bytecode = Bytecode Ptr(closure)[0]\n\t\t\tLocal voff:Int = STACKFRAME_INC + 4 * newBC.upvars\n\t\t\tnewStk.varp = Long Ptr(Byte Ptr(newStk) + voff)\n\t\t\tnewStk.func = newBC\n\t\t'\tnewStk._IP = 0\n\t\t\t\n\t\t\tLocal argc_actual:Int = Short Ptr(rp)[1], argc_required:Int = newBC.pcount\n\t\t'\tLocal argc_min:Int ; If argc_actual < argc_required Then argc_min = argc_actual Else argc_min = argc_required\n\t\t\tLocal argc_min:Int = argc_actual - argc_required ; argc_min = (argc_min & (argc_min Shr 31)) + argc_required 'branchless 32-bit Min\n\t\t\t\n\t\t\tLocal argv:Long Ptr = varp + rp[1], destv:Long Ptr = newStk.varp\n\t\t\tFor Local a:Int = 0 Until argc_min\n\t\t\t\tdestv[a] = argv[a]\n\t\t\t'\tPrint \" arg \" + a + \": \" + argv[a]\n\t\t\tNext\n\t\t\tFor Local a:Int = argc_min Until argc_required\t'nil any unfilled parameters\n\t\t\t\tInt Ptr(destv + a)[1] = BlueTypeTag.NANBOX | BlueTypeTag.NIL\n\t\t\tNext\n\t\t\tnewStk.argv = argv + argc_min\t'argv should be to the varargs (if any)\n\t\t\tnewStk.argc = argc_actual - argc_min\t'argc is the number of varargs\n\t\t\t\n\t\t\tLocal destup:Byte Ptr Ptr = Byte Ptr Ptr(Byte Ptr(newStk) + STACKFRAME_INC)\n\t\t\tLocal upv:Byte Ptr Ptr = Byte Ptr Ptr(closure + 8)\n\t\t\tFor Local up:Int = 0 Until newBC.upvars\t'emplace upvars\n\t\t\t\tdestup[up] = upv[up]\n\t\t\t'\tPrint \" upv \" + up + \": \" + destv[up]\n\t\t\t'\tPrint \" val: \" + Double Ptr Ptr(Byte Ptr Ptr(closure) + 2 + up)[0][0]\n\t\t\tNext\n\t\t\t\n\t\t\t'note that the following OVERWRITE THE PARAMETERS (in release mode), so no touching stk from here on\n\t\t\tByte Ptr Ptr(retptr)[-4] = newBC.mcode\n\t\t\tByte Ptr Ptr(retptr)[-3] = Byte Ptr(newStk)\n\t\t\tByte Ptr Ptr(retptr)[-2] = Byte Ptr(newBC) + BYTECODE_INC\n\t\t\t\n\t\tElseIf fp[1] = BlueTypeTag.NANBOX | BlueTypeTag.NATFUN\n\t\t\t'native call\n\t\tElse\n\t\t\tReturn False\t'not a function; take appropriate action\n\t\tEndIf\n\t\tReturn True\t'all good and will auto-call when the caller returns\n\tEnd Function\n\t\n\tFunction InitOpTbl()\n\t\topc = New BlueOpcode\n\t\topTbl = [MOV, GETLC, SETLC, LOADK, LOADSI, LOADBOOL, LOADNIL, ..\n\t\t\tGETTAB, GETTABSI, SETTAB, SETTABSI, GETTABI, SETTABI, GETUPV, SETUPV, ..\n\t\t\tNEWTAB, CLOSURE, NEWUPV, ..\n\t\t\tADD, SUB, MUL, DIV, NMOD, POW, CAT, ..\n\t\t\tIDIV, BAND, BOR, BXOR, BSHL, BSHR, ..\n\t\t\tUNM, LNOT, ALEN, BNOT, UNP, ..\n\t\t\tEQ, LT, LEQ, ..\n\t\t\tJMP, JIF, JNOT, CALL, TCALL, RETVA, RETVA, ..\t'not a mistake: RET doesn't fit but we need the spacer\n\t\t\tPOSTCALL, VARARG, VAINIT, CALLINIT]\n\t\t\n\t\topTbl[opc.RET] = Byte Ptr(RET)\n\tEnd Function\n\t\n\tFunction Identity:Byte Ptr(b:Byte Ptr)\n\t\tReturn b\n\tEnd Function\n\tFunction PointerToExtType:Byte Ptr(p:Byte Ptr)\t'horrible pointer abuse (increment down so we can ignore the nonexistent vtbl)\n\t\tReturn p - 4'sizeof(Byte Ptr)\n\tEnd Function\n\tGlobal BPtoS:Stack(p:Byte Ptr) = Byte Ptr(BlueJIT.PointerToExtType)\nEnd Type\n\nType BlueLuaVal\n\tField _obj:BlueGCNode\n\n\tMethod Call()\n\tEnd Method\nEnd Type\n\n\nRem\nLocal files:TList = CreateList()\nLocal as:String, ld:String, showHelp:Int, output:String = \"a.out\", doAssemble:Int = 1\nLocal keepAsm:Int, makeExe:Int = 1, asOpts:String, ldOpts:String, showAST:Int, showVersion:Int\n\n?MacOS\nas = \"clang -m32 -c \" ; ld = \"clang -Wl,-no_pie -m32 -read_only_relocs suppress \"\n?Not MacOS\nas = \"gcc -m32 -c \" ; ld = \"gcc -m32 \"\n?\n\nFor Local a:Int = 1 Until AppArgs.Length\n\tSelect AppArgs[a]\n\t\tCase \"-?\", \"--help\"\n\t\t\tshowHelp = 1\n\t\tCase \"-v\"\n\t\t\tshowVersion = 1\n\t\tCase \"-o\"\n\t\t\tIf makeExe = 0\n\t\t\t\tPrint \"warning: -c and -o are mutually exclusive; -c is overruling -o\"\n\t\t\tElse\n\t\t\t\ta :+ 1 ; output = AppArgs[a] ; makeExe = 2\n\t\t\tEndIf\n\t\tCase \"-c\"\n\t\t\tIf makeExe = 2\n\t\t\t\tPrint \"warning: -o and -c are mutually exclusive; -o is overruling -c\"\n\t\t\tElse\n\t\t\t\tdoAssemble = 1 ; makeExe = 0\n\t\t\tEndIf\n\t\tCase \"-s\"\n\t\t\tkeepAsm = 1\n\t\tCase \"-S\"\n\t\t\tkeepAsm = 1 ; doAssemble = 0 ; makeExe = 0\n\t\tCase \"--as\"\n\t\t\ta :+ 1 ; as = AppArgs[a] + \" \"\n\t\tCase \"--ld\"\n\t\t\ta :+ 1 ; ld = AppArgs[a] + \" \"\n\t\tCase \"--as-opt\"\n\t\t\ta :+ 1 ; asOpts :+ AppArgs[a] + \" \"\n\t\tCase \"--ld-opt\"\n\t\t\ta :+ 1 ; ldOpts :+ AppArgs[a] + \" \"\n\t\tCase \"--tree\"\n\t\t\tshowAST = 1 ; makeExe = 0\n\t\tCase \"-w\" ; YBCodeGen.SetWarningLevel 0\n\t\tCase \"--werr\" ; YBCodeGen.SetWarningLevel 2\n\t\tCase \"--warn\" ; YBCodeGen.SetWarningLevel 1\n\t\tDefault\n\t\t\tfiles.AddLast AppArgs[a]\n\tEnd Select\nNext\nIf AppArgs.Length = 1 Then Print \"ybc: no input files\" ; End\n\nIf showVersion Then DisplayVersion\nIf showHelp Then DisplayHelp\n\n?Win32\nLocal rm:String = \"del \/Q \"\n?Not Win32\nLocal rm:String = \"rm \"\n?\n\nLocal allOFiles:String = \"\"\nFor Local file:String = EachIn files\n\tTry\n\t\tLocal tree:TParseNode = YBParseFile(file)\n\t\tIf showAST\n\t\t\tPrint tree.ToString()\n\t\tElse\n\t\t\tYBCodeGen.Build tree\n\t\t\tYBAssembler.Emit file + \".s\", YBCodeGen.syms, YBCodeGen.funs, YBCodeGen.vars, YBCodeGen.strs\n\t\t\tIf doAssemble\n\t\t\t\tsystem_(as + asOpts + file + \".s -o \" + file + \".o\")\n\t\t\t\tallOFiles :+ file + \".o \"\n\t\t\tEndIf\n\t\t\tIf Not keepAsm\n\t\t\t\tsystem_ rm + file + \".s\"\n\t\t\tEndIf\n\t\tEndIf\n\tCatch e:Object\n\t\tPrint \"Compile error:~n \" + e.ToString()\n\t\tPrint \"Compilation halted.\"\n\t\t?Debug\n\t\tThrow e\n\t\t?\n\t\tEnd\n\tEnd Try\nNext\n\n?Linux\nLocal bLib:String = \"b-lib-linux\"\n?Not Linux\nLocal bLib:String = \"b-lib\"\n?\nIf makeExe\n\tIf Not FileType(\"b-lib.o\") Then system_ as + bLib + \".s -o b-lib.o\"\n\tsystem_(ld + ldOpts + \"-o \" + output + \" \" + allOFiles + \" b-lib.o\")\n\tsystem_(rm + allOFiles)\nEndIf\n\nPrint \"done.\"\nEnd\nEnd Rem\nRem\nFunction DisplayVersion()\n\tPrint \"Shadow SIMD Compiler: version 0.0\"\nEnd Function\n\nFunction DisplayHelp()\n\tPrint \"OVERVIEW: ybc compiler for B~n\"\n\tPrint \"USAGE: ybc [options] ~n\"\n\tPrint \"OPTIONS:~n\"\n\tPrint \" -?, --help Display this message\"\n\tPrint \" -v Show the compiler version\"\n\tPrint \" -o Set the name of the output executable (default 'a.out')\"\n\tPrint \" -c Produce separate .o files instead of an executable\"\n\tPrint \" -s Keep text assembly .s files\"\n\tPrint \" -S Only produce text assembly, do not assemble binaries\"\n\tPrint \" --as Set the command to use as the assembler\"\n\tPrint \" --ld Set the command to use as the linker\"\n\tPrint \" --as-opt Add an option to pass to the assembler (can repeat)\"\n\tPrint \" --ld-opt Add an option to pass to the linker (can repeat)\"\n\tPrint \" --tree Display the AST of the program source instead of compiling\"\n\tPrint \" -w Silence warnings\"\n\tPrint \" --werr Convert warnings to errors\"\n\tPrint \" --warn Notify but do not halt on warnings (default)\"\nEnd Function\nEnd Rem\n","old_contents":"\n' Blue Moon\n' an implementation of Lua in pure BlitzMax\n\nSuperStrict\n\n'Framework Brl.Blitz\n'Import Brl.LinkedList\n'Import Brl.Map\n'Import Brl.Reflection\n\nImport \"bluecompiler.bmx\"\nImport \"blueallocator.bmx\"\nRem\nImport \"blueasm.o\"\nExtern\nFunction ADD:Int(s:Stack, b:Bytecode, r:Byte Ptr) = \"ADD2\"\nFunction EQ:Int(s:Stack, b:Bytecode, r:Byte Ptr) = \"EQ2\"\nFunction GETUPV:Int(s:Stack, b:Bytecode, r:Byte Ptr) = \"GETUPV2\"\nFunction JIF:Int(s:Stack, b:Bytecode, r:Byte Ptr) = \"JIF2\"\nFunction LOADBOOL:Int(s:Stack, b:Bytecode, r:Byte Ptr) = \"LOADBOOL2\"\nFunction LOADK:Int(s:Stack, b:Bytecode, r:Byte Ptr) = \"LOADK2\"\nFunction LOADNIL:Int(s:Stack, b:Bytecode, r:Byte Ptr) = \"LOADNIL2\"\nFunction LOADSI:Int(s:Stack, b:Bytecode, r:Byte Ptr) = \"LOADSI2\"\nFunction MOV:Int(s:Stack, b:Bytecode, r:Byte Ptr) = \"MOV2\"\nFunction NEWUPV:Int(s:Stack, b:Bytecode, r:Byte Ptr) = \"NEWUPV2\"\nFunction SETLC:Int(s:Stack, b:Bytecode, r:Byte Ptr) = \"SETLC2\"\nEnd Extern\nEnd Rem\n'Const file:String = \"tests\/checktable.lua\"\n'Const file:String = \"tests\/mandelbrot.lua\"\n'Const file:String = \"tests\/sieve.lua\"\n'Const file:String = \"tests\/attrib.lua\"\nConst file:String = \"test.lua\"\n\nConst outFile:String = \"out.lua.so\"\n\n\nPrint BlueCompiler.ShowBytecode(file)\n\nRem\nBlueJIT.InitOpTbl()\n'BlueJIT.opTbl[BlueJIT.opc.ADD] = ADD\n'BlueJIT.opTbl[BlueJIT.opc.EQ] = EQ\n'BlueJIT.opTbl[BlueJIT.opc.GETUPV] = GETUPV\n'BlueJIT.opTbl[BlueJIT.opc.JIF] = JIF\n'BlueJIT.opTbl[BlueJIT.opc.LOADBOOL] = LOADBOOL\n'BlueJIT.opTbl[BlueJIT.opc.LOADK] = LOADK\n'BlueJIT.opTbl[BlueJIT.opc.LOADNIL] = LOADNIL\n'BlueJIT.opTbl[BlueJIT.opc.LOADSI] = LOADSI\nBlueJIT.opTbl[BlueJIT.opc.MOV] = MOV\n'BlueJIT.opTbl[BlueJIT.opc.NEWUPV] = NEWUPV\n'BlueJIT.opTbl[BlueJIT.opc.SETLC] = SETLC\nEnd Rem\n\nLocal code:BlueBinary = BlueCompiler.CompileFileForLoad(file)\nLocal vm:BlueVM = New BlueVM\nLocal tl:BlueLuaVal = vm.LoadObjectCode(code)\n'tl.Call()\n\nLocal stk:Stack = BlueJIT.BPtoS(vm.mem.stack)\nstk.retIP = Null ; stk.prevBase = Null\nLocal vc:Int = 10, upvars:Int = 1\nstk.varp = Long Ptr(Byte Ptr(stk) + BlueJIT.STACKFRAME_INC) + upvars\nstk.func = vm.funIndex[0]\n'stk.IP = 0\nstk.argv = Null\t'may want to add space?\nstk.retv = Null\nstk.argc = 0\nstk.retc = 0\n\nPrint \"running...\"\nLocal t:Int = MilliSecs()\nLocal test:Int(_:Byte Ptr) = stk.func.mcode - BlueJIT.PROLOGUESZ ; test(stk)\nt = MilliSecs() - t\nPrint t\nPrint \"run complete\"\n\n\nPrint \"done.\"\nEnd\n\n' notes:\n' - string constants and bytecode are loaded directly into oldSpc, since they'll be needed often\n' - the structure of a bytecode object is:\n' [ machine code ptr ][ id-offset ][ #k ][ #param ][ #upvar ][ frame sz ][ #instrs ][ vm ][ instructions... ][ upvar table... ][ k table... ]\n' initial fields are all 32b; instructions are each 64b; upvar table is pairs of 32b values (level, pos); k table is NaN-box values\n\n' - the structure of a closure object (actual Lua value representing a function) is:\n' [ bytecode ptr ][ upvar values... ]\n\nType BlueVM\n\tField mem:BlueVMMemory, _ENV:BlueLuaVal\n\tField idMod:Int, funIndex:Bytecode Ptr, _fiSz:Int\n\t\n\tMethod New()\n\t\tmem = New BlueVMMemory\n\tEnd Method\n\t\n\t' Load the procedures and constants of a compiled binary into the VM, returning the function representing the program toplevel\n\tMethod LoadObjectCode:BlueLuaVal(code:BlueBinary)\n\t\tLocal buf:Int[] = code.buf\n\t\tLocal fcount:Int = buf[0], kcount:Int = buf[1], ktblpos:Int = buf[2], ktbl:Double[kcount]\n\t\tLocal convert:Byte Ptr(o:Object) = Byte Ptr(BlueJIT.Identity)\n\t\t\n\t\tFor Local k:Int = 0 Until kcount\n\t\t\tLocal koff:Int = buf[ktblpos + k], sz:Int = buf[ktblpos + k + 1] - koff\n\t\t\tIf sz > 2\t'strings have size > 2\n\t\t\t\tLocal length:Double, lp:Int Ptr = Int Ptr(Varptr(length))\n\t\t\t\tlp[0] = buf[koff] ; lp[1] = buf[koff + 1]\n\t\t\t\tLocal s:Byte Ptr = mem.AllocString(length, Short Ptr(Varptr(buf[koff + 2])))\n\t\t\t\tktbl[k] = mem.PtrToVal(s, BlueTypeTag.STR)\n\t\t\tElse\n\t\t\t\tLocal d:Double, dp:Int Ptr = Int Ptr(Varptr(d))\n\t\t\t\tdp[0] = buf[koff] ; dp[1] = buf[koff + 1]\n\t\t\t\tktbl[k] = d\n\t\t\tEndIf\n\t\tNext\n\t\t\n\t\tExtendFunIndex(idMod + fcount)\n\t\tFor Local f:Int = 0 Until fcount\n\t\t\tLocal foff:Int = buf[3 + f]\n\t\t\tLocal ic:Int = buf[foff + 1], kc:Int = buf[foff + 2], pc:Int = buf[foff + 3], uc:Int = buf[foff + 5], fsz:Int = buf[foff + 6]\n\t\t\t\n\t\t\tLocal b:Bytecode = BPtoBC(mem.AllocObjectOldSpace(mem.oldStrSpace, (8 + 2 * (uc + uc Mod 2) + 2 * kc + 2 * ic) * 4, BlueTypeTag.BCODE))\n\t\t\tb.idMod = idMod ; b.kcount = kc ; b.pcount = pc ; b.upvars = uc + (uc Mod 2)\t'round up for alignment\n\t\t\tb.frameSz = BlueJIT.STACKFRAMESZ + b.upvars * 8 + fsz * 8 ; b.icount = ic ; b.vm = convert(Self)\n\t\t\t\n\t\t\tLocal ib:Int Ptr = Int Ptr(Byte Ptr(b) + 4) + 8 + 2 * ic\n\t\t\tFor Local u:Int = 0 Until uc\n\t\t\t\tLocal uoff:Int = 7 + u * 2\n\t\t\t\tib[u * 2] = buf[foff + uoff] ; ib[u * 2 + 1] = buf[foff + uoff + 1]\n\t\t\tNext\n\t\t\tIf uc <> b.upvars\t'ensure padding is safe by copying the first one\n\t\t\t\tib[uc * 2] = buf[foff + 7] ; ib[uc * 2 + 1] = buf[foff + 7 + 1]\n\t\t\tEndIf\n\t\t\t\n\t\t\tLocal db:Double Ptr = Double Ptr(ib + 2 * b.upvars)\n\t\t\tFor Local k:Int = 0 Until kc\n\t\t\t\tdb[k] = ktbl[buf[foff + 7 + uc * 2 + k]]\n\t\t\tNext\n\t\t\t\n\t\t\tLocal ioff:Int = 7 + 2 * uc + kc ; ib = Int Ptr(Byte Ptr(b) + BlueJIT.BYTECODE_INC)\n\t\t\t\n\t\t\tFor Local i:Int = 0 Until ic * 2\n\t\t\t\tib[i] = buf[foff + ioff + i]\n\t\t\tNext\n\t\t\t\n\t\t\tb.mcode = BlueJIT.Compile(Self, ib, ic, b) + BlueJIT.PROLOGUESZ\n\t\t\tfunIndex[idMod + f] = b\n\t\tNext\n\t\t\n\t\tidMod :+ fcount\n\t\tReturn New BlueLuaVal\n\tEnd Method\n\t\n\tMethod ExtendFunIndex(sz:Int)\t'hack: BlitzMax has a bug with arrays of extern types! so we need to use C-style arrays for now\n\t\tLocal newFI:Bytecode Ptr = Bytecode Ptr(MemAlloc(sz * 4))\n\t\tIf _fiSz\n\t\t\tFor Local b:Int = 0 Until _fiSz\n\t\t\t\tnewFI[b] = funIndex[b]\n\t\t\tNext\n\t\t\tMemFree(funIndex)\n\t\t\tFor Local b:Int = _fiSz Until sz\n\t\t\t\tnewFI[b] = Null\n\t\t\tNext\n\t\tEndIf\n\t\tfunIndex = newFI ; _fiSz = sz\n\tEnd Method\n\t\n\tMethod CallToLua()\n\tEnd Method\n\t\n\tGlobal BPtoBC:Bytecode(p:Byte Ptr) = Byte Ptr(BlueJIT.PointerToExtType)\nEnd Type\n\nPrivate\nExtern\n\tType Stack\n\t\tField retIP:Byte Ptr, prevBase:Stack, varp:Long Ptr, func:Bytecode, _IP:Int, argv:Long Ptr, retv:Long Ptr, argc:Short, retc:Short\n\tEnd Type\n\tType Bytecode\n\t\tField mcode:Byte Ptr, idMod:Int, kcount:Int, pcount:Int, upvars:Int, frameSz:Int, icount:Int, vm:Byte Ptr\n\tEnd Type\nEnd Extern\nPublic\n\nType BlueJIT Final\n\tConst PROLOGUESZ:Int = 25, ISIZE:Int = 5\n\t\n\tGlobal opTbl:Int(s:Stack, b:Bytecode, r:Byte Ptr)[], opc:BlueOpcode\n\tGlobal Prologue:Int[] = [ ..\n\t\t$90, $90, ..\n\t\t$8b, $44, $24, $04, .. 'mov 4(%esp), %eax\n\t\t$89, $44, $24, $f4, .. 'mov %eax, -12(%esp)\n\t\t$c7, $44, $24, $f8, $FF, $FF, $FF, $FF, .. 'movl ########, -8(%esp)\n\t\t$89, $64, $24, $fc, .. 'mov %esp, -4(%esp)\n\t\t$83, $ec, $0c.. 'sub $12, %esp\n\t]\n\t\n\tFunction Compile:Byte Ptr(vm:BlueVM, ins:Byte Ptr, icount:Int, bytecode:Bytecode)\n\t\t?Not x86\n\t\tRuntimeError \"The Blue Moon JIT does not support your platform (x86-32 only at this time)\"\n\t\t?\n\t\tAssert SizeOf(0:Long) = SizeOf(0:Double) And SizeOf(0:Int) = 4 And SizeOf(0:Long) = 8 And SizeOf(Byte Ptr(0)) = 4, ..\n\t\t\t\"assumptions about platform datatype sizes are invalid\"\n\t\t\n\t\tIf opTbl = Null Then InitOpTbl()\n\t\t\n\t\tLocal sz:Int = PROLOGUESZ + icount * ISIZE\n\t\t\n\t\t' allocate executable space\n\t\tLocal blocks:Int[] = vm.mem.AllocCodeBlock(PROLOGUESZ + icount * ISIZE)\n\t\tLocal code:Byte Ptr = Byte Ptr(blocks[0]), rsize:Int = blocks[1] - (blocks[1] Mod ISIZE)\n\t\t\n\t\tFor Local p:Int = 0 Until PROLOGUESZ\t'emplace prologue (used for calling in from native only)\n\t\t\tcode[p] = Prologue[p]\n\t\tNext\n\t\tByte Ptr Ptr(code + 14)[0] = Byte Ptr(bytecode)\t'replace the ########\n\t\tcode :+ PROLOGUESZ ; rsize :- PROLOGUESZ\t'easier to not have to take this into account below\n\t\t\n\t\tLocal codePage:Int Ptr = Int Ptr(Int(code) & ((Int(2^12)-1) Shl 20))\t'return-to-native for the page\n\t\tcodePage[1] = $c30cc483\t'add $12, %esp ; ret - i.e. restore the stack to normal\n\t\t\n\t\t' generate machine code!\n\t\tRepeat\n\t\t\t\n\t\t\tFor Local i:Int = 0 Until rsize \/ ISIZE\t'emplace opcode calls and supporting bytecode data\n\t\t\t\tLocal codep:Byte Ptr = code + i * ISIZE, bytecodep:Byte Ptr = Byte Ptr(Int(codep) + vm.mem.PAGESZ)\n\t\t\t\tcodep[0] = $e8\t'call\n\t\t\t\tLocal bi:Int = i * 8, op:Int = ins[bi], ip:Int Ptr = Int Ptr(ins + bi), func:Byte Ptr = opTbl[op]\n\t\t\t\tByte Ptr Ptr(codep + 1)[0] = func - Int(codep + ISIZE)\n\t\t\t\t\n\t\t\t\tSelect op\n\t\t\t\t\tCase opc.LOADSI, opc.CLOSURE, opc.RET, opc.POSTCALL\n\t\t\t\t\t\tbytecodep[0] = ins[bi + 1] ; Int Ptr(bytecodep + 1)[0] = Int Ptr(ins + bi)[1]\n\t\t\t\t\t\t\n\t\t\t\t\tCase opc.LOADK\n\t\t\t\t\t\tLocal kp:Double Ptr = Double Ptr(ins + 8 * bytecode.icount + 8 * bytecode.upvars) + ip[1]\n\t\t\t\t\t\tbytecodep[0] = ins[bi + 1] ; Double Ptr Ptr(bytecodep + 1)[0] = kp\n\t\t\t\t\t\t\n\t\t\t\t\tCase opc.CALL\n\t\t\t\t\t\tbytecodep[0] = ins[bi + 1] ; bytecodep[1] = ins[bi + 2]\n\t\t\t\t\t\tShort Ptr(bytecodep)[1] = Int Ptr(ins + bi)[1]\n\t\t\t\t\t\t\n\t\t\t\t\tCase opc.JIF, opc.JNOT\n\t\t\t\t\t\tbytecodep[0] = ins[bi + 1]\n\t\t\t\t\t\tInt Ptr(bytecodep + 1)[0] = Int(codep) + ISIZE * Int Ptr(ins + bi)[1]\n\t\t\t\t\t\t\n\t\t\t\t\tCase opc.JMP\n\t\t\t\t\t\tcodep[0] = $e9\t'use a true jump\n\t\t\t\t\t\tInt Ptr(codep + 1)[0] = ISIZE * (Int Ptr(ins + bi)[1] - 1)\n\t\t\t\t\t\t\n\t\t\t\t\tDefault\t'binary operations A = B op C\n\t\t\t\t\t\tbytecodep[0] = ins[bi + 1] ; bytecodep[1] = ins[bi + 2] ; bytecodep[2] = Int Ptr(ins + bi)[1]\n\t\t\t\tEnd Select\n\t\t\tNext\n\t\t\t\n\t\t\tExit\t'deal with overflowing code sections here\n\t\tForever\n\t\t\n\t\tReturn code - PROLOGUESZ\n\tEnd Function\n\t\n\t\n\tConst STACKFRAMESZ:Int = 8 * 4, BYTECODESZ:Int = 8 * 4, STACKFRAME_INC:Int = STACKFRAMESZ + 4, BYTECODE_INC:Int = BYTECODESZ + 4\n\tConst IP_OFFSET:Int = BlueVMMemory.PAGESZ - ISIZE\n\t\n\t\n\t'note: extern vars must take into account the vtbl offset, so that converting from a typed pointer can be a simple cast (faster)\t\n\t\n\tFunction MOV(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"MOV \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tvarp[rp[0]] = varp[rp[1]]\t'assigning through Double is unsafe as it can corrupt the bit pattern\n\tEnd Function\n\tFunction GETLC(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction SETLC(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"SETLC \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLong Ptr Ptr(varp + rp[0])[0][0] = varp[rp[1]]\n\tEnd Function\n\tFunction LOADK(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"LOADK \/\/\"\n\t\tLocal rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET, varp:Long Ptr = stk.varp + rp[0], kp:Long Ptr = Long Ptr Ptr(rp + 1)[0]\n\t\tvarp[0] = kp[0]\n\tEnd Function\n\tFunction LOADSI(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"LOADSI \/\/\"\n\t\tLocal rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal val:Int = Int Ptr(rp + 1)[0]\n\t\tDouble Ptr(stk.varp)[rp[0]] = Double(val)\n\tEnd Function\n\tFunction LOADBOOL(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"LOADBOOL \/\/\"\n\t\tLocal rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET, vp:Int Ptr = Int Ptr(stk.varp + rp[0])\n\t\tvp[1] = BlueTypeTag.NANBOX | BlueTypeTag.BOOL\n\t\tvp[0] = Int Ptr(rp + 1)[0]\n\tEnd Function\n\tFunction LOADNIL(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"LOADNIL \/\/\"\n\t\tLocal rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tInt Ptr(stk.varp + rp[0])[1] = BlueTypeTag.NANBOX | BlueTypeTag.NIL\n\tEnd Function\n\t\n\tFunction GETTAB(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction GETTABSI(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction SETTAB(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction SETTABSI(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction GETTABI(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction SETTABI(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction GETUPV(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"GETUPV \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, upvp:Byte Ptr Ptr = Byte Ptr Ptr(Byte Ptr(stk) + STACKFRAME_INC)\n\t\tLocal rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET, valp:Long Ptr = Long Ptr(upvp[rp[1]])\n\t\tvarp[rp[0]] = valp[0]\n\tEnd Function\n\tFunction SETUPV(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction NEWTAB(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"NEWTAB \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal convert:BlueVM(p:Byte Ptr) = Byte Ptr(Identity), vm:BlueVM = convert(bc.vm)\n\t\tLocal tab:Byte Ptr = vm.mem.AllocTable(Null)\n\t\tLocal d:Int Ptr = Int Ptr(varp + rp[0])\n\t\td[0] = Int(tab) ; d[1] = BlueTypeTag.NANBOX | BlueTypeTag.TBL\n\tEnd Function\n\tFunction CLOSURE(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"CLOSURE \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal convert:BlueVM(p:Byte Ptr) = Byte Ptr(Identity), vm:BlueVM = convert(bc.vm)\n\t\tLocal d:Int Ptr = Int Ptr(varp + rp[0])\n\t\tLocal cbytecode:Bytecode = vm.funIndex[Int Ptr(rp + 1)[0]], upvp:Int Ptr = Int Ptr(Byte Ptr(cbytecode) + BYTECODE_INC + 8 * cbytecode.icount)\n\t\tLocal closure:Byte Ptr = vm.mem.AllocClosure(cbytecode, cbytecode.upvars)\t'upvars is always even (alignment)\n\t\t\n\t\t'get upvalues off the stack\n\t\tFor Local u:Int = 0 Until cbytecode.upvars\n\t\t\tIf upvp[2 * u]\n\t\t\t\tByte Ptr Ptr(closure)[2 + u] = Byte Ptr Ptr(Byte Ptr(stk) + STACKFRAME_INC)[upvp[2 * u + 1]]\n\t\t\tElse\n\t\t\t\tByte Ptr Ptr(closure)[2 + u] = Byte Ptr Ptr(varp + upvp[2 * u + 1])[0]\n\t\t\tEndIf\n\t\tNext\n\t\t\n\t\td[0] = Int(closure) ; d[1] = BlueTypeTag.NANBOX | BlueTypeTag.FUN\n\tEnd Function\n\tFunction NEWUPV(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"NEWUPV \/\/\"\n\t\tLocal rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal convert:BlueVM(p:Byte Ptr) = Byte Ptr(Identity), vm:BlueVM = convert(bc.vm)\n\t\tLocal upv:Byte Ptr = vm.mem.AllocObject(8, BlueTypeTag.UPV), d:Int Ptr = Int Ptr(stk.varp + rp[0])\n\t\tLong Ptr(upv)[0] = Long Ptr(d)[0]\t'promote a value if it existed (useful for parameters)\n\t\td[0] = Int(upv) ; d[1] = BlueTypeTag.NANBOX | BlueTypeTag.UPV\n\tEnd Function\n\t\n\tFunction ADD(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"ADD \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal d:Double Ptr = Double Ptr(varp + rp[0])\n\t\tLocal r:Int Ptr = Int Ptr(varp + rp[1]), l:Int Ptr = Int Ptr(varp + rp[2])\n\t\tIf l[1] & BlueTypeTag.NANBOX_CHK = BlueTypeTag.NANBOX Or r[1] & BlueTypeTag.NANBOX_CHK = BlueTypeTag.NANBOX\n\t\t\tDebugStop\n\t\tElse\n\t\t\td[0] = Double Ptr(l)[0] + Double Ptr(r)[0]\n\t\tEndIf\n\tEnd Function\n\tFunction SUB(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction MUL(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction DIV(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction NMOD(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction POW(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction CAT(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction IDIV(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction BAND(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction BOR(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction BXOR(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction BSHL(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction BSHR(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction UNM(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction LNOT(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction ALEN(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction BNOT(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction UNP(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction EQ(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"EQ \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = (Byte Ptr Ptr(retptr) - 4)[0] + IP_OFFSET\n\t\tLocal r:Double = Double Ptr(varp)[rp[1]]\n\t\tLocal l:Double = Double Ptr(varp)[rp[2]]\n\t\tInt Ptr(varp + rp[0])[0] = l = r\n\tEnd Function\n\tFunction LT(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction LEQ(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\t\n\tFunction JMP(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t\tPrint \"wait, why are we here?\"\n\tEnd Function\n\tFunction JIF(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"JIF \/\/\"\n\t\tLocal rp:Byte Ptr = (Byte Ptr Ptr(retptr) - 4)[0] + IP_OFFSET\n\t\tIf Int Ptr(stk.varp + rp[0])[0]\n\t\t\tLocal target:Int = Int Ptr(rp + 1)[0]\n\t\t\tInt Ptr(retptr)[-4] = target\n\t\tEndIf\n\tEnd Function\n\tFunction JNOT(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction CALL(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"CALL \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal fp:Int Ptr = Int Ptr(varp + rp[0])\n\t\tIf Not PrepareCall(fp, stk, rp, varp, retptr)\t'PrepareCall sets everything up so there's nothing else to do to make the call happen\n\t\t\t'__call metamethod\n\t\tEndIf\n\tEnd Function\n\tFunction TCALL(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction RET:Byte Ptr(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"RET \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp\n\t\tLocal rp0:Byte Ptr = Byte Ptr Ptr(retptr)[-4], rp:Byte Ptr = rp0 + IP_OFFSET\n\t\t\n\t\tLocal oldStk:Stack = stk.prevBase\n\t\tLocal retv:Long Ptr = varp + rp[0]\n\t\tIf oldStk\n\t\t\toldStk.retv = retv\n\t\t\toldStk.retc = Int Ptr(rp + 1)[0]\n\t\t\tByte Ptr Ptr(retptr)[-4] = stk.retIP\n\t\t\tByte Ptr Ptr(retptr)[-3] = Byte Ptr(oldStk)\n\t\t\tByte Ptr Ptr(retptr)[-2] = Byte Ptr(oldStk.func) + BYTECODE_INC\n\t\tElse\t'return to native code\n\t\t\tLocal codePage:Byte Ptr = Byte Ptr(Int(rp0) & ((Int(2^12)-1) Shl 20))\n\t\t\tByte Ptr Ptr(retptr)[-4] = codePage + 4\n\t\t\tReturn retv\n\t\tEndIf\n\tEnd Function\n\tFunction RETVA(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction POSTCALL(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"POSTCALL \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp\n\t\tLocal rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\t\n\t\tFor Local r:Int = 0 Until Min(Int Ptr(rp + 1)[0], stk.retc)\n\t\t\t(varp + rp[0])[r] = stk.retv[r]\n\t\t'\tPrint \" return \" + r + \": \" + Double Ptr(stk.retv)[r]\n\t\tNext\n\tEnd Function\n\tFunction VARARG(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction VAINIT(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction CALLINIT(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\t\n\t\n\tFunction PrepareCall:Int(fp:Int Ptr, stk:Stack, rp:Byte Ptr, varp:Long Ptr, retptr:Byte Ptr)\n\t\tIf fp[1] = BlueTypeTag.NANBOX | BlueTypeTag.FUN\n\t\t\tLocal newStk0:Stack ; Byte Ptr Ptr(Varptr(newStk0))[0] = Byte Ptr(stk) + stk.func.frameSz\n\t\t\tLocal newStk:Stack = newStk0\t'micro-opt: newStk0 can't be a register because of the unwieldy conversion\n\t\t\t\n\t\t\tnewStk.retIP = Byte Ptr Ptr(retptr)[-4]\n\t\t\tnewStk.prevBase = stk\n\t\t\tLocal closure:Byte Ptr = Byte Ptr(fp[0])\n\t\t\tLocal newBC:Bytecode = Bytecode Ptr(closure)[0]\n\t\t\tLocal voff:Int = STACKFRAME_INC + 4 * newBC.upvars\n\t\t\tnewStk.varp = Long Ptr(Byte Ptr(newStk) + voff)\n\t\t\tnewStk.func = newBC\n\t\t'\tnewStk._IP = 0\n\t\t\t\n\t\t\tLocal argc_actual:Int = Short Ptr(rp)[1], argc_required:Int = newBC.pcount\n\t\t'\tLocal argc_min:Int ; If argc_actual < argc_required Then argc_min = argc_actual Else argc_min = argc_required\n\t\t\tLocal argc_min:Int = argc_actual - argc_required ; argc_min = (argc_min & (argc_min Shr 31)) + argc_required 'branchless 32-bit Min\n\t\t\t\n\t\t\tLocal argv:Long Ptr = varp + rp[1], destv:Long Ptr = newStk.varp\n\t\t\tFor Local a:Int = 0 Until argc_min\n\t\t\t\tdestv[a] = argv[a]\n\t\t\t'\tPrint \" arg \" + a + \": \" + argv[a]\n\t\t\tNext\n\t\t\tFor Local a:Int = argc_min Until argc_required\t'nil any unfilled parameters\n\t\t\t\tInt Ptr(destv + a)[1] = BlueTypeTag.NANBOX | BlueTypeTag.NIL\n\t\t\tNext\n\t\t\tnewStk.argv = argv + argc_min\t'argv should be to the varargs (if any)\n\t\t\tnewStk.argc = argc_actual - argc_min\t'argc is the number of varargs\n\t\t\t\n\t\t\tLocal destup:Byte Ptr Ptr = Byte Ptr Ptr(Byte Ptr(newStk) + STACKFRAME_INC)\n\t\t\tLocal upv:Byte Ptr Ptr = Byte Ptr Ptr(closure + 8)\n\t\t\tFor Local up:Int = 0 Until newBC.upvars\t'emplace upvars\n\t\t\t\tdestup[up] = upv[up]\n\t\t\t'\tPrint \" upv \" + up + \": \" + destv[up]\n\t\t\t'\tPrint \" val: \" + Double Ptr Ptr(Byte Ptr Ptr(closure) + 2 + up)[0][0]\n\t\t\tNext\n\t\t\t\n\t\t\t'note that the following OVERWRITE THE PARAMETERS (in release mode), so no touching stk from here on\n\t\t\tByte Ptr Ptr(retptr)[-4] = newBC.mcode\n\t\t\tByte Ptr Ptr(retptr)[-3] = Byte Ptr(newStk)\n\t\t\tByte Ptr Ptr(retptr)[-2] = Byte Ptr(newBC) + BYTECODE_INC\n\t\t\t\n\t\tElseIf fp[1] = BlueTypeTag.NANBOX | BlueTypeTag.NATFUN\n\t\t\t'native call\n\t\tElse\n\t\t\tReturn False\t'not a function; take appropriate action\n\t\tEndIf\n\t\tReturn True\t'all good and will auto-call when the caller returns\n\tEnd Function\n\t\n\tFunction InitOpTbl()\n\t\topc = New BlueOpcode\n\t\topTbl = [MOV, GETLC, SETLC, LOADK, LOADSI, LOADBOOL, LOADNIL, ..\n\t\t\tGETTAB, GETTABSI, SETTAB, SETTABSI, GETTABI, SETTABI, GETUPV, SETUPV, ..\n\t\t\tNEWTAB, CLOSURE, NEWUPV, ..\n\t\t\tADD, SUB, MUL, DIV, NMOD, POW, CAT, ..\n\t\t\tIDIV, BAND, BOR, BXOR, BSHL, BSHR, ..\n\t\t\tUNM, LNOT, ALEN, BNOT, UNP, ..\n\t\t\tEQ, LT, LEQ, ..\n\t\t\tJMP, JIF, JNOT, CALL, TCALL, RETVA, RETVA, ..\t'not a mistake: RET doesn't fit but we need the spacer\n\t\t\tPOSTCALL, VARARG, VAINIT, CALLINIT]\n\t\t\n\t\topTbl[opc.RET] = Byte Ptr(RET)\n\tEnd Function\n\t\n\tFunction Identity:Byte Ptr(b:Byte Ptr)\n\t\tReturn b\n\tEnd Function\n\tFunction PointerToExtType:Byte Ptr(p:Byte Ptr)\t'horrible pointer abuse (increment down so we can ignore the nonexistent vtbl)\n\t\tReturn p - 4'sizeof(Byte Ptr)\n\tEnd Function\n\tGlobal BPtoS:Stack(p:Byte Ptr) = Byte Ptr(BlueJIT.PointerToExtType)\nEnd Type\n\nType BlueLuaVal\n\tField _obj:BlueGCNode\n\n\tMethod Call()\n\tEnd Method\nEnd Type\n\n\nRem\nLocal files:TList = CreateList()\nLocal as:String, ld:String, showHelp:Int, output:String = \"a.out\", doAssemble:Int = 1\nLocal keepAsm:Int, makeExe:Int = 1, asOpts:String, ldOpts:String, showAST:Int, showVersion:Int\n\n?MacOS\nas = \"clang -m32 -c \" ; ld = \"clang -Wl,-no_pie -m32 -read_only_relocs suppress \"\n?Not MacOS\nas = \"gcc -m32 -c \" ; ld = \"gcc -m32 \"\n?\n\nFor Local a:Int = 1 Until AppArgs.Length\n\tSelect AppArgs[a]\n\t\tCase \"-?\", \"--help\"\n\t\t\tshowHelp = 1\n\t\tCase \"-v\"\n\t\t\tshowVersion = 1\n\t\tCase \"-o\"\n\t\t\tIf makeExe = 0\n\t\t\t\tPrint \"warning: -c and -o are mutually exclusive; -c is overruling -o\"\n\t\t\tElse\n\t\t\t\ta :+ 1 ; output = AppArgs[a] ; makeExe = 2\n\t\t\tEndIf\n\t\tCase \"-c\"\n\t\t\tIf makeExe = 2\n\t\t\t\tPrint \"warning: -o and -c are mutually exclusive; -o is overruling -c\"\n\t\t\tElse\n\t\t\t\tdoAssemble = 1 ; makeExe = 0\n\t\t\tEndIf\n\t\tCase \"-s\"\n\t\t\tkeepAsm = 1\n\t\tCase \"-S\"\n\t\t\tkeepAsm = 1 ; doAssemble = 0 ; makeExe = 0\n\t\tCase \"--as\"\n\t\t\ta :+ 1 ; as = AppArgs[a] + \" \"\n\t\tCase \"--ld\"\n\t\t\ta :+ 1 ; ld = AppArgs[a] + \" \"\n\t\tCase \"--as-opt\"\n\t\t\ta :+ 1 ; asOpts :+ AppArgs[a] + \" \"\n\t\tCase \"--ld-opt\"\n\t\t\ta :+ 1 ; ldOpts :+ AppArgs[a] + \" \"\n\t\tCase \"--tree\"\n\t\t\tshowAST = 1 ; makeExe = 0\n\t\tCase \"-w\" ; YBCodeGen.SetWarningLevel 0\n\t\tCase \"--werr\" ; YBCodeGen.SetWarningLevel 2\n\t\tCase \"--warn\" ; YBCodeGen.SetWarningLevel 1\n\t\tDefault\n\t\t\tfiles.AddLast AppArgs[a]\n\tEnd Select\nNext\nIf AppArgs.Length = 1 Then Print \"ybc: no input files\" ; End\n\nIf showVersion Then DisplayVersion\nIf showHelp Then DisplayHelp\n\n?Win32\nLocal rm:String = \"del \/Q \"\n?Not Win32\nLocal rm:String = \"rm \"\n?\n\nLocal allOFiles:String = \"\"\nFor Local file:String = EachIn files\n\tTry\n\t\tLocal tree:TParseNode = YBParseFile(file)\n\t\tIf showAST\n\t\t\tPrint tree.ToString()\n\t\tElse\n\t\t\tYBCodeGen.Build tree\n\t\t\tYBAssembler.Emit file + \".s\", YBCodeGen.syms, YBCodeGen.funs, YBCodeGen.vars, YBCodeGen.strs\n\t\t\tIf doAssemble\n\t\t\t\tsystem_(as + asOpts + file + \".s -o \" + file + \".o\")\n\t\t\t\tallOFiles :+ file + \".o \"\n\t\t\tEndIf\n\t\t\tIf Not keepAsm\n\t\t\t\tsystem_ rm + file + \".s\"\n\t\t\tEndIf\n\t\tEndIf\n\tCatch e:Object\n\t\tPrint \"Compile error:~n \" + e.ToString()\n\t\tPrint \"Compilation halted.\"\n\t\t?Debug\n\t\tThrow e\n\t\t?\n\t\tEnd\n\tEnd Try\nNext\n\n?Linux\nLocal bLib:String = \"b-lib-linux\"\n?Not Linux\nLocal bLib:String = \"b-lib\"\n?\nIf makeExe\n\tIf Not FileType(\"b-lib.o\") Then system_ as + bLib + \".s -o b-lib.o\"\n\tsystem_(ld + ldOpts + \"-o \" + output + \" \" + allOFiles + \" b-lib.o\")\n\tsystem_(rm + allOFiles)\nEndIf\n\nPrint \"done.\"\nEnd\nEnd Rem\nRem\nFunction DisplayVersion()\n\tPrint \"Shadow SIMD Compiler: version 0.0\"\nEnd Function\n\nFunction DisplayHelp()\n\tPrint \"OVERVIEW: ybc compiler for B~n\"\n\tPrint \"USAGE: ybc [options] ~n\"\n\tPrint \"OPTIONS:~n\"\n\tPrint \" -?, --help Display this message\"\n\tPrint \" -v Show the compiler version\"\n\tPrint \" -o Set the name of the output executable (default 'a.out')\"\n\tPrint \" -c Produce separate .o files instead of an executable\"\n\tPrint \" -s Keep text assembly .s files\"\n\tPrint \" -S Only produce text assembly, do not assemble binaries\"\n\tPrint \" --as Set the command to use as the assembler\"\n\tPrint \" --ld Set the command to use as the linker\"\n\tPrint \" --as-opt Add an option to pass to the assembler (can repeat)\"\n\tPrint \" --ld-opt Add an option to pass to the linker (can repeat)\"\n\tPrint \" --tree Display the AST of the program source instead of compiling\"\n\tPrint \" -w Silence warnings\"\n\tPrint \" --werr Convert warnings to errors\"\n\tPrint \" --warn Notify but do not halt on warnings (default)\"\nEnd Function\nEnd Rem\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"db02294a92427db59e8c8055ba6450e7dd551bdf","subject":"Removed unneeded line of code","message":"Removed unneeded line of code\n","repos":"Htbaa\/xmlrpc.mod,Htbaa\/xmlrpc.mod,Htbaa\/xmlrpc.mod,Htbaa\/xmlrpc.mod,Htbaa\/xmlrpc.mod","old_file":"response.bmx","new_file":"response.bmx","new_contents":"Rem\n\tbbdoc:\nEnd Rem\nType TXMLRPC_Response_Data_Exception Extends TXMLRPC_Exception\nEnd Type\n\nRem\n\tbbdoc: Data returned from XML-RPC server\nEnd Rem\nType TXMLRPC_Response_Data\n\tField data:TMap\n\t\n\tRem\n\t\tbbdoc:\n\tEnd Rem\n\tMethod Create:TXMLRPC_Response_Data(message:String, options:Byte Ptr)\n\t\tLocal request:Byte Ptr = XMLRPC_REQUEST_FromXML(message, Null, options)\n\t\t\n\t\tLocal el:Byte Ptr = XMLRPC_RequestGetData(request)\n\n\t\tSelf.data = TXMLRPC_Response_Data.IterateVector(el)\n\t\t\n\t\tXMLRPC_RequestFree(request, 1)\n\t\tReturn Self\n\tEnd Method\n\n\tRem\n\t\tbbdoc: Iterate over an XMLRPC vector and add it to a TMap\n\tEnd Rem\t\n\tFunction IterateVector:TMap(el:Byte Ptr)\n\t\tLocal data:TMap = New TMap\n\n\t\tIf el\n\t\t\t'Rewind vector\n\t\t\tLocal itr:Byte Ptr = XMLRPC_VectorRewind(el)\n\t\t\tIf Not itr\n\t\t\t\tdata.Insert(\"0\", TXMLRPC_Data_Type_Abstract.XMLRPC_To_BlizMax(el))\n\t\t\tElse\n\t\t\t\tLocal dataCounter:Int = 0\n\t\t\t\tWhile itr\n\t\t\t\t\tLocal id:String = String.FromCString(XMLRPC_GetValueID(itr))\n\t\t\t\t\t\n\t\t\t\t\tIf id.Length = 0\n\t\t\t\t\t\tid = String.FromInt(dataCounter)\n\t\t\t\t\t\tdataCounter:+1\n\t\t\t\t\tEnd If\n\t\t\t\t\t\n\t\t\t\t\tdata.Insert(id, TXMLRPC_Data_Type_Abstract.XMLRPC_To_BlizMax(itr))\n\t\n\t\t\t\t\t'Next element\n\t\t\t\t\titr = XMLRPC_VectorNext(el)\n\t\t\t\tWend\n\t\t\tEnd If\n\t\tEnd If\n\t\t\n\t\tReturn data\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Helper function to show what's inside the map\n\tEnd Rem\n\tFunction DebugData:String(map:TMap, pad:Int Var)\n\t\tLocal str:String\n\t\tLocal prefix:String\n\t\tFor Local i:Int = 0 To pad\n\t\t\tprefix:+\"-\"\n\t\tNext\n\t\t\n\t\tFor Local val:TXMLRPC_Data_Type_Abstract = EachIn map.Values()\n\t\t\tstr:+prefix + \" \" + TTypeId.ForObject(val).Name() + \" (\" + val.name + \") = \" + val.ToString() + \"~n\"\n\t\t\tIf TXMLRPC_Data_Type_Collection(val)\n\t\t\t\tpad:+1\n\t\t\t\tstr:+TXMLRPC_Response_Data.DebugData(TXMLRPC_Data_Type_Collection(val).data, pad) + \"~n\"\n\t\t\t\tpad:-1\n\t\t\tEnd If\n\t\tNext\n\t\tReturn str\n\tEnd Function\nEnd Type\n","old_contents":"Rem\n\tbbdoc:\nEnd Rem\nType TXMLRPC_Response_Data_Exception Extends TXMLRPC_Exception\nEnd Type\n\nRem\n\tbbdoc: Data returned from XML-RPC server\nEnd Rem\nType TXMLRPC_Response_Data\n\tField data:TMap\n\t\n\tRem\n\t\tbbdoc:\n\tEnd Rem\n\tMethod Create:TXMLRPC_Response_Data(message:String, options:Byte Ptr)\n\t\tLocal request:Byte Ptr = XMLRPC_REQUEST_FromXML(message, Null, options)\n\t\t\n\t\tLocal el:Byte Ptr = XMLRPC_RequestGetData(request)\n\n\t\tSelf.data = TXMLRPC_Response_Data.IterateVector(el)\n\t\t\n\t\tXMLRPC_RequestFree(request, 1)\n\t\tReturn Self\n\tEnd Method\n\n\tRem\n\t\tbbdoc: Iterate over an XMLRPC vector and add it to a TMap\n\tEnd Rem\t\n\tFunction IterateVector:TMap(el:Byte Ptr)\n\t\tLocal data:TMap = New TMap\n\n\t\tIf el\n\t\t\t'Rewind vector\n\t\t\tLocal itr:Byte Ptr = XMLRPC_VectorRewind(el)\n\t\t\tIf Not itr\n\t\t\t\tdata.Insert(\"0\", TXMLRPC_Data_Type_Abstract.XMLRPC_To_BlizMax(el))\n\t\t\tElse\n\t\t\t\tLocal dataCounter:Int = 0\n\t\t\t\tWhile itr\n\t\t\t\t\tLocal dataType:Int = XMLRPC_GetValueType(itr)\n\t\t\t\t\tLocal id:String = String.FromCString(XMLRPC_GetValueID(itr))\n\t\t\t\t\t\n\t\t\t\t\tIf id.Length = 0\n\t\t\t\t\t\tid = String.FromInt(dataCounter)\n\t\t\t\t\t\tdataCounter:+1\n\t\t\t\t\tEnd If\n\t\t\t\t\t\n\t\t\t\t\tdata.Insert(id, TXMLRPC_Data_Type_Abstract.XMLRPC_To_BlizMax(itr))\n\t\n\t\t\t\t\t'Next element\n\t\t\t\t\titr = XMLRPC_VectorNext(el)\n\t\t\t\tWend\n\t\t\tEnd If\n\t\tEnd If\n\t\t\n\t\tReturn data\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Helper function to show what's inside the map\n\tEnd Rem\n\tFunction DebugData:String(map:TMap, pad:Int Var)\n\t\tLocal str:String\n\t\tLocal prefix:String\n\t\tFor Local i:Int = 0 To pad\n\t\t\tprefix:+\"-\"\n\t\tNext\n\t\t\n\t\tFor Local val:TXMLRPC_Data_Type_Abstract = EachIn map.Values()\n\t\t\tstr:+prefix + \" \" + TTypeId.ForObject(val).Name() + \" (\" + val.name + \") = \" + val.ToString() + \"~n\"\n\t\t\tIf TXMLRPC_Data_Type_Collection(val)\n\t\t\t\tpad:+1\n\t\t\t\tstr:+TXMLRPC_Response_Data.DebugData(TXMLRPC_Data_Type_Collection(val).data, pad) + \"~n\"\n\t\t\t\tpad:-1\n\t\t\tEnd If\n\t\tNext\n\t\tReturn str\n\tEnd Function\nEnd Type\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"8cbdbc864c2cbff6f8d29f2dd53214b924205acc","subject":"Stop key going over 256 which causes BlitzMax to crash for MonkeyMax.","message":"Stop key going over 256 which causes BlitzMax to crash for MonkeyMax.\n\n--HG--\nextra : convert_revision : svn%3Ae934d3cd-0d57-f34a-94d0-9e8d31ae1c29\/trunk%40353\n","repos":"programmerby\/diddy-mirror,programmerby\/diddy-mirror,programmerby\/diddy-mirror,programmerby\/diddy-mirror","old_file":"monkeymax\/modules\/mojo\/native\/mojo.bmax.bmx","new_file":"monkeymax\/modules\/mojo\/native\/mojo.bmax.bmx","new_contents":"' ***** Start mojo.bmax.bmx ******\r\n\r\nGlobal app:gxtkApp\r\n\r\nType gxtkApp\r\n\tField ginput:gxtkInput\r\n\tField gaudio:gxtkAudio\r\n\tField ggraphics:gxtkGraphics\r\n\r\n\tField dead:Int=0\r\n\tField suspended:Int=0\r\n\tField vloading:Int=0\r\n\tField maxloading:Int=0\r\n\tField updateRate:Int=0\r\n\tField nextUpdate:Float=0\r\n\tField updatePeriod:Float=0\r\n\tField startMillis:Float=0\r\n\t\r\n\tMethod New()' gxtkApp()\r\n\t\tapp=Self\r\n\t\tggraphics=New gxtkGraphics\r\n\tEndMethod\r\n\t\r\n\tMethod Setup()\r\n\t\tginput=New gxtkInput\r\n\t\tgaudio=New gxtkAudio\r\n\r\n\t\tbb_input_SetInputDevice(ginput)\r\n\t\tbb_audio_SetAudioDevice(gaudio)\r\n\t\t\r\n\t\tstartMillis=BlitzMaxMillisecs()\r\n\t\t\r\n\t\tSetFrameRate( 0 )\r\n\t\t\r\n\t\tInvokeOnCreate()\r\n\t\tInvokeOnRender()\r\n\t\tUpdate()\r\n\tEndMethod\r\n\t\r\n\tMethod Update()\r\n\t\tWhile Not AppTerminate()\r\n\t\t\tLocal updates:Int = 0\r\n\t\t\t\r\n\t\t\tLocal cont:Int = 1\r\n\t\t\tWhile (cont)\r\n\t\t\t\tnextUpdate:+updatePeriod\r\n\t\t\t\tInvokeOnUpdate()\r\n\t\t\t\tIf Not updatePeriod Then cont = 0\r\n\t\t\t\tIf nextUpdate>BlitzMaxMillisecs() Then cont = 0\r\n\t\t\t\tupdates:+1\r\n\t\t\t\tIf updates = 7 Then\r\n\t\t\t\t\tnextUpdate = BlitzMaxMillisecs()\r\n\t\t\t\t\tcont = 0\r\n\t\t\t\tEndIf\r\n\t\t\tWend\r\n\t\t\tInvokeOnRender()\r\n\t\tWend\r\n\tEndMethod\r\n\t\r\n\tMethod InvokeOnCreate()\r\n\t\tIf dead Return\r\n\t\tdead = 1\r\n\t\tOnCreate()\r\n\t\tdead = 0\r\n\tEndMethod\r\n\r\n\tMethod InvokeOnUpdate()\r\n\t\tIf dead Or suspended Or Not updateRate Or vloading Return\r\n\t\tOnUpdate()\r\n\tEndMethod\r\n\t\r\n\tMethod InvokeOnRender()\r\n\t\tIf dead Or suspended Return\r\n\t\tggraphics.BeginRender()\r\n\t\tIf vloading\r\n\t\t\tOnLoading()\r\n\t\tElse\r\n\t\t\tOnRender()\r\n\t\tEndIf\r\n\t\tggraphics.EndRender()\r\n\tEndMethod\r\n\t\r\n\t\r\n\tMethod SetFrameRate( fps:Int )\r\n\t\tIf fps\r\n\t\t\tupdatePeriod=1000.0\/fps\r\n\t\t\tnextUpdate=BlitzMaxMillisecs() +updatePeriod\r\n\t\tElse\r\n\t\t\tupdatePeriod=0\r\n\t\tEndIf\r\n\tEndMethod\r\n\r\n\tMethod LoadState:String()\r\n'\t\tvar file:SharedObject=SharedObject.getLocal( \"gxtkapp\" );\r\n'\t\tvar state:String=file.data.state;\r\n'\t\tfile.close();\r\n'\t\tif( state ) return state;\r\n\t\tReturn \"\"\r\n\tEndMethod\r\n\t\r\n\tMethod SaveState:Int( state:String )\r\n'\t\tvar file:SharedObject=SharedObject.getLocal( \"gxtkapp\" );\r\n'\t\tfile.data.state=state;\r\n'\t\tfile.close();\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod LoadString:String( path:String )\r\n\t\tpath = \"data\/\" + path\r\n\t\tReturn LoadText( path )\r\n\tEndMethod\r\n\t\r\n\t' ***** GXTK API *****\r\n\t\r\n\tMethod GraphicsDevice:gxtkGraphics()\r\n\t\tReturn ggraphics\r\n\tEndMethod\r\n\r\n\tMethod InputDevice:gxtkInput()\r\n\t\tReturn ginput\r\n\tEndMethod\r\n\r\n\tMethod AudioDevice:gxtkAudio()\r\n\t\tReturn gaudio\r\n\tEndMethod\r\n\r\n\tMethod SetUpdateRate:Int(hertz:Int)\r\n\t\tupdateRate = hertz\r\n\t\tIf Not vloading Then SetFrameRate(updateRate)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod MilliSecs:Int()\r\n\t\tReturn BlitzMaxMillisecs() - startMillis\r\n\tEndMethod\r\n\t\r\n\tMethod Loading:Int()\r\n\t\tReturn vloading\r\n\tEndMethod\r\n\r\n\tMethod OnCreate:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod OnUpdate:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod OnSuspend:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod OnResume:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod OnRender:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod OnLoading:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkGraphics\r\n\tField gmode:Int = 1\r\n\r\n\tMethod Mode:Int()\r\n\t\tReturn gmode\r\n\tEndMethod\r\n\t\r\n\tMethod Cls:Int(r:Int = 0, g:Int = 0, b:Int = 0)\r\n\t\tBlitzMaxCls(r, g, b)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawPoint:Int(x:Float, y:Float)\r\n\t\tPlot x, y\r\n\tEndMethod\r\n\t\r\n\tMethod LoadSurface:gxtkSurface(path:String)\r\n\t\tLocal image:TImage = LoadImage(\"data\/\"+path)\r\n\t\tIf image Then\r\n\t\t\tLocal gs:gxtkSurface = New gxtkSurface\r\n\t\t\tgs.setImage(image)\r\n\t\t\tReturn gs\r\n\t\tEndIf\r\n\t\tReturn Null\r\n\tEndMethod\r\n\t\r\n\tMethod BeginRender()\r\n\tEndMethod\r\n\t\r\n\tMethod EndRender()\r\n\t\tFlip\r\n\tEndMethod\r\n\t\r\n\tMethod SetColor:Int(r:Int, g:Int, b:Int)\r\n\t\tBlitzMaxSetColor(r, g, b)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod SetAlpha:Int(a:Float)\r\n\t\tBlitzMaxSetAlpha(a)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod SetBlend:Int(blend:Int)\r\n\t\tBlitzMaxSetBlend(blend)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod Width:Int()\r\n\t\tReturn GraphicsWidth()\r\n\tEndMethod\r\n\t\r\n\tMethod Height:Int()\r\n\t\tReturn GraphicsHeight()\r\n\tEndMethod\r\n\t\r\n\tMethod SetScissor:Int(x:Int, y:Int, w:Int, h:Int)\r\n\t\tSetViewport(x, y, w, h) ' NOT TESTED!\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod SetMatrix:Int(ix:Float,iy:Float,jx:Float,jy:Float,tx:Float,ty:Float)\r\n\t\tLocal sx:Float = Sqr( (ix*ix) + (jx*jx) )\r\n\t\tLocal sy:Float = Sqr( (iy*iy) + (jy*jy) )\r\n\t\tLocal rot:Float = -Atan2( jx, ix )\r\n\t\tSetTransform( rot, sx, sy )\r\n\t\tSetOrigin( tx, ty )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawSurface:Int(surface:gxtkSurface,x:Float,y:Float)\r\n\t\tDrawImage(surface.image, x, y, 0)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawSurface2:Int(surface:gxtkSurface,x:Float,y:Float, srcx:Int, srcy:Int, srcw:Int, srch:Int )\r\n\t\tDrawSubImageRect(surface.image, x, y, srcw, srch, srcx, srcy, srcw, srch)\t\t\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawLine:Int( x1:Float,y1:Float,x2:Float,y2:Float )\r\n\t\tBlitzMaxDrawLine(x1, y1, x2, y2)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawOval:Int( x:Float, y:Float, w:Float, h:Float )\r\n\t\tBlitzMaxDrawOval(x, y, w, h)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawPoly:Int(vertices:Float[])\r\n\t\tBlitzMaxDrawPoly( vertices )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawRect:Int( x:Float, y:Float, w:Float, h:Float )\r\n\t\tBlitzMaxDrawRect(x, y, w, h)\r\n\t\tReturn 0\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkInput\r\n\tMethod MouseX:Float()\r\n\t\tReturn BRL.PolledInput.MouseX()\r\n\tEndMethod\r\n\r\n\tMethod MouseY:Float()\r\n\t\tReturn BRL.PolledInput.MouseY()\r\n\tEndMethod\r\n\t\r\n\tMethod KeyDown:Int( key:Int )\r\n\t\tIf( key >= 1 And key <= 3 )\r\n\t\t\tReturn BRL.PolledInput.MouseDown( key )\r\n\t\tEndIf\r\n\t\tIf key < 256\r\n\t\t\tReturn BRL.PolledInput.KeyDown( key )\r\n\t\tElse\r\n\t\t\tReturn 0\r\n\t\tEndIf\r\n\tEndMethod\r\n\r\n\tMethod KeyHit:Int( key:Int )\r\n\t\tIf( key >= 1 And key <= 3 )\r\n\t\t\tReturn BRL.PolledInput.MouseHit( key )\r\n\t\tEndIf\r\n\t\tIf key < 256\r\n\t\t\tReturn BRL.PolledInput.KeyHit( key )\r\n\t\tElse\r\n\t\t\tReturn 0\r\n\t\tEndIf\r\n\tEndMethod\r\n\r\n\tMethod GetChar:Int()\r\n\t\tReturn BRL.PolledInput.GetChar()\r\n\tEndMethod\r\n\r\n\tMethod JoyX:Int( index:Int )\r\n\t\tReturn Pub.FreeJoy.JoyX( index )\r\n\tEndMethod\r\n\r\n\tMethod JoyY:Int( index:Int )\r\n\t\tReturn Pub.FreeJoy.JoyY( index )\r\n\tEndMethod\r\n\r\n\tMethod JoyZ:Int( index:Int )\r\n\t\tReturn Pub.FreeJoy.JoyZ( index )\r\n\tEndMethod\r\n\r\n\tMethod TouchX:Float( index:Int )\r\n\t\tReturn BRL.PolledInput.MouseX()\r\n\tEndMethod\r\n\r\n\tMethod TouchY:Float( index:Int )\r\n\t\tReturn BRL.PolledInput.MouseY()\r\n\tEndMethod\r\n\t\r\n\tMethod AccelX:Int()\r\n\t\treturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod AccelY:Int()\r\n\t\treturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod AccelZ:Int()\r\n\t\treturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod SetKeyboardEnabled:Int( enabled:int )\r\n\t\tReturn 0\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkChannel\r\n\tField channel:TChannel\t' null then not playing\r\n\tField sample:gxtkSample\r\n\tField loops:int\r\n\t'Field transform:SoundTransform=new SoundTransform()\r\n\t'Field pausepos:Number\r\n\tField state:int\r\n\t\r\n\tMethod New()\r\n\t\tchannel = New TChannel\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkAudio\r\n\tField amusicState:Int = 0\r\n\tField channels:gxtkChannel[] = New gxtkChannel[33]\r\n\t\r\n\tMethod New()\r\n\t\tFor local i:Int = 0 To 33 - 1\r\n\t\t\tchannels[i] = New gxtkChannel\r\n\t\tNext\r\n\tEndMethod\r\n\t\r\n\tMethod MusicState:Int()\r\n'\t\tIf( musicState = 1 And music.isPlaying() = False )\r\n'\t\t\tmusicState = 0;\r\n'\t\tEndif\r\n\t\tReturn amusicState\r\n\tEndMethod\r\n\t\r\n\tMethod PlayMusic:Int( path:String, flags:Int )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod ChannelState:int( channel:int )\r\n\t\tReturn -1\r\n\tEndMethod\r\n\t\r\n\tMethod StopMusic()\r\n\tEndMethod\r\n\t\r\n\tMethod StopChannel( channel:Int )\r\n\tEndMethod\r\n\r\n\tMethod PlaySample( sound:gxtkSample, channel:Int, flags:Int )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\t\r\n\t\t'If chan.state <> 0 Then chan.channel.Stop() <-- this crashes after the first play!?\r\n\t\t\r\n\t\tchan.sample = sound\r\n\t\t'chan.loops = flags ? 0x7fffffff : 0;\r\n\t\t'chan.channel = sample.sound.play( 0,chan.loops,chan.transform );\r\n\t\t'chan.channel = sound\r\n\t\tchan.state=1\r\n\t\r\n\t\tPlaySound( sound.sound, chan.channel )\r\n\tEndMethod\r\n\r\n\tMethod SetPan( channel:Int, pan:Float )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tchan.channel.SetPan(pan)\r\n\tEndMethod\r\n\r\n\tMethod SetRate( channel:Int, rate:Float )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tchan.channel.SetRate(rate)\r\n\tEndMethod\r\n\r\n\tMethod PauseMusic:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod ResumeMusic:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod SetMusicVolume:Int( volume:Float )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod SetVolume:Int( channel:Int, volume:Float )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tchan.channel.SetVolume(volume)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod LoadSample:gxtkSample( path:String )\r\n\t\tLocal sound:TSound = LoadSound(\"data\/\"+path)\r\n\t\tIf sound Then\r\n\t\t\tLocal gs:gxtkSample = New gxtkSample\r\n\t\t\tgs.setSound(sound)\r\n\t\t\tReturn gs\r\n\t\tEndIf\r\n\t\tReturn Null\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkSample\r\n\tField sound:TSound\r\n\t\r\n\tMethod setSound(sound:TSound)\r\n\t\tSelf.sound = sound\r\n\tEndMethod\r\n\t\r\n\tMethod Discard()\r\n\t\tSelf.sound = null\r\n\tEndMethod\r\nEndType\r\n\r\nFunction BlitzMaxDrawPoly:Int(vertices:Float[])\r\n\tDrawPoly vertices\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxDrawRect:Int( x:Float, y:Float, w:Float, h:Float )\r\n\tDrawRect x, y, w, h\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxDrawOval:Int( x:Float, y:Float, w:Float, h:Float )\r\n\tDrawOval x, y, w, h\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxDrawLine:Int( x1:Float,y1:Float,x2:Float,y2:Float )\r\n\tDrawLine x1, y1, x2, y2\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxMillisecs:Int()\r\n\tReturn MilliSecs()\r\nEndFunction\r\n\r\nFunction BlitzMaxSetColor(r:Int, g:Int, b:Int)\r\n\tSetColor(r, g, b)\r\nEndFunction\r\n\r\nFunction BlitzMaxSetBlend(blend:Int)\r\n\tSelect blend\r\n\t\tCase 0\r\n\t\t\tSetBlend( ALPHABLEND )\r\n\t\tCase 1\r\n\t\t\tSetBlend( LIGHTBLEND )\r\n\tEnd Select\r\nEndFunction\r\n\r\nFunction BlitzMaxSetAlpha(a:Float)\r\n\tSetAlpha(a)\r\nEndFunction\r\n\r\nFunction BlitzMaxCls(r:Int = 0, g:Int = 0, b:Int = 0)\r\n\tSetClsColor(r, g, b)\r\n\tCls\r\nEndFunction\r\n\r\nType gxtkSurface\r\n\tField w:Int, h:Int\r\n\tField image:TImage\r\n\t\r\n\tMethod setImage(image:TImage)\r\n\t\tSelf.image = image\r\n\tEndMethod\r\n\t\r\n\tMethod Width:Int()\r\n\t\tReturn image.Width\r\n\tEndMethod\r\n\t\r\n\tMethod Height:Int()\r\n\t\tReturn image.Height\r\n\tEndMethod\r\n\t\r\n\tMethod Discard()\r\n\tEndMethod\r\nEndType\r\n\r\n' ***** End mojo.bmax.bmx ******\r\n\r\n","old_contents":"' ***** Start mojo.bmax.bmx ******\r\n\r\nGlobal app:gxtkApp\r\n\r\nType gxtkApp\r\n\tField ginput:gxtkInput\r\n\tField gaudio:gxtkAudio\r\n\tField ggraphics:gxtkGraphics\r\n\r\n\tField dead:Int=0\r\n\tField suspended:Int=0\r\n\tField vloading:Int=0\r\n\tField maxloading:Int=0\r\n\tField updateRate:Int=0\r\n\tField nextUpdate:Float=0\r\n\tField updatePeriod:Float=0\r\n\tField startMillis:Float=0\r\n\t\r\n\tMethod New()' gxtkApp()\r\n\t\tapp=Self\r\n\t\tggraphics=New gxtkGraphics\r\n\tEndMethod\r\n\t\r\n\tMethod Setup()\r\n\t\tginput=New gxtkInput\r\n\t\tgaudio=New gxtkAudio\r\n\r\n\t\tbb_input_SetInputDevice(ginput)\r\n\t\tbb_audio_SetAudioDevice(gaudio)\r\n\t\t\r\n\t\tstartMillis=BlitzMaxMillisecs()\r\n\t\t\r\n\t\tSetFrameRate( 0 )\r\n\t\t\r\n\t\tInvokeOnCreate()\r\n\t\tInvokeOnRender()\r\n\t\tUpdate()\r\n\tEndMethod\r\n\t\r\n\tMethod Update()\r\n\t\tWhile Not AppTerminate()\r\n\t\t\tLocal updates:Int = 0\r\n\t\t\t\r\n\t\t\tLocal cont:Int = 1\r\n\t\t\tWhile (cont)\r\n\t\t\t\tnextUpdate:+updatePeriod\r\n\t\t\t\tInvokeOnUpdate()\r\n\t\t\t\tIf Not updatePeriod Then cont = 0\r\n\t\t\t\tIf nextUpdate>BlitzMaxMillisecs() Then cont = 0\r\n\t\t\t\tupdates:+1\r\n\t\t\t\tIf updates = 7 Then\r\n\t\t\t\t\tnextUpdate = BlitzMaxMillisecs()\r\n\t\t\t\t\tcont = 0\r\n\t\t\t\tEndIf\r\n\t\t\tWend\r\n\t\t\tInvokeOnRender()\r\n\t\tWend\r\n\tEndMethod\r\n\t\r\n\tMethod InvokeOnCreate()\r\n\t\tIf dead Return\r\n\t\tdead = 1\r\n\t\tOnCreate()\r\n\t\tdead = 0\r\n\tEndMethod\r\n\r\n\tMethod InvokeOnUpdate()\r\n\t\tIf dead Or suspended Or Not updateRate Or vloading Return\r\n\t\tOnUpdate()\r\n\tEndMethod\r\n\t\r\n\tMethod InvokeOnRender()\r\n\t\tIf dead Or suspended Return\r\n\t\tggraphics.BeginRender()\r\n\t\tIf vloading\r\n\t\t\tOnLoading()\r\n\t\tElse\r\n\t\t\tOnRender()\r\n\t\tEndIf\r\n\t\tggraphics.EndRender()\r\n\tEndMethod\r\n\t\r\n\t\r\n\tMethod SetFrameRate( fps:Int )\r\n\t\tIf fps\r\n\t\t\tupdatePeriod=1000.0\/fps\r\n\t\t\tnextUpdate=BlitzMaxMillisecs() +updatePeriod\r\n\t\tElse\r\n\t\t\tupdatePeriod=0\r\n\t\tEndIf\r\n\tEndMethod\r\n\r\n\tMethod LoadState:String()\r\n'\t\tvar file:SharedObject=SharedObject.getLocal( \"gxtkapp\" );\r\n'\t\tvar state:String=file.data.state;\r\n'\t\tfile.close();\r\n'\t\tif( state ) return state;\r\n\t\tReturn \"\"\r\n\tEndMethod\r\n\t\r\n\tMethod SaveState:Int( state:String )\r\n'\t\tvar file:SharedObject=SharedObject.getLocal( \"gxtkapp\" );\r\n'\t\tfile.data.state=state;\r\n'\t\tfile.close();\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod LoadString:String( path:String )\r\n\t\tpath = \"data\/\" + path\r\n\t\tReturn LoadText( path )\r\n\tEndMethod\r\n\t\r\n\t' ***** GXTK API *****\r\n\t\r\n\tMethod GraphicsDevice:gxtkGraphics()\r\n\t\tReturn ggraphics\r\n\tEndMethod\r\n\r\n\tMethod InputDevice:gxtkInput()\r\n\t\tReturn ginput\r\n\tEndMethod\r\n\r\n\tMethod AudioDevice:gxtkAudio()\r\n\t\tReturn gaudio\r\n\tEndMethod\r\n\r\n\tMethod SetUpdateRate:Int(hertz:Int)\r\n\t\tupdateRate = hertz\r\n\t\tIf Not vloading Then SetFrameRate(updateRate)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod MilliSecs:Int()\r\n\t\tReturn BlitzMaxMillisecs() - startMillis\r\n\tEndMethod\r\n\t\r\n\tMethod Loading:Int()\r\n\t\tReturn vloading\r\n\tEndMethod\r\n\r\n\tMethod OnCreate:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod OnUpdate:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod OnSuspend:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod OnResume:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod OnRender:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod OnLoading:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkGraphics\r\n\tField gmode:Int = 1\r\n\r\n\tMethod Mode:Int()\r\n\t\tReturn gmode\r\n\tEndMethod\r\n\t\r\n\tMethod Cls:Int(r:Int = 0, g:Int = 0, b:Int = 0)\r\n\t\tBlitzMaxCls(r, g, b)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawPoint:Int(x:Float, y:Float)\r\n\t\tPlot x, y\r\n\tEndMethod\r\n\t\r\n\tMethod LoadSurface:gxtkSurface(path:String)\r\n\t\tLocal image:TImage = LoadImage(\"data\/\"+path)\r\n\t\tIf image Then\r\n\t\t\tLocal gs:gxtkSurface = New gxtkSurface\r\n\t\t\tgs.setImage(image)\r\n\t\t\tReturn gs\r\n\t\tEndIf\r\n\t\tReturn Null\r\n\tEndMethod\r\n\t\r\n\tMethod BeginRender()\r\n\tEndMethod\r\n\t\r\n\tMethod EndRender()\r\n\t\tFlip\r\n\tEndMethod\r\n\t\r\n\tMethod SetColor:Int(r:Int, g:Int, b:Int)\r\n\t\tBlitzMaxSetColor(r, g, b)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod SetAlpha:Int(a:Float)\r\n\t\tBlitzMaxSetAlpha(a)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod SetBlend:Int(blend:Int)\r\n\t\tBlitzMaxSetBlend(blend)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod Width:Int()\r\n\t\tReturn GraphicsWidth()\r\n\tEndMethod\r\n\t\r\n\tMethod Height:Int()\r\n\t\tReturn GraphicsHeight()\r\n\tEndMethod\r\n\t\r\n\tMethod SetScissor:Int(x:Int, y:Int, w:Int, h:Int)\r\n\t\tSetViewport(x, y, w, h) ' NOT TESTED!\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod SetMatrix:Int(ix:Float,iy:Float,jx:Float,jy:Float,tx:Float,ty:Float)\r\n\t\tLocal sx:Float = Sqr( (ix*ix) + (jx*jx) )\r\n\t\tLocal sy:Float = Sqr( (iy*iy) + (jy*jy) )\r\n\t\tLocal rot:Float = -Atan2( jx, ix )\r\n\t\tSetTransform( rot, sx, sy )\r\n\t\tSetOrigin( tx, ty )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawSurface:Int(surface:gxtkSurface,x:Float,y:Float)\r\n\t\tDrawImage(surface.image, x, y, 0)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawSurface2:Int(surface:gxtkSurface,x:Float,y:Float, srcx:Int, srcy:Int, srcw:Int, srch:Int )\r\n\t\tDrawSubImageRect(surface.image, x, y, srcw, srch, srcx, srcy, srcw, srch)\t\t\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawLine:Int( x1:Float,y1:Float,x2:Float,y2:Float )\r\n\t\tBlitzMaxDrawLine(x1, y1, x2, y2)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawOval:Int( x:Float, y:Float, w:Float, h:Float )\r\n\t\tBlitzMaxDrawOval(x, y, w, h)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawPoly:Int(vertices:Float[])\r\n\t\tBlitzMaxDrawPoly( vertices )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawRect:Int( x:Float, y:Float, w:Float, h:Float )\r\n\t\tBlitzMaxDrawRect(x, y, w, h)\r\n\t\tReturn 0\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkInput\r\n\tMethod MouseX:Float()\r\n\t\tReturn BRL.PolledInput.MouseX()\r\n\tEndMethod\r\n\r\n\tMethod MouseY:Float()\r\n\t\tReturn BRL.PolledInput.MouseY()\r\n\tEndMethod\r\n\t\r\n\tMethod KeyDown:Int( key:Int )\r\n\t\tIf( key >= 1 And key <= 3 )\r\n\t\t\tReturn BRL.PolledInput.MouseDown( key )\r\n\t\tEndIf\r\n\t\tReturn BRL.PolledInput.KeyDown( key )\r\n\tEndMethod\r\n\r\n\tMethod KeyHit:Int( key:Int )\r\n\t\tIf( key >= 1 And key <= 3 )\r\n\t\t\tReturn BRL.PolledInput.MouseHit( key )\r\n\t\tEndIf\r\n\t\tReturn BRL.PolledInput.KeyHit( key )\r\n\tEndMethod\r\n\r\n\tMethod GetChar:Int()\r\n\t\tReturn BRL.PolledInput.GetChar()\r\n\tEndMethod\r\n\r\n\tMethod JoyX:Int( index:Int )\r\n\t\tReturn Pub.FreeJoy.JoyX( index )\r\n\tEndMethod\r\n\r\n\tMethod JoyY:Int( index:Int )\r\n\t\tReturn Pub.FreeJoy.JoyY( index )\r\n\tEndMethod\r\n\r\n\tMethod JoyZ:Int( index:Int )\r\n\t\tReturn Pub.FreeJoy.JoyZ( index )\r\n\tEndMethod\r\n\r\n\tMethod TouchX:Float( index:Int )\r\n\t\tReturn BRL.PolledInput.MouseX()\r\n\tEndMethod\r\n\r\n\tMethod TouchY:Float( index:Int )\r\n\t\tReturn BRL.PolledInput.MouseY()\r\n\tEndMethod\r\n\t\r\n\tMethod AccelX:Int()\r\n\t\treturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod AccelY:Int()\r\n\t\treturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod AccelZ:Int()\r\n\t\treturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod SetKeyboardEnabled:Int( enabled:int )\r\n\t\tReturn 0\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkChannel\r\n\tField channel:TChannel\t' null then not playing\r\n\tField sample:gxtkSample\r\n\tField loops:int\r\n\t'Field transform:SoundTransform=new SoundTransform()\r\n\t'Field pausepos:Number\r\n\tField state:int\r\n\t\r\n\tMethod New()\r\n\t\tchannel = New TChannel\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkAudio\r\n\tField amusicState:Int = 0\r\n\tField channels:gxtkChannel[] = New gxtkChannel[33]\r\n\t\r\n\tMethod New()\r\n\t\tFor local i:Int = 0 To 33 - 1\r\n\t\t\tchannels[i] = New gxtkChannel\r\n\t\tNext\r\n\tEndMethod\r\n\t\r\n\tMethod MusicState:Int()\r\n'\t\tIf( musicState = 1 And music.isPlaying() = False )\r\n'\t\t\tmusicState = 0;\r\n'\t\tEndif\r\n\t\tReturn amusicState\r\n\tEndMethod\r\n\t\r\n\tMethod PlayMusic:Int( path:String, flags:Int )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod ChannelState:int( channel:int )\r\n\t\tReturn -1\r\n\tEndMethod\r\n\t\r\n\tMethod StopMusic()\r\n\tEndMethod\r\n\t\r\n\tMethod StopChannel( channel:Int )\r\n\tEndMethod\r\n\r\n\tMethod PlaySample( sound:gxtkSample, channel:Int, flags:Int )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\t\r\n\t\t'If chan.state <> 0 Then chan.channel.Stop() <-- this crashes after the first play!?\r\n\t\t\r\n\t\tchan.sample = sound\r\n\t\t'chan.loops = flags ? 0x7fffffff : 0;\r\n\t\t'chan.channel = sample.sound.play( 0,chan.loops,chan.transform );\r\n\t\t'chan.channel = sound\r\n\t\tchan.state=1\r\n\t\r\n\t\tPlaySound( sound.sound, chan.channel )\r\n\tEndMethod\r\n\r\n\tMethod SetPan( channel:Int, pan:Float )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tchan.channel.SetPan(pan)\r\n\tEndMethod\r\n\r\n\tMethod SetRate( channel:Int, rate:Float )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tchan.channel.SetRate(rate)\r\n\tEndMethod\r\n\r\n\tMethod PauseMusic:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod ResumeMusic:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod SetMusicVolume:Int( volume:Float )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod SetVolume:Int( channel:Int, volume:Float )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tchan.channel.SetVolume(volume)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod LoadSample:gxtkSample( path:String )\r\n\t\tLocal sound:TSound = LoadSound(\"data\/\"+path)\r\n\t\tIf sound Then\r\n\t\t\tLocal gs:gxtkSample = New gxtkSample\r\n\t\t\tgs.setSound(sound)\r\n\t\t\tReturn gs\r\n\t\tEndIf\r\n\t\tReturn Null\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkSample\r\n\tField sound:TSound\r\n\t\r\n\tMethod setSound(sound:TSound)\r\n\t\tSelf.sound = sound\r\n\tEndMethod\r\n\t\r\n\tMethod Discard()\r\n\t\tSelf.sound = null\r\n\tEndMethod\r\nEndType\r\n\r\nFunction BlitzMaxDrawPoly:Int(vertices:Float[])\r\n\tDrawPoly vertices\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxDrawRect:Int( x:Float, y:Float, w:Float, h:Float )\r\n\tDrawRect x, y, w, h\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxDrawOval:Int( x:Float, y:Float, w:Float, h:Float )\r\n\tDrawOval x, y, w, h\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxDrawLine:Int( x1:Float,y1:Float,x2:Float,y2:Float )\r\n\tDrawLine x1, y1, x2, y2\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxMillisecs:Int()\r\n\tReturn MilliSecs()\r\nEndFunction\r\n\r\nFunction BlitzMaxSetColor(r:Int, g:Int, b:Int)\r\n\tSetColor(r, g, b)\r\nEndFunction\r\n\r\nFunction BlitzMaxSetBlend(blend:Int)\r\n\tSelect blend\r\n\t\tCase 0\r\n\t\t\tSetBlend( ALPHABLEND )\r\n\t\tCase 1\r\n\t\t\tSetBlend( LIGHTBLEND )\r\n\tEnd Select\r\nEndFunction\r\n\r\nFunction BlitzMaxSetAlpha(a:Float)\r\n\tSetAlpha(a)\r\nEndFunction\r\n\r\nFunction BlitzMaxCls(r:Int = 0, g:Int = 0, b:Int = 0)\r\n\tSetClsColor(r, g, b)\r\n\tCls\r\nEndFunction\r\n\r\nType gxtkSurface\r\n\tField w:Int, h:Int\r\n\tField image:TImage\r\n\t\r\n\tMethod setImage(image:TImage)\r\n\t\tSelf.image = image\r\n\tEndMethod\r\n\t\r\n\tMethod Width:Int()\r\n\t\tReturn image.Width\r\n\tEndMethod\r\n\t\r\n\tMethod Height:Int()\r\n\t\tReturn image.Height\r\n\tEndMethod\r\n\t\r\n\tMethod Discard()\r\n\tEndMethod\r\nEndType\r\n\r\n' ***** End mojo.bmax.bmx ******\r\n\r\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"daee1e669620a0b3637618d130bbc3c9128a6041","subject":"stack overflow detection","message":"stack overflow detection\n","repos":"Leushenko\/blue-moon","old_file":"blueallocator.bmx","new_file":"blueallocator.bmx","new_contents":"\n' Blue Moon\n' Memory allocator\/garbage collector\n' this is a generational three-colour mark\/compact collector\n\n' notes:\n\n' - a basic Lua value is represented as a NaN-box (i.e. a double, unless it's a NaN in which case there's a pointer in the significand)\n\n' - objects are allocated in newSpc, Cheney'd over to cpySpc when it runs out; the Eden spaces are 8MB each\n' - when less than .edenThreshold remains in cpySpc after a scavenge, objects held from oldSpc are promoted\n' - when more than .sizeThreshold has been promoted or less than .edenThreshold still remains, a full GC runs\n' this scan updates usage statistics for each page\n' the \"worst\" N pages are then compacted; if total usage is still poor, mark for another compact after next scavenge\n' the rest of Eden is then promoted\n' - fallback to compacting in one go if usage is catastrophic\/increments aren't keeping up\n' - roots are obtained from the gcroots list, and the stack\n\n' - before compacting\/discarding, the space is scanned for objects with finalizers which are resurrected into newSpc and put on toFinalize\n' - during a FULL collection, weak tables are listed in .weakTables rather than colouring elems, then weakscanned before compaction\n\n' - the stack is an 8M block with the last page protected\n' - stack frames use this format:\n' [ ret ip ][ prev base ][[ 16b frame sz ][ 16b var ofs ]][ func obj ][ ip ][ argv ][ retv ][[ 16b argc ][ 16b retc ]][ upv0 | upv1 | ... ][ v0 | v1 | ... ][ tmp... ]\n' the upvar slots, var slots, and temp slots beyond are all 64-bit NaN-boxes\n' the preceding slots are 32-bit words except otherwise shown\n\n' - pages in oldPtrSpc use this format:\n' [[[ 0..256 metadata ] ..16K dirty bitmap ] ..1M allocated objects ]\n' each 64-byte potential NaN-box in the object-space has a corresponding dirty bit that is set if it points to newSpc\n' a metamap in the metadata in turn marks dirty sectors of the bitmap, for reduced scanning\n' metadata also contains allocation pointer and used space total\n\n' - codeSpace stores executable instruction buffers for Lua functions (bytecode is allocated directly into oldStrSpc)\n\n' - bigSpc is a simple list of conventionally-allocated objects that don't fit on a 1M page\n\n' - objects use this layout:\n' [ 64b header: [ 32b size ][ 16b type tag ][ 8b colour ][ 1b hasFinalizer ][ 2b weak keys, values ] ][ N * 64b data area... ]\n' size includes header. for moved objects the second 32b are replaced by a forwarding pointer\n' pointers in general are to the data area, skipping header\n\n' - data types are: nil, boolean, number, string, closure, natfun, userdata, thread, table ; upvar, tablearray, tablehash, bytecode\n' nil\/boolean\/number\/natfun are value types and need no allocation\n' string uses this structure:\n' [H][ 32b length ][ 32b hash ][ ceil(length\/4) * 64b chars... ]\n' closure uses this structure:\n' [H][ 32b bytecode ptr ][32b][ N * 32b upvar ptrs... ] (N rounded up to 2 for alignment)\n' userdata uses this structure:\n' [H][ 32b metatable ][ 32b value ]\n' thread uses this structure:\n' [H][\n' table uses this structure:\n' [H][ 32b metatable ][32b][ 32b hashpart ptr + 8 ][ 32b arraypart ptr + 8 ]\n' tablearray uses this structure:\n' [H][ 32b len ][ 32b maxlen ][ N * 64b values... ]\n' tablehash uses this structure:\n' [H][ 32b count ][ 32b log2(maxlen) ][ N * [ 64b key ][ 64b value ]... ]\n' upvar uses this structure:\n' [H][ 64b value ]\n' bytecode uses this structure:\n' [H][\n\n\nSuperStrict\n\nImport \"blueerror.bmx\"\nImport \"bluememory.c\"\n\nPrivate\nExtern\n\tFunction PageAlloc:Byte Ptr(size:Int) = \"bluemoon_mmap\"\n\tFunction PageSetRW:Int(p:Byte Ptr, sz:Int) = \"bluemoon_mprotect_rw\"\n\tFunction PageSetRWX:Int(p:Byte Ptr, sz:Int) = \"bluemoon_mprotect_rwx\"\n\tFunction PageSetProtected:Int(p:Byte Ptr, sz:Int) = \"bluemoon_mprotect_none\"\n\tFunction PageFree:Int(p:Byte Ptr, sz:Int) = \"bluemoon_munmap\"\nEnd Extern\nPublic\n\n\nType BlueTypeTag Final\n\tConst NUM:Int = 0, NIL:Int = 1, BOOL:Int = 1 Shl 1, STR:Int = 1 Shl 2, FUN:Int = 1 Shl 3\n\tConst NATFUN:Int = 1 Shl 4, USR:Int = 1 Shl 5, THR:Int = 1 Shl 6, TBL:Int = 1 Shl 7\n\tConst UPV:Int = 1 Shl 8, ARR:Int = 1 Shl 9, HASH:Int = 1 Shl 10, BCODE:Int = 1 Shl 11\n\t\n\tConst NANBOX:Int = Int(2^11 - 1) Shl 20, NANBOX_CHK:Int = NANBOX | (1 Shl 19)\t'test against upper word (and that it's not a genuine NaN)\nEnd Type\n\nType BlueVMMemory Final\n\tConst PAGESZ:Int = 1048576, PAGEBITMAPSZ:Int = 16384, PAGEMETASZ:Int = 256\n\tConst EDENSIZE:Int = 8 * PAGESZ, STACKSZ:Int = 8 * PAGESZ, STACKPROTECT:Int = 4096 * 3, BIGOBJECTSZ:Int = 500000\n\tConst STACKFRAMESZ:Int = 8 * 4, BYTECODESZ:Int = 8 * 4\n\t\t\n\tField gcroots:BlueGCNode, stack:Byte Ptr\n\tField newSpace:Byte Ptr, cpySpace:Byte Ptr, oldPtrSpace:Byte Ptr[], oldStrSpace:Byte Ptr[], bigSpace:Byte Ptr[]\n\tField toFinalize:BlueGCNode, weakTables:BlueGCNode\n\tField codeSpace:Byte Ptr[], returnToNative:Int Ptr\n\tField bytecodes:Byte Ptr[], kstrings:Byte Ptr[]\n\t\n\tField memAlloced:Int\n\tField edenThreshold:Int, sizeThreshold:Int\n\tField newPtr:Int\n\t\n\tFunction AlignedAlloc:Byte Ptr(size:Int, align:Int)\t'abuse mmap\/munmap to get greater-than-4K alignments\n\t\t?Not x86\n\t\tRuntimeError \"The Blue Moon memory system does not support your platform (x86-32 only at this time)\"\n\t\t?\n\t\tLocal mem:Byte Ptr = PageAlloc(size + align)\n\t\tIf Not mem Then Throw BlueInterpretError.Make(\"unable to allocate enough memory for system\")\n\t\t\n\t\t' this is where it starts to get unpleasantly x86-32 specific\n\t\tLocal iMem:Int = Int(mem), offset:Int = iMem Mod align\n\t\tIf offset\n\t\t\tLocal preceding:Int = align - offset\n\t\t\tPageFree(mem, preceding) ; mem :+ preceding\n\t\t\tPageFree(mem + size, offset)\t'so we free the surrounding chunks of mem. that aren't aligned, and keep the middle\n\t\tElse\n\t\t\tPageFree(mem + size, align)\n\t\tEndIf\n\t\t\n\t\tReturn mem\n\tEnd Function\n\t\n\tMethod New()\n\t\tstack = AlignedAlloc(STACKSZ, PAGESZ)\n\t\tPageSetProtected(stack + STACKSZ - STACKPROTECT, STACKPROTECT)\t' add protection to end of stack\n\t\tnewSpace = AlignedAlloc(EDENSIZE, PAGESZ) ; cpySpace = AlignedAlloc(EDENSIZE, PAGESZ)\n\t\tnewPtr = 0\n\t\t\n\t\tAddCodePage() ; returnToNative = Int Ptr(codeSpace[0]) + 1\n\t\tAddPage(oldStrSpace, PAGEMETASZ)\n\t\tAddPage(oldPtrSpace, PAGEBITMAPSZ)\n\tEnd Method\n\tMethod Delete()\n\t\t' unmap a bunch of stuff\n\t\t' free a bunch of other stuff\n\tEnd Method\n\t\n\tMethod Write(slot:Long Ptr, val:Long)\t'write barrier around old\/big-space\n\t\t'implement it here\n\t\tslot[0] = val\n\tEnd Method\n\t\n\tMethod Collect()\n\tEnd Method\n\t\n\tMethod AllocTable:Byte Ptr(meta:Byte Ptr)\n\t\tLocal ret:Byte Ptr = AllocObject(16, BlueTypeTag.TBL)\n\t\tByte Ptr Ptr(ret)[0] = meta\n\t\tInt Ptr(ret)[2] = 0 ; Int Ptr(ret)[3] = 0\n\t\tReturn ret\n\tEnd Method\n\tMethod AllocClosure:Byte Ptr(bc:Byte Ptr, upvars:Int)\t'already aligned\n\t\tLocal ret:Byte Ptr = AllocObject(8 + upvars * 4, BlueTypeTag.FUN)\n\t\tByte Ptr Ptr(ret)[0] = bc\n\t\tReturn ret\n\tEnd Method\n\tMethod AllocString:Byte Ptr(size:Int, charp:Short Ptr)\n\t\tLocal sz:Int = size\n\t\tIf sz Mod 4 Then sz :+ 4 - sz Mod 4\t'align properly\n\t\tLocal ret:Byte Ptr = AllocObject(8 + sz * 2, BlueTypeTag.STR), destp:Short Ptr = Short Ptr(ret + 8), hash:Int = 5381\n\t\tFor Local c:Int = 0 Until size\t'fill the string and compute hash in one go\n\t\t\tdestp[c] = charp[c]\n\t\t\thash = (hash * 33) ~ charp[c]\t'djb2\n\t\tNext\n\t\tInt Ptr(ret)[0] = size ; Int Ptr(ret)[1] = hash\n\t\tReturn ret\n\tEnd Method\n\tMethod AllocUserdata:Byte Ptr(meta:Byte Ptr, val:Byte Ptr)\n\t\tLocal ret:Byte Ptr = AllocObject(8, BlueTypeTag.USR)\n\t\tByte Ptr Ptr(ret)[0] = meta ; Byte Ptr Ptr(ret)[1] = val\n\t\tReturn ret\n\tEnd Method\n\tMethod AllocThread()\n\tEnd Method\n\t\n\tMethod AllocConstant:Byte Ptr(size:Int, charp:Short Ptr)\t'string constants (the only other kind are doubles)\n\t\tLocal hash:Int = 5381\n\t\tFor Local c:Int = 0 Until size\t'do this first so we can check for duplicates easily\n\t\t\thash = (hash * 33) ~ charp[c]\t'djb2\n\t\tNext\n\t\tFor Local k:Int = 0 Until kstrings.Length\n\t\t\tIf hash = Int Ptr(kstrings[k])[3] And size = Int Ptr(kstrings[k])[2]\n\t\t\t\tLocal eq:Int = True\n\t\t\t\tFor Local ch:Int = 0 Until size\n\t\t\t\t\tIf charp[ch] <> Short Ptr(kstrings[k] + 16)[ch] Then eq = False ; Exit\n\t\t\t\tNext\n\t\t\t\tIf eq Then Return kstrings[k] + 8\t'if it already exists, share it\n\t\t\tEndIf\n\t\tNext\n\t\t\n\t\tLocal ret:Byte Ptr = MemAlloc(8 + 8 + size * 2), destp:Short Ptr = Short Ptr(ret + 16)\n\t\t\n\t\tInt Ptr(ret)[0] = (8 + 8 + size * 2) ; Short Ptr(ret + 4)[0] = BlueTypeTag.STR\t'set colour too?\n\t\tInt Ptr(ret)[2] = size ; Int Ptr(ret)[3] = hash\n\t\tFor Local ch:Int = 0 Until size\n\t\t\tdestp[ch] = charp[ch]\n\t\tNext\n\t\t\n\t\tkstrings :+ [ret]\n\t\tReturn ret + 8\n\tEnd Method\n\tMethod AllocBytecode:Byte Ptr(upvars:Int, kcount:Int, icount:Int)\n\t\tLocal ret:Byte Ptr = MemAlloc(4 * BYTECODESZ + 8 * kcount + 8 * icount + 8 * upvars)\t'not here to do malloc's job for it\n\t\tbytecodes :+ [ret]\n\t\tReturn ret\n\tEnd Method\n\t\n\tMethod AddCodePage()\n\t\tcodeSpace = [AlignedAlloc(2 * PAGESZ, PAGESZ)] + codeSpace\n\t\tPageSetRWX(codeSpace[0], PAGESZ)\n\t\tInt Ptr(codeSpace[0])[0] = PAGEMETASZ\n\tEnd Method\n\tMethod AddPage:Byte Ptr(space:Byte Ptr[] Var, init:Int, exec:Int = False)\n\t\tLocal p:Byte Ptr = AlignedAlloc(PAGESZ, PAGESZ)\t'x86: assume this returns zero-initialized result already\n\t\tspace = [p] + space ; Int Ptr(p)[0] = init\n\t\tIf exec Then PageSetRWX(space[0], PAGESZ)\n\t\tReturn p\n\tEnd Method\n'\tMethod HeaderSize:Int(space:Byte Ptr[])\n'\t\tSelect space\n'\t\t\tCase oldPtrSpace ; Return PAGEBITMAPSZ\n'\t\t\tDefault ; Return PAGEMETASZ\n'\t\tEnd Select\n'\tEnd Method\n\t\n\tMethod AllocCodeBlock:Byte Ptr(sz:Int)\t'this returns the requested size, allocating it externally if necessary\n\t\tLocal page:Byte Ptr = codeSpace[0], pNewPtr:Int = Int Ptr(page)[0]\n\t\tIf pNewPtr + sz > PAGESZ\n\t\t\tRuntimeError \"not yet implemented\"\n\t\tElse\n\t\t\tInt Ptr(page)[0] :+ sz\n\t\t\tReturn page + pNewPtr\n\t\tEndIf\n\tEnd Method\n\t\n\tMethod AllocObject:Byte Ptr(sz:Int, tag:Short)\n\t\tsz :+ 8 ; Local ret:Byte Ptr\n\t\tIf sz < BIGOBJECTSZ\n\t\t\tIf newPtr + sz > EDENSIZE Then Collect()\n\t\t\tret = newSpace + newPtr; newPtr :+ sz\n\t\tElse\n\t\t\tret = MemAlloc(sz)\n\t\t\tIf Not ret Then Throw BlueInterpretError.Make(\"unable to allocate memory for object\")\n\t\t\tbigSpace :+ [ret]\n\t\t\t' track as part of allocated memory\n\t\tEndIf\n\t\tInt Ptr(ret)[0] = sz ; Short Ptr(ret + 4)[0] = tag\n\t\tReturn ret + 8\n\tEnd Method\n\t\n\tFunction PtrToVal:Long(p:Byte Ptr, tag:Short)\n\t\tLocal ret:Long, rp:Int Ptr = Int Ptr(Varptr(ret))\n\t\trp[0] = Int(p) ; rp[1] = BlueTypeTag.NANBOX | tag\n\t\tReturn ret\n\tEnd Function\n\tFunction ValToPtr:Byte Ptr(v:Long)\n\t\tLocal vp:Byte Ptr Ptr = Byte Ptr Ptr(Varptr(v))\n\t\tReturn vp[0]\n\tEnd Function\nEnd Type\n\nType BlueGCNode\n\tField pv:BlueGCNode, nx:BlueGCNode, val:Byte Ptr\n\tMethod Remove()\n\t\tIf pv Then pv.nx = nx ; pv = Null\n\t\tIf nx Then nx.pv = pv ; nx = Null\n\tEnd Method\nEnd Type\n\nPrivate\n\nPublic\n\n","old_contents":"\n' Blue Moon\n' Memory allocator\/garbage collector\n' this is a generational three-colour mark\/compact collector\n\n' notes:\n\n' - a basic Lua value is represented as a NaN-box (i.e. a double, unless it's a NaN in which case there's a pointer in the significand)\n\n' - objects are allocated in newSpc, Cheney'd over to cpySpc when it runs out; the Eden spaces are 8MB each\n' - when less than .edenThreshold remains in cpySpc after a scavenge, objects held from oldSpc are promoted\n' - when more than .sizeThreshold has been promoted or less than .edenThreshold still remains, a full GC runs\n' this scan updates usage statistics for each page\n' the \"worst\" N pages are then compacted; if total usage is still poor, mark for another compact after next scavenge\n' the rest of Eden is then promoted\n' - fallback to compacting in one go if usage is catastrophic\/increments aren't keeping up\n' - roots are obtained from the gcroots list, and the stack\n\n' - before compacting\/discarding, the space is scanned for objects with finalizers which are resurrected into newSpc and put on toFinalize\n' - during a FULL collection, weak tables are listed in .weakTables rather than colouring elems, then weakscanned before compaction\n\n' - the stack is an 8M block with the last page protected\n' - stack frames use this format:\n' [ ret ip ][ prev base ][[ 16b frame sz ][ 16b var ofs ]][ func obj ][ ip ][ argv ][ retv ][[ 16b argc ][ 16b retc ]][ upv0 | upv1 | ... ][ v0 | v1 | ... ][ tmp... ]\n' the upvar slots, var slots, and temp slots beyond are all 64-bit NaN-boxes\n' the preceding slots are 32-bit words except otherwise shown\n\n' - pages in oldPtrSpc use this format:\n' [[[ 0..256 metadata ] ..16K dirty bitmap ] ..1M allocated objects ]\n' each 64-byte potential NaN-box in the object-space has a corresponding dirty bit that is set if it points to newSpc\n' a metamap in the metadata in turn marks dirty sectors of the bitmap, for reduced scanning\n' metadata also contains allocation pointer and used space total\n\n' - codeSpace stores executable instruction buffers for Lua functions (bytecode is allocated directly into oldStrSpc)\n\n' - bigSpc is a simple list of conventionally-allocated objects that don't fit on a 1M page\n\n' - objects use this layout:\n' [ 64b header: [ 32b size ][ 16b type tag ][ 8b colour ][ 1b hasFinalizer ][ 2b weak keys, values ] ][ N * 64b data area... ]\n' size includes header. for moved objects the second 32b are replaced by a forwarding pointer\n' pointers in general are to the data area, skipping header\n\n' - data types are: nil, boolean, number, string, closure, natfun, userdata, thread, table ; upvar, tablearray, tablehash, bytecode\n' nil\/boolean\/number\/natfun are value types and need no allocation\n' string uses this structure:\n' [H][ 32b length ][ 32b hash ][ ceil(length\/4) * 64b chars... ]\n' closure uses this structure:\n' [H][ 32b bytecode ptr ][32b][ N * 32b upvar ptrs... ] (N rounded up to 2 for alignment)\n' userdata uses this structure:\n' [H][ 32b metatable ][ 32b value ]\n' thread uses this structure:\n' [H][\n' table uses this structure:\n' [H][ 32b metatable ][32b][ 32b hashpart ptr + 8 ][ 32b arraypart ptr + 8 ]\n' tablearray uses this structure:\n' [H][ 32b len ][ 32b maxlen ][ N * 64b values... ]\n' tablehash uses this structure:\n' [H][ 32b count ][ 32b log2(maxlen) ][ N * [ 64b key ][ 64b value ]... ]\n' upvar uses this structure:\n' [H][ 64b value ]\n' bytecode uses this structure:\n' [H][\n\n\nSuperStrict\n\nImport \"blueerror.bmx\"\nImport \"bluememory.c\"\n\nPrivate\nExtern\n\tFunction PageAlloc:Byte Ptr(size:Int) = \"bluemoon_mmap\"\n\tFunction PageSetRW:Int(p:Byte Ptr, sz:Int) = \"bluemoon_mprotect_rw\"\n\tFunction PageSetRWX:Int(p:Byte Ptr, sz:Int) = \"bluemoon_mprotect_rwx\"\n\tFunction PageSetProtected:Int(p:Byte Ptr, sz:Int) = \"bluemoon_mprotect_none\"\n\tFunction PageFree:Int(p:Byte Ptr, sz:Int) = \"bluemoon_munmap\"\nEnd Extern\nPublic\n\n\nType BlueTypeTag Final\n\tConst NUM:Int = 0, NIL:Int = 1, BOOL:Int = 1 Shl 1, STR:Int = 1 Shl 2, FUN:Int = 1 Shl 3\n\tConst NATFUN:Int = 1 Shl 4, USR:Int = 1 Shl 5, THR:Int = 1 Shl 6, TBL:Int = 1 Shl 7\n\tConst UPV:Int = 1 Shl 8, ARR:Int = 1 Shl 9, HASH:Int = 1 Shl 10, BCODE:Int = 1 Shl 11\n\t\n\tConst NANBOX:Int = Int(2^11 - 1) Shl 20, NANBOX_CHK:Int = NANBOX | (1 Shl 19)\t'test against upper word (and that it's not a genuine NaN)\nEnd Type\n\nType BlueVMMemory Final\n\tConst PAGESZ:Int = 1048576, PAGEBITMAPSZ:Int = 16384, PAGEMETASZ:Int = 256\n\tConst EDENSIZE:Int = 8 * PAGESZ, STACKSZ:Int = 8 * PAGESZ, BIGOBJECTSZ:Int = 500000\n\tConst STACKFRAMESZ:Int = 8 * 4, BYTECODESZ:Int = 8 * 4\n\t\t\n\tField gcroots:BlueGCNode, stack:Byte Ptr\n\tField newSpace:Byte Ptr, cpySpace:Byte Ptr, oldPtrSpace:Byte Ptr[], oldStrSpace:Byte Ptr[], bigSpace:Byte Ptr[]\n\tField toFinalize:BlueGCNode, weakTables:BlueGCNode\n\tField codeSpace:Byte Ptr[], returnToNative:Int Ptr\n\tField bytecodes:Byte Ptr[], kstrings:Byte Ptr[]\n\t\n\tField memAlloced:Int\n\tField edenThreshold:Int, sizeThreshold:Int\n\tField newPtr:Int\n\t\n\tFunction AlignedAlloc:Byte Ptr(size:Int, align:Int)\t'abuse mmap\/munmap to get greater-than-4K alignments\n\t\t?Not x86\n\t\tRuntimeError \"The Blue Moon memory system does not support your platform (x86-32 only at this time)\"\n\t\t?\n\t\tLocal mem:Byte Ptr = PageAlloc(size + align)\n\t\tIf Not mem Then Throw BlueInterpretError.Make(\"unable to allocate enough memory for system\")\n\t\t\n\t\t' this is where it starts to get unpleasantly x86-32 specific\n\t\tLocal iMem:Int = Int(mem), offset:Int = iMem Mod align\n\t\tIf offset\n\t\t\tLocal preceding:Int = align - offset\n\t\t\tPageFree(mem, preceding) ; mem :+ preceding\n\t\t\tPageFree(mem + size, offset)\t'so we free the surrounding chunks of mem. that aren't aligned, and keep the middle\n\t\tElse\n\t\t\tPageFree(mem + size, align)\n\t\tEndIf\n\t\t\n\t\tReturn mem\n\tEnd Function\n\t\n\tMethod New()\n\t\tstack = AlignedAlloc(STACKSZ, PAGESZ)\n\t\t' add protection to end of stack\n\t\tnewSpace = AlignedAlloc(EDENSIZE, PAGESZ) ; cpySpace = AlignedAlloc(EDENSIZE, PAGESZ)\n\t\tnewPtr = 0\n\t\t\n\t\tAddCodePage() ; returnToNative = Int Ptr(codeSpace[0]) + 1\n\t\tAddPage(oldStrSpace, PAGEMETASZ)\n\t\tAddPage(oldPtrSpace, PAGEBITMAPSZ)\n\tEnd Method\n\tMethod Delete()\n\t\t' unmap a bunch of stuff\n\t\t' free a bunch of other stuff\n\tEnd Method\n\t\n\tMethod Write(slot:Long Ptr, val:Long)\t'write barrier around old\/big-space\n\t\t'implement it here\n\t\tslot[0] = val\n\tEnd Method\n\t\n\tMethod Collect()\n\tEnd Method\n\t\n\tMethod AllocTable:Byte Ptr(meta:Byte Ptr)\n\t\tLocal ret:Byte Ptr = AllocObject(16, BlueTypeTag.TBL)\n\t\tByte Ptr Ptr(ret)[0] = meta\n\t\tInt Ptr(ret)[2] = 0 ; Int Ptr(ret)[3] = 0\n\t\tReturn ret\n\tEnd Method\n\tMethod AllocClosure:Byte Ptr(bc:Byte Ptr, upvars:Int)\t'already aligned\n\t\tLocal ret:Byte Ptr = AllocObject(8 + upvars * 4, BlueTypeTag.FUN)\n\t\tByte Ptr Ptr(ret)[0] = bc\n\t\tReturn ret\n\tEnd Method\n\tMethod AllocString:Byte Ptr(size:Int, charp:Short Ptr)\n\t\tLocal sz:Int = size\n\t\tIf sz Mod 4 Then sz :+ 4 - sz Mod 4\t'align properly\n\t\tLocal ret:Byte Ptr = AllocObject(8 + sz * 2, BlueTypeTag.STR), destp:Short Ptr = Short Ptr(ret + 8), hash:Int = 5381\n\t\tFor Local c:Int = 0 Until size\t'fill the string and compute hash in one go\n\t\t\tdestp[c] = charp[c]\n\t\t\thash = (hash * 33) ~ charp[c]\t'djb2\n\t\tNext\n\t\tInt Ptr(ret)[0] = size ; Int Ptr(ret)[1] = hash\n\t\tReturn ret\n\tEnd Method\n\tMethod AllocUserdata:Byte Ptr(meta:Byte Ptr, val:Byte Ptr)\n\t\tLocal ret:Byte Ptr = AllocObject(8, BlueTypeTag.USR)\n\t\tByte Ptr Ptr(ret)[0] = meta ; Byte Ptr Ptr(ret)[1] = val\n\t\tReturn ret\n\tEnd Method\n\tMethod AllocThread()\n\tEnd Method\n\t\n\tMethod AllocConstant:Byte Ptr(size:Int, charp:Short Ptr)\t'string constants (the only other kind are doubles)\n\t\tLocal hash:Int = 5381\n\t\tFor Local c:Int = 0 Until size\t'do this first so we can check for duplicates easily\n\t\t\thash = (hash * 33) ~ charp[c]\t'djb2\n\t\tNext\n\t\tFor Local k:Int = 0 Until kstrings.Length\n\t\t\tIf hash = Int Ptr(kstrings[k])[3] And size = Int Ptr(kstrings[k])[2]\n\t\t\t\tLocal eq:Int = True\n\t\t\t\tFor Local ch:Int = 0 Until size\n\t\t\t\t\tIf charp[ch] <> Short Ptr(kstrings[k] + 16)[ch] Then eq = False ; Exit\n\t\t\t\tNext\n\t\t\t\tIf eq Then Return kstrings[k] + 8\t'if it already exists, share it\n\t\t\tEndIf\n\t\tNext\n\t\t\n\t\tLocal ret:Byte Ptr = MemAlloc(8 + 8 + size * 2), destp:Short Ptr = Short Ptr(ret + 16)\n\t\t\n\t\tInt Ptr(ret)[0] = (8 + 8 + size * 2) ; Short Ptr(ret + 4)[0] = BlueTypeTag.STR\t'set colour too?\n\t\tInt Ptr(ret)[2] = size ; Int Ptr(ret)[3] = hash\n\t\tFor Local ch:Int = 0 Until size\n\t\t\tdestp[ch] = charp[ch]\n\t\tNext\n\t\t\n\t\tkstrings :+ [ret]\n\t\tReturn ret + 8\n\tEnd Method\n\tMethod AllocBytecode:Byte Ptr(upvars:Int, kcount:Int, icount:Int)\n\t\tLocal ret:Byte Ptr = MemAlloc(4 * BYTECODESZ + 8 * kcount + 8 * icount + 8 * upvars)\t'not here to do malloc's job for it\n\t\tbytecodes :+ [ret]\n\t\tReturn ret\n\tEnd Method\n\t\n\tMethod AddCodePage()\n\t\tcodeSpace = [AlignedAlloc(2 * PAGESZ, PAGESZ)] + codeSpace\n\t\tPageSetRWX(codeSpace[0], PAGESZ)\n\t\tInt Ptr(codeSpace[0])[0] = PAGEMETASZ\n\tEnd Method\n\tMethod AddPage:Byte Ptr(space:Byte Ptr[] Var, init:Int, exec:Int = False)\n\t\tLocal p:Byte Ptr = AlignedAlloc(PAGESZ, PAGESZ)\t'x86: assume this returns zero-initialized result already\n\t\tspace = [p] + space ; Int Ptr(p)[0] = init\n\t\tIf exec Then PageSetRWX(space[0], PAGESZ)\n\t\tReturn p\n\tEnd Method\n'\tMethod HeaderSize:Int(space:Byte Ptr[])\n'\t\tSelect space\n'\t\t\tCase oldPtrSpace ; Return PAGEBITMAPSZ\n'\t\t\tDefault ; Return PAGEMETASZ\n'\t\tEnd Select\n'\tEnd Method\n\t\n\tMethod AllocCodeBlock:Byte Ptr(sz:Int)\t'this returns the requested size, allocating it externally if necessary\n\t\tLocal page:Byte Ptr = codeSpace[0], pNewPtr:Int = Int Ptr(page)[0]\n\t\tIf pNewPtr + sz > PAGESZ\n\t\t\tRuntimeError \"not yet implemented\"\n\t\tElse\n\t\t\tInt Ptr(page)[0] :+ sz\n\t\t\tReturn page + pNewPtr\n\t\tEndIf\n\tEnd Method\n\t\n\tMethod AllocObject:Byte Ptr(sz:Int, tag:Short)\n\t\tsz :+ 8 ; Local ret:Byte Ptr\n\t\tIf sz < BIGOBJECTSZ\n\t\t\tIf newPtr + sz > EDENSIZE Then Collect()\n\t\t\tret = newSpace + newPtr; newPtr :+ sz\n\t\tElse\n\t\t\tret = MemAlloc(sz)\n\t\t\tIf Not ret Then Throw BlueInterpretError.Make(\"unable to allocate memory for object\")\n\t\t\tbigSpace :+ [ret]\n\t\t\t' track as part of allocated memory\n\t\tEndIf\n\t\tInt Ptr(ret)[0] = sz ; Short Ptr(ret + 4)[0] = tag\n\t\tReturn ret + 8\n\tEnd Method\n\t\n\tFunction PtrToVal:Long(p:Byte Ptr, tag:Short)\n\t\tLocal ret:Long, rp:Int Ptr = Int Ptr(Varptr(ret))\n\t\trp[0] = Int(p) ; rp[1] = BlueTypeTag.NANBOX | tag\n\t\tReturn ret\n\tEnd Function\n\tFunction ValToPtr:Byte Ptr(v:Long)\n\t\tLocal vp:Byte Ptr Ptr = Byte Ptr Ptr(Varptr(v))\n\t\tReturn vp[0]\n\tEnd Function\nEnd Type\n\nType BlueGCNode\n\tField pv:BlueGCNode, nx:BlueGCNode, val:Byte Ptr\n\tMethod Remove()\n\t\tIf pv Then pv.nx = nx ; pv = Null\n\t\tIf nx Then nx.pv = pv ; nx = Null\n\tEnd Method\nEnd Type\n\nPrivate\n\nPublic\n\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"6958ffd5515a3f8805ee3301074dca66d4ef46a1","subject":"Removed intersection code.","message":"Removed intersection code.\n","repos":"kfprimm\/maxb3d,kfprimm\/maxb3d","old_file":"core.mod\/entity.bmx","new_file":"core.mod\/entity.bmx","new_contents":"\nStrict\n\nImport BRL.LinkedList\nImport MaxB3D.Math\nImport \"brush.bmx\"\nImport \"collision.bmx\"\nImport \"worldconfig.bmx\"\n\nConst PICKMODE_OFF\t\t\t= 0\nConst PICKMODE_SPHERE\t\t= 1\nConst PICKMODE_POLYGON\t= 2\nConst PICKMODE_BOX\t\t\t= 3\n\nType TEntity\n\tField _config:TWorldConfig\n\tField _matrix:TMatrix=TMatrix.Identity(), _lockmatrix\n\t\n\tField _name$\n\tField _px#,_py#,_pz#\n\tField _rx#,_ry#,_rz#\n\tField _sx#,_sy#,_sz#\n\t\t\n\tField _brush:TBrush=New TBrush\n\t\n\tField _parent:TEntity,_childlist:TList=CreateList()\n\tField _hidden,_order\n\t\n\tField _collision:TCollision[]\n\tField _oldx#,_oldy#,_oldz#\n\tField _radiusx#,_radiusy#\n\tField _boxx#,_boxy#,_boxz#,_boxwidth#,_boxheight#,_boxdepth#\n\tField _type,_typelink:TLink\n\tField _pickmode, _obscurer\n\t\n\tField _cullradius#\n\t\n\tField _alphaorder#\n\t\n\tField _linklist:TList=CreateList()\n\t\n\tMethod Init:TEntity(config:TWorldConfig,parent:TEntity)\n\t\t_config = config\n\t\tSetParent parent,False\n\t\tFor Local l=EachIn Lists()\n\t\t\tAddLink _config.AddObject(Self,l)\n\t\tNext\n\t\t\n\t\tSetScale 1,1,1\n\t\t\n\t\tReturn Self\n\tEnd Method\n\t\n\tMethod Free()\n\t\tFor Local child:TEntity=EachIn _childlist\n\t\t\tchild.Free()\n\t\tNext\n\t\tFor Local link:TLink=EachIn _linklist\n\t\t\tRemoveLink link\n\t\tNext\n\tEnd Method\n\t\n\tMethod AddLink(link:TLink)\n\t\t_linklist.AddLast link\n\tEnd Method\n\t\n\tMethod Lists[]()\n\t\tReturn [WORLDLIST_ENTITY]\n\tEnd Method\n\t\n\tMethod CopyData:TEntity(entity:TEntity)\n\t\t_config = entity._config\n\t\tLocal pickmode, obscurer\n\t\tentity.GetPickMode pickmode,obscurer\n\t\t\n\t\tSetBrush entity.GetBrush()\n\t\tSetName entity.GetName()\n\t\tSetPickMode pickmode, obscurer\n\t\tSetType entity.GetType()\n\t\tReturn Self\n\tEnd Method\n\t\n\tMethod Copy_:TEntity(parent:TEntity=Null)\n\t\tReturn New Self.CopyData(Self).Init(_config,parent)\n\tEnd Method\n\t\n\tMethod Copy:TEntity(parent:TEntity=Null) Abstract\n\t\n\tMethod AddParent(parent:TEntity)\n\t\t_parent=parent\n\t\tIf parent\n\t\t\t_matrix.Overwrite parent._matrix\n\t\t\tparent._childlist.AddLast Self\n\t\tEndIf\n\tEnd Method\n\t\n\tMethod GetParent:TEntity()\n\t\tReturn _parent\n\tEnd Method\n\tMethod SetParent(parent:TEntity,glob=True)\n\t\tLocal gpx#,gpy#,gpz#\t\t\n\t\tLocal grx#,gry#,grz#\t\t\n\t\tLocal gsx#,gsy#,gsz#\n\t\t\n\t\tGetPosition gpx,gpy,gpz,True\n\t\tGetRotation grx,gry,grz,True\n\t\tGetScale gsx,gsy,gsz,True\n\t\t\n\t\tIf _parent\n\t\t\tFor Local entity:TEntity=EachIn _parent._childlist\n\t\t\t\tIf entity=Self ListRemove(_parent._childlist,Self)\n\t\t\tNext\n\t\t\t_parent=Null\n\t\tEndIf\n\n\t\t_px=gpx;_py=gpy;_pz=gpz\n\t\t_rx=grx;_ry=gry;_rz=grz\n\t\t_sx=gsx;_sy=gsy;_sz=gsz\n\t\t\n\t\tIf parent=Null UpdateMatrix(True);Return\t\t\n\t\t\n\t\tAddParent(parent)\n\t\tIf glob\t\t\t\t\n\t\t\tSetPosition(gpx,gpy,gpz,True)\n\t\t\tSetRotation(grx,gry,grz,True)\n\t\t\tSetScale(gsx,gsy,gsz,True)\n\t\tElse\t\t\t\n\t\t\tUpdateMatrix(False)\t\t\t\t\n\t\tEndIf\t\t\t\n\tEnd Method\n\t\n\tMethod CountChildren(recursive=False)\n\t\tLocal count\n\t\tIf recursive\n\t\t\tFor Local child:TEntity=EachIn _childlist\n\t\t\t\tcount:+child.CountChildren(True)\n\t\t\tNext\n\t\tEndIf\n\t\tReturn _childlist.Count()+count\n\tEnd Method\n\t\n\tMethod FindChild:TEntity(name$,recursive=False)\n\t\tFor Local child:TEntity=EachIn _childlist\n\t\t\tIf child.GetName()=name Return child\n\t\tNext\n\t\tIf recursive\n\t\t\tFor Local child:TEntity=EachIn _childlist\n\t\t\t\tLocal entity:TEntity = child.FindChild(name, True)\n\t\t\t\tIf entity Return entity\n\t\t\tNext\n\t\tEndIf\n\tEnd Method\n\t\n\tMethod GetName$()\n\t\tReturn _name\n\tEnd Method\n\tMethod SetName(name$)\n\t\t_name=name\n\tEnd Method\n\t\n\tMethod GetBrush:TBrush()\n\t\tReturn _brush.Copy()\n\tEnd Method\n\tMethod SetBrush(brush:TBrush)\n\t\t_brush.Load brush\n\tEnd Method\n\t\n\tMethod GetColor(red Var,green Var,blue Var)\n\t\tReturn _brush.GetColor(red,green,blue)\n\tEnd Method\n\tMethod SetColor(red,green,blue)\n\t\tReturn _brush.SetColor(red,green,blue)\n\tEnd Method\n\t\n\tMethod GetAlpha#()\n\t\tReturn _brush.GetAlpha()\n\tEnd Method\n\tMethod SetAlpha(alpha#)\n\t\t_brush.SetAlpha(alpha)\n\tEnd Method\n\t\n\tMethod GetShine#()\n\t\tReturn _brush.GetShine()\n\tEnd Method\n\tMethod SetShine(shine#)\n\t\t_brush.SetShine(shine)\n\tEnd Method\n\t\n\tMethod GetTexture:TTexture(index)\n\t\tReturn _brush.GetTexture(index)\n\tEnd Method\n\tMethod SetTexture(texture:TTexture,index=0,frame=0)\n\t\tReturn _brush.SetTexture(texture,index,frame)\n\tEnd Method\n\t\n\tMethod GetFX()\n\t\tReturn _brush.GetFX()\n\tEnd Method\n\tMethod SetFX(fx)\n\t\tReturn _brush.SetFX(fx)\n\tEnd Method\n\t\n\tMethod GetBlend()\n\t\tReturn _brush.GetBlend()\n\tEnd Method\n\tMethod SetBlend(blend)\n\t\tReturn _brush.SetBlend(blend)\n\tEnd Method\n\t\n\tMethod GetShader:TShader()\n\t\tReturn _brush.GetShader()\n\tEnd Method\n\tMethod SetShader(shader:TShader)\n\t\tReturn _brush.SetShader(shader)\n\tEnd Method\n\t\n\tMethod GetScale(x# Var,y# Var,z# Var,glob=False)\n\t\tIf glob\n\t\t\tx=_matrix._m[0,0]\n\t\t\ty=_matrix._m[1,1]\n\t\t\tz=_matrix._m[2,2]\n\t\tElse\n\t\t\tx=_sx;y=_sy;z=_sz\n\t\tEndIf\n\tEnd Method\n\tMethod SetScale(x#,y#,z#,glob=False)\n\t\t_sx=x;_sy=y;_sz=z\n\t\tIf glob=True And _parent<>Null\n\t\t\tLocal entity:TEntity=Self\n\t\t\tRepeat\n\t\t\t\t_sx:\/entity._parent._sx\n\t\t\t\t_sy:\/entity._parent._sy\n\t\t\t\t_sz:\/entity._parent._sz\n\t\t\t\tentity=entity._parent\n\t\t\tUntil entity._parent=Null\n\t\tEndIf\n\t\tRefreshMatrix()\t\n\tEnd Method\n\t\n\tMethod Transform(matrix:TMatrix,glob=False)\n\t\tSetMatrix matrix.Multiply(_matrix),glob\n\tEnd Method\n\t\n\tMethod Turn(pitch#,yaw#,roll#,glob=False)\n\t\t_rx:+pitch;_ry:+yaw;_rz:+roll\n\t\tRefreshMatrix()\n\tEnd Method\n\t\n\tMethod Point(target:Object,roll#=0.0)\n\t\tLocal x#,y#,z#,tx#,ty#,tz#\n\t\tGetPosition x,y,z,True\n\t\tGetTargetPosition target,tx,ty,tz \n\n\t\tLocal xdiff#=x-tx,ydiff#=y-ty,zdiff#=z-tz\n\n\t\tLocal dist22#=Sqr((xdiff*xdiff)+(zdiff*zdiff))\n\t\tLocal pitch#=ATan2(ydiff,dist22)\n\t\tLocal yaw#=ATan2(xdiff,-zdiff)\n\n\t\tSetRotation pitch,yaw,roll,True\n\tEnd Method\n\t\n\tMethod GetDistance#(target:Object)\n\t\tLocal x#,y#,z#,tx#,ty#,tz#\n\t\tGetPosition x,y,z,True\n\t\tGetTargetPosition target,tx,ty,tz\t\t\n\t\tReturn Sqr((x-tx)*(x-tx)+(y-ty)*(y-ty)+(z-tz)*(z-tz))\n\tEnd Method\n\t\n\tFunction GetTargetPosition(target:Object,x# Var,y# Var,z# Var)\n\t\tAssert target,\"Null target given.\"\n\t\tIf TEntity(target) TEntity(target).GetPosition x,y,z,True\n\t\tIf Float[](target)\n\t\t\tLocal coords#[]=Float[](target)\n\t\t\tIf coords.length>0 x=coords[0]\n\t\t\tIf coords.length>1 y=coords[1]\n\t\t\tIf coords.length>2 z=coords[2]\n\t\tEndIf\n\t\tAssert \"Invalid target given.\"\n\tEnd Function\t\n\t\n\tMethod GetRotation(pitch# Var,yaw# Var,roll# Var,glob=False)\n\t\tIf glob\n\t\t\t_matrix.GetRotation pitch,yaw,roll\n\t\t\tpitch:*-1\n\t\t\tyaw:*-1\n\t\tElse\n\t\t\tpitch=_rx;yaw=_ry;roll=_rz\n\t\tEndIf\n\tEnd Method\n\tMethod SetRotation(pitch#,yaw#,roll#,glob=False)\n\t\t_rx=pitch;_ry=yaw;_rz=roll\n\t\tIf glob And _parent<>Null\n\t\t\tLocal rx#,ry#,rz#\n\t\t\t_parent.GetRotation rx,ry,rz\n\t\t\t_rx:+rx;_ry:+ry;_rz:+rz\t\t\t\n\t\tEndIf\n\t\tRefreshMatrix()\n\tEnd Method\n\t\t\n\tMethod GetPosition(x# Var,y# Var,z# Var,glob=False)\n\t\tx=_px;y=_py;z=_pz\n\t\tIf glob _matrix.GetPosition x,y,z\n\tEnd Method\n\tMethod SetPosition(x#,y#,z#,glob=False)\n\t\t_px=x;_py=y;_pz=z\n\t\t\n\t\tIf glob And _parent<>Null\n\t\t\tLocal px#,py#,pz#\n\t\t\t_parent.GetPosition px,py,pz,True\n\t\t\t_px:-px;_py:-py;_pz:-pz\n\t\tEndIf\n\t\t\n\t\tRefreshMatrix()\n\tEnd Method\n\t\n\tMethod Move(x#,y#,z#)\n\t\tLocal matrix:TMatrix=TMatrix.Identity()\n\t\tmatrix=TMatrix.YawPitchRoll(-_ry,-_rx,_rz).Multiply(matrix)\n\t\tmatrix=TMatrix.Translation(x,y,z).Multiply(matrix)\n\t\n\t\tmatrix.GetPosition(x,y,z)\t\t\n\t\t_px:+x;_py:+y;_pz:+z\n\n\t\tRefreshMatrix()\n\tEnd Method\n\t\n\tMethod Translate(x#,y#,z#,glob=True)\n\t\tIf glob And _parent\t\t\t\n\t\t\tLocal ax#,ay#,az#\n\t\t\tGetRotation ax,ay,az,True\n\t\t\t\t\t\t\n\t\t\tLocal matrix:TMatrix=TMatrix.Roll(-az)\n\t\t\tmatrix=matrix.Multiply(TMatrix.Pitch(-ax))\n\t\t\tmatrix=matrix.Multiply(TMatrix.Yaw(-ay))\n\t\t\tmatrix=matrix.Multiply(TMatrix.Translation(x,y,z))\n\t\t\t\n\t\t\tmatrix.GetPosition x,y,z\n\t\tEndIf\n\t\t\n\t\t_px:+x;_py:+y;_pz:+z\n\n\t\tRefreshMatrix()\n\tEnd Method\n\t\n\tMethod GetVisible()\n\t\tLocal entity:TEntity=Self\n\t\tWhile entity<>Null\n\t\t\tIf entity._hidden=True Return False\n\t\t\tentity=entity._parent\n\t\tWend\n\t\tReturn True\n\tEnd Method\n\tMethod SetVisible(visible)\n\t\t_hidden=Not visible\n\tEnd Method\n\t\n\tMethod GetOrder()\n\t\tReturn _order\n\tEnd Method\n\tMethod SetOrder(order)\n\t\t_order=order\n\tEnd Method\n\t\n\tMethod GetCollisions:TCollision[]()\n\t\tReturn _collision\n\tEnd Method\n\t\n\tMethod GetRadius(x# Var,y# Var)\n\t\tx=_radiusx;y=_radiusy\n\tEnd Method\n\tMethod SetRadius(x#,y#=-1)\n\t\t_radiusx=x;_radiusy=x\n\t\tIf y>-1 _radiusy=y\n\tEnd Method\n\t\n\tMethod GetBox(x# Var,y# Var,z# Var,width# Var,height# Var,depth# Var)\n\t\tx=_boxx;y=_boxy;z=_boxz\n\t\twidth=_boxwidth;height=_boxheight;depth=_boxdepth\n\tEnd Method\n\tMethod SetBox(x#,y#,z#,width#,height#,depth#)\n\t\t_boxx=x;_boxy=y;_boxz=z\n\t\t_boxwidth=width;_boxheight=height;_boxdepth=depth\n\tEnd Method\n\t\n\tMethod Reset()\n\t\t_collision=Null\n\t\tGetPosition _oldx,_oldy,_oldz,True\n\tEnd Method\n\t\n\tMethod GetType()\n\t\tReturn _type\n\tEnd Method\n\tMethod SetType(typ,recursive=False)\n\t\tIf _typelink\n\t\t\t_linklist.Remove(_typelink)\n\t\t\t_typelink.Remove()\n\t\t\t_typelink=Null\n\t\tEndIf\n\t\t\n\t\tIf typ>0\n\t\t\tIf _config.CollisionType[typ]=Null _config.CollisionType[typ]=CreateList()\n\t\t\t_typelink=_config.CollisionType[typ].AddLast(Self)\n\t\t\tAddLink _typelink\n\t\tEndIf\t\t\n\t\t\n\t\t_type=typ\n\t\tGetPosition _oldx,_oldy,_oldz,True\n\t\t\n\t\tIf recursive\n\t\t\tFor Local child:TEntity=EachIn _childlist\n\t\t\t\tchild.SetType typ,True\n\t\t\tNext\n\t\tEndIf\n\tEnd Method\n\t\n\tMethod GetCullRadius#()\n\t\tReturn Abs(_cullradius)\n\tEnd Method\n\tMethod SetCullRadius(radius#)\n\t\t_cullradius=-radius\n\tEnd Method\n\n\tMethod GetCullParams(x# Var,y# Var,z# Var,radius# Var)\n\t\tGetPosition x,y,z,True\n\t\tradius=GetCullRadius()\n\tEnd Method\n\t\t\n\tMethod GetPickMode(mode Var, obscurer Var)\n\t\tmode = _pickmode\n\t\tobscurer = _obscurer\n\tEnd Method\t\n\tMethod SetPickMode(mode, obscurer=True)\n\t\t_pickmode = mode\n\t\t_obscurer = obscurer\n\tEnd Method\n\t\n\tMethod HasAlpha()\n\t\tReturn _brush.HasAlpha()\n\tEnd Method\n\t\n\tMethod GetMatrix:TMatrix(alternate=False,copy=True)\n\t\tIf copy Return _matrix.Copy()\n\t\tReturn _matrix\n\tEnd Method\n\tMethod SetMatrix(matrix:TMatrix,glob=True)\n\t\tLocal x#,y#,z#,pitch#,yaw#,roll#,sx#,sy#,sz#\n\t\tmatrix.GetPosition x,y,z\n\t\tmatrix.GetRotation pitch,yaw,roll\n\t\tmatrix.GetScale sx,sy,sz\n\t\t\n\t\tLockMatrix\n\t\tSetPosition x,y,z,glob\n\t\tSetRotation pitch,yaw,roll,glob\n\t\tSetScale sx,sy,sz,glob\n\t\tUnlockMatrix\n\tEnd Method\n\t\n\tMethod LockMatrix()\n\t\t_lockmatrix=True\n\tEnd Method\n\tMethod UnlockMatrix()\n\t\t_lockmatrix=False\n\t\tRefreshMatrix()\n\tEnd Method\n\t\n\tMethod RefreshMatrix()\n\t\tIf _lockmatrix Return\n\t\tIf _parent<>Null\n\t\t\t_matrix.Overwrite _parent._matrix\n\t\t\tUpdateMatrix False\n\t\tElse\n\t\t\tUpdateMatrix True\n\t\tEndIf\t\t\n\t\t\n\t\tFor Local child:TEntity=EachIn _childlist\n\t\t\tchild.RefreshMatrix()\n\t\tNext\n\tEnd Method\n\t\n\tMethod UpdateMatrix(loadidentity)\n\t\tIf loadidentity _matrix=TMatrix.Identity()\n\t\t_matrix=TMatrix.Translation(_px,_py,_pz).Multiply(_matrix)\n\t\t_matrix=TMatrix.YawPitchRoll(-_ry,-_rx,_rz).Multiply(_matrix)\n\t\t_matrix=TMatrix.Scale(_sx,_sy,_sz).Multiply(_matrix)\n\tEnd Method\n\t\n\tMethod ObjectEnumerator:Object()\n\t\tReturn TChildrenEnumerator.Create(_childlist)\n\tEnd Method\nEnd Type\n\nType TChildrenEnumerator\n\tField _children:TEntity[],_index=-1\n\t\n\tFunction Create:TChildrenEnumerator(list:TList)\n\t\tLocal enum:TChildrenEnumerator=New TChildrenEnumerator\n\t\tenum._children=TEntity[](list.ToArray())\n\t\tReturn enum\n\tEnd Function\n\t\n\tMethod HasNext()\n\t\tReturn _index>=_children.length-1\n\tEnd Method\n\t\n\tMethod NextObject:Object()\n\t\t_index:+1\n\t\tReturn _children[_index]\n\tEnd Method\nEnd Type\n","old_contents":"\nStrict\n\nImport BRL.LinkedList\nImport MaxB3D.Math\nImport \"brush.bmx\"\nImport \"collision.bmx\"\nImport \"worldconfig.bmx\"\n\nConst PICKMODE_OFF\t\t\t= 0\nConst PICKMODE_SPHERE\t\t= 1\nConst PICKMODE_POLYGON\t= 2\nConst PICKMODE_BOX\t\t\t= 3\n\nType TEntity\n\tField _config:TWorldConfig\n\tField _matrix:TMatrix=TMatrix.Identity(), _lockmatrix\n\t\n\tField _name$\n\tField _px#,_py#,_pz#\n\tField _rx#,_ry#,_rz#\n\tField _sx#,_sy#,_sz#\n\t\t\n\tField _brush:TBrush=New TBrush\n\t\n\tField _parent:TEntity,_childlist:TList=CreateList()\n\tField _hidden,_order\n\t\n\tField _collision:TCollision[]\n\tField _oldx#,_oldy#,_oldz#\n\tField _radiusx#,_radiusy#\n\tField _boxx#,_boxy#,_boxz#,_boxwidth#,_boxheight#,_boxdepth#\n\tField _type,_typelink:TLink\n\tField _pickmode, _obscurer\n\t\n\tField _cullradius#\n\t\n\tField _alphaorder#\n\t\n\tField _linklist:TList=CreateList()\n\t\n\tMethod Init:TEntity(config:TWorldConfig,parent:TEntity)\n\t\t_config = config\n\t\tSetParent parent,False\n\t\tFor Local l=EachIn Lists()\n\t\t\tAddLink _config.AddObject(Self,l)\n\t\tNext\n\t\t\n\t\tSetScale 1,1,1\n\t\t\n\t\tReturn Self\n\tEnd Method\n\t\n\tMethod Free()\n\t\tFor Local child:TEntity=EachIn _childlist\n\t\t\tchild.Free()\n\t\tNext\n\t\tFor Local link:TLink=EachIn _linklist\n\t\t\tRemoveLink link\n\t\tNext\n\tEnd Method\n\t\n\tMethod AddLink(link:TLink)\n\t\t_linklist.AddLast link\n\tEnd Method\n\t\n\tMethod Lists[]()\n\t\tReturn [WORLDLIST_ENTITY]\n\tEnd Method\n\t\n\tMethod CopyData:TEntity(entity:TEntity)\n\t\t_config = entity._config\n\t\tLocal pickmode, obscurer\n\t\tentity.GetPickMode pickmode,obscurer\n\t\t\n\t\tSetBrush entity.GetBrush()\n\t\tSetName entity.GetName()\n\t\tSetPickMode pickmode, obscurer\n\t\tSetType entity.GetType()\n\t\tReturn Self\n\tEnd Method\n\t\n\tMethod Copy_:TEntity(parent:TEntity=Null)\n\t\tReturn New Self.CopyData(Self).Init(_config,parent)\n\tEnd Method\n\t\n\tMethod Copy:TEntity(parent:TEntity=Null) Abstract\n\t\n\tMethod AddParent(parent:TEntity)\n\t\t_parent=parent\n\t\tIf parent\n\t\t\t_matrix.Overwrite parent._matrix\n\t\t\tparent._childlist.AddLast Self\n\t\tEndIf\n\tEnd Method\n\t\n\tMethod GetParent:TEntity()\n\t\tReturn _parent\n\tEnd Method\n\tMethod SetParent(parent:TEntity,glob=True)\n\t\tLocal gpx#,gpy#,gpz#\t\t\n\t\tLocal grx#,gry#,grz#\t\t\n\t\tLocal gsx#,gsy#,gsz#\n\t\t\n\t\tGetPosition gpx,gpy,gpz,True\n\t\tGetRotation grx,gry,grz,True\n\t\tGetScale gsx,gsy,gsz,True\n\t\t\n\t\tIf _parent\n\t\t\tFor Local entity:TEntity=EachIn _parent._childlist\n\t\t\t\tIf entity=Self ListRemove(_parent._childlist,Self)\n\t\t\tNext\n\t\t\t_parent=Null\n\t\tEndIf\n\n\t\t_px=gpx;_py=gpy;_pz=gpz\n\t\t_rx=grx;_ry=gry;_rz=grz\n\t\t_sx=gsx;_sy=gsy;_sz=gsz\n\t\t\n\t\tIf parent=Null UpdateMatrix(True);Return\t\t\n\t\t\n\t\tAddParent(parent)\n\t\tIf glob\t\t\t\t\n\t\t\tSetPosition(gpx,gpy,gpz,True)\n\t\t\tSetRotation(grx,gry,grz,True)\n\t\t\tSetScale(gsx,gsy,gsz,True)\n\t\tElse\t\t\t\n\t\t\tUpdateMatrix(False)\t\t\t\t\n\t\tEndIf\t\t\t\n\tEnd Method\n\t\n\tMethod CountChildren(recursive=False)\n\t\tLocal count\n\t\tIf recursive\n\t\t\tFor Local child:TEntity=EachIn _childlist\n\t\t\t\tcount:+child.CountChildren(True)\n\t\t\tNext\n\t\tEndIf\n\t\tReturn _childlist.Count()+count\n\tEnd Method\n\t\n\tMethod FindChild:TEntity(name$,recursive=False)\n\t\tFor Local child:TEntity=EachIn _childlist\n\t\t\tIf child.GetName()=name Return child\n\t\tNext\n\t\tIf recursive\n\t\t\tFor Local child:TEntity=EachIn _childlist\n\t\t\t\tLocal entity:TEntity = child.FindChild(name, True)\n\t\t\t\tIf entity Return entity\n\t\t\tNext\n\t\tEndIf\n\tEnd Method\n\t\n\tMethod GetName$()\n\t\tReturn _name\n\tEnd Method\n\tMethod SetName(name$)\n\t\t_name=name\n\tEnd Method\n\t\n\tMethod GetBrush:TBrush()\n\t\tReturn _brush.Copy()\n\tEnd Method\n\tMethod SetBrush(brush:TBrush)\n\t\t_brush.Load brush\n\tEnd Method\n\t\n\tMethod GetColor(red Var,green Var,blue Var)\n\t\tReturn _brush.GetColor(red,green,blue)\n\tEnd Method\n\tMethod SetColor(red,green,blue)\n\t\tReturn _brush.SetColor(red,green,blue)\n\tEnd Method\n\t\n\tMethod GetAlpha#()\n\t\tReturn _brush.GetAlpha()\n\tEnd Method\n\tMethod SetAlpha(alpha#)\n\t\t_brush.SetAlpha(alpha)\n\tEnd Method\n\t\n\tMethod GetShine#()\n\t\tReturn _brush.GetShine()\n\tEnd Method\n\tMethod SetShine(shine#)\n\t\t_brush.SetShine(shine)\n\tEnd Method\n\t\n\tMethod GetTexture:TTexture(index)\n\t\tReturn _brush.GetTexture(index)\n\tEnd Method\n\tMethod SetTexture(texture:TTexture,index=0,frame=0)\n\t\tReturn _brush.SetTexture(texture,index,frame)\n\tEnd Method\n\t\n\tMethod GetFX()\n\t\tReturn _brush.GetFX()\n\tEnd Method\n\tMethod SetFX(fx)\n\t\tReturn _brush.SetFX(fx)\n\tEnd Method\n\t\n\tMethod GetBlend()\n\t\tReturn _brush.GetBlend()\n\tEnd Method\n\tMethod SetBlend(blend)\n\t\tReturn _brush.SetBlend(blend)\n\tEnd Method\n\t\n\tMethod GetShader:TShader()\n\t\tReturn _brush.GetShader()\n\tEnd Method\n\tMethod SetShader(shader:TShader)\n\t\tReturn _brush.SetShader(shader)\n\tEnd Method\n\t\n\tMethod GetScale(x# Var,y# Var,z# Var,glob=False)\n\t\tIf glob\n\t\t\tx=_matrix._m[0,0]\n\t\t\ty=_matrix._m[1,1]\n\t\t\tz=_matrix._m[2,2]\n\t\tElse\n\t\t\tx=_sx;y=_sy;z=_sz\n\t\tEndIf\n\tEnd Method\n\tMethod SetScale(x#,y#,z#,glob=False)\n\t\t_sx=x;_sy=y;_sz=z\n\t\tIf glob=True And _parent<>Null\n\t\t\tLocal entity:TEntity=Self\n\t\t\tRepeat\n\t\t\t\t_sx:\/entity._parent._sx\n\t\t\t\t_sy:\/entity._parent._sy\n\t\t\t\t_sz:\/entity._parent._sz\n\t\t\t\tentity=entity._parent\n\t\t\tUntil entity._parent=Null\n\t\tEndIf\n\t\tRefreshMatrix()\t\n\tEnd Method\n\t\n\tMethod Transform(matrix:TMatrix,glob=False)\n\t\tSetMatrix matrix.Multiply(_matrix),glob\n\tEnd Method\n\t\n\tMethod Turn(pitch#,yaw#,roll#,glob=False)\n\t\t_rx:+pitch;_ry:+yaw;_rz:+roll\n\t\tRefreshMatrix()\n\tEnd Method\n\t\n\tMethod Point(target:Object,roll#=0.0)\n\t\tLocal x#,y#,z#,tx#,ty#,tz#\n\t\tGetPosition x,y,z,True\n\t\tGetTargetPosition target,tx,ty,tz \n\n\t\tLocal xdiff#=x-tx,ydiff#=y-ty,zdiff#=z-tz\n\n\t\tLocal dist22#=Sqr((xdiff*xdiff)+(zdiff*zdiff))\n\t\tLocal pitch#=ATan2(ydiff,dist22)\n\t\tLocal yaw#=ATan2(xdiff,-zdiff)\n\n\t\tSetRotation pitch,yaw,roll,True\n\tEnd Method\n\t\n\tMethod GetDistance#(target:Object)\n\t\tLocal x#,y#,z#,tx#,ty#,tz#\n\t\tGetPosition x,y,z,True\n\t\tGetTargetPosition target,tx,ty,tz\t\t\n\t\tReturn Sqr((x-tx)*(x-tx)+(y-ty)*(y-ty)+(z-tz)*(z-tz))\n\tEnd Method\n\t\n\tFunction GetTargetPosition(target:Object,x# Var,y# Var,z# Var)\n\t\tAssert target,\"Null target given.\"\n\t\tIf TEntity(target) TEntity(target).GetPosition x,y,z,True\n\t\tIf Float[](target)\n\t\t\tLocal coords#[]=Float[](target)\n\t\t\tIf coords.length>0 x=coords[0]\n\t\t\tIf coords.length>1 y=coords[1]\n\t\t\tIf coords.length>2 z=coords[2]\n\t\tEndIf\n\t\tAssert \"Invalid target given.\"\n\tEnd Function\t\n\t\n\tMethod GetRotation(pitch# Var,yaw# Var,roll# Var,glob=False)\n\t\tIf glob\n\t\t\t_matrix.GetRotation pitch,yaw,roll\n\t\t\tpitch:*-1\n\t\t\tyaw:*-1\n\t\tElse\n\t\t\tpitch=_rx;yaw=_ry;roll=_rz\n\t\tEndIf\n\tEnd Method\n\tMethod SetRotation(pitch#,yaw#,roll#,glob=False)\n\t\t_rx=pitch;_ry=yaw;_rz=roll\n\t\tIf glob And _parent<>Null\n\t\t\tLocal rx#,ry#,rz#\n\t\t\t_parent.GetRotation rx,ry,rz\n\t\t\t_rx:+rx;_ry:+ry;_rz:+rz\t\t\t\n\t\tEndIf\n\t\tRefreshMatrix()\n\tEnd Method\n\t\t\n\tMethod GetPosition(x# Var,y# Var,z# Var,glob=False)\n\t\tx=_px;y=_py;z=_pz\n\t\tIf glob _matrix.GetPosition x,y,z\n\tEnd Method\n\tMethod SetPosition(x#,y#,z#,glob=False)\n\t\t_px=x;_py=y;_pz=z\n\t\t\n\t\tIf glob And _parent<>Null\n\t\t\tLocal px#,py#,pz#\n\t\t\t_parent.GetPosition px,py,pz,True\n\t\t\t_px:-px;_py:-py;_pz:-pz\n\t\tEndIf\n\t\t\n\t\tRefreshMatrix()\n\tEnd Method\n\t\n\tMethod Move(x#,y#,z#)\n\t\tLocal matrix:TMatrix=TMatrix.Identity()\n\t\tmatrix=TMatrix.YawPitchRoll(-_ry,-_rx,_rz).Multiply(matrix)\n\t\tmatrix=TMatrix.Translation(x,y,z).Multiply(matrix)\n\t\n\t\tmatrix.GetPosition(x,y,z)\t\t\n\t\t_px:+x;_py:+y;_pz:+z\n\n\t\tRefreshMatrix()\n\tEnd Method\n\t\n\tMethod Translate(x#,y#,z#,glob=True)\n\t\tIf glob And _parent\t\t\t\n\t\t\tLocal ax#,ay#,az#\n\t\t\tGetRotation ax,ay,az,True\n\t\t\t\t\t\t\n\t\t\tLocal matrix:TMatrix=TMatrix.Roll(-az)\n\t\t\tmatrix=matrix.Multiply(TMatrix.Pitch(-ax))\n\t\t\tmatrix=matrix.Multiply(TMatrix.Yaw(-ay))\n\t\t\tmatrix=matrix.Multiply(TMatrix.Translation(x,y,z))\n\t\t\t\n\t\t\tmatrix.GetPosition x,y,z\n\t\tEndIf\n\t\t\n\t\t_px:+x;_py:+y;_pz:+z\n\n\t\tRefreshMatrix()\n\tEnd Method\n\t\n\tMethod GetVisible()\n\t\tLocal entity:TEntity=Self\n\t\tWhile entity<>Null\n\t\t\tIf entity._hidden=True Return False\n\t\t\tentity=entity._parent\n\t\tWend\n\t\tReturn True\n\tEnd Method\n\tMethod SetVisible(visible)\n\t\t_hidden=Not visible\n\tEnd Method\n\t\n\tMethod GetOrder()\n\t\tReturn _order\n\tEnd Method\n\tMethod SetOrder(order)\n\t\t_order=order\n\tEnd Method\n\t\n\tMethod GetCollisions:TCollision[]()\n\t\tReturn _collision\n\tEnd Method\n\t\n\tMethod GetRadius(x# Var,y# Var)\n\t\tx=_radiusx;y=_radiusy\n\tEnd Method\n\tMethod SetRadius(x#,y#=-1)\n\t\t_radiusx=x;_radiusy=x\n\t\tIf y>-1 _radiusy=y\n\tEnd Method\n\t\n\tMethod GetBox(x# Var,y# Var,z# Var,width# Var,height# Var,depth# Var)\n\t\tx=_boxx;y=_boxy;z=_boxz\n\t\twidth=_boxwidth;height=_boxheight;depth=_boxdepth\n\tEnd Method\n\tMethod SetBox(x#,y#,z#,width#,height#,depth#)\n\t\t_boxx=x;_boxy=y;_boxz=z\n\t\t_boxwidth=width;_boxheight=height;_boxdepth=depth\n\tEnd Method\n\t\n\tMethod Reset()\n\t\t_collision=Null\n\t\tGetPosition _oldx,_oldy,_oldz,True\n\tEnd Method\n\t\n\tMethod GetType()\n\t\tReturn _type\n\tEnd Method\n\tMethod SetType(typ,recursive=False)\n\t\tIf _typelink\n\t\t\t_linklist.Remove(_typelink)\n\t\t\t_typelink.Remove()\n\t\t\t_typelink=Null\n\t\tEndIf\n\t\t\n\t\tIf typ>0\n\t\t\tIf _config.CollisionType[typ]=Null _config.CollisionType[typ]=CreateList()\n\t\t\t_typelink=_config.CollisionType[typ].AddLast(Self)\n\t\t\tAddLink _typelink\n\t\tEndIf\t\t\n\t\t\n\t\t_type=typ\n\t\tGetPosition _oldx,_oldy,_oldz,True\n\t\t\n\t\tIf recursive\n\t\t\tFor Local child:TEntity=EachIn _childlist\n\t\t\t\tchild.SetType typ,True\n\t\t\tNext\n\t\tEndIf\n\tEnd Method\n\t\n\tMethod GetCullRadius#()\n\t\tReturn Abs(_cullradius)\n\tEnd Method\n\tMethod SetCullRadius(radius#)\n\t\t_cullradius=-radius\n\tEnd Method\n\n\tMethod GetCullParams(x# Var,y# Var,z# Var,radius# Var)\n\t\tGetPosition x,y,z,True\n\t\tradius=GetCullRadius()\n\tEnd Method\n\t\n\tMethod IntersectsLine:TVector(ptA:TVector, ptB:TVector)\n\t\tReturn Null\n\tEnd Method\n\t\n\tMethod GetPickMode(mode Var, obscurer Var)\n\t\tmode = _pickmode\n\t\tobscurer = _obscurer\n\tEnd Method\t\n\tMethod SetPickMode(mode, obscurer=True)\n\t\t_pickmode = mode\n\t\t_obscurer = obscurer\n\tEnd Method\n\t\n\tMethod HasAlpha()\n\t\tReturn _brush.HasAlpha()\n\tEnd Method\n\t\n\tMethod GetMatrix:TMatrix(alternate=False,copy=True)\n\t\tIf copy Return _matrix.Copy()\n\t\tReturn _matrix\n\tEnd Method\n\tMethod SetMatrix(matrix:TMatrix,glob=True)\n\t\tLocal x#,y#,z#,pitch#,yaw#,roll#,sx#,sy#,sz#\n\t\tmatrix.GetPosition x,y,z\n\t\tmatrix.GetRotation pitch,yaw,roll\n\t\tmatrix.GetScale sx,sy,sz\n\t\t\n\t\tLockMatrix\n\t\tSetPosition x,y,z,glob\n\t\tSetRotation pitch,yaw,roll,glob\n\t\tSetScale sx,sy,sz,glob\n\t\tUnlockMatrix\n\tEnd Method\n\t\n\tMethod LockMatrix()\n\t\t_lockmatrix=True\n\tEnd Method\n\tMethod UnlockMatrix()\n\t\t_lockmatrix=False\n\t\tRefreshMatrix()\n\tEnd Method\n\t\n\tMethod RefreshMatrix()\n\t\tIf _lockmatrix Return\n\t\tIf _parent<>Null\n\t\t\t_matrix.Overwrite _parent._matrix\n\t\t\tUpdateMatrix False\n\t\tElse\n\t\t\tUpdateMatrix True\n\t\tEndIf\t\t\n\t\t\n\t\tFor Local child:TEntity=EachIn _childlist\n\t\t\tchild.RefreshMatrix()\n\t\tNext\n\tEnd Method\n\t\n\tMethod UpdateMatrix(loadidentity)\n\t\tIf loadidentity _matrix=TMatrix.Identity()\n\t\t_matrix=TMatrix.Translation(_px,_py,_pz).Multiply(_matrix)\n\t\t_matrix=TMatrix.YawPitchRoll(-_ry,-_rx,_rz).Multiply(_matrix)\n\t\t_matrix=TMatrix.Scale(_sx,_sy,_sz).Multiply(_matrix)\n\tEnd Method\n\t\n\tMethod ObjectEnumerator:Object()\n\t\tReturn TChildrenEnumerator.Create(_childlist)\n\tEnd Method\nEnd Type\n\nType TChildrenEnumerator\n\tField _children:TEntity[],_index=-1\n\t\n\tFunction Create:TChildrenEnumerator(list:TList)\n\t\tLocal enum:TChildrenEnumerator=New TChildrenEnumerator\n\t\tenum._children=TEntity[](list.ToArray())\n\t\tReturn enum\n\tEnd Function\n\t\n\tMethod HasNext()\n\t\tReturn _index>=_children.length-1\n\tEnd Method\n\t\n\tMethod NextObject:Object()\n\t\t_index:+1\n\t\tReturn _children[_index]\n\tEnd Method\nEnd Type\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"b354675bb1f7d604f61c53cf10bf9dbe8714a4cc","subject":"[logging] (v0.3) \tAdded CloseLogStream method to TLogger","message":"[logging] (v0.3)\n\tAdded CloseLogStream method to TLogger\n","repos":"komiga\/duct-max,komiga\/duct-max,komiga\/duct-max","old_file":"logging.mod\/logging.bmx","new_file":"logging.mod\/logging.bmx","new_contents":"\nRem\n\tCopyright (c) 2009 Tim Howard\n\t\n\tPermission is hereby granted, free of charge, to any person obtaining a copy\n\tof this software and associated documentation files (the \"Software\"), to deal\n\tin the Software without restriction, including without limitation the rights\n\tto use, copy, modify, merge, publish, distribute, sublicense, and\/or sell\n\tcopies of the Software, and to permit persons to whom the Software is\n\tfurnished to do so, subject to the following conditions:\n\t\n\tThe above copyright notice and this permission notice shall be included in\n\tall copies or substantial portions of the Software.\n\t\n\tTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n\tIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n\tFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n\tAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n\tLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n\tOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n\tTHE SOFTWARE.\n\t-----------------------------------------------------------------------------\n\t\n\tlogging.bmx (Contains: TLogger, )\n\t\nEnd Rem\n\nSuperStrict\n\nRem\nbbdoc: Logging module\nEnd Rem\nModule duct.logging\n\nModuleInfo \"Version: 0.3\"\nModuleInfo \"Copyright: Tim Howard\"\nModuleInfo \"License: MIT\"\n\nModuleInfo \"History: Version 0.3\"\nModuleInfo \"History: Added CloseLogStream method to TLogger\"\nModuleInfo \"History: Version 0.2\"\nModuleInfo \"History: General cleanup\"\nModuleInfo \"History: Version 0.1\"\nModuleInfo \"History: Initial release\"\n\nImport brl.standardio\nImport brl.stream\n\nImport duct.appendstream\nImport duct.etc\n\nRem\n\tbbdoc: Stream\/Debug\/StandardIO based logger.\nEnd Rem\nType TLogger\n\t\n\tConst LOGTYPE_NONE:Int = 1, LOGTYPE_WARNING:Int = 2, LOGTYPE_ERROR:Int = 3\n\t\n\tField m_timeformat:String\n\tField m_formatter:TTextReplacer, m_rep_time:TTextReplacement, m_rep_type:TTextReplacement, m_rep_msg:TTextReplacement\n\t\n\tField m_logfile:String, m_logstream:TStream\n\tField m_usestream:Int = True, m_useprint:Int = False, m_usedebuglog:Int = False\n\t\n\tMethod New()\n\t\tm_formatter = New TTextReplacer\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Create a logger.\n\t\treturns: The new logger (itself).\n\tEnd Rem\n\tMethod Create:TLogger(timeformat:String = \"%H:%M:%S\", format:String = \"[{time} {type}] {msg}\", logfile:String, _usestream:Int = True, _useprint:Int = False, _usedebuglog:Int = False)\n\t\tSetTimeFormat(timeformat)\n\t\tSetFormat(format)\n\t\tSetLogFile(logfile)\n\t\tUseStream(_usestream)\n\t\tUsePrint(_useprint)\n\t\tUseDebugLog(_usedebuglog)\n\t\tReturn Self\n\tEnd Method\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the time format.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetTimeFormat(timeformat:String)\n\t\tm_timeformat = timeformat\n\tEnd Method\n\tRem\n\t\tbbdoc: Get the time format.\n\t\treturns: The time format for logged information.\n\tEnd Rem\n\tMethod GetTimeFormat:String()\n\t\tReturn m_timeformat\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the format.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetFormat(format:String, beginiden:String = \"{\", endiden:String = \"}\")\n\t\tm_formatter.SetString(format)\n\t\tm_formatter.AutoReplacements(beginiden, endiden)\n\t\tm_rep_time = m_formatter.GetReplacementFromName(\"time\")\n\t\tm_rep_type = m_formatter.GetReplacementFromName(\"type\")\n\t\tm_rep_msg = m_formatter.GetReplacementFromName(\"msg\")\n\tEnd Method\n\tRem\n\t\tbbdoc: Get the format.\n\t\treturns: The format for logged information.\n\tEnd Rem\n\tMethod GetFormat:String(beginiden:String = \"{\", endiden:String = \"}\")\n\t\tReturn m_formatter.GetOriginal(beginiden, endiden)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the log file.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetLogFile(logfile:String)\n\t\tm_logfile = logfile\n\tEnd Method\n\tRem\n\t\tbbdoc: Get the log file.\n\t\treturns: The file for the logged information.\n\tEnd Rem\n\tMethod GetLogFile:String()\n\t\tReturn m_logfile\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the log stream.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetLogStream(logstream:TStream)\n\t\tm_logstream = logstream\n\tEnd Method\n\tRem\n\t\tbbdoc: Get the log stream.\n\t\treturns: The log stream (may be Null).\n\tEnd Rem\n\tMethod GetLogStream:TStream()\n\t\tReturn m_logstream\n\tEnd Method\n\tRem\n\t\tbbdoc: Open the log stream to the set log file.\n\t\treturns: True if the stream was opened, or False if it was not.\n\t\tabout: This will open the log file stream.\n\tEnd Rem\n\tMethod OpenLogStream:Int(append:Int = True)\n\t\tLocal file:String\n\t\t\n\t\tIf append = True\n\t\t\tfile = \"append::\" + m_logfile\n\t\tElse\n\t\t\tfile = m_logfile\n\t\tEnd If\n\t\tm_logstream = WriteStream(file)\n\t\t\n\t\tReturn m_logstream <> Null\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Close the log stream.\n\t\treturns: True if the stream was closed, or False if it was not (stream has not been opened\/set).\n\tEnd Rem\n\tMethod CloseLogStream:Int()\n\t\tIf m_logstream <> Null\n\t\t\tm_logstream.Close()\n\t\t\tReturn True\n\t\tEnd If\n\t\tReturn False\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set stream usage state (True - on - or False - off).\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod UseStream(_usestream:Int)\n\t\tm_usestream = _usestream\n\tEnd Method\n\tRem\n\t\tbbdoc: Get the stream-usage state.\n\t\treturns: True (on) or False (off).\n\tEnd Rem\n\tMethod UsingStream:Int()\n\t\tReturn m_usestream\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set Print usage state (True - on - or False - off).\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod UsePrint(_useprint:Int)\n\t\tm_useprint = _useprint\n\tEnd Method\n\tRem\n\t\tbbdoc: Get the Print-usage state.\n\t\treturns: True (on) or False (off).\n\tEnd Rem\n\tMethod UsingPrint:Int()\n\t\tReturn m_useprint\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set DebugLog usage state (True - on - or False - off).\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod UseDebugLog(_usedebuglog:Int)\n\t\tm_usedebuglog = _usedebuglog\n\tEnd Method\n\tRem\n\t\tbbdoc: Get the DebugLog-usage state.\n\t\treturns: True (on) or False (off).\n\tEnd Rem\n\tMethod UsingDebugLog:Int()\n\t\tReturn m_usedebuglog\n\tEnd Method\n\t\n'#end region (Field accessors)\n\t\n'#region Formatting\n\t\n\tRem\n\t\tbbdoc: Get the current time in the logger's time format.\n\t\treturns: The current time in the logger's time format, or Null if the format is Null.\n\tEnd Rem\n\tMethod GetFormattedTime:String()\n\t\tIf m_timeformat <> Null\n\t\t\tReturn TimeInFormat(m_timeformat)\n\t\tElse\n\t\t\tReturn Null\n\t\tEnd If\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the given message formatted in the given log type.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod GetFormattedMessage:String(message:String, logtype:Int = LOGTYPE_NONE)\n\t\tIf m_rep_time <> Null And m_timeformat <> Null\n\t\t\tm_rep_time.SetReplacement(GetFormattedTime())\n\t\tEnd If\n\t\tIf m_rep_type <> Null\n\t\t\tSelect logtype\n\t\t\t\tCase LOGTYPE_NONE\n\t\t\t\t\tm_rep_type.SetReplacement(\"\")\n\t\t\t\tCase LOGTYPE_WARNING\n\t\t\t\t\tm_rep_type.SetReplacement(\"WARNING\")\n\t\t\t\tCase LOGTYPE_ERROR\n\t\t\t\t\tm_rep_type.SetReplacement(\"ERROR\")\n\t\t\tEnd Select\n\t\tEnd If\n\t\tIf m_rep_msg <> Null\n\t\t\tm_rep_msg.SetReplacement(message)\n\t\tEnd If\n\t\t\n\t\tReturn m_formatter.DoReplacements()\n\tEnd Method\n\t\n'#end region (Formatting)\n\t\n'#region Logging\n\t\n\tRem\n\t\tbbdoc: Log a string in the given log type.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod LogString(message:String, formatted:Int = True, logtype:Int = LOGTYPE_NONE)\n\t\tLocal formattedmessage:String\n\t\t\n\t\tIf formatted = True\n\t\t\tformattedmessage = GetFormattedMessage(message, logtype)\n\t\tElse\n\t\t\tformattedmessage = message\n\t\tEnd If\n\t\t\n\t\tIf m_usestream = True And m_logstream <> Null\n\t\t\tm_logstream.WriteLine(formattedmessage)\n\t\tEnd If\n\t\tIf m_useprint = True\n\t\t\tPrint(formattedmessage)\n\t\tEnd If\n\t\tIf m_usedebuglog = True\n\t\t\tDebugLog(formattedmessage)\n\t\tEnd If\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Log a generic message.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod LogMessage(message:String, formatted:Int = True)\n\t\tLogString(message, formatted, LOGTYPE_NONE)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Log a warning message.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod LogWarning(message:String, formatted:Int = True)\n\t\tLogString(message, formatted, LOGTYPE_WARNING)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Log an error message.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod LogError(message:String, formatted:Int = True)\n\t\tLogString(message, formatted, LOGTYPE_ERROR)\n\tEnd Method\n\t\n'#end region (Logging)\n\t\nEnd Type\n\n","old_contents":"\nRem\n\tCopyright (c) 2009 Tim Howard\n\t\n\tPermission is hereby granted, free of charge, to any person obtaining a copy\n\tof this software and associated documentation files (the \"Software\"), to deal\n\tin the Software without restriction, including without limitation the rights\n\tto use, copy, modify, merge, publish, distribute, sublicense, and\/or sell\n\tcopies of the Software, and to permit persons to whom the Software is\n\tfurnished to do so, subject to the following conditions:\n\t\n\tThe above copyright notice and this permission notice shall be included in\n\tall copies or substantial portions of the Software.\n\t\n\tTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n\tIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n\tFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n\tAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n\tLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n\tOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n\tTHE SOFTWARE.\n\t-----------------------------------------------------------------------------\n\t\n\tlogging.bmx (Contains: TLogger, )\n\t\nEnd Rem\n\nSuperStrict\n\nRem\nbbdoc: Logging module\nEnd Rem\nModule duct.logging\n\nModuleInfo \"Version: 0.2\"\nModuleInfo \"Copyright: Tim Howard\"\nModuleInfo \"License: MIT\"\n\nModuleInfo \"History: Version 0.2\"\nModuleInfo \"History: General cleanup\"\nModuleInfo \"History: Version 0.1\"\nModuleInfo \"History: Initial release\"\n\nImport brl.standardio\nImport brl.stream\n\nImport duct.appendstream\nImport duct.etc\n\nRem\n\tbbdoc: Stream\/Debug\/StandardIO based logger.\nEnd Rem\nType TLogger\n\t\n\tConst LOGTYPE_NONE:Int = 1, LOGTYPE_WARNING:Int = 2, LOGTYPE_ERROR:Int = 3\n\t\n\tField m_timeformat:String\n\tField m_formatter:TTextReplacer, m_rep_time:TTextReplacement, m_rep_type:TTextReplacement, m_rep_msg:TTextReplacement\n\t\n\tField m_logfile:String, m_logstream:TStream\n\tField m_usestream:Int = True, m_useprint:Int = False, m_usedebuglog:Int = False\n\t\n\tMethod New()\n\t\tm_formatter = New TTextReplacer\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Create a logger.\n\t\treturns: The new logger (itself).\n\tEnd Rem\n\tMethod Create:TLogger(timeformat:String = \"%H:%M:%S\", format:String = \"[{time} {type}] {msg}\", logfile:String, _usestream:Int = True, _useprint:Int = False, _usedebuglog:Int = False)\n\t\tSetTimeFormat(timeformat)\n\t\tSetFormat(format)\n\t\tSetLogFile(logfile)\n\t\tUseStream(_usestream)\n\t\tUsePrint(_useprint)\n\t\tUseDebugLog(_usedebuglog)\n\t\tReturn Self\n\tEnd Method\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the time format.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetTimeFormat(timeformat:String)\n\t\tm_timeformat = timeformat\n\tEnd Method\n\tRem\n\t\tbbdoc: Get the time format.\n\t\treturns: The time format for logged information.\n\tEnd Rem\n\tMethod GetTimeFormat:String()\n\t\tReturn m_timeformat\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the format.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetFormat(format:String, beginiden:String = \"{\", endiden:String = \"}\")\n\t\tm_formatter.SetString(format)\n\t\tm_formatter.AutoReplacements(beginiden, endiden)\n\t\tm_rep_time = m_formatter.GetReplacementFromName(\"time\")\n\t\tm_rep_type = m_formatter.GetReplacementFromName(\"type\")\n\t\tm_rep_msg = m_formatter.GetReplacementFromName(\"msg\")\n\tEnd Method\n\tRem\n\t\tbbdoc: Get the format.\n\t\treturns: The format for logged information.\n\tEnd Rem\n\tMethod GetFormat:String(beginiden:String = \"{\", endiden:String = \"}\")\n\t\tReturn m_formatter.GetOriginal(beginiden, endiden)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the log file.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetLogFile(logfile:String)\n\t\tm_logfile = logfile\n\tEnd Method\n\tRem\n\t\tbbdoc: Get the log file.\n\t\treturns: The file for the logged information.\n\tEnd Rem\n\tMethod GetLogFile:String()\n\t\tReturn m_logfile\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the log stream.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetLogStream(logstream:TStream)\n\t\tm_logstream = logstream\n\tEnd Method\n\tRem\n\t\tbbdoc: Get the log stream.\n\t\treturns: The log stream (may be Null).\n\tEnd Rem\n\tMethod GetLogStream:TStream()\n\t\tReturn m_logstream\n\tEnd Method\n\tRem\n\t\tbbdoc: Open the log stream to the set log file.\n\t\treturns: True if the stream was opened, or False if it was not.\n\t\tabout: This will open the log file stream.\n\tEnd Rem\n\tMethod OpenLogStream:Int(append:Int = True)\n\t\tLocal file:String\n\t\t\n\t\tIf append = True\n\t\t\tfile = \"append::\" + m_logfile\n\t\tElse\n\t\t\tfile = m_logfile\n\t\tEnd If\n\t\tm_logstream = WriteStream(file)\n\t\t\n\t\tReturn m_logstream <> Null\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set stream usage state (True - on - or False - off).\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod UseStream(_usestream:Int)\n\t\tm_usestream = _usestream\n\tEnd Method\n\tRem\n\t\tbbdoc: Get the stream-usage state.\n\t\treturns: True (on) or False (off).\n\tEnd Rem\n\tMethod UsingStream:Int()\n\t\tReturn m_usestream\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set Print usage state (True - on - or False - off).\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod UsePrint(_useprint:Int)\n\t\tm_useprint = _useprint\n\tEnd Method\n\tRem\n\t\tbbdoc: Get the Print-usage state.\n\t\treturns: True (on) or False (off).\n\tEnd Rem\n\tMethod UsingPrint:Int()\n\t\tReturn m_useprint\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set DebugLog usage state (True - on - or False - off).\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod UseDebugLog(_usedebuglog:Int)\n\t\tm_usedebuglog = _usedebuglog\n\tEnd Method\n\tRem\n\t\tbbdoc: Get the DebugLog-usage state.\n\t\treturns: True (on) or False (off).\n\tEnd Rem\n\tMethod UsingDebugLog:Int()\n\t\tReturn m_usedebuglog\n\tEnd Method\n\t\n'#end region (Field accessors)\n\t\n'#region Formatting\n\t\n\tRem\n\t\tbbdoc: Get the current time in the logger's time format.\n\t\treturns: The current time in the logger's time format, or Null if the format is Null.\n\tEnd Rem\n\tMethod GetFormattedTime:String()\n\t\tIf m_timeformat <> Null\n\t\t\tReturn TimeInFormat(m_timeformat)\n\t\tElse\n\t\t\tReturn Null\n\t\tEnd If\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the given message formatted in the given log type.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod GetFormattedMessage:String(message:String, logtype:Int = LOGTYPE_NONE)\n\t\tIf m_rep_time <> Null And m_timeformat <> Null\n\t\t\tm_rep_time.SetReplacement(GetFormattedTime())\n\t\tEnd If\n\t\tIf m_rep_type <> Null\n\t\t\tSelect logtype\n\t\t\t\tCase LOGTYPE_NONE\n\t\t\t\t\tm_rep_type.SetReplacement(\"\")\n\t\t\t\tCase LOGTYPE_WARNING\n\t\t\t\t\tm_rep_type.SetReplacement(\"WARNING\")\n\t\t\t\tCase LOGTYPE_ERROR\n\t\t\t\t\tm_rep_type.SetReplacement(\"ERROR\")\n\t\t\tEnd Select\n\t\tEnd If\n\t\tIf m_rep_msg <> Null\n\t\t\tm_rep_msg.SetReplacement(message)\n\t\tEnd If\n\t\t\n\t\tReturn m_formatter.DoReplacements()\n\tEnd Method\n\t\n'#end region (Formatting)\n\t\n'#region Logging\n\t\n\tRem\n\t\tbbdoc: Log a string in the given log type.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod LogString(message:String, formatted:Int = True, logtype:Int = LOGTYPE_NONE)\n\t\tLocal formattedmessage:String\n\t\t\n\t\tIf formatted = True\n\t\t\tformattedmessage = GetFormattedMessage(message, logtype)\n\t\tElse\n\t\t\tformattedmessage = message\n\t\tEnd If\n\t\t\n\t\tIf m_usestream = True And m_logstream <> Null\n\t\t\tm_logstream.WriteLine(formattedmessage)\n\t\tEnd If\n\t\tIf m_useprint = True\n\t\t\tPrint(formattedmessage)\n\t\tEnd If\n\t\tIf m_usedebuglog = True\n\t\t\tDebugLog(formattedmessage)\n\t\tEnd If\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Log a generic message.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod LogMessage(message:String, formatted:Int = True)\n\t\tLogString(message, formatted, LOGTYPE_NONE)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Log a warning message.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod LogWarning(message:String, formatted:Int = True)\n\t\tLogString(message, formatted, LOGTYPE_WARNING)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Log an error message.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod LogError(message:String, formatted:Int = True)\n\t\tLogString(message, formatted, LOGTYPE_ERROR)\n\tEnd Method\n\t\n'#end region (Logging)\n\t\nEnd Type\n\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"7f6ccdd298f5b924ecb6b131fb3983422fcbe251","subject":"Fixed return value check","message":"Fixed return value check\n","repos":"Htbaa\/zmq.mod,Htbaa\/zmq.mod","old_file":"socket.bmx","new_file":"socket.bmx","new_contents":"Rem\n\tCopyright (c) 2012 Christiaan Kras\n\t\n\tPermission is hereby granted, free of charge, to any person obtaining a copy\n\tof this software and associated documentation files (the \"Software\"), to deal\n\tin the Software without restriction, including without limitation the rights\n\tto use, copy, modify, merge, publish, distribute, sublicense, and\/or sell\n\tcopies of the Software, and to permit persons to whom the Software is\n\tfurnished to do so, subject to the following conditions:\n\t\n\tThe above copyright notice and this permission notice shall be included in\n\tall copies or substantial portions of the Software.\n\t\n\tTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n\tIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n\tFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n\tAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n\tLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n\tOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n\tTHE SOFTWARE.\nEnd Rem\n\nRem\n\tbbdoc: Type that represents a ZMQ socket\nEnd Rem\nType TZMQ_Socket\n\n\tRem\n\t\tbbdoc: Pointer to a ZMQ context\n\tEnd Rem\n\tField context:Byte Ptr\n\n\tRem\n\t\tbbdoc: Pointer to a ZMQ socket\n\t\tabout: Use @Close() to free socket\n\tEnd Rem\n\tField socket:Byte Ptr\n\n\tRem\n\t\tbbdoc: Create a ZMQ Socket\n\t\treturns: TZMQ_Socket\n\t\tabout: Throws a TZMQ_Exception on errors\n\tEnd Rem\n\tMethod Create:TZMQ_Socket(context:Byte Ptr, socket_type:Int)\n\t\tIf socket Then Throw \"Socket already exists!\"\n\t\tSelf.context = context\n\t\tSelf.socket = zmq_socket(Self.context, socket_type)\n\t\tIf Self.socket = Null Then Throw New TZMQ_Socket_Exception\n\t\tReturn Self\n\tEnd Method\n\n\tRem\n\t\tbbdoc: Destructor\n\t\tabout: Will call @Close() when collected\n\tEnd Rem\n\tMethod Destroy()\n\t\tSelf.Close()\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Bind to an address\n\t\tabout: Throws a TZMQ_Exception on errors\n\tEnd Rem\n\tMethod Bind(address:String)\n\t\tLocal rc:Int = zmq_bind(Self.socket, address)\n\t\tIf rc = -1 Then Throw New TZMQ_Socket_Exception\n\tEnd Method\n\n\tRem\n\t\tbbdoc: Connect to a ZMQ socket\n\t\tabout: Throws a TZMQ_Exception on errors\n\tEnd Rem\n\tMethod Connect(address:String)\n\t\tLocal rc:Int = zmq_connect(Self.socket, address)\n\t\tIf rc = -1 Then Throw New TZMQ_Socket_Exception\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Close socket\n\t\tabout: Throws a TZMQ_Exception on errors\n\tEnd Rem\n\tMethod Close()\n\t\tLocal rc:Int = zmq_close(Self.socket)\n\t\tIf rc = -1 Then Throw New TZMQ_Socket_Exception\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set a socket option\n\t\tabout: Throws a TZMQ_Exception on errors\n\tEnd Rem\n\tMethod SetSockOpt(socket_option:Int, value:String)\n\t\tLocal rc:Int = zmq_setsockopt(Self.socket, socket_option, value, value.Length)\n\t\tIf rc = -1 Then Throw New TZMQ_Socket_Exception\n\tEnd Method\n\n\tRem\n\t\tbbdoc: Get a socket options\n\t\tabout: Not yet implemented!\n\tEnd Rem\n\tMethod GetSockOpt(socket_option:Int)\n\t\tThrow \"Not yet implemented\"\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Send message to socket\n\t\tabout: Throws a TZMQ_Exception on errors\n\t\tmessage can either be a String, which will be converted to a TZMQ_Message,\n\t\tor you can pass a TZMQ_Message straight away\n\tEnd Rem\n\tMethod Send(message:Object, flags:Int = 0)\n\t\tIf TZMQ_Message(message)\n\t\t\tLocal rc:Int = zmq_send(Self.socket, TZMQ_Message(message).message, flags)\n\t\t\tIf rc = -1 Then Throw New TZMQ_Socket_Exception\n\t\tElse If String(message)\n\t\t\tLocal content:String = String(message)\n\t\t\tLocal msg:TZMQ_Message = New TZMQ_Message.CreateFromString(content)\n\t\t\tTry\n\t\t\t\tSelf.Send(msg, flags)\n\t\t\t\tmsg.Close()\n\t\t\tCatch ex:TZMQ_Socket_Exception\n\t\t\t\tmsg.Close()\n\t\t\t\tThrow ex\n\t\t\tEnd Try\n\t\tEnd If\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Receive message from socket\n\t\treturns: TZMQ_Message\n\tEnd Rem\n\tMethod Recv:TZMQ_Message(flags:Int = 0)\n\t\tLocal msg:Byte Ptr = bmx_zmq_message_t()\n\t\tzmq_msg_init(msg)\n\t\tIf zmq_recv(Self.socket, msg, flags) = -1 Then Return Null\n\t\tReturn New TZMQ_Message.CreateFromMessage(msg)\n\tEnd Method\nEnd Type","old_contents":"Rem\n\tCopyright (c) 2012 Christiaan Kras\n\t\n\tPermission is hereby granted, free of charge, to any person obtaining a copy\n\tof this software and associated documentation files (the \"Software\"), to deal\n\tin the Software without restriction, including without limitation the rights\n\tto use, copy, modify, merge, publish, distribute, sublicense, and\/or sell\n\tcopies of the Software, and to permit persons to whom the Software is\n\tfurnished to do so, subject to the following conditions:\n\t\n\tThe above copyright notice and this permission notice shall be included in\n\tall copies or substantial portions of the Software.\n\t\n\tTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n\tIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n\tFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n\tAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n\tLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n\tOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n\tTHE SOFTWARE.\nEnd Rem\n\nRem\n\tbbdoc: Type that represents a ZMQ socket\nEnd Rem\nType TZMQ_Socket\n\n\tRem\n\t\tbbdoc: Pointer to a ZMQ context\n\tEnd Rem\n\tField context:Byte Ptr\n\n\tRem\n\t\tbbdoc: Pointer to a ZMQ socket\n\t\tabout: Use @Close() to free socket\n\tEnd Rem\n\tField socket:Byte Ptr\n\n\tRem\n\t\tbbdoc: Create a ZMQ Socket\n\t\treturns: TZMQ_Socket\n\t\tabout: Throws a TZMQ_Exception on errors\n\tEnd Rem\n\tMethod Create:TZMQ_Socket(context:Byte Ptr, socket_type:Int)\n\t\tIf socket Then Throw \"Socket already exists!\"\n\t\tSelf.context = context\n\t\tSelf.socket = zmq_socket(Self.context, socket_type)\n\t\tIf Self.socket = Null Then Throw New TZMQ_Socket_Exception\n\t\tReturn Self\n\tEnd Method\n\n\tRem\n\t\tbbdoc: Destructor\n\t\tabout: Will call @Close() when collected\n\tEnd Rem\n\tMethod Destroy()\n\t\tSelf.Close()\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Bind to an address\n\t\tabout: Throws a TZMQ_Exception on errors\n\tEnd Rem\n\tMethod Bind(address:String)\n\t\tLocal rc:Int = zmq_bind(Self.socket, address)\n\t\tIf rc = -1 Then Throw New TZMQ_Socket_Exception\n\tEnd Method\n\n\tRem\n\t\tbbdoc: Connect to a ZMQ socket\n\t\tabout: Throws a TZMQ_Exception on errors\n\tEnd Rem\n\tMethod Connect(address:String)\n\t\tLocal rc:Int = zmq_connect(Self.socket, address)\n\t\tIf rc = -1 Then Throw New TZMQ_Socket_Exception\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Close socket\n\t\tabout: Throws a TZMQ_Exception on errors\n\tEnd Rem\n\tMethod Close()\n\t\tLocal rc:Int = zmq_close(Self.socket)\n\t\tIf rc = -1 Then Throw New TZMQ_Socket_Exception\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set a socket option\n\t\tabout: Throws a TZMQ_Exception on errors\n\tEnd Rem\n\tMethod SetSockOpt(socket_option:Int, value:String)\n\t\tLocal rc:Int = zmq_setsockopt(Self.socket, socket_option, value, value.Length)\n\t\tIf rc = -1 Then Throw New TZMQ_Socket_Exception\n\tEnd Method\n\n\tRem\n\t\tbbdoc: Get a socket options\n\t\tabout: Not yet implemented!\n\tEnd Rem\n\tMethod GetSockOpt(socket_option:Int)\n\t\tThrow \"Not yet implemented\"\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Send message to socket\n\t\tabout: Throws a TZMQ_Exception on errors\n\t\tmessage can either be a String, which will be converted to a TZMQ_Message,\n\t\tor you can pass a TZMQ_Message straight away\n\tEnd Rem\n\tMethod Send(message:Object, flags:Int = 0)\n\t\tIf TZMQ_Message(message)\n\t\t\tLocal rc:Int = zmq_send(Self.socket, TZMQ_Message(message).message, flags)\n\t\t\tIf rc = -1 Then Throw New TZMQ_Socket_Exception\n\t\tElse If String(message)\n\t\t\tLocal content:String = String(message)\n\t\t\tLocal msg:TZMQ_Message = New TZMQ_Message.CreateFromString(content)\n\t\t\tTry\n\t\t\t\tSelf.Send(msg, flags)\n\t\t\t\tmsg.Close()\n\t\t\tCatch ex:TZMQ_Socket_Exception\n\t\t\t\tmsg.Close()\n\t\t\t\tThrow ex\n\t\t\tEnd Try\n\t\tEnd If\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Receive message from socket\n\t\treturns: TZMQ_Message\n\tEnd Rem\n\tMethod Recv:TZMQ_Message(flags:Int = 0)\n\t\tLocal msg:Byte Ptr = bmx_zmq_message_t()\n\t\tzmq_msg_init(msg)\n\t\tIf zmq_recv(Self.socket, msg, flags) Then Return Null\n\t\tReturn New TZMQ_Message.CreateFromMessage(msg)\n\tEnd Method\nEnd Type","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"47d83b191c70919e776fb96c02c04a02b5741bd0","subject":"Forgot to remove exception.bmx as the code is included in xmlrpc.bmx","message":"Forgot to remove exception.bmx as the code is included in xmlrpc.bmx\n","repos":"Htbaa\/xmlrpc.mod,Htbaa\/xmlrpc.mod,Htbaa\/xmlrpc.mod,Htbaa\/xmlrpc.mod,Htbaa\/xmlrpc.mod","old_file":"exception.bmx","new_file":"exception.bmx","new_contents":"","old_contents":"Rem\n\tbbdoc:\nEnd Rem\nType TXMLRPC_Exception\n\tField message:String\n\tRem\n\t\tbbdoc:\n\tEnd Rem\n\tMethod Create:TXMLRPC_Exception(message:String)\n\t\tSelf.message = message\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc:\n\tEnd Rem\n\tMethod ToString:String()\n\t\tReturn Self.message\n\tEnd Method\nEnd Type\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"dc6b59a45159550170ba15da64c09ced45ef8c0b","subject":"Wrapped XMLRPC-EPI Server functions","message":"Wrapped XMLRPC-EPI Server functions\n","repos":"Htbaa\/xmlrpc.mod,Htbaa\/xmlrpc.mod,Htbaa\/xmlrpc.mod,Htbaa\/xmlrpc.mod,Htbaa\/xmlrpc.mod","old_file":"wrapper.bmx","new_file":"wrapper.bmx","new_contents":"'XMLRPC_REQUEST_TYPE\nConst xmlrpc_request_none:Int = 0\nConst xmlrpc_request_call:Int = 1\nConst xmlrpc_request_response:Int = 2\n\n'XMLRPC_VERSION\nConst xmlrpc_version_none:Int = 0\nConst xmlrpc_version_1_0:Int = 1\nConst xmlrpc_version_simple:Int = 2\nConst xmlrpc_version_danda:Int = 2\nConst xmlrpc_version_soap_1_1:Int = 3\n\n'XMLRPC_VECTOR_TYPE\nConst xmlrpc_vector_none:Int = 0\nConst xmlrpc_vector_array:Int = 1\nConst xmlrpc_vector_mixed:Int = 2\nConst xmlrpc_vector_struct:Int = 3\n\n'XMLRPC_VALUE_TYPE\nConst xmlrpc_none:Int = 0\nConst xmlrpc_empty:Int = 1\nConst xmlrpc_base64:Int = 2\nConst xmlrpc_boolean:Int = 3\nConst xmlrpc_datetime:Int = 4\nConst xmlrpc_double:Int = 5\nConst xmlrpc_int:Int = 6\nConst xmlrpc_string:Int = 7\nConst xmlrpc_vector:Int = 8\n\n'XMLRPC_VALUE_TYPE_EASY\nConst xmlrpc_type_none:Int = 0\nConst xmlrpc_type_empty:Int = 1\nConst xmlrpc_type_base64:Int = 2\nConst xmlrpc_type_boolean:Int = 3\nConst xmlrpc_type_datetime:Int = 4\nConst xmlrpc_type_double:Int = 5\nConst xmlrpc_type_int:Int = 6\nConst xmlrpc_type_string:Int = 7\nConst xmlrpc_type_array:Int = 8\nConst xmlrpc_type_mixed:Int = 9\nConst xmlrpc_type_struct:Int = 10\n\n'XMLRPC_ERROR_CODE\nConst xmlrpc_error_none:Int = 0\nConst xmlrpc_error_parse_xml_syntax:Int = -32700\nConst xmlrpc_error_parse_unknown_encoding:Int = -32701\nConst xmlrpc_error_parse_bad_encoding:Int = -32702\nConst xmlrpc_error_invalid_xmlrpc:Int = -32600\nConst xmlrpc_error_unknown_method:Int = -32601\nConst xmlrpc_error_invalid_params:Int = -32602\nConst xmlrpc_error_internal_server:Int = -32603\nConst xmlrpc_error_application:Int = -32500\nConst xmlrpc_error_system:Int = -32400\nConst xmlrpc_error_transport:Int = -32300\n\n'XMLRPC_SERVER_VALIDATION\nConst validation_none:Int = 0\nConst validation_all:Int = 1\nConst validation_if_defined:Int = 2\n\n'XMLRPC_CASE_COMPARISON\nConst xmlrpc_case_insensitive:Int = 0\nConst xmlrpc_case_sensitive:Int = 1\n\n'XMLRPC_CASE\nConst xmlrpc_case_exact:Int = 0\nConst xmlrpc_case_lower:Int = 1\nConst xmlrpc_case_upper:Int = 2\n\nExtern \"C\"\n\tFunction bmxXMLRPC_RequestSetOutputOptions(request:Byte Ptr, version:Int)\n\n\tFunction XMLRPC_RequestNew:Byte Ptr()\n\tFunction XMLRPC_RequestFree(request:Byte Ptr, bFreeIO:Int)\n\tFunction XMLRPC_RequestSetMethodName:Byte Ptr(request:Byte Ptr, methodName:Byte Ptr)\n\tFunction XMLRPC_RequestGetMethodName:Byte Ptr(request:Byte Ptr)\n\tFunction XMLRPC_RequestSetOutputOptions:Byte Ptr(request:Byte Ptr, output:Byte Ptr)\n\tFunction XMLRPC_RequestGetOutputOptions:Byte Ptr(request:Byte Ptr)\n\tFunction XMLRPC_RequestSetData:Byte Ptr(request:Byte Ptr, data:Byte Ptr)\n\tFunction XMLRPC_RequestGetData:Byte Ptr(request:Byte Ptr)\n\tFunction XMLRPC_RequestSetRequestType:Int(request:Byte Ptr, iType:Int)\n\tFunction XMLRPC_RequestGetRequestType:Int(request:Byte Ptr)\n\n\tFunction XMLRPC_REQUEST_ToXML:Byte Ptr(request:Byte Ptr, buf_len:Byte Ptr)\n\tFunction XMLRPC_REQUEST_FromXML:Byte Ptr(in_buf:Byte Ptr, length:Int, in_options:Byte Ptr)\n\tFunction XMLRPC_VALUE_ToXML:Byte Ptr(val:Int, buf_len:Byte Ptr)\n\tFunction XMLRPC_VALUE_FromXML:Byte Ptr(in_buf:Byte Ptr, length:Int, in_options:Byte Ptr)\n\n\tFunction XMLRPC_CreateVector:Byte Ptr(id:String, iType:Int)\n\tFunction XMLRPC_AddValueToVector:Int(target:Byte Ptr, source:Byte Ptr)\n\tFunction XMLRPC_VectorSize:Int(value:Byte Ptr)\n\tFunction XMLRPC_VectorRewind:Byte Ptr(value:Byte Ptr)\n\tFunction XMLRPC_VectorNext:Byte Ptr(value:Byte Ptr)\n\t\n\tFunction XMLRPC_CreateValueBoolean:Byte Ptr(id:Byte Ptr, truth:Int)\n\tFunction XMLRPC_CreateValueBase64:Byte Ptr(id:Byte Ptr, s:Byte Ptr, length:Int)\n\tFunction XMLRPC_CreateValueDateTime:Byte Ptr(id:Byte Ptr, time:Long)\n\tFunction XMLRPC_CreateValueDateTime_ISO8601:Byte Ptr(id:Byte Ptr, s:Byte Ptr)\n\tFunction XMLRPC_CreateValueDouble:Byte Ptr(id:Byte Ptr, f:Double)\n\tFunction XMLRPC_CreateValueInt:Byte Ptr(id:Byte Ptr, i:Int)\n\tFunction XMLRPC_CreateValueEmpty:Byte Ptr()\n\tFunction XMLRPC_CreateValueString:Byte Ptr(id:Byte Ptr, s:Byte Ptr, length:Int)\n\tFunction XMLRPC_CleanupValue(value:Byte Ptr)\n\n\tFunction XMLRPC_ServerCreate:Byte Ptr()\n\tFunction XMLRPC_GetGlobalServer:Byte Ptr()\n\tFunction XMLRPC_ServerDestroy(server:Byte Ptr)\n\tFunction XMLRPC_ServerRegisterMethod:Int(server:Byte Ptr, name:Byte Ptr, cb:Byte Ptr)\n\tFunction XMLRPC_ServerFindMethod:Byte Ptr(server:Byte Ptr, callName:Byte Ptr)\n\tFunction XMLRPC_ServerCallMethod:Byte Ptr(server:Byte Ptr, request:Byte Ptr, userData:Byte Ptr)\n\n'\tAccording to the XMLRPC-EPI documentation these 2 are private and shouldn't be used\n'\tFunction XMLRPC_RequestSetError:Byte Ptr(request:Byte Ptr, error:Int)\n'\tFunction XMLRPC_RequestGetError:Byte Ptr(request:Byte Ptr)\n\n\tFunction XMLRPC_VectorGetValueWithID_Case:Byte Ptr(vector:Byte Ptr, id:Byte Ptr, id_case:Int)\n\t\n\tFunction XMLRPC_GetValueType:Int(v:Byte Ptr)\n\t'XMLRPC_VALUE_TYPE_EASY XMLRPC_GetValueTypeEasy(XMLRPC_VALUE v);\n\tFunction XMLRPC_GetVectorType:Int(v:Byte Ptr)\n\t\n\tFunction XMLRPC_GetValueString:Byte Ptr(value:Byte Ptr)\n\tFunction XMLRPC_GetValueStringLen:Int(value:Byte Ptr)\n\tFunction XMLRPC_GetValueInt:Int(value:Byte Ptr)\n\tFunction XMLRPC_GetValueBoolean:Int(value:Byte Ptr)\n\tFunction XMLRPC_GetValueDouble:Double(value:Byte Ptr)\n\tFunction XMLRPC_GetValueBase64:Byte Ptr(value:Byte Ptr)\n\tFunction XMLRPC_GetValueDateTime:Long(value:Byte Ptr)\n\tFunction XMLRPC_GetValueDateTime_ISO8601:Byte Ptr(value:Byte Ptr)\n\tFunction XMLRPC_GetValueID:Byte Ptr(value:Byte Ptr)\n\t\n\tFunction XMLRPC_ValueIsFault:Int(value:Byte Ptr)\n\tFunction XMLRPC_ResponseIsFault(response:Byte Ptr)\n\tFunction XMLRPC_GetValueFaultCode:Int(value:Byte Ptr)\n\tFunction XMLRPC_GetResponseFaultCode:Int(response:Byte Ptr)\n\tFunction XMLRPC_GetValueFaultString:Byte Ptr(value:Byte Ptr)\n\tFunction XMLRPC_GetResponseFaultString:Byte Ptr(response:Byte Ptr)\n\tFunction XMLRPC_Free(mem:Byte Ptr)\n\tFunction XMLRPC_GetVersionString:Byte Ptr()\nRem\n\n\nXMLRPC_VALUE XMLRPC_UtilityCreateFault(int fault_code, const char* fault_string);\n\n\/* Get Values *\/\n#define XMLRPC_VectorGetStringWithID(vector, id) XMLRPC_GetValueString(XMLRPC_VectorGetValueWithID(vector, id))\n#define XMLRPC_VectorGetBase64WithID(vector, id) XMLRPC_GetValueBase64(XMLRPC_VectorGetValueWithID(vector, id))\n#define XMLRPC_VectorGetDateTimeWithID(vector, id) XMLRPC_GetValueDateTime(XMLRPC_VectorGetValueWithID(vector, id))\n#define XMLRPC_VectorGetDoubleWithID(vector, id) XMLRPC_GetValueDouble(XMLRPC_VectorGetValueWithID(vector, id))\n#define XMLRPC_VectorGetIntWithID(vector, id) XMLRPC_GetValueInt(XMLRPC_VectorGetValueWithID(vector, id))\n#define XMLRPC_VectorGetBooleanWithID(vector, id) XMLRPC_GetValueBoolean(XMLRPC_VectorGetValueWithID(vector, id))\nEndrem\nEnd Extern\n\nFunction XMLRPC_VectorGetValueWithID:Byte Ptr(vector:Byte Ptr, id:String)\n\tLocal strId:Byte Ptr\n\tIf id.Length > 0\n\t\tstrId = id.ToCString()\n\tEnd If\n\tLocal val:Byte Ptr = XMLRPC_VectorGetValueWithID_Case(vector, strId, xmlrpc_case_sensitive)\n\tMemFree(strId)\n\tReturn val\nEnd Function\n\nFunction XMLRPC_VectorAppendString:Int(vector:Byte Ptr, id:String, s:String, length:Int = 0)\n\tLocal strId:Byte Ptr\n\tLocal strS:Byte Ptr = s.ToCString()\n\tIf id.Length > 0\n\t\tstrId = id.ToCString()\n\tEnd If\n\tLocal val:Int = XMLRPC_AddValueToVector(vector, XMLRPC_CreateValueString(strId, strS, length))\n\tMemFree(strId)\n\tMemFree(strS)\n\tReturn val\nEnd Function\n\nFunction XMLRPC_VectorAppendBase64:Int(vector:Byte Ptr, id:String, s:String, length:Int = 0)\n\tLocal strId:Byte Ptr\n\tLocal strS:Byte Ptr = s.ToCString()\n\tIf id.Length > 0\n\t\tstrId = id.ToCString()\n\tEnd If\n\tLocal val:Int = XMLRPC_AddValueToVector(vector, XMLRPC_CreateValueBase64(strId, strS, length))\n\tMemFree(strId)\n\tMemFree(strS)\n\tReturn val\nEnd Function\n\nFunction XMLRPC_VectorAppendDateTime:Int(vector:Byte Ptr, id:String, time:Long)\n\tLocal strId:Byte Ptr\n\tIf id.Length > 0\n\t\tstrId = id.ToCString()\n\tEnd If\n\tLocal val:Int = XMLRPC_AddValueToVector(vector, XMLRPC_CreateValueDateTime(strId, time))\n\tMemFree(strId)\n\tReturn val\nEnd Function\n\nFunction XMLRPC_VectorAppendDateTime_ISO8601:Int(vector:Byte Ptr, id:String, s:String)\n\tLocal strId:Byte Ptr\n\tLocal strS:Byte Ptr = s.ToCString()\n\tIf id.Length > 0\n\t\tstrId = id.ToCString()\n\tEnd If\n\tLocal val:Int = XMLRPC_AddValueToVector(vector, XMLRPC_CreateValueDateTime_ISO8601(strId, strS))\n\tMemFree(strId)\n\tMemFree(strS)\n\tReturn val\nEnd Function\n\nFunction XMLRPC_VectorAppendDouble:Int(vector:Byte Ptr, id:String, f:Double)\n\tLocal strId:Byte Ptr\n\tIf id.Length > 0\n\t\tstrId = id.ToCString()\n\tEnd If\n\tLocal val:Int = XMLRPC_AddValueToVector(vector, XMLRPC_CreateValueDouble(strId, f))\n\tMemFree(strId)\n\tReturn val\nEnd Function\n\nFunction XMLRPC_VectorAppendInt:Int(vector:Byte Ptr, id:String, i:Int)\n\tLocal strId:Byte Ptr\n\tIf id.Length > 0\n\t\tstrId = id.ToCString()\n\tEnd If\n\tLocal val:Int = XMLRPC_AddValueToVector(vector, XMLRPC_CreateValueInt(strId, i))\n\tMemFree(strId)\n\tReturn val\nEnd Function\n\nFunction XMLRPC_VectorAppendBoolean:Int(vector:Byte Ptr, id:String, i:Int)\n\tLocal strId:Byte Ptr\n\tIf id.Length > 0\n\t\tstrId = id.ToCString()\n\tEnd If\n\tLocal val:Int = XMLRPC_AddValueToVector(vector, XMLRPC_CreateValueBoolean(strId, i))\n\tMemFree(strId)\n\tReturn val\nEnd Function\nrem\n\/****s* VALUE\/XMLRPC_REQUEST_INPUT_OPTIONS\n * NAME\n * XMLRPC_REQUEST_INPUT_OPTIONS\n * NOTES\n * Defines options for reading in xml data\n * SEE ALSO\n * XMLRPC_VERSION\n * XML_ELEM_INPUT_OPTIONS\n * XMLRPC_REQUEST_From_XML ()\n * SOURCE\n *\/\ntypedef struct _xmlrpc_request_input_options {\n STRUCT_XML_ELEM_INPUT_OPTIONS xml_elem_opts; \/* xml_element specific output options *\/\n} STRUCT_XMLRPC_REQUEST_INPUT_OPTIONS, *XMLRPC_REQUEST_INPUT_OPTIONS;\n\/******\/\n\n\/****s* VALUE\/XMLRPC_ERROR\n * NAME\n * XMLRPC_ERROR\n * NOTES\n * For the reporting and handling of errors\n * SOURCE\n *\/\ntypedef struct _xmlrpc_error {\n XMLRPC_ERROR_CODE code;\n STRUCT_XML_ELEM_ERROR xml_elem_error; \/* xml_element errors (parser errors) *\/\n} STRUCT_XMLRPC_ERROR, *XMLRPC_ERROR;\n\/******\/\nendrem\n\n\nRem\n\tString conversion stuff below. Shamelessly stolen from Brucey :-)\nEnd Rem\n\nExtern\n\tFunction _strlen:Int(s:Byte Ptr) = \"strlen\"\nEnd Extern\n\n' Convert from Max to UTF8\nFunction convertISO8859toUTF8:String(text:String)\n\tIf Not text Then\n\t\tReturn \"\"\n\tEnd If\n\t\n\tLocal l:Int = text.length\n\tIf l = 0 Then\n\t\tReturn \"\"\n\tEnd If\n\t\n\tLocal count:Int = 0\n\tLocal s:Byte[] = New Byte[l * 3]\n\t\n\tFor Local i:Int = 0 Until l\n\t\tLocal char:Int = text[i]\n\n\t\tIf char < 128 Then\n\t\t\ts[count] = char\n\t\t\tcount:+ 1\n\t\t\tContinue\n\t\tElse If char<2048\n\t\t\ts[count] = char\/64 | 192\n\t\t\tcount:+ 1\n\t\t\ts[count] = char Mod 64 | 128\n\t\t\tcount:+ 1\n\t\t\tContinue\n\t\tElse\n\t\t\ts[count] = char\/4096 | 224\n\t\t\tcount:+ 1\n\t\t\ts[count] = char\/64 Mod 64 | 128\n\t\t\tcount:+ 1\n\t\t\ts[count] = char Mod 64 | 128\n\t\t\tcount:+ 1\n\t\t\tContinue\n\t\tEndIf\n\t\t\n\tNext\n\n\tReturn String.fromBytes(s, count)\nEnd Function\n\n' Convert from UTF8 to Max\nFunction convertUTF8toISO8859:String(s:Byte Ptr)\n\n\tLocal l:Int = _strlen(s)\n\n\tLocal b:Short[] = New Short[l]\n\tLocal bc:Int = -1\n\tLocal c:Int\n\tLocal d:Int\n\tLocal e:Int\n\tFor Local i:Int = 0 Until l\n\n\t\tbc:+1\n\t\tc = s[i]\n\t\tIf c<128 \n\t\t\tb[bc] = c\n\t\t\tContinue\n\t\tEnd If\n\t\ti:+1\n\t\td=s[i]\n\t\tIf c<224 \n\t\t\tb[bc] = (c-192)*64+(d-128)\n\t\t\tContinue\n\t\tEnd If\n\t\ti:+1\n\t\te = s[i]\n\t\tIf c < 240 \n\t\t\tb[bc] = (c-224)*4096+(d-128)*64+(e-128)\n\t\t\tIf b[bc] = 8233 Then\n\t\t\t\tb[bc] = 10\n\t\t\tEnd If\n\t\t\tContinue\n\t\tEnd If\n\tNext\n\n\tReturn String.fromshorts(b, bc + 1)\nEnd Function\n\nFunction sizedUTF8toISO8859:String(s:Byte Ptr, size:Int)\n\n\tLocal l:Int = size\n\tLocal b:Short[] = New Short[l]\n\tLocal bc:Int = -1\n\tLocal c:Int\n\tLocal d:Int\n\tLocal e:Int\n\tFor Local i:Int = 0 Until l\n\n\t\tc = s[i]\n\t\tIf c = 0 Continue\n\n\t\tbc:+1\n\t\tIf c<128\n\t\t\tb[bc] = c\n\t\t\tContinue\n\t\tEnd If\n\t\ti:+1\n\t\td=s[i]\n\t\tIf c<224 \n\t\t\tb[bc] = (c-192)*64+(d-128)\n\t\t\tContinue\n\t\tEnd If\n\t\ti:+1\n\t\te = s[i]\n\t\tIf c < 240 \n\t\t\tb[bc] = (c-224)*4096+(d-128)*64+(e-128)\n\t\t\tIf b[bc] = 8233 Then\n\t\t\t\tb[bc] = 10\n\t\t\tEnd If\n\t\t\tContinue\n\t\tEnd If\n\tNext\n\n\tReturn String.fromshorts(b, bc + 1)\nEnd Function","old_contents":"'XMLRPC_REQUEST_TYPE\nConst xmlrpc_request_none:Int = 0\nConst xmlrpc_request_call:Int = 1\nConst xmlrpc_request_response:Int = 2\n\n'XMLRPC_VERSION\nConst xmlrpc_version_none:Int = 0\nConst xmlrpc_version_1_0:Int = 1\nConst xmlrpc_version_simple:Int = 2\nConst xmlrpc_version_danda:Int = 2\nConst xmlrpc_version_soap_1_1:Int = 3\n\n'XMLRPC_VECTOR_TYPE\nConst xmlrpc_vector_none:Int = 0\nConst xmlrpc_vector_array:Int = 1\nConst xmlrpc_vector_mixed:Int = 2\nConst xmlrpc_vector_struct:Int = 3\n\n'XMLRPC_VALUE_TYPE\nConst xmlrpc_none:Int = 0\nConst xmlrpc_empty:Int = 1\nConst xmlrpc_base64:Int = 2\nConst xmlrpc_boolean:Int = 3\nConst xmlrpc_datetime:Int = 4\nConst xmlrpc_double:Int = 5\nConst xmlrpc_int:Int = 6\nConst xmlrpc_string:Int = 7\nConst xmlrpc_vector:Int = 8\n\n'XMLRPC_VALUE_TYPE_EASY\nConst xmlrpc_type_none:Int = 0\nConst xmlrpc_type_empty:Int = 1\nConst xmlrpc_type_base64:Int = 2\nConst xmlrpc_type_boolean:Int = 3\nConst xmlrpc_type_datetime:Int = 4\nConst xmlrpc_type_double:Int = 5\nConst xmlrpc_type_int:Int = 6\nConst xmlrpc_type_string:Int = 7\nConst xmlrpc_type_array:Int = 8\nConst xmlrpc_type_mixed:Int = 9\nConst xmlrpc_type_struct:Int = 10\n\n'XMLRPC_ERROR_CODE\nConst xmlrpc_error_none:Int = 0\nConst xmlrpc_error_parse_xml_syntax:Int = -32700\nConst xmlrpc_error_parse_unknown_encoding:Int = -32701\nConst xmlrpc_error_parse_bad_encoding:Int = -32702\nConst xmlrpc_error_invalid_xmlrpc:Int = -32600\nConst xmlrpc_error_unknown_method:Int = -32601\nConst xmlrpc_error_invalid_params:Int = -32602\nConst xmlrpc_error_internal_server:Int = -32603\nConst xmlrpc_error_application:Int = -32500\nConst xmlrpc_error_system:Int = -32400\nConst xmlrpc_error_transport:Int = -32300\n\n'XMLRPC_SERVER_VALIDATION\nConst validation_none:Int = 0\nConst validation_all:Int = 1\nConst validation_if_defined:Int = 2\n\n'XMLRPC_CASE_COMPARISON\nConst xmlrpc_case_insensitive:Int = 0\nConst xmlrpc_case_sensitive:Int = 1\n\n'XMLRPC_CASE\nConst xmlrpc_case_exact:Int = 0\nConst xmlrpc_case_lower:Int = 1\nConst xmlrpc_case_upper:Int = 2\n\nExtern \"C\"\n\tFunction bmxXMLRPC_RequestSetOutputOptions(request:Byte Ptr, version:Int)\n\n\tFunction XMLRPC_RequestNew:Byte Ptr()\n\tFunction XMLRPC_RequestFree(request:Byte Ptr, bFreeIO:Int)\n\tFunction XMLRPC_RequestSetMethodName:Byte Ptr(request:Byte Ptr, methodName:Byte Ptr)\n\tFunction XMLRPC_RequestGetMethodName:Byte Ptr(request:Byte Ptr)\n\tFunction XMLRPC_RequestSetOutputOptions:Byte Ptr(request:Byte Ptr, output:Byte Ptr)\n\tFunction XMLRPC_RequestGetOutputOptions:Byte Ptr(request:Byte Ptr)\n\tFunction XMLRPC_RequestSetData:Byte Ptr(request:Byte Ptr, data:Byte Ptr)\n\tFunction XMLRPC_RequestGetData:Byte Ptr(request:Byte Ptr)\n\tFunction XMLRPC_RequestSetRequestType:Int(request:Byte Ptr, iType:Int)\n\tFunction XMLRPC_RequestGetRequestType:Int(request:Byte Ptr)\n\n\tFunction XMLRPC_REQUEST_ToXML:Byte Ptr(request:Byte Ptr, buf_len:Byte Ptr)\n\tFunction XMLRPC_REQUEST_FromXML:Byte Ptr(in_buf:Byte Ptr, length:Int, in_options:Byte Ptr)\n\tFunction XMLRPC_VALUE_ToXML:Byte Ptr(val:Int, buf_len:Byte Ptr)\n\tFunction XMLRPC_VALUE_FromXML:Byte Ptr(in_buf:Byte Ptr, length:Int, in_options:Byte Ptr)\n\n\tFunction XMLRPC_CreateVector:Byte Ptr(id:String, iType:Int)\n\tFunction XMLRPC_AddValueToVector:Int(target:Byte Ptr, source:Byte Ptr)\n\tFunction XMLRPC_VectorSize:Int(value:Byte Ptr)\n\tFunction XMLRPC_VectorRewind:Byte Ptr(value:Byte Ptr)\n\tFunction XMLRPC_VectorNext:Byte Ptr(value:Byte Ptr)\n\t\n\tFunction XMLRPC_CreateValueBoolean:Byte Ptr(id:Byte Ptr, truth:Int)\n\tFunction XMLRPC_CreateValueBase64:Byte Ptr(id:Byte Ptr, s:Byte Ptr, length:Int)\n\tFunction XMLRPC_CreateValueDateTime:Byte Ptr(id:Byte Ptr, time:Long)\n\tFunction XMLRPC_CreateValueDateTime_ISO8601:Byte Ptr(id:Byte Ptr, s:Byte Ptr)\n\tFunction XMLRPC_CreateValueDouble:Byte Ptr(id:Byte Ptr, f:Double)\n\tFunction XMLRPC_CreateValueInt:Byte Ptr(id:Byte Ptr, i:Int)\n\tFunction XMLRPC_CreateValueEmpty:Byte Ptr()\n\tFunction XMLRPC_CreateValueString:Byte Ptr(id:Byte Ptr, s:Byte Ptr, length:Int)\n\tFunction XMLRPC_CleanupValue(value:Byte Ptr)\n\n'\tAccording to the XMLRPC-EPI documentation these 2 are private and shouldn't be used\n'\tFunction XMLRPC_RequestSetError:Byte Ptr(request:Byte Ptr, error:Int)\n'\tFunction XMLRPC_RequestGetError:Byte Ptr(request:Byte Ptr)\n\n\tFunction XMLRPC_VectorGetValueWithID_Case:Byte Ptr(vector:Byte Ptr, id:Byte Ptr, id_case:Int)\n\t\n\tFunction XMLRPC_GetValueType:Int(v:Byte Ptr)\n\t'XMLRPC_VALUE_TYPE_EASY XMLRPC_GetValueTypeEasy(XMLRPC_VALUE v);\n\tFunction XMLRPC_GetVectorType:Int(v:Byte Ptr)\n\t\n\tFunction XMLRPC_GetValueString:Byte Ptr(value:Byte Ptr)\n\tFunction XMLRPC_GetValueStringLen:Int(value:Byte Ptr)\n\tFunction XMLRPC_GetValueInt:Int(value:Byte Ptr)\n\tFunction XMLRPC_GetValueBoolean:Int(value:Byte Ptr)\n\tFunction XMLRPC_GetValueDouble:Double(value:Byte Ptr)\n\tFunction XMLRPC_GetValueBase64:Byte Ptr(value:Byte Ptr)\n\tFunction XMLRPC_GetValueDateTime:Long(value:Byte Ptr)\n\tFunction XMLRPC_GetValueDateTime_ISO8601:Byte Ptr(value:Byte Ptr)\n\tFunction XMLRPC_GetValueID:Byte Ptr(value:Byte Ptr)\n\t\n\tFunction XMLRPC_ValueIsFault:Int(value:Byte Ptr)\n\tFunction XMLRPC_ResponseIsFault(response:Byte Ptr)\n\tFunction XMLRPC_GetValueFaultCode:Int(value:Byte Ptr)\n\tFunction XMLRPC_GetResponseFaultCode:Int(response:Byte Ptr)\n\tFunction XMLRPC_GetValueFaultString:Byte Ptr(value:Byte Ptr)\n\tFunction XMLRPC_GetResponseFaultString:Byte Ptr(response:Byte Ptr)\n\tFunction XMLRPC_Free(mem:Byte Ptr)\n\tFunction XMLRPC_GetVersionString:Byte Ptr()\nRem\n\n\nXMLRPC_VALUE XMLRPC_UtilityCreateFault(int fault_code, const char* fault_string);\n\n\/* Get Values *\/\n#define XMLRPC_VectorGetStringWithID(vector, id) XMLRPC_GetValueString(XMLRPC_VectorGetValueWithID(vector, id))\n#define XMLRPC_VectorGetBase64WithID(vector, id) XMLRPC_GetValueBase64(XMLRPC_VectorGetValueWithID(vector, id))\n#define XMLRPC_VectorGetDateTimeWithID(vector, id) XMLRPC_GetValueDateTime(XMLRPC_VectorGetValueWithID(vector, id))\n#define XMLRPC_VectorGetDoubleWithID(vector, id) XMLRPC_GetValueDouble(XMLRPC_VectorGetValueWithID(vector, id))\n#define XMLRPC_VectorGetIntWithID(vector, id) XMLRPC_GetValueInt(XMLRPC_VectorGetValueWithID(vector, id))\n#define XMLRPC_VectorGetBooleanWithID(vector, id) XMLRPC_GetValueBoolean(XMLRPC_VectorGetValueWithID(vector, id))\nEndrem\nEnd Extern\n\nFunction XMLRPC_VectorGetValueWithID:Byte Ptr(vector:Byte Ptr, id:String)\n\tLocal strId:Byte Ptr\n\tIf id.Length > 0\n\t\tstrId = id.ToCString()\n\tEnd If\n\tLocal val:Byte Ptr = XMLRPC_VectorGetValueWithID_Case(vector, strId, xmlrpc_case_sensitive)\n\tMemFree(strId)\n\tReturn val\nEnd Function\n\nFunction XMLRPC_VectorAppendString:Int(vector:Byte Ptr, id:String, s:String, length:Int = 0)\n\tLocal strId:Byte Ptr\n\tLocal strS:Byte Ptr = s.ToCString()\n\tIf id.Length > 0\n\t\tstrId = id.ToCString()\n\tEnd If\n\tLocal val:Int = XMLRPC_AddValueToVector(vector, XMLRPC_CreateValueString(strId, strS, length))\n\tMemFree(strId)\n\tMemFree(strS)\n\tReturn val\nEnd Function\n\nFunction XMLRPC_VectorAppendBase64:Int(vector:Byte Ptr, id:String, s:String, length:Int = 0)\n\tLocal strId:Byte Ptr\n\tLocal strS:Byte Ptr = s.ToCString()\n\tIf id.Length > 0\n\t\tstrId = id.ToCString()\n\tEnd If\n\tLocal val:Int = XMLRPC_AddValueToVector(vector, XMLRPC_CreateValueBase64(strId, strS, length))\n\tMemFree(strId)\n\tMemFree(strS)\n\tReturn val\nEnd Function\n\nFunction XMLRPC_VectorAppendDateTime:Int(vector:Byte Ptr, id:String, time:Long)\n\tLocal strId:Byte Ptr\n\tIf id.Length > 0\n\t\tstrId = id.ToCString()\n\tEnd If\n\tLocal val:Int = XMLRPC_AddValueToVector(vector, XMLRPC_CreateValueDateTime(strId, time))\n\tMemFree(strId)\n\tReturn val\nEnd Function\n\nFunction XMLRPC_VectorAppendDateTime_ISO8601:Int(vector:Byte Ptr, id:String, s:String)\n\tLocal strId:Byte Ptr\n\tLocal strS:Byte Ptr = s.ToCString()\n\tIf id.Length > 0\n\t\tstrId = id.ToCString()\n\tEnd If\n\tLocal val:Int = XMLRPC_AddValueToVector(vector, XMLRPC_CreateValueDateTime_ISO8601(strId, strS))\n\tMemFree(strId)\n\tMemFree(strS)\n\tReturn val\nEnd Function\n\nFunction XMLRPC_VectorAppendDouble:Int(vector:Byte Ptr, id:String, f:Double)\n\tLocal strId:Byte Ptr\n\tIf id.Length > 0\n\t\tstrId = id.ToCString()\n\tEnd If\n\tLocal val:Int = XMLRPC_AddValueToVector(vector, XMLRPC_CreateValueDouble(strId, f))\n\tMemFree(strId)\n\tReturn val\nEnd Function\n\nFunction XMLRPC_VectorAppendInt:Int(vector:Byte Ptr, id:String, i:Int)\n\tLocal strId:Byte Ptr\n\tIf id.Length > 0\n\t\tstrId = id.ToCString()\n\tEnd If\n\tLocal val:Int = XMLRPC_AddValueToVector(vector, XMLRPC_CreateValueInt(strId, i))\n\tMemFree(strId)\n\tReturn val\nEnd Function\n\nFunction XMLRPC_VectorAppendBoolean:Int(vector:Byte Ptr, id:String, i:Int)\n\tLocal strId:Byte Ptr\n\tIf id.Length > 0\n\t\tstrId = id.ToCString()\n\tEnd If\n\tLocal val:Int = XMLRPC_AddValueToVector(vector, XMLRPC_CreateValueBoolean(strId, i))\n\tMemFree(strId)\n\tReturn val\nEnd Function\nrem\n\/****s* VALUE\/XMLRPC_REQUEST_INPUT_OPTIONS\n * NAME\n * XMLRPC_REQUEST_INPUT_OPTIONS\n * NOTES\n * Defines options for reading in xml data\n * SEE ALSO\n * XMLRPC_VERSION\n * XML_ELEM_INPUT_OPTIONS\n * XMLRPC_REQUEST_From_XML ()\n * SOURCE\n *\/\ntypedef struct _xmlrpc_request_input_options {\n STRUCT_XML_ELEM_INPUT_OPTIONS xml_elem_opts; \/* xml_element specific output options *\/\n} STRUCT_XMLRPC_REQUEST_INPUT_OPTIONS, *XMLRPC_REQUEST_INPUT_OPTIONS;\n\/******\/\n\n\/****s* VALUE\/XMLRPC_ERROR\n * NAME\n * XMLRPC_ERROR\n * NOTES\n * For the reporting and handling of errors\n * SOURCE\n *\/\ntypedef struct _xmlrpc_error {\n XMLRPC_ERROR_CODE code;\n STRUCT_XML_ELEM_ERROR xml_elem_error; \/* xml_element errors (parser errors) *\/\n} STRUCT_XMLRPC_ERROR, *XMLRPC_ERROR;\n\/******\/\nendrem\n\n\nRem\n\tString conversion stuff below. Shamelessly stolen from Brucey :-)\nEnd Rem\n\nExtern\n\tFunction _strlen:Int(s:Byte Ptr) = \"strlen\"\nEnd Extern\n\n' Convert from Max to UTF8\nFunction convertISO8859toUTF8:String(text:String)\n\tIf Not text Then\n\t\tReturn \"\"\n\tEnd If\n\t\n\tLocal l:Int = text.length\n\tIf l = 0 Then\n\t\tReturn \"\"\n\tEnd If\n\t\n\tLocal count:Int = 0\n\tLocal s:Byte[] = New Byte[l * 3]\n\t\n\tFor Local i:Int = 0 Until l\n\t\tLocal char:Int = text[i]\n\n\t\tIf char < 128 Then\n\t\t\ts[count] = char\n\t\t\tcount:+ 1\n\t\t\tContinue\n\t\tElse If char<2048\n\t\t\ts[count] = char\/64 | 192\n\t\t\tcount:+ 1\n\t\t\ts[count] = char Mod 64 | 128\n\t\t\tcount:+ 1\n\t\t\tContinue\n\t\tElse\n\t\t\ts[count] = char\/4096 | 224\n\t\t\tcount:+ 1\n\t\t\ts[count] = char\/64 Mod 64 | 128\n\t\t\tcount:+ 1\n\t\t\ts[count] = char Mod 64 | 128\n\t\t\tcount:+ 1\n\t\t\tContinue\n\t\tEndIf\n\t\t\n\tNext\n\n\tReturn String.fromBytes(s, count)\nEnd Function\n\n' Convert from UTF8 to Max\nFunction convertUTF8toISO8859:String(s:Byte Ptr)\n\n\tLocal l:Int = _strlen(s)\n\n\tLocal b:Short[] = New Short[l]\n\tLocal bc:Int = -1\n\tLocal c:Int\n\tLocal d:Int\n\tLocal e:Int\n\tFor Local i:Int = 0 Until l\n\n\t\tbc:+1\n\t\tc = s[i]\n\t\tIf c<128 \n\t\t\tb[bc] = c\n\t\t\tContinue\n\t\tEnd If\n\t\ti:+1\n\t\td=s[i]\n\t\tIf c<224 \n\t\t\tb[bc] = (c-192)*64+(d-128)\n\t\t\tContinue\n\t\tEnd If\n\t\ti:+1\n\t\te = s[i]\n\t\tIf c < 240 \n\t\t\tb[bc] = (c-224)*4096+(d-128)*64+(e-128)\n\t\t\tIf b[bc] = 8233 Then\n\t\t\t\tb[bc] = 10\n\t\t\tEnd If\n\t\t\tContinue\n\t\tEnd If\n\tNext\n\n\tReturn String.fromshorts(b, bc + 1)\nEnd Function\n\nFunction sizedUTF8toISO8859:String(s:Byte Ptr, size:Int)\n\n\tLocal l:Int = size\n\tLocal b:Short[] = New Short[l]\n\tLocal bc:Int = -1\n\tLocal c:Int\n\tLocal d:Int\n\tLocal e:Int\n\tFor Local i:Int = 0 Until l\n\n\t\tc = s[i]\n\t\tIf c = 0 Continue\n\n\t\tbc:+1\n\t\tIf c<128\n\t\t\tb[bc] = c\n\t\t\tContinue\n\t\tEnd If\n\t\ti:+1\n\t\td=s[i]\n\t\tIf c<224 \n\t\t\tb[bc] = (c-192)*64+(d-128)\n\t\t\tContinue\n\t\tEnd If\n\t\ti:+1\n\t\te = s[i]\n\t\tIf c < 240 \n\t\t\tb[bc] = (c-224)*4096+(d-128)*64+(e-128)\n\t\t\tIf b[bc] = 8233 Then\n\t\t\t\tb[bc] = 10\n\t\t\tEnd If\n\t\t\tContinue\n\t\tEnd If\n\tNext\n\n\tReturn String.fromshorts(b, bc + 1)\nEnd Function","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"3617cfd35ffb1f4d8f37cb9cd13c8403ca84d924","subject":"FINALLY fixed matrices.... I hope.","message":"FINALLY fixed matrices.... I hope.\n\n--HG--\nextra : convert_revision : svn%3Ae934d3cd-0d57-f34a-94d0-9e8d31ae1c29\/trunk%40386\n","repos":"programmerby\/diddy-mirror,programmerby\/diddy-mirror,programmerby\/diddy-mirror,programmerby\/diddy-mirror","old_file":"monkeymax\/modules\/mojo\/native\/mojo.bmax.bmx","new_file":"monkeymax\/modules\/mojo\/native\/mojo.bmax.bmx","new_contents":"' ***** Start mojo.bmax.bmx ******\r\n\r\nGlobal app:gxtkApp\r\n\r\nType gxtkApp\r\n\tField ginput:gxtkInput\r\n\tField gaudio:gxtkAudio\r\n\tField ggraphics:gxtkGraphics\r\n\r\n\tField dead:Int=0\r\n\tField suspended:Int=0\r\n\tField vloading:Int=0\r\n\tField maxloading:Int=0\r\n\tField updateRate:Int=0\r\n\tField nextUpdate:Float=0\r\n\tField updatePeriod:Float=0\r\n\tField startMillis:Float=0\r\n\t\r\n\tMethod New()' gxtkApp()\r\n\t\tapp=Self\r\n\t\tggraphics=New gxtkGraphics\r\n\tEndMethod\r\n\t\r\n\tMethod Setup()\r\n\t\tginput=New gxtkInput\r\n\t\tgaudio=New gxtkAudio\r\n\r\n\t\tbb_input__1Set_1Input_1Device(ginput)\r\n\t\tbb_audio__1Set_1Audio_1Device(gaudio)\r\n\t\t\r\n\t\tstartMillis=BlitzMaxMillisecs()\r\n\t\t\r\n\t\tSetFrameRate( 0 )\r\n\t\t\r\n\t\tInvokeOnCreate()\r\n\t\tInvokeOnRender()\r\n\t\tUpdate()\r\n\tEndMethod\r\n\t\r\n\tMethod Update()\r\n\t\tWhile Not AppTerminate()\r\n\t\t\tIf Not updatePeriod return\r\n\t\t\tLocal updates:Int = 0\r\n\t\t\t\r\n\t\t\tRepeat\r\n\t\t\t\tnextUpdate:+updatePeriod\r\n\t\t\t\tInvokeOnUpdate()\r\n\t\t\t\tIf Not updatePeriod Then Exit\r\n\t\t\t\tIf nextUpdate>BlitzMaxMillisecs() Then Exit\r\n\t\t\t\tupdates:+1\r\n\t\t\t\tIf updates = 7 Then\r\n\t\t\t\t\tnextUpdate = BlitzMaxMillisecs()\r\n\t\t\t\t\tExit\r\n\t\t\t\tEndIf\r\n\t\t\tForever\r\n\t\t\tInvokeOnRender()\r\n\t\t\tLocal del:Int = nextUpdate - BlitzMaxMillisecs()\r\n\t\t\tIf del < 1 Then del = 1\r\n\t\t\tDelay(del)\r\n\t\tWend\r\n\tEndMethod\r\n\t\r\n\tMethod InvokeOnCreate()\r\n\t\tIf dead Return\r\n\t\tdead = 1\r\n\t\tOnCreate()\r\n\t\tdead = 0\r\n\tEndMethod\r\n\r\n\tMethod InvokeOnUpdate()\r\n\t\tIf dead Or suspended Or Not updateRate Or vloading Return\r\n\t\tOnUpdate()\r\n\tEndMethod\r\n\t\r\n\tMethod InvokeOnRender()\r\n\t\tIf dead Or suspended Return\r\n\t\tggraphics.BeginRender()\r\n\t\tIf vloading\r\n\t\t\tOnLoading()\r\n\t\tElse\r\n\t\t\tOnRender()\r\n\t\tEndIf\r\n\t\tggraphics.EndRender()\r\n\tEndMethod\r\n\t\r\n\t\r\n\tMethod SetFrameRate( fps:Int )\r\n\t\tIf fps\r\n\t\t\tupdatePeriod=1000.0\/fps\r\n\t\t\tnextUpdate=BlitzMaxMillisecs() +updatePeriod\r\n\t\tElse\r\n\t\t\tupdatePeriod=0\r\n\t\tEndIf\r\n\tEndMethod\r\n\r\n\tMethod LoadState:String()\r\n'\t\tvar file:SharedObject=SharedObject.getLocal( \"gxtkapp\" );\r\n'\t\tvar state:String=file.data.state;\r\n'\t\tfile.close();\r\n'\t\tif( state ) return state;\r\n\t\tReturn \"\"\r\n\tEndMethod\r\n\t\r\n\tMethod SaveState:Int( state:String )\r\n'\t\tvar file:SharedObject=SharedObject.getLocal( \"gxtkapp\" );\r\n'\t\tfile.data.state=state;\r\n'\t\tfile.close();\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod LoadString:String( path:String )\r\n\t\tpath = \"data\/\" + path\r\n\t\tReturn LoadText( path )\r\n\tEndMethod\r\n\t\r\n\t' ***** GXTK API *****\r\n\t\r\n\tMethod GraphicsDevice:gxtkGraphics()\r\n\t\tReturn ggraphics\r\n\tEndMethod\r\n\r\n\tMethod InputDevice:gxtkInput()\r\n\t\tReturn ginput\r\n\tEndMethod\r\n\r\n\tMethod AudioDevice:gxtkAudio()\r\n\t\tReturn gaudio\r\n\tEndMethod\r\n\r\n\tMethod SetUpdateRate:Int(hertz:Int)\r\n\t\tupdateRate = hertz\r\n\t\tIf Not vloading Then SetFrameRate(updateRate)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod MilliSecs:Int()\r\n\t\tReturn BlitzMaxMillisecs() - startMillis\r\n\tEndMethod\r\n\t\r\n\tMethod Loading:Int()\r\n\t\tReturn vloading\r\n\tEndMethod\r\n\r\n\tMethod OnCreate:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod OnUpdate:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod OnSuspend:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod OnResume:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod OnRender:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod OnLoading:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkGraphics\r\n\tField gmode:Int = 1\r\n\tField ix:Float=1,iy:Float,jx:Float,jy:Float=1,tx:Float,ty:Float\r\n\tField sx:Float=1,sy:Float=1,rot:Float=0\r\n\t\r\n\tMethod Mode:Int()\r\n\t\tReturn gmode\r\n\tEndMethod\r\n\t\r\n\tMethod Cls:Int(r:Int = 0, g:Int = 0, b:Int = 0)\r\n\t\tBlitzMaxCls(r, g, b)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawPoint:Int(x:Float, y:Float)\r\n\t\tLocal nx:Float = TransX(x,y)\r\n\t\tLocal ny:Float = TransY(x,y)\r\n\t\tPlot nx, ny\r\n\tEndMethod\r\n\t\r\n\tMethod LoadSurface:gxtkSurface(path:String)\r\n\t\tLocal image:TImage = LoadImage(\"data\/\"+path)\r\n\t\tIf image Then\r\n\t\t\tLocal gs:gxtkSurface = New gxtkSurface\r\n\t\t\tgs.setImage(image)\r\n\t\t\tReturn gs\r\n\t\tEndIf\r\n\t\tReturn Null\r\n\tEndMethod\r\n\t\r\n\tMethod BeginRender()\r\n\tEndMethod\r\n\t\r\n\tMethod EndRender()\r\n\t\tFlip\r\n\tEndMethod\r\n\t\r\n\tMethod SetColor:Int(r:Int, g:Int, b:Int)\r\n\t\tBlitzMaxSetColor(r, g, b)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod SetAlpha:Int(a:Float)\r\n\t\tBlitzMaxSetAlpha(a)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod SetBlend:Int(blend:Int)\r\n\t\tBlitzMaxSetBlend(blend)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod Width:Int()\r\n\t\tReturn GraphicsWidth()\r\n\tEndMethod\r\n\t\r\n\tMethod Height:Int()\r\n\t\tReturn GraphicsHeight()\r\n\tEndMethod\r\n\t\r\n\tMethod SetScissor:Int(x:Int, y:Int, w:Int, h:Int)\r\n\t\tSetViewport(x, y, w, h) ' NOT TESTED!\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod TransX:Float(x:Float, y:Float)\r\n\t\tReturn ix*x + jx*y + tx\r\n\tEndMethod\r\n\t\r\n\tMethod TransY:Float(x:Float, y:Float)\r\n\t\tReturn iy*x + jy*y + ty\r\n\tEndMethod\r\n\t\r\n\tMethod SetMatrix:Int(ix:Float,iy:Float,jx:Float,jy:Float,tx:Float,ty:Float)\r\n\t\tSelf.ix = ix ; Self.iy = iy\r\n\t\tSelf.jx = jx ; Self.jy = jy\r\n\t\tSelf.tx = tx ; Self.ty = ty\r\n\t\tsx = Sqr(ix*ix+iy*iy)\r\n\t\tsy = Sqr(jx*jx+jy*jy)\r\n\t\trot = Atan2( iy, ix )\r\n\t\tIf ix < 0 Then\r\n\t\t\tsx = -sx\r\n\t\t\trot :+ 180\r\n\t\tEndIf\r\n\t\tIf jy < 0 Then sy = -sy\r\n\t\tSetTransform( rot, sx, sy )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawSurface:Int(surface:gxtkSurface,x:Float,y:Float)\r\n\t\tLocal nx:Float = TransX(x,y)\r\n\t\tLocal ny:Float = TransY(x,y)\r\n\t\tDrawImage(surface.image, nx, ny, 0)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawSurface2:Int(surface:gxtkSurface,x:Float,y:Float, srcx:Int, srcy:Int, srcw:Int, srch:Int )\r\n\t\tLocal nx:Float = TransX(x,y)\r\n\t\tLocal ny:Float = TransY(x,y)\r\n\t\tDrawSubImageRect(surface.image, nx, ny, srcw, srch, srcx, srcy, srcw, srch)\t\t\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawLine:Int( x1:Float,y1:Float,x2:Float,y2:Float )\r\n\t\tLocal nx1:Float = TransX(x1,y1)\r\n\t\tLocal ny1:Float = TransY(x1,y1)\r\n\t\tLocal nx2:Float = TransX(x2,y2)\r\n\t\tLocal ny2:Float = TransY(x2,y2)\r\n\t\t' Need to reset transform so that BlitzMax doesn't try to apply rotation\r\n\t\tSetTransform( 0, 1, 1 )\r\n\t\tBlitzMaxDrawLine(nx1, ny1, nx2, ny2)\r\n\t\tSetTransform( rot, sx, sy )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawOval:Int( x:Float, y:Float, w:Float, h:Float )\r\n\t\tLocal nx:Float = TransX(x,y)\r\n\t\tLocal ny:Float = TransY(x,y)\r\n\t\tBlitzMaxDrawOval(nx, ny, w, h)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawPoly:Int(vertices:Float[])\r\n\t\t' setting the origin to use the current rotation translation\r\n\t\tSetOrigin(TransX(0,0), TransY(0,0))\r\n\t\tBlitzMaxDrawPoly( vertices )\r\n\t\tSetOrigin(0, 0)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawRect:Int( x:Float, y:Float, w:Float, h:Float )\r\n\t\tLocal nx:Float = TransX(x,y)\r\n\t\tLocal ny:Float = TransY(x,y)\r\n\t\tBlitzMaxDrawRect(nx, ny, w, h)\r\n\t\tReturn 0\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkInput\r\n\tMethod MouseX:Float()\r\n\t\tReturn BRL.PolledInput.MouseX()\r\n\tEndMethod\r\n\r\n\tMethod MouseY:Float()\r\n\t\tReturn BRL.PolledInput.MouseY()\r\n\tEndMethod\r\n\t\r\n\tMethod KeyDown:Int( key:Int )\r\n\t\tif( key = 384 ) key = 1 ' change TOUCH0 to MOUSE_LMB\r\n\r\n\t\tIf( key >= 1 And key <= 3 )\r\n\t\t\tReturn BRL.PolledInput.MouseDown( key )\r\n\t\tEndIf\r\n\t\tIf key < 256\r\n\t\t\tReturn BRL.PolledInput.KeyDown( key )\r\n\t\tElse\r\n\t\t\tReturn 0\r\n\t\tEndIf\r\n\tEndMethod\r\n\r\n\tMethod KeyHit:Int( key:Int )\r\n\t\tif( key = 384 ) key = 1 ' change TOUCH0 to MOUSE_LMB\r\n\t\tIf( key >= 1 And key <= 3 )\r\n\t\t\tReturn BRL.PolledInput.MouseHit( key )\r\n\t\tEndIf\r\n\t\tIf key < 256\r\n\t\t\tReturn BRL.PolledInput.KeyHit( key )\r\n\t\tElse\r\n\t\t\tReturn 0\r\n\t\tEndIf\r\n\tEndMethod\r\n\r\n\tMethod GetChar:Int()\r\n\t\tReturn BRL.PolledInput.GetChar()\r\n\tEndMethod\r\n\r\n\tMethod JoyX:Int( index:Int )\r\n\t\tReturn Pub.FreeJoy.JoyX( index )\r\n\tEndMethod\r\n\r\n\tMethod JoyY:Int( index:Int )\r\n\t\tReturn Pub.FreeJoy.JoyY( index )\r\n\tEndMethod\r\n\r\n\tMethod JoyZ:Int( index:Int )\r\n\t\tReturn Pub.FreeJoy.JoyZ( index )\r\n\tEndMethod\r\n\r\n\tMethod TouchX:Float( index:Int )\r\n\t\tReturn BRL.PolledInput.MouseX()\r\n\tEndMethod\r\n\r\n\tMethod TouchY:Float( index:Int )\r\n\t\tReturn BRL.PolledInput.MouseY()\r\n\tEndMethod\r\n\t\r\n\tMethod AccelX:Int()\r\n\t\treturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod AccelY:Int()\r\n\t\treturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod AccelZ:Int()\r\n\t\treturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod SetKeyboardEnabled:Int( enabled:int )\r\n\t\tReturn 0\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkChannel\r\n\tField channel:TChannel\t' null then not playing\r\n\tField sample:gxtkSample\r\n\tField loops:int\r\n\t'Field transform:SoundTransform=new SoundTransform()\r\n\t'Field pausepos:Number\r\n\tField state:int\r\n\t\r\n\tMethod New()\r\n\t\tchannel = New TChannel\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkAudio\r\n\tField amusicState:Int = 0\r\n\tField channels:gxtkChannel[] = New gxtkChannel[33]\r\n\t\r\n\tMethod New()\r\n\t\tFor local i:Int = 0 To 33 - 1\r\n\t\t\tchannels[i] = New gxtkChannel\r\n\t\tNext\r\n\tEndMethod\r\n\t\r\n\tMethod MusicState:Int()\r\n'\t\tIf( musicState = 1 And music.isPlaying() = False )\r\n'\t\t\tmusicState = 0;\r\n'\t\tEndif\r\n\t\tReturn amusicState\r\n\tEndMethod\r\n\t\r\n\tMethod PlayMusic:Int( path:String, flags:Int )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod ChannelState:int( channel:int )\r\n\t\tReturn -1\r\n\tEndMethod\r\n\t\r\n\tMethod StopMusic()\r\n\tEndMethod\r\n\t\r\n\tMethod StopChannel( channel:Int )\r\n\tEndMethod\r\n\r\n\tMethod PlaySample( sound:gxtkSample, channel:Int, flags:Int )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\t\r\n\t\t'If chan.state <> 0 Then chan.channel.Stop() <-- this crashes after the first play!?\r\n\t\t\r\n\t\tchan.sample = sound\r\n\t\t'chan.loops = flags ? 0x7fffffff : 0;\r\n\t\t'chan.channel = sample.sound.play( 0,chan.loops,chan.transform );\r\n\t\t'chan.channel = sound\r\n\t\tchan.state=1\r\n\t\r\n\t\tPlaySound( sound.sound, chan.channel )\r\n\tEndMethod\r\n\r\n\tMethod SetPan( channel:Int, pan:Float )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tchan.channel.SetPan(pan)\r\n\tEndMethod\r\n\r\n\tMethod SetRate( channel:Int, rate:Float )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tchan.channel.SetRate(rate)\r\n\tEndMethod\r\n\r\n\tMethod PauseMusic:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod ResumeMusic:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod SetMusicVolume:Int( volume:Float )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod SetVolume:Int( channel:Int, volume:Float )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tchan.channel.SetVolume(volume)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod LoadSample:gxtkSample( path:String )\r\n\t\tLocal extension:String = ExtractExt( path)\r\n\t\tIf extension = \"ogg\" Or extension = \"wav\" Then\r\n\t\t\tLocal sound:TSound = LoadSound(\"data\/\"+path)\r\n\t\t\tIf sound Then\r\n\t\t\t\tLocal gs:gxtkSample = New gxtkSample\r\n\t\t\t\tgs.setSound(sound)\r\n\t\t\t\tReturn gs\r\n\t\t\tEndIf\r\n\t\tElse\r\n\t\t\tRuntimeError \"BlitzMax can only use ogg and wav file formats\"\r\n\t\tEndIf\r\n\t\tReturn Null\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkSample\r\n\tField sound:TSound\r\n\t\r\n\tMethod setSound(sound:TSound)\r\n\t\tSelf.sound = sound\r\n\tEndMethod\r\n\t\r\n\tMethod Discard()\r\n\t\tSelf.sound = null\r\n\tEndMethod\r\nEndType\r\n\r\nFunction BlitzMaxDrawPoly:Int(vertices:Float[])\r\n\tDrawPoly vertices\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxDrawRect:Int( x:Float, y:Float, w:Float, h:Float )\r\n\tDrawRect x, y, w, h\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxDrawOval:Int( x:Float, y:Float, w:Float, h:Float )\r\n\tDrawOval x, y, w, h\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxDrawLine:Int( x1:Float,y1:Float,x2:Float,y2:Float )\r\n\tDrawLine x1, y1, x2, y2\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxMillisecs:Int()\r\n\tReturn MilliSecs()\r\nEndFunction\r\n\r\nFunction BlitzMaxSetColor(r:Int, g:Int, b:Int)\r\n\tSetColor(r, g, b)\r\nEndFunction\r\n\r\nFunction BlitzMaxSetBlend(blend:Int)\r\n\tSelect blend\r\n\t\tCase 0\r\n\t\t\tSetBlend( ALPHABLEND )\r\n\t\tCase 1\r\n\t\t\tSetBlend( LIGHTBLEND )\r\n\tEnd Select\r\nEndFunction\r\n\r\nFunction BlitzMaxSetAlpha(a:Float)\r\n\tSetAlpha(a)\r\nEndFunction\r\n\r\nFunction BlitzMaxCls(r:Int = 0, g:Int = 0, b:Int = 0)\r\n\tSetClsColor(r, g, b)\r\n\tCls\r\nEndFunction\r\n\r\nType gxtkSurface\r\n\tField w:Int, h:Int\r\n\tField image:TImage\r\n\t\r\n\tMethod setImage(image:TImage)\r\n\t\tSelf.image = image\r\n\tEndMethod\r\n\t\r\n\tMethod Width:Int()\r\n\t\tReturn image.Width\r\n\tEndMethod\r\n\t\r\n\tMethod Height:Int()\r\n\t\tReturn image.Height\r\n\tEndMethod\r\n\t\r\n\tMethod Discard()\r\n\tEndMethod\r\nEndType\r\n\r\n' ***** End mojo.bmax.bmx ******\r\n\r\n","old_contents":"' ***** Start mojo.bmax.bmx ******\r\n\r\nGlobal app:gxtkApp\r\n\r\nType gxtkApp\r\n\tField ginput:gxtkInput\r\n\tField gaudio:gxtkAudio\r\n\tField ggraphics:gxtkGraphics\r\n\r\n\tField dead:Int=0\r\n\tField suspended:Int=0\r\n\tField vloading:Int=0\r\n\tField maxloading:Int=0\r\n\tField updateRate:Int=0\r\n\tField nextUpdate:Float=0\r\n\tField updatePeriod:Float=0\r\n\tField startMillis:Float=0\r\n\t\r\n\tMethod New()' gxtkApp()\r\n\t\tapp=Self\r\n\t\tggraphics=New gxtkGraphics\r\n\tEndMethod\r\n\t\r\n\tMethod Setup()\r\n\t\tginput=New gxtkInput\r\n\t\tgaudio=New gxtkAudio\r\n\r\n\t\tbb_input__1Set_1Input_1Device(ginput)\r\n\t\tbb_audio__1Set_1Audio_1Device(gaudio)\r\n\t\t\r\n\t\tstartMillis=BlitzMaxMillisecs()\r\n\t\t\r\n\t\tSetFrameRate( 0 )\r\n\t\t\r\n\t\tInvokeOnCreate()\r\n\t\tInvokeOnRender()\r\n\t\tUpdate()\r\n\tEndMethod\r\n\t\r\n\tMethod Update()\r\n\t\tWhile Not AppTerminate()\r\n\t\t\tIf Not updatePeriod return\r\n\t\t\tLocal updates:Int = 0\r\n\t\t\t\r\n\t\t\tRepeat\r\n\t\t\t\tnextUpdate:+updatePeriod\r\n\t\t\t\tInvokeOnUpdate()\r\n\t\t\t\tIf Not updatePeriod Then Exit\r\n\t\t\t\tIf nextUpdate>BlitzMaxMillisecs() Then Exit\r\n\t\t\t\tupdates:+1\r\n\t\t\t\tIf updates = 7 Then\r\n\t\t\t\t\tnextUpdate = BlitzMaxMillisecs()\r\n\t\t\t\t\tExit\r\n\t\t\t\tEndIf\r\n\t\t\tForever\r\n\t\t\tInvokeOnRender()\r\n\t\t\tLocal del:Int = nextUpdate - BlitzMaxMillisecs()\r\n\t\t\tIf del < 1 Then del = 1\r\n\t\t\tDelay(del)\r\n\t\tWend\r\n\tEndMethod\r\n\t\r\n\tMethod InvokeOnCreate()\r\n\t\tIf dead Return\r\n\t\tdead = 1\r\n\t\tOnCreate()\r\n\t\tdead = 0\r\n\tEndMethod\r\n\r\n\tMethod InvokeOnUpdate()\r\n\t\tIf dead Or suspended Or Not updateRate Or vloading Return\r\n\t\tOnUpdate()\r\n\tEndMethod\r\n\t\r\n\tMethod InvokeOnRender()\r\n\t\tIf dead Or suspended Return\r\n\t\tggraphics.BeginRender()\r\n\t\tIf vloading\r\n\t\t\tOnLoading()\r\n\t\tElse\r\n\t\t\tOnRender()\r\n\t\tEndIf\r\n\t\tggraphics.EndRender()\r\n\tEndMethod\r\n\t\r\n\t\r\n\tMethod SetFrameRate( fps:Int )\r\n\t\tIf fps\r\n\t\t\tupdatePeriod=1000.0\/fps\r\n\t\t\tnextUpdate=BlitzMaxMillisecs() +updatePeriod\r\n\t\tElse\r\n\t\t\tupdatePeriod=0\r\n\t\tEndIf\r\n\tEndMethod\r\n\r\n\tMethod LoadState:String()\r\n'\t\tvar file:SharedObject=SharedObject.getLocal( \"gxtkapp\" );\r\n'\t\tvar state:String=file.data.state;\r\n'\t\tfile.close();\r\n'\t\tif( state ) return state;\r\n\t\tReturn \"\"\r\n\tEndMethod\r\n\t\r\n\tMethod SaveState:Int( state:String )\r\n'\t\tvar file:SharedObject=SharedObject.getLocal( \"gxtkapp\" );\r\n'\t\tfile.data.state=state;\r\n'\t\tfile.close();\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod LoadString:String( path:String )\r\n\t\tpath = \"data\/\" + path\r\n\t\tReturn LoadText( path )\r\n\tEndMethod\r\n\t\r\n\t' ***** GXTK API *****\r\n\t\r\n\tMethod GraphicsDevice:gxtkGraphics()\r\n\t\tReturn ggraphics\r\n\tEndMethod\r\n\r\n\tMethod InputDevice:gxtkInput()\r\n\t\tReturn ginput\r\n\tEndMethod\r\n\r\n\tMethod AudioDevice:gxtkAudio()\r\n\t\tReturn gaudio\r\n\tEndMethod\r\n\r\n\tMethod SetUpdateRate:Int(hertz:Int)\r\n\t\tupdateRate = hertz\r\n\t\tIf Not vloading Then SetFrameRate(updateRate)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod MilliSecs:Int()\r\n\t\tReturn BlitzMaxMillisecs() - startMillis\r\n\tEndMethod\r\n\t\r\n\tMethod Loading:Int()\r\n\t\tReturn vloading\r\n\tEndMethod\r\n\r\n\tMethod OnCreate:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod OnUpdate:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod OnSuspend:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod OnResume:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod OnRender:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod OnLoading:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkGraphics\r\n\tField gmode:Int = 1\r\n\tField ix:Float=1,iy:Float,jx:Float,jy:Float=1,tx:Float,ty:Float\r\n\tField sx:Float=1,sy:Float=1,rot:Float=0\r\n\t\r\n\tMethod Mode:Int()\r\n\t\tReturn gmode\r\n\tEndMethod\r\n\t\r\n\tMethod Cls:Int(r:Int = 0, g:Int = 0, b:Int = 0)\r\n\t\tBlitzMaxCls(r, g, b)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawPoint:Int(x:Float, y:Float)\r\n\t\tLocal nx:Float = TransX(x,y)\r\n\t\tLocal ny:Float = TransY(x,y)\r\n\t\tPlot nx, ny\r\n\tEndMethod\r\n\t\r\n\tMethod LoadSurface:gxtkSurface(path:String)\r\n\t\tLocal image:TImage = LoadImage(\"data\/\"+path)\r\n\t\tIf image Then\r\n\t\t\tLocal gs:gxtkSurface = New gxtkSurface\r\n\t\t\tgs.setImage(image)\r\n\t\t\tReturn gs\r\n\t\tEndIf\r\n\t\tReturn Null\r\n\tEndMethod\r\n\t\r\n\tMethod BeginRender()\r\n\tEndMethod\r\n\t\r\n\tMethod EndRender()\r\n\t\tFlip\r\n\tEndMethod\r\n\t\r\n\tMethod SetColor:Int(r:Int, g:Int, b:Int)\r\n\t\tBlitzMaxSetColor(r, g, b)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod SetAlpha:Int(a:Float)\r\n\t\tBlitzMaxSetAlpha(a)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod SetBlend:Int(blend:Int)\r\n\t\tBlitzMaxSetBlend(blend)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod Width:Int()\r\n\t\tReturn GraphicsWidth()\r\n\tEndMethod\r\n\t\r\n\tMethod Height:Int()\r\n\t\tReturn GraphicsHeight()\r\n\tEndMethod\r\n\t\r\n\tMethod SetScissor:Int(x:Int, y:Int, w:Int, h:Int)\r\n\t\tSetViewport(x, y, w, h) ' NOT TESTED!\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod TransX:Float(x:Float, y:Float)\r\n\t\tReturn ix*x + jx*y + tx\r\n\tEndMethod\r\n\t\r\n\tMethod TransY:Float(x:Float, y:Float)\r\n\t\tReturn iy*x + jy*y + ty\r\n\tEndMethod\r\n\t\r\n\tMethod SetMatrix:Int(ix:Float,iy:Float,jx:Float,jy:Float,tx:Float,ty:Float)\r\n\t\tSelf.ix = ix ; Self.iy = iy\r\n\t\tSelf.jx = jx ; Self.jy = jy\r\n\t\tSelf.tx = tx ; Self.ty = ty\r\n\t\tsx = Sqr( (ix*ix) + (jx*jx) )\r\n\t\tsy = Sqr( (iy*iy) + (jy*jy) )\r\n\t\trot = -Atan2( jx, ix )\r\n\t\tSetTransform( rot, sx, sy )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawSurface:Int(surface:gxtkSurface,x:Float,y:Float)\r\n\t\tLocal nx:Float = TransX(x,y)\r\n\t\tLocal ny:Float = TransY(x,y)\r\n\t\tDrawImage(surface.image, nx, ny, 0)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawSurface2:Int(surface:gxtkSurface,x:Float,y:Float, srcx:Int, srcy:Int, srcw:Int, srch:Int )\r\n\t\tLocal nx:Float = TransX(x,y)\r\n\t\tLocal ny:Float = TransY(x,y)\r\n\t\tDrawSubImageRect(surface.image, nx, ny, srcw, srch, srcx, srcy, srcw, srch)\t\t\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawLine:Int( x1:Float,y1:Float,x2:Float,y2:Float )\r\n\t\tLocal nx1:Float = TransX(x1,y1)\r\n\t\tLocal ny1:Float = TransY(x1,y1)\r\n\t\tLocal nx2:Float = TransX(x2,y2)\r\n\t\tLocal ny2:Float = TransY(x2,y2)\r\n\t\t' Need to reset transform so that BlitzMax doesn't try to apply rotation\r\n\t\tSetTransform( 0, 1, 1 )\r\n\t\tBlitzMaxDrawLine(nx1, ny1, nx2, ny2)\r\n\t\tSetTransform( rot, sx, sy )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawOval:Int( x:Float, y:Float, w:Float, h:Float )\r\n\t\tLocal nx:Float = TransX(x,y)\r\n\t\tLocal ny:Float = TransY(x,y)\r\n\t\tBlitzMaxDrawOval(nx, ny, w, h)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawPoly:Int(vertices:Float[])\r\n\t\t' setting the origin to use the current rotation translation\r\n\t\tSetOrigin(TransX(0,0), TransY(0,0))\r\n\t\tBlitzMaxDrawPoly( vertices )\r\n\t\tSetOrigin(0, 0)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawRect:Int( x:Float, y:Float, w:Float, h:Float )\r\n\t\tLocal nx:Float = TransX(x,y)\r\n\t\tLocal ny:Float = TransY(x,y)\r\n\t\tBlitzMaxDrawRect(nx, ny, w, h)\r\n\t\tReturn 0\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkInput\r\n\tMethod MouseX:Float()\r\n\t\tReturn BRL.PolledInput.MouseX()\r\n\tEndMethod\r\n\r\n\tMethod MouseY:Float()\r\n\t\tReturn BRL.PolledInput.MouseY()\r\n\tEndMethod\r\n\t\r\n\tMethod KeyDown:Int( key:Int )\r\n\t\tif( key = 384 ) key = 1 ' change TOUCH0 to MOUSE_LMB\r\n\r\n\t\tIf( key >= 1 And key <= 3 )\r\n\t\t\tReturn BRL.PolledInput.MouseDown( key )\r\n\t\tEndIf\r\n\t\tIf key < 256\r\n\t\t\tReturn BRL.PolledInput.KeyDown( key )\r\n\t\tElse\r\n\t\t\tReturn 0\r\n\t\tEndIf\r\n\tEndMethod\r\n\r\n\tMethod KeyHit:Int( key:Int )\r\n\t\tif( key = 384 ) key = 1 ' change TOUCH0 to MOUSE_LMB\r\n\t\tIf( key >= 1 And key <= 3 )\r\n\t\t\tReturn BRL.PolledInput.MouseHit( key )\r\n\t\tEndIf\r\n\t\tIf key < 256\r\n\t\t\tReturn BRL.PolledInput.KeyHit( key )\r\n\t\tElse\r\n\t\t\tReturn 0\r\n\t\tEndIf\r\n\tEndMethod\r\n\r\n\tMethod GetChar:Int()\r\n\t\tReturn BRL.PolledInput.GetChar()\r\n\tEndMethod\r\n\r\n\tMethod JoyX:Int( index:Int )\r\n\t\tReturn Pub.FreeJoy.JoyX( index )\r\n\tEndMethod\r\n\r\n\tMethod JoyY:Int( index:Int )\r\n\t\tReturn Pub.FreeJoy.JoyY( index )\r\n\tEndMethod\r\n\r\n\tMethod JoyZ:Int( index:Int )\r\n\t\tReturn Pub.FreeJoy.JoyZ( index )\r\n\tEndMethod\r\n\r\n\tMethod TouchX:Float( index:Int )\r\n\t\tReturn BRL.PolledInput.MouseX()\r\n\tEndMethod\r\n\r\n\tMethod TouchY:Float( index:Int )\r\n\t\tReturn BRL.PolledInput.MouseY()\r\n\tEndMethod\r\n\t\r\n\tMethod AccelX:Int()\r\n\t\treturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod AccelY:Int()\r\n\t\treturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod AccelZ:Int()\r\n\t\treturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod SetKeyboardEnabled:Int( enabled:int )\r\n\t\tReturn 0\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkChannel\r\n\tField channel:TChannel\t' null then not playing\r\n\tField sample:gxtkSample\r\n\tField loops:int\r\n\t'Field transform:SoundTransform=new SoundTransform()\r\n\t'Field pausepos:Number\r\n\tField state:int\r\n\t\r\n\tMethod New()\r\n\t\tchannel = New TChannel\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkAudio\r\n\tField amusicState:Int = 0\r\n\tField channels:gxtkChannel[] = New gxtkChannel[33]\r\n\t\r\n\tMethod New()\r\n\t\tFor local i:Int = 0 To 33 - 1\r\n\t\t\tchannels[i] = New gxtkChannel\r\n\t\tNext\r\n\tEndMethod\r\n\t\r\n\tMethod MusicState:Int()\r\n'\t\tIf( musicState = 1 And music.isPlaying() = False )\r\n'\t\t\tmusicState = 0;\r\n'\t\tEndif\r\n\t\tReturn amusicState\r\n\tEndMethod\r\n\t\r\n\tMethod PlayMusic:Int( path:String, flags:Int )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod ChannelState:int( channel:int )\r\n\t\tReturn -1\r\n\tEndMethod\r\n\t\r\n\tMethod StopMusic()\r\n\tEndMethod\r\n\t\r\n\tMethod StopChannel( channel:Int )\r\n\tEndMethod\r\n\r\n\tMethod PlaySample( sound:gxtkSample, channel:Int, flags:Int )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\t\r\n\t\t'If chan.state <> 0 Then chan.channel.Stop() <-- this crashes after the first play!?\r\n\t\t\r\n\t\tchan.sample = sound\r\n\t\t'chan.loops = flags ? 0x7fffffff : 0;\r\n\t\t'chan.channel = sample.sound.play( 0,chan.loops,chan.transform );\r\n\t\t'chan.channel = sound\r\n\t\tchan.state=1\r\n\t\r\n\t\tPlaySound( sound.sound, chan.channel )\r\n\tEndMethod\r\n\r\n\tMethod SetPan( channel:Int, pan:Float )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tchan.channel.SetPan(pan)\r\n\tEndMethod\r\n\r\n\tMethod SetRate( channel:Int, rate:Float )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tchan.channel.SetRate(rate)\r\n\tEndMethod\r\n\r\n\tMethod PauseMusic:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod ResumeMusic:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod SetMusicVolume:Int( volume:Float )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod SetVolume:Int( channel:Int, volume:Float )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tchan.channel.SetVolume(volume)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod LoadSample:gxtkSample( path:String )\r\n\t\tLocal extension:String = ExtractExt( path)\r\n\t\tIf extension = \"ogg\" Or extension = \"wav\" Then\r\n\t\t\tLocal sound:TSound = LoadSound(\"data\/\"+path)\r\n\t\t\tIf sound Then\r\n\t\t\t\tLocal gs:gxtkSample = New gxtkSample\r\n\t\t\t\tgs.setSound(sound)\r\n\t\t\t\tReturn gs\r\n\t\t\tEndIf\r\n\t\tElse\r\n\t\t\tRuntimeError \"BlitzMax can only use ogg and wav file formats\"\r\n\t\tEndIf\r\n\t\tReturn Null\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkSample\r\n\tField sound:TSound\r\n\t\r\n\tMethod setSound(sound:TSound)\r\n\t\tSelf.sound = sound\r\n\tEndMethod\r\n\t\r\n\tMethod Discard()\r\n\t\tSelf.sound = null\r\n\tEndMethod\r\nEndType\r\n\r\nFunction BlitzMaxDrawPoly:Int(vertices:Float[])\r\n\tDrawPoly vertices\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxDrawRect:Int( x:Float, y:Float, w:Float, h:Float )\r\n\tDrawRect x, y, w, h\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxDrawOval:Int( x:Float, y:Float, w:Float, h:Float )\r\n\tDrawOval x, y, w, h\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxDrawLine:Int( x1:Float,y1:Float,x2:Float,y2:Float )\r\n\tDrawLine x1, y1, x2, y2\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxMillisecs:Int()\r\n\tReturn MilliSecs()\r\nEndFunction\r\n\r\nFunction BlitzMaxSetColor(r:Int, g:Int, b:Int)\r\n\tSetColor(r, g, b)\r\nEndFunction\r\n\r\nFunction BlitzMaxSetBlend(blend:Int)\r\n\tSelect blend\r\n\t\tCase 0\r\n\t\t\tSetBlend( ALPHABLEND )\r\n\t\tCase 1\r\n\t\t\tSetBlend( LIGHTBLEND )\r\n\tEnd Select\r\nEndFunction\r\n\r\nFunction BlitzMaxSetAlpha(a:Float)\r\n\tSetAlpha(a)\r\nEndFunction\r\n\r\nFunction BlitzMaxCls(r:Int = 0, g:Int = 0, b:Int = 0)\r\n\tSetClsColor(r, g, b)\r\n\tCls\r\nEndFunction\r\n\r\nType gxtkSurface\r\n\tField w:Int, h:Int\r\n\tField image:TImage\r\n\t\r\n\tMethod setImage(image:TImage)\r\n\t\tSelf.image = image\r\n\tEndMethod\r\n\t\r\n\tMethod Width:Int()\r\n\t\tReturn image.Width\r\n\tEndMethod\r\n\t\r\n\tMethod Height:Int()\r\n\t\tReturn image.Height\r\n\tEndMethod\r\n\t\r\n\tMethod Discard()\r\n\tEndMethod\r\nEndType\r\n\r\n' ***** End mojo.bmax.bmx ******\r\n\r\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"5af8d03d78bd24982e68295bacadb5ef4eac72b6","subject":"Added missing (forgotten) import for brl.Threads. Closes #1.","message":"Added missing (forgotten) import for brl.Threads. Closes #1.","repos":"nilium\/lugi.mod,nilium\/lugi.mod","old_file":"generator.mod\/generator.bmx","new_file":"generator.mod\/generator.bmx","new_contents":"Rem\n\tLuGI - Copyright (c) 2009 Noel R. Cower\n\n\tPermission is hereby granted, free of charge, to any person obtaining a copy\n\tof this software and associated documentation files (the \"Software\"), to deal\n\tin the Software without restriction, including without limitation the rights\n\tto use, copy, modify, merge, publish, distribute, sublicense, and\/or sell\n\tcopies of the Software, and to permit persons to whom the Software is\n\tfurnished to do so, subject to the following conditions:\n\n\tThe above copyright notice and this permission notice shall be included in\n\tall copies or substantial portions of the Software.\n\n\tTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n\tIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n\tFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n\tAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n\tLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n\tOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n\tTHE SOFTWARE.\nEndRem\n\nSuperStrict\n\nModule LuGI.Generator\n\nModuleInfo \"Name: LuGI Code Generator\"\nModuleInfo \"Description: Default code generator for Lua glue code used by LuGI\"\nModuleInfo \"Author: Noel Cower\"\nModuleInfo \"License: MIT\"\nModuleInfo \"URL:
http:\/\/github.com\/nilium\/lugi.mod\/<\/a>\"\n\nImport brl.LinkedList\nImport brl.Map\nImport brl.Random\nImport brl.Reflection\nImport brl.Stream\nImport Brl.System\n?Threaded\nImport brl.Threads\n?\n\nPrivate\n\nInclude \"utility.bmx\"\n\n' The actually meat of the code here...\nInclude \"metadata.bmx\"\nInclude \"method.bmx\"\nInclude \"field.bmx\"\nInclude \"type.bmx\"\n\nPublic\n\nFunction GenerateGlueCode(url:Object = Null)\n\tAssert url Else \"GenerateGlueCode: No output URL provided\"\n\t\n\t' Clear existing types (in case the code is generating multiple wrappers)\n\tClearExposedTypes()\n\t\n\tLocal output:TStream = OpenStream(url, False, True)\n\tAssert output Else \"GenerateGlueCode: Unable to create writeable output stream\"\n\t\n\tSeedRndWithDateTime\n\t\n\tBuildTypeInfo()\n\t\n\toutput.WriteString(\"Private~n~n\")\n\t\n\tFor Local t:LExposedType = EachIn LExposedType.EnumTypes()\n\t\tLocal outs$ = t.Implementation()\n\t\tIf outs Then\n\t\t\toutput.WriteLine(\"'---- \"+t.name)\n\t\t\toutput.WriteString(outs)\n\t\tEndIf\n\tNext\n\t\n\tLocal pretag$ = GenerateUniqueTag(16)\n\tLocal posttag$ = GenerateUniqueTag(16)\n\t\n\t' Generate the initialization function\n\toutput.WriteLine(\"Function \"+LUGI_GLOBAL_PREFIX+LUGI_INIT_PREFIX+\"pre_\"+pretag+\"(lua_vm:Byte Ptr, register_field(off%, typ%, name$, class@ Ptr), register_method(luafn:Int(state:Byte Ptr), name$, class@ Ptr))\")\n\t\n\tFor Local t:LExposedType = EachIn LExposedType.EnumTypes()\n\t\toutput.WriteString(t.PreInitBlock()+\"~n\")\n\tNext\n\t\n\toutput.WriteLine(\"End Function\")\n\toutput.WriteString(\"New LuGIInitFunction.PreInit(\"+LUGI_GLOBAL_PREFIX+LUGI_INIT_PREFIX+\"pre_\"+pretag+\")~n~n~n\")\n\t\n\toutput.WriteLine(\"Function \"+LUGI_GLOBAL_PREFIX+LUGI_INIT_PREFIX+\"post_\"+posttag+\"(lua_vm:Byte Ptr, constructor:Int(state:Byte Ptr))\")\n\t\n\t' Any initialization code following the exposure (e.g., setting global constructors and such)\n\tFor Local t:LExposedType = EachIn LExposedType.EnumTypes()\n\t\toutput.WriteString(t.PostInitBlock())\n\tNext\n\t\n\toutput.WriteLine(\"End Function\")\n\toutput.WriteString(\"New LuGIInitFunction.PostInit(\"+LUGI_GLOBAL_PREFIX+LUGI_INIT_PREFIX+\"post_\"+posttag+\")~n~n~n\")\n\t\n\toutput.WriteString(\"~nPublic~n~n\")\n\t\n\toutput.Flush\n\toutput.Close\nEnd Function\n","old_contents":"Rem\n\tLuGI - Copyright (c) 2009 Noel R. Cower\n\n\tPermission is hereby granted, free of charge, to any person obtaining a copy\n\tof this software and associated documentation files (the \"Software\"), to deal\n\tin the Software without restriction, including without limitation the rights\n\tto use, copy, modify, merge, publish, distribute, sublicense, and\/or sell\n\tcopies of the Software, and to permit persons to whom the Software is\n\tfurnished to do so, subject to the following conditions:\n\n\tThe above copyright notice and this permission notice shall be included in\n\tall copies or substantial portions of the Software.\n\n\tTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n\tIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n\tFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n\tAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n\tLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n\tOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n\tTHE SOFTWARE.\nEndRem\n\nSuperStrict\n\nModule LuGI.Generator\n\nModuleInfo \"Name: LuGI Code Generator\"\nModuleInfo \"Description: Default code generator for Lua glue code used by LuGI\"\nModuleInfo \"Author: Noel Cower\"\nModuleInfo \"License: MIT\"\nModuleInfo \"URL: http:\/\/github.com\/nilium\/lugi.mod\/<\/a>\"\n\nImport brl.LinkedList\nImport brl.Map\nImport brl.Random\nImport brl.Reflection\nImport brl.Stream\nImport Brl.System\n\nPrivate\n\nInclude \"utility.bmx\"\n\n' The actually meat of the code here...\nInclude \"metadata.bmx\"\nInclude \"method.bmx\"\nInclude \"field.bmx\"\nInclude \"type.bmx\"\n\nPublic\n\nFunction GenerateGlueCode(url:Object = Null)\n\tAssert url Else \"GenerateGlueCode: No output URL provided\"\n\t\n\t' Clear existing types (in case the code is generating multiple wrappers)\n\tClearExposedTypes()\n\t\n\tLocal output:TStream = OpenStream(url, False, True)\n\tAssert output Else \"GenerateGlueCode: Unable to create writeable output stream\"\n\t\n\tSeedRndWithDateTime\n\t\n\tBuildTypeInfo()\n\t\n\toutput.WriteString(\"Private~n~n\")\n\t\n\tFor Local t:LExposedType = EachIn LExposedType.EnumTypes()\n\t\tLocal outs$ = t.Implementation()\n\t\tIf outs Then\n\t\t\toutput.WriteLine(\"'---- \"+t.name)\n\t\t\toutput.WriteString(outs)\n\t\tEndIf\n\tNext\n\t\n\tLocal pretag$ = GenerateUniqueTag(16)\n\tLocal posttag$ = GenerateUniqueTag(16)\n\t\n\t' Generate the initialization function\n\toutput.WriteLine(\"Function \"+LUGI_GLOBAL_PREFIX+LUGI_INIT_PREFIX+\"pre_\"+pretag+\"(lua_vm:Byte Ptr, register_field(off%, typ%, name$, class@ Ptr), register_method(luafn:Int(state:Byte Ptr), name$, class@ Ptr))\")\n\t\n\tFor Local t:LExposedType = EachIn LExposedType.EnumTypes()\n\t\toutput.WriteString(t.PreInitBlock()+\"~n\")\n\tNext\n\t\n\toutput.WriteLine(\"End Function\")\n\toutput.WriteString(\"New LuGIInitFunction.PreInit(\"+LUGI_GLOBAL_PREFIX+LUGI_INIT_PREFIX+\"pre_\"+pretag+\")~n~n~n\")\n\t\n\toutput.WriteLine(\"Function \"+LUGI_GLOBAL_PREFIX+LUGI_INIT_PREFIX+\"post_\"+posttag+\"(lua_vm:Byte Ptr, constructor:Int(state:Byte Ptr))\")\n\t\n\t' Any initialization code following the exposure (e.g., setting global constructors and such)\n\tFor Local t:LExposedType = EachIn LExposedType.EnumTypes()\n\t\toutput.WriteString(t.PostInitBlock())\n\tNext\n\t\n\toutput.WriteLine(\"End Function\")\n\toutput.WriteString(\"New LuGIInitFunction.PostInit(\"+LUGI_GLOBAL_PREFIX+LUGI_INIT_PREFIX+\"post_\"+posttag+\")~n~n~n\")\n\t\n\toutput.WriteString(\"~nPublic~n~n\")\n\t\n\toutput.Flush\n\toutput.Close\nEnd Function\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"4b41c5475cb46ef542ead56fe278c31b03d5e67f","subject":"more informative","message":"more informative\n\njust a list of names is less helpful when you've forgotten what's\nprinting it\n","repos":"Leushenko\/blue-moon","old_file":"debugfold.bmx","new_file":"debugfold.bmx","new_contents":"\n' This FOLD delegate is intended for debugging others\n\n'enumerate keys (compiler debug tool: make sure all are handled and none are wrong)\n'this prints all keys not handled by the given fold delegate (given nothing, it just prints all keys)\nType Debug_KeyListFold\n\tField cache:TMap, handled:TMap\n\tFunction Make:Debug_KeyListFold(over:Object = Null)\n\t\tLocal d:Debug_KeyListFold = New Self\n\t\td.cache = CreateMap() ; If over Then d.handled = Node.BuildCache(over)\n\t\tReturn d\n\tEnd Function\n\t\n\tFunction Run(funs:FunDef[], over:Object)\n\t\tLocal dbg:Debug_KeyListFold = Self.Make(over)\n\t\tFor Local f:FunDef = EachIn funs\n\t\t\tNode.Fold(f.n, dbg)\n\t\tNext\n\t\tIf Not dbg.cache.IsEmpty() Then Print \"Debug nodes:\"\n\t\tFor Local s:String = EachIn dbg.cache.Keys()\n\t\t\tPrint \" \" + s\n\t\tNext\n\tEnd Function\n\t\n\tMethod any:Node(n:Node)\n\t\tIf handled = Null Or handled.ValueForKey(n.key) = Null Then cache.Insert(n.key, \"@\")\n\t\tReturn n\n\tEnd Method\nEnd Type\n\n","old_contents":"\n' This FOLD delegate is intended for debugging others\n\n'enumerate keys (compiler debug tool: make sure all are handled and none are wrong)\n'this prints all keys not handled by the given fold delegate (given nothing, it just prints all keys)\nType Debug_KeyListFold\n\tField cache:TMap, handled:TMap\n\tFunction Make:Debug_KeyListFold(over:Object = Null)\n\t\tLocal d:Debug_KeyListFold = New Self\n\t\td.cache = CreateMap() ; If over Then d.handled = Node.BuildCache(over)\n\t\tReturn d\n\tEnd Function\n\t\n\tFunction Run(funs:FunDef[], over:Object)\n\t\tLocal dbg:Debug_KeyListFold = Self.Make(over)\n\t\tFor Local f:FunDef = EachIn funs\n\t\t\tNode.Fold(f.n, dbg)\n\t\tNext\n\t\tFor Local s:String = EachIn dbg.cache.Keys()\n\t\t\tPrint s\n\t\tNext\n\tEnd Function\n\t\n\tMethod any:Node(n:Node)\n\t\tIf handled = Null Or handled.ValueForKey(n.key) = Null Then cache.Insert(n.key, \"@\")\n\t\tReturn n\n\tEnd Method\nEnd Type\n\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"844fa73148e71044fdc3308c4f013cce8d80e667","subject":"mxUserInputDriverGUI","message":"mxUserInputDriverGUI\n\nrefs gh-17\n","repos":"maximos\/maximus","old_file":"src\/userinput.bmx","new_file":"src\/userinput.bmx","new_contents":"\nRem\n\tbbdoc: User Input interface\nEnd Rem\nType mxUserInput\n\n\tRem\n\t\tbbdoc:Command Line Interface\n\tEnd Rem\n\tConst c_cli:Byte = 0\n\t\n\tRem\n\t\tbbdoc:Graphical User Interface\n\tEnd Rem\n\tConst c_gui:Byte = 1\n\n\tField m_driver:mxUserInputDriver\n\t\n\tRem\n\t\tbbdoc: Factory for initializing mxUserInput object\n\t\tabout: interface can be either c_cli of c_gui\n\tEnd Rem\n\tFunction factory:mxUserInput(interface:Byte)\n\t\tLocal ui:mxUserInput = New mxUserInput\n\t\tSelect interface\n\t\t\tCase c_cli\n\t\t\t\tui.m_driver = New mxUserInputDriverCLI\n\t\t\tCase c_gui\n\t\t\t\tui.m_driver = New mxUserInputDriverGUI\n\t\tEnd Select\n\t\tReturn ui\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Ask user to confirm an action\n\t\treturns: True or False\n\tEnd Rem\n\tMethod Confirm:Byte(question:String)\n\t\tReturn Self.m_driver.Confirm(question)\n\tEnd Method\n\nEnd Type\n\nRem\n\tbbdoc: User Input Driver interface\nEnd Rem\nType mxUserInputDriver Abstract\n\t\n\tRem\n\t\tbbdoc: Ask user to confirm an action\n\t\treturns: True or False\n\tEnd Rem\n\tMethod Confirm:Byte(question:String) Abstract\n\t\nEnd Type\n\n\t\nRem\n\tbbdoc: UserInpitDriver for Command Line Interface\nEnd Rem\nType mxUserInputDriverCLI Extends mxUserInputDriver\n\t\n\tRem\n\t\tbbdoc: Ask user to confirm an action\n\t\treturns: True or False\n\tEnd Rem\n\tMethod Confirm:Byte(question:String)\n\t\tLocal resp:String = Input(question + \" \").ToLower()\n\t\tIf resp = \"y\" Or resp = \"yes\"\n\t\t\tReturn True\n\t\tElse\n\t\t\tReturn False\n\t\tEnd If\n\tEnd Method\n\nEnd Type\n\nType mxUserInputDriverGUI Extends mxUserInputDriver\n\tRem\n\t\tbbdoc:Ask user to confirm an action\n\tEnd Rem\n\tMethod Confirm:Byte(question:String)\n\t\tReturn Confirm(question)\n\tEnd Method\n\nEnd Type","old_contents":"\nRem\n\tbbdoc: User Input interface\nEnd Rem\nType mxUserInput\n\n\tRem\n\t\tbbdoc:Command Line Interface\n\tEnd Rem\n\tConst c_cli:Byte = 0\n\t\n\tRem\n\t\tbbdoc:Graphical User Interface\n\tEnd Rem\n\tConst c_gui:Byte = 1\n\n\tField m_driver:mxUserInputDriver\n\t\n\tRem\n\t\tbbdoc: Factory for initializing mxUserInput object\n\t\tabout: interface can be either c_cli of c_gui\n\tEnd Rem\n\tFunction factory:mxUserInput(interface:Byte)\n\t\tLocal ui:mxUserInput = New mxUserInput\n\t\tSelect interface\n\t\t\tCase c_cli\n\t\t\t\tui.m_driver = New mxUserInputDriverCLI\n\t\t\tCase c_gui\n\t\t\t\tRuntimeError(\"GUI driver not yet supported!\")\n\t\tEnd Select\n\t\tReturn ui\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Ask user to confirm an action\n\t\treturns: True or False\n\tEnd Rem\n\tMethod Confirm:Byte(question:String)\n\t\tReturn Self.m_driver.Confirm(question)\n\tEnd Method\n\nEnd Type\n\nRem\n\tbbdoc: User Input Driver interface\nEnd Rem\nType mxUserInputDriver Abstract\n\t\n\tRem\n\t\tbbdoc: Ask user to confirm an action\n\t\treturns: True or False\n\tEnd Rem\n\tMethod Confirm:Byte(question:String) Abstract\n\t\nEnd Type\n\n\t\nRem\n\tbbdoc: UserInpitDriver for Command Line Interface\nEnd Rem\nType mxUserInputDriverCLI Extends mxUserInputDriver\n\t\n\tRem\n\t\tbbdoc: Ask user to confirm an action\n\t\treturns: True or False\n\tEnd Rem\n\tMethod Confirm:Byte(question:String)\n\t\tLocal resp:String = Input(question + \" \").ToLower()\n\t\tIf resp = \"y\" Or resp = \"yes\"\n\t\t\tReturn True\n\t\tElse\n\t\t\tReturn False\n\t\tEnd If\n\tEnd Method\n\nEnd Type\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"05d6fde9a32063d4185b79eb3853f5ba2e4d9fae","subject":"Maximus now identifies itself to servers as: Maximus\/ (;)","message":"Maximus now identifies itself to servers as: Maximus\/ (;)\n","repos":"maximos\/maximus","old_file":"src\/module.bmx","new_file":"src\/module.bmx","new_contents":"\nRem\nCopyright (c) 2010 Tim Howard\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and\/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\nEnd Rem\n\nRem\n\tbbdoc: Maximus module base.\n\tabout: An abstract type for the similarities between module scopes and modules.\nEnd Rem\nType mxModuleBase Abstract\n\t\n\tField m_name:String, m_description:String\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the base's name.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetName(name:String)\n\t\tAssert name, \"(mxModuleBase.SetName) name cannot be Null!\"\n\t\tm_name = name\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the base's name.\n\t\treturns: The base's name.\n\tEnd Rem\n\tMethod GetName:String()\n\t\tReturn m_name\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the base's description.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetDescription(description:String)\n\t\tAssert description, \"(mxModuleBase.SetDescription) description cannot be Null!\"\n\t\tm_description = description\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the base's description.\n\t\treturns: The base's description.\n\tEnd Rem\n\tMethod GetDescription:String()\n\t\tReturn m_description\n\tEnd Method\n\t\n'#end region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set a common field from the given variable.\n\t\treturns: True if the given variable was handled, or False if it was not.\n\tEnd Rem\n\tMethod SetCommonFromVariable:Int(variable:dVariable)\n\t\tSelect variable.GetName().ToLower()\n\t\t\tCase \"desc\"\n\t\t\t\tSetDescription(variable.ValueAsString())\n\t\t\t\tReturn True\n\t\tEnd Select\n\t\tReturn False\n\tEnd Method\n\t\nEnd Type\n\nRem\n\tbbdoc: Maximus module scope.\nEnd Rem\nType mxModuleScope Extends mxModuleBase\n\t\n\tField m_modules:dObjectMap\n\t\n\tMethod New()\n\t\tm_modules = New dObjectMap\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Add the given module to the scope.\n\t\treturns: True if the module was added, or False if it was not (the module is Null).\n\tEnd Rem\n\tMethod AddModule:Int(modul:mxModule)\n\t\tIf modul <> Null\n\t\t\tm_modules._Insert(modul.GetName(), modul)\n\t\t\tmodul.SetParent(Self)\n\t\t\tReturn True\n\t\tEnd If\n\t\tReturn False\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Check if the given module name is found in the scope.\n\t\treturns: True if the given module was found in the scope, or False if it was not.\n\tEnd Rem\n\tMethod HasModule:Int(modname:String)\n\t\tReturn m_modules._Contains(modname)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get a module with the given name.\n\t\treturns: The module with the given name, or Null if there is no module with the given name.\n\tEnd Rem\n\tMethod GetModuleWithName:mxModule(modname:String)\n\t\tReturn mxModule(m_modules._ValueByKey(modname))\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Load the given dJObject into the scope.\n\t\treturns: Itself, or Null if @root is Null.\n\tEnd Rem\n\tMethod FromJSON:mxModuleScope(root:dJObject)\n\t\tIf root <> Null\n\t\t\tSetName(root.GetName())\n\t\t\tFor Local variable:dVariable = EachIn root.GetValues()\n\t\t\t\tIf dJObject(variable)\n\t\t\t\t\tAddModule(New mxModule.FromJSON(dJObject(variable)))\n\t\t\t\tElse\n\t\t\t\t\tSetCommonFromVariable(variable)\n\t\t\t\tEnd If\n\t\t\tNext\n\t\t\tReturn Self\n\t\tEnd If\n\t\tReturn Null\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the module enumerator for the scope.\n\t\treturns: The module enumerator for the scope.\n\tEnd Rem\n\tMethod ModuleEnumerator:TMapEnumerator()\n\t\tReturn m_modules.ValueEnumerator()\n\tEnd Method\n\t\nEnd Type\n\nRem\n\tbbdoc: Maximus module.\nEnd Rem\nType mxModule Extends mxModuleBase\n\t\n\tField m_parent:mxModuleScope\n\tField m_versions:dObjectMap\n\t\n\tMethod New()\n\t\tm_versions = New dObjectMap\n\tEnd Method\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the module's parent.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetParent(parent:mxModuleScope)\n\t\tm_parent = parent\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the module's parent.\n\t\treturns: The module's parent.\n\tEnd Rem\n\tMethod GetParent:mxModuleScope()\n\t\tReturn m_parent\n\tEnd Method\n\t\n'#end region Field accessors\n\t\n\tRem\n\t\tbbdoc: Add the given version to the module.\n\t\treturns: True if the version was added, or False if it was not (the version is Null).\n\tEnd Rem\n\tMethod AddVersion:Int(version:mxModuleVersion)\n\t\tIf version <> Null\n\t\t\tm_versions._Insert(version.GetName(), version)\n\t\t\tversion.SetParent(Self)\n\t\t\tReturn True\n\t\tEnd If\n\t\tReturn False\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Check if there is a version with the given name.\n\t\treturns: True if the version was found, or False if it was not.\n\tEnd Rem\n\tMethod HasVersion:Int(name:String)\n\t\tReturn m_versions._Contains(name)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get a version with the given name.\n\t\treturns: The version with the given name, or Null if there is no version with the given name.\n\tEnd Rem\n\tMethod GetVersionWithName:mxModuleVersion(name:String)\n\t\tReturn mxModuleVersion(m_versions._ValueByKey(name))\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the latest (non-dev) version for this module.\n\t\treturns: The latest version for this module.\n\tEnd Rem\n\tMethod GetLatestVersion:mxModuleVersion()\n\t\tLocal hver:mxModuleVersion\n\t\tFor Local ver:mxModuleVersion = EachIn VersionEnumerator()\n\t\t\tIf ver.GetName() <> \"dev\"\n\t\t\t\tIf hver = Null Or hver.Compare(ver) = 1\n\t\t\t\t\thver = ver\n\t\t\t\tEnd If\n\t\t\tEnd If\n\t\tNext\n\t\tReturn hver\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set a common field from the given variable.\n\t\treturns: True if the given variable was handled, or False if it was not.\n\tEnd Rem\n\tMethod SetCommonFromVariable:Int(variable:dVariable)\n\t\tIf Super.SetCommonFromVariable(variable) = True\n\t\t\tReturn True\n\t\tElse\n\t\t\tSelect variable.GetName().ToLower()\n\t\t\t\tCase \"versions\"\n\t\t\t\t\tFor Local jobj:dJObject = EachIn dJObject(variable).GetValues()\n\t\t\t\t\t\tAddVersion(New mxModuleVersion.FromJSON(jobj))\n\t\t\t\t\tNext\n\t\t\tEnd Select\n\t\t\tReturn False\n\t\tEnd If\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Load the given dJObject into the module.\n\t\treturns: Itself, or Null if @root is Null.\n\tEnd Rem\n\tMethod FromJSON:mxModule(root:dJObject)\n\t\tIf root <> Null\n\t\t\tSetName(root.GetName())\n\t\t\tFor Local variable:dVariable = EachIn root.GetValues()\n\t\t\t\tSetCommonFromVariable(variable)\n\t\t\tNext\n\t\t\tReturn Self\n\t\tEnd If\n\t\tReturn Null\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the version enumerator for the module.\n\t\treturns: The version enumerator for the module.\n\tEnd Rem\n\tMethod VersionEnumerator:TMapEnumerator()\n\t\tReturn m_versions.ValueEnumerator()\n\tEnd Method\n\t\nEnd Type\n\nRem\n\tbbdoc: Maximus module version.\nEnd Rem\nType mxModuleVersion\n\t\n\tField m_parent:mxModule\n\tField m_name:String, m_url:String\n\tField m_dependencies:mxModuleDependencies\n\t\n\tMethod New()\n\t\tm_dependencies = New mxModuleDependencies\n\tEnd Method\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the version's parent.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetParent(parent:mxModule)\n\t\tm_parent = parent\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the version's parent.\n\t\treturns: The version's parent.\n\tEnd Rem\n\tMethod GetParent:mxModule()\n\t\tReturn m_parent\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the version's name.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetName(name:String)\n\t\tAssert name, \"(mxModuleVersion.SetName) name cannot be Null!\"\n\t\tm_name = name\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the version's name.\n\t\treturns: The version's name.\n\tEnd Rem\n\tMethod GetName:String()\n\t\tReturn m_name\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the version's url.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetUrl(url:String)\n\t\tAssert url, \"(mxModuleVersion.SetUrl) url cannot be Null!\"\n\t\tm_url = url\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the version's url.\n\t\treturns: The version's url.\n\tEnd Rem\n\tMethod GetUrl:String()\n\t\tReturn m_url\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the temporary fetch path for the version's source archive.\n\t\treturns: The temporary file path for the version's source archive.\n\tEnd Rem\n\tMethod GetTemporaryFilePath:String()\n\t\tReturn \"tmp\/\" + StripDir(GetUrl())\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the version's dependencies.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetDependencies(dependencies:mxModuleDependencies)\n\t\tm_dependencies = dependencies\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the version's dependencies.\n\t\treturns: The version's dependencies.\n\tEnd Rem\n\tMethod GetDependencies:mxModuleDependencies()\n\t\tReturn m_dependencies\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the version parts for the version.\n\t\treturns: True if the version is development, in which case the parameters are both 0; or False, in which case the parameters are set accordingly.\n\tEnd Rem\n\tMethod GetVersionParts:Int(vmajor:String Var, vminor:String Var)\n\t\tIf m_name <> \"dev\"\n\t\t\tLocal i:Int = m_name.Find(\".\")\n\t\t\tIf i > -1\n\t\t\t\tvmajor = m_name[..i]\n\t\t\t\tvminor = m_name[i + 1..]\n\t\t\tElse\n\t\t\t\tvmajor = m_name ' I'm not sure what other version formats would be used, so I'm just playing a random card here\n\t\t\tEnd If\n\t\t\tReturn False\n\t\tEnd If\n\t\tReturn True\n\tEnd Method\n\t\n'#end region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set a common field from the given variable.\n\t\treturns: True if the given variable was handled, or False if it was not.\n\tEnd Rem\n\tMethod SetCommonFromVariable:Int(variable:dVariable)\n\t\tSelect variable.GetName().ToLower()\n\t\t\tCase \"url\"\n\t\t\t\tSetUrl(variable.ValueAsString())\n\t\t\tCase \"deps\"\n\t\t\t\tm_dependencies.FromJSON(dJArray(variable))\n\t\t\t\tReturn True\n\t\tEnd Select\n\t\tReturn False\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Load the given dJObject into the version.\n\t\treturns: Itself, or Null if @root is Null.\n\tEnd Rem\n\tMethod FromJSON:mxModuleVersion(root:dJObject)\n\t\tIf root <> Null\n\t\t\tSetName(root.GetName())\n\t\t\tFor Local variable:dVariable = EachIn root.GetValues()\n\t\t\t\tSetCommonFromVariable(variable)\n\t\t\tNext\n\t\t\tReturn Self\n\t\tEnd If\n\t\tReturn Null\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the dependency enumerator for the version.\n\t\treturns: The dependency enumerator for the version.\n\tEnd Rem\n\tMethod DependencyEnumerator:TMapEnumerator()\n\t\tReturn m_dependencies.DependencyEnumerator()\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Compare the version with the given version.\n\t\treturns: 0 if the two versions are the same (same in version number alone), 1 if this version is greater than the given, or -1 if the given version is greater than this version.\n\tEnd Rem\n\tMethod Compare:Int(with:Object)\n\t\tLocal ver:mxModuleVersion = mxModuleVersion(with)\n\t\tIf ver <> Null\n\t\t\tIf m_name = ver.m_name\n\t\t\t\tReturn 0\n\t\t\tElse\n\t\t\t\tLocal smajor:String, sminor:String, wmajor:String, wminor:String\n\t\t\t\tLocal sdev:Int = GetVersionParts(smajor, sminor), wdev:Int = ver.GetVersionParts(wmajor, wminor)\n\t\t\t\tIf (sdev = True And wdev = True) Or (smajor = wmajor And sminor = wminor)\n\t\t\t\t\tReturn 0\n\t\t\t\tElse If smajor > wmajor\n\t\t\t\t\tReturn 1\n\t\t\t\tElse If smajor = wmajor\n\t\t\t\t\tIf sminor > wminor\n\t\t\t\t\t\tReturn 1\n\t\t\t\t\tElse\n\t\t\t\t\t\tReturn -1\n\t\t\t\t\tEnd If\n\t\t\t\tElse\n\t\t\t\t\tReturn -1\n\t\t\t\tEnd If\n\t\t\tEnd If\n\t\tEnd If\n\t\tReturn 0\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Fetch the version's source archive.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod FetchSourceArchive()\n\t\tLocal file:String = GetTemporaryFilePath()\n\t\tlogger.LogMessage(\"fetching: \" + GetUrl() + \" -> \" + file + \"~t\", False)\n\t\tIf FileType(file) = FILETYPE_NONE\n\t\t\tLocal stream:TStream = WriteFileExplicitly(file)\n\t\t\tIf stream <> Null\n\t\t\t\tLocal request:TRESTRequest = New TRESTRequest, response:TRESTResponse\n\t\t\t\trequest.SetProgressCallback(_ProgressCallback, New _mxProgressStore)\n\t\t\t\trequest.SetStream(stream)\n\t\t\t\tTry\n\t\t\t\t\tLocal os:String\n\t\t\t\t\t?Win32\n\t\t\t\t\t\tos = \"Windows\"\n\t\t\t\t\t?Linux\n\t\t\t\t\t\tos = \"Linux\"\n\t\t\t\t\t?MacOS\n\t\t\t\t\t\tos = \"MacOS\"\n\t\t\t\t\t?\n\t\t\t\t\t\n\t\t\t\t\tLocal language:String\n\t\t\t\t\tIf mainapp.m_locale Then language = mainapp.m_locale.GetName()\n\t\t\t\t\t\n\t\t\t\t\tresponse = request.Call(GetUrl(), [\"User-Agent: Maximus\/\" + mxApp.c_version + \" (\" + os + \"; \" + language + \")\"], \"GET\")\n\t\t\t\tCatch e:Object\n\t\t\t\t\tstream.Close()\n\t\t\t\t\tDeleteFile(file)\n\t\t\t\t\tlogger.LogMessage(\"\")\n\t\t\t\t\tThrowError(_s(\"error.fetch.error\", [e.ToString()]))\n\t\t\t\tEnd Try\n\t\t\t\tstream.Close()\n\t\t\t\tIf response.responseCode = 200\n\t\t\t\t\tlogger.LogMessage(_s(\"message.fetch.done\", [String(response.responseCode)]))\n\t\t\t\tElse\n\t\t\t\t\tDeleteFile(file)\n\t\t\t\t\tlogger.LogMessage(\"\")\n\t\t\t\t\tThrowError(_s(\"error.fetch.error\", [\"Bad response code: \" + String(response.responseCode)]))\n\t\t\t\tEnd If\n\t\t\tElse\n\t\t\t\tThrowError(_s(\"error.writeperms\", [file]))\n\t\t\tEnd If\n\t\tElse\n\t\t\tlogger.LogMessage(_s(\"message.fetch.alreadyfetched\"))\n\t\tEnd If\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Progress callback for source archive fetching.\n\t\treturns: Zero (no error).\n\tEnd Rem\n\tFunction _ProgressCallback:Int(data:Object, dltotal:Double, dlnow:Double, ultotal:Double, ulnow:Double)\n\t\tLocal store:_mxProgressStore = _mxProgressStore(data)\n\t\tLocal prog:Int = (dlnow \/ dltotal) * 100\n\t\tIf prog > store.m_progress + 5\n\t\t\tstore.m_progress = prog\n\t\t\tWriteStdOut(\".\")\n\t\tEnd If\n\t\tReturn 0\n\tEnd Function\n\t\nEnd Type\n\nRem\n\tbbdoc: Maximus temporary progress storage for archive fetching.\nEnd Rem\nType _mxProgressStore\n\t\n\tField m_progress:Int = 0\n\t\nEnd Type\n\n","old_contents":"\nRem\nCopyright (c) 2010 Tim Howard\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and\/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\nEnd Rem\n\nRem\n\tbbdoc: Maximus module base.\n\tabout: An abstract type for the similarities between module scopes and modules.\nEnd Rem\nType mxModuleBase Abstract\n\t\n\tField m_name:String, m_description:String\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the base's name.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetName(name:String)\n\t\tAssert name, \"(mxModuleBase.SetName) name cannot be Null!\"\n\t\tm_name = name\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the base's name.\n\t\treturns: The base's name.\n\tEnd Rem\n\tMethod GetName:String()\n\t\tReturn m_name\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the base's description.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetDescription(description:String)\n\t\tAssert description, \"(mxModuleBase.SetDescription) description cannot be Null!\"\n\t\tm_description = description\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the base's description.\n\t\treturns: The base's description.\n\tEnd Rem\n\tMethod GetDescription:String()\n\t\tReturn m_description\n\tEnd Method\n\t\n'#end region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set a common field from the given variable.\n\t\treturns: True if the given variable was handled, or False if it was not.\n\tEnd Rem\n\tMethod SetCommonFromVariable:Int(variable:dVariable)\n\t\tSelect variable.GetName().ToLower()\n\t\t\tCase \"desc\"\n\t\t\t\tSetDescription(variable.ValueAsString())\n\t\t\t\tReturn True\n\t\tEnd Select\n\t\tReturn False\n\tEnd Method\n\t\nEnd Type\n\nRem\n\tbbdoc: Maximus module scope.\nEnd Rem\nType mxModuleScope Extends mxModuleBase\n\t\n\tField m_modules:dObjectMap\n\t\n\tMethod New()\n\t\tm_modules = New dObjectMap\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Add the given module to the scope.\n\t\treturns: True if the module was added, or False if it was not (the module is Null).\n\tEnd Rem\n\tMethod AddModule:Int(modul:mxModule)\n\t\tIf modul <> Null\n\t\t\tm_modules._Insert(modul.GetName(), modul)\n\t\t\tmodul.SetParent(Self)\n\t\t\tReturn True\n\t\tEnd If\n\t\tReturn False\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Check if the given module name is found in the scope.\n\t\treturns: True if the given module was found in the scope, or False if it was not.\n\tEnd Rem\n\tMethod HasModule:Int(modname:String)\n\t\tReturn m_modules._Contains(modname)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get a module with the given name.\n\t\treturns: The module with the given name, or Null if there is no module with the given name.\n\tEnd Rem\n\tMethod GetModuleWithName:mxModule(modname:String)\n\t\tReturn mxModule(m_modules._ValueByKey(modname))\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Load the given dJObject into the scope.\n\t\treturns: Itself, or Null if @root is Null.\n\tEnd Rem\n\tMethod FromJSON:mxModuleScope(root:dJObject)\n\t\tIf root <> Null\n\t\t\tSetName(root.GetName())\n\t\t\tFor Local variable:dVariable = EachIn root.GetValues()\n\t\t\t\tIf dJObject(variable)\n\t\t\t\t\tAddModule(New mxModule.FromJSON(dJObject(variable)))\n\t\t\t\tElse\n\t\t\t\t\tSetCommonFromVariable(variable)\n\t\t\t\tEnd If\n\t\t\tNext\n\t\t\tReturn Self\n\t\tEnd If\n\t\tReturn Null\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the module enumerator for the scope.\n\t\treturns: The module enumerator for the scope.\n\tEnd Rem\n\tMethod ModuleEnumerator:TMapEnumerator()\n\t\tReturn m_modules.ValueEnumerator()\n\tEnd Method\n\t\nEnd Type\n\nRem\n\tbbdoc: Maximus module.\nEnd Rem\nType mxModule Extends mxModuleBase\n\t\n\tField m_parent:mxModuleScope\n\tField m_versions:dObjectMap\n\t\n\tMethod New()\n\t\tm_versions = New dObjectMap\n\tEnd Method\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the module's parent.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetParent(parent:mxModuleScope)\n\t\tm_parent = parent\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the module's parent.\n\t\treturns: The module's parent.\n\tEnd Rem\n\tMethod GetParent:mxModuleScope()\n\t\tReturn m_parent\n\tEnd Method\n\t\n'#end region Field accessors\n\t\n\tRem\n\t\tbbdoc: Add the given version to the module.\n\t\treturns: True if the version was added, or False if it was not (the version is Null).\n\tEnd Rem\n\tMethod AddVersion:Int(version:mxModuleVersion)\n\t\tIf version <> Null\n\t\t\tm_versions._Insert(version.GetName(), version)\n\t\t\tversion.SetParent(Self)\n\t\t\tReturn True\n\t\tEnd If\n\t\tReturn False\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Check if there is a version with the given name.\n\t\treturns: True if the version was found, or False if it was not.\n\tEnd Rem\n\tMethod HasVersion:Int(name:String)\n\t\tReturn m_versions._Contains(name)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get a version with the given name.\n\t\treturns: The version with the given name, or Null if there is no version with the given name.\n\tEnd Rem\n\tMethod GetVersionWithName:mxModuleVersion(name:String)\n\t\tReturn mxModuleVersion(m_versions._ValueByKey(name))\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the latest (non-dev) version for this module.\n\t\treturns: The latest version for this module.\n\tEnd Rem\n\tMethod GetLatestVersion:mxModuleVersion()\n\t\tLocal hver:mxModuleVersion\n\t\tFor Local ver:mxModuleVersion = EachIn VersionEnumerator()\n\t\t\tIf ver.GetName() <> \"dev\"\n\t\t\t\tIf hver = Null Or hver.Compare(ver) = 1\n\t\t\t\t\thver = ver\n\t\t\t\tEnd If\n\t\t\tEnd If\n\t\tNext\n\t\tReturn hver\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set a common field from the given variable.\n\t\treturns: True if the given variable was handled, or False if it was not.\n\tEnd Rem\n\tMethod SetCommonFromVariable:Int(variable:dVariable)\n\t\tIf Super.SetCommonFromVariable(variable) = True\n\t\t\tReturn True\n\t\tElse\n\t\t\tSelect variable.GetName().ToLower()\n\t\t\t\tCase \"versions\"\n\t\t\t\t\tFor Local jobj:dJObject = EachIn dJObject(variable).GetValues()\n\t\t\t\t\t\tAddVersion(New mxModuleVersion.FromJSON(jobj))\n\t\t\t\t\tNext\n\t\t\tEnd Select\n\t\t\tReturn False\n\t\tEnd If\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Load the given dJObject into the module.\n\t\treturns: Itself, or Null if @root is Null.\n\tEnd Rem\n\tMethod FromJSON:mxModule(root:dJObject)\n\t\tIf root <> Null\n\t\t\tSetName(root.GetName())\n\t\t\tFor Local variable:dVariable = EachIn root.GetValues()\n\t\t\t\tSetCommonFromVariable(variable)\n\t\t\tNext\n\t\t\tReturn Self\n\t\tEnd If\n\t\tReturn Null\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the version enumerator for the module.\n\t\treturns: The version enumerator for the module.\n\tEnd Rem\n\tMethod VersionEnumerator:TMapEnumerator()\n\t\tReturn m_versions.ValueEnumerator()\n\tEnd Method\n\t\nEnd Type\n\nRem\n\tbbdoc: Maximus module version.\nEnd Rem\nType mxModuleVersion\n\t\n\tField m_parent:mxModule\n\tField m_name:String, m_url:String\n\tField m_dependencies:mxModuleDependencies\n\t\n\tMethod New()\n\t\tm_dependencies = New mxModuleDependencies\n\tEnd Method\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the version's parent.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetParent(parent:mxModule)\n\t\tm_parent = parent\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the version's parent.\n\t\treturns: The version's parent.\n\tEnd Rem\n\tMethod GetParent:mxModule()\n\t\tReturn m_parent\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the version's name.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetName(name:String)\n\t\tAssert name, \"(mxModuleVersion.SetName) name cannot be Null!\"\n\t\tm_name = name\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the version's name.\n\t\treturns: The version's name.\n\tEnd Rem\n\tMethod GetName:String()\n\t\tReturn m_name\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the version's url.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetUrl(url:String)\n\t\tAssert url, \"(mxModuleVersion.SetUrl) url cannot be Null!\"\n\t\tm_url = url\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the version's url.\n\t\treturns: The version's url.\n\tEnd Rem\n\tMethod GetUrl:String()\n\t\tReturn m_url\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the temporary fetch path for the version's source archive.\n\t\treturns: The temporary file path for the version's source archive.\n\tEnd Rem\n\tMethod GetTemporaryFilePath:String()\n\t\tReturn \"tmp\/\" + StripDir(GetUrl())\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the version's dependencies.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetDependencies(dependencies:mxModuleDependencies)\n\t\tm_dependencies = dependencies\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the version's dependencies.\n\t\treturns: The version's dependencies.\n\tEnd Rem\n\tMethod GetDependencies:mxModuleDependencies()\n\t\tReturn m_dependencies\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the version parts for the version.\n\t\treturns: True if the version is development, in which case the parameters are both 0; or False, in which case the parameters are set accordingly.\n\tEnd Rem\n\tMethod GetVersionParts:Int(vmajor:String Var, vminor:String Var)\n\t\tIf m_name <> \"dev\"\n\t\t\tLocal i:Int = m_name.Find(\".\")\n\t\t\tIf i > -1\n\t\t\t\tvmajor = m_name[..i]\n\t\t\t\tvminor = m_name[i + 1..]\n\t\t\tElse\n\t\t\t\tvmajor = m_name ' I'm not sure what other version formats would be used, so I'm just playing a random card here\n\t\t\tEnd If\n\t\t\tReturn False\n\t\tEnd If\n\t\tReturn True\n\tEnd Method\n\t\n'#end region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set a common field from the given variable.\n\t\treturns: True if the given variable was handled, or False if it was not.\n\tEnd Rem\n\tMethod SetCommonFromVariable:Int(variable:dVariable)\n\t\tSelect variable.GetName().ToLower()\n\t\t\tCase \"url\"\n\t\t\t\tSetUrl(variable.ValueAsString())\n\t\t\tCase \"deps\"\n\t\t\t\tm_dependencies.FromJSON(dJArray(variable))\n\t\t\t\tReturn True\n\t\tEnd Select\n\t\tReturn False\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Load the given dJObject into the version.\n\t\treturns: Itself, or Null if @root is Null.\n\tEnd Rem\n\tMethod FromJSON:mxModuleVersion(root:dJObject)\n\t\tIf root <> Null\n\t\t\tSetName(root.GetName())\n\t\t\tFor Local variable:dVariable = EachIn root.GetValues()\n\t\t\t\tSetCommonFromVariable(variable)\n\t\t\tNext\n\t\t\tReturn Self\n\t\tEnd If\n\t\tReturn Null\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the dependency enumerator for the version.\n\t\treturns: The dependency enumerator for the version.\n\tEnd Rem\n\tMethod DependencyEnumerator:TMapEnumerator()\n\t\tReturn m_dependencies.DependencyEnumerator()\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Compare the version with the given version.\n\t\treturns: 0 if the two versions are the same (same in version number alone), 1 if this version is greater than the given, or -1 if the given version is greater than this version.\n\tEnd Rem\n\tMethod Compare:Int(with:Object)\n\t\tLocal ver:mxModuleVersion = mxModuleVersion(with)\n\t\tIf ver <> Null\n\t\t\tIf m_name = ver.m_name\n\t\t\t\tReturn 0\n\t\t\tElse\n\t\t\t\tLocal smajor:String, sminor:String, wmajor:String, wminor:String\n\t\t\t\tLocal sdev:Int = GetVersionParts(smajor, sminor), wdev:Int = ver.GetVersionParts(wmajor, wminor)\n\t\t\t\tIf (sdev = True And wdev = True) Or (smajor = wmajor And sminor = wminor)\n\t\t\t\t\tReturn 0\n\t\t\t\tElse If smajor > wmajor\n\t\t\t\t\tReturn 1\n\t\t\t\tElse If smajor = wmajor\n\t\t\t\t\tIf sminor > wminor\n\t\t\t\t\t\tReturn 1\n\t\t\t\t\tElse\n\t\t\t\t\t\tReturn -1\n\t\t\t\t\tEnd If\n\t\t\t\tElse\n\t\t\t\t\tReturn -1\n\t\t\t\tEnd If\n\t\t\tEnd If\n\t\tEnd If\n\t\tReturn 0\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Fetch the version's source archive.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod FetchSourceArchive()\n\t\tLocal file:String = GetTemporaryFilePath()\n\t\tlogger.LogMessage(\"fetching: \" + GetUrl() + \" -> \" + file + \"~t\", False)\n\t\tIf FileType(file) = FILETYPE_NONE\n\t\t\tLocal stream:TStream = WriteFileExplicitly(file)\n\t\t\tIf stream <> Null\n\t\t\t\tLocal request:TRESTRequest = New TRESTRequest, response:TRESTResponse\n\t\t\t\trequest.SetProgressCallback(_ProgressCallback, New _mxProgressStore)\n\t\t\t\trequest.SetStream(stream)\n\t\t\t\tTry\n\t\t\t\t\tresponse = request.Call(GetUrl(), Null, \"GET\")\n\t\t\t\tCatch e:Object\n\t\t\t\t\tstream.Close()\n\t\t\t\t\tDeleteFile(file)\n\t\t\t\t\tlogger.LogMessage(\"\")\n\t\t\t\t\tThrowError(_s(\"error.fetch.error\", [e.ToString()]))\n\t\t\t\tEnd Try\n\t\t\t\tstream.Close()\n\t\t\t\tIf response.responseCode = 200\n\t\t\t\t\tlogger.LogMessage(_s(\"message.fetch.done\", [String(response.responseCode)]))\n\t\t\t\tElse\n\t\t\t\t\tDeleteFile(file)\n\t\t\t\t\tlogger.LogMessage(\"\")\n\t\t\t\t\tThrowError(_s(\"error.fetch.error\", [\"Bad response code: \" + String(response.responseCode)]))\n\t\t\t\tEnd If\n\t\t\tElse\n\t\t\t\tThrowError(_s(\"error.writeperms\", [file]))\n\t\t\tEnd If\n\t\tElse\n\t\t\tlogger.LogMessage(_s(\"message.fetch.alreadyfetched\"))\n\t\tEnd If\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Progress callback for source archive fetching.\n\t\treturns: Zero (no error).\n\tEnd Rem\n\tFunction _ProgressCallback:Int(data:Object, dltotal:Double, dlnow:Double, ultotal:Double, ulnow:Double)\n\t\tLocal store:_mxProgressStore = _mxProgressStore(data)\n\t\tLocal prog:Int = (dlnow \/ dltotal) * 100\n\t\tIf prog > store.m_progress + 5\n\t\t\tstore.m_progress = prog\n\t\t\tWriteStdOut(\".\")\n\t\tEnd If\n\t\tReturn 0\n\tEnd Function\n\t\nEnd Type\n\nRem\n\tbbdoc: Maximus temporary progress storage for archive fetching.\nEnd Rem\nType _mxProgressStore\n\t\n\tField m_progress:Int = 0\n\t\nEnd Type\n\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"fb1b27bdec874659ea1bb65b190c842cf1889fcd","subject":"Fixed camera range issues approaching zero.","message":"Fixed camera range issues approaching zero.\n","repos":"kfprimm\/maxb3d,kfprimm\/maxb3d","old_file":"d3d9driver.mod\/d3d9driver.bmx","new_file":"d3d9driver.mod\/d3d9driver.bmx","new_contents":"\nStrict\n\nRem\n\tbbdoc: Direct3D 9 renderer for MaxB3D\nEnd Rem\nModule MaxB3D.D3D9Driver\nModuleInfo \"Author: Kevin Primm\"\nModuleInfo \"License: MIT\"\n\nImport MaxB3D.Core\nImport Prime.D3D9Max2DEx\nImport Prime.DirectXEx\n\n?Win32\n\nImport \"d3d9.cpp\"\n\nPrivate \n\nExtern \"C\"\n\tFunction maxb3dD3D9VertexElements:Byte Ptr()'=\"_maxb3dD3D9VertexElements@0\"\nEnd Extern\n\nFunction GetD3D9MaxB3DVertexDecl:IDirect3DVertexDeclaration9(d3ddev:IDirect3DDevice9)\n\tGlobal decl:IDirect3DVertexDeclaration9,dev:IDirect3DDevice9\n\tIf decl=Null Or dev<>d3ddev\n\t\tAssert d3ddev.CreateVertexDeclaration(maxb3dD3D9VertexElements(),decl)=D3D_OK,\"Failed to create vertex declaration.\"\n\t\tdev=d3ddev\n\tEndIf\n\tReturn decl\nEnd Function\n\nFunction Pow2Size( n )\n\tLocal t=1\n\tWhile tNull\n\t\t\t_d3ddev=TD3D9Graphics(TMax2DGraphics(g)._graphics).GetDirect3DDevice()\n\t\t\tEndMax2D\n\t\tEndIf\n\tEnd Method\n\t\t\n\tMethod MakeBuffer:TBuffer(src:Object,width,height,flags)\n\t\tReturn TMax2DExDriver(_parent).MakeBuffer(src,width,height,flags)\n\tEnd Method\n\t\n\tMethod GetCaps:TCaps()\n\t\tLocal caps:TCaps=New TCaps\n\t\tReturn caps\n\tEnd Method\n\t\n\tMethod Abbr$()\n\t\tReturn \"d3d9\"\n\tEnd Method\n\t\n\tMethod SetMax2D(enable)\n\t\tIf enable\n\t\t\tGlobal identity:TMatrix=TMatrix.Identity()\n\t\t\tLocal width=GraphicsWidth(),height=GraphicsHeight()\n\t\t\tLocal matrix#[]=[..\n\t\t\t2.0\/width,0.0,0.0,0.0,..\n\t\t\t 0.0,-2.0\/height,0.0,0.0,..\n\t\t\t 0.0,0.0,1.0,0.0,..\n\t\t\t -1-(1.0\/width),1+(1.0\/height),1.0,1.0]\n\t\t\t\n\t\t\tSetBlend -1\n\t\t\tSetBlend SOLIDBLEND\n\t\t\t\n\t\t\t_d3ddev.SetTransform D3DTS_PROJECTION,matrix\n\t\t\t_d3ddev.SetTransform D3DTS_WORLD,identity.ToPtr()\n\t\t\t_d3ddev.SetTransform D3DTS_VIEW,identity.ToPtr()\n\t\t\t_d3ddev.SetTransform D3DTS_TEXTURE0,identity.ToPtr()\n\t\t\t\n\t\t\t_d3ddev.SetVertexDeclaration Null\n\t\t\t_d3ddev.SetIndices Null\n\t\t\t_d3ddev.SetFVF D3DFVF_XYZ|D3DFVF_DIFFUSE|D3DFVF_TEX1\n\t\t\t\n\t\t\t_d3ddev.SetRenderState D3DRS_LIGHTING,False\n\t\t\t_d3ddev.SetRenderState D3DRS_ZENABLE,False\n\t\t\t_d3ddev.SetRenderState D3DRS_SCISSORTESTENABLE,_viewporton\t\t\n\t\t\t\n\t\t\t_d3ddev.SetRenderState D3DRS_ALPHATESTENABLE,True\n\t\t\t\n\t\t\tFor Local i=1 To 7\n\t\t\t\t_d3ddev.SetTexture i,Null\n\t\t\tNext\n\t\t\t\t\n\t\t\t_d3ddev.SetFVF D3DFVF_XYZ|D3DFVF_DIFFUSE|D3DFVF_TEX1\n\t\t\t\n\t\t\t_d3ddev.SetTextureStageState 0,D3DTSS_COLOROP,D3DTOP_MODULATE\n\t\t\t_d3ddev.SetTextureStageState 0,D3DTSS_ALPHAOP,D3DTOP_MODULATE\n\t\t\t\n\t\t\t_d3ddev.SetTextureStageState 0,D3DTSS_ADDRESS,D3DTADDRESS_CLAMP\n\t\t\n\t\t\t_d3ddev.SetTextureStageState 0,D3DTSS_MAGFILTER,D3DTFG_POINT\n\t\t\t_d3ddev.SetTextureStageState 0,D3DTSS_MINFILTER,D3DTFN_POINT\n\t\t\t_d3ddev.SetTextureStageState 0,D3DTSS_MIPFILTER,D3DTFP_POINT\n\t\t\t\n\t\t\t_d3ddev.SetRenderState D3DRS_FOGENABLE,False\n\t\t\t\t\t\t\t\t\n\t\t\t_d3ddev.SetRenderState D3DRS_CULLMODE,D3DCULL_NONE\n\t\t\t_d3ddev.SetRenderState D3DRS_FILLMODE,D3DFILL_SOLID\n\t\tElse\n\t\t\t_d3ddev.SetRenderState D3DRS_ZENABLE,True\n\t\t\t_d3ddev.SetRenderState D3DRS_ZWRITEENABLE,True\n\t\n\t\t\t_d3ddev.GetRenderState D3DRS_SCISSORTESTENABLE,_viewporton\n\t\t\t_d3ddev.SetRenderState D3DRS_SCISSORTESTENABLE,True\n\t\t\t\n\t\t\t_d3ddev.SetRenderState D3DRS_LIGHTING,True\n\t\t\t_d3ddev.SetRenderState D3DRS_NORMALIZENORMALS,True\n\t\t\t\n\t\t\t_d3ddev.SetRenderState D3DRS_COLORVERTEX, True\n\t\t\t\t\t\t\n\t\t\t'_d3ddev.SetRenderState D3DRS_ALPHAREF, 1\n\t\t\t'_d3ddev.SetRenderState D3DRS_ALPHAFUNC, D3DCMP_GREATEREQUAL\n\t\tEndIf\t\n\tEnd Method\n\t\n\tMethod SetCamera(camera:TCamera,config:TWorldConfig)\n\t\t_d3ddev.SetRenderState D3DRS_DITHERENABLE, config.Dither\n\t\t\n\t\tLocal clearflags\t\t\n\t\tIf camera._clsmode&CLSMODE_COLOR clearflags:|D3DCLEAR_TARGET\n\t\tIf camera._clsmode&CLSMODE_DEPTH clearflags:|D3DCLEAR_ZBUFFER\n\n\t\tLocal viewport[]=[camera._viewx,camera._viewy,camera._viewwidth-camera._viewx,camera._viewheight-camera._viewy]\n\t\t_d3ddev.SetScissorRect viewport\n\t\t_d3ddev.Clear(1,viewport,clearflags,D3DCOLOR_XRGB(camera._brush._r*255,camera._brush._g*255,camera._brush._b*255),1.0,0)\n\t\t\t\t\n\t\tSelect camera._fogmode\n\t\tCase FOGMODE_LINEAR\n\t\t\t_d3ddev.SetRenderState D3DRS_FOGENABLE,True\n\t\t\t_d3ddev.SetRenderState D3DRS_FOGSTART,Int(Varptr camera._fognear)\n\t\t\t_d3ddev.SetRenderState D3DRS_FOGEND,Int(Varptr camera._fogfar)\n\t\tDefault\n\t\t\t_d3ddev.SetRenderState D3DRS_FOGENABLE,False\n\t\tEnd Select\n\t\t\n\t\tLocal oldnear# = camera._near ' Ugh, hack. Need to investigate cause.\n\t\tcamera._near = Max(camera._near - 0.396250010, .01)\n\t\tcamera.UpdateMatrices()\n\t\tcamera._near = oldnear\n\t\t\n\t\t_d3ddev.SetTransform D3DTS_PROJECTION,camera._projection.ToPtr() \n\t\t_d3ddev.SetTransform D3DTS_VIEW,camera._modelview.ToPtr()\n\tEnd Method\n\t\n\tMethod SetLight(light:TLight,index)\n\t\tIf light=Null \n\t\t\t_d3ddev.LightEnable index,False\n\t\t\tReturn\n\t\tEndIf\n\t\t\n\t\tLocal brush:TBrush=light._brush\n\n\t\tGlobal d3dlight:D3DLIGHT9=New D3DLIGHT9\n\t\td3dlight.Type_=D3DLIGHT_DIRECTIONAL \n\t\td3dlight.Diffuse_r=brush._r;d3dlight.Diffuse_g=brush._g;d3dlight.Diffuse_b=brush._b;d3dlight.Diffuse_a=brush._a\n\t\t'd3dlight.Ambient_r=WorldConfig.AmbientRed\/255.0;d3dlight.Ambient_g=WorldConfig.AmbientGreen\/255.0;d3dlight.Ambient_b=WorldConfig.AmbientBlue\/255.0;d3dlight.Ambient_a=1.0\n\t\t\n\t\td3dlight.Direction_x=0.0;d3dlight.Direction_y=0.0;d3dlight.Direction_z=1.0\n\t\t\t\t\n\t\tLocal matrix:TMatrix=light._matrix\n\t\tmatrix.TransformVec3 d3dlight.Direction_x,d3dlight.Direction_y,d3dlight.Direction_z\n\t\tmatrix.GetPosition d3dlight.Position_x,d3dlight.Position_y,d3dlight.Position_z\t\t\n\t\t\n\t\td3dlight.Range=light._range\t\t\n\t\t\n\t\t_d3ddev.SetLight index,d3dlight\n\t\t_d3ddev.LightEnable index,True\n\tEnd Method\n\t\n\tMethod SetBrush(brush:TBrush,hasalpha,config:TWorldConfig)\t\t\n\t\t_d3ddev.SetRenderState D3DRS_ALPHABLENDENABLE,hasalpha\n\t\t_d3ddev.SetRenderState D3DRS_ZWRITEENABLE,Not hasalpha\n\t\t\n\t\tSelect brush._blend\n\t\tCase BLEND_NONE, BLEND_ALPHA\n\t\t\t_d3ddev.SetRenderState D3DRS_SRCBLEND,D3DBLEND_SRCALPHA\n\t\t\t_d3ddev.SetRenderState D3DRS_DESTBLEND,D3DBLEND_INVSRCALPHA\n\t\tCase BLEND_MULTIPLY\n\t\t\t_d3ddev.SetRenderState D3DRS_SRCBLEND,D3DBLEND_DESTCOLOR\n\t\t\t_d3ddev.SetRenderState D3DRS_DESTBLEND,D3DBLEND_ZERO\n\t\tCase BLEND_ADD\n\t\t\t_d3ddev.SetRenderState D3DRS_SRCBLEND,D3DBLEND_SRCALPHA\n\t\t\t_d3ddev.SetRenderState D3DRS_DESTBLEND,D3DBLEND_ONE\n\t\tEnd Select\n\n\t\tIf brush._fx&FX_FULLBRIGHT\n\t\t\t_d3ddev.SetRenderState D3DRS_AMBIENT,D3DCOLOR_RGB(255,255,255)\n\t\tElse\n\t\t\t_d3ddev.SetRenderState D3DRS_AMBIENT,D3DCOLOR_RGB(config.AmbientRed,config.AmbientGreen,config.AmbientBlue)\n\t\tEndIf\n\t\t\n\t\tIf brush._fx&FX_VERTEXCOLOR\n\t\t\t_d3ddev.SetRenderState D3DRS_DIFFUSEMATERIALSOURCE,D3DMCS_COLOR1\n\t\t\t_d3ddev.SetRenderState D3DRS_AMBIENTMATERIALSOURCE,D3DMCS_COLOR1\n\t\tElse\n\t\t\t_d3ddev.SetRenderState D3DRS_DIFFUSEMATERIALSOURCE,D3DMCS_MATERIAL\n\t\t\t_d3ddev.SetRenderState D3DRS_AMBIENTMATERIALSOURCE,D3DMCS_MATERIAL \n\t\tEndIf\n\t\t\n\t\tIf brush._fx&FX_FLATSHADED\n\t\t\t_d3ddev.SetRenderState D3DRS_SHADEMODE, D3DSHADE_FLAT\n\t\tElse\n\t\t\t_d3ddev.SetRenderState D3DRS_SHADEMODE, D3DSHADE_GOURAUD\n\t\tEndIf\n\n\t\tIf brush._fx&FX_NOCULLING\n\t\t\t_d3ddev.SetRenderState D3DRS_CULLMODE,D3DCULL_NONE\n\t\tElse\n\t\t\t_d3ddev.SetRenderState D3DRS_CULLMODE,D3DCULL_CCW\n\t\tEndIf\n\t\t\n\t\tIf brush._fx&FX_WIREFRAME Or config.Wireframe\n\t\t\t_d3ddev.SetRenderState D3DRS_FILLMODE,D3DFILL_WIREFRAME\n\t\tElse\n\t\t\t_d3ddev.SetRenderState D3DRS_FILLMODE,D3DFILL_SOLID\n\t\tEndIf\n\t\t\n\t\tLocal material:D3DMATERIAL9 = New D3DMATERIAL9\n\t\tmaterial.Diffuse_r=brush._r;material.Diffuse_g=brush._g;material.Diffuse_b=brush._b;material.Diffuse_a=brush._a\n\t\tmaterial.Ambient_r=brush._r;material.Ambient_g=brush._g;material.Ambient_b=brush._b;material.Ambient_a=brush._a\n\t\t\n\t\t_d3ddev.SetMaterial material\n\t\t\n\t\tLocal alpha_test\n\t\tFor Local i=0 To 7\n\t\t\tLocal texture:TTexture=brush._texture[i]\n\t\t\tIf texture=Null Or texture._blend=BLEND_NONE \n\t\t\t\t_d3ddev.SetTexture i,Null\n\t\t\t\tContinue\n\t\t\tEndIf\n\t\t\t\n\t\t\t_d3ddev.SetTexture i,UpdateTextureRes(texture._frame[brush._textureframe[i]],texture._flags)._tex\n\n\t\t\tLocal matrix:TMatrix=TMatrix.Identity()\n\t\t\t'matrix._m[0,0]=-texture._sx\n\t\t\t'matrix._m[1,1]=texture._sy\n\t\t\tmatrix=TMatrix.YawPitchRoll(0,0,-texture._r).Multiply(matrix)\n\t\t\tmatrix=TMatrix.Scale(-texture._sx,texture._sy,1).Multiply(matrix)\n\t\t\tmatrix._m[2,0]=-texture._px\n\t\t\tmatrix._m[2,1]=-texture._py\n\t\t\t\n\t\t\t_d3ddev.SetTransform D3DTS_TEXTURE0+i,matrix.ToPtr()\n\n\t\t\t_d3ddev.SetTextureStageState i,D3DTSS_TEXTURETRANSFORMFLAGS,D3DTTFF_COUNT2\n\t\t\t_d3ddev.SetTextureStageState i,D3DTSS_ADDRESS,0\n\t\t\t\n\t\t\t_d3ddev.SetSamplerState i,D3DSAMP_MAGFILTER,D3DTEXF_LINEAR\n\t\t\t_d3ddev.SetSamplerState i,D3DSAMP_MINFILTER,D3DTEXF_LINEAR\n\t\t\t\t\t\t\n\t\t\t'_d3ddev.SetRenderState D3DRS_WRAP0+i, D3DWRAP_U|D3DWRAP_V\n\t\t\talpha_test :| (texture._flags&TEXTURE_ALPHA Or texture._flags&TEXTURE_MASKED)\n\t\t\t\t\t\n\t\t\tIf texture._flags&TEXTURE_MIPMAP\t\t\t\t\n\t\t\t\t_d3ddev.SetSamplerState i,D3DSAMP_MIPFILTER,D3DTEXF_LINEAR\n\t\t\t\t_d3ddev.SetTextureStageState i,D3DTSS_MAGFILTER,D3DTEXF_LINEAR\n\t\t\t\t_d3ddev.SetTextureStageState i,D3DTSS_MINFILTER,D3DTEXF_LINEAR\n\t\t\tElse\n\t\t\t\t_d3ddev.SetSamplerState i,D3DSAMP_MIPFILTER,D3DTEXF_NONE\n\t\t\t\t_d3ddev.SetTextureStageState i,D3DTSS_MAGFILTER,D3DTEXF_POINT\n\t\t\t\t_d3ddev.SetTextureStageState i,D3DTSS_MINFILTER,D3DTEXF_POINT\n\t\t\tEndIf\n\t\t\t\n\t\t\tIf texture._flags&TEXTURE_CLAMPU\n\t\t\t\t_d3ddev.SetSamplerState i,D3DSAMP_ADDRESSU,D3DTADDRESS_CLAMP\n\t\t\tElse\n\t\t\t\t_d3ddev.SetSamplerState i,D3DSAMP_ADDRESSU,D3DTADDRESS_WRAP\n\t\t\tEndIf\n\n\t\t\tIf texture._flags&TEXTURE_CLAMPV\n\t\t\t\t_d3ddev.SetSamplerState i,D3DSAMP_ADDRESSU,D3DTADDRESS_CLAMP\n\t\t\tElse\n\t\t\t\t_d3ddev.SetSamplerState i,D3DSAMP_ADDRESSV,D3DTADDRESS_WRAP\n\t\t\tEndIf\n\t\t\t\n\t\t\tIf texture._flags&TEXTURE_SPHEREMAP\n\t\t\t\t_d3ddev.SetTextureStageState i,D3DTSS_TEXCOORDINDEX,D3DTSS_TCI_SPHEREMAP\n\t\t\tElse\n\t\t\t\t_d3ddev.SetTextureStageState i,D3DTSS_TEXCOORDINDEX,texture._coords\n\t\t\tEndIf\n\t\t\t\n\t\t\tSelect texture._blend\n\t\t\tCase BLEND_ALPHA\n\t\t\t\t_d3ddev.SetTextureStageState i,D3DTSS_COLOROP,D3DTOP_MODULATE\n\t\t\t\t_d3ddev.SetTextureStageState i,D3DTSS_ALPHAOP,D3DTOP_MODULATE\n\t\t\tCase BLEND_MULTIPLY\n\t\t\t\t_d3ddev.SetTextureStageState i,D3DTSS_COLOROP,D3DTOP_MODULATE\n\t\t\t\t_d3ddev.SetTextureStageState i,D3DTSS_ALPHAOP,D3DTOP_MODULATE\n\t\t\tCase BLEND_ADD\n\t\t\t\t_d3ddev.SetTextureStageState i,D3DTSS_COLOROP,D3DTOP_ADD\n\t\t\t\t_d3ddev.SetTextureStageState i,D3DTSS_ALPHAOP,D3DTOP_ADD\n\t\t\tCase BLEND_DOT3\n\t\t\t\t_d3ddev.SetTextureStageState i,D3DTSS_COLOROP,D3DTOP_DOTPRODUCT3\n\t\t\t\t_d3ddev.SetTextureStageState i,D3DTSS_ALPHAOP,D3DTOP_DOTPRODUCT3\n\t\t\tCase BLEND_MULTIPLY2\n\t\t\t\t_d3ddev.SetTextureStageState i,D3DTSS_COLOROP,D3DTOP_MODULATE2X\n\t\t\t\t_d3ddev.SetTextureStageState i,D3DTSS_ALPHAOP,D3DTOP_MODULATE2X\n\t\t\tDefault\n\t\t\t\t_d3ddev.SetTextureStageState i,D3DTSS_COLOROP,D3DTOP_SELECTARG2\n\t\t\t\t_d3ddev.SetTextureStageState i,D3DTSS_ALPHAOP,D3DTOP_SELECTARG2\n\t\t\tEnd Select\t\t\t\n\t\tNext\n\t\t_d3ddev.SetRenderState D3DRS_ALPHATESTENABLE, alpha_test\n\tEnd Method\n\t\n\tMethod RenderSurface(resource:TSurfaceRes,brush:TBrush)\n\t\tLocal res:TD3D9SurfaceRes=TD3D9SurfaceRes(resource)\n\t\t\n\t\t_d3ddev.SetFVF 0\n\t\t_d3ddev.SetVertexDeclaration GetD3D9MaxB3DVertexDecl(_d3ddev)\n\t\t_d3ddev.SetStreamSource 0,res._pos,0,12\n\t\t_d3ddev.SetStreamSource 1,res._nml,0,12\n\t\t_d3ddev.SetStreamSource 2,res._clr,0,16\n\t\t_d3ddev.SetStreamSource 3,res._tex[0],0,8\n\t\t_d3ddev.SetStreamSource 4,res._tex[1],0,8\n\t\t_d3ddev.SetStreamSource 5,res._tex[2],0,8\n\t\t_d3ddev.SetStreamSource 6,res._tex[3],0,8\n\t\t_d3ddev.SetStreamSource 7,res._tex[4],0,8\n\t\t_d3ddev.SetStreamSource 8,res._tex[5],0,8\n\t\t_d3ddev.SetStreamSource 9,res._tex[6],0,8\n\t\t_d3ddev.SetStreamSource 10,res._tex[7],0,8\n\t\t_d3ddev.SetIndices res._tri\n\t\t_d3ddev.DrawIndexedPrimitive D3DPT_TRIANGLELIST,0,0,res._vertexcnt,0,res._trianglecnt\n\n\t\tReturn res._trianglecnt\n\tEnd Method\n\t\n\tMethod RenderSprite(sprite:TSprite)\t\n\t\tGlobal _data#[]=[ -1.0, 1.0,0.0, 0.0,0.0,1.0, 0.0,0.0, ..\n\t\t\t\t\t\t\t\t\t\t\t-1.0,-1.0,0.0, 0.0,0.0,1.0, 0.0,1.0, ..\n\t\t 1.0, 1.0,0.0, 0.0,0.0,1.0, 1.0,0.0, ..\n\t\t 1.0,-1.0,0.0, 0.0,0.0,1.0, 1.0,1.0 ]\n\t\t\n\t\t_d3ddev.SetVertexDeclaration Null\n\t\t_d3ddev.SetFVF D3DFVF_XYZ|D3DFVF_NORMAL|D3DFVF_TEX1\n\t\t_d3ddev.DrawPrimitiveUP D3DPT_TRIANGLESTRIP,2,_data,8*4\n\tEnd Method\n\t\n\tMethod BeginEntityRender(entity:TEntity)\n\t\t_d3ddev.SetTransform D3DTS_WORLD,entity.GetMatrix(True).ToPtr()\n\tEnd Method\n\t\n\tMethod EndEntityRender(entity:TEntity)\n\tEnd Method\n\t\n\tMethod RenderFlat(flat:TFlat)\n\t\tLocal x#,y#,z#\n\t\tflat.GetScale x,y,z,True\n\n\t\tGlobal _data#[]=[ -1.0,0.0, 1.0, 0.0,1.0,0.0, 0.0,0.0, ..\n\t\t 1.0,0.0, 1.0, 0.0,1.0,0.0, x,0.0, ..\n\t\t -1.0,0.0,-1.0, 0.0,1.0,0.0, 0.0, z, ..\n\t\t 1.0,0.0,-1.0, 0.0,1.0,0.0, x, z ]\t\t\n\t\t\n\t\t_d3ddev.SetVertexDeclaration Null\n\t\t_d3ddev.SetFVF D3DFVF_XYZ|D3DFVF_NORMAL|D3DFVF_TEX1\n\t\t_d3ddev.DrawPrimitiveUP D3DPT_TRIANGLESTRIP,2,_data,8*4\n\tEnd Method\n\t\n\tMethod RenderTerrain(terrain:TTerrain)\n\tEnd Method\n\t\n\tMethod RenderBSPTree(tree:TBSPTree)\n\t\tLocal node:TBSPNode=tree.Node\n\t\tIf node=Null Return\n\t\tLocal triangles\n\t\ttriangles:+RenderBSPTree(node.In)\n\t\t\n\t\t_d3ddev.SetVertexDeclaration Null\n\t\t_d3ddev.SetFVF D3DFVF_XYZ|D3DFVF_NORMAL|D3DFVF_TEX1\n\t\t\t\t\n\t\tFor Local poly:TBSPPolygon=EachIn node.On\n\t\t\tLocal ptA:TVector=poly.Point[0],v0\n\t\t\tLocal trianglecnt=poly.Count()-2\n\t\t\tLocal data#[trianglecnt*24],dataptr:Float Ptr=data\n\t\t\tFor Local i=0 To trianglecnt-1\n\t\t\t\tLocal ptB:TVector=poly.Point[i+1],ptC:TVector=poly.Point[i+2]\n\t\t\t\tdata[i*24+00]=ptA.x;data[i*24+01]=ptA.y;data[i*24+02]=ptA.z;data[i*24+03]=poly.Plane.x;data[i*24+04]=poly.Plane.y;\tdata[i*24+05]=poly.Plane.z;data[i*24+06]=0.0;data[i*24+07]=0.0\n\t\t\t\tdata[i*24+08]=ptB.x;data[i*24+09]=ptB.y;data[i*24+10]=ptB.z;data[i*24+11]=poly.Plane.x;data[i*24+12]=poly.Plane.y;\tdata[i*24+13]=poly.Plane.z;data[i*24+14]=0.0;data[i*24+15]=0.0\n\t\t\t\tdata[i*24+16]=ptC.x;data[i*24+17]=ptC.y;data[i*24+18]=ptC.z;data[i*24+19]=poly.Plane.x;data[i*24+20]=poly.Plane.y;data[i*24+21]=poly.Plane.z;data[i*24+22]=0.0;data[i*24+23]=0.0\n\t\t\tNext\n\t\t\t_d3ddev.DrawPrimitiveUP D3DPT_TRIANGLELIST,trianglecnt,data,8*4\n\t\t\ttriangles:+trianglecnt\n\t\tNext\n\t\t\t\t\n\t\ttriangles:+RenderBSPTree(node.Out)\n\t\tReturn triangles\n\tEnd Method\n\t\n\tMethod UpdateTextureRes:TD3D9TextureRes(frame:TTextureFrame,flags)\n\t\tLocal res:TD3D9TextureRes=TD3D9TextureRes(frame._res)\n\t\tIf res And frame._updateres=False Return res\n\n\t\tIf res=Null res=New TD3D9TextureRes\n\t\tframe._res=res\n\t\t\n\t\tLocal pixmap:TPixmap=frame._pixmap\n\t\tLocal tex_width=Pow2Size(pixmap.width),tex_height=Pow2Size(pixmap.height)\n\t\tpixmap=ConvertPixmap(ResizePixmap(pixmap,tex_width,tex_height),PF_BGRA8888)\n\t\tIf res._tex=Null Assert _d3ddev.CreateTexture(tex_width,tex_height,(flags & TEXTURE_MIPMAP)=0,D3DUSAGE_AUTOGENMIPMAP,D3DFMT_A8R8G8B8,D3DPOOL_MANAGED,res._tex,Null)=D3D_OK\n\t\t\n\t\tLocal rect:D3DLOCKED_RECT=New D3DLOCKED_RECT \n\t\tres._tex.LockRect 0,rect,Null,0\n\t\tMemCopy rect.pBits,pixmap.pixels,pixmap.width*pixmap.height*4\n\t\tres._tex.UnlockRect 0\n\t\t\n\t\tframe._updateres=False\n\t\t\t\t\n\t\tReturn res\n\tEnd Method\n\t\n\tMethod UpdateSurfaceRes:TD3D9SurfaceRes(surface:TSurface)\n\t\tLocal res:TD3D9SurfaceRes=TD3D9SurfaceRes(surface._res)\n\t\tIf res=Null res=New TD3D9SurfaceRes;surface._reset=-1\n\t\t\n\t\tIf surface._reset=0 Return res\t\t\n\t\tIf surface._reset=-1 surface._reset=1|2|4|8|16|32|64|128|256\n\n\t\tIf surface._reset&1 And surface._vertexpos UploadVertexData res._pos,surface._vertexpos\n\t\tIf surface._reset&2 And surface._vertexnml UploadVertexData res._nml,surface._vertexnml\n\t\tIf surface._reset&4 And surface._vertexclr UploadVertexData res._clr,surface._vertexclr\n\t\tIf surface._reset&8 And surface._triangle\n\t\t\tIf res._tri=Null _d3ddev.CreateIndexBuffer(surface._triangle.length*4,0,D3DFMT_INDEX32,D3DPOOL_MANAGED,res._tri,Null)\n\t\t\tLocal dataptr:Byte Ptr\n\t\t\tAssert res._tri.Lock(0,0,dataptr,0)=D3D_OK,\"Failed to lock index buffer.\"\n\t\t\tMemCopy dataptr,surface._triangle,surface._triangle.length*4\t\t\n\t\t\tres._tri.Unlock()\n\t\tEndIf\n\t\t\n\t\tFor Local i=0 To surface._vertextex.length-1\n\t\t\tIf surface._reset&Int(2^(4+i)) UploadVertexData res._tex[i],surface._vertextex[i]\n\t\tNext\n\t\t\n\t\tres._trianglecnt=surface._trianglecnt\n\t\tres._vertexcnt=surface._vertexcnt\n\t\t\n\t\tsurface._reset=0\n\t\tsurface._res=res\n\t\t\n\t\tReturn res\n\tEnd Method\n\n\tMethod MergeSurfaceRes:TSurfaceRes(base:TSurface,animation:TSurface,data)\n\t\tIf animation=Null Return UpdateSurfaceRes(base)\n\t\tLocal base_res:TD3D9SurfaceRes=UpdateSurfaceRes(base)\n\t\tLocal anim_res:TD3D9SurfaceRes=UpdateSurfaceRes(animation)\n\t\tLocal res:TD3D9SurfaceRes=base_res.Copy()\n\t\tres._pos=anim_res._pos\n\t\tReturn res\n\tEnd Method\n\t\n\tMethod UploadVertexData(buffer:IDirect3DVertexBuffer9 Var,data#[])\n\t\tIf buffer=Null _d3ddev.CreateVertexBuffer(data.length*4,0,0,D3DPOOL_MANAGED,buffer,Null)\n\t\tLocal dataptr:Byte Ptr\n\t\tAssert buffer.Lock(0,0,dataptr,0)=D3D_OK,\"Failed to lock vertex buffer.\"\n\t\tMemCopy dataptr,data,data.length*4\t\t\n\t\tbuffer.Unlock()\n\tEnd Method\n\t\nEnd Type\n\nType TD3D9TextureRes Extends TTextureRes\n\tField _tex:IDirect3DTexture9\nEnd Type\n\nType TD3D9SurfaceRes Extends TSurfaceRes\n\tField _pos:IDirect3DVertexBuffer9\n\tField _nml:IDirect3DVertexBuffer9\n\tField _clr:IDirect3DVertexBuffer9\n\tField _tri:IDirect3DIndexBuffer9\n\tField _tex:IDirect3DVertexBuffer9[8]\n\t\n\tMethod Copy:TD3D9SurfaceRes()\n\t\tLocal res:TD3D9SurfaceRes=New TD3D9SurfaceRes\n\t\tres._vertexcnt=_vertexcnt;res._trianglecnt=_trianglecnt\n\t\tres._pos=_pos;res._nml=_nml;res._clr=_clr;res._tri=_tri;\n\t\tFor Local i=0 To 7\n\t\t\tres._tex[i]=_tex[i]\n\t\tNext\n\t\tReturn res\n\tEnd Method\nEnd Type\n\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction D3D9MaxB3DDriver:TD3D9MaxB3DDriver()\n\tIf D3D9Max2DExDriver()\n\t\tGlobal driver:TD3D9MaxB3DDriver=New TD3D9MaxB3DDriver\n\t\tdriver._parent=D3D9Max2DExDriver()\n\t\tReturn driver\n\tEnd If\nEnd Function\n\nRem\n\tbbdoc: Utility function that sets the MaxB3D D3D9 driver and calls Graphics.\nEnd Rem\nFunction D3D9Graphics3D:TGraphics(width,height,depth=0,hertz=0,flags=0)\n\tSetGraphicsDriver D3D9MaxB3DDriver(),GRAPHICS_BACKBUFFER|GRAPHICS_DEPTHBUFFER\n\tReturn Graphics(width,height,depth,hertz,flags)\nEnd Function\n\nLocal driver:TD3D9MaxB3DDriver=D3D9MaxB3DDriver()\nIf driver SetGraphicsDriver driver,GRAPHICS_BACKBUFFER|GRAPHICS_DEPTHBUFFER\n\n?\n","old_contents":"\nStrict\n\nRem\n\tbbdoc: Direct3D 9 renderer for MaxB3D\nEnd Rem\nModule MaxB3D.D3D9Driver\nModuleInfo \"Author: Kevin Primm\"\nModuleInfo \"License: MIT\"\n\nImport MaxB3D.Core\nImport Prime.D3D9Max2DEx\nImport Prime.DirectXEx\n\n?Win32\n\nImport \"d3d9.cpp\"\n\nPrivate \n\nExtern \"C\"\n\tFunction maxb3dD3D9VertexElements:Byte Ptr()'=\"_maxb3dD3D9VertexElements@0\"\nEnd Extern\n\nFunction GetD3D9MaxB3DVertexDecl:IDirect3DVertexDeclaration9(d3ddev:IDirect3DDevice9)\n\tGlobal decl:IDirect3DVertexDeclaration9,dev:IDirect3DDevice9\n\tIf decl=Null Or dev<>d3ddev\n\t\tAssert d3ddev.CreateVertexDeclaration(maxb3dD3D9VertexElements(),decl)=D3D_OK,\"Failed to create vertex declaration.\"\n\t\tdev=d3ddev\n\tEndIf\n\tReturn decl\nEnd Function\n\nFunction Pow2Size( n )\n\tLocal t=1\n\tWhile tNull\n\t\t\t_d3ddev=TD3D9Graphics(TMax2DGraphics(g)._graphics).GetDirect3DDevice()\n\t\t\tEndMax2D\n\t\tEndIf\n\tEnd Method\n\t\t\n\tMethod MakeBuffer:TBuffer(src:Object,width,height,flags)\n\t\tReturn TMax2DExDriver(_parent).MakeBuffer(src,width,height,flags)\n\tEnd Method\n\t\n\tMethod GetCaps:TCaps()\n\t\tLocal caps:TCaps=New TCaps\n\t\tReturn caps\n\tEnd Method\n\t\n\tMethod Abbr$()\n\t\tReturn \"d3d9\"\n\tEnd Method\n\t\n\tMethod SetMax2D(enable)\n\t\tIf enable\n\t\t\tGlobal identity:TMatrix=TMatrix.Identity()\n\t\t\tLocal width=GraphicsWidth(),height=GraphicsHeight()\n\t\t\tLocal matrix#[]=[..\n\t\t\t2.0\/width,0.0,0.0,0.0,..\n\t\t\t 0.0,-2.0\/height,0.0,0.0,..\n\t\t\t 0.0,0.0,1.0,0.0,..\n\t\t\t -1-(1.0\/width),1+(1.0\/height),1.0,1.0]\n\t\t\t\n\t\t\tSetBlend -1\n\t\t\tSetBlend SOLIDBLEND\n\t\t\t\n\t\t\t_d3ddev.SetTransform D3DTS_PROJECTION,matrix\n\t\t\t_d3ddev.SetTransform D3DTS_WORLD,identity.ToPtr()\n\t\t\t_d3ddev.SetTransform D3DTS_VIEW,identity.ToPtr()\n\t\t\t_d3ddev.SetTransform D3DTS_TEXTURE0,identity.ToPtr()\n\t\t\t\n\t\t\t_d3ddev.SetVertexDeclaration Null\n\t\t\t_d3ddev.SetIndices Null\n\t\t\t_d3ddev.SetFVF D3DFVF_XYZ|D3DFVF_DIFFUSE|D3DFVF_TEX1\n\t\t\t\n\t\t\t_d3ddev.SetRenderState D3DRS_LIGHTING,False\n\t\t\t_d3ddev.SetRenderState D3DRS_ZENABLE,False\n\t\t\t_d3ddev.SetRenderState D3DRS_SCISSORTESTENABLE,_viewporton\t\t\n\t\t\t\n\t\t\t_d3ddev.SetRenderState D3DRS_ALPHATESTENABLE,True\n\t\t\t\n\t\t\tFor Local i=1 To 7\n\t\t\t\t_d3ddev.SetTexture i,Null\n\t\t\tNext\n\t\t\t\t\n\t\t\t_d3ddev.SetFVF D3DFVF_XYZ|D3DFVF_DIFFUSE|D3DFVF_TEX1\n\t\t\t\n\t\t\t_d3ddev.SetTextureStageState 0,D3DTSS_COLOROP,D3DTOP_MODULATE\n\t\t\t_d3ddev.SetTextureStageState 0,D3DTSS_ALPHAOP,D3DTOP_MODULATE\n\t\t\t\n\t\t\t_d3ddev.SetTextureStageState 0,D3DTSS_ADDRESS,D3DTADDRESS_CLAMP\n\t\t\n\t\t\t_d3ddev.SetTextureStageState 0,D3DTSS_MAGFILTER,D3DTFG_POINT\n\t\t\t_d3ddev.SetTextureStageState 0,D3DTSS_MINFILTER,D3DTFN_POINT\n\t\t\t_d3ddev.SetTextureStageState 0,D3DTSS_MIPFILTER,D3DTFP_POINT\n\t\t\t\n\t\t\t_d3ddev.SetRenderState D3DRS_FOGENABLE,False\n\t\t\t\t\t\t\t\t\n\t\t\t_d3ddev.SetRenderState D3DRS_CULLMODE,D3DCULL_NONE\n\t\t\t_d3ddev.SetRenderState D3DRS_FILLMODE,D3DFILL_SOLID\n\t\tElse\n\t\t\t_d3ddev.SetRenderState D3DRS_ZENABLE,True\n\t\t\t_d3ddev.SetRenderState D3DRS_ZWRITEENABLE,True\n\t\n\t\t\t_d3ddev.GetRenderState D3DRS_SCISSORTESTENABLE,_viewporton\n\t\t\t_d3ddev.SetRenderState D3DRS_SCISSORTESTENABLE,True\n\t\t\t\n\t\t\t_d3ddev.SetRenderState D3DRS_LIGHTING,True\n\t\t\t_d3ddev.SetRenderState D3DRS_NORMALIZENORMALS,True\n\t\t\t\n\t\t\t_d3ddev.SetRenderState D3DRS_COLORVERTEX, True\n\t\t\t\t\t\t\n\t\t\t'_d3ddev.SetRenderState D3DRS_ALPHAREF, 1\n\t\t\t'_d3ddev.SetRenderState D3DRS_ALPHAFUNC, D3DCMP_GREATEREQUAL\n\t\tEndIf\t\n\tEnd Method\n\t\n\tMethod SetCamera(camera:TCamera,config:TWorldConfig)\n\t\t_d3ddev.SetRenderState D3DRS_DITHERENABLE, config.Dither\n\t\t\n\t\tLocal clearflags\t\t\n\t\tIf camera._clsmode&CLSMODE_COLOR clearflags:|D3DCLEAR_TARGET\n\t\tIf camera._clsmode&CLSMODE_DEPTH clearflags:|D3DCLEAR_ZBUFFER\n\n\t\tLocal viewport[]=[camera._viewx,camera._viewy,camera._viewwidth-camera._viewx,camera._viewheight-camera._viewy]\n\t\t_d3ddev.SetScissorRect viewport\n\t\t_d3ddev.Clear(1,viewport,clearflags,D3DCOLOR_XRGB(camera._brush._r*255,camera._brush._g*255,camera._brush._b*255),1.0,0)\n\t\t\t\t\n\t\tSelect camera._fogmode\n\t\tCase FOGMODE_LINEAR\n\t\t\t_d3ddev.SetRenderState D3DRS_FOGENABLE,True\n\t\t\t_d3ddev.SetRenderState D3DRS_FOGSTART,Int(Varptr camera._fognear)\n\t\t\t_d3ddev.SetRenderState D3DRS_FOGEND,Int(Varptr camera._fogfar)\n\t\tDefault\n\t\t\t_d3ddev.SetRenderState D3DRS_FOGENABLE,False\n\t\tEnd Select\n\t\t\n\t\tLocal oldnear# = camera._near ' Ugh, hack. Need to investigate cause.\n\t\tcamera._near :- 0.396250010 \n\t\tcamera.UpdateMatrices()\n\t\tcamera._near = oldnear\n\t\t\n\t\t_d3ddev.SetTransform D3DTS_PROJECTION,camera._projection.ToPtr() \n\t\t_d3ddev.SetTransform D3DTS_VIEW,camera._modelview.ToPtr()\n\tEnd Method\n\t\n\tMethod SetLight(light:TLight,index)\n\t\tIf light=Null \n\t\t\t_d3ddev.LightEnable index,False\n\t\t\tReturn\n\t\tEndIf\n\t\t\n\t\tLocal brush:TBrush=light._brush\n\n\t\tGlobal d3dlight:D3DLIGHT9=New D3DLIGHT9\n\t\td3dlight.Type_=D3DLIGHT_DIRECTIONAL \n\t\td3dlight.Diffuse_r=brush._r;d3dlight.Diffuse_g=brush._g;d3dlight.Diffuse_b=brush._b;d3dlight.Diffuse_a=brush._a\n\t\t'd3dlight.Ambient_r=WorldConfig.AmbientRed\/255.0;d3dlight.Ambient_g=WorldConfig.AmbientGreen\/255.0;d3dlight.Ambient_b=WorldConfig.AmbientBlue\/255.0;d3dlight.Ambient_a=1.0\n\t\t\n\t\td3dlight.Direction_x=0.0;d3dlight.Direction_y=0.0;d3dlight.Direction_z=1.0\n\t\t\t\t\n\t\tLocal matrix:TMatrix=light._matrix\n\t\tmatrix.TransformVec3 d3dlight.Direction_x,d3dlight.Direction_y,d3dlight.Direction_z\n\t\tmatrix.GetPosition d3dlight.Position_x,d3dlight.Position_y,d3dlight.Position_z\t\t\n\t\t\n\t\td3dlight.Range=light._range\t\t\n\t\t\n\t\t_d3ddev.SetLight index,d3dlight\n\t\t_d3ddev.LightEnable index,True\n\tEnd Method\n\t\n\tMethod SetBrush(brush:TBrush,hasalpha,config:TWorldConfig)\t\t\n\t\t_d3ddev.SetRenderState D3DRS_ALPHABLENDENABLE,hasalpha\n\t\t_d3ddev.SetRenderState D3DRS_ZWRITEENABLE,Not hasalpha\n\t\t\n\t\tSelect brush._blend\n\t\tCase BLEND_NONE, BLEND_ALPHA\n\t\t\t_d3ddev.SetRenderState D3DRS_SRCBLEND,D3DBLEND_SRCALPHA\n\t\t\t_d3ddev.SetRenderState D3DRS_DESTBLEND,D3DBLEND_INVSRCALPHA\n\t\tCase BLEND_MULTIPLY\n\t\t\t_d3ddev.SetRenderState D3DRS_SRCBLEND,D3DBLEND_DESTCOLOR\n\t\t\t_d3ddev.SetRenderState D3DRS_DESTBLEND,D3DBLEND_ZERO\n\t\tCase BLEND_ADD\n\t\t\t_d3ddev.SetRenderState D3DRS_SRCBLEND,D3DBLEND_SRCALPHA\n\t\t\t_d3ddev.SetRenderState D3DRS_DESTBLEND,D3DBLEND_ONE\n\t\tEnd Select\n\n\t\tIf brush._fx&FX_FULLBRIGHT\n\t\t\t_d3ddev.SetRenderState D3DRS_AMBIENT,D3DCOLOR_RGB(255,255,255)\n\t\tElse\n\t\t\t_d3ddev.SetRenderState D3DRS_AMBIENT,D3DCOLOR_RGB(config.AmbientRed,config.AmbientGreen,config.AmbientBlue)\n\t\tEndIf\n\t\t\n\t\tIf brush._fx&FX_VERTEXCOLOR\n\t\t\t_d3ddev.SetRenderState D3DRS_DIFFUSEMATERIALSOURCE,D3DMCS_COLOR1\n\t\t\t_d3ddev.SetRenderState D3DRS_AMBIENTMATERIALSOURCE,D3DMCS_COLOR1\n\t\tElse\n\t\t\t_d3ddev.SetRenderState D3DRS_DIFFUSEMATERIALSOURCE,D3DMCS_MATERIAL\n\t\t\t_d3ddev.SetRenderState D3DRS_AMBIENTMATERIALSOURCE,D3DMCS_MATERIAL \n\t\tEndIf\n\t\t\n\t\tIf brush._fx&FX_FLATSHADED\n\t\t\t_d3ddev.SetRenderState D3DRS_SHADEMODE, D3DSHADE_FLAT\n\t\tElse\n\t\t\t_d3ddev.SetRenderState D3DRS_SHADEMODE, D3DSHADE_GOURAUD\n\t\tEndIf\n\n\t\tIf brush._fx&FX_NOCULLING\n\t\t\t_d3ddev.SetRenderState D3DRS_CULLMODE,D3DCULL_NONE\n\t\tElse\n\t\t\t_d3ddev.SetRenderState D3DRS_CULLMODE,D3DCULL_CCW\n\t\tEndIf\n\t\t\n\t\tIf brush._fx&FX_WIREFRAME Or config.Wireframe\n\t\t\t_d3ddev.SetRenderState D3DRS_FILLMODE,D3DFILL_WIREFRAME\n\t\tElse\n\t\t\t_d3ddev.SetRenderState D3DRS_FILLMODE,D3DFILL_SOLID\n\t\tEndIf\n\t\t\n\t\tLocal material:D3DMATERIAL9 = New D3DMATERIAL9\n\t\tmaterial.Diffuse_r=brush._r;material.Diffuse_g=brush._g;material.Diffuse_b=brush._b;material.Diffuse_a=brush._a\n\t\tmaterial.Ambient_r=brush._r;material.Ambient_g=brush._g;material.Ambient_b=brush._b;material.Ambient_a=brush._a\n\t\t\n\t\t_d3ddev.SetMaterial material\n\t\t\n\t\tLocal alpha_test\n\t\tFor Local i=0 To 7\n\t\t\tLocal texture:TTexture=brush._texture[i]\n\t\t\tIf texture=Null Or texture._blend=BLEND_NONE \n\t\t\t\t_d3ddev.SetTexture i,Null\n\t\t\t\tContinue\n\t\t\tEndIf\n\t\t\t\n\t\t\t_d3ddev.SetTexture i,UpdateTextureRes(texture._frame[brush._textureframe[i]],texture._flags)._tex\n\n\t\t\tLocal matrix:TMatrix=TMatrix.Identity()\n\t\t\t'matrix._m[0,0]=-texture._sx\n\t\t\t'matrix._m[1,1]=texture._sy\n\t\t\tmatrix=TMatrix.YawPitchRoll(0,0,-texture._r).Multiply(matrix)\n\t\t\tmatrix=TMatrix.Scale(-texture._sx,texture._sy,1).Multiply(matrix)\n\t\t\tmatrix._m[2,0]=-texture._px\n\t\t\tmatrix._m[2,1]=-texture._py\n\t\t\t\n\t\t\t_d3ddev.SetTransform D3DTS_TEXTURE0+i,matrix.ToPtr()\n\n\t\t\t_d3ddev.SetTextureStageState i,D3DTSS_TEXTURETRANSFORMFLAGS,D3DTTFF_COUNT2\n\t\t\t_d3ddev.SetTextureStageState i,D3DTSS_ADDRESS,0\n\t\t\t\n\t\t\t_d3ddev.SetSamplerState i,D3DSAMP_MAGFILTER,D3DTEXF_LINEAR\n\t\t\t_d3ddev.SetSamplerState i,D3DSAMP_MINFILTER,D3DTEXF_LINEAR\n\t\t\t\t\t\t\n\t\t\t'_d3ddev.SetRenderState D3DRS_WRAP0+i, D3DWRAP_U|D3DWRAP_V\n\t\t\talpha_test :| (texture._flags&TEXTURE_ALPHA Or texture._flags&TEXTURE_MASKED)\n\t\t\t\t\t\n\t\t\tIf texture._flags&TEXTURE_MIPMAP\t\t\t\t\n\t\t\t\t_d3ddev.SetSamplerState i,D3DSAMP_MIPFILTER,D3DTEXF_LINEAR\n\t\t\t\t_d3ddev.SetTextureStageState i,D3DTSS_MAGFILTER,D3DTEXF_LINEAR\n\t\t\t\t_d3ddev.SetTextureStageState i,D3DTSS_MINFILTER,D3DTEXF_LINEAR\n\t\t\tElse\n\t\t\t\t_d3ddev.SetSamplerState i,D3DSAMP_MIPFILTER,D3DTEXF_NONE\n\t\t\t\t_d3ddev.SetTextureStageState i,D3DTSS_MAGFILTER,D3DTEXF_POINT\n\t\t\t\t_d3ddev.SetTextureStageState i,D3DTSS_MINFILTER,D3DTEXF_POINT\n\t\t\tEndIf\n\t\t\t\n\t\t\tIf texture._flags&TEXTURE_CLAMPU\n\t\t\t\t_d3ddev.SetSamplerState i,D3DSAMP_ADDRESSU,D3DTADDRESS_CLAMP\n\t\t\tElse\n\t\t\t\t_d3ddev.SetSamplerState i,D3DSAMP_ADDRESSU,D3DTADDRESS_WRAP\n\t\t\tEndIf\n\n\t\t\tIf texture._flags&TEXTURE_CLAMPV\n\t\t\t\t_d3ddev.SetSamplerState i,D3DSAMP_ADDRESSU,D3DTADDRESS_CLAMP\n\t\t\tElse\n\t\t\t\t_d3ddev.SetSamplerState i,D3DSAMP_ADDRESSV,D3DTADDRESS_WRAP\n\t\t\tEndIf\n\t\t\t\n\t\t\tIf texture._flags&TEXTURE_SPHEREMAP\n\t\t\t\t_d3ddev.SetTextureStageState i,D3DTSS_TEXCOORDINDEX,D3DTSS_TCI_SPHEREMAP\n\t\t\tElse\n\t\t\t\t_d3ddev.SetTextureStageState i,D3DTSS_TEXCOORDINDEX,texture._coords\n\t\t\tEndIf\n\t\t\t\n\t\t\tSelect texture._blend\n\t\t\tCase BLEND_ALPHA\n\t\t\t\t_d3ddev.SetTextureStageState i,D3DTSS_COLOROP,D3DTOP_MODULATE\n\t\t\t\t_d3ddev.SetTextureStageState i,D3DTSS_ALPHAOP,D3DTOP_MODULATE\n\t\t\tCase BLEND_MULTIPLY\n\t\t\t\t_d3ddev.SetTextureStageState i,D3DTSS_COLOROP,D3DTOP_MODULATE\n\t\t\t\t_d3ddev.SetTextureStageState i,D3DTSS_ALPHAOP,D3DTOP_MODULATE\n\t\t\tCase BLEND_ADD\n\t\t\t\t_d3ddev.SetTextureStageState i,D3DTSS_COLOROP,D3DTOP_ADD\n\t\t\t\t_d3ddev.SetTextureStageState i,D3DTSS_ALPHAOP,D3DTOP_ADD\n\t\t\tCase BLEND_DOT3\n\t\t\t\t_d3ddev.SetTextureStageState i,D3DTSS_COLOROP,D3DTOP_DOTPRODUCT3\n\t\t\t\t_d3ddev.SetTextureStageState i,D3DTSS_ALPHAOP,D3DTOP_DOTPRODUCT3\n\t\t\tCase BLEND_MULTIPLY2\n\t\t\t\t_d3ddev.SetTextureStageState i,D3DTSS_COLOROP,D3DTOP_MODULATE2X\n\t\t\t\t_d3ddev.SetTextureStageState i,D3DTSS_ALPHAOP,D3DTOP_MODULATE2X\n\t\t\tDefault\n\t\t\t\t_d3ddev.SetTextureStageState i,D3DTSS_COLOROP,D3DTOP_SELECTARG2\n\t\t\t\t_d3ddev.SetTextureStageState i,D3DTSS_ALPHAOP,D3DTOP_SELECTARG2\n\t\t\tEnd Select\t\t\t\n\t\tNext\n\t\t_d3ddev.SetRenderState D3DRS_ALPHATESTENABLE, alpha_test\n\tEnd Method\n\t\n\tMethod RenderSurface(resource:TSurfaceRes,brush:TBrush)\n\t\tLocal res:TD3D9SurfaceRes=TD3D9SurfaceRes(resource)\n\t\t\n\t\t_d3ddev.SetFVF 0\n\t\t_d3ddev.SetVertexDeclaration GetD3D9MaxB3DVertexDecl(_d3ddev)\n\t\t_d3ddev.SetStreamSource 0,res._pos,0,12\n\t\t_d3ddev.SetStreamSource 1,res._nml,0,12\n\t\t_d3ddev.SetStreamSource 2,res._clr,0,16\n\t\t_d3ddev.SetStreamSource 3,res._tex[0],0,8\n\t\t_d3ddev.SetStreamSource 4,res._tex[1],0,8\n\t\t_d3ddev.SetStreamSource 5,res._tex[2],0,8\n\t\t_d3ddev.SetStreamSource 6,res._tex[3],0,8\n\t\t_d3ddev.SetStreamSource 7,res._tex[4],0,8\n\t\t_d3ddev.SetStreamSource 8,res._tex[5],0,8\n\t\t_d3ddev.SetStreamSource 9,res._tex[6],0,8\n\t\t_d3ddev.SetStreamSource 10,res._tex[7],0,8\n\t\t_d3ddev.SetIndices res._tri\n\t\t_d3ddev.DrawIndexedPrimitive D3DPT_TRIANGLELIST,0,0,res._vertexcnt,0,res._trianglecnt\n\n\t\tReturn res._trianglecnt\n\tEnd Method\n\t\n\tMethod RenderSprite(sprite:TSprite)\t\n\t\tGlobal _data#[]=[ -1.0, 1.0,0.0, 0.0,0.0,1.0, 0.0,0.0, ..\n\t\t\t\t\t\t\t\t\t\t\t-1.0,-1.0,0.0, 0.0,0.0,1.0, 0.0,1.0, ..\n\t\t 1.0, 1.0,0.0, 0.0,0.0,1.0, 1.0,0.0, ..\n\t\t 1.0,-1.0,0.0, 0.0,0.0,1.0, 1.0,1.0 ]\n\t\t\n\t\t_d3ddev.SetVertexDeclaration Null\n\t\t_d3ddev.SetFVF D3DFVF_XYZ|D3DFVF_NORMAL|D3DFVF_TEX1\n\t\t_d3ddev.DrawPrimitiveUP D3DPT_TRIANGLESTRIP,2,_data,8*4\n\tEnd Method\n\t\n\tMethod BeginEntityRender(entity:TEntity)\n\t\t_d3ddev.SetTransform D3DTS_WORLD,entity.GetMatrix(True).ToPtr()\n\tEnd Method\n\t\n\tMethod EndEntityRender(entity:TEntity)\n\tEnd Method\n\t\n\tMethod RenderFlat(flat:TFlat)\n\t\tLocal x#,y#,z#\n\t\tflat.GetScale x,y,z,True\n\n\t\tGlobal _data#[]=[ -1.0,0.0, 1.0, 0.0,1.0,0.0, 0.0,0.0, ..\n\t\t 1.0,0.0, 1.0, 0.0,1.0,0.0, x,0.0, ..\n\t\t -1.0,0.0,-1.0, 0.0,1.0,0.0, 0.0, z, ..\n\t\t 1.0,0.0,-1.0, 0.0,1.0,0.0, x, z ]\t\t\n\t\t\n\t\t_d3ddev.SetVertexDeclaration Null\n\t\t_d3ddev.SetFVF D3DFVF_XYZ|D3DFVF_NORMAL|D3DFVF_TEX1\n\t\t_d3ddev.DrawPrimitiveUP D3DPT_TRIANGLESTRIP,2,_data,8*4\n\tEnd Method\n\t\n\tMethod RenderTerrain(terrain:TTerrain)\n\tEnd Method\n\t\n\tMethod RenderBSPTree(tree:TBSPTree)\n\t\tLocal node:TBSPNode=tree.Node\n\t\tIf node=Null Return\n\t\tLocal triangles\n\t\ttriangles:+RenderBSPTree(node.In)\n\t\t\n\t\t_d3ddev.SetVertexDeclaration Null\n\t\t_d3ddev.SetFVF D3DFVF_XYZ|D3DFVF_NORMAL|D3DFVF_TEX1\n\t\t\t\t\n\t\tFor Local poly:TBSPPolygon=EachIn node.On\n\t\t\tLocal ptA:TVector=poly.Point[0],v0\n\t\t\tLocal trianglecnt=poly.Count()-2\n\t\t\tLocal data#[trianglecnt*24],dataptr:Float Ptr=data\n\t\t\tFor Local i=0 To trianglecnt-1\n\t\t\t\tLocal ptB:TVector=poly.Point[i+1],ptC:TVector=poly.Point[i+2]\n\t\t\t\tdata[i*24+00]=ptA.x;data[i*24+01]=ptA.y;data[i*24+02]=ptA.z;data[i*24+03]=poly.Plane.x;data[i*24+04]=poly.Plane.y;\tdata[i*24+05]=poly.Plane.z;data[i*24+06]=0.0;data[i*24+07]=0.0\n\t\t\t\tdata[i*24+08]=ptB.x;data[i*24+09]=ptB.y;data[i*24+10]=ptB.z;data[i*24+11]=poly.Plane.x;data[i*24+12]=poly.Plane.y;\tdata[i*24+13]=poly.Plane.z;data[i*24+14]=0.0;data[i*24+15]=0.0\n\t\t\t\tdata[i*24+16]=ptC.x;data[i*24+17]=ptC.y;data[i*24+18]=ptC.z;data[i*24+19]=poly.Plane.x;data[i*24+20]=poly.Plane.y;data[i*24+21]=poly.Plane.z;data[i*24+22]=0.0;data[i*24+23]=0.0\n\t\t\tNext\n\t\t\t_d3ddev.DrawPrimitiveUP D3DPT_TRIANGLELIST,trianglecnt,data,8*4\n\t\t\ttriangles:+trianglecnt\n\t\tNext\n\t\t\t\t\n\t\ttriangles:+RenderBSPTree(node.Out)\n\t\tReturn triangles\n\tEnd Method\n\t\n\tMethod UpdateTextureRes:TD3D9TextureRes(frame:TTextureFrame,flags)\n\t\tLocal res:TD3D9TextureRes=TD3D9TextureRes(frame._res)\n\t\tIf res And frame._updateres=False Return res\n\n\t\tIf res=Null res=New TD3D9TextureRes\n\t\tframe._res=res\n\t\t\n\t\tLocal pixmap:TPixmap=frame._pixmap\n\t\tLocal tex_width=Pow2Size(pixmap.width),tex_height=Pow2Size(pixmap.height)\n\t\tpixmap=ConvertPixmap(ResizePixmap(pixmap,tex_width,tex_height),PF_BGRA8888)\n\t\tIf res._tex=Null Assert _d3ddev.CreateTexture(tex_width,tex_height,(flags & TEXTURE_MIPMAP)=0,D3DUSAGE_AUTOGENMIPMAP,D3DFMT_A8R8G8B8,D3DPOOL_MANAGED,res._tex,Null)=D3D_OK\n\t\t\n\t\tLocal rect:D3DLOCKED_RECT=New D3DLOCKED_RECT \n\t\tres._tex.LockRect 0,rect,Null,0\n\t\tMemCopy rect.pBits,pixmap.pixels,pixmap.width*pixmap.height*4\n\t\tres._tex.UnlockRect 0\n\t\t\n\t\tframe._updateres=False\n\t\t\t\t\n\t\tReturn res\n\tEnd Method\n\t\n\tMethod UpdateSurfaceRes:TD3D9SurfaceRes(surface:TSurface)\n\t\tLocal res:TD3D9SurfaceRes=TD3D9SurfaceRes(surface._res)\n\t\tIf res=Null res=New TD3D9SurfaceRes;surface._reset=-1\n\t\t\n\t\tIf surface._reset=0 Return res\t\t\n\t\tIf surface._reset=-1 surface._reset=1|2|4|8|16|32|64|128|256\n\n\t\tIf surface._reset&1 And surface._vertexpos UploadVertexData res._pos,surface._vertexpos\n\t\tIf surface._reset&2 And surface._vertexnml UploadVertexData res._nml,surface._vertexnml\n\t\tIf surface._reset&4 And surface._vertexclr UploadVertexData res._clr,surface._vertexclr\n\t\tIf surface._reset&8 And surface._triangle\n\t\t\tIf res._tri=Null _d3ddev.CreateIndexBuffer(surface._triangle.length*4,0,D3DFMT_INDEX32,D3DPOOL_MANAGED,res._tri,Null)\n\t\t\tLocal dataptr:Byte Ptr\n\t\t\tAssert res._tri.Lock(0,0,dataptr,0)=D3D_OK,\"Failed to lock index buffer.\"\n\t\t\tMemCopy dataptr,surface._triangle,surface._triangle.length*4\t\t\n\t\t\tres._tri.Unlock()\n\t\tEndIf\n\t\t\n\t\tFor Local i=0 To surface._vertextex.length-1\n\t\t\tIf surface._reset&Int(2^(4+i)) UploadVertexData res._tex[i],surface._vertextex[i]\n\t\tNext\n\t\t\n\t\tres._trianglecnt=surface._trianglecnt\n\t\tres._vertexcnt=surface._vertexcnt\n\t\t\n\t\tsurface._reset=0\n\t\tsurface._res=res\n\t\t\n\t\tReturn res\n\tEnd Method\n\n\tMethod MergeSurfaceRes:TSurfaceRes(base:TSurface,animation:TSurface,data)\n\t\tIf animation=Null Return UpdateSurfaceRes(base)\n\t\tLocal base_res:TD3D9SurfaceRes=UpdateSurfaceRes(base)\n\t\tLocal anim_res:TD3D9SurfaceRes=UpdateSurfaceRes(animation)\n\t\tLocal res:TD3D9SurfaceRes=base_res.Copy()\n\t\tres._pos=anim_res._pos\n\t\tReturn res\n\tEnd Method\n\t\n\tMethod UploadVertexData(buffer:IDirect3DVertexBuffer9 Var,data#[])\n\t\tIf buffer=Null _d3ddev.CreateVertexBuffer(data.length*4,0,0,D3DPOOL_MANAGED,buffer,Null)\n\t\tLocal dataptr:Byte Ptr\n\t\tAssert buffer.Lock(0,0,dataptr,0)=D3D_OK,\"Failed to lock vertex buffer.\"\n\t\tMemCopy dataptr,data,data.length*4\t\t\n\t\tbuffer.Unlock()\n\tEnd Method\n\t\nEnd Type\n\nType TD3D9TextureRes Extends TTextureRes\n\tField _tex:IDirect3DTexture9\nEnd Type\n\nType TD3D9SurfaceRes Extends TSurfaceRes\n\tField _pos:IDirect3DVertexBuffer9\n\tField _nml:IDirect3DVertexBuffer9\n\tField _clr:IDirect3DVertexBuffer9\n\tField _tri:IDirect3DIndexBuffer9\n\tField _tex:IDirect3DVertexBuffer9[8]\n\t\n\tMethod Copy:TD3D9SurfaceRes()\n\t\tLocal res:TD3D9SurfaceRes=New TD3D9SurfaceRes\n\t\tres._vertexcnt=_vertexcnt;res._trianglecnt=_trianglecnt\n\t\tres._pos=_pos;res._nml=_nml;res._clr=_clr;res._tri=_tri;\n\t\tFor Local i=0 To 7\n\t\t\tres._tex[i]=_tex[i]\n\t\tNext\n\t\tReturn res\n\tEnd Method\nEnd Type\n\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction D3D9MaxB3DDriver:TD3D9MaxB3DDriver()\n\tIf D3D9Max2DExDriver()\n\t\tGlobal driver:TD3D9MaxB3DDriver=New TD3D9MaxB3DDriver\n\t\tdriver._parent=D3D9Max2DExDriver()\n\t\tReturn driver\n\tEnd If\nEnd Function\n\nRem\n\tbbdoc: Utility function that sets the MaxB3D D3D9 driver and calls Graphics.\nEnd Rem\nFunction D3D9Graphics3D:TGraphics(width,height,depth=0,hertz=0,flags=0)\n\tSetGraphicsDriver D3D9MaxB3DDriver(),GRAPHICS_BACKBUFFER|GRAPHICS_DEPTHBUFFER\n\tReturn Graphics(width,height,depth,hertz,flags)\nEnd Function\n\nLocal driver:TD3D9MaxB3DDriver=D3D9MaxB3DDriver()\nIf driver SetGraphicsDriver driver,GRAPHICS_BACKBUFFER|GRAPHICS_DEPTHBUFFER\n\n?\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"bfc60503dfbccb36fdb7267f1790a66e0d41dc3a","subject":"CreateMonkeyHead fix","message":"CreateMonkeyHead fix\n","repos":"kfprimm\/maxb3d,kfprimm\/maxb3d","old_file":"monkeyheadloader.mod\/monkeyheadloader.bmx","new_file":"monkeyheadloader.mod\/monkeyheadloader.bmx","new_contents":"\nStrict\n\nRem\n\tbbdoc: Blender's 'Suzanne' model loader.\nEnd Rem\nModule MaxB3D.MonkeyHeadLoader\n\nImport MaxB3D.Core\nImport \"data.c\"\n\nExtern\n\tFunction get_monkeyhead(verts:Float Ptr Var,normals:Float Ptr Var,tris:Short Ptr Var,vert_count Var,tri_count Var)\nEnd Extern\n\nType TMeshLoaderMONKEYHEAD Extends TMeshLoader\n\tMethod Run(config:TWorldConfig,mesh:TMesh,stream:TStream,url:Object)\n\t\tIf String(url)<>\"\/\/monkeyhead\" Return False\n\t\tGlobal surface:TSurface\n\t\tIf Not surface\n\t\t\tsurface=New TSurface\n\t\t\tLocal v:Float Ptr,n:Float Ptr,t:Short Ptr,vc,tc\n\t\t\tget_monkeyhead v,n,t,vc,tc\n\t\t\tsurface.Resize vc,tc\n\t\t\t\n\t\t\tFor Local i=0 To vc-1\n\t\t\t\tsurface.SetCoords i,v[i*3+0],v[i*3+1],v[i*3+2]\n\t\t\t\tsurface.SetNormal i,-n[i*3+0],-n[i*3+1],-n[i*3+2]\n\t\t\tNext\n\t\t\t\n\t\t\tFor Local i=0 To tc-1\n\t\t\t\tsurface.SetTriangle i,t[i*3+0],t[i*3+1],t[i*3+2]\n\t\t\tNext\n\t\tEndIf\n\t\tmesh.AppendSurface surface.Copy()\n\t\tReturn True\n\tEnd Method\n\t\n\tMethod Info$()\n\t\tReturn \"Suzanne\"\n\tEnd Method\n\tMethod ModuleName$()\n\t\tReturn \"monkeyheadloader\"\n\tEnd Method\nEnd Type\nNew TMeshLoaderMONKEYHEAD\n\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction CreateMonkeyHead:TMesh(parent:TEntity=Null)\n\tReturn _currentworld.AddMesh(\"\/\/monkeyhead\",parent)\nEnd Function\n","old_contents":"\nStrict\n\nRem\n\tbbdoc: Blender's 'Suzanne' model loader.\nEnd Rem\nModule MaxB3D.MonkeyHeadLoader\n\nImport MaxB3D.Core\nImport \"data.c\"\n\nExtern\n\tFunction get_monkeyhead(verts:Float Ptr Var,normals:Float Ptr Var,tris:Short Ptr Var,vert_count Var,tri_count Var)\nEnd Extern\n\nType TMeshLoaderMONKEYHEAD Extends TMeshLoader\n\tMethod Run(config:TWorldConfig,mesh:TMesh,stream:TStream,url:Object)\n\t\tIf String(url)<>\"\/\/monkeyhead\" Return False\n\t\tGlobal surface:TSurface\n\t\tIf Not surface\n\t\t\tsurface=New TSurface\n\t\t\tLocal v:Float Ptr,n:Float Ptr,t:Short Ptr,vc,tc\n\t\t\tget_monkeyhead v,n,t,vc,tc\n\t\t\tsurface.Resize vc,tc\n\t\t\t\n\t\t\tFor Local i=0 To vc-1\n\t\t\t\tsurface.SetCoords i,v[i*3+0],v[i*3+1],v[i*3+2]\n\t\t\t\tsurface.SetNormal i,-n[i*3+0],-n[i*3+1],-n[i*3+2]\n\t\t\tNext\n\t\t\t\n\t\t\tFor Local i=0 To tc-1\n\t\t\t\tsurface.SetTriangle i,t[i*3+0],t[i*3+1],t[i*3+2]\n\t\t\tNext\n\t\tEndIf\n\t\tmesh.AppendSurface surface.Copy()\n\t\tReturn True\n\tEnd Method\n\t\n\tMethod Info$()\n\t\tReturn \"Suzanne\"\n\tEnd Method\n\tMethod ModuleName$()\n\t\tReturn \"monkeyheadloader\"\n\tEnd Method\nEnd Type\nNew TMeshLoaderMONKEYHEAD\n\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction CreateMonkeyHead:TMesh(parent:TEntity=Null)\n\tReturn _currentworld.AddMesh(\"*monkeyhead*\",parent)\nEnd Function\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"999b497cadc4f1bdd04a7485a8d78446f16137a2","subject":"[json] (v0.3) \tCorrected rootliness in dJEventHandler.","message":"[json] (v0.3)\n\tCorrected rootliness in dJEventHandler.\n","repos":"komiga\/duct-max,komiga\/duct-max,komiga\/duct-max","old_file":"json.mod\/json.bmx","new_file":"json.mod\/json.bmx","new_contents":"\nRem\nCopyright (c) 2010 Tim Howard\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and\/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\nEnd Rem\n\nSuperStrict\n\nRem\nbbdoc: JSON handler for cower.jonk\nEnd Rem\nModule duct.json\n\nModuleInfo \"Version: 0.3\"\nModuleInfo \"Copyright: Tim Howard\"\nModuleInfo \"License: MIT\"\n\nModuleInfo \"History: Version 0.3\"\nModuleInfo \"History: Corrected rootliness in dJEventHandler\"\nModuleInfo \"History: Version 0.2\"\nModuleInfo \"History: dJNullVariable.ValueAsString now returns Null (instead of ~qnull~q); documentation correction\"\nModuleInfo \"History: Version 0.1\"\nModuleInfo \"History: Initial version.\"\n\nImport duct.variables\nImport cower.jonk\n\nRem\n\tbbdoc: duct JSON object.\nEnd Rem\nType dJObject Extends TIdentifier\n\t\n\tRem\n\t\tbbdoc: Create a new dJObject.\n\t\treturns: The new dJObject (itself).\n\tEnd Rem\n\tMethod Create:dJObject()\n\t\tSuper.Create()\n\t\tReturn Self\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the object's parent.\n\t\treturns: The object's parent.\n\tEnd Rem\n\tMethod GetParent:dJObject()\n\t\tReturn dJObject(m_parent)\n\tEnd Method\n\t\nEnd Type\n\nRem\n\tbbdoc: duct JSON array.\nEnd Rem\nType dJArray Extends dJObject\n\t\n\tRem\n\t\tbbdoc: Create a new dJArray.\n\t\treturns: The new dJArray (itself).\n\tEnd Rem\n\tMethod Create:dJArray()\n\t\tSuper.Create()\n\t\tReturn Self\n\tEnd Method\n\t\nEnd Type\n\nConst TV_NULL:Int = 100\n\nRem\n\tbbdoc: duct JSON null variable.\nEnd Rem\nType dJNullVariable Extends TVariable\n\t\n\tRem\n\t\tbbdoc: Create a New dJNullVariable.\n\t\treturns: The New dJNullVariable (itself).\n\tEnd Rem\n\tMethod Create:dJNullVariable(name:String = Null)\n\t\tSetName(name)\n\t\tReturn Self\n\tEnd Method\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the value of the variable To the given String (ambiguous).\n\t\treturns: Nothing.\n\t\tabout: This does nothing for dJNullVariable.\n\tEnd Rem\n\tMethod SetAmbiguous(value:String)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Convert the variable to a String.\n\t\treturns: A string representation of the variable.\n\t\tabout: This function is for script output, for in-code use see #ValueAsString.\n\tEnd Rem\n\tMethod ConvToString:String()\n\t\tReturn \"null\"\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the variable as a String.\n\t\treturns: The variable's value converted to a String.\n\tEnd Rem\n\tMethod ValueAsString:String()\n\t\tReturn Null\n\tEnd Method\n\t\n'#end region (Field accessors)\n\t\n'#region Data handling\n\t\n\tRem\n\t\tbbdoc: Create a copy of the variable\n\t\treturns: A clone of the variable.\n\tEnd Rem\n\tMethod Copy:dJNullVariable()\n\t\tReturn New dJNullVariable.Create(m_name)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Serialize the variable to a stream.\n\t\treturns: Nothing.\n\t\tabout: @tv tells the method whether it should serialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod Serialize(stream:TStream, tv:Int = True, name:Int = False)\n\t\tIf tv = True\n\t\t\tstream.WriteByte(TV_INTEGER)\n\t\tEnd If\n\t\tIf name = True\n\t\t\tWriteLString(stream, m_name)\n\t\tEnd If\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Deserialize the variable from a stream.\n\t\treturns: The deserialized variable.\n\t\tabout: @tv tells the method whether it should deserialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod DeSerialize:dJNullVariable(stream:TStream, tv:Int = True, name:Int = False)\n\t\tIf tv = True\n\t\t\tstream.ReadByte()\n\t\tEnd If\n\t\tIf name = True\n\t\t\tm_name = ReadLString(stream)\n\t\tEnd If\n\t\tReturn Self\n\tEnd Method\n\t\n'#end region (Data handling)\n\t\n\tRem\n\t\tbbdoc: Get the type of this variable.\n\t\treturns: The type of this variable (\"null\").\n\tEnd Rem\n\tFunction ReportType:String()\n\t\tReturn \"null\"\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Get the TV type of this variable.\n\t\treturns: The TV_* type of this variable (TV_NULL).\n\tEnd Rem\n\tFunction GetTVType:Int()\n\t\tReturn TV_NULL\n\tEnd Function\n\t\nEnd Type\n\nRem\n\tbbdoc: duct event handler for JONK.\nEnd Rem\nType dJEventHandler Extends JEventHandler\n\t\n\tField m_objname:String\n\tField m_root:dJObject\n\tField m_object:dJObject\n\t\n\tField tmpvar:TVariable\n\t\n\tMethod BeginParsing()\n\t\t'm_root = New dJObject.Create()\n\t\t'm_object = m_root\n\tEnd Method\n\t\n\tMethod EndParsing()\n\t\t'Assert m_object = m_root, \"(dJEventHandler.EndParsing) m_object != m_root!\"\n\t\tm_objname = Null\n\t\tm_object = Null\n\tEnd Method\n\t\n\tMethod ObjectBegin()\n\t\ttmpvar = New dJObject.Create()\n\t\tDoBegin()\n\tEnd Method\n\t\n\tMethod ObjectKey(name:String)\n\t\tm_objname = name\n\tEnd Method\n\t\n\tMethod ObjectEnd()\n\t\tm_object = dJObject(m_object.GetParent())\n\tEnd Method\n\t\n\tMethod ArrayBegin()\n\t\ttmpvar = New dJArray.Create()\n\t\tDoBegin()\n\tEnd Method\n\t\n\tMethod ArrayEnd()\n\t\tm_object = dJObject(m_object.GetParent())\n\tEnd Method\n\t\n\tMethod NumberValue(number:String, isdecimal:Int)\n\t\tIf isdecimal = True\n\t\t\ttmpvar = New TFloatVariable.Create(Null, Float(number))\n\t\tElse\n\t\t\ttmpvar = New TIntVariable.Create(Null, Int(number))\n\t\tEnd If\n\t\tSetAndClearName(tmpvar)\n\t\tm_object.AddValue(tmpvar)\n\tEnd Method\n\t\n\tMethod StringValue(value:String)\n\t\ttmpvar = New TStringVariable.Create(Null, value)\n\t\tSetAndClearName(tmpvar)\n\t\tm_object.AddValue(tmpvar)\n\tEnd Method\n\t\n\tMethod BooleanValue(value:Int)\n\t\ttmpvar = New TBoolVariable.Create(Null, value)\n\t\tSetAndClearName(tmpvar)\n\t\tm_object.AddValue(tmpvar)\n\tEnd Method\n\t\n\tMethod NullValue()\n\t\ttmpvar = New dJNullVariable.Create(Null)\n\t\tSetAndClearName(tmpvar)\n\t\tm_object.AddValue(tmpvar)\n\tEnd Method\n\t\n\tMethod Error:Int(err:JParserException)\n\t\tReturn False\n\tEnd Method\n\t\n\tMethod SetAndClearName(variable:TVariable)\n\t\tvariable.SetName(m_objname)\n\t\tm_objname = Null\n\tEnd Method\n\t\n\tMethod DoBegin()\n\t\tSetAndClearName(tmpvar)\n\t\tIf m_object <> Null m_object.AddValue(tmpvar)\n\t\tm_object = dJObject(tmpvar)\n\t\tIf Not m_root Then m_root = m_object\n\tEnd Method\n\t\nEnd Type\n\nRem\n\tbbdoc: duct JSON reader.\nEnd Rem\nType dJReader\n\t\n\tField m_evthandler:dJEventHandler\n\tField m_parser:JParser\n\tField m_root:dJObject\n\t\n\tMethod New()\n\t\tm_evthandler = New dJEventHandler\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Initiate the reader with the given url\/stream.\n\t\treturns: Itself, or Null if the stream could not be opened.\n\tEnd Rem\n\tMethod InitWithStream:dJReader(url:Object, encoding:Int = JSONEncodingUTF8, bufferLength:Int = JParser.JPARSERBUFFER_INITIAL_SIZE)\n\t\tTry\n\t\t\tm_parser = New JParser.InitWithStream(url, m_evthandler, encoding, bufferLength)\n\t\t\tReturn Self\n\t\tCatch e:JException\n\t\t\tReturn Null\n\t\tEnd Try\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Initiate the reader with the given string.\n\t\treturns: Itself.\n\tEnd Rem\n\tMethod InitWithString:dJReader(str:String)\n\t\tm_parser = New JParser.InitWithString(str, m_evthandler)\n\t\tReturn Self\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Parse the reader's data.\n\t\treturns: The root object for the json data.\n\t\tabout: A #JParserException will be thrown if there is an error during parsing.\n\tEnd Rem\n\tMethod Parse:dJObject()\n\t\tm_parser.Parse()\n\t\tReturn m_evthandler.m_root\n\tEnd Method\n\t\nEnd Type\n\n","old_contents":"\nRem\n\tCopyright (c) 2009 Tim Howard\n\t\n\tPermission is hereby granted, free of charge, to any person obtaining a copy\n\tof this software and associated documentation files (the \"Software\"), to deal\n\tin the Software without restriction, including without limitation the rights\n\tto use, copy, modify, merge, publish, distribute, sublicense, and\/or sell\n\tcopies of the Software, and to permit persons to whom the Software is\n\tfurnished to do so, subject to the following conditions:\n\t\n\tThe above copyright notice and this permission notice shall be included in\n\tall copies or substantial portions of the Software.\n\t\n\tTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n\tIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n\tFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n\tAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n\tLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n\tOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n\tTHE SOFTWARE.\nEnd Rem\n\nSuperStrict\n\nRem\nbbdoc: JSON handler for cower.jonk\nEnd Rem\nModule duct.json\n\nModuleInfo \"Version: 0.2\"\nModuleInfo \"Copyright: Tim Howard\"\nModuleInfo \"License: MIT\"\n\nModuleInfo \"History: Version 0.2\"\nModuleInfo \"History: dJNullVariable.ValueAsString now returns Null (instead of ~qnull~q); documentation correction\"\nModuleInfo \"History: Version 0.1\"\nModuleInfo \"History: Initial version.\"\n\nImport duct.variables\nImport cower.jonk\n\nRem\n\tbbdoc: duct JSON object.\nEnd Rem\nType dJObject Extends TIdentifier\n\t\n\tRem\n\t\tbbdoc: Create a new dJObject.\n\t\treturns: The new dJObject (itself).\n\tEnd Rem\n\tMethod Create:dJObject()\n\t\tSuper.Create()\n\t\tReturn Self\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the object's parent.\n\t\treturns: The object's parent.\n\tEnd Rem\n\tMethod GetParent:dJObject()\n\t\tReturn dJObject(m_parent)\n\tEnd Method\n\t\nEnd Type\n\nRem\n\tbbdoc: duct JSON array.\nEnd Rem\nType dJArray Extends dJObject\n\t\n\tRem\n\t\tbbdoc: Create a new dJArray.\n\t\treturns: The new dJArray (itself).\n\tEnd Rem\n\tMethod Create:dJArray()\n\t\tSuper.Create()\n\t\tReturn Self\n\tEnd Method\n\t\nEnd Type\n\nConst TV_NULL:Int = 100\n\nRem\n\tbbdoc: duct JSON null variable.\nEnd Rem\nType dJNullVariable Extends TVariable\n\t\n\tRem\n\t\tbbdoc: Create a New dJNullVariable.\n\t\treturns: The New dJNullVariable (itself).\n\tEnd Rem\n\tMethod Create:dJNullVariable(name:String = Null)\n\t\tSetName(name)\n\t\tReturn Self\n\tEnd Method\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the value of the variable To the given String (ambiguous).\n\t\treturns: Nothing.\n\t\tabout: This does nothing for dJNullVariable.\n\tEnd Rem\n\tMethod SetAmbiguous(value:String)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Convert the variable to a String.\n\t\treturns: A string representation of the variable.\n\t\tabout: This function is for script output, for in-code use see #ValueAsString.\n\tEnd Rem\n\tMethod ConvToString:String()\n\t\tReturn \"null\"\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the variable as a String.\n\t\treturns: The variable's value converted to a String.\n\tEnd Rem\n\tMethod ValueAsString:String()\n\t\tReturn Null\n\tEnd Method\n\t\n'#end region (Field accessors)\n\t\n'#region Data handling\n\t\n\tRem\n\t\tbbdoc: Create a copy of the variable\n\t\treturns: A clone of the variable.\n\tEnd Rem\n\tMethod Copy:dJNullVariable()\n\t\tReturn New dJNullVariable.Create(m_name)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Serialize the variable to a stream.\n\t\treturns: Nothing.\n\t\tabout: @tv tells the method whether it should serialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod Serialize(stream:TStream, tv:Int = True, name:Int = False)\n\t\tIf tv = True\n\t\t\tstream.WriteByte(TV_INTEGER)\n\t\tEnd If\n\t\tIf name = True\n\t\t\tWriteLString(stream, m_name)\n\t\tEnd If\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Deserialize the variable from a stream.\n\t\treturns: The deserialized variable.\n\t\tabout: @tv tells the method whether it should deserialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod DeSerialize:dJNullVariable(stream:TStream, tv:Int = True, name:Int = False)\n\t\tIf tv = True\n\t\t\tstream.ReadByte()\n\t\tEnd If\n\t\tIf name = True\n\t\t\tm_name = ReadLString(stream)\n\t\tEnd If\n\t\tReturn Self\n\tEnd Method\n\t\n'#end region (Data handling)\n\t\n\tRem\n\t\tbbdoc: Get the type of this variable.\n\t\treturns: The type of this variable (\"null\").\n\tEnd Rem\n\tFunction ReportType:String()\n\t\tReturn \"null\"\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Get the TV type of this variable.\n\t\treturns: The TV_* type of this variable (TV_NULL).\n\tEnd Rem\n\tFunction GetTVType:Int()\n\t\tReturn TV_NULL\n\tEnd Function\n\t\nEnd Type\n\nRem\n\tbbdoc: duct event handler for JONK.\nEnd Rem\nType dJEventHandler Extends JEventHandler\n\t\n\tField m_objname:String\n\tField m_root:dJObject\n\tField m_object:dJObject\n\t\n\tField tmpvar:TVariable\n\t\n\tMethod BeginParsing()\n\t\tm_root = New dJObject.Create()\n\t\tm_object = m_root\n\tEnd Method\n\t\n\tMethod EndParsing()\n\t\tAssert m_object = m_root, \"(dJEventHandler.EndParsing) m_object != m_root!\"\n\t\tm_objname = Null\n\t\tm_object = Null\n\tEnd Method\n\t\n\tMethod ObjectBegin()\n\t\ttmpvar = New dJObject.Create()\n\t\tSetAndClearName(tmpvar)\n\t\tm_object.AddValue(tmpvar)\n\t\tm_object = dJObject(tmpvar)\n\tEnd Method\n\t\n\tMethod ObjectKey(name:String)\n\t\tm_objname = name\n\tEnd Method\n\t\n\tMethod ObjectEnd()\n\t\tm_object = dJObject(m_object.GetParent())\n\tEnd Method\n\t\n\tMethod ArrayBegin()\n\t\ttmpvar = New dJArray.Create()\n\t\tSetAndClearName(tmpvar)\n\t\tm_object.AddValue(tmpvar)\n\t\tm_object = dJObject(tmpvar)\n\tEnd Method\n\t\n\tMethod ArrayEnd()\n\t\tm_object = dJObject(m_object.GetParent())\n\tEnd Method\n\t\n\tMethod NumberValue(number:String, isdecimal:Int)\n\t\tIf isdecimal = True\n\t\t\ttmpvar = New TFloatVariable.Create(Null, Float(number))\n\t\tElse\n\t\t\ttmpvar = New TIntVariable.Create(Null, Int(number))\n\t\tEnd If\n\t\tSetAndClearName(tmpvar)\n\t\tm_object.AddValue(tmpvar)\n\tEnd Method\n\t\n\tMethod StringValue(value:String)\n\t\ttmpvar = New TStringVariable.Create(Null, value)\n\t\tSetAndClearName(tmpvar)\n\t\tm_object.AddValue(tmpvar)\n\tEnd Method\n\t\n\tMethod BooleanValue(value:Int)\n\t\ttmpvar = New TBoolVariable.Create(Null, value)\n\t\tSetAndClearName(tmpvar)\n\t\tm_object.AddValue(tmpvar)\n\tEnd Method\n\t\n\tMethod NullValue()\n\t\ttmpvar = New dJNullVariable.Create(Null)\n\t\tSetAndClearName(tmpvar)\n\t\tm_object.AddValue(tmpvar)\n\tEnd Method\n\t\n\tMethod Error:Int(err:JParserException)\n\t\tReturn False\n\tEnd Method\n\t\n\tMethod SetAndClearName(variable:TVariable)\n\t\tvariable.SetName(m_objname)\n\t\tm_objname = Null\n\tEnd Method\n\t\nEnd Type\n\nRem\n\tbbdoc: duct JSON reader.\nEnd Rem\nType dJReader\n\t\n\tField m_evthandler:dJEventHandler\n\tField m_parser:JParser\n\tField m_root:dJObject\n\t\n\tMethod New()\n\t\tm_evthandler = New dJEventHandler\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Initiate the reader with the given url\/stream.\n\t\treturns: Itself, or Null if the stream could not be opened.\n\tEnd Rem\n\tMethod InitWithStream:dJReader(url:Object, encoding:Int = JSONEncodingUTF8, bufferLength:Int = JParser.JPARSERBUFFER_INITIAL_SIZE)\n\t\tTry\n\t\t\tm_parser = New JParser.InitWithStream(url, m_evthandler, encoding, bufferLength)\n\t\t\tReturn Self\n\t\tCatch e:JException\n\t\t\tReturn Null\n\t\tEnd Try\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Initiate the reader with the given string.\n\t\treturns: Itself.\n\tEnd Rem\n\tMethod InitWithString:dJReader(str:String)\n\t\tm_parser = New JParser.InitWithString(str, m_evthandler)\n\t\tReturn Self\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Parse the reader's data.\n\t\treturns: The root object for the json data.\n\t\tabout: A #JParserException will be thrown if there is an error during parsing.\n\tEnd Rem\n\tMethod Parse:dJObject()\n\t\tm_parser.Parse()\n\t\tReturn m_evthandler.m_root\n\tEnd Method\n\t\nEnd Type\n\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"9f35ac1cbfad20dce2bc8455dd3079db78909eec","subject":"Added Karja's SetMatrix code for MonkeyMax.","message":"Added Karja's SetMatrix code for MonkeyMax.\n\n--HG--\nextra : convert_revision : svn%3Ae934d3cd-0d57-f34a-94d0-9e8d31ae1c29\/trunk%40345\n","repos":"programmerby\/diddy-mirror,programmerby\/diddy-mirror,programmerby\/diddy-mirror,programmerby\/diddy-mirror","old_file":"monkeymax\/modules\/mojo\/native\/mojo.bmax.bmx","new_file":"monkeymax\/modules\/mojo\/native\/mojo.bmax.bmx","new_contents":"' ***** Start mojo.bmax.bmx ******\r\n\r\nGlobal app:gxtkApp;\r\n\r\nType gxtkApp\r\n\tField ginput:gxtkInput;\r\n\tField gaudio:gxtkAudio;\r\n\tField ggraphics:gxtkGraphics;\r\n\r\n\tField dead:int=0;\r\n\tField suspended:int=0;\r\n\tField vloading:int=0;\r\n\tField maxloading:int=0;\r\n\tField updateRate:int=0;\r\n\tField nextUpdate:Float=0;\r\n\tField updatePeriod:Float=0;\r\n\tField startMillis:Float=0;\r\n\t\r\n\tMethod New()' gxtkApp()\r\n\t\tapp=self;\r\n\t\tggraphics=new gxtkGraphics;\r\n\tEndMethod\r\n\t\r\n\tMethod Setup()\r\n\t\t\r\n\t\tginput=new gxtkInput;\r\n\t\tgaudio=new gxtkAudio;\r\n\r\n\t\tbb_input_SetInputDevice(ginput);\r\n\t\tbb_audio_SetAudioDevice(gaudio);\r\n\t\t\r\n\t\tstartMillis=BlitzMaxMillisecs()\r\n\t\t\r\n\t\t'game.stage.addEventListener( Event.ENTER_FRAME,OnEnterFrame );\r\n\t\t\r\n\t\tSetFrameRate( 0 );\r\n\t\t\r\n\t\tInvokeOnCreate();\r\n\t\tInvokeOnRender();\r\n\t\tUpdate()\r\n\tEndMethod\r\n\t\r\n\tMethod Update()\r\n\t\tWhile Not AppTerminate()\r\n\t\t\tlocal updates:Int = 0\r\n\t\t\t\r\n\t\t\tlocal cont:int = 1\r\n\t\t\tWhile (cont)\r\n\t\t\t\tnextUpdate:+updatePeriod\r\n\t\t\t\tInvokeOnUpdate()\r\n\t\t\t\tif not updatePeriod then cont = 0\r\n\t\t\t\tif nextUpdate>BlitzMaxMillisecs() then cont = 0\r\n\t\t\t\tupdates:+1\r\n\t\t\t\tif updates = 7 then\r\n\t\t\t\t\tnextUpdate = BlitzMaxMillisecs()\r\n\t\t\t\t\tcont = 0\r\n\t\t\t\tendif\r\n\t\t\tWend\r\n\t\t\tInvokeOnRender()\r\n\t\tWend\r\n\tEndMethod\r\n\t\r\n\tMethod InvokeOnCreate()\r\n\t\tif dead return\r\n\t\tdead = 1\r\n\t\tOnCreate()\r\n\t\tdead = 0\r\n\tEndMethod\r\n\r\n\tMethod InvokeOnUpdate()\r\n\t\tif dead or suspended or not updateRate or vloading return\r\n\t\tOnUpdate()\r\n\tEndMethod\r\n\t\r\n\tMethod InvokeOnRender()\r\n\t\tif dead or suspended return\r\n\t\tggraphics.BeginRender()\r\n\t\tif vloading\r\n\t\t\tOnLoading()\r\n\t\telse\r\n\t\t\tOnRender()\r\n\t\tEndif\r\n\t\tggraphics.EndRender()\r\n\tEndMethod\r\n\t\r\n\t\r\n\tMethod SetFrameRate( fps:int )\r\n\t\tif fps\r\n\t\t\tupdatePeriod=1000.0\/fps;\r\n\t\t\tnextUpdate=BlitzMaxMillisecs() +updatePeriod;\r\n\t\telse\r\n\t\t\tupdatePeriod=0\r\n\t\tendif\r\n\tEndMethod\r\n\t\r\n\tMethod LoadString:String( path:String )\r\n\t\tpath = \"data\/\" + path;\r\n\t\tReturn LoadText( path )\r\n\tEndMethod\r\n\t\r\n\t' ***** GXTK API *****\r\n\t\r\n\tMethod GraphicsDevice:gxtkGraphics()\r\n\t\tReturn ggraphics\r\n\tEndMethod\r\n\r\n\tMethod InputDevice:gxtkInput()\r\n\t\tReturn ginput\r\n\tEndMethod\r\n\r\n\tMethod AudioDevice:gxtkAudio()\r\n\t\tReturn gaudio\r\n\tEndMethod\r\n\r\n\tMethod SetUpdateRate:int(hertz:int)\r\n\t\tupdateRate = hertz\r\n\t\tif not vloading then SetFrameRate(updateRate)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod MilliSecs:Int()\r\n\t\treturn BlitzMaxMillisecs() - startMillis\r\n\tEndMethod\r\n\t\r\n\tMethod Loading:int()\r\n\t\treturn vloading;\r\n\tEndMethod\r\n\r\n\tMethod OnCreate:int()\r\n\t\treturn 0;\r\n\tEndMethod\r\n\r\n\tMethod OnUpdate:int()\r\n\t\treturn 0;\r\n\tEndMethod\r\n\t\r\n\tMethod OnSuspend:int()\r\n\t\treturn 0;\r\n\tEndMethod\r\n\t\r\n\tMethod OnResume:int()\r\n\t\treturn 0;\r\n\tEndMethod\r\n\t\r\n\tMethod OnRender:int()\r\n\t\treturn 0;\r\n\tEndMethod\r\n\t\r\n\tMethod OnLoading:int()\r\n\t\treturn 0;\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkGraphics\r\n\tField gmode:Int = 1\r\n\r\n\tMethod Mode:Int()\r\n\t\treturn gmode\r\n\tEndMethod\r\n\t\r\n\tMethod Cls:Int(r:int = 0, g:int = 0, b:int = 0)\r\n\t\tBlitzMaxCls(r, g, b)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod LoadSurface:gxtkSurface(path:String)\r\n\t\tlocal image:TImage = LoadImage(\"data\/\"+path)\r\n\t\tif image then\r\n\t\t\tlocal gs:gxtkSurface = new gxtkSurface\r\n\t\t\tgs.setImage(image)\r\n\t\t\treturn gs\r\n\t\tendif\r\n\t\treturn null\r\n\tEndMethod\r\n\t\r\n\tMethod BeginRender()\r\n\tEndMethod\r\n\t\r\n\tMethod EndRender()\r\n\t\tFlip\r\n\tEndMethod\r\n\t\r\n\tMethod SetColor:Int(r:Int, g:Int, b:Int)\r\n\t\tBlitzMaxSetColor(r, g, b)\r\n\t\treturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod SetAlpha:Int(a:Float)\r\n\t\tBlitzMaxSetAlpha(a)\r\n\t\treturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod SetBlend:Int(blend:Int)\r\n\t\tBlitzMaxSetBlend(blend)\r\n\t\treturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod Width:Int()\r\n\t\t'TO-DO\r\n\t\tReturn 800\r\n\tEndMethod\r\n\t\r\n\tMethod Height:Int()\r\n\t\t'TO-DO\r\n\t\tReturn 600\r\n\tEndMethod\r\n\t\r\n\tMethod SetScissor:Int(x:int, y:int, w:int, h:int)\r\n 'TO-DO\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod SetMatrix:Int(ix:float,iy:float,jx:float,jy:float,tx:float,ty:float)\r\n\t\tLocal sx:Float = Sqr( (ix*ix) + (jx*jx) )\r\n\t\tLocal sy:Float = Sqr( (iy*iy) + (jy*jy) )\r\n\t\tLocal rot:Float = Atan2( jx, ix )\r\n\t\tSetTransform( rot, sx, sy )\r\n\t\tSetOrigin( tx, ty )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawSurface:Int(surface:gxtkSurface,x:Float,y:Float)\r\n\t\tDrawImage(surface.image, x, y, 0)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawSurface2:Int(surface:gxtkSurface,x:Float,y:Float, srcx:int, srcy:int, srcw:int, srch:int )\r\n\r\n\t'\tPrint \"x = \"+x\r\n\t'\tPrint \"y = \"+y\r\n\t'\tPrint \"srcx = \"+srcx\r\n\t'\tPrint \"srcy = \"+srcy\r\n\t'\tPrint \"srcw = \"+srcw\r\n\t'\tPrint \"srch = \"+srch\r\n\t\tDrawSubImageRect(surface.image, x, y, srcw, srch, srcx, srcy, srcw, srch)\r\n\t\t\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawLine:Int( x1:Float,y1:Float,x2:Float,y2:Float )\r\n\t\tBlitzMaxDrawLine(x1, y1, x2, y2)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawOval:Int( x:Float, y:Float, w:Float, h:Float )\r\n\t\tBlitzMaxDrawOval(x, y, w, h)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawPoly:Int(vertices:Float[])\r\n\t\tBlitzMaxDrawPoly( vertices )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawRect:Int( x:Float, y:Float, w:Float, h:Float )\r\n\t\tBlitzMaxDrawRect(x, y, w, h)\r\n\t\tReturn 0\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkInput\r\n\tMethod MouseX:Float()\r\n\t\treturn 0\r\n\tEndMethod\r\n\r\n\tMethod MouseY:Float()\r\n\t\treturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod KeyDown:Int( key:Int )\r\n\t\treturn BRL.PolledInput.KeyDown( key )\r\n\tEndMethod\r\n\r\n\tMethod KeyHit:Int( key:Int )\r\n\t\treturn BRL.PolledInput.KeyHit( key )\r\n\tEndMethod\r\n\r\n\tMethod GetChar:Int()\r\n\t\treturn BRL.PolledInput.GetChar()\r\n\tEndMethod\r\n\r\n\tMethod JoyX:Int( index:Int )\r\n\t\treturn Pub.FreeJoy.JoyX( index )\r\n\tEndMethod\r\n\r\n\tMethod JoyY:Int( index:Int )\r\n\t\treturn Pub.FreeJoy.JoyY( index )\r\n\tEndMethod\r\n\r\n\tMethod JoyZ:Int( index:Int )\r\n\t\treturn Pub.FreeJoy.JoyZ( index )\r\n\tEndMethod\r\n\r\n\tMethod TouchX:Float( index:Int )\r\n\t\treturn 0\r\n\tEndMethod\r\n\r\n\tMethod TouchY:Float( index:Int )\r\n\t\treturn 0\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkAudio\r\n\tField amusicState:Int = 0;\r\n\r\n\tMethod MusicState:Int()\r\n'\t\tIf( musicState = 1 And music.isPlaying() = False )\r\n'\t\t\tmusicState = 0;\r\n'\t\tEndif\r\n\t\treturn amusicState;\r\n\tEndMethod\r\n\t\r\n\tMethod PlayMusic:Int( path:String, flags:int )\r\n\t\treturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod StopMusic()\r\n\tEndMethod\r\n\t\r\n\tMethod StopChannel( channel:Int )\r\n\tEndMethod\r\n\r\n\tMethod PlaySample( sound:gxtkSample, channel:Int, flags:Int )\r\n\tEndMethod\r\n\r\n\tMethod SetPan( channel:Int, pan:Float )\r\n\tEndMethod\r\n\r\n\tMethod SetRate( channel:Int, rate:Float )\r\n\tEndMethod\r\n\r\n\tMethod SetMusicVolume:Int( volume:Float )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod SetVolume:Int( channel:Int, volume:Float )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod LoadSample:gxtkSample( path:String )\r\n\t\tReturn Null\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkSample\r\n\tMethod Discard()\r\n\tEndMethod\r\nEndType\r\n\r\nFunction BlitzMaxDrawPoly:Int(vertices:Float[])\r\n\tDrawPoly vertices\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxDrawRect:Int( x:Float, y:Float, w:Float, h:Float )\r\n\tDrawRect x, y, w, h\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxDrawOval:Int( x:Float, y:Float, w:Float, h:Float )\r\n\tDrawOval x, y, w, h\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxDrawLine:Int( x1:Float,y1:Float,x2:Float,y2:Float )\r\n\tDrawLine x1, y1, x2, y2\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxMillisecs:Int()\r\n\treturn MilliSecs()\r\nEndFunction\r\n\r\nFunction BlitzMaxSetColor(r:Int, g:Int, b:Int)\r\n\tSetColor(r, g, b)\r\nEndFunction\r\n\r\nFunction BlitzMaxSetBlend(blend:Int)\r\n\tSetBlend(blend)\r\nEndFunction\r\n\r\nFunction BlitzMaxSetAlpha(a:Float)\r\n\tSetAlpha(a)\r\nEndFunction\r\n\r\nFunction BlitzMaxCls(r:Int = 0, g:Int = 0, b:Int = 0)\r\n\tSetClsColor(r, g, b)\r\n\tCls\r\nEndFunction\r\n\r\nType gxtkSurface\r\n\tField w:Int, h:Int\r\n\tField image:TImage\r\n\t\r\n\tMethod setImage(image:TImage)\r\n\t\tself.image = image\r\n\tEndMethod\r\n\t\r\n\tMethod Width:Int()\r\n\t\treturn image.Width\r\n\tEndMethod\r\n\t\r\n\tMethod Height:Int()\r\n\t\treturn image.Height\r\n\tEndMethod\r\n\t\r\n\tMethod Discard()\r\n\tEndMethod\r\nEndType\r\n\r\n' ***** End mojo.bmax.bmx ******\r\n\r\n","old_contents":"' ***** Start mojo.bmax.bmx ******\r\n\r\nGlobal app:gxtkApp;\r\n\r\nType gxtkApp\r\n\tField ginput:gxtkInput;\r\n\tField gaudio:gxtkAudio;\r\n\tField ggraphics:gxtkGraphics;\r\n\r\n\tField dead:int=0;\r\n\tField suspended:int=0;\r\n\tField vloading:int=0;\r\n\tField maxloading:int=0;\r\n\tField updateRate:int=0;\r\n\tField nextUpdate:Float=0;\r\n\tField updatePeriod:Float=0;\r\n\tField startMillis:Float=0;\r\n\t\r\n\tMethod New()' gxtkApp()\r\n\t\tapp=self;\r\n\t\tggraphics=new gxtkGraphics;\r\n\tEndMethod\r\n\t\r\n\tMethod Setup()\r\n\t\t\r\n\t\tginput=new gxtkInput;\r\n\t\tgaudio=new gxtkAudio;\r\n\r\n\t\tbb_input_SetInputDevice(ginput);\r\n\t\tbb_audio_SetAudioDevice(gaudio);\r\n\t\t\r\n\t\tstartMillis=BlitzMaxMillisecs()\r\n\t\t\r\n\t\t'game.stage.addEventListener( Event.ENTER_FRAME,OnEnterFrame );\r\n\t\t\r\n\t\tSetFrameRate( 0 );\r\n\t\t\r\n\t\tInvokeOnCreate();\r\n\t\tInvokeOnRender();\r\n\t\tUpdate()\r\n\tEndMethod\r\n\t\r\n\tMethod Update()\r\n\t\tWhile Not AppTerminate()\r\n\t\t\tlocal updates:Int = 0\r\n\t\t\t\r\n\t\t\tlocal cont:int = 1\r\n\t\t\tWhile (cont)\r\n\t\t\t\tnextUpdate:+updatePeriod\r\n\t\t\t\tInvokeOnUpdate()\r\n\t\t\t\tif not updatePeriod then cont = 0\r\n\t\t\t\tif nextUpdate>BlitzMaxMillisecs() then cont = 0\r\n\t\t\t\tupdates:+1\r\n\t\t\t\tif updates = 7 then\r\n\t\t\t\t\tnextUpdate = BlitzMaxMillisecs()\r\n\t\t\t\t\tcont = 0\r\n\t\t\t\tendif\r\n\t\t\tWend\r\n\t\t\tInvokeOnRender()\r\n\t\tWend\r\n\tEndMethod\r\n\t\r\n\tMethod InvokeOnCreate()\r\n\t\tif dead return\r\n\t\tdead = 1\r\n\t\tOnCreate()\r\n\t\tdead = 0\r\n\tEndMethod\r\n\r\n\tMethod InvokeOnUpdate()\r\n\t\tif dead or suspended or not updateRate or vloading return\r\n\t\tOnUpdate()\r\n\tEndMethod\r\n\t\r\n\tMethod InvokeOnRender()\r\n\t\tif dead or suspended return\r\n\t\tggraphics.BeginRender()\r\n\t\tif vloading\r\n\t\t\tOnLoading()\r\n\t\telse\r\n\t\t\tOnRender()\r\n\t\tEndif\r\n\t\tggraphics.EndRender()\r\n\tEndMethod\r\n\t\r\n\t\r\n\tMethod SetFrameRate( fps:int )\r\n\t\tif fps\r\n\t\t\tupdatePeriod=1000.0\/fps;\r\n\t\t\tnextUpdate=BlitzMaxMillisecs() +updatePeriod;\r\n\t\telse\r\n\t\t\tupdatePeriod=0\r\n\t\tendif\r\n\tEndMethod\r\n\t\r\n\tMethod LoadString:String( path:String )\r\n\t\tpath = \"data\/\" + path;\r\n\t\tReturn LoadText( path )\r\n\tEndMethod\r\n\t\r\n\t' ***** GXTK API *****\r\n\t\r\n\tMethod GraphicsDevice:gxtkGraphics()\r\n\t\tReturn ggraphics\r\n\tEndMethod\r\n\r\n\tMethod InputDevice:gxtkInput()\r\n\t\tReturn ginput\r\n\tEndMethod\r\n\r\n\tMethod AudioDevice:gxtkAudio()\r\n\t\tReturn gaudio\r\n\tEndMethod\r\n\r\n\tMethod SetUpdateRate:int(hertz:int)\r\n\t\tupdateRate = hertz\r\n\t\tif not vloading then SetFrameRate(updateRate)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod MilliSecs:Int()\r\n\t\treturn BlitzMaxMillisecs() - startMillis\r\n\tEndMethod\r\n\t\r\n\tMethod Loading:int()\r\n\t\treturn vloading;\r\n\tEndMethod\r\n\r\n\tMethod OnCreate:int()\r\n\t\treturn 0;\r\n\tEndMethod\r\n\r\n\tMethod OnUpdate:int()\r\n\t\treturn 0;\r\n\tEndMethod\r\n\t\r\n\tMethod OnSuspend:int()\r\n\t\treturn 0;\r\n\tEndMethod\r\n\t\r\n\tMethod OnResume:int()\r\n\t\treturn 0;\r\n\tEndMethod\r\n\t\r\n\tMethod OnRender:int()\r\n\t\treturn 0;\r\n\tEndMethod\r\n\t\r\n\tMethod OnLoading:int()\r\n\t\treturn 0;\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkGraphics\r\n\tField gmode:Int = 1\r\n\r\n\tMethod Mode:Int()\r\n\t\treturn gmode\r\n\tEndMethod\r\n\t\r\n\tMethod Cls:Int(r:int = 0, g:int = 0, b:int = 0)\r\n\t\tBlitzMaxCls(r, g, b)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod LoadSurface:gxtkSurface(path:String)\r\n\t\tlocal image:TImage = LoadImage(\"data\/\"+path)\r\n\t\tif image then\r\n\t\t\tlocal gs:gxtkSurface = new gxtkSurface\r\n\t\t\tgs.setImage(image)\r\n\t\t\treturn gs\r\n\t\tendif\r\n\t\treturn null\r\n\tEndMethod\r\n\t\r\n\tMethod BeginRender()\r\n\tEndMethod\r\n\t\r\n\tMethod EndRender()\r\n\t\tFlip\r\n\tEndMethod\r\n\t\r\n\tMethod SetColor:Int(r:Int, g:Int, b:Int)\r\n\t\tBlitzMaxSetColor(r, g, b)\r\n\t\treturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod SetAlpha:Int(a:Float)\r\n\t\tBlitzMaxSetAlpha(a)\r\n\t\treturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod SetBlend:Int(blend:Int)\r\n\t\tBlitzMaxSetBlend(blend)\r\n\t\treturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod Width:Int()\r\n\t\t'TO-DO\r\n\t\tReturn 800\r\n\tEndMethod\r\n\t\r\n\tMethod Height:Int()\r\n\t\t'TO-DO\r\n\t\tReturn 600\r\n\tEndMethod\r\n\t\r\n\tMethod SetScissor:Int(x:int, y:int, w:int, h:int)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod SetMatrix:Int(x:float,iy:float,jx:float,jy:float,tx:float,ty:float)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawSurface:Int(surface:gxtkSurface,x:Float,y:Float)\r\n\t\tDrawImage(surface.image, x, y, 0)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawSurface2:Int(surface:gxtkSurface,x:Float,y:Float, srcx:int, srcy:int, srcw:int, srch:int )\r\n\r\n\t'\tPrint \"x = \"+x\r\n\t'\tPrint \"y = \"+y\r\n\t'\tPrint \"srcx = \"+srcx\r\n\t'\tPrint \"srcy = \"+srcy\r\n\t'\tPrint \"srcw = \"+srcw\r\n\t'\tPrint \"srch = \"+srch\r\n\t\tDrawSubImageRect(surface.image, x, y, srcw, srch, srcx, srcy, srcw, srch)\r\n\t\t\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawLine:Int( x1:Float,y1:Float,x2:Float,y2:Float )\r\n\t\tBlitzMaxDrawLine(x1, y1, x2, y2)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawOval:Int( x:Float, y:Float, w:Float, h:Float )\r\n\t\tBlitzMaxDrawOval(x, y, w, h)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawPoly:Int(vertices:Float[])\r\n\t\tBlitzMaxDrawPoly( vertices )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawRect:Int( x:Float, y:Float, w:Float, h:Float )\r\n\t\tBlitzMaxDrawRect(x, y, w, h)\r\n\t\tReturn 0\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkInput\r\n\tMethod MouseX:Float()\r\n\t\treturn 0\r\n\tEndMethod\r\n\r\n\tMethod MouseY:Float()\r\n\t\treturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod KeyDown:Int( key:Int )\r\n\t\treturn BRL.PolledInput.KeyDown( key )\r\n\tEndMethod\r\n\r\n\tMethod KeyHit:Int( key:Int )\r\n\t\treturn BRL.PolledInput.KeyHit( key )\r\n\tEndMethod\r\n\r\n\tMethod GetChar:Int()\r\n\t\treturn BRL.PolledInput.GetChar()\r\n\tEndMethod\r\n\r\n\tMethod JoyX:Int( index:Int )\r\n\t\treturn Pub.FreeJoy.JoyX( index )\r\n\tEndMethod\r\n\r\n\tMethod JoyY:Int( index:Int )\r\n\t\treturn Pub.FreeJoy.JoyY( index )\r\n\tEndMethod\r\n\r\n\tMethod JoyZ:Int( index:Int )\r\n\t\treturn Pub.FreeJoy.JoyZ( index )\r\n\tEndMethod\r\n\r\n\tMethod TouchX:Float( index:Int )\r\n\t\treturn 0\r\n\tEndMethod\r\n\r\n\tMethod TouchY:Float( index:Int )\r\n\t\treturn 0\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkAudio\r\n\tField amusicState:Int = 0;\r\n\r\n\tMethod MusicState:Int()\r\n'\t\tIf( musicState = 1 And music.isPlaying() = False )\r\n'\t\t\tmusicState = 0;\r\n'\t\tEndif\r\n\t\treturn amusicState;\r\n\tEndMethod\r\n\t\r\n\tMethod PlayMusic:Int( path:String, flags:int )\r\n\t\treturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod StopMusic()\r\n\tEndMethod\r\n\t\r\n\tMethod StopChannel( channel:Int )\r\n\tEndMethod\r\n\r\n\tMethod PlaySample( sound:gxtkSample, channel:Int, flags:Int )\r\n\tEndMethod\r\n\r\n\tMethod SetPan( channel:Int, pan:Float )\r\n\tEndMethod\r\n\r\n\tMethod SetRate( channel:Int, rate:Float )\r\n\tEndMethod\r\n\r\n\tMethod SetMusicVolume:Int( volume:Float )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod SetVolume:Int( channel:Int, volume:Float )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod LoadSample:gxtkSample( path:String )\r\n\t\tReturn Null\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkSample\r\n\tMethod Discard()\r\n\tEndMethod\r\nEndType\r\n\r\nFunction BlitzMaxDrawPoly:Int(vertices:Float[])\r\n\tDrawPoly vertices\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxDrawRect:Int( x:Float, y:Float, w:Float, h:Float )\r\n\tDrawRect x, y, w, h\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxDrawOval:Int( x:Float, y:Float, w:Float, h:Float )\r\n\tDrawOval x, y, w, h\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxDrawLine:Int( x1:Float,y1:Float,x2:Float,y2:Float )\r\n\tDrawLine x1, y1, x2, y2\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxMillisecs:Int()\r\n\treturn MilliSecs()\r\nEndFunction\r\n\r\nFunction BlitzMaxSetColor(r:Int, g:Int, b:Int)\r\n\tSetColor(r, g, b)\r\nEndFunction\r\n\r\nFunction BlitzMaxSetBlend(blend:Int)\r\n\tSetBlend(blend)\r\nEndFunction\r\n\r\nFunction BlitzMaxSetAlpha(a:Float)\r\n\tSetAlpha(a)\r\nEndFunction\r\n\r\nFunction BlitzMaxCls(r:Int = 0, g:Int = 0, b:Int = 0)\r\n\tSetClsColor(r, g, b)\r\n\tCls\r\nEndFunction\r\n\r\nType gxtkSurface\r\n\tField w:Int, h:Int\r\n\tField image:TImage\r\n\t\r\n\tMethod setImage(image:TImage)\r\n\t\tself.image = image\r\n\tEndMethod\r\n\t\r\n\tMethod Width:Int()\r\n\t\treturn image.Width\r\n\tEndMethod\r\n\t\r\n\tMethod Height:Int()\r\n\t\treturn image.Height\r\n\tEndMethod\r\n\t\r\n\tMethod Discard()\r\n\tEndMethod\r\nEndType\r\n\r\n' ***** End mojo.bmax.bmx ******\r\n\r\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"b9e555f6c02903a43cc54a3b26c1be880badd767","subject":"XYZRecord array resize #51","message":"XYZRecord array resize #51\n","repos":"devolonter\/flixel-monkey,devolonter\/flixel-monkey,devolonter\/flixel-monkey,devolonter\/flixel-monkey","old_file":"native\/flixel.bmax.bmx","new_file":"native\/flixel.bmax.bmx","new_contents":"\nType flixel\n\n\tFunction systemMillisecs:Int()\n\t\tReturn Millisecs()\n\tEnd Function\n\t\n\tFunction hideMouse()\n\t\tbmxHideMouse()\n\tEnd Function\n\t\n\tFunction showMouse()\n\t\tbmxShowMouse()\n\tEnd Function\n\t\n\tFunction isMobile:Int()\n\t\tReturn False\n\tEnd Function\n\t\n\tFunction openURL(url:String)\n\t\tbmxOpenURL(url)\n\tEnd Function\n\nEnd Type\n\nFunction bmxHideMouse()\n\tHideMouse()\nEndFunction\n\nFunction bmxShowMouse()\n\tShowMouse()\nEndFunction\n\nFunction bmxOpenURL(url:String)\n\tOpenURL(url)\nEnd Function\n\nFunction resize_array_array_XYZRecord:bb_xyzrecord__1X_1Y_1Z_1Record[][] (arr:bb_xyzrecord__1X_1Y_1Z_1Record[][], leng:Int)\n\tLocal i:Int = arr.length\n\tarr = arr[..leng]\n\t\n\tIf( leng<=i ) Return arr\n\n\tFor Local l:Int = 0 Until Len(arr)\n\t\tarr[l] = arr[l][..leng]\n\tNext\n\t\n\tWhile( i Null\n\t\t\t\t\tThrowCommonError(mxOptErrors.DOESNOTTAKEPARAMS, \"-h|--help\")\n\t\t\t\tEnd If\n\t\tEnd Select\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get a string describing the typical usage of the argument.\n\t\treturns: A string describing the typical usage of the argument.\n\tEnd Rem\n\tMethod GetUsage:String()\n\t\tSelect GetCallConvention()\n\t\t\tCase mxCallConvention.COMMAND\n\t\t\t\tReturn \"usage: maximus help ~n\" + ..\n\t\t\t\t\t\t\"e.g. maximus help get\"\n\t\t\tCase mxCallConvention.OPTION\n\t\t\t\tReturn \"maximus usage: maximus [-v|--version] [-h|--help] COMMAND [ARGS]~n\" + ..\n\t\t\t\t\t\t\"The most commonly used commands:~n\" + ..\n\t\t\t\t\t\t\"~tget~tGet the given set modules~n\" + ..\n\t\t\t\t\t\t\"~tremove~tRemove the given set of modules~n\" + ..\n\t\t\t\t\t\t\"~tupdate~tUpdate the current set of modules~n\" + ..\n\t\t\t\t\t\t\"~thelp~tGet help on a specific command~n\" + ..\n\t\t\t\t\t\t\"Try 'maximus help ' for more information on a specific command.\"\n\t\tEnd Select\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Execute the implementation's operation.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod Execute()\n\t\tSelect GetCallConvention()\n\t\t\tCase mxCallConvention.COMMAND\n\t\t\t\tFor Local command:String = EachIn m_args\n\t\t\t\t\tIf command.ToLower() = \"help\"\n\t\t\t\t\t\tlogger.LogMessage(command + \":~t\" + \"HELP HELP I'M BEING REPRESSED!\")\n\t\t\t\t\tElse\n\t\t\t\t\t\tLocal argimpl:mxArgumentImplementation = mainapp.m_arghandler.GetArgImplFromAlias(command)\n\t\t\t\t\t\tIf argimpl <> Null\n\t\t\t\t\t\t\tlogger.LogMessage(command + \":~t\" + argimpl.GetUsage().Replace(\"~n\", \"~n~t~t\"))\n\t\t\t\t\t\tElse\n\t\t\t\t\t\t\tlogger.LogMessage(command + \":~tCommand not found\")\n\t\t\t\t\t\tEnd If\n\t\t\t\t\tEnd If\n\t\t\t\tNext\n\t\t\tCase mxCallConvention.OPTION\n\t\t\t\tlogger.LogMessage(GetUsage())\n\t\tEnd Select\n\tEnd Method\n\t\nEnd Type\n\n","old_contents":"\nRem\nCopyright (c) 2010 Tim Howard\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and\/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\nEnd Rem\n\nRem\n\tbbdoc: Maximus 'help' argument implementation.\nEnd Rem\nType mxHelpImpl Extends mxArgumentImplementation\n\t\n\tMethod New()\n\t\tinit([\"help\", \"--help\", \"-h\"])\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Check the current arguments for errors (according to the specific implementation).\n\t\treturns: Nothing.\n\t\tabout: This method will throw an error if the given arguments are invalid.\n\tEnd Rem\n\tMethod CheckArgs()\n\t\tSelect GetCallConvention()\n\t\t\tCase mxCallConvention.COMMAND ' \"help\"\n\t\t\t\tIf m_args = Null\n\t\t\t\t\tThrowCommonError(mxCmdErrors.MISSINGPARAMS, \"help\")\n\t\t\t\tEnd If\n\t\t\tCase mxCallConvention.OPTION ' \"--help\" or \"-h\"\n\t\t\t\tIf m_args <> Null\n\t\t\t\t\tThrowCommonError(mxOptErrors.DOESNOTTAKEPARAMS, \"-h|--help\")\n\t\t\t\tEnd If\n\t\tEnd Select\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get a string describing the typical usage of the argument.\n\t\treturns: A string describing the typical usage of the argument.\n\tEnd Rem\n\tMethod GetUsage:String()\n\t\tSelect GetCallConvention()\n\t\t\tCase mxCallConvention.COMMAND\n\t\t\t\tReturn \"usage: maximus help ~n\" + ..\n\t\t\t\t\t\t\"e.g. maximus help get\"\n\t\t\tCase mxCallConvention.OPTION\n\t\t\t\tReturn \"maximus usage: maximus [-v|--version] [-h|--help] COMMAND [ARGS]~n\" + ..\n\t\t\t\t\t\t\"The most commonly used commands:~n\" + ..\n\t\t\t\t\t\t\"~tget~tGet the given set modules~n\" + ..\n\t\t\t\t\t\t\"~tremove~tRemove the given set of modules\" + ..\n\t\t\t\t\t\t\"~tupdate~tUpdate the current set of modules~n\" + ..\n\t\t\t\t\t\t\"~thelp~tGet help on a specific command~n\" + ..\n\t\t\t\t\t\t\"Try 'maximus help ' for more information on a specific command.\"\n\t\tEnd Select\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Execute the implementation's operation.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod Execute()\n\t\tSelect GetCallConvention()\n\t\t\tCase mxCallConvention.COMMAND\n\t\t\t\tFor Local command:String = EachIn m_args\n\t\t\t\t\tIf command.ToLower() = \"help\"\n\t\t\t\t\t\tlogger.LogMessage(command + \":~t\" + \"HELP HELP I'M BEING REPRESSED!\")\n\t\t\t\t\tElse\n\t\t\t\t\t\tLocal argimpl:mxArgumentImplementation = mainapp.m_arghandler.GetArgImplFromAlias(command)\n\t\t\t\t\t\tIf argimpl <> Null\n\t\t\t\t\t\t\tlogger.LogMessage(command + \":~t\" + argimpl.GetUsage().Replace(\"~n\", \"~n~t~t\"))\n\t\t\t\t\t\tElse\n\t\t\t\t\t\t\tlogger.LogMessage(command + \":~tCommand not found\")\n\t\t\t\t\t\tEnd If\n\t\t\t\t\tEnd If\n\t\t\t\tNext\n\t\t\tCase mxCallConvention.OPTION\n\t\t\t\tlogger.LogMessage(GetUsage())\n\t\tEnd Select\n\tEnd Method\n\t\nEnd Type\n\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"1339bd6b6575a377add57cfcbea1027dd3f9361f","subject":"Fixed matrix stuff.","message":"Fixed matrix stuff.\n","repos":"swoolcock\/diddy,swoolcock\/diddy,swoolcock\/diddy,swoolcock\/diddy,swoolcock\/diddy","old_file":"monkeymax\/modules\/mojo\/native\/mojo.bmax.bmx","new_file":"monkeymax\/modules\/mojo\/native\/mojo.bmax.bmx","new_contents":"' ***** Start mojo.bmax.bmx ******\r\n\r\nGlobal app:gxtkApp\r\n\r\nType gxtkApp\r\n\tField ginput:gxtkInput\r\n\tField gaudio:gxtkAudio\r\n\tField ggraphics:gxtkGraphics\r\n\r\n\tField dead:Int=0\r\n\tField suspended:Int=0\r\n\tField vloading:Int=0\r\n\tField maxloading:Int=0\r\n\tField updateRate:Int=0\r\n\tField nextUpdate:Float=0\r\n\tField updatePeriod:Float=0\r\n\tField startMillis:Float=0\r\n\t\r\n\tMethod New()' gxtkApp()\r\n\t\tapp=Self\r\n\t\tggraphics=New gxtkGraphics\r\n\tEndMethod\r\n\t\r\n\tMethod Setup()\r\n\t\tginput=New gxtkInput\r\n\t\tgaudio=New gxtkAudio\r\n\r\n\t\tbb_input_SetInputDevice(ginput)\r\n\t\tbb_audio_SetAudioDevice(gaudio)\r\n\t\t\r\n\t\tstartMillis=BlitzMaxMillisecs()\r\n\t\t\r\n\t\tSetFrameRate( 0 )\r\n\t\t\r\n\t\tInvokeOnCreate()\r\n\t\tInvokeOnRender()\r\n\t\tUpdate()\r\n\tEndMethod\r\n\t\r\n\tMethod Update()\r\n\t\tWhile Not AppTerminate()\r\n\t\t\tLocal updates:Int = 0\r\n\t\t\t\r\n\t\t\tLocal cont:Int = 1\r\n\t\t\tWhile (cont)\r\n\t\t\t\tnextUpdate:+updatePeriod\r\n\t\t\t\tInvokeOnUpdate()\r\n\t\t\t\tIf Not updatePeriod Then cont = 0\r\n\t\t\t\tIf nextUpdate>BlitzMaxMillisecs() Then cont = 0\r\n\t\t\t\tupdates:+1\r\n\t\t\t\tIf updates = 7 Then\r\n\t\t\t\t\tnextUpdate = BlitzMaxMillisecs()\r\n\t\t\t\t\tcont = 0\r\n\t\t\t\tEndIf\r\n\t\t\tWend\r\n\t\t\tInvokeOnRender()\r\n\t\tWend\r\n\tEndMethod\r\n\t\r\n\tMethod InvokeOnCreate()\r\n\t\tIf dead Return\r\n\t\tdead = 1\r\n\t\tOnCreate()\r\n\t\tdead = 0\r\n\tEndMethod\r\n\r\n\tMethod InvokeOnUpdate()\r\n\t\tIf dead Or suspended Or Not updateRate Or vloading Return\r\n\t\tOnUpdate()\r\n\tEndMethod\r\n\t\r\n\tMethod InvokeOnRender()\r\n\t\tIf dead Or suspended Return\r\n\t\tggraphics.BeginRender()\r\n\t\tIf vloading\r\n\t\t\tOnLoading()\r\n\t\tElse\r\n\t\t\tOnRender()\r\n\t\tEndIf\r\n\t\tggraphics.EndRender()\r\n\tEndMethod\r\n\t\r\n\t\r\n\tMethod SetFrameRate( fps:Int )\r\n\t\tIf fps\r\n\t\t\tupdatePeriod=1000.0\/fps\r\n\t\t\tnextUpdate=BlitzMaxMillisecs() +updatePeriod\r\n\t\tElse\r\n\t\t\tupdatePeriod=0\r\n\t\tEndIf\r\n\tEndMethod\r\n\r\n\tMethod LoadState:String()\r\n'\t\tvar file:SharedObject=SharedObject.getLocal( \"gxtkapp\" );\r\n'\t\tvar state:String=file.data.state;\r\n'\t\tfile.close();\r\n'\t\tif( state ) return state;\r\n\t\tReturn \"\"\r\n\tEndMethod\r\n\t\r\n\tMethod SaveState:Int( state:String )\r\n'\t\tvar file:SharedObject=SharedObject.getLocal( \"gxtkapp\" );\r\n'\t\tfile.data.state=state;\r\n'\t\tfile.close();\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod LoadString:String( path:String )\r\n\t\tpath = \"data\/\" + path\r\n\t\tReturn LoadText( path )\r\n\tEndMethod\r\n\t\r\n\t' ***** GXTK API *****\r\n\t\r\n\tMethod GraphicsDevice:gxtkGraphics()\r\n\t\tReturn ggraphics\r\n\tEndMethod\r\n\r\n\tMethod InputDevice:gxtkInput()\r\n\t\tReturn ginput\r\n\tEndMethod\r\n\r\n\tMethod AudioDevice:gxtkAudio()\r\n\t\tReturn gaudio\r\n\tEndMethod\r\n\r\n\tMethod SetUpdateRate:Int(hertz:Int)\r\n\t\tupdateRate = hertz\r\n\t\tIf Not vloading Then SetFrameRate(updateRate)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod MilliSecs:Int()\r\n\t\tReturn BlitzMaxMillisecs() - startMillis\r\n\tEndMethod\r\n\t\r\n\tMethod Loading:Int()\r\n\t\tReturn vloading\r\n\tEndMethod\r\n\r\n\tMethod OnCreate:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod OnUpdate:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod OnSuspend:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod OnResume:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod OnRender:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod OnLoading:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkGraphics\r\n\tField gmode:Int = 1\r\n\tField ix:Float=1,iy:Float,jx:Float,jy:Float=1,tx:Float,ty:Float\r\n\tField sx:Float=1,sy:Float=1,rot:Float=0\r\n\t\r\n\tMethod Mode:Int()\r\n\t\tReturn gmode\r\n\tEndMethod\r\n\t\r\n\tMethod Cls:Int(r:Int = 0, g:Int = 0, b:Int = 0)\r\n\t\tBlitzMaxCls(r, g, b)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawPoint:Int(x:Float, y:Float)\r\n\t\tLocal nx:Float = TransX(x,y)\r\n\t\tLocal ny:Float = TransY(x,y)\r\n\t\tPlot nx, ny\r\n\tEndMethod\r\n\t\r\n\tMethod LoadSurface:gxtkSurface(path:String)\r\n\t\tLocal image:TImage = LoadImage(\"data\/\"+path)\r\n\t\tIf image Then\r\n\t\t\tLocal gs:gxtkSurface = New gxtkSurface\r\n\t\t\tgs.setImage(image)\r\n\t\t\tReturn gs\r\n\t\tEndIf\r\n\t\tReturn Null\r\n\tEndMethod\r\n\t\r\n\tMethod BeginRender()\r\n\tEndMethod\r\n\t\r\n\tMethod EndRender()\r\n\t\tFlip\r\n\tEndMethod\r\n\t\r\n\tMethod SetColor:Int(r:Int, g:Int, b:Int)\r\n\t\tBlitzMaxSetColor(r, g, b)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod SetAlpha:Int(a:Float)\r\n\t\tBlitzMaxSetAlpha(a)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod SetBlend:Int(blend:Int)\r\n\t\tBlitzMaxSetBlend(blend)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod Width:Int()\r\n\t\tReturn GraphicsWidth()\r\n\tEndMethod\r\n\t\r\n\tMethod Height:Int()\r\n\t\tReturn GraphicsHeight()\r\n\tEndMethod\r\n\t\r\n\tMethod SetScissor:Int(x:Int, y:Int, w:Int, h:Int)\r\n\t\tSetViewport(x, y, w, h) ' NOT TESTED!\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod TransX:Float(x:Float, y:Float)\r\n\t\tReturn ix*x + jx*y + tx\r\n\tEndMethod\r\n\t\r\n\tMethod TransY:Float(x:Float, y:Float)\r\n\t\tReturn iy*x + jy*y + ty\r\n\tEndMethod\r\n\t\r\n\tMethod SetMatrix:Int(ix:Float,iy:Float,jx:Float,jy:Float,tx:Float,ty:Float)\r\n\t\tSelf.ix = ix ; Self.iy = iy\r\n\t\tSelf.jx = jx ; Self.jy = jy\r\n\t\tSelf.tx = tx ; Self.ty = ty\r\n\t\tsx = Sqr( (ix*ix) + (jx*jx) )\r\n\t\tsy = Sqr( (iy*iy) + (jy*jy) )\r\n\t\trot = -Atan2( jx, ix )\r\n\t\tSetTransform( rot, sx, sy )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawSurface:Int(surface:gxtkSurface,x:Float,y:Float)\r\n\t\tLocal nx:Float = TransX(x,y)\r\n\t\tLocal ny:Float = TransY(x,y)\r\n\t\tDrawImage(surface.image, nx, ny, 0)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawSurface2:Int(surface:gxtkSurface,x:Float,y:Float, srcx:Int, srcy:Int, srcw:Int, srch:Int )\r\n\t\tLocal nx:Float = TransX(x,y)\r\n\t\tLocal ny:Float = TransY(x,y)\r\n\t\tDrawSubImageRect(surface.image, nx, ny, srcw, srch, srcx, srcy, srcw, srch)\t\t\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawLine:Int( x1:Float,y1:Float,x2:Float,y2:Float )\r\n\t\tLocal nx1:Float = TransX(x1,y1)\r\n\t\tLocal ny1:Float = TransY(x1,y1)\r\n\t\tLocal nx2:Float = TransX(x2,y2)\r\n\t\tLocal ny2:Float = TransY(x2,y2)\r\n\t\t' Need to reset transform so that BlitzMax doesn't try to apply rotation\r\n\t\tSetTransform( 0, 1, 1 )\r\n\t\tBlitzMaxDrawLine(nx1, ny1, nx2, ny2)\r\n\t\tSetTransform( rot, sx, sy )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawOval:Int( x:Float, y:Float, w:Float, h:Float )\r\n\t\tLocal nx:Float = TransX(x,y)\r\n\t\tLocal ny:Float = TransY(x,y)\r\n\t\tBlitzMaxDrawOval(nx, ny, w, h)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawPoly:Int(vertices:Float[])\r\n\t\t' setting the origin to use the current rotation translation\r\n\t\tSetOrigin(TransX(0,0), TransY(0,0))\r\n\t\tBlitzMaxDrawPoly( vertices )\r\n\t\tSetOrigin(0, 0)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawRect:Int( x:Float, y:Float, w:Float, h:Float )\r\n\t\tLocal nx:Float = TransX(x,y)\r\n\t\tLocal ny:Float = TransY(x,y)\r\n\t\tBlitzMaxDrawRect(nx, ny, w, h)\r\n\t\tReturn 0\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkInput\r\n\tMethod MouseX:Float()\r\n\t\tReturn BRL.PolledInput.MouseX()\r\n\tEndMethod\r\n\r\n\tMethod MouseY:Float()\r\n\t\tReturn BRL.PolledInput.MouseY()\r\n\tEndMethod\r\n\t\r\n\tMethod KeyDown:Int( key:Int )\r\n\t\tif( key = 384 ) key = 1 ' change TOUCH0 to MOUSE_LMB\r\n\r\n\t\tIf( key >= 1 And key <= 3 )\r\n\t\t\tReturn BRL.PolledInput.MouseDown( key )\r\n\t\tEndIf\r\n\t\tIf key < 256\r\n\t\t\tReturn BRL.PolledInput.KeyDown( key )\r\n\t\tElse\r\n\t\t\tReturn 0\r\n\t\tEndIf\r\n\tEndMethod\r\n\r\n\tMethod KeyHit:Int( key:Int )\r\n\t\tif( key = 384 ) key = 1 ' change TOUCH0 to MOUSE_LMB\r\n\t\tIf( key >= 1 And key <= 3 )\r\n\t\t\tReturn BRL.PolledInput.MouseHit( key )\r\n\t\tEndIf\r\n\t\tIf key < 256\r\n\t\t\tReturn BRL.PolledInput.KeyHit( key )\r\n\t\tElse\r\n\t\t\tReturn 0\r\n\t\tEndIf\r\n\tEndMethod\r\n\r\n\tMethod GetChar:Int()\r\n\t\tReturn BRL.PolledInput.GetChar()\r\n\tEndMethod\r\n\r\n\tMethod JoyX:Int( index:Int )\r\n\t\tReturn Pub.FreeJoy.JoyX( index )\r\n\tEndMethod\r\n\r\n\tMethod JoyY:Int( index:Int )\r\n\t\tReturn Pub.FreeJoy.JoyY( index )\r\n\tEndMethod\r\n\r\n\tMethod JoyZ:Int( index:Int )\r\n\t\tReturn Pub.FreeJoy.JoyZ( index )\r\n\tEndMethod\r\n\r\n\tMethod TouchX:Float( index:Int )\r\n\t\tReturn BRL.PolledInput.MouseX()\r\n\tEndMethod\r\n\r\n\tMethod TouchY:Float( index:Int )\r\n\t\tReturn BRL.PolledInput.MouseY()\r\n\tEndMethod\r\n\t\r\n\tMethod AccelX:Int()\r\n\t\treturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod AccelY:Int()\r\n\t\treturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod AccelZ:Int()\r\n\t\treturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod SetKeyboardEnabled:Int( enabled:int )\r\n\t\tReturn 0\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkChannel\r\n\tField channel:TChannel\t' null then not playing\r\n\tField sample:gxtkSample\r\n\tField loops:int\r\n\t'Field transform:SoundTransform=new SoundTransform()\r\n\t'Field pausepos:Number\r\n\tField state:int\r\n\t\r\n\tMethod New()\r\n\t\tchannel = New TChannel\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkAudio\r\n\tField amusicState:Int = 0\r\n\tField channels:gxtkChannel[] = New gxtkChannel[33]\r\n\t\r\n\tMethod New()\r\n\t\tFor local i:Int = 0 To 33 - 1\r\n\t\t\tchannels[i] = New gxtkChannel\r\n\t\tNext\r\n\tEndMethod\r\n\t\r\n\tMethod MusicState:Int()\r\n'\t\tIf( musicState = 1 And music.isPlaying() = False )\r\n'\t\t\tmusicState = 0;\r\n'\t\tEndif\r\n\t\tReturn amusicState\r\n\tEndMethod\r\n\t\r\n\tMethod PlayMusic:Int( path:String, flags:Int )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod ChannelState:int( channel:int )\r\n\t\tReturn -1\r\n\tEndMethod\r\n\t\r\n\tMethod StopMusic()\r\n\tEndMethod\r\n\t\r\n\tMethod StopChannel( channel:Int )\r\n\tEndMethod\r\n\r\n\tMethod PlaySample( sound:gxtkSample, channel:Int, flags:Int )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\t\r\n\t\t'If chan.state <> 0 Then chan.channel.Stop() <-- this crashes after the first play!?\r\n\t\t\r\n\t\tchan.sample = sound\r\n\t\t'chan.loops = flags ? 0x7fffffff : 0;\r\n\t\t'chan.channel = sample.sound.play( 0,chan.loops,chan.transform );\r\n\t\t'chan.channel = sound\r\n\t\tchan.state=1\r\n\t\r\n\t\tPlaySound( sound.sound, chan.channel )\r\n\tEndMethod\r\n\r\n\tMethod SetPan( channel:Int, pan:Float )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tchan.channel.SetPan(pan)\r\n\tEndMethod\r\n\r\n\tMethod SetRate( channel:Int, rate:Float )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tchan.channel.SetRate(rate)\r\n\tEndMethod\r\n\r\n\tMethod PauseMusic:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod ResumeMusic:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod SetMusicVolume:Int( volume:Float )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod SetVolume:Int( channel:Int, volume:Float )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tchan.channel.SetVolume(volume)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod LoadSample:gxtkSample( path:String )\r\n\t\tLocal extension:String = ExtractExt( path)\r\n\t\tIf extension = \"ogg\" Or extension = \"wav\" Then\r\n\t\t\tLocal sound:TSound = LoadSound(\"data\/\"+path)\r\n\t\t\tIf sound Then\r\n\t\t\t\tLocal gs:gxtkSample = New gxtkSample\r\n\t\t\t\tgs.setSound(sound)\r\n\t\t\t\tReturn gs\r\n\t\t\tEndIf\r\n\t\tElse\r\n\t\t\tRuntimeError \"BlitzMax can only use ogg and wav file formats\"\r\n\t\tEndIf\r\n\t\tReturn Null\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkSample\r\n\tField sound:TSound\r\n\t\r\n\tMethod setSound(sound:TSound)\r\n\t\tSelf.sound = sound\r\n\tEndMethod\r\n\t\r\n\tMethod Discard()\r\n\t\tSelf.sound = null\r\n\tEndMethod\r\nEndType\r\n\r\nFunction BlitzMaxDrawPoly:Int(vertices:Float[])\r\n\tDrawPoly vertices\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxDrawRect:Int( x:Float, y:Float, w:Float, h:Float )\r\n\tDrawRect x, y, w, h\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxDrawOval:Int( x:Float, y:Float, w:Float, h:Float )\r\n\tDrawOval x, y, w, h\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxDrawLine:Int( x1:Float,y1:Float,x2:Float,y2:Float )\r\n\tDrawLine x1, y1, x2, y2\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxMillisecs:Int()\r\n\tReturn MilliSecs()\r\nEndFunction\r\n\r\nFunction BlitzMaxSetColor(r:Int, g:Int, b:Int)\r\n\tSetColor(r, g, b)\r\nEndFunction\r\n\r\nFunction BlitzMaxSetBlend(blend:Int)\r\n\tSelect blend\r\n\t\tCase 0\r\n\t\t\tSetBlend( ALPHABLEND )\r\n\t\tCase 1\r\n\t\t\tSetBlend( LIGHTBLEND )\r\n\tEnd Select\r\nEndFunction\r\n\r\nFunction BlitzMaxSetAlpha(a:Float)\r\n\tSetAlpha(a)\r\nEndFunction\r\n\r\nFunction BlitzMaxCls(r:Int = 0, g:Int = 0, b:Int = 0)\r\n\tSetClsColor(r, g, b)\r\n\tCls\r\nEndFunction\r\n\r\nType gxtkSurface\r\n\tField w:Int, h:Int\r\n\tField image:TImage\r\n\t\r\n\tMethod setImage(image:TImage)\r\n\t\tSelf.image = image\r\n\tEndMethod\r\n\t\r\n\tMethod Width:Int()\r\n\t\tReturn image.Width\r\n\tEndMethod\r\n\t\r\n\tMethod Height:Int()\r\n\t\tReturn image.Height\r\n\tEndMethod\r\n\t\r\n\tMethod Discard()\r\n\tEndMethod\r\nEndType\r\n\r\n' ***** End mojo.bmax.bmx ******\r\n\r\n","old_contents":"' ***** Start mojo.bmax.bmx ******\r\n\r\nGlobal app:gxtkApp\r\n\r\nType gxtkApp\r\n\tField ginput:gxtkInput\r\n\tField gaudio:gxtkAudio\r\n\tField ggraphics:gxtkGraphics\r\n\r\n\tField dead:Int=0\r\n\tField suspended:Int=0\r\n\tField vloading:Int=0\r\n\tField maxloading:Int=0\r\n\tField updateRate:Int=0\r\n\tField nextUpdate:Float=0\r\n\tField updatePeriod:Float=0\r\n\tField startMillis:Float=0\r\n\t\r\n\tMethod New()' gxtkApp()\r\n\t\tapp=Self\r\n\t\tggraphics=New gxtkGraphics\r\n\tEndMethod\r\n\t\r\n\tMethod Setup()\r\n\t\tginput=New gxtkInput\r\n\t\tgaudio=New gxtkAudio\r\n\r\n\t\tbb_input_SetInputDevice(ginput)\r\n\t\tbb_audio_SetAudioDevice(gaudio)\r\n\t\t\r\n\t\tstartMillis=BlitzMaxMillisecs()\r\n\t\t\r\n\t\tSetFrameRate( 0 )\r\n\t\t\r\n\t\tInvokeOnCreate()\r\n\t\tInvokeOnRender()\r\n\t\tUpdate()\r\n\tEndMethod\r\n\t\r\n\tMethod Update()\r\n\t\tWhile Not AppTerminate()\r\n\t\t\tLocal updates:Int = 0\r\n\t\t\t\r\n\t\t\tLocal cont:Int = 1\r\n\t\t\tWhile (cont)\r\n\t\t\t\tnextUpdate:+updatePeriod\r\n\t\t\t\tInvokeOnUpdate()\r\n\t\t\t\tIf Not updatePeriod Then cont = 0\r\n\t\t\t\tIf nextUpdate>BlitzMaxMillisecs() Then cont = 0\r\n\t\t\t\tupdates:+1\r\n\t\t\t\tIf updates = 7 Then\r\n\t\t\t\t\tnextUpdate = BlitzMaxMillisecs()\r\n\t\t\t\t\tcont = 0\r\n\t\t\t\tEndIf\r\n\t\t\tWend\r\n\t\t\tInvokeOnRender()\r\n\t\tWend\r\n\tEndMethod\r\n\t\r\n\tMethod InvokeOnCreate()\r\n\t\tIf dead Return\r\n\t\tdead = 1\r\n\t\tOnCreate()\r\n\t\tdead = 0\r\n\tEndMethod\r\n\r\n\tMethod InvokeOnUpdate()\r\n\t\tIf dead Or suspended Or Not updateRate Or vloading Return\r\n\t\tOnUpdate()\r\n\tEndMethod\r\n\t\r\n\tMethod InvokeOnRender()\r\n\t\tIf dead Or suspended Return\r\n\t\tggraphics.BeginRender()\r\n\t\tIf vloading\r\n\t\t\tOnLoading()\r\n\t\tElse\r\n\t\t\tOnRender()\r\n\t\tEndIf\r\n\t\tggraphics.EndRender()\r\n\tEndMethod\r\n\t\r\n\t\r\n\tMethod SetFrameRate( fps:Int )\r\n\t\tIf fps\r\n\t\t\tupdatePeriod=1000.0\/fps\r\n\t\t\tnextUpdate=BlitzMaxMillisecs() +updatePeriod\r\n\t\tElse\r\n\t\t\tupdatePeriod=0\r\n\t\tEndIf\r\n\tEndMethod\r\n\r\n\tMethod LoadState:String()\r\n'\t\tvar file:SharedObject=SharedObject.getLocal( \"gxtkapp\" );\r\n'\t\tvar state:String=file.data.state;\r\n'\t\tfile.close();\r\n'\t\tif( state ) return state;\r\n\t\tReturn \"\"\r\n\tEndMethod\r\n\t\r\n\tMethod SaveState:Int( state:String )\r\n'\t\tvar file:SharedObject=SharedObject.getLocal( \"gxtkapp\" );\r\n'\t\tfile.data.state=state;\r\n'\t\tfile.close();\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod LoadString:String( path:String )\r\n\t\tpath = \"data\/\" + path\r\n\t\tReturn LoadText( path )\r\n\tEndMethod\r\n\t\r\n\t' ***** GXTK API *****\r\n\t\r\n\tMethod GraphicsDevice:gxtkGraphics()\r\n\t\tReturn ggraphics\r\n\tEndMethod\r\n\r\n\tMethod InputDevice:gxtkInput()\r\n\t\tReturn ginput\r\n\tEndMethod\r\n\r\n\tMethod AudioDevice:gxtkAudio()\r\n\t\tReturn gaudio\r\n\tEndMethod\r\n\r\n\tMethod SetUpdateRate:Int(hertz:Int)\r\n\t\tupdateRate = hertz\r\n\t\tIf Not vloading Then SetFrameRate(updateRate)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod MilliSecs:Int()\r\n\t\tReturn BlitzMaxMillisecs() - startMillis\r\n\tEndMethod\r\n\t\r\n\tMethod Loading:Int()\r\n\t\tReturn vloading\r\n\tEndMethod\r\n\r\n\tMethod OnCreate:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod OnUpdate:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod OnSuspend:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod OnResume:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod OnRender:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod OnLoading:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkGraphics\r\n\tField gmode:Int = 1\r\n\r\n\tMethod Mode:Int()\r\n\t\tReturn gmode\r\n\tEndMethod\r\n\t\r\n\tMethod Cls:Int(r:Int = 0, g:Int = 0, b:Int = 0)\r\n\t\tBlitzMaxCls(r, g, b)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawPoint:Int(x:Float, y:Float)\r\n\t\tPlot x, y\r\n\tEndMethod\r\n\t\r\n\tMethod LoadSurface:gxtkSurface(path:String)\r\n\t\tLocal image:TImage = LoadImage(\"data\/\"+path)\r\n\t\tIf image Then\r\n\t\t\tLocal gs:gxtkSurface = New gxtkSurface\r\n\t\t\tgs.setImage(image)\r\n\t\t\tReturn gs\r\n\t\tEndIf\r\n\t\tReturn Null\r\n\tEndMethod\r\n\t\r\n\tMethod BeginRender()\r\n\tEndMethod\r\n\t\r\n\tMethod EndRender()\r\n\t\tFlip\r\n\tEndMethod\r\n\t\r\n\tMethod SetColor:Int(r:Int, g:Int, b:Int)\r\n\t\tBlitzMaxSetColor(r, g, b)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod SetAlpha:Int(a:Float)\r\n\t\tBlitzMaxSetAlpha(a)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod SetBlend:Int(blend:Int)\r\n\t\tBlitzMaxSetBlend(blend)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod Width:Int()\r\n\t\tReturn GraphicsWidth()\r\n\tEndMethod\r\n\t\r\n\tMethod Height:Int()\r\n\t\tReturn GraphicsHeight()\r\n\tEndMethod\r\n\t\r\n\tMethod SetScissor:Int(x:Int, y:Int, w:Int, h:Int)\r\n\t\tSetViewport(x, y, w, h) ' NOT TESTED!\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod SetMatrix:Int(ix:Float,iy:Float,jx:Float,jy:Float,tx:Float,ty:Float)\r\n\t\tLocal sx:Float = Sqr( (ix*ix) + (jx*jx) )\r\n\t\tLocal sy:Float = Sqr( (iy*iy) + (jy*jy) )\r\n\t\tLocal rot:Float = -Atan2( jx, ix )\r\n\t\tSetTransform( rot, sx, sy )\r\n\t\tSetOrigin( tx, ty )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawSurface:Int(surface:gxtkSurface,x:Float,y:Float)\r\n\t\tDrawImage(surface.image, x, y, 0)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawSurface2:Int(surface:gxtkSurface,x:Float,y:Float, srcx:Int, srcy:Int, srcw:Int, srch:Int )\r\n\t\tDrawSubImageRect(surface.image, x, y, srcw, srch, srcx, srcy, srcw, srch)\t\t\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawLine:Int( x1:Float,y1:Float,x2:Float,y2:Float )\r\n\t\tBlitzMaxDrawLine(x1, y1, x2, y2)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawOval:Int( x:Float, y:Float, w:Float, h:Float )\r\n\t\tBlitzMaxDrawOval(x, y, w, h)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawPoly:Int(vertices:Float[])\r\n\t\tBlitzMaxDrawPoly( vertices )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawRect:Int( x:Float, y:Float, w:Float, h:Float )\r\n\t\tBlitzMaxDrawRect(x, y, w, h)\r\n\t\tReturn 0\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkInput\r\n\tMethod MouseX:Float()\r\n\t\tReturn BRL.PolledInput.MouseX()\r\n\tEndMethod\r\n\r\n\tMethod MouseY:Float()\r\n\t\tReturn BRL.PolledInput.MouseY()\r\n\tEndMethod\r\n\t\r\n\tMethod KeyDown:Int( key:Int )\r\n\t\tif( key = 384 ) key = 1 ' change TOUCH0 to MOUSE_LMB\r\n\r\n\t\tIf( key >= 1 And key <= 3 )\r\n\t\t\tReturn BRL.PolledInput.MouseDown( key )\r\n\t\tEndIf\r\n\t\tIf key < 256\r\n\t\t\tReturn BRL.PolledInput.KeyDown( key )\r\n\t\tElse\r\n\t\t\tReturn 0\r\n\t\tEndIf\r\n\tEndMethod\r\n\r\n\tMethod KeyHit:Int( key:Int )\r\n\t\tif( key = 384 ) key = 1 ' change TOUCH0 to MOUSE_LMB\r\n\t\tIf( key >= 1 And key <= 3 )\r\n\t\t\tReturn BRL.PolledInput.MouseHit( key )\r\n\t\tEndIf\r\n\t\tIf key < 256\r\n\t\t\tReturn BRL.PolledInput.KeyHit( key )\r\n\t\tElse\r\n\t\t\tReturn 0\r\n\t\tEndIf\r\n\tEndMethod\r\n\r\n\tMethod GetChar:Int()\r\n\t\tReturn BRL.PolledInput.GetChar()\r\n\tEndMethod\r\n\r\n\tMethod JoyX:Int( index:Int )\r\n\t\tReturn Pub.FreeJoy.JoyX( index )\r\n\tEndMethod\r\n\r\n\tMethod JoyY:Int( index:Int )\r\n\t\tReturn Pub.FreeJoy.JoyY( index )\r\n\tEndMethod\r\n\r\n\tMethod JoyZ:Int( index:Int )\r\n\t\tReturn Pub.FreeJoy.JoyZ( index )\r\n\tEndMethod\r\n\r\n\tMethod TouchX:Float( index:Int )\r\n\t\tReturn BRL.PolledInput.MouseX()\r\n\tEndMethod\r\n\r\n\tMethod TouchY:Float( index:Int )\r\n\t\tReturn BRL.PolledInput.MouseY()\r\n\tEndMethod\r\n\t\r\n\tMethod AccelX:Int()\r\n\t\treturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod AccelY:Int()\r\n\t\treturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod AccelZ:Int()\r\n\t\treturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod SetKeyboardEnabled:Int( enabled:int )\r\n\t\tReturn 0\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkChannel\r\n\tField channel:TChannel\t' null then not playing\r\n\tField sample:gxtkSample\r\n\tField loops:int\r\n\t'Field transform:SoundTransform=new SoundTransform()\r\n\t'Field pausepos:Number\r\n\tField state:int\r\n\t\r\n\tMethod New()\r\n\t\tchannel = New TChannel\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkAudio\r\n\tField amusicState:Int = 0\r\n\tField channels:gxtkChannel[] = New gxtkChannel[33]\r\n\t\r\n\tMethod New()\r\n\t\tFor local i:Int = 0 To 33 - 1\r\n\t\t\tchannels[i] = New gxtkChannel\r\n\t\tNext\r\n\tEndMethod\r\n\t\r\n\tMethod MusicState:Int()\r\n'\t\tIf( musicState = 1 And music.isPlaying() = False )\r\n'\t\t\tmusicState = 0;\r\n'\t\tEndif\r\n\t\tReturn amusicState\r\n\tEndMethod\r\n\t\r\n\tMethod PlayMusic:Int( path:String, flags:Int )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod ChannelState:int( channel:int )\r\n\t\tReturn -1\r\n\tEndMethod\r\n\t\r\n\tMethod StopMusic()\r\n\tEndMethod\r\n\t\r\n\tMethod StopChannel( channel:Int )\r\n\tEndMethod\r\n\r\n\tMethod PlaySample( sound:gxtkSample, channel:Int, flags:Int )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\t\r\n\t\t'If chan.state <> 0 Then chan.channel.Stop() <-- this crashes after the first play!?\r\n\t\t\r\n\t\tchan.sample = sound\r\n\t\t'chan.loops = flags ? 0x7fffffff : 0;\r\n\t\t'chan.channel = sample.sound.play( 0,chan.loops,chan.transform );\r\n\t\t'chan.channel = sound\r\n\t\tchan.state=1\r\n\t\r\n\t\tPlaySound( sound.sound, chan.channel )\r\n\tEndMethod\r\n\r\n\tMethod SetPan( channel:Int, pan:Float )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tchan.channel.SetPan(pan)\r\n\tEndMethod\r\n\r\n\tMethod SetRate( channel:Int, rate:Float )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tchan.channel.SetRate(rate)\r\n\tEndMethod\r\n\r\n\tMethod PauseMusic:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod ResumeMusic:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod SetMusicVolume:Int( volume:Float )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod SetVolume:Int( channel:Int, volume:Float )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tchan.channel.SetVolume(volume)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod LoadSample:gxtkSample( path:String )\r\n\t\tLocal extension:String = ExtractExt( path)\r\n\t\tIf extension = \"ogg\" Or extension = \"wav\" Then\r\n\t\t\tLocal sound:TSound = LoadSound(\"data\/\"+path)\r\n\t\t\tIf sound Then\r\n\t\t\t\tLocal gs:gxtkSample = New gxtkSample\r\n\t\t\t\tgs.setSound(sound)\r\n\t\t\t\tReturn gs\r\n\t\t\tEndIf\r\n\t\tElse\r\n\t\t\tRuntimeError \"BlitzMax can only use ogg and wav file formats\"\r\n\t\tEndIf\r\n\t\tReturn Null\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkSample\r\n\tField sound:TSound\r\n\t\r\n\tMethod setSound(sound:TSound)\r\n\t\tSelf.sound = sound\r\n\tEndMethod\r\n\t\r\n\tMethod Discard()\r\n\t\tSelf.sound = null\r\n\tEndMethod\r\nEndType\r\n\r\nFunction BlitzMaxDrawPoly:Int(vertices:Float[])\r\n\tDrawPoly vertices\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxDrawRect:Int( x:Float, y:Float, w:Float, h:Float )\r\n\tDrawRect x, y, w, h\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxDrawOval:Int( x:Float, y:Float, w:Float, h:Float )\r\n\tDrawOval x, y, w, h\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxDrawLine:Int( x1:Float,y1:Float,x2:Float,y2:Float )\r\n\tDrawLine x1, y1, x2, y2\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxMillisecs:Int()\r\n\tReturn MilliSecs()\r\nEndFunction\r\n\r\nFunction BlitzMaxSetColor(r:Int, g:Int, b:Int)\r\n\tSetColor(r, g, b)\r\nEndFunction\r\n\r\nFunction BlitzMaxSetBlend(blend:Int)\r\n\tSelect blend\r\n\t\tCase 0\r\n\t\t\tSetBlend( ALPHABLEND )\r\n\t\tCase 1\r\n\t\t\tSetBlend( LIGHTBLEND )\r\n\tEnd Select\r\nEndFunction\r\n\r\nFunction BlitzMaxSetAlpha(a:Float)\r\n\tSetAlpha(a)\r\nEndFunction\r\n\r\nFunction BlitzMaxCls(r:Int = 0, g:Int = 0, b:Int = 0)\r\n\tSetClsColor(r, g, b)\r\n\tCls\r\nEndFunction\r\n\r\nType gxtkSurface\r\n\tField w:Int, h:Int\r\n\tField image:TImage\r\n\t\r\n\tMethod setImage(image:TImage)\r\n\t\tSelf.image = image\r\n\tEndMethod\r\n\t\r\n\tMethod Width:Int()\r\n\t\tReturn image.Width\r\n\tEndMethod\r\n\t\r\n\tMethod Height:Int()\r\n\t\tReturn image.Height\r\n\tEndMethod\r\n\t\r\n\tMethod Discard()\r\n\tEndMethod\r\nEndType\r\n\r\n' ***** End mojo.bmax.bmx ******\r\n\r\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"b7f1d865cc1ce874319b09d5c4cef7f6e5fcfcb5","subject":"[app] (v0.3) \tAdded OnExit method to TDApp","message":"[app] (v0.3)\n\tAdded OnExit method to TDApp\n","repos":"komiga\/duct-max,komiga\/duct-max,komiga\/duct-max","old_file":"app.mod\/inc\/types\/dapp.bmx","new_file":"app.mod\/inc\/types\/dapp.bmx","new_contents":"","old_contents":"","returncode":0,"stderr":"unknown","license":"mit","lang":"BlitzMax"} {"commit":"a227de0c0d128d35bf2f95df937741196463f95d","subject":"resize tweaks","message":"resize tweaks\n","repos":"Leushenko\/blue-moon","old_file":"bluetable.bmx","new_file":"bluetable.bmx","new_contents":"\n' Blue Moon\n' Lua-table implementation\n' uses simple linear probing for collision resolution and a shockingly naive reallocator\n\n\nSuperStrict\n\nImport \"blueallocator.bmx\"\n\n\nPrivate\nExtern\n\tFunction frexp:Double(d:Double, Exp:Int Ptr) = \"frexp\"\nEnd Extern\nPublic\n\nType BlueTable Final\n\t' retrieve the slot *for* a key's value, null if no available slot exists (to be used by non-raw index\/set operations)\n\tFunction GetSlot:Long Ptr(tbl:Byte Ptr, key:Long, keyslot:Long Ptr Ptr)\t'keyslot will return the slot for the key if it's not an array-slot\n\t\tLocal tag:Int = Int Ptr(Varptr(key))[1], idx:Int\n\t\tConst NILTAG:Int = BlueTypeTag.NANBOX | BlueTypeTag.NIL\n\t\t\n\t\tIf tag = BlueTypeTag.NANBOX | BlueTypeTag.STR\t'string - common case\n\t\t\tidx = Int Ptr(Int(key))[1]\n\t\tElseIf tag & BlueTypeTag.NANBOX_CHK <> BlueTypeTag.NANBOX\t'number\n\t\t\tLocal d:Double ; Long Ptr(Varptr(d))[0] = key ; idx = Abs Int(d)\n\t\t\tIf d = idx\t'int key\n\t\t\t\tLocal arr:Byte Ptr = Byte Ptr Ptr(tbl)[3]\n\t\t\t\tIf arr And idx < Int Ptr(arr)[-1] Then Return Long Ptr(arr) + idx\t'if this is nil, it won't be in the hash part anyway\n\t\t\tElse\n\t\t\t\td = frexp(d, Varptr(idx)) * ($7fffffff - 1024)\t'INT_MAX - DBL_MAX_EXP\n\t\t\t\tidx = Abs(idx) + Int(d)\n\t\t\tEndIf\n\t\tElseIf tag = NILTAG\t'nil -> nil\n\t\t\tkeyslot[0] = Long Ptr(1) ; Return Null\n\t\tElse\t'pointer (needs improvement)\n\t\t\tidx = Int(key) Shr 3\n\t\tEndIf\n\t\t\n\t\tLocal hashpart:Byte Ptr = Byte Ptr Ptr(tbl)[2]\n\t\tIf hashpart\n\t\t\tLocal hsize:Int = 1 Shl Int Ptr(hashpart)[-1]\n\t\t\tidx = idx & (hsize - 1)\t'apparently this is faster than Mod\n\t\t\tFor Local i:Int = idx Until hsize\t'naive linear probe\n\t\t\t\tLocal kp:Long Ptr = Long Ptr(hashpart) + 2 * i\n\t\t\t\tIf kp[0] = key Or Int Ptr(kp)[1] = NILTAG\n\t\t\t\t\tkeyslot[0] = kp ; Return kp + 1\n\t\t\t\tEndIf\n\t\t\tNext\n\t\t\tFor Local i:Int = 0 Until idx\t'yep\n\t\t\t\tLocal kp:Long Ptr = Long Ptr(hashpart) + 2 * i\n\t\t\t\tIf kp[0] = key Or Int Ptr(kp)[1] = NILTAG\n\t\t\t\t\tkeyslot[0] = kp ; Return kp + 1\n\t\t\t\tEndIf\n\t\t\tNext\n\t\tEndIf\n\t\t\n\t\tReturn Null\n\tEnd Function\n\t\n\t' retrieve a value from a table, or nil\n\tFunction RawGet:Long(tbl:Byte Ptr, key:Long)\n\t\tLocal keyp:Long Ptr = Null, retp:Long Ptr = GetSlot(tbl, key, Varptr(keyp)), ret:Long\n\t\tIf retp And (keyp <> Long Ptr(1))\n\t\t\tret = retp[0]\n\t\tElse\n\t\t\tInt Ptr(Varptr(ret))[1] = BlueTypeTag.NANBOX | BlueTypeTag.NIL\t'why can't i shift longs?\n\t\tEndIf\n\t\tReturn ret\n\tEnd Function\n\t\n\t' put a value into a table, resizing it if necessary\n\tFunction RawSet(mem:BlueVMMemory, tbl:Byte Ptr, key:Long, val:Long)\n\t\tLocal keyp:Long Ptr = Null, valp:Long Ptr = GetSlot(tbl, key, Varptr(keyp))\n\t\tIf valp\n\t\t\tmem.Write(valp, val)\n\t\t\tIf keyp\n\t\t\t\tLocal hashpart:Int Ptr = Int Ptr Ptr(tbl)[2]\n\t\t\t\tIf Int Ptr(valp)[1] <> BlueTypeTag.NILBOX\n\t\t\t\t\tIf keyp[0] <> key Then mem.Write(keyp, key) ; hashpart[-2] :+ 1\n\t\t\t\tElse\t'nil value = remove element\n\t\t\t\t\tmem.Write(keyp, val) ; hashpart[-2] :- 1\n\t\t\t\tEndIf\n\t\t\tEndIf\n\t\tElseIf keyp <> Long Ptr(1)\n\t\t\tResize(mem, tbl, key) ; RawSet mem, tbl, key, val\n\t\tEndIf\n\tEnd Function\n\t\n\t' resize a table (adds space for the extra key, tries to reshuffle integer-keyed elements for optimal space usage)\n\tFunction Resize(mem:BlueVMMemory, tbl:Byte Ptr, key:Long)\n\t\tLocal hashpart:Byte Ptr = Byte Ptr Ptr(tbl)[2], arraypart:Byte Ptr = Byte Ptr Ptr(tbl)[3]\n\t\tConst NILTAG:Int = BlueTypeTag.NANBOX | BlueTypeTag.NIL\n\t\t\n\t\tLocal asize:Int = 0, tsize:Int = 0, numcount:Int[32]\n\t\tIf arraypart\t'compute new array size\n\t\t\tIf Int Ptr(arraypart)[1] <> NILTAG Then numcount[0] = 1\n\t\t\tLocal cell:Int = 1, cellp2:Int = 2 ^ cell\n\t\t\tFor Local i:Int = 1 Until Int Ptr(arraypart)[-1]\n\t\t\t\tIf i >= cellp2 Then cell :+ 1 ; cellp2 = 2 ^ cell\n\t\t\t\tIf Int Ptr(arraypart)[i * 2 + 1] <> NILTAG Then numcount[cell] :+ 1\n\t\t\tNext\n\t\tEndIf\n\t\tIf hashpart\n\t\t\tFor Local i:Int = 0 Until Int Ptr(hashpart)[-2]\n\t\t\t\tLocal tag2:Int = Int Ptr(hashpart)[i * 4 + 1]\n\t\t\t\tIf tag2 & BlueTypeTag.NANBOX_CHK <> BlueTypeTag.NANBOX\n\t\t\t\t\tLocal d:Double = Double Ptr(hashpart)[i * 2]\n\t\t\t\t\tIf d = Abs Int(d) Then numcount[Ceil(Log(d + 1) \/ Log(2))] :+ 1 Else tsize :+ 1\n\t\t\t\tElse\n\t\t\t\t\ttsize :+ 1\t'get started on new table size\n\t\t\t\tEndIf\n\t\t\tNext\n\t\tEndIf\n\t\t\n\t\tLocal tag:Int = Int Ptr(Varptr(key))[1]\t'add key to the appropriate one\n\t\tIf tag & BlueTypeTag.NANBOX_CHK <> BlueTypeTag.NANBOX\n\t\t\tLocal d:Double = Double Ptr(Varptr(key))[0]\n\t\t\tIf d = Abs Int(d) Then numcount[Ceil(Log(d + 1) \/ Log(2))] :+ 1 Else tsize :+ 1\n\t\tElse\n\t\t\ttsize :+ 1\n\t\tEndIf\n\t\tLocal addtotsize:Int = 0\n\t\tFor Local i:Int = 0 Until 32\t'tally up\n\t\t\taddtotsize :+ numcount[i]\n\t\t\tIf i Then numcount[i] :+ numcount[i - 1]\n\t\t\tIf numcount[i] > 2 ^ i \/ 2 Then asize = 2 ^ i ; addtotsize = 0\n\t\tNext\n\t\ttsize :+ addtotsize\n\t\tIf arraypart <> Null\t'complete new table size with any discarded array elements\n\t\t\tFor Local i:Int = asize Until Int Ptr(arraypart)[-1]\n\t\t\t\tIf Int Ptr(arraypart)[i * 2 + 1] <> NILTAG Then tsize :+ 1\n\t\t\tNext\n\t\tEndIf\n\t\ttsize = Ceil(Log(tsize) \/ Log(2)) + 1\t'go from count to power\n\t\t\n\t\tLocal newarray:Byte Ptr = Null, newtable:Byte Ptr = Null\t'allocate and copy\n\t\tLocal oldasize:Int = 0 ; If arraypart Then oldasize = Int Ptr(arraypart)[-1]\n\t\tLocal oldtsize:Int = 0 ; If hashpart Then oldtsize = Int Ptr(hashpart)[-1]\n\t\t\n\t\tIf asize <> oldasize\n\t\t\tnewarray = mem.AllocObject(asize * 8 + 8, BlueTypeTag.ARR) + 8\n\t\t\tFor Local i:Int = 0 Until asize\n\t\t\t\tLong Ptr(newarray)[i] = BlueVMMemory.NIL\n\t\t\tNext\n\t\t\tInt Ptr(newarray)[-1] = asize ; Byte Ptr Ptr(tbl)[3] = newarray\n\t\tElseIf asize = 0\n\t\t\tInt Ptr(tbl)[3] = 0\n\t\tElse\n\t\t\tnewarray = arraypart ; arraypart = Null\n\t\tEndIf\n\t\tIf tsize <> oldtsize\n\t\t\tnewtable = mem.AllocObject(2 ^ tsize * 16 + 8, BlueTypeTag.HASH)\n\t\t\tFor Local i:Int = 0 Until 2 ^ tsize * 2\n\t\t\t\tLong Ptr(newtable)[i] = BlueVMMemory.NIL\n\t\t\tNext\n\t\t\tInt Ptr(newtable)[-1] = tsize ; Int Ptr(newtable)[-2] = 0\n\t\t\tByte Ptr Ptr(tbl)[2] = newtable\n\t\tElseIf tsize = 0\n\t\t\tInt Ptr(tbl)[2] = 0\n\t\tElse\n\t\t\tnewtable = hashpart ; hashpart = Null\n\t\tEndIf\n\t\t\n\t\tIf arraypart\n\t\t\tFor Local i:Int = 0 Until oldasize\t'reinsert values\n\t\t\t\tLocal key:Long ; Double Ptr(Varptr(key))[0] = i\n\t\t\t\tRawSet mem, tbl, key,Long Ptr(arraypart)[i]\n\t\t\tNext\n\t\tEndIf\n\t\tIf hashpart\n\t\t\tFor Local i:Int = 0 Until 2 ^ oldtsize\n\t\t\t\tRawSet mem, tbl, Long Ptr(hashpart)[i * 2], Long Ptr(hashpart)[i * 2 + 1]\n\t\t\tNext\n\t\tEndIf\n\tEnd Function\nEnd Type\n\n","old_contents":"\n' Blue Moon\n' Lua-table implementation\n' uses simple linear probing for collision resolution and a shockingly naive reallocator\n\n\nSuperStrict\n\nImport \"blueallocator.bmx\"\n\n\nPrivate\nExtern\n\tFunction frexp:Double(d:Double, Exp:Int Ptr) = \"frexp\"\nEnd Extern\nPublic\n\nType BlueTable Final\n\t' retrieve the slot *for* a key's value, null if no available slot exists (to be used by non-raw index\/set operations)\n\tFunction GetSlot:Long Ptr(tbl:Byte Ptr, key:Long, keyslot:Long Ptr Ptr)\t'keyslot will return the slot for the key if it's not an array-slot\n\t\tLocal tag:Int = Int Ptr(Varptr(key))[1], idx:Int\n\t\tConst NILTAG:Int = BlueTypeTag.NANBOX | BlueTypeTag.NIL\n\t\t\n\t\tIf tag = BlueTypeTag.NANBOX | BlueTypeTag.STR\t'string - common case\n\t\t\tidx = Int Ptr(Int(key))[1]\n\t\tElseIf tag & BlueTypeTag.NANBOX_CHK <> BlueTypeTag.NANBOX\t'number\n\t\t\tLocal d:Double ; Long Ptr(Varptr(d))[0] = key ; idx = Abs Int(d)\n\t\t\tIf d = idx\t'int key\n\t\t\t\tLocal arr:Byte Ptr = Byte Ptr Ptr(tbl)[3]\n\t\t\t\tIf arr And idx < Int Ptr(arr)[-1] Then Return Long Ptr(arr) + idx\t'if this is nil, it won't be in the hash part anyway\n\t\t\tElse\n\t\t\t\td = frexp(d, Varptr(idx)) * ($7fffffff - 1024)\t'INT_MAX - DBL_MAX_EXP\n\t\t\t\tidx = Abs(idx) + Int(d)\n\t\t\tEndIf\n\t\tElseIf tag = NILTAG\t'nil -> nil\n\t\t\tkeyslot[0] = Long Ptr(1) ; Return Null\n\t\tElse\t'pointer (needs improvement)\n\t\t\tidx = Int(key) Shr 3\n\t\tEndIf\n\t\t\n\t\tLocal hashpart:Byte Ptr = Byte Ptr Ptr(tbl)[2]\n\t\tIf hashpart\n\t\t\tLocal hsize:Int = 1 Shl Int Ptr(hashpart)[-1]\n\t\t\tidx = idx & (hsize - 1)\t'apparently this is faster than Mod\n\t\t\tFor Local i:Int = idx Until hsize\t'naive linear probe\n\t\t\t\tLocal kp:Long Ptr = Long Ptr(hashpart) + 2 * i\n\t\t\t\tIf kp[0] = key Or Int Ptr(kp)[1] = NILTAG\n\t\t\t\t\tkeyslot[0] = kp ; Return kp + 1\n\t\t\t\tEndIf\n\t\t\tNext\n\t\t\tFor Local i:Int = 0 Until idx\t'yep\n\t\t\t\tLocal kp:Long Ptr = Long Ptr(hashpart) + 2 * i\n\t\t\t\tIf kp[0] = key Or Int Ptr(kp)[1] = NILTAG\n\t\t\t\t\tkeyslot[0] = kp ; Return kp + 1\n\t\t\t\tEndIf\n\t\t\tNext\n\t\tEndIf\n\t\t\n\t\tReturn Null\n\tEnd Function\n\t\n\t' retrieve a value from a table, or nil\n\tFunction RawGet:Long(tbl:Byte Ptr, key:Long)\n\t\tLocal keyp:Long Ptr = Null, retp:Long Ptr = GetSlot(tbl, key, Varptr(keyp)), ret:Long\n\t\tIf retp And (keyp <> Long Ptr(1))\n\t\t\tret = retp[0]\n\t\tElse\n\t\t\tInt Ptr(Varptr(ret))[1] = BlueTypeTag.NANBOX | BlueTypeTag.NIL\t'why can't i shift longs?\n\t\tEndIf\n\t\tReturn ret\n\tEnd Function\n\t\n\t' put a value into a table, resizing it if necessary\n\tFunction RawSet(mem:BlueVMMemory, tbl:Byte Ptr, key:Long, val:Long)\n\t\tLocal keyp:Long Ptr = Null, valp:Long Ptr = GetSlot(tbl, key, Varptr(keyp))\n\t\tIf valp\n\t\t\tmem.Write(valp, val)\n\t\t\tIf keyp\n\t\t\t\tLocal hashpart:Int Ptr = Int Ptr Ptr(tbl)[2]\n\t\t\t\tIf Int Ptr(valp)[1] <> BlueTypeTag.NILBOX\n\t\t\t\t\tIf keyp[0] <> key Then mem.Write(keyp, key) ; hashpart[-2] :+ 1\n\t\t\t\tElse\t'nil value = remove element\n\t\t\t\t\tmem.Write(keyp, val) ; hashpart[-2] :- 1\n\t\t\t\tEndIf\n\t\t\tEndIf\n\t\tElseIf keyp <> Long Ptr(1)\n\t\t\tResize(mem, tbl, key) ; RawSet mem, tbl, key, val\n\t\tEndIf\n\tEnd Function\n\t\n\t' resize a table (adds space for the extra key, tries to reshuffle integer-keyed elements for optimal space usage)\n\tFunction Resize(mem:BlueVMMemory, tbl:Byte Ptr, key:Long)\n\t\tLocal hashpart:Byte Ptr = Byte Ptr Ptr(tbl)[2], arraypart:Byte Ptr = Byte Ptr Ptr(tbl)[3]\n\t\tConst NILTAG:Int = BlueTypeTag.NANBOX | BlueTypeTag.NIL\n\t\t\n\t\tLocal asize:Int = 0, tsize:Int = 0, numcount:Int[32]\n\t\tIf arraypart\t'compute new array size\n\t\t\tIf Int Ptr(arraypart)[1] <> NILTAG Then numcount[0] = 1\n\t\t\tLocal cell:Int = 1, cellp2:Int = 2 ^ cell\n\t\t\tFor Local i:Int = 1 Until Int Ptr(arraypart)[-1]\n\t\t\t\tIf i >= cellp2 Then cell :+ 1 ; cellp2 = 2 ^ cell\n\t\t\t\tIf Int Ptr(arraypart)[i * 2 + 1] <> NILTAG Then numcount[cell] :+ 1\n\t\t\tNext\n\t\tEndIf\n\t\tIf hashpart\n\t\t\tFor Local i:Int = 0 Until Int Ptr(hashpart)[-2]\n\t\t\t\tLocal tag2:Int = Int Ptr(hashpart)[i * 4 + 1]\n\t\t\t\tIf tag2 & BlueTypeTag.NANBOX_CHK <> BlueTypeTag.NANBOX\n\t\t\t\t\tLocal d:Double = Double Ptr(hashpart)[i * 2]\n\t\t\t\t\tIf d = Abs Int(d) Then numcount[Ceil(Log(d + 1) \/ Log(2))] :+ 1 Else tsize :+ 1\n\t\t\t\tElse\n\t\t\t\t\ttsize :+ 1\t'get started on new table size\n\t\t\t\tEndIf\n\t\t\tNext\n\t\tEndIf\n\t\t\n\t\tLocal tag:Int = Int Ptr(Varptr(key))[1]\t'add key to the appropriate one\n\t\tIf tag & BlueTypeTag.NANBOX_CHK <> BlueTypeTag.NANBOX\n\t\t\tLocal d:Double = Double Ptr(Varptr(key))[0]\n\t\t\tIf d = Abs Int(d) Then numcount[Ceil(Log(d + 1) \/ Log(2))] :+ 1 Else tsize :+ 1\n\t\tElse\n\t\t\ttsize :+ 1\n\t\tEndIf\n\t\tLocal addtotsize:Int = 0\n\t\tFor Local i:Int = 0 Until 32\t'tally up\n\t\t\taddtotsize :+ numcount[i]\n\t\t\tIf i Then numcount[i] :+ numcount[i - 1]\n\t\t\tIf numcount[i] > 2 ^ i \/ 2 Then asize = 2 ^ i ; addtotsize = 0\n\t\tNext\n\t\ttsize :+ addtotsize\n\t\tIf arraypart <> Null\t'complete new table size with any discarded array elements\n\t\t\tFor Local i:Int = asize Until Int Ptr(arraypart)[-1]\n\t\t\t\tIf Int Ptr(arraypart)[i * 2 + 1] <> NILTAG Then tsize :+ 1\n\t\t\tNext\n\t\tEndIf\n\t\ttsize = Ceil(Log(tsize + 1) \/ Log(2))\t'go from count to power\n\t\t\n\t\tLocal newarray:Byte Ptr = Null, newtable:Byte Ptr = Null\t'allocate and copy\n\t\tLocal oldasize:Int = 0 ; If arraypart Then oldasize = Int Ptr(arraypart)[-1]\n\t\tLocal oldtsize:Int = 0 ; If hashpart Then oldtsize = Int Ptr(hashpart)[-1]\n\t\t\n\t\tIf asize <> oldasize\n\t\t\tnewarray = mem.AllocObject(asize * 8 + 8, BlueTypeTag.ARR) + 8\n\t\t\tFor Local i:Int = 0 Until asize\n\t\t\t\tInt Ptr(newarray)[i * 2 + 1] = NILTAG\n\t\t\tNext\n\t\t\tInt Ptr(newarray)[-1] = asize ; Byte Ptr Ptr(tbl)[3] = newarray\n\t\tElseIf asize = 0\n\t\t\tInt Ptr(tbl)[3] = 0\n\t\tElse\n\t\t\tnewarray = arraypart ; arraypart = Null\n\t\tEndIf\n\t\tIf tsize <> oldtsize\n\t\t\tnewtable = mem.AllocObject(2 ^ tsize * 16 + 8, BlueTypeTag.HASH)\n\t\t\tFor Local i:Int = 0 Until 2 ^ tsize * 2\n\t\t\t\tInt Ptr(newtable)[i * 2 + 1] = NILTAG\n\t\t\tNext\n\t\t\tInt Ptr(newtable)[-1] = tsize ; Int Ptr(newtable)[-2] = 0\n\t\t\tByte Ptr Ptr(tbl)[2] = newtable\n\t\tElseIf tsize = 0\n\t\t\tInt Ptr(tbl)[2] = 0\n\t\tElse\n\t\t\tnewtable = hashpart ; hashpart = Null\n\t\tEndIf\n\t\t\n\t\tIf arraypart\n\t\t\tFor Local i:Int = 0 Until oldasize\t'reinsert values\n\t\t\t\tLocal key:Long ; Double Ptr(Varptr(key))[0] = i\n\t\t\t\tRawSet mem, tbl, key,Long Ptr(arraypart)[i]\n\t\t\tNext\n\t\tEndIf\n\t\tIf hashpart\n\t\t\tFor Local i:Int = 0 Until 2 ^ oldtsize\n\t\t\t\tRawSet mem, tbl, Long Ptr(hashpart)[i * 2], Long Ptr(hashpart)[i * 2 + 1]\n\t\t\tNext\n\t\tEndIf\n\tEnd Function\nEnd Type\n\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"091a9262ffc1df2a83857eb0dbfbead245e478e9","subject":"Fixed matrix build issue.","message":"Fixed matrix build issue.\n","repos":"kfprimm\/maxb3d,kfprimm\/maxb3d","old_file":"core.mod\/camera.bmx","new_file":"core.mod\/camera.bmx","new_contents":"\nStrict\n\nImport \"entity.bmx\"\nImport \"worldconfig.bmx\"\n\nConst CAMMODE_NONE\t= 0\nConst CAMMODE_PERSP\t= 1\nConst CAMMODE_ORTHO\t= 2\n\nConst CLSMODE_COLOR\t= 1\nConst CLSMODE_DEPTH\t= 2\n\nConst FOGMODE_NONE\t\t= 0\nConst FOGMODE_LINEAR\t= 1\n\nType TCamera Extends TEntity\n\tField _projmode\n\tField _fogmode,_fogr#,_fogg#,_fogb#,_fognear#,_fogfar#\n\tField _viewx,_viewy,_viewwidth,_viewheight\n\tField _clsmode,_near#,_far#\n\tField _zoom#\n\t\n\tField _modelview:TMatrix=New TMatrix, _projection:TMatrix=New TMatrix\n\tField _viewport[4], _frustum:TFrustum\n\tField _update = True\n\t\n\tMethod Init:TCamera(config:TWorldConfig,parent:TEntity)\n\t\tSuper.Init(config, parent)\n\t\tSetMode CAMMODE_PERSP\n\t\tSetFogMode FOGMODE_NONE\n\t\tSetFogRange 1,1000\n\t\tSetViewport 0,0,_config.Width,_config.Height\n\t\tSetClsMode CLSMODE_COLOR|CLSMODE_DEPTH\n\t\tSetColor 0,0,0\n\t\tSetRange 1,1000\n\t\tSetZoom 1.0\n\t\tReturn Self\n\tEnd Method\n\t\n\tMethod Lists[]()\n\t\tReturn Super.Lists() + [WORLDLIST_CAMERA]\n\tEnd Method\n\n\tMethod CopyData:TEntity(entity:TEntity)\n\t\tLocal camera:TCamera = TCamera(entity)\n\t\tLocal red,green,blue,fognear#,fogfar#,x,y,width,height,near#,far#\n\t\tcamera.GetFogColor red,green,blue\n\t\tcamera.GetFogRange fognear,fogfar\n\t\tcamera.GetViewport x,y,width,height\n\t\tcamera.GetRange near,far\n\t\t\n\t\tSetMode camera.GetMode()\n\t\tSetFogMode camera.GetFogMode()\n\t\tSetFogColor red,green,blue\n\t\tSetFogRange fognear,fogfar\n\t\tSetViewport x,y,width,height\n\t\tSetClsMode camera.GetClsMode()\n\t\tSetRange near,far\n\t\tSetZoom camera.GetZoom()\n\t\tReturn Super.CopyData(entity)\n\tEnd Method\n\t\n\tMethod Copy:TCamera(parent:TEntity=Null)\n\t\tReturn TCamera(Super.Copy_(parent))\n\tEnd Method\n\t\n\tMethod GetMode()\n\t\tReturn _projmode\n\tEnd Method\n\tMethod SetMode(mode)\n\t\t_projmode=mode\n\tEnd Method\t\n\t\n\tMethod GetFogMode()\n\t\tReturn _fogmode\n\tEnd Method\n\tMethod SetFogMode(mode)\n\t\t_fogmode=mode\n\tEnd Method\n\t\n\tMethod GetFogColor(red Var,green Var,blue Var)\n\t\tred=_fogr*255.0;green=_fogg*255.0;blue=_fogb*255.0\n\tEnd Method\n\tMethod SetFogColor(red,green,blue)\n\t\t_fogr=red\/255.0;_fogg=green\/255.0;_fogb=blue\/255.0\n\tEnd Method\n\t\n\tMethod GetFogRange(near# Var,far# Var)\n\t\tnear=_fognear;far=_fogfar\n\tEnd Method\n\tMethod SetFogRange(near#,far#)\n\t\t_fognear=Max(near,0);_fogfar=Max(far,0.001)\n\tEnd Method\n\t\n\tMethod GetViewport(x Var,y Var,width Var,height Var)\n\t\tx=_viewx;y=_viewy;width=_viewwidth;height=_viewheight\n\tEnd Method\n\tMethod SetViewport(x,y,width,height)\n\t\t_viewx=x;_viewy=y;_viewwidth=width;_viewheight=height\n\tEnd Method\n\t\n\tMethod GetClsMode()\n\t\tReturn _clsmode\n\tEnd Method\n\tMethod SetClsMode(mode)\n\t\t_clsmode=mode\n\tEnd Method\n\t\n\tMethod GetRange(near# Var,far# Var)\n\t\tnear=_near;far=_far\n\tEnd Method\n\tMethod SetRange(near#,far#)\n\t\t_near=near;_far=far\n\tEnd Method\t\n\t\n\tMethod GetZoom#()\n\t\tReturn _zoom\n\tEnd Method\n\tMethod SetZoom(zoom#)\n\t\t_zoom=zoom\n\tEnd Method\n\t\n\tMethod GetFOV#()\n\t\tReturn ATan(_zoom \/ 1.0)\n\tEnd Method\n\tMethod SetFOV(angle#)\n\t\t_zoom = 1.0 \/ Tan(angle \/ 2.0)\n\tEnd Method\n\t\n\tMethod GetEye:TRay()\n\t\tLocal x#,y#,z#,dx#,dy#,dz#=1.0,o:TVector,d:TVector\n\t\tGetPosition x,y,z,True\n\t\t_matrix.TransformVec3 dx,dy,dz\n\t\tReturn New TRay.Create(New TVector.Create3(x,y,z),New TVector.Create3(dx-x,dy-y,dz-x))\t\t\n\tEnd Method\n\t\n\tMethod UpdateMatrices()\n\t\t_viewport[0]=_viewx\n\t\t_viewport[1]=_viewy\n\t\t_viewport[2]=_viewwidth\n\t\t_viewport[3]=_viewheight\n\t\t\n\t\t_modelview = _matrix.Inverse()\n\t\t\n\t\tLocal ratio#=(Float(_viewwidth)\/_viewheight)\n\t\t_projection = TMatrix.Scale(1,1,-1).Multiply(TMatrix.PerspectiveFovRH(ATan((1.0\/(_zoom*ratio)))*2.0,ratio,_near,_far))\n\n\t\t_frustum=TFrustum.Extract(_modelview, _projection)\n\t\t\n\t\t_update = False\n\tEnd Method\n\t\n\tMethod Project(target:Object,x# Var,y# Var, offset#[] = Null)\n\t\tIf _update UpdateMatrices()\n\t\tLocal z#\n\t\tTEntity.GetTargetPosition target,x,y,z\n\t\t\n\t\tIf offset\n\t\t\tx :+ offset[0]\n\t\t\ty :+ offset[1]\n\t\t\tz :+ offset[2]\n\t\tEndIf\n\t\t\n\t\tReturn TMatrix.Project(_modelview,_projection,_viewport,x,y,z)\n\tEnd Method\n\t\n\tMethod Unproject(wx#,wy#,wz#,x# Var,y# Var,z# Var)\n\t\tIf _update UpdateMatrices()\n\t\tReturn TMatrix.Unproject(_modelview,_projection,_viewport,wx,_viewport[3]-wy,wz,x,y,z)\n\tEnd Method\n\t\n\tMethod InView#(target:Object)\n\t\tLocal x#,y#,z#,radius#\n\t\tLocal entity:TEntity=TEntity(target),point#[]=Float[](target)\n\t\tIf entity\n\t\t\tentity.GetCullParams x,y,z,radius\n\t\tElseIf point\n\t\t\tx=point[0];y=point[1];z=point[2];radius=point[3]\n\t\tElse\n\t\t\tReturn 0\n\t\tEndIf\n\t\tReturn _frustum.IntersectsPoint(x,y,z,radius)\n\tEnd Method\nEnd Type\n","old_contents":"\nStrict\n\nImport \"entity.bmx\"\nImport \"worldconfig.bmx\"\n\nConst CAMMODE_NONE\t= 0\nConst CAMMODE_PERSP\t= 1\nConst CAMMODE_ORTHO\t= 2\n\nConst CLSMODE_COLOR\t= 1\nConst CLSMODE_DEPTH\t= 2\n\nConst FOGMODE_NONE\t\t= 0\nConst FOGMODE_LINEAR\t= 1\n\nType TCamera Extends TEntity\n\tField _projmode\n\tField _fogmode,_fogr#,_fogg#,_fogb#,_fognear#,_fogfar#\n\tField _viewx,_viewy,_viewwidth,_viewheight\n\tField _clsmode,_near#,_far#\n\tField _zoom#\n\t\n\tField _modelview:TMatrix=New TMatrix\n\tField _projection:TMatrix=New TMatrix\n\tField _viewport[4]\n\tField _frustum:TFrustum\n\t\n\tMethod Init:TCamera(config:TWorldConfig,parent:TEntity)\n\t\tSuper.Init(config, parent)\n\t\tSetMode CAMMODE_PERSP\n\t\tSetFogMode FOGMODE_NONE\n\t\tSetFogRange 1,1000\n\t\tSetViewport 0,0,_config.Width,_config.Height\n\t\tSetClsMode CLSMODE_COLOR|CLSMODE_DEPTH\n\t\tSetColor 0,0,0\n\t\tSetRange 1,1000\n\t\tSetZoom 1.0\n\t\tReturn Self\n\tEnd Method\n\t\n\tMethod Lists[]()\n\t\tReturn Super.Lists() + [WORLDLIST_CAMERA]\n\tEnd Method\n\n\tMethod CopyData:TEntity(entity:TEntity)\n\t\tLocal camera:TCamera = TCamera(entity)\n\t\tLocal red,green,blue,fognear#,fogfar#,x,y,width,height,near#,far#\n\t\tcamera.GetFogColor red,green,blue\n\t\tcamera.GetFogRange fognear,fogfar\n\t\tcamera.GetViewport x,y,width,height\n\t\tcamera.GetRange near,far\n\t\t\n\t\tSetMode camera.GetMode()\n\t\tSetFogMode camera.GetFogMode()\n\t\tSetFogColor red,green,blue\n\t\tSetFogRange fognear,fogfar\n\t\tSetViewport x,y,width,height\n\t\tSetClsMode camera.GetClsMode()\n\t\tSetRange near,far\n\t\tSetZoom camera.GetZoom()\n\t\tReturn Super.CopyData(entity)\n\tEnd Method\n\t\n\tMethod Copy:TCamera(parent:TEntity=Null)\n\t\tReturn TCamera(Super.Copy_(parent))\n\tEnd Method\n\t\n\tMethod GetMode()\n\t\tReturn _projmode\n\tEnd Method\n\tMethod SetMode(mode)\n\t\t_projmode=mode\n\tEnd Method\t\n\t\n\tMethod GetFogMode()\n\t\tReturn _fogmode\n\tEnd Method\n\tMethod SetFogMode(mode)\n\t\t_fogmode=mode\n\tEnd Method\n\t\n\tMethod GetFogColor(red Var,green Var,blue Var)\n\t\tred=_fogr*255.0;green=_fogg*255.0;blue=_fogb*255.0\n\tEnd Method\n\tMethod SetFogColor(red,green,blue)\n\t\t_fogr=red\/255.0;_fogg=green\/255.0;_fogb=blue\/255.0\n\tEnd Method\n\t\n\tMethod GetFogRange(near# Var,far# Var)\n\t\tnear=_fognear;far=_fogfar\n\tEnd Method\n\tMethod SetFogRange(near#,far#)\n\t\t_fognear=Max(near,0);_fogfar=Max(far,0.001)\n\tEnd Method\n\t\n\tMethod GetViewport(x Var,y Var,width Var,height Var)\n\t\tx=_viewx;y=_viewy;width=_viewwidth;height=_viewheight\n\tEnd Method\n\tMethod SetViewport(x,y,width,height)\n\t\t_viewx=x;_viewy=y;_viewwidth=width;_viewheight=height\n\tEnd Method\n\t\n\tMethod GetClsMode()\n\t\tReturn _clsmode\n\tEnd Method\n\tMethod SetClsMode(mode)\n\t\t_clsmode=mode\n\tEnd Method\n\t\n\tMethod GetRange(near# Var,far# Var)\n\t\tnear=_near;far=_far\n\tEnd Method\n\tMethod SetRange(near#,far#)\n\t\t_near=near;_far=far\n\tEnd Method\t\n\t\n\tMethod GetZoom#()\n\t\tReturn _zoom\n\tEnd Method\n\tMethod SetZoom(zoom#)\n\t\t_zoom=zoom\n\tEnd Method\n\t\n\tMethod GetFOV#()\n\t\tReturn ATan(_zoom \/ 1.0)\n\tEnd Method\n\tMethod SetFOV(angle#)\n\t\t_zoom = 1.0 \/ Tan(angle \/ 2.0)\n\tEnd Method\n\t\n\tMethod GetEye:TRay()\n\t\tLocal x#,y#,z#,dx#,dy#,dz#=1.0,o:TVector,d:TVector\n\t\tGetPosition x,y,z,True\n\t\t_matrix.TransformVec3 dx,dy,dz\n\t\tReturn New TRay.Create(New TVector.Create3(x,y,z),New TVector.Create3(dx-x,dy-y,dz-x))\t\t\n\tEnd Method\n\t\n\tMethod UpdateMatrices()\n\t\t_viewport[0]=_viewx\n\t\t_viewport[1]=_viewy\n\t\t_viewport[2]=_viewwidth\n\t\t_viewport[3]=_viewheight\n\t\t\n\t\t_modelview = _matrix.Inverse()\n\t\t\n\t\tLocal ratio#=(Float(_viewwidth)\/_viewheight)\n\t\t_projection = TMatrix.Scale(1,1,-1).Multiply(TMatrix.PerspectiveFovRH(ATan((1.0\/(_zoom*ratio)))*2.0,ratio,_near,_far))\n\n\t\t_frustum=TFrustum.Extract(_modelview, _projection)\n\tEnd Method\n\t\n\tMethod Project(target:Object,x# Var,y# Var, offset#[] = Null)\n\t\tLocal z#\n\t\tTEntity.GetTargetPosition target,x,y,z\n\t\t\n\t\tIf offset\n\t\t\tx :+ offset[0]\n\t\t\ty :+ offset[1]\n\t\t\tz :+ offset[2]\n\t\tEndIf\n\t\t\n\t\tReturn TMatrix.Project(_modelview,_projection,_viewport,x,y,z)\n\tEnd Method\n\t\n\tMethod Unproject(wx#,wy#,wz#,x# Var,y# Var,z# Var)\n\t\tReturn TMatrix.Unproject(_modelview,_projection,_viewport,wx,wy,wz,x,y,z)\n\tEnd Method\n\t\n\tMethod InView#(target:Object)\n\t\tLocal x#,y#,z#,radius#\n\t\tLocal entity:TEntity=TEntity(target),point#[]=Float[](target)\n\t\tIf entity\n\t\t\tentity.GetCullParams x,y,z,radius\n\t\tElseIf point\n\t\t\tx=point[0];y=point[1];z=point[2];radius=point[3]\n\t\tElse\n\t\t\tReturn 0\n\t\tEndIf\n\t\tReturn _frustum.IntersectsPoint(x,y,z,radius)\n\tEnd Method\nEnd Type\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"0675d12e1a7f4e87e887d1f4177b571309f6c062","subject":"Made last pick priority in TWorld.Pick.","message":"Made last pick priority in TWorld.Pick.\n","repos":"kfprimm\/maxb3d,kfprimm\/maxb3d","old_file":"core.mod\/world.bmx","new_file":"core.mod\/world.bmx","new_contents":"\nStrict\n\nImport \"worldconfig.bmx\"\nImport \"collision.bmx\"\nImport \"body.bmx\"\nImport \"pivot.bmx\"\nImport \"custom_entity.bmx\"\nImport \"driver.bmx\"\nImport \"pick.bmx\"\nImport \"meshloader.bmx\"\nImport \"meshloaderempty.bmx\"\n\nPrivate\nFunction ModuleLog(message$)\n\tTMaxB3DLogger.Write \"core\/world\",message\nEnd Function\n\nPublic\n\nType TWorld\n\tField _config:TWorldConfig=New TWorldConfig\n\tField _collisiondriver:TCollisionDriver\n\t\n\tMethod New()\n\t\tSetAmbientLight 127,127,127\n\t\tSetCollisionDriver TCollisionDriver._default\n\t\tAddTextureFilter \"\", TEXTURE_COLOR|TEXTURE_MIPMAP\n\t\t\n\t\t_config.Width = GraphicsWidth()\n\t\t_config.Height = GraphicsHeight()\n\t\t\n\t\tTMaxB3DDriver._configs :+ [_config]\n\tEnd Method\n\t\n\tMethod AddResourcePath(path$)\n\t\t_config.ResourcePath=_config.ResourcePath[.._config.ResourcePath.length+1]\n\t\t_config.ResourcePath[_config.ResourcePath.length-1]=path\n\tEnd Method\n\t\n\tMethod ClearTextureFilters()\n\t\t_config.TextureFilters = Null\n\tEnd Method\n\t\n\tMethod AddTextureFilter(text$, flags)\n\t\t_config.TextureFilters :+ [[text, String(flags)]]\n\tEnd Method\n\t\n\tMethod SetCollisionDriver(driver:TCollisionDriver)\n\t\tIf driver\n\t\t\tdriver.Init()\n\t\t\t_collisiondriver=driver\n\t\tEndIf\n\tEnd Method\n\t\n\tMethod GetAmbientLight(red Var,green Var,blue Var)\n\t\tred=_config.AmbientRed\n\t\tgreen=_config.AmbientGreen\n\t\tblue=_config.AmbientBlue\n\tEnd Method\n\tMethod SetAmbientLight(red,green,blue)\n\t\t_config.AmbientRed=red\n\t\t_config.AmbientGreen=green\n\t\t_config.AmbientBlue=blue\n\tEnd Method\n\t\n\tMethod GetWireFrame()\n\t\tReturn _config.Wireframe\n\tEnd Method\n\tMethod SetWireFrame(enable)\n\t\t_config.Wireframe=enable\n\tEnd Method\n\t\n\tMethod GetDither()\n\t\tReturn _config.Dither\n\tEnd Method\n\tMethod SetDither(enable)\n\t\t_config.Dither=enable\n\tEnd Method\n\t\n\tMethod PickTarget(src:Object,target#[],ax# Var,ay# Var,az# Var,bx# Var,by# Var,bz# Var,radius#)\n\t\tIf target.length = 1\n\t\t\n\t\tElseIf target.length = 2\n\t\t\tLocal camera:TCamera = TCamera(src)\n\t\t\tcamera.Unproject target[0], target[1], 1, ax, ay, az\n\t\t\tcamera.Unproject target[0], target[1], 0, bx, by, bz\n\t\tElse\n\t\t\n\t\tEndIf\n\tEnd Method\n\t\n\t'EntityPick ( entity,range# )\n\t'CameraPick ( camera,viewport_x#,viewport_y# )\n\t'LinePick ( x#,y#,z#,dx#,dy#,dz#[,radius#] )\n\tMethod Picks:TPick[](src:Object, target:Object, sort = False)\n\t\tLocal ax#,ay#,az#,bx#,by#,bz#,radius#=0.0\n\t\tTEntity.GetTargetPosition src,ax,ay,az\n\t\tPickTarget src,Float[](target),ax,ay,az,bx,by,bz,radius\n\t\t\t\n\t\tLocal picks:TPick[]\t\t\n\t\tFor Local entity:TEntity=EachIn _config.List[WORLDLIST_ENTITY]\t\t\n\t\t\tIf entity._pickmode=PICKMODE_OFF Or Not entity.GetVisible() Then Continue\n\t\t\tIf entity._pickmode=PICKMODE_POLYGON And TMesh(entity)=Null Continue\n\t\t\t\n\t\t\tLocal matrix:TMatrix = entity._matrix\n\t\t\t\n\t\t\tLocal raw:TRawPick = entity.Pick(entity._pickmode,ax,ay,az,bx-ax,by-ay,bz-az,radius)\n\t\t\tIf raw\n\t\t\t\tLocal info:TPick = New TPick.FromRaw(raw)\n\t\t\t\tIf TMesh(entity)<>Null And entity._pickmode = PICKMODE_POLYGON info.surface = TMesh(entity)._surfaces[raw.surface]\t\t\t\t\n\t\t\t\tpicks :+ [info]\n\t\t\tEndIf\t\t\n\t\tNext\n\t\t\n\t\tReturn picks\t\t\n\tEnd Method\n\t\n\tMethod Pick:TPick(src:Object, target:Object)\n\t\tLocal picks:TPick[] = Picks(src, target, True)\n\t\tIf picks.length > 0 Return picks[picks.length - 1]\n\tEnd Method\n\t\t\n\tMethod AddTexture:TTexture(url:Object,flags=TEXTURE_DEFAULT)\n\t\tIf TTexture(url) Return TTexture(url)\n\t\tIf Not Int[](url) And Not TPixmap(url) url = _config.GetStream(url)\n\t\tReturn New TTexture.Init(_config,url,flags)\n\tEnd Method\n\t\n\tMethod AddBrush:TBrush(url:Object=Null)\n\t\tReturn New TBrush.Init(_config, url)\n\tEnd Method\n\t\n\tMethod AddPivot:TPivot(parent:TEntity=Null)\n\t\tReturn TPivot(New TPivot.Init(_config, parent))\n\tEnd Method\n\t\n\tMethod AddCamera:TCamera(parent:TEntity=Null)\n\t\tReturn TCamera(New TCamera.Init(_config, parent))\n\tEnd Method\n\t\n\tMethod AddLight:TLight(mode,parent:TEntity=Null)\n\t\tLocal light:TLight=New TLight\n\t\tlight.SetMode mode\n\t\tReturn TLight(light.Init(_config, parent))\n\tEnd Method\t\n\t\n\tMethod AddMesh:TMesh(url:Object,parent:TEntity=Null)\n\t\tLocal mesh:TMesh=New TMesh\n\t\tIf String(url) _config.TmpResourcePath=ExtractDir(String(url))\n\t\tIf Not TMeshLoader.Load(_config,mesh,_config.GetStream(url))\n\t\t\t_config.TmpResourcePath = \"\"\n\t\t\tIf url ModuleLog \"Unable to load mesh url. (\"+url.ToString()+\")\" Else ModuleLog \"Unable to load mesh url. (null)\"\n\t\t\tReturn Null\n\t\tEndIf\n\t\t_config.TmpResourcePath = \"\"\n\t\tReturn TMesh(mesh.Init(_config, parent))\n\tEnd Method\n\t\n\tMethod AddFlat:TFlat(parent:TEntity=Null)\n\t\tReturn TFlat(New TFlat.Init(_config, parent))\n\tEnd Method\n\t\n\tMethod AddSprite:TSprite(url:Object,flags=TEXTURE_DEFAULT,parent:TEntity=Null)\n\t\tLocal sprite:TSprite=New TSprite \n\t\tIf url sprite.SetTexture AddTexture(url,flags)\n\t\tReturn TSprite(sprite.Init(_config, parent))\n\tEnd Method\n\t\n\tMethod AddTerrain:TTerrain(url:Object,parent:TEntity=Null)\n\t\tLocal terrain:TTerrain=New TTerrain\n\t\tterrain.SetMap url\n\t\tReturn TTerrain(terrain.Init(_config, parent))\n\tEnd Method\n\t\n\tMethod AddBody:TBody()\n\t\tReturn TBody(New TBody.Init(_config, Null))\n\tEnd Method\n\t\n\tMethod AddBone:TBone(parent:TEntity=Null)\n\t\tReturn TBone(New TBone.Init(_config, parent))\n\tEnd Method\n\t\n\tMethod AddBSPModel:TBSPModel(url:Object,parent:TEntity=Null)\n\t\tLocal bsp:TBSPModel=New TBSPModel\n\t\tbsp.SetTree TBSPTree(url)\n\t\tReturn TBSPModel(bsp.Init(_config, parent))\n\tEnd Method\n\t\n\tMethod AddCustomEntity:TCustomEntity(entity:TCustomEntity,parent:TEntity=Null)\n\t\tReturn TCustomEntity(entity.Init(_config, parent))\n\tEnd Method\n\t\n\tMethod Render:TRenderInfo(tween#=1.0)\n\t\tLocal driver:TMaxB3DDriver=TMaxB3DDriver(GetGraphicsDriver())\n\n\t\tGlobal info:TRenderInfo=New TRenderInfo\n\t\tinfo.Triangles=0\n\t\tinfo.Entities=0\n\n\t\tFor Local camera:TCamera=EachIn _config.List[WORLDLIST_CAMERA]\n\t\t\tIf Not camera.GetVisible() Continue\n\t\t\tLocal i:TRenderInfo=RenderCamera(camera)\n\t\t\tinfo.Triangles:+i.Triangles\n\t\t\tinfo.Entities:+i.Entities\n\t\tNext\n\t\t\n\t\tGlobal _ticks,_lastupdate\n\n\t\tIf _lastupdate+1000 0\n\t\t\t\t\tRepeat\n\t\t\t\t\t\tlink=link._succ\n\t\t\t\t\tUntil link=list._head Or TEntity(link.Value())._order <= entity._order\n\t\t\t\t\tlist.InsertBeforeLink(entity,link)\n\t\t\t\tElseIf entity._order < 0\n\t\t\t\t\tRepeat\n\t\t\t\t\t\tlink=link._pred\n\t\t\t\t\tUntil link=list._head Or TEntity(link.Value())._order >= entity._order\n\t\t\t\t\tlist.InsertAfterLink(entity,link)\t\t\t\t\n\t\t\t\tElse\n\t\t\t\t\tIf entity.HasAlpha()\n\t\t\t\t\t\tentity._alphaorder = camera.GetDistance(entity)\n\t\t\t\t\t\tRepeat\n\t\t\t\t\t\t\tlink=link._pred\n\t\t\t\t\t\t\tIf link=list._head Then Exit\n\t\t\t\t\t\tUntil TEntity(link.Value())._order >= 0 And (TEntity(link.Value())._alphaorder >= entity._alphaorder Or TEntity(link.Value())._alphaorder = 0.0)\n\t\t\t\t\t\tlist.InsertAfterLink(entity,link)\n\t\t\t\t\tElse\n\t\t\t\t\t\tentity._alphaorder = 0\n\t\t\t\t\t\tRepeat\n\t\t\t\t\t\t\tlink=link._succ\n\t\t\t\t\t\tUntil link=list._head Or TEntity(link.Value())._order <= 0\n\t\t\t\t\t\tlist.InsertBeforeLink(entity,link)\n\t\t\t\t\tEndIf\n\t\t\t\tEndIf\t\n\t\t\tEndIf\n\t\tNext\n\t\t\n\t\tUpdateSprites list,driver,camera\n\t\t\n\t\tReturn RenderEntities(list,driver,camera)\t\t\n\tEnd Method\n\n\tMethod Update(speed#)\n\t\t_config.UpdateSpeed = speed#\n\t\tRunHooks _config.UpdateHook, _config\n\t\t_collisiondriver.Update _config,speed\n\t\tFor Local mesh:TMesh=EachIn _config.List[WORLDLIST_MESH]\n\t\t\tLocal animator:TAnimator=mesh._animator\n\t\t\tIf animator=Null Continue\n\t\t\tLocal seq:TAnimSeq=animator._current\n\t\t\tIf seq\n\t\t\t\tIf animator._mode>0\t\t\n\t\t\t\t\tanimator._frame:+(speed*animator._speed)\n\t\t\t\t\tIf animator._frame>seq._end Or animator._frameseq._end animator._frame=seq._start'+(animator._frame-seq._end)\n\t\t\t\t\t\t\tIf animator._frameseq._end animator._frame=seq._end'+(animator._frame-seq._end)\n\t\t\t\t\t\t\tIf animator._frame0))\n\t\t\t\tElseIf terrain\n\t\t\t\t\tLocal x#,y#,z#\n\t\t\t\t\tcamera.GetPosition x,y,z,True\n\t\t\t\t\tterrain.Update x,y,z,camera._frustum.ToPtr()\n\t\t\t\t\tinfo.Triangles:+driver.RenderTerrain(terrain)\n\t\t\t\tElseIf bsp\n\t\t\t\t\tLocal tree:TBSPTree=bsp.GetRenderTree(camera.GetEye())\n\t\t\t\t\tinfo.Triangles:+driver.RenderBSPTree(tree)\n\t\t\t\tElseIf custom\n\t\t\t\t\tinfo.Triangles:+renderer.Render(custom, driver)\n\t\t\t\tEndIf\t\n\t\t\tEndIf\n\t\t\tdriver.EndEntityRender entity\t\t\n\t\tNext\n\t\tReturn info\n\tEnd Method\n\t\n\tMethod UpdateSprites(sprites:TList,driver:TMaxB3DDriver,camera:TCamera)\t\n\t\tFor Local sprite:TSprite=EachIn sprites\n\t\t\tLocal matrix:TMatrix\n\t\t\tIf True\n\t\t\t\tIf sprite._viewmode<>VIEWMODE_FREE\t\t\n\t\t\t\t\tLocal x#,y#,z#\n\t\t\t\t\tsprite.GetPosition x,y,z,True\n\t\t\t\t\n\t\t\t\t\tmatrix = camera.GetMatrix()'.Inverse()\n\t\t\t\t\tmatrix._m[3,0]=x\n\t\t\t\t\tmatrix._m[3,1]=y\n\t\t\t\t\tmatrix._m[3,2]=z\n\t\t\t\t\t\n\t\t\t\t\tmatrix=TMatrix.YawPitchRoll(180,0,sprite._angle).Multiply(matrix)\t\t\t\t\t\n\t\t\t\t\tIf sprite._sx<>1.0 Or sprite._sy<>1.0 matrix=TMatrix.Scale(sprite._sx,sprite._sy,1.0).Multiply(matrix)\t\t\t\t\t\n\t\t\t\t\t'If sprite._handlex<>0.0 Or sprite._handley<>0.0 matrix=TMatrix.Translation(-sprite._handlex,-sprite._handley,0.0).Multiply(matrix)\n\t\t\t\tElse\t\t\t\t\n\t\t\t\t\tmatrix = sprite.GetMatrix()\t\t\t\t\t\n\t\t\t\t\t'If sprite.scale_x#<>1.0 Or sprite.scale_y#<>1.0\n\t\t\t\t\t'\tsprite.mat_sp.Scale(sprite.scale_x#,sprite.scale_y#,1.0)\n\t\t\t\t\t'EndIf\t\t\n\t\t\t\tEndIf\n\t\t\tElse\n\t\t\t\tmatrix=sprite._matrix\n\t\t\tEndIf\n\t\t\tsprite._view_matrix=matrix\t\n\t\tNext\n\tEnd Method\n\t\n\tMethod SetLighting(driver:TMaxB3DDriver,camera:TCamera)\n\t\tLocal index\n\t\tFor Local i=0 To 7\n\t\t\tLocal light:TLight\n\t\t\tIf index=CountList(_config.List[WORLDLIST_LIGHT])\n\t\t\tEndIf\n\t\t\tdriver.SetLight light,i\n\t\tNext\n\tEnd Method\nEnd Type\n\nType TRenderInfo\n\tField FPS\n\tField Triangles\n\tField Entities\nEnd Type\n\n","old_contents":"\nStrict\n\nImport \"worldconfig.bmx\"\nImport \"collision.bmx\"\nImport \"body.bmx\"\nImport \"pivot.bmx\"\nImport \"custom_entity.bmx\"\nImport \"driver.bmx\"\nImport \"pick.bmx\"\nImport \"meshloader.bmx\"\nImport \"meshloaderempty.bmx\"\n\nPrivate\nFunction ModuleLog(message$)\n\tTMaxB3DLogger.Write \"core\/world\",message\nEnd Function\n\nPublic\n\nType TWorld\n\tField _config:TWorldConfig=New TWorldConfig\n\tField _collisiondriver:TCollisionDriver\n\t\n\tMethod New()\n\t\tSetAmbientLight 127,127,127\n\t\tSetCollisionDriver TCollisionDriver._default\n\t\tAddTextureFilter \"\", TEXTURE_COLOR|TEXTURE_MIPMAP\n\t\t\n\t\t_config.Width = GraphicsWidth()\n\t\t_config.Height = GraphicsHeight()\n\t\t\n\t\tTMaxB3DDriver._configs :+ [_config]\n\tEnd Method\n\t\n\tMethod AddResourcePath(path$)\n\t\t_config.ResourcePath=_config.ResourcePath[.._config.ResourcePath.length+1]\n\t\t_config.ResourcePath[_config.ResourcePath.length-1]=path\n\tEnd Method\n\t\n\tMethod ClearTextureFilters()\n\t\t_config.TextureFilters = Null\n\tEnd Method\n\t\n\tMethod AddTextureFilter(text$, flags)\n\t\t_config.TextureFilters :+ [[text, String(flags)]]\n\tEnd Method\n\t\n\tMethod SetCollisionDriver(driver:TCollisionDriver)\n\t\tIf driver\n\t\t\tdriver.Init()\n\t\t\t_collisiondriver=driver\n\t\tEndIf\n\tEnd Method\n\t\n\tMethod GetAmbientLight(red Var,green Var,blue Var)\n\t\tred=_config.AmbientRed\n\t\tgreen=_config.AmbientGreen\n\t\tblue=_config.AmbientBlue\n\tEnd Method\n\tMethod SetAmbientLight(red,green,blue)\n\t\t_config.AmbientRed=red\n\t\t_config.AmbientGreen=green\n\t\t_config.AmbientBlue=blue\n\tEnd Method\n\t\n\tMethod GetWireFrame()\n\t\tReturn _config.Wireframe\n\tEnd Method\n\tMethod SetWireFrame(enable)\n\t\t_config.Wireframe=enable\n\tEnd Method\n\t\n\tMethod GetDither()\n\t\tReturn _config.Dither\n\tEnd Method\n\tMethod SetDither(enable)\n\t\t_config.Dither=enable\n\tEnd Method\n\t\n\tMethod PickTarget(src:Object,target#[],ax# Var,ay# Var,az# Var,bx# Var,by# Var,bz# Var,radius#)\n\t\tIf target.length = 1\n\t\t\n\t\tElseIf target.length = 2\n\t\t\tLocal camera:TCamera = TCamera(src)\n\t\t\tcamera.Unproject target[0], target[1], 1, ax, ay, az\n\t\t\tcamera.Unproject target[0], target[1], 0, bx, by, bz\n\t\tElse\n\t\t\n\t\tEndIf\n\tEnd Method\n\t\n\t'EntityPick ( entity,range# )\n\t'CameraPick ( camera,viewport_x#,viewport_y# )\n\t'LinePick ( x#,y#,z#,dx#,dy#,dz#[,radius#] )\n\tMethod Picks:TPick[](src:Object, target:Object, sort = False)\n\t\tLocal ax#,ay#,az#,bx#,by#,bz#,radius#=0.0\n\t\tTEntity.GetTargetPosition src,ax,ay,az\n\t\tPickTarget src,Float[](target),ax,ay,az,bx,by,bz,radius\n\t\t\t\n\t\tLocal picks:TPick[]\t\t\n\t\tFor Local entity:TEntity=EachIn _config.List[WORLDLIST_ENTITY]\t\t\n\t\t\tIf entity._pickmode=PICKMODE_OFF Or Not entity.GetVisible() Then Continue\n\t\t\tIf entity._pickmode=PICKMODE_POLYGON And TMesh(entity)=Null Continue\n\t\t\t\n\t\t\tLocal matrix:TMatrix = entity._matrix\n\t\t\t\n\t\t\tLocal raw:TRawPick = entity.Pick(entity._pickmode,ax,ay,az,bx-ax,by-ay,bz-az,radius)\n\t\t\tIf raw\n\t\t\t\tLocal info:TPick = New TPick.FromRaw(raw)\n\t\t\t\tIf TMesh(entity)<>Null And entity._pickmode = PICKMODE_POLYGON info.surface = TMesh(entity)._surfaces[raw.surface]\t\t\t\t\n\t\t\t\tpicks :+ [info]\n\t\t\tEndIf\t\t\n\t\tNext\n\t\t\n\t\tReturn picks\t\t\n\tEnd Method\n\t\n\tMethod Pick:TPick(src:Object, target:Object)\n\t\tLocal picks:TPick[] = Picks(src, target, True)\n\t\tIf picks.length > 0 Return picks[0]\n\tEnd Method\n\t\t\n\tMethod AddTexture:TTexture(url:Object,flags=TEXTURE_DEFAULT)\n\t\tIf TTexture(url) Return TTexture(url)\n\t\tIf Not Int[](url) And Not TPixmap(url) url = _config.GetStream(url)\n\t\tReturn New TTexture.Init(_config,url,flags)\n\tEnd Method\n\t\n\tMethod AddBrush:TBrush(url:Object=Null)\n\t\tReturn New TBrush.Init(_config, url)\n\tEnd Method\n\t\n\tMethod AddPivot:TPivot(parent:TEntity=Null)\n\t\tReturn TPivot(New TPivot.Init(_config, parent))\n\tEnd Method\n\t\n\tMethod AddCamera:TCamera(parent:TEntity=Null)\n\t\tReturn TCamera(New TCamera.Init(_config, parent))\n\tEnd Method\n\t\n\tMethod AddLight:TLight(mode,parent:TEntity=Null)\n\t\tLocal light:TLight=New TLight\n\t\tlight.SetMode mode\n\t\tReturn TLight(light.Init(_config, parent))\n\tEnd Method\t\n\t\n\tMethod AddMesh:TMesh(url:Object,parent:TEntity=Null)\n\t\tLocal mesh:TMesh=New TMesh\n\t\tIf String(url) _config.TmpResourcePath=ExtractDir(String(url))\n\t\tIf Not TMeshLoader.Load(_config,mesh,_config.GetStream(url))\n\t\t\t_config.TmpResourcePath = \"\"\n\t\t\tIf url ModuleLog \"Unable to load mesh url. (\"+url.ToString()+\")\" Else ModuleLog \"Unable to load mesh url. (null)\"\n\t\t\tReturn Null\n\t\tEndIf\n\t\t_config.TmpResourcePath = \"\"\n\t\tReturn TMesh(mesh.Init(_config, parent))\n\tEnd Method\n\t\n\tMethod AddFlat:TFlat(parent:TEntity=Null)\n\t\tReturn TFlat(New TFlat.Init(_config, parent))\n\tEnd Method\n\t\n\tMethod AddSprite:TSprite(url:Object,flags=TEXTURE_DEFAULT,parent:TEntity=Null)\n\t\tLocal sprite:TSprite=New TSprite \n\t\tIf url sprite.SetTexture AddTexture(url,flags)\n\t\tReturn TSprite(sprite.Init(_config, parent))\n\tEnd Method\n\t\n\tMethod AddTerrain:TTerrain(url:Object,parent:TEntity=Null)\n\t\tLocal terrain:TTerrain=New TTerrain\n\t\tterrain.SetMap url\n\t\tReturn TTerrain(terrain.Init(_config, parent))\n\tEnd Method\n\t\n\tMethod AddBody:TBody()\n\t\tReturn TBody(New TBody.Init(_config, Null))\n\tEnd Method\n\t\n\tMethod AddBone:TBone(parent:TEntity=Null)\n\t\tReturn TBone(New TBone.Init(_config, parent))\n\tEnd Method\n\t\n\tMethod AddBSPModel:TBSPModel(url:Object,parent:TEntity=Null)\n\t\tLocal bsp:TBSPModel=New TBSPModel\n\t\tbsp.SetTree TBSPTree(url)\n\t\tReturn TBSPModel(bsp.Init(_config, parent))\n\tEnd Method\n\t\n\tMethod AddCustomEntity:TCustomEntity(entity:TCustomEntity,parent:TEntity=Null)\n\t\tReturn TCustomEntity(entity.Init(_config, parent))\n\tEnd Method\n\t\n\tMethod Render:TRenderInfo(tween#=1.0)\n\t\tLocal driver:TMaxB3DDriver=TMaxB3DDriver(GetGraphicsDriver())\n\n\t\tGlobal info:TRenderInfo=New TRenderInfo\n\t\tinfo.Triangles=0\n\t\tinfo.Entities=0\n\n\t\tFor Local camera:TCamera=EachIn _config.List[WORLDLIST_CAMERA]\n\t\t\tIf Not camera.GetVisible() Continue\n\t\t\tLocal i:TRenderInfo=RenderCamera(camera)\n\t\t\tinfo.Triangles:+i.Triangles\n\t\t\tinfo.Entities:+i.Entities\n\t\tNext\n\t\t\n\t\tGlobal _ticks,_lastupdate\n\n\t\tIf _lastupdate+1000 0\n\t\t\t\t\tRepeat\n\t\t\t\t\t\tlink=link._succ\n\t\t\t\t\tUntil link=list._head Or TEntity(link.Value())._order <= entity._order\n\t\t\t\t\tlist.InsertBeforeLink(entity,link)\n\t\t\t\tElseIf entity._order < 0\n\t\t\t\t\tRepeat\n\t\t\t\t\t\tlink=link._pred\n\t\t\t\t\tUntil link=list._head Or TEntity(link.Value())._order >= entity._order\n\t\t\t\t\tlist.InsertAfterLink(entity,link)\t\t\t\t\n\t\t\t\tElse\n\t\t\t\t\tIf entity.HasAlpha()\n\t\t\t\t\t\tentity._alphaorder = camera.GetDistance(entity)\n\t\t\t\t\t\tRepeat\n\t\t\t\t\t\t\tlink=link._pred\n\t\t\t\t\t\t\tIf link=list._head Then Exit\n\t\t\t\t\t\tUntil TEntity(link.Value())._order >= 0 And (TEntity(link.Value())._alphaorder >= entity._alphaorder Or TEntity(link.Value())._alphaorder = 0.0)\n\t\t\t\t\t\tlist.InsertAfterLink(entity,link)\n\t\t\t\t\tElse\n\t\t\t\t\t\tentity._alphaorder = 0\n\t\t\t\t\t\tRepeat\n\t\t\t\t\t\t\tlink=link._succ\n\t\t\t\t\t\tUntil link=list._head Or TEntity(link.Value())._order <= 0\n\t\t\t\t\t\tlist.InsertBeforeLink(entity,link)\n\t\t\t\t\tEndIf\n\t\t\t\tEndIf\t\n\t\t\tEndIf\n\t\tNext\n\t\t\n\t\tUpdateSprites list,driver,camera\n\t\t\n\t\tReturn RenderEntities(list,driver,camera)\t\t\n\tEnd Method\n\n\tMethod Update(speed#)\n\t\t_config.UpdateSpeed = speed#\n\t\tRunHooks _config.UpdateHook, _config\n\t\t_collisiondriver.Update _config,speed\n\t\tFor Local mesh:TMesh=EachIn _config.List[WORLDLIST_MESH]\n\t\t\tLocal animator:TAnimator=mesh._animator\n\t\t\tIf animator=Null Continue\n\t\t\tLocal seq:TAnimSeq=animator._current\n\t\t\tIf seq\n\t\t\t\tIf animator._mode>0\t\t\n\t\t\t\t\tanimator._frame:+(speed*animator._speed)\n\t\t\t\t\tIf animator._frame>seq._end Or animator._frameseq._end animator._frame=seq._start'+(animator._frame-seq._end)\n\t\t\t\t\t\t\tIf animator._frameseq._end animator._frame=seq._end'+(animator._frame-seq._end)\n\t\t\t\t\t\t\tIf animator._frame0))\n\t\t\t\tElseIf terrain\n\t\t\t\t\tLocal x#,y#,z#\n\t\t\t\t\tcamera.GetPosition x,y,z,True\n\t\t\t\t\tterrain.Update x,y,z,camera._frustum.ToPtr()\n\t\t\t\t\tinfo.Triangles:+driver.RenderTerrain(terrain)\n\t\t\t\tElseIf bsp\n\t\t\t\t\tLocal tree:TBSPTree=bsp.GetRenderTree(camera.GetEye())\n\t\t\t\t\tinfo.Triangles:+driver.RenderBSPTree(tree)\n\t\t\t\tElseIf custom\n\t\t\t\t\tinfo.Triangles:+renderer.Render(custom, driver)\n\t\t\t\tEndIf\t\n\t\t\tEndIf\n\t\t\tdriver.EndEntityRender entity\t\t\n\t\tNext\n\t\tReturn info\n\tEnd Method\n\t\n\tMethod UpdateSprites(sprites:TList,driver:TMaxB3DDriver,camera:TCamera)\t\n\t\tFor Local sprite:TSprite=EachIn sprites\n\t\t\tLocal matrix:TMatrix\n\t\t\tIf True\n\t\t\t\tIf sprite._viewmode<>VIEWMODE_FREE\t\t\n\t\t\t\t\tLocal x#,y#,z#\n\t\t\t\t\tsprite.GetPosition x,y,z,True\n\t\t\t\t\n\t\t\t\t\tmatrix = camera.GetMatrix()'.Inverse()\n\t\t\t\t\tmatrix._m[3,0]=x\n\t\t\t\t\tmatrix._m[3,1]=y\n\t\t\t\t\tmatrix._m[3,2]=z\n\t\t\t\t\t\n\t\t\t\t\tmatrix=TMatrix.YawPitchRoll(180,0,sprite._angle).Multiply(matrix)\t\t\t\t\t\n\t\t\t\t\tIf sprite._sx<>1.0 Or sprite._sy<>1.0 matrix=TMatrix.Scale(sprite._sx,sprite._sy,1.0).Multiply(matrix)\t\t\t\t\t\n\t\t\t\t\t'If sprite._handlex<>0.0 Or sprite._handley<>0.0 matrix=TMatrix.Translation(-sprite._handlex,-sprite._handley,0.0).Multiply(matrix)\n\t\t\t\tElse\t\t\t\t\n\t\t\t\t\tmatrix = sprite.GetMatrix()\t\t\t\t\t\n\t\t\t\t\t'If sprite.scale_x#<>1.0 Or sprite.scale_y#<>1.0\n\t\t\t\t\t'\tsprite.mat_sp.Scale(sprite.scale_x#,sprite.scale_y#,1.0)\n\t\t\t\t\t'EndIf\t\t\n\t\t\t\tEndIf\n\t\t\tElse\n\t\t\t\tmatrix=sprite._matrix\n\t\t\tEndIf\n\t\t\tsprite._view_matrix=matrix\t\n\t\tNext\n\tEnd Method\n\t\n\tMethod SetLighting(driver:TMaxB3DDriver,camera:TCamera)\n\t\tLocal index\n\t\tFor Local i=0 To 7\n\t\t\tLocal light:TLight\n\t\t\tIf index=CountList(_config.List[WORLDLIST_LIGHT])\n\t\t\tEndIf\n\t\t\tdriver.SetLight light,i\n\t\tNext\n\tEnd Method\nEnd Type\n\nType TRenderInfo\n\tField FPS\n\tField Triangles\n\tField Entities\nEnd Type\n\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"4f594071385d4947c617c68d666c99e58d53b7ae","subject":"Sanity check (and because options might take arguments in the future).","message":"Sanity check (and because options might take arguments in the future).\n","repos":"maximos\/maximus","old_file":"maximus.bmx","new_file":"maximus.bmx","new_contents":"\nRem\nCopyright (c) 2010 Tim Howard\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and\/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\nEnd Rem\n\nSuperStrict\n\nFramework brl.blitz\nImport brl.standardio\nImport brl.maxutil\n\nImport cower.jonk\n\nImport duct.variables\nImport duct.objectmap\nImport duct.json\n\nInclude \"src\/logger.bmx\"\nInclude \"src\/errors.bmx\"\nInclude \"src\/arghandler.bmx\"\nInclude \"src\/impl\/help.bmx\"\nInclude \"src\/impl\/update.bmx\"\nInclude \"src\/impl\/version.bmx\"\nInclude \"src\/dependencies.bmx\"\nInclude \"src\/module.bmx\"\nInclude \"src\/sources.bmx\"\n\nGlobal logger:mxLogger = New mxLogger\nGlobal mainapp:mxApp\nNew mxApp.Create(AppArgs[1..]) ' Skip the first element because it is the program's location\nmainapp.Run()\n\nRem\n\tbbdoc: Maximus app.\n\tabout: This handles the basic flow of the program (initiation, parsing, command calling, exiting..)\nEnd Rem\nType mxApp\n\t\n\tConst c_version:String = \"0.01\"\n\t\n\tField m_maxpath:String\n\t\n\tField m_args:String[]\n\tField m_arghandler:mxArgumentHandler\n\t\n\tRem\n\t\tbbdoc: Create a new mxApp.\n\t\treturns: The new mxApp.\n\tEnd Rem\n\tMethod Create:mxApp(args:String[])\n\t\tmainapp = Self\n\t\tSetArgs(args)\n\t\tOnInit()\n\t\tReturn Self\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Called when the application is created.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod OnInit()\n\t\tTry\n\t\t\tm_maxpath = BlitzMaxPath()\n\t\tCatch e:Object\n\t\t\tThrowError(\"Unable to determine the path to BlitzMax!~nHave you set the 'BMXPATH' environment variable?\")\n\t\tEnd Try\n\t\tm_arghandler = New mxArgumentHandler\n\t\tm_arghandler.AddArgImpl(New mxHelpImpl)\n\t\tm_arghandler.AddArgImpl(New mxVersionImpl)\n\t\tm_arghandler.AddArgImpl(New mxUpdateImpl)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Called when the application is ended (this includes #ThrowError calls).\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod OnExit()\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Run the application.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod Run()\n\t\tLocal argimpl:mxArgumentImplementation\n\t\tLocal i:Int, arg:String, isopt:Int\n\t\tFor i = 0 To m_args.Length - 1\n\t\t\targ = m_args[i]\n\t\t\targimpl = m_arghandler.GetArgImplFromAlias(arg)\n\t\t\tisopt = arg.StartsWith(\"-\")\n\t\t\tIf argimpl <> Null\n\t\t\t\tIf isopt = True\n\t\t\t\t\targimpl.SetArgs(Null)\n\t\t\t\t\targimpl.SetCallConvention(mxCallConvention.OPTION)\n\t\t\t\t\targimpl.CheckArgs()\n\t\t\t\t\targimpl.Execute()\n\t\t\t\tElse ' Must be a command (leaving out parameters for options, as that would get really complicated)\n\t\t\t\t\targimpl.SetCallConvention(mxCallConvention.COMMAND)\n\t\t\t\t\tParseCommandArgs(argimpl, m_args[i + 1..])\n\t\t\t\t\targimpl.Execute()\n\t\t\t\t\tExit ' Commands take all the subsequent arguments\n\t\t\t\tEnd If\n\t\t\tElse\n\t\t\t\tIf isopt = True\n\t\t\t\t\tThrowCommonError(mxOptErrors.UNKNOWN, arg)\n\t\t\t\tElse\n\t\t\t\t\tThrowCommonError(mxCmdErrors.UNKNOWN, arg)\n\t\t\t\tEnd If\n\t\t\tEnd If\n\t\tNext\n\t\tOnExit()\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Parse command arguments.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod ParseCommandArgs(argimpl:mxArgumentImplementation, args:String[])\n\t\t' This will need to be parsed eventually, but for now..\n\t\targimpl.SetArgs(args)\n\t\targimpl.CheckArgs()\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the application's arguments.\n\t\treturns: Nothing.\n\t\tabout: NOTE: This will resolve to '--help' if the given args are Null.\n\tEnd Rem\n\tMethod SetArgs(args:String[])\n\t\tIf args = Null\n\t\t\targs = [\"--help\"]\n\t\tEnd If\n\t\tm_args = args\n\tEnd Method\n\t\nEnd Type\n\nRem\n\tbbdoc: Throw an error (terminating the application).\n\treturns: Nothing.\nEnd Rem\nFunction ThrowError(error:String)\n\tlogger.LogError(error)\n\tmainapp.OnExit()\n\tEnd\nEnd Function\n\n","old_contents":"\nRem\nCopyright (c) 2010 Tim Howard\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and\/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\nEnd Rem\n\nSuperStrict\n\nFramework brl.blitz\nImport brl.standardio\nImport brl.maxutil\n\nImport cower.jonk\n\nImport duct.variables\nImport duct.objectmap\nImport duct.json\n\nInclude \"src\/logger.bmx\"\nInclude \"src\/errors.bmx\"\nInclude \"src\/arghandler.bmx\"\nInclude \"src\/impl\/help.bmx\"\nInclude \"src\/impl\/update.bmx\"\nInclude \"src\/impl\/version.bmx\"\nInclude \"src\/dependencies.bmx\"\nInclude \"src\/module.bmx\"\nInclude \"src\/sources.bmx\"\n\nGlobal logger:mxLogger = New mxLogger\nGlobal mainapp:mxApp\nNew mxApp.Create(AppArgs[1..]) ' Skip the first element because it is the program's location\nmainapp.Run()\n\nRem\n\tbbdoc: Maximus app.\n\tabout: This handles the basic flow of the program (initiation, parsing, command calling, exiting..)\nEnd Rem\nType mxApp\n\t\n\tConst c_version:String = \"0.01\"\n\t\n\tField m_maxpath:String\n\t\n\tField m_args:String[]\n\tField m_arghandler:mxArgumentHandler\n\t\n\tRem\n\t\tbbdoc: Create a new mxApp.\n\t\treturns: The new mxApp.\n\tEnd Rem\n\tMethod Create:mxApp(args:String[])\n\t\tmainapp = Self\n\t\tSetArgs(args)\n\t\tOnInit()\n\t\tReturn Self\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Called when the application is created.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod OnInit()\n\t\tTry\n\t\t\tm_maxpath = BlitzMaxPath()\n\t\tCatch e:Object\n\t\t\tThrowError(\"Unable to determine the path to BlitzMax!~nHave you set the 'BMXPATH' environment variable?\")\n\t\tEnd Try\n\t\tm_arghandler = New mxArgumentHandler\n\t\tm_arghandler.AddArgImpl(New mxHelpImpl)\n\t\tm_arghandler.AddArgImpl(New mxVersionImpl)\n\t\tm_arghandler.AddArgImpl(New mxUpdateImpl)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Called when the application is ended (this includes #ThrowError calls).\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod OnExit()\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Run the application.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod Run()\n\t\tLocal argimpl:mxArgumentImplementation\n\t\tLocal i:Int, arg:String, isopt:Int\n\t\tFor i = 0 To m_args.Length - 1\n\t\t\targ = m_args[i]\n\t\t\targimpl = m_arghandler.GetArgImplFromAlias(arg)\n\t\t\tisopt = arg.StartsWith(\"-\")\n\t\t\tIf argimpl <> Null\n\t\t\t\tIf isopt = True\n\t\t\t\t\targimpl.SetArgs(Null)\n\t\t\t\t\targimpl.SetCallConvention(mxCallConvention.OPTION)\n\t\t\t\t\targimpl.Execute()\n\t\t\t\tElse ' Must be a command (leaving out parameters for options, as that would get really complicated)\n\t\t\t\t\targimpl.SetCallConvention(mxCallConvention.COMMAND)\n\t\t\t\t\tParseCommandArgs(argimpl, m_args[i + 1..])\n\t\t\t\t\targimpl.Execute()\n\t\t\t\t\tExit ' Commands take all the subsequent arguments\n\t\t\t\tEnd If\n\t\t\tElse\n\t\t\t\tIf isopt = True\n\t\t\t\t\tThrowCommonError(mxOptErrors.UNKNOWN, arg)\n\t\t\t\tElse\n\t\t\t\t\tThrowCommonError(mxCmdErrors.UNKNOWN, arg)\n\t\t\t\tEnd If\n\t\t\tEnd If\n\t\tNext\n\t\tOnExit()\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Parse command arguments.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod ParseCommandArgs(argimpl:mxArgumentImplementation, args:String[])\n\t\t' This will need to be parsed eventually, but for now..\n\t\targimpl.SetArgs(args)\n\t\targimpl.CheckArgs()\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the application's arguments.\n\t\treturns: Nothing.\n\t\tabout: NOTE: This will resolve to '--help' if the given args are Null.\n\tEnd Rem\n\tMethod SetArgs(args:String[])\n\t\tIf args = Null\n\t\t\targs = [\"--help\"]\n\t\tEnd If\n\t\tm_args = args\n\tEnd Method\n\t\nEnd Type\n\nRem\n\tbbdoc: Throw an error (terminating the application).\n\treturns: Nothing.\nEnd Rem\nFunction ThrowError(error:String)\n\tlogger.LogError(error)\n\tmainapp.OnExit()\n\tEnd\nEnd Function\n\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"b1031dbd2ffbbdc68f63358c5266c40349ba8814","subject":"Added Karja's SetMatrix code for MonkeyMax.","message":"Added Karja's SetMatrix code for MonkeyMax.\n","repos":"swoolcock\/diddy,swoolcock\/diddy,swoolcock\/diddy,swoolcock\/diddy,swoolcock\/diddy","old_file":"monkeymax\/modules\/mojo\/native\/mojo.bmax.bmx","new_file":"monkeymax\/modules\/mojo\/native\/mojo.bmax.bmx","new_contents":"' ***** Start mojo.bmax.bmx ******\r\n\r\nGlobal app:gxtkApp;\r\n\r\nType gxtkApp\r\n\tField ginput:gxtkInput;\r\n\tField gaudio:gxtkAudio;\r\n\tField ggraphics:gxtkGraphics;\r\n\r\n\tField dead:int=0;\r\n\tField suspended:int=0;\r\n\tField vloading:int=0;\r\n\tField maxloading:int=0;\r\n\tField updateRate:int=0;\r\n\tField nextUpdate:Float=0;\r\n\tField updatePeriod:Float=0;\r\n\tField startMillis:Float=0;\r\n\t\r\n\tMethod New()' gxtkApp()\r\n\t\tapp=self;\r\n\t\tggraphics=new gxtkGraphics;\r\n\tEndMethod\r\n\t\r\n\tMethod Setup()\r\n\t\t\r\n\t\tginput=new gxtkInput;\r\n\t\tgaudio=new gxtkAudio;\r\n\r\n\t\tbb_input_SetInputDevice(ginput);\r\n\t\tbb_audio_SetAudioDevice(gaudio);\r\n\t\t\r\n\t\tstartMillis=BlitzMaxMillisecs()\r\n\t\t\r\n\t\t'game.stage.addEventListener( Event.ENTER_FRAME,OnEnterFrame );\r\n\t\t\r\n\t\tSetFrameRate( 0 );\r\n\t\t\r\n\t\tInvokeOnCreate();\r\n\t\tInvokeOnRender();\r\n\t\tUpdate()\r\n\tEndMethod\r\n\t\r\n\tMethod Update()\r\n\t\tWhile Not AppTerminate()\r\n\t\t\tlocal updates:Int = 0\r\n\t\t\t\r\n\t\t\tlocal cont:int = 1\r\n\t\t\tWhile (cont)\r\n\t\t\t\tnextUpdate:+updatePeriod\r\n\t\t\t\tInvokeOnUpdate()\r\n\t\t\t\tif not updatePeriod then cont = 0\r\n\t\t\t\tif nextUpdate>BlitzMaxMillisecs() then cont = 0\r\n\t\t\t\tupdates:+1\r\n\t\t\t\tif updates = 7 then\r\n\t\t\t\t\tnextUpdate = BlitzMaxMillisecs()\r\n\t\t\t\t\tcont = 0\r\n\t\t\t\tendif\r\n\t\t\tWend\r\n\t\t\tInvokeOnRender()\r\n\t\tWend\r\n\tEndMethod\r\n\t\r\n\tMethod InvokeOnCreate()\r\n\t\tif dead return\r\n\t\tdead = 1\r\n\t\tOnCreate()\r\n\t\tdead = 0\r\n\tEndMethod\r\n\r\n\tMethod InvokeOnUpdate()\r\n\t\tif dead or suspended or not updateRate or vloading return\r\n\t\tOnUpdate()\r\n\tEndMethod\r\n\t\r\n\tMethod InvokeOnRender()\r\n\t\tif dead or suspended return\r\n\t\tggraphics.BeginRender()\r\n\t\tif vloading\r\n\t\t\tOnLoading()\r\n\t\telse\r\n\t\t\tOnRender()\r\n\t\tEndif\r\n\t\tggraphics.EndRender()\r\n\tEndMethod\r\n\t\r\n\t\r\n\tMethod SetFrameRate( fps:int )\r\n\t\tif fps\r\n\t\t\tupdatePeriod=1000.0\/fps;\r\n\t\t\tnextUpdate=BlitzMaxMillisecs() +updatePeriod;\r\n\t\telse\r\n\t\t\tupdatePeriod=0\r\n\t\tendif\r\n\tEndMethod\r\n\t\r\n\tMethod LoadString:String( path:String )\r\n\t\tpath = \"data\/\" + path;\r\n\t\tReturn LoadText( path )\r\n\tEndMethod\r\n\t\r\n\t' ***** GXTK API *****\r\n\t\r\n\tMethod GraphicsDevice:gxtkGraphics()\r\n\t\tReturn ggraphics\r\n\tEndMethod\r\n\r\n\tMethod InputDevice:gxtkInput()\r\n\t\tReturn ginput\r\n\tEndMethod\r\n\r\n\tMethod AudioDevice:gxtkAudio()\r\n\t\tReturn gaudio\r\n\tEndMethod\r\n\r\n\tMethod SetUpdateRate:int(hertz:int)\r\n\t\tupdateRate = hertz\r\n\t\tif not vloading then SetFrameRate(updateRate)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod MilliSecs:Int()\r\n\t\treturn BlitzMaxMillisecs() - startMillis\r\n\tEndMethod\r\n\t\r\n\tMethod Loading:int()\r\n\t\treturn vloading;\r\n\tEndMethod\r\n\r\n\tMethod OnCreate:int()\r\n\t\treturn 0;\r\n\tEndMethod\r\n\r\n\tMethod OnUpdate:int()\r\n\t\treturn 0;\r\n\tEndMethod\r\n\t\r\n\tMethod OnSuspend:int()\r\n\t\treturn 0;\r\n\tEndMethod\r\n\t\r\n\tMethod OnResume:int()\r\n\t\treturn 0;\r\n\tEndMethod\r\n\t\r\n\tMethod OnRender:int()\r\n\t\treturn 0;\r\n\tEndMethod\r\n\t\r\n\tMethod OnLoading:int()\r\n\t\treturn 0;\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkGraphics\r\n\tField gmode:Int = 1\r\n\r\n\tMethod Mode:Int()\r\n\t\treturn gmode\r\n\tEndMethod\r\n\t\r\n\tMethod Cls:Int(r:int = 0, g:int = 0, b:int = 0)\r\n\t\tBlitzMaxCls(r, g, b)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod LoadSurface:gxtkSurface(path:String)\r\n\t\tlocal image:TImage = LoadImage(\"data\/\"+path)\r\n\t\tif image then\r\n\t\t\tlocal gs:gxtkSurface = new gxtkSurface\r\n\t\t\tgs.setImage(image)\r\n\t\t\treturn gs\r\n\t\tendif\r\n\t\treturn null\r\n\tEndMethod\r\n\t\r\n\tMethod BeginRender()\r\n\tEndMethod\r\n\t\r\n\tMethod EndRender()\r\n\t\tFlip\r\n\tEndMethod\r\n\t\r\n\tMethod SetColor:Int(r:Int, g:Int, b:Int)\r\n\t\tBlitzMaxSetColor(r, g, b)\r\n\t\treturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod SetAlpha:Int(a:Float)\r\n\t\tBlitzMaxSetAlpha(a)\r\n\t\treturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod SetBlend:Int(blend:Int)\r\n\t\tBlitzMaxSetBlend(blend)\r\n\t\treturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod Width:Int()\r\n\t\t'TO-DO\r\n\t\tReturn 800\r\n\tEndMethod\r\n\t\r\n\tMethod Height:Int()\r\n\t\t'TO-DO\r\n\t\tReturn 600\r\n\tEndMethod\r\n\t\r\n\tMethod SetScissor:Int(x:int, y:int, w:int, h:int)\r\n 'TO-DO\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod SetMatrix:Int(ix:float,iy:float,jx:float,jy:float,tx:float,ty:float)\r\n\t\tLocal sx:Float = Sqr( (ix*ix) + (jx*jx) )\r\n\t\tLocal sy:Float = Sqr( (iy*iy) + (jy*jy) )\r\n\t\tLocal rot:Float = Atan2( jx, ix )\r\n\t\tSetTransform( rot, sx, sy )\r\n\t\tSetOrigin( tx, ty )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawSurface:Int(surface:gxtkSurface,x:Float,y:Float)\r\n\t\tDrawImage(surface.image, x, y, 0)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawSurface2:Int(surface:gxtkSurface,x:Float,y:Float, srcx:int, srcy:int, srcw:int, srch:int )\r\n\r\n\t'\tPrint \"x = \"+x\r\n\t'\tPrint \"y = \"+y\r\n\t'\tPrint \"srcx = \"+srcx\r\n\t'\tPrint \"srcy = \"+srcy\r\n\t'\tPrint \"srcw = \"+srcw\r\n\t'\tPrint \"srch = \"+srch\r\n\t\tDrawSubImageRect(surface.image, x, y, srcw, srch, srcx, srcy, srcw, srch)\r\n\t\t\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawLine:Int( x1:Float,y1:Float,x2:Float,y2:Float )\r\n\t\tBlitzMaxDrawLine(x1, y1, x2, y2)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawOval:Int( x:Float, y:Float, w:Float, h:Float )\r\n\t\tBlitzMaxDrawOval(x, y, w, h)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawPoly:Int(vertices:Float[])\r\n\t\tBlitzMaxDrawPoly( vertices )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawRect:Int( x:Float, y:Float, w:Float, h:Float )\r\n\t\tBlitzMaxDrawRect(x, y, w, h)\r\n\t\tReturn 0\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkInput\r\n\tMethod MouseX:Float()\r\n\t\treturn 0\r\n\tEndMethod\r\n\r\n\tMethod MouseY:Float()\r\n\t\treturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod KeyDown:Int( key:Int )\r\n\t\treturn BRL.PolledInput.KeyDown( key )\r\n\tEndMethod\r\n\r\n\tMethod KeyHit:Int( key:Int )\r\n\t\treturn BRL.PolledInput.KeyHit( key )\r\n\tEndMethod\r\n\r\n\tMethod GetChar:Int()\r\n\t\treturn BRL.PolledInput.GetChar()\r\n\tEndMethod\r\n\r\n\tMethod JoyX:Int( index:Int )\r\n\t\treturn Pub.FreeJoy.JoyX( index )\r\n\tEndMethod\r\n\r\n\tMethod JoyY:Int( index:Int )\r\n\t\treturn Pub.FreeJoy.JoyY( index )\r\n\tEndMethod\r\n\r\n\tMethod JoyZ:Int( index:Int )\r\n\t\treturn Pub.FreeJoy.JoyZ( index )\r\n\tEndMethod\r\n\r\n\tMethod TouchX:Float( index:Int )\r\n\t\treturn 0\r\n\tEndMethod\r\n\r\n\tMethod TouchY:Float( index:Int )\r\n\t\treturn 0\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkAudio\r\n\tField amusicState:Int = 0;\r\n\r\n\tMethod MusicState:Int()\r\n'\t\tIf( musicState = 1 And music.isPlaying() = False )\r\n'\t\t\tmusicState = 0;\r\n'\t\tEndif\r\n\t\treturn amusicState;\r\n\tEndMethod\r\n\t\r\n\tMethod PlayMusic:Int( path:String, flags:int )\r\n\t\treturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod StopMusic()\r\n\tEndMethod\r\n\t\r\n\tMethod StopChannel( channel:Int )\r\n\tEndMethod\r\n\r\n\tMethod PlaySample( sound:gxtkSample, channel:Int, flags:Int )\r\n\tEndMethod\r\n\r\n\tMethod SetPan( channel:Int, pan:Float )\r\n\tEndMethod\r\n\r\n\tMethod SetRate( channel:Int, rate:Float )\r\n\tEndMethod\r\n\r\n\tMethod SetMusicVolume:Int( volume:Float )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod SetVolume:Int( channel:Int, volume:Float )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod LoadSample:gxtkSample( path:String )\r\n\t\tReturn Null\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkSample\r\n\tMethod Discard()\r\n\tEndMethod\r\nEndType\r\n\r\nFunction BlitzMaxDrawPoly:Int(vertices:Float[])\r\n\tDrawPoly vertices\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxDrawRect:Int( x:Float, y:Float, w:Float, h:Float )\r\n\tDrawRect x, y, w, h\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxDrawOval:Int( x:Float, y:Float, w:Float, h:Float )\r\n\tDrawOval x, y, w, h\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxDrawLine:Int( x1:Float,y1:Float,x2:Float,y2:Float )\r\n\tDrawLine x1, y1, x2, y2\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxMillisecs:Int()\r\n\treturn MilliSecs()\r\nEndFunction\r\n\r\nFunction BlitzMaxSetColor(r:Int, g:Int, b:Int)\r\n\tSetColor(r, g, b)\r\nEndFunction\r\n\r\nFunction BlitzMaxSetBlend(blend:Int)\r\n\tSetBlend(blend)\r\nEndFunction\r\n\r\nFunction BlitzMaxSetAlpha(a:Float)\r\n\tSetAlpha(a)\r\nEndFunction\r\n\r\nFunction BlitzMaxCls(r:Int = 0, g:Int = 0, b:Int = 0)\r\n\tSetClsColor(r, g, b)\r\n\tCls\r\nEndFunction\r\n\r\nType gxtkSurface\r\n\tField w:Int, h:Int\r\n\tField image:TImage\r\n\t\r\n\tMethod setImage(image:TImage)\r\n\t\tself.image = image\r\n\tEndMethod\r\n\t\r\n\tMethod Width:Int()\r\n\t\treturn image.Width\r\n\tEndMethod\r\n\t\r\n\tMethod Height:Int()\r\n\t\treturn image.Height\r\n\tEndMethod\r\n\t\r\n\tMethod Discard()\r\n\tEndMethod\r\nEndType\r\n\r\n' ***** End mojo.bmax.bmx ******\r\n\r\n","old_contents":"' ***** Start mojo.bmax.bmx ******\r\n\r\nGlobal app:gxtkApp;\r\n\r\nType gxtkApp\r\n\tField ginput:gxtkInput;\r\n\tField gaudio:gxtkAudio;\r\n\tField ggraphics:gxtkGraphics;\r\n\r\n\tField dead:int=0;\r\n\tField suspended:int=0;\r\n\tField vloading:int=0;\r\n\tField maxloading:int=0;\r\n\tField updateRate:int=0;\r\n\tField nextUpdate:Float=0;\r\n\tField updatePeriod:Float=0;\r\n\tField startMillis:Float=0;\r\n\t\r\n\tMethod New()' gxtkApp()\r\n\t\tapp=self;\r\n\t\tggraphics=new gxtkGraphics;\r\n\tEndMethod\r\n\t\r\n\tMethod Setup()\r\n\t\t\r\n\t\tginput=new gxtkInput;\r\n\t\tgaudio=new gxtkAudio;\r\n\r\n\t\tbb_input_SetInputDevice(ginput);\r\n\t\tbb_audio_SetAudioDevice(gaudio);\r\n\t\t\r\n\t\tstartMillis=BlitzMaxMillisecs()\r\n\t\t\r\n\t\t'game.stage.addEventListener( Event.ENTER_FRAME,OnEnterFrame );\r\n\t\t\r\n\t\tSetFrameRate( 0 );\r\n\t\t\r\n\t\tInvokeOnCreate();\r\n\t\tInvokeOnRender();\r\n\t\tUpdate()\r\n\tEndMethod\r\n\t\r\n\tMethod Update()\r\n\t\tWhile Not AppTerminate()\r\n\t\t\tlocal updates:Int = 0\r\n\t\t\t\r\n\t\t\tlocal cont:int = 1\r\n\t\t\tWhile (cont)\r\n\t\t\t\tnextUpdate:+updatePeriod\r\n\t\t\t\tInvokeOnUpdate()\r\n\t\t\t\tif not updatePeriod then cont = 0\r\n\t\t\t\tif nextUpdate>BlitzMaxMillisecs() then cont = 0\r\n\t\t\t\tupdates:+1\r\n\t\t\t\tif updates = 7 then\r\n\t\t\t\t\tnextUpdate = BlitzMaxMillisecs()\r\n\t\t\t\t\tcont = 0\r\n\t\t\t\tendif\r\n\t\t\tWend\r\n\t\t\tInvokeOnRender()\r\n\t\tWend\r\n\tEndMethod\r\n\t\r\n\tMethod InvokeOnCreate()\r\n\t\tif dead return\r\n\t\tdead = 1\r\n\t\tOnCreate()\r\n\t\tdead = 0\r\n\tEndMethod\r\n\r\n\tMethod InvokeOnUpdate()\r\n\t\tif dead or suspended or not updateRate or vloading return\r\n\t\tOnUpdate()\r\n\tEndMethod\r\n\t\r\n\tMethod InvokeOnRender()\r\n\t\tif dead or suspended return\r\n\t\tggraphics.BeginRender()\r\n\t\tif vloading\r\n\t\t\tOnLoading()\r\n\t\telse\r\n\t\t\tOnRender()\r\n\t\tEndif\r\n\t\tggraphics.EndRender()\r\n\tEndMethod\r\n\t\r\n\t\r\n\tMethod SetFrameRate( fps:int )\r\n\t\tif fps\r\n\t\t\tupdatePeriod=1000.0\/fps;\r\n\t\t\tnextUpdate=BlitzMaxMillisecs() +updatePeriod;\r\n\t\telse\r\n\t\t\tupdatePeriod=0\r\n\t\tendif\r\n\tEndMethod\r\n\t\r\n\tMethod LoadString:String( path:String )\r\n\t\tpath = \"data\/\" + path;\r\n\t\tReturn LoadText( path )\r\n\tEndMethod\r\n\t\r\n\t' ***** GXTK API *****\r\n\t\r\n\tMethod GraphicsDevice:gxtkGraphics()\r\n\t\tReturn ggraphics\r\n\tEndMethod\r\n\r\n\tMethod InputDevice:gxtkInput()\r\n\t\tReturn ginput\r\n\tEndMethod\r\n\r\n\tMethod AudioDevice:gxtkAudio()\r\n\t\tReturn gaudio\r\n\tEndMethod\r\n\r\n\tMethod SetUpdateRate:int(hertz:int)\r\n\t\tupdateRate = hertz\r\n\t\tif not vloading then SetFrameRate(updateRate)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod MilliSecs:Int()\r\n\t\treturn BlitzMaxMillisecs() - startMillis\r\n\tEndMethod\r\n\t\r\n\tMethod Loading:int()\r\n\t\treturn vloading;\r\n\tEndMethod\r\n\r\n\tMethod OnCreate:int()\r\n\t\treturn 0;\r\n\tEndMethod\r\n\r\n\tMethod OnUpdate:int()\r\n\t\treturn 0;\r\n\tEndMethod\r\n\t\r\n\tMethod OnSuspend:int()\r\n\t\treturn 0;\r\n\tEndMethod\r\n\t\r\n\tMethod OnResume:int()\r\n\t\treturn 0;\r\n\tEndMethod\r\n\t\r\n\tMethod OnRender:int()\r\n\t\treturn 0;\r\n\tEndMethod\r\n\t\r\n\tMethod OnLoading:int()\r\n\t\treturn 0;\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkGraphics\r\n\tField gmode:Int = 1\r\n\r\n\tMethod Mode:Int()\r\n\t\treturn gmode\r\n\tEndMethod\r\n\t\r\n\tMethod Cls:Int(r:int = 0, g:int = 0, b:int = 0)\r\n\t\tBlitzMaxCls(r, g, b)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod LoadSurface:gxtkSurface(path:String)\r\n\t\tlocal image:TImage = LoadImage(\"data\/\"+path)\r\n\t\tif image then\r\n\t\t\tlocal gs:gxtkSurface = new gxtkSurface\r\n\t\t\tgs.setImage(image)\r\n\t\t\treturn gs\r\n\t\tendif\r\n\t\treturn null\r\n\tEndMethod\r\n\t\r\n\tMethod BeginRender()\r\n\tEndMethod\r\n\t\r\n\tMethod EndRender()\r\n\t\tFlip\r\n\tEndMethod\r\n\t\r\n\tMethod SetColor:Int(r:Int, g:Int, b:Int)\r\n\t\tBlitzMaxSetColor(r, g, b)\r\n\t\treturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod SetAlpha:Int(a:Float)\r\n\t\tBlitzMaxSetAlpha(a)\r\n\t\treturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod SetBlend:Int(blend:Int)\r\n\t\tBlitzMaxSetBlend(blend)\r\n\t\treturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod Width:Int()\r\n\t\t'TO-DO\r\n\t\tReturn 800\r\n\tEndMethod\r\n\t\r\n\tMethod Height:Int()\r\n\t\t'TO-DO\r\n\t\tReturn 600\r\n\tEndMethod\r\n\t\r\n\tMethod SetScissor:Int(x:int, y:int, w:int, h:int)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod SetMatrix:Int(x:float,iy:float,jx:float,jy:float,tx:float,ty:float)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawSurface:Int(surface:gxtkSurface,x:Float,y:Float)\r\n\t\tDrawImage(surface.image, x, y, 0)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawSurface2:Int(surface:gxtkSurface,x:Float,y:Float, srcx:int, srcy:int, srcw:int, srch:int )\r\n\r\n\t'\tPrint \"x = \"+x\r\n\t'\tPrint \"y = \"+y\r\n\t'\tPrint \"srcx = \"+srcx\r\n\t'\tPrint \"srcy = \"+srcy\r\n\t'\tPrint \"srcw = \"+srcw\r\n\t'\tPrint \"srch = \"+srch\r\n\t\tDrawSubImageRect(surface.image, x, y, srcw, srch, srcx, srcy, srcw, srch)\r\n\t\t\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawLine:Int( x1:Float,y1:Float,x2:Float,y2:Float )\r\n\t\tBlitzMaxDrawLine(x1, y1, x2, y2)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawOval:Int( x:Float, y:Float, w:Float, h:Float )\r\n\t\tBlitzMaxDrawOval(x, y, w, h)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawPoly:Int(vertices:Float[])\r\n\t\tBlitzMaxDrawPoly( vertices )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawRect:Int( x:Float, y:Float, w:Float, h:Float )\r\n\t\tBlitzMaxDrawRect(x, y, w, h)\r\n\t\tReturn 0\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkInput\r\n\tMethod MouseX:Float()\r\n\t\treturn 0\r\n\tEndMethod\r\n\r\n\tMethod MouseY:Float()\r\n\t\treturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod KeyDown:Int( key:Int )\r\n\t\treturn BRL.PolledInput.KeyDown( key )\r\n\tEndMethod\r\n\r\n\tMethod KeyHit:Int( key:Int )\r\n\t\treturn BRL.PolledInput.KeyHit( key )\r\n\tEndMethod\r\n\r\n\tMethod GetChar:Int()\r\n\t\treturn BRL.PolledInput.GetChar()\r\n\tEndMethod\r\n\r\n\tMethod JoyX:Int( index:Int )\r\n\t\treturn Pub.FreeJoy.JoyX( index )\r\n\tEndMethod\r\n\r\n\tMethod JoyY:Int( index:Int )\r\n\t\treturn Pub.FreeJoy.JoyY( index )\r\n\tEndMethod\r\n\r\n\tMethod JoyZ:Int( index:Int )\r\n\t\treturn Pub.FreeJoy.JoyZ( index )\r\n\tEndMethod\r\n\r\n\tMethod TouchX:Float( index:Int )\r\n\t\treturn 0\r\n\tEndMethod\r\n\r\n\tMethod TouchY:Float( index:Int )\r\n\t\treturn 0\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkAudio\r\n\tField amusicState:Int = 0;\r\n\r\n\tMethod MusicState:Int()\r\n'\t\tIf( musicState = 1 And music.isPlaying() = False )\r\n'\t\t\tmusicState = 0;\r\n'\t\tEndif\r\n\t\treturn amusicState;\r\n\tEndMethod\r\n\t\r\n\tMethod PlayMusic:Int( path:String, flags:int )\r\n\t\treturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod StopMusic()\r\n\tEndMethod\r\n\t\r\n\tMethod StopChannel( channel:Int )\r\n\tEndMethod\r\n\r\n\tMethod PlaySample( sound:gxtkSample, channel:Int, flags:Int )\r\n\tEndMethod\r\n\r\n\tMethod SetPan( channel:Int, pan:Float )\r\n\tEndMethod\r\n\r\n\tMethod SetRate( channel:Int, rate:Float )\r\n\tEndMethod\r\n\r\n\tMethod SetMusicVolume:Int( volume:Float )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod SetVolume:Int( channel:Int, volume:Float )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod LoadSample:gxtkSample( path:String )\r\n\t\tReturn Null\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkSample\r\n\tMethod Discard()\r\n\tEndMethod\r\nEndType\r\n\r\nFunction BlitzMaxDrawPoly:Int(vertices:Float[])\r\n\tDrawPoly vertices\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxDrawRect:Int( x:Float, y:Float, w:Float, h:Float )\r\n\tDrawRect x, y, w, h\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxDrawOval:Int( x:Float, y:Float, w:Float, h:Float )\r\n\tDrawOval x, y, w, h\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxDrawLine:Int( x1:Float,y1:Float,x2:Float,y2:Float )\r\n\tDrawLine x1, y1, x2, y2\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxMillisecs:Int()\r\n\treturn MilliSecs()\r\nEndFunction\r\n\r\nFunction BlitzMaxSetColor(r:Int, g:Int, b:Int)\r\n\tSetColor(r, g, b)\r\nEndFunction\r\n\r\nFunction BlitzMaxSetBlend(blend:Int)\r\n\tSetBlend(blend)\r\nEndFunction\r\n\r\nFunction BlitzMaxSetAlpha(a:Float)\r\n\tSetAlpha(a)\r\nEndFunction\r\n\r\nFunction BlitzMaxCls(r:Int = 0, g:Int = 0, b:Int = 0)\r\n\tSetClsColor(r, g, b)\r\n\tCls\r\nEndFunction\r\n\r\nType gxtkSurface\r\n\tField w:Int, h:Int\r\n\tField image:TImage\r\n\t\r\n\tMethod setImage(image:TImage)\r\n\t\tself.image = image\r\n\tEndMethod\r\n\t\r\n\tMethod Width:Int()\r\n\t\treturn image.Width\r\n\tEndMethod\r\n\t\r\n\tMethod Height:Int()\r\n\t\treturn image.Height\r\n\tEndMethod\r\n\t\r\n\tMethod Discard()\r\n\tEndMethod\r\nEndType\r\n\r\n' ***** End mojo.bmax.bmx ******\r\n\r\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"2caabc5afa3d8ae8725bd743c9ad7f70d5773d3e","subject":"Added SetViewPort, Width and Height contents to MonkeyMax","message":"Added SetViewPort, Width and Height contents to MonkeyMax\n\n--HG--\nextra : convert_revision : svn%3Ae934d3cd-0d57-f34a-94d0-9e8d31ae1c29\/trunk%40351\n","repos":"programmerby\/diddy-mirror,programmerby\/diddy-mirror,programmerby\/diddy-mirror,programmerby\/diddy-mirror","old_file":"monkeymax\/modules\/mojo\/native\/mojo.bmax.bmx","new_file":"monkeymax\/modules\/mojo\/native\/mojo.bmax.bmx","new_contents":"' ***** Start mojo.bmax.bmx ******\r\n\r\nGlobal app:gxtkApp;\r\n\r\nType gxtkApp\r\n\tField ginput:gxtkInput;\r\n\tField gaudio:gxtkAudio;\r\n\tField ggraphics:gxtkGraphics;\r\n\r\n\tField dead:Int=0;\r\n\tField suspended:Int=0;\r\n\tField vloading:Int=0;\r\n\tField maxloading:Int=0;\r\n\tField updateRate:Int=0;\r\n\tField nextUpdate:Float=0;\r\n\tField updatePeriod:Float=0;\r\n\tField startMillis:Float=0;\r\n\t\r\n\tMethod New()' gxtkApp()\r\n\t\tapp=Self;\r\n\t\tggraphics=New gxtkGraphics;\r\n\tEndMethod\r\n\t\r\n\tMethod Setup()\r\n\t\tginput=New gxtkInput;\r\n\t\tgaudio=New gxtkAudio;\r\n\r\n\t\tbb_input_SetInputDevice(ginput);\r\n\t\tbb_audio_SetAudioDevice(gaudio);\r\n\t\t\r\n\t\tstartMillis=BlitzMaxMillisecs()\r\n\t\t\r\n\t\tSetFrameRate( 0 );\r\n\t\t\r\n\t\tInvokeOnCreate();\r\n\t\tInvokeOnRender();\r\n\t\tUpdate()\r\n\tEndMethod\r\n\t\r\n\tMethod Update()\r\n\t\tWhile Not AppTerminate()\r\n\t\t\tLocal updates:Int = 0\r\n\t\t\t\r\n\t\t\tLocal cont:Int = 1\r\n\t\t\tWhile (cont)\r\n\t\t\t\tnextUpdate:+updatePeriod\r\n\t\t\t\tInvokeOnUpdate()\r\n\t\t\t\tIf Not updatePeriod Then cont = 0\r\n\t\t\t\tIf nextUpdate>BlitzMaxMillisecs() Then cont = 0\r\n\t\t\t\tupdates:+1\r\n\t\t\t\tIf updates = 7 Then\r\n\t\t\t\t\tnextUpdate = BlitzMaxMillisecs()\r\n\t\t\t\t\tcont = 0\r\n\t\t\t\tEndIf\r\n\t\t\tWend\r\n\t\t\tInvokeOnRender()\r\n\t\tWend\r\n\tEndMethod\r\n\t\r\n\tMethod InvokeOnCreate()\r\n\t\tIf dead Return\r\n\t\tdead = 1\r\n\t\tOnCreate()\r\n\t\tdead = 0\r\n\tEndMethod\r\n\r\n\tMethod InvokeOnUpdate()\r\n\t\tIf dead Or suspended Or Not updateRate Or vloading Return\r\n\t\tOnUpdate()\r\n\tEndMethod\r\n\t\r\n\tMethod InvokeOnRender()\r\n\t\tIf dead Or suspended Return\r\n\t\tggraphics.BeginRender()\r\n\t\tIf vloading\r\n\t\t\tOnLoading()\r\n\t\tElse\r\n\t\t\tOnRender()\r\n\t\tEndIf\r\n\t\tggraphics.EndRender()\r\n\tEndMethod\r\n\t\r\n\t\r\n\tMethod SetFrameRate( fps:Int )\r\n\t\tIf fps\r\n\t\t\tupdatePeriod=1000.0\/fps;\r\n\t\t\tnextUpdate=BlitzMaxMillisecs() +updatePeriod;\r\n\t\tElse\r\n\t\t\tupdatePeriod=0\r\n\t\tEndIf\r\n\tEndMethod\r\n\t\r\n\tMethod LoadString:String( path:String )\r\n\t\tpath = \"data\/\" + path;\r\n\t\tReturn LoadText( path )\r\n\tEndMethod\r\n\t\r\n\t' ***** GXTK API *****\r\n\t\r\n\tMethod GraphicsDevice:gxtkGraphics()\r\n\t\tReturn ggraphics\r\n\tEndMethod\r\n\r\n\tMethod InputDevice:gxtkInput()\r\n\t\tReturn ginput\r\n\tEndMethod\r\n\r\n\tMethod AudioDevice:gxtkAudio()\r\n\t\tReturn gaudio\r\n\tEndMethod\r\n\r\n\tMethod SetUpdateRate:Int(hertz:Int)\r\n\t\tupdateRate = hertz\r\n\t\tIf Not vloading Then SetFrameRate(updateRate)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod MilliSecs:Int()\r\n\t\tReturn BlitzMaxMillisecs() - startMillis\r\n\tEndMethod\r\n\t\r\n\tMethod Loading:Int()\r\n\t\tReturn vloading;\r\n\tEndMethod\r\n\r\n\tMethod OnCreate:Int()\r\n\t\tReturn 0;\r\n\tEndMethod\r\n\r\n\tMethod OnUpdate:Int()\r\n\t\tReturn 0;\r\n\tEndMethod\r\n\t\r\n\tMethod OnSuspend:Int()\r\n\t\tReturn 0;\r\n\tEndMethod\r\n\t\r\n\tMethod OnResume:Int()\r\n\t\tReturn 0;\r\n\tEndMethod\r\n\t\r\n\tMethod OnRender:Int()\r\n\t\tReturn 0;\r\n\tEndMethod\r\n\t\r\n\tMethod OnLoading:Int()\r\n\t\tReturn 0;\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkGraphics\r\n\tField gmode:Int = 1\r\n\r\n\tMethod Mode:Int()\r\n\t\tReturn gmode\r\n\tEndMethod\r\n\t\r\n\tMethod Cls:Int(r:Int = 0, g:Int = 0, b:Int = 0)\r\n\t\tBlitzMaxCls(r, g, b)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod LoadSurface:gxtkSurface(path:String)\r\n\t\tLocal image:TImage = LoadImage(\"data\/\"+path)\r\n\t\tIf image Then\r\n\t\t\tLocal gs:gxtkSurface = New gxtkSurface\r\n\t\t\tgs.setImage(image)\r\n\t\t\tReturn gs\r\n\t\tEndIf\r\n\t\tReturn Null\r\n\tEndMethod\r\n\t\r\n\tMethod BeginRender()\r\n\tEndMethod\r\n\t\r\n\tMethod EndRender()\r\n\t\tFlip\r\n\tEndMethod\r\n\t\r\n\tMethod SetColor:Int(r:Int, g:Int, b:Int)\r\n\t\tBlitzMaxSetColor(r, g, b)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod SetAlpha:Int(a:Float)\r\n\t\tBlitzMaxSetAlpha(a)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod SetBlend:Int(blend:Int)\r\n\t\tBlitzMaxSetBlend(blend)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod Width:Int()\r\n\t\tReturn GraphicsWidth()\r\n\tEndMethod\r\n\t\r\n\tMethod Height:Int()\r\n\t\tReturn GraphicsHeight()\r\n\tEndMethod\r\n\t\r\n\tMethod SetScissor:Int(x:Int, y:Int, w:Int, h:Int)\r\n\t\tSetViewport(x, y, w, h) ' NOT TESTED!\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod SetMatrix:Int(ix:Float,iy:Float,jx:Float,jy:Float,tx:Float,ty:Float)\r\n\t\tLocal sx:Float = Sqr( (ix*ix) + (jx*jx) )\r\n\t\tLocal sy:Float = Sqr( (iy*iy) + (jy*jy) )\r\n\t\tLocal rot:Float = -Atan2( jx, ix )\r\n\t\tSetTransform( rot, sx, sy )\r\n\t\tSetOrigin( tx, ty )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawSurface:Int(surface:gxtkSurface,x:Float,y:Float)\r\n\t\tDrawImage(surface.image, x, y, 0)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawSurface2:Int(surface:gxtkSurface,x:Float,y:Float, srcx:Int, srcy:Int, srcw:Int, srch:Int )\r\n\t\tDrawSubImageRect(surface.image, x, y, srcw, srch, srcx, srcy, srcw, srch)\t\t\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawLine:Int( x1:Float,y1:Float,x2:Float,y2:Float )\r\n\t\tBlitzMaxDrawLine(x1, y1, x2, y2)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawOval:Int( x:Float, y:Float, w:Float, h:Float )\r\n\t\tBlitzMaxDrawOval(x, y, w, h)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawPoly:Int(vertices:Float[])\r\n\t\tBlitzMaxDrawPoly( vertices )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawRect:Int( x:Float, y:Float, w:Float, h:Float )\r\n\t\tBlitzMaxDrawRect(x, y, w, h)\r\n\t\tReturn 0\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkInput\r\n\tMethod MouseX:Float()\r\n\t\tReturn BRL.PolledInput.MouseX()\r\n\tEndMethod\r\n\r\n\tMethod MouseY:Float()\r\n\t\tReturn BRL.PolledInput.MouseY()\r\n\tEndMethod\r\n\t\r\n\tMethod KeyDown:Int( key:Int )\r\n\t\tIf( key >= 1 And key <= 3 )\r\n\t\t\tReturn BRL.PolledInput.MouseDown( key )\r\n\t\tEndIf\r\n\t\tReturn BRL.PolledInput.KeyDown( key )\r\n\tEndMethod\r\n\r\n\tMethod KeyHit:Int( key:Int )\r\n\t\tIf( key >= 1 And key <= 3 )\r\n\t\t\tReturn BRL.PolledInput.MouseHit( key )\r\n\t\tEndIf\r\n\t\tReturn BRL.PolledInput.KeyHit( key )\r\n\tEndMethod\r\n\r\n\tMethod GetChar:Int()\r\n\t\tReturn BRL.PolledInput.GetChar()\r\n\tEndMethod\r\n\r\n\tMethod JoyX:Int( index:Int )\r\n\t\tReturn Pub.FreeJoy.JoyX( index )\r\n\tEndMethod\r\n\r\n\tMethod JoyY:Int( index:Int )\r\n\t\tReturn Pub.FreeJoy.JoyY( index )\r\n\tEndMethod\r\n\r\n\tMethod JoyZ:Int( index:Int )\r\n\t\tReturn Pub.FreeJoy.JoyZ( index )\r\n\tEndMethod\r\n\r\n\tMethod TouchX:Float( index:Int )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod TouchY:Float( index:Int )\r\n\t\tReturn 0\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkChannel\r\n\tField channel:TChannel\t' null then not playing\r\n\tField sample:gxtkSample\r\n\tField loops:int\r\n\t'Field transform:SoundTransform=new SoundTransform()\r\n\t'Field pausepos:Number\r\n\tField state:int\r\n\t\r\n\tMethod New()\r\n\t\tchannel = New TChannel\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkAudio\r\n\tField amusicState:Int = 0;\r\n\tField channels:gxtkChannel[] = New gxtkChannel[33];\r\n\t\r\n\tMethod New()\r\n\t\tFor local i:Int = 0 To 33 - 1\r\n\t\t\tchannels[i] = New gxtkChannel\r\n\t\tNext\r\n\tEndMethod\r\n\t\r\n\tMethod MusicState:Int()\r\n'\t\tIf( musicState = 1 And music.isPlaying() = False )\r\n'\t\t\tmusicState = 0;\r\n'\t\tEndif\r\n\t\tReturn amusicState;\r\n\tEndMethod\r\n\t\r\n\tMethod PlayMusic:Int( path:String, flags:Int )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod StopMusic()\r\n\tEndMethod\r\n\t\r\n\tMethod StopChannel( channel:Int )\r\n\tEndMethod\r\n\r\n\tMethod PlaySample( sound:gxtkSample, channel:Int, flags:Int )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\t\r\n\t\t'If chan.state <> 0 Then chan.channel.Stop() <-- this crashes after the first play!?\r\n\t\t\r\n\t\tchan.sample = sound\r\n\t\t'chan.loops = flags ? 0x7fffffff : 0;\r\n\t\t'chan.channel = sample.sound.play( 0,chan.loops,chan.transform );\r\n\t\t'chan.channel = sound\r\n\t\tchan.state=1\r\n\t\r\n\t\tPlaySound( sound.sound, chan.channel )\r\n\tEndMethod\r\n\r\n\tMethod SetPan( channel:Int, pan:Float )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tchan.channel.SetPan(pan)\r\n\tEndMethod\r\n\r\n\tMethod SetRate( channel:Int, rate:Float )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tchan.channel.SetRate(rate)\r\n\tEndMethod\r\n\r\n\tMethod SetMusicVolume:Int( volume:Float )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod SetVolume:Int( channel:Int, volume:Float )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tchan.channel.SetVolume(volume)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod LoadSample:gxtkSample( path:String )\r\n\t\tLocal sound:TSound = LoadSound(\"data\/\"+path)\r\n\t\tIf sound Then\r\n\t\t\tLocal gs:gxtkSample = New gxtkSample\r\n\t\t\tgs.setSound(sound)\r\n\t\t\tReturn gs\r\n\t\tEndIf\r\n\t\tReturn Null\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkSample\r\n\tField sound:TSound\r\n\t\r\n\tMethod setSound(sound:TSound)\r\n\t\tSelf.sound = sound\r\n\tEndMethod\r\n\t\r\n\tMethod Discard()\r\n\t\tSelf.sound = null\r\n\tEndMethod\r\nEndType\r\n\r\nFunction BlitzMaxDrawPoly:Int(vertices:Float[])\r\n\tDrawPoly vertices\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxDrawRect:Int( x:Float, y:Float, w:Float, h:Float )\r\n\tDrawRect x, y, w, h\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxDrawOval:Int( x:Float, y:Float, w:Float, h:Float )\r\n\tDrawOval x, y, w, h\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxDrawLine:Int( x1:Float,y1:Float,x2:Float,y2:Float )\r\n\tDrawLine x1, y1, x2, y2\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxMillisecs:Int()\r\n\tReturn MilliSecs()\r\nEndFunction\r\n\r\nFunction BlitzMaxSetColor(r:Int, g:Int, b:Int)\r\n\tSetColor(r, g, b)\r\nEndFunction\r\n\r\nFunction BlitzMaxSetBlend(blend:Int)\r\n\tSelect blend\r\n\t\tCase 0\r\n\t\t\tSetBlend( ALPHABLEND )\r\n\t\tCase 1\r\n\t\t\tSetBlend( LIGHTBLEND )\r\n\tEnd Select\r\nEndFunction\r\n\r\nFunction BlitzMaxSetAlpha(a:Float)\r\n\tSetAlpha(a)\r\nEndFunction\r\n\r\nFunction BlitzMaxCls(r:Int = 0, g:Int = 0, b:Int = 0)\r\n\tSetClsColor(r, g, b)\r\n\tCls\r\nEndFunction\r\n\r\nType gxtkSurface\r\n\tField w:Int, h:Int\r\n\tField image:TImage\r\n\t\r\n\tMethod setImage(image:TImage)\r\n\t\tSelf.image = image\r\n\tEndMethod\r\n\t\r\n\tMethod Width:Int()\r\n\t\tReturn image.Width\r\n\tEndMethod\r\n\t\r\n\tMethod Height:Int()\r\n\t\tReturn image.Height\r\n\tEndMethod\r\n\t\r\n\tMethod Discard()\r\n\tEndMethod\r\nEndType\r\n\r\n' ***** End mojo.bmax.bmx ******\r\n\r\n","old_contents":"' ***** Start mojo.bmax.bmx ******\r\n\r\nGlobal app:gxtkApp;\r\n\r\nType gxtkApp\r\n\tField ginput:gxtkInput;\r\n\tField gaudio:gxtkAudio;\r\n\tField ggraphics:gxtkGraphics;\r\n\r\n\tField dead:Int=0;\r\n\tField suspended:Int=0;\r\n\tField vloading:Int=0;\r\n\tField maxloading:Int=0;\r\n\tField updateRate:Int=0;\r\n\tField nextUpdate:Float=0;\r\n\tField updatePeriod:Float=0;\r\n\tField startMillis:Float=0;\r\n\t\r\n\tMethod New()' gxtkApp()\r\n\t\tapp=Self;\r\n\t\tggraphics=New gxtkGraphics;\r\n\tEndMethod\r\n\t\r\n\tMethod Setup()\r\n\t\tginput=New gxtkInput;\r\n\t\tgaudio=New gxtkAudio;\r\n\r\n\t\tbb_input_SetInputDevice(ginput);\r\n\t\tbb_audio_SetAudioDevice(gaudio);\r\n\t\t\r\n\t\tstartMillis=BlitzMaxMillisecs()\r\n\t\t\r\n\t\tSetFrameRate( 0 );\r\n\t\t\r\n\t\tInvokeOnCreate();\r\n\t\tInvokeOnRender();\r\n\t\tUpdate()\r\n\tEndMethod\r\n\t\r\n\tMethod Update()\r\n\t\tWhile Not AppTerminate()\r\n\t\t\tLocal updates:Int = 0\r\n\t\t\t\r\n\t\t\tLocal cont:Int = 1\r\n\t\t\tWhile (cont)\r\n\t\t\t\tnextUpdate:+updatePeriod\r\n\t\t\t\tInvokeOnUpdate()\r\n\t\t\t\tIf Not updatePeriod Then cont = 0\r\n\t\t\t\tIf nextUpdate>BlitzMaxMillisecs() Then cont = 0\r\n\t\t\t\tupdates:+1\r\n\t\t\t\tIf updates = 7 Then\r\n\t\t\t\t\tnextUpdate = BlitzMaxMillisecs()\r\n\t\t\t\t\tcont = 0\r\n\t\t\t\tEndIf\r\n\t\t\tWend\r\n\t\t\tInvokeOnRender()\r\n\t\tWend\r\n\tEndMethod\r\n\t\r\n\tMethod InvokeOnCreate()\r\n\t\tIf dead Return\r\n\t\tdead = 1\r\n\t\tOnCreate()\r\n\t\tdead = 0\r\n\tEndMethod\r\n\r\n\tMethod InvokeOnUpdate()\r\n\t\tIf dead Or suspended Or Not updateRate Or vloading Return\r\n\t\tOnUpdate()\r\n\tEndMethod\r\n\t\r\n\tMethod InvokeOnRender()\r\n\t\tIf dead Or suspended Return\r\n\t\tggraphics.BeginRender()\r\n\t\tIf vloading\r\n\t\t\tOnLoading()\r\n\t\tElse\r\n\t\t\tOnRender()\r\n\t\tEndIf\r\n\t\tggraphics.EndRender()\r\n\tEndMethod\r\n\t\r\n\t\r\n\tMethod SetFrameRate( fps:Int )\r\n\t\tIf fps\r\n\t\t\tupdatePeriod=1000.0\/fps;\r\n\t\t\tnextUpdate=BlitzMaxMillisecs() +updatePeriod;\r\n\t\tElse\r\n\t\t\tupdatePeriod=0\r\n\t\tEndIf\r\n\tEndMethod\r\n\t\r\n\tMethod LoadString:String( path:String )\r\n\t\tpath = \"data\/\" + path;\r\n\t\tReturn LoadText( path )\r\n\tEndMethod\r\n\t\r\n\t' ***** GXTK API *****\r\n\t\r\n\tMethod GraphicsDevice:gxtkGraphics()\r\n\t\tReturn ggraphics\r\n\tEndMethod\r\n\r\n\tMethod InputDevice:gxtkInput()\r\n\t\tReturn ginput\r\n\tEndMethod\r\n\r\n\tMethod AudioDevice:gxtkAudio()\r\n\t\tReturn gaudio\r\n\tEndMethod\r\n\r\n\tMethod SetUpdateRate:Int(hertz:Int)\r\n\t\tupdateRate = hertz\r\n\t\tIf Not vloading Then SetFrameRate(updateRate)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod MilliSecs:Int()\r\n\t\tReturn BlitzMaxMillisecs() - startMillis\r\n\tEndMethod\r\n\t\r\n\tMethod Loading:Int()\r\n\t\tReturn vloading;\r\n\tEndMethod\r\n\r\n\tMethod OnCreate:Int()\r\n\t\tReturn 0;\r\n\tEndMethod\r\n\r\n\tMethod OnUpdate:Int()\r\n\t\tReturn 0;\r\n\tEndMethod\r\n\t\r\n\tMethod OnSuspend:Int()\r\n\t\tReturn 0;\r\n\tEndMethod\r\n\t\r\n\tMethod OnResume:Int()\r\n\t\tReturn 0;\r\n\tEndMethod\r\n\t\r\n\tMethod OnRender:Int()\r\n\t\tReturn 0;\r\n\tEndMethod\r\n\t\r\n\tMethod OnLoading:Int()\r\n\t\tReturn 0;\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkGraphics\r\n\tField gmode:Int = 1\r\n\r\n\tMethod Mode:Int()\r\n\t\tReturn gmode\r\n\tEndMethod\r\n\t\r\n\tMethod Cls:Int(r:Int = 0, g:Int = 0, b:Int = 0)\r\n\t\tBlitzMaxCls(r, g, b)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod LoadSurface:gxtkSurface(path:String)\r\n\t\tLocal image:TImage = LoadImage(\"data\/\"+path)\r\n\t\tIf image Then\r\n\t\t\tLocal gs:gxtkSurface = New gxtkSurface\r\n\t\t\tgs.setImage(image)\r\n\t\t\tReturn gs\r\n\t\tEndIf\r\n\t\tReturn Null\r\n\tEndMethod\r\n\t\r\n\tMethod BeginRender()\r\n\tEndMethod\r\n\t\r\n\tMethod EndRender()\r\n\t\tFlip\r\n\tEndMethod\r\n\t\r\n\tMethod SetColor:Int(r:Int, g:Int, b:Int)\r\n\t\tBlitzMaxSetColor(r, g, b)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod SetAlpha:Int(a:Float)\r\n\t\tBlitzMaxSetAlpha(a)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod SetBlend:Int(blend:Int)\r\n\t\tBlitzMaxSetBlend(blend)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod Width:Int()\r\n\t\t'TO-DO\r\n\t\tReturn 800\r\n\tEndMethod\r\n\t\r\n\tMethod Height:Int()\r\n\t\t'TO-DO\r\n\t\tReturn 480\r\n\tEndMethod\r\n\t\r\n\tMethod SetScissor:Int(x:Int, y:Int, w:Int, h:Int)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod SetMatrix:Int(ix:Float,iy:Float,jx:Float,jy:Float,tx:Float,ty:Float)\r\n\t\tLocal sx:Float = Sqr( (ix*ix) + (jx*jx) )\r\n\t\tLocal sy:Float = Sqr( (iy*iy) + (jy*jy) )\r\n\t\tLocal rot:Float = -Atan2( jx, ix )\r\n\t\tSetTransform( rot, sx, sy )\r\n\t\tSetOrigin( tx, ty )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawSurface:Int(surface:gxtkSurface,x:Float,y:Float)\r\n\t\tDrawImage(surface.image, x, y, 0)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawSurface2:Int(surface:gxtkSurface,x:Float,y:Float, srcx:Int, srcy:Int, srcw:Int, srch:Int )\r\n\t\tDrawSubImageRect(surface.image, x, y, srcw, srch, srcx, srcy, srcw, srch)\t\t\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawLine:Int( x1:Float,y1:Float,x2:Float,y2:Float )\r\n\t\tBlitzMaxDrawLine(x1, y1, x2, y2)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawOval:Int( x:Float, y:Float, w:Float, h:Float )\r\n\t\tBlitzMaxDrawOval(x, y, w, h)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawPoly:Int(vertices:Float[])\r\n\t\tBlitzMaxDrawPoly( vertices )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawRect:Int( x:Float, y:Float, w:Float, h:Float )\r\n\t\tBlitzMaxDrawRect(x, y, w, h)\r\n\t\tReturn 0\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkInput\r\n\tMethod MouseX:Float()\r\n\t\tReturn BRL.PolledInput.MouseX()\r\n\tEndMethod\r\n\r\n\tMethod MouseY:Float()\r\n\t\tReturn BRL.PolledInput.MouseY()\r\n\tEndMethod\r\n\t\r\n\tMethod KeyDown:Int( key:Int )\r\n\t\tIf( key >= 1 And key <= 3 )\r\n\t\t\tReturn BRL.PolledInput.MouseDown( key )\r\n\t\tEndIf\r\n\t\tReturn BRL.PolledInput.KeyDown( key )\r\n\tEndMethod\r\n\r\n\tMethod KeyHit:Int( key:Int )\r\n\t\tIf( key >= 1 And key <= 3 )\r\n\t\t\tReturn BRL.PolledInput.MouseHit( key )\r\n\t\tEndIf\r\n\t\tReturn BRL.PolledInput.KeyHit( key )\r\n\tEndMethod\r\n\r\n\tMethod GetChar:Int()\r\n\t\tReturn BRL.PolledInput.GetChar()\r\n\tEndMethod\r\n\r\n\tMethod JoyX:Int( index:Int )\r\n\t\tReturn Pub.FreeJoy.JoyX( index )\r\n\tEndMethod\r\n\r\n\tMethod JoyY:Int( index:Int )\r\n\t\tReturn Pub.FreeJoy.JoyY( index )\r\n\tEndMethod\r\n\r\n\tMethod JoyZ:Int( index:Int )\r\n\t\tReturn Pub.FreeJoy.JoyZ( index )\r\n\tEndMethod\r\n\r\n\tMethod TouchX:Float( index:Int )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod TouchY:Float( index:Int )\r\n\t\tReturn 0\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkChannel\r\n\tField channel:TChannel\t' null then not playing\r\n\tField sample:gxtkSample\r\n\tField loops:int\r\n\t'Field transform:SoundTransform=new SoundTransform()\r\n\t'Field pausepos:Number\r\n\tField state:int\r\n\t\r\n\tMethod New()\r\n\t\tchannel = New TChannel\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkAudio\r\n\tField amusicState:Int = 0;\r\n\tField channels:gxtkChannel[] = New gxtkChannel[33];\r\n\t\r\n\tMethod New()\r\n\t\tFor local i:Int = 0 To 33 - 1\r\n\t\t\tchannels[i] = New gxtkChannel\r\n\t\tNext\r\n\tEndMethod\r\n\t\r\n\tMethod MusicState:Int()\r\n'\t\tIf( musicState = 1 And music.isPlaying() = False )\r\n'\t\t\tmusicState = 0;\r\n'\t\tEndif\r\n\t\tReturn amusicState;\r\n\tEndMethod\r\n\t\r\n\tMethod PlayMusic:Int( path:String, flags:Int )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod StopMusic()\r\n\tEndMethod\r\n\t\r\n\tMethod StopChannel( channel:Int )\r\n\tEndMethod\r\n\r\n\tMethod PlaySample( sound:gxtkSample, channel:Int, flags:Int )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\t\r\n\t\t'If chan.state <> 0 Then chan.channel.Stop() <-- this crashes after the first play!?\r\n\t\t\r\n\t\tchan.sample = sound\r\n\t\t'chan.loops = flags ? 0x7fffffff : 0;\r\n\t\t'chan.channel = sample.sound.play( 0,chan.loops,chan.transform );\r\n\t\t'chan.channel = sound\r\n\t\tchan.state=1\r\n\t\r\n\t\tPlaySound( sound.sound, chan.channel )\r\n\tEndMethod\r\n\r\n\tMethod SetPan( channel:Int, pan:Float )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tchan.channel.SetPan(pan)\r\n\tEndMethod\r\n\r\n\tMethod SetRate( channel:Int, rate:Float )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tchan.channel.SetRate(rate)\r\n\tEndMethod\r\n\r\n\tMethod SetMusicVolume:Int( volume:Float )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod SetVolume:Int( channel:Int, volume:Float )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tchan.channel.SetVolume(volume)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod LoadSample:gxtkSample( path:String )\r\n\t\tLocal sound:TSound = LoadSound(\"data\/\"+path)\r\n\t\tIf sound Then\r\n\t\t\tLocal gs:gxtkSample = New gxtkSample\r\n\t\t\tgs.setSound(sound)\r\n\t\t\tReturn gs\r\n\t\tEndIf\r\n\t\tReturn Null\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkSample\r\n\tField sound:TSound\r\n\t\r\n\tMethod setSound(sound:TSound)\r\n\t\tSelf.sound = sound\r\n\tEndMethod\r\n\t\r\n\tMethod Discard()\r\n\t\tSelf.sound = null\r\n\tEndMethod\r\nEndType\r\n\r\nFunction BlitzMaxDrawPoly:Int(vertices:Float[])\r\n\tDrawPoly vertices\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxDrawRect:Int( x:Float, y:Float, w:Float, h:Float )\r\n\tDrawRect x, y, w, h\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxDrawOval:Int( x:Float, y:Float, w:Float, h:Float )\r\n\tDrawOval x, y, w, h\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxDrawLine:Int( x1:Float,y1:Float,x2:Float,y2:Float )\r\n\tDrawLine x1, y1, x2, y2\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxMillisecs:Int()\r\n\tReturn MilliSecs()\r\nEndFunction\r\n\r\nFunction BlitzMaxSetColor(r:Int, g:Int, b:Int)\r\n\tSetColor(r, g, b)\r\nEndFunction\r\n\r\nFunction BlitzMaxSetBlend(blend:Int)\r\n\tSelect blend\r\n\t\tCase 0\r\n\t\t\tSetBlend( ALPHABLEND )\r\n\t\tCase 1\r\n\t\t\tSetBlend( LIGHTBLEND )\r\n\tEnd Select\r\nEndFunction\r\n\r\nFunction BlitzMaxSetAlpha(a:Float)\r\n\tSetAlpha(a)\r\nEndFunction\r\n\r\nFunction BlitzMaxCls(r:Int = 0, g:Int = 0, b:Int = 0)\r\n\tSetClsColor(r, g, b)\r\n\tCls\r\nEndFunction\r\n\r\nType gxtkSurface\r\n\tField w:Int, h:Int\r\n\tField image:TImage\r\n\t\r\n\tMethod setImage(image:TImage)\r\n\t\tSelf.image = image\r\n\tEndMethod\r\n\t\r\n\tMethod Width:Int()\r\n\t\tReturn image.Width\r\n\tEndMethod\r\n\t\r\n\tMethod Height:Int()\r\n\t\tReturn image.Height\r\n\tEndMethod\r\n\t\r\n\tMethod Discard()\r\n\tEndMethod\r\nEndType\r\n\r\n' ***** End mojo.bmax.bmx ******\r\n\r\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"de458053427265a101330a005a99e099c5a81e1b","subject":"Fixed up SetMatrix for MonkeyMax","message":"Fixed up SetMatrix for MonkeyMax\n","repos":"swoolcock\/diddy,swoolcock\/diddy,swoolcock\/diddy,swoolcock\/diddy,swoolcock\/diddy","old_file":"monkeymax\/modules\/mojo\/native\/mojo.bmax.bmx","new_file":"monkeymax\/modules\/mojo\/native\/mojo.bmax.bmx","new_contents":"' ***** Start mojo.bmax.bmx ******\r\n\r\nGlobal app:gxtkApp;\r\n\r\nType gxtkApp\r\n\tField ginput:gxtkInput;\r\n\tField gaudio:gxtkAudio;\r\n\tField ggraphics:gxtkGraphics;\r\n\r\n\tField dead:Int=0;\r\n\tField suspended:Int=0;\r\n\tField vloading:Int=0;\r\n\tField maxloading:Int=0;\r\n\tField updateRate:Int=0;\r\n\tField nextUpdate:Float=0;\r\n\tField updatePeriod:Float=0;\r\n\tField startMillis:Float=0;\r\n\t\r\n\tMethod New()' gxtkApp()\r\n\t\tapp=Self;\r\n\t\tggraphics=New gxtkGraphics;\r\n\tEndMethod\r\n\t\r\n\tMethod Setup()\r\n\t\tginput=New gxtkInput;\r\n\t\tgaudio=New gxtkAudio;\r\n\r\n\t\tbb_input_SetInputDevice(ginput);\r\n\t\tbb_audio_SetAudioDevice(gaudio);\r\n\t\t\r\n\t\tstartMillis=BlitzMaxMillisecs()\r\n\t\t\r\n\t\tSetFrameRate( 0 );\r\n\t\t\r\n\t\tInvokeOnCreate();\r\n\t\tInvokeOnRender();\r\n\t\tUpdate()\r\n\tEndMethod\r\n\t\r\n\tMethod Update()\r\n\t\tWhile Not AppTerminate()\r\n\t\t\tLocal updates:Int = 0\r\n\t\t\t\r\n\t\t\tLocal cont:Int = 1\r\n\t\t\tWhile (cont)\r\n\t\t\t\tnextUpdate:+updatePeriod\r\n\t\t\t\tInvokeOnUpdate()\r\n\t\t\t\tIf Not updatePeriod Then cont = 0\r\n\t\t\t\tIf nextUpdate>BlitzMaxMillisecs() Then cont = 0\r\n\t\t\t\tupdates:+1\r\n\t\t\t\tIf updates = 7 Then\r\n\t\t\t\t\tnextUpdate = BlitzMaxMillisecs()\r\n\t\t\t\t\tcont = 0\r\n\t\t\t\tEndIf\r\n\t\t\tWend\r\n\t\t\tInvokeOnRender()\r\n\t\tWend\r\n\tEndMethod\r\n\t\r\n\tMethod InvokeOnCreate()\r\n\t\tIf dead Return\r\n\t\tdead = 1\r\n\t\tOnCreate()\r\n\t\tdead = 0\r\n\tEndMethod\r\n\r\n\tMethod InvokeOnUpdate()\r\n\t\tIf dead Or suspended Or Not updateRate Or vloading Return\r\n\t\tOnUpdate()\r\n\tEndMethod\r\n\t\r\n\tMethod InvokeOnRender()\r\n\t\tIf dead Or suspended Return\r\n\t\tggraphics.BeginRender()\r\n\t\tIf vloading\r\n\t\t\tOnLoading()\r\n\t\tElse\r\n\t\t\tOnRender()\r\n\t\tEndIf\r\n\t\tggraphics.EndRender()\r\n\tEndMethod\r\n\t\r\n\t\r\n\tMethod SetFrameRate( fps:Int )\r\n\t\tIf fps\r\n\t\t\tupdatePeriod=1000.0\/fps;\r\n\t\t\tnextUpdate=BlitzMaxMillisecs() +updatePeriod;\r\n\t\tElse\r\n\t\t\tupdatePeriod=0\r\n\t\tEndIf\r\n\tEndMethod\r\n\t\r\n\tMethod LoadString:String( path:String )\r\n\t\tpath = \"data\/\" + path;\r\n\t\tReturn LoadText( path )\r\n\tEndMethod\r\n\t\r\n\t' ***** GXTK API *****\r\n\t\r\n\tMethod GraphicsDevice:gxtkGraphics()\r\n\t\tReturn ggraphics\r\n\tEndMethod\r\n\r\n\tMethod InputDevice:gxtkInput()\r\n\t\tReturn ginput\r\n\tEndMethod\r\n\r\n\tMethod AudioDevice:gxtkAudio()\r\n\t\tReturn gaudio\r\n\tEndMethod\r\n\r\n\tMethod SetUpdateRate:Int(hertz:Int)\r\n\t\tupdateRate = hertz\r\n\t\tIf Not vloading Then SetFrameRate(updateRate)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod MilliSecs:Int()\r\n\t\tReturn BlitzMaxMillisecs() - startMillis\r\n\tEndMethod\r\n\t\r\n\tMethod Loading:Int()\r\n\t\tReturn vloading;\r\n\tEndMethod\r\n\r\n\tMethod OnCreate:Int()\r\n\t\tReturn 0;\r\n\tEndMethod\r\n\r\n\tMethod OnUpdate:Int()\r\n\t\tReturn 0;\r\n\tEndMethod\r\n\t\r\n\tMethod OnSuspend:Int()\r\n\t\tReturn 0;\r\n\tEndMethod\r\n\t\r\n\tMethod OnResume:Int()\r\n\t\tReturn 0;\r\n\tEndMethod\r\n\t\r\n\tMethod OnRender:Int()\r\n\t\tReturn 0;\r\n\tEndMethod\r\n\t\r\n\tMethod OnLoading:Int()\r\n\t\tReturn 0;\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkGraphics\r\n\tField gmode:Int = 1\r\n\r\n\tMethod Mode:Int()\r\n\t\tReturn gmode\r\n\tEndMethod\r\n\t\r\n\tMethod Cls:Int(r:Int = 0, g:Int = 0, b:Int = 0)\r\n\t\tBlitzMaxCls(r, g, b)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod LoadSurface:gxtkSurface(path:String)\r\n\t\tLocal image:TImage = LoadImage(\"data\/\"+path)\r\n\t\tIf image Then\r\n\t\t\tLocal gs:gxtkSurface = New gxtkSurface\r\n\t\t\tgs.setImage(image)\r\n\t\t\tReturn gs\r\n\t\tEndIf\r\n\t\tReturn Null\r\n\tEndMethod\r\n\t\r\n\tMethod BeginRender()\r\n\tEndMethod\r\n\t\r\n\tMethod EndRender()\r\n\t\tFlip\r\n\tEndMethod\r\n\t\r\n\tMethod SetColor:Int(r:Int, g:Int, b:Int)\r\n\t\tBlitzMaxSetColor(r, g, b)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod SetAlpha:Int(a:Float)\r\n\t\tBlitzMaxSetAlpha(a)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod SetBlend:Int(blend:Int)\r\n\t\tBlitzMaxSetBlend(blend)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod Width:Int()\r\n\t\t'TO-DO\r\n\t\tReturn 800\r\n\tEndMethod\r\n\t\r\n\tMethod Height:Int()\r\n\t\t'TO-DO\r\n\t\tReturn 480\r\n\tEndMethod\r\n\t\r\n\tMethod SetScissor:Int(x:Int, y:Int, w:Int, h:Int)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod SetMatrix:Int(ix:Float,iy:Float,jx:Float,jy:Float,tx:Float,ty:Float)\r\n\t\tLocal sx:Float = Sqr( (ix*ix) + (jx*jx) )\r\n\t\tLocal sy:Float = Sqr( (iy*iy) + (jy*jy) )\r\n\t\tLocal rot:Float = -Atan2( jx, ix )\r\n\t\tSetTransform( rot, sx, sy )\r\n\t\tSetOrigin( tx, ty )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawSurface:Int(surface:gxtkSurface,x:Float,y:Float)\r\n\t\tDrawImage(surface.image, x, y, 0)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawSurface2:Int(surface:gxtkSurface,x:Float,y:Float, srcx:Int, srcy:Int, srcw:Int, srch:Int )\r\n\t\tDrawSubImageRect(surface.image, x, y, srcw, srch, srcx, srcy, srcw, srch)\t\t\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawLine:Int( x1:Float,y1:Float,x2:Float,y2:Float )\r\n\t\tBlitzMaxDrawLine(x1, y1, x2, y2)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawOval:Int( x:Float, y:Float, w:Float, h:Float )\r\n\t\tBlitzMaxDrawOval(x, y, w, h)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawPoly:Int(vertices:Float[])\r\n\t\tBlitzMaxDrawPoly( vertices )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawRect:Int( x:Float, y:Float, w:Float, h:Float )\r\n\t\tBlitzMaxDrawRect(x, y, w, h)\r\n\t\tReturn 0\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkInput\r\n\tMethod MouseX:Float()\r\n\t\tReturn BRL.PolledInput.MouseX()\r\n\tEndMethod\r\n\r\n\tMethod MouseY:Float()\r\n\t\tReturn BRL.PolledInput.MouseY()\r\n\tEndMethod\r\n\t\r\n\tMethod KeyDown:Int( key:Int )\r\n\t\tIf( key >= 1 And key <= 3 )\r\n\t\t\tReturn BRL.PolledInput.MouseDown( key )\r\n\t\tEndIf\r\n\t\tReturn BRL.PolledInput.KeyDown( key )\r\n\tEndMethod\r\n\r\n\tMethod KeyHit:Int( key:Int )\r\n\t\tIf( key >= 1 And key <= 3 )\r\n\t\t\tReturn BRL.PolledInput.MouseHit( key )\r\n\t\tEndIf\r\n\t\tReturn BRL.PolledInput.KeyHit( key )\r\n\tEndMethod\r\n\r\n\tMethod GetChar:Int()\r\n\t\tReturn BRL.PolledInput.GetChar()\r\n\tEndMethod\r\n\r\n\tMethod JoyX:Int( index:Int )\r\n\t\tReturn Pub.FreeJoy.JoyX( index )\r\n\tEndMethod\r\n\r\n\tMethod JoyY:Int( index:Int )\r\n\t\tReturn Pub.FreeJoy.JoyY( index )\r\n\tEndMethod\r\n\r\n\tMethod JoyZ:Int( index:Int )\r\n\t\tReturn Pub.FreeJoy.JoyZ( index )\r\n\tEndMethod\r\n\r\n\tMethod TouchX:Float( index:Int )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod TouchY:Float( index:Int )\r\n\t\tReturn 0\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkChannel\r\n\tField channel:TChannel\t' null then not playing\r\n\tField sample:gxtkSample\r\n\tField loops:int\r\n\t'Field transform:SoundTransform=new SoundTransform()\r\n\t'Field pausepos:Number\r\n\tField state:int\r\n\t\r\n\tMethod New()\r\n\t\tchannel = New TChannel\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkAudio\r\n\tField amusicState:Int = 0;\r\n\tField channels:gxtkChannel[] = New gxtkChannel[33];\r\n\t\r\n\tMethod New()\r\n\t\tFor local i:Int = 0 To 33 - 1\r\n\t\t\tchannels[i] = New gxtkChannel\r\n\t\tNext\r\n\tEndMethod\r\n\t\r\n\tMethod MusicState:Int()\r\n'\t\tIf( musicState = 1 And music.isPlaying() = False )\r\n'\t\t\tmusicState = 0;\r\n'\t\tEndif\r\n\t\tReturn amusicState;\r\n\tEndMethod\r\n\t\r\n\tMethod PlayMusic:Int( path:String, flags:Int )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod StopMusic()\r\n\tEndMethod\r\n\t\r\n\tMethod StopChannel( channel:Int )\r\n\tEndMethod\r\n\r\n\tMethod PlaySample( sound:gxtkSample, channel:Int, flags:Int )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\t\r\n\t\t'If chan.state <> 0 Then chan.channel.Stop() <-- this crashes after the first play!?\r\n\t\t\r\n\t\tchan.sample = sound\r\n\t\t'chan.loops = flags ? 0x7fffffff : 0;\r\n\t\t'chan.channel = sample.sound.play( 0,chan.loops,chan.transform );\r\n\t\t'chan.channel = sound\r\n\t\tchan.state=1\r\n\t\r\n\t\tPlaySound( sound.sound, chan.channel )\r\n\tEndMethod\r\n\r\n\tMethod SetPan( channel:Int, pan:Float )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tchan.channel.SetPan(pan)\r\n\tEndMethod\r\n\r\n\tMethod SetRate( channel:Int, rate:Float )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tchan.channel.SetRate(rate)\r\n\tEndMethod\r\n\r\n\tMethod SetMusicVolume:Int( volume:Float )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod SetVolume:Int( channel:Int, volume:Float )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tchan.channel.SetVolume(volume)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod LoadSample:gxtkSample( path:String )\r\n\t\tLocal sound:TSound = LoadSound(\"data\/\"+path)\r\n\t\tIf sound Then\r\n\t\t\tLocal gs:gxtkSample = New gxtkSample\r\n\t\t\tgs.setSound(sound)\r\n\t\t\tReturn gs\r\n\t\tEndIf\r\n\t\tReturn Null\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkSample\r\n\tField sound:TSound\r\n\t\r\n\tMethod setSound(sound:TSound)\r\n\t\tSelf.sound = sound\r\n\tEndMethod\r\n\t\r\n\tMethod Discard()\r\n\t\tSelf.sound = null\r\n\tEndMethod\r\nEndType\r\n\r\nFunction BlitzMaxDrawPoly:Int(vertices:Float[])\r\n\tDrawPoly vertices\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxDrawRect:Int( x:Float, y:Float, w:Float, h:Float )\r\n\tDrawRect x, y, w, h\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxDrawOval:Int( x:Float, y:Float, w:Float, h:Float )\r\n\tDrawOval x, y, w, h\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxDrawLine:Int( x1:Float,y1:Float,x2:Float,y2:Float )\r\n\tDrawLine x1, y1, x2, y2\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxMillisecs:Int()\r\n\tReturn MilliSecs()\r\nEndFunction\r\n\r\nFunction BlitzMaxSetColor(r:Int, g:Int, b:Int)\r\n\tSetColor(r, g, b)\r\nEndFunction\r\n\r\nFunction BlitzMaxSetBlend(blend:Int)\r\n\tSelect blend\r\n\t\tCase 0\r\n\t\t\tSetBlend( ALPHABLEND )\r\n\t\tCase 1\r\n\t\t\tSetBlend( LIGHTBLEND )\r\n\tEnd Select\r\nEndFunction\r\n\r\nFunction BlitzMaxSetAlpha(a:Float)\r\n\tSetAlpha(a)\r\nEndFunction\r\n\r\nFunction BlitzMaxCls(r:Int = 0, g:Int = 0, b:Int = 0)\r\n\tSetClsColor(r, g, b)\r\n\tCls\r\nEndFunction\r\n\r\nType gxtkSurface\r\n\tField w:Int, h:Int\r\n\tField image:TImage\r\n\t\r\n\tMethod setImage(image:TImage)\r\n\t\tSelf.image = image\r\n\tEndMethod\r\n\t\r\n\tMethod Width:Int()\r\n\t\tReturn image.Width\r\n\tEndMethod\r\n\t\r\n\tMethod Height:Int()\r\n\t\tReturn image.Height\r\n\tEndMethod\r\n\t\r\n\tMethod Discard()\r\n\tEndMethod\r\nEndType\r\n\r\n' ***** End mojo.bmax.bmx ******\r\n\r\n","old_contents":"' ***** Start mojo.bmax.bmx ******\r\n\r\nGlobal app:gxtkApp;\r\n\r\nType gxtkApp\r\n\tField ginput:gxtkInput;\r\n\tField gaudio:gxtkAudio;\r\n\tField ggraphics:gxtkGraphics;\r\n\r\n\tField dead:Int=0;\r\n\tField suspended:Int=0;\r\n\tField vloading:Int=0;\r\n\tField maxloading:Int=0;\r\n\tField updateRate:Int=0;\r\n\tField nextUpdate:Float=0;\r\n\tField updatePeriod:Float=0;\r\n\tField startMillis:Float=0;\r\n\t\r\n\tMethod New()' gxtkApp()\r\n\t\tapp=Self;\r\n\t\tggraphics=New gxtkGraphics;\r\n\tEndMethod\r\n\t\r\n\tMethod Setup()\r\n\t\tginput=New gxtkInput;\r\n\t\tgaudio=New gxtkAudio;\r\n\r\n\t\tbb_input_SetInputDevice(ginput);\r\n\t\tbb_audio_SetAudioDevice(gaudio);\r\n\t\t\r\n\t\tstartMillis=BlitzMaxMillisecs()\r\n\t\t\r\n\t\tSetFrameRate( 0 );\r\n\t\t\r\n\t\tInvokeOnCreate();\r\n\t\tInvokeOnRender();\r\n\t\tUpdate()\r\n\tEndMethod\r\n\t\r\n\tMethod Update()\r\n\t\tWhile Not AppTerminate()\r\n\t\t\tLocal updates:Int = 0\r\n\t\t\t\r\n\t\t\tLocal cont:Int = 1\r\n\t\t\tWhile (cont)\r\n\t\t\t\tnextUpdate:+updatePeriod\r\n\t\t\t\tInvokeOnUpdate()\r\n\t\t\t\tIf Not updatePeriod Then cont = 0\r\n\t\t\t\tIf nextUpdate>BlitzMaxMillisecs() Then cont = 0\r\n\t\t\t\tupdates:+1\r\n\t\t\t\tIf updates = 7 Then\r\n\t\t\t\t\tnextUpdate = BlitzMaxMillisecs()\r\n\t\t\t\t\tcont = 0\r\n\t\t\t\tEndIf\r\n\t\t\tWend\r\n\t\t\tInvokeOnRender()\r\n\t\tWend\r\n\tEndMethod\r\n\t\r\n\tMethod InvokeOnCreate()\r\n\t\tIf dead Return\r\n\t\tdead = 1\r\n\t\tOnCreate()\r\n\t\tdead = 0\r\n\tEndMethod\r\n\r\n\tMethod InvokeOnUpdate()\r\n\t\tIf dead Or suspended Or Not updateRate Or vloading Return\r\n\t\tOnUpdate()\r\n\tEndMethod\r\n\t\r\n\tMethod InvokeOnRender()\r\n\t\tIf dead Or suspended Return\r\n\t\tggraphics.BeginRender()\r\n\t\tIf vloading\r\n\t\t\tOnLoading()\r\n\t\tElse\r\n\t\t\tOnRender()\r\n\t\tEndIf\r\n\t\tggraphics.EndRender()\r\n\tEndMethod\r\n\t\r\n\t\r\n\tMethod SetFrameRate( fps:Int )\r\n\t\tIf fps\r\n\t\t\tupdatePeriod=1000.0\/fps;\r\n\t\t\tnextUpdate=BlitzMaxMillisecs() +updatePeriod;\r\n\t\tElse\r\n\t\t\tupdatePeriod=0\r\n\t\tEndIf\r\n\tEndMethod\r\n\t\r\n\tMethod LoadString:String( path:String )\r\n\t\tpath = \"data\/\" + path;\r\n\t\tReturn LoadText( path )\r\n\tEndMethod\r\n\t\r\n\t' ***** GXTK API *****\r\n\t\r\n\tMethod GraphicsDevice:gxtkGraphics()\r\n\t\tReturn ggraphics\r\n\tEndMethod\r\n\r\n\tMethod InputDevice:gxtkInput()\r\n\t\tReturn ginput\r\n\tEndMethod\r\n\r\n\tMethod AudioDevice:gxtkAudio()\r\n\t\tReturn gaudio\r\n\tEndMethod\r\n\r\n\tMethod SetUpdateRate:Int(hertz:Int)\r\n\t\tupdateRate = hertz\r\n\t\tIf Not vloading Then SetFrameRate(updateRate)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod MilliSecs:Int()\r\n\t\tReturn BlitzMaxMillisecs() - startMillis\r\n\tEndMethod\r\n\t\r\n\tMethod Loading:Int()\r\n\t\tReturn vloading;\r\n\tEndMethod\r\n\r\n\tMethod OnCreate:Int()\r\n\t\tReturn 0;\r\n\tEndMethod\r\n\r\n\tMethod OnUpdate:Int()\r\n\t\tReturn 0;\r\n\tEndMethod\r\n\t\r\n\tMethod OnSuspend:Int()\r\n\t\tReturn 0;\r\n\tEndMethod\r\n\t\r\n\tMethod OnResume:Int()\r\n\t\tReturn 0;\r\n\tEndMethod\r\n\t\r\n\tMethod OnRender:Int()\r\n\t\tReturn 0;\r\n\tEndMethod\r\n\t\r\n\tMethod OnLoading:Int()\r\n\t\tReturn 0;\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkGraphics\r\n\tField gmode:Int = 1\r\n\r\n\tMethod Mode:Int()\r\n\t\tReturn gmode\r\n\tEndMethod\r\n\t\r\n\tMethod Cls:Int(r:Int = 0, g:Int = 0, b:Int = 0)\r\n\t\tBlitzMaxCls(r, g, b)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod LoadSurface:gxtkSurface(path:String)\r\n\t\tLocal image:TImage = LoadImage(\"data\/\"+path)\r\n\t\tIf image Then\r\n\t\t\tLocal gs:gxtkSurface = New gxtkSurface\r\n\t\t\tgs.setImage(image)\r\n\t\t\tReturn gs\r\n\t\tEndIf\r\n\t\tReturn Null\r\n\tEndMethod\r\n\t\r\n\tMethod BeginRender()\r\n\tEndMethod\r\n\t\r\n\tMethod EndRender()\r\n\t\tFlip\r\n\tEndMethod\r\n\t\r\n\tMethod SetColor:Int(r:Int, g:Int, b:Int)\r\n\t\tBlitzMaxSetColor(r, g, b)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod SetAlpha:Int(a:Float)\r\n\t\tBlitzMaxSetAlpha(a)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod SetBlend:Int(blend:Int)\r\n\t\tBlitzMaxSetBlend(blend)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod Width:Int()\r\n\t\t'TO-DO\r\n\t\tReturn 800\r\n\tEndMethod\r\n\t\r\n\tMethod Height:Int()\r\n\t\t'TO-DO\r\n\t\tReturn 480\r\n\tEndMethod\r\n\t\r\n\tMethod SetScissor:Int(x:Int, y:Int, w:Int, h:Int)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod SetMatrix:Int(ix:Float,iy:Float,jx:Float,jy:Float,tx:Float,ty:Float)\r\n'\t\tLocal sx:Float = Sqr( (ix*ix) + (jx*jx) )\r\n'\t\tLocal sy:Float = Sqr( (iy*iy) + (jy*jy) )\r\n'\t\tLocal rot:Float = Atan2( jx, ix )\r\n'\t\tSetTransform( rot, sx, sy )\r\n\t\tSetTransform( 0, ix, jy )\r\n\t\tSetOrigin( tx, ty )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawSurface:Int(surface:gxtkSurface,x:Float,y:Float)\r\n\t\tDrawImage(surface.image, x, y, 0)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawSurface2:Int(surface:gxtkSurface,x:Float,y:Float, srcx:Int, srcy:Int, srcw:Int, srch:Int )\r\n\t\tDrawSubImageRect(surface.image, x, y, srcw, srch, srcx, srcy, srcw, srch)\t\t\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawLine:Int( x1:Float,y1:Float,x2:Float,y2:Float )\r\n\t\tBlitzMaxDrawLine(x1, y1, x2, y2)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawOval:Int( x:Float, y:Float, w:Float, h:Float )\r\n\t\tBlitzMaxDrawOval(x, y, w, h)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawPoly:Int(vertices:Float[])\r\n\t\tBlitzMaxDrawPoly( vertices )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawRect:Int( x:Float, y:Float, w:Float, h:Float )\r\n\t\tBlitzMaxDrawRect(x, y, w, h)\r\n\t\tReturn 0\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkInput\r\n\tMethod MouseX:Float()\r\n\t\tReturn BRL.PolledInput.MouseX()\r\n\tEndMethod\r\n\r\n\tMethod MouseY:Float()\r\n\t\tReturn BRL.PolledInput.MouseY()\r\n\tEndMethod\r\n\t\r\n\tMethod KeyDown:Int( key:Int )\r\n\t\tIf( key >= 1 And key <= 3 )\r\n\t\t\tReturn BRL.PolledInput.MouseDown( key )\r\n\t\tEndIf\r\n\t\tReturn BRL.PolledInput.KeyDown( key )\r\n\tEndMethod\r\n\r\n\tMethod KeyHit:Int( key:Int )\r\n\t\tIf( key >= 1 And key <= 3 )\r\n\t\t\tReturn BRL.PolledInput.MouseHit( key )\r\n\t\tEndIf\r\n\t\tReturn BRL.PolledInput.KeyHit( key )\r\n\tEndMethod\r\n\r\n\tMethod GetChar:Int()\r\n\t\tReturn BRL.PolledInput.GetChar()\r\n\tEndMethod\r\n\r\n\tMethod JoyX:Int( index:Int )\r\n\t\tReturn Pub.FreeJoy.JoyX( index )\r\n\tEndMethod\r\n\r\n\tMethod JoyY:Int( index:Int )\r\n\t\tReturn Pub.FreeJoy.JoyY( index )\r\n\tEndMethod\r\n\r\n\tMethod JoyZ:Int( index:Int )\r\n\t\tReturn Pub.FreeJoy.JoyZ( index )\r\n\tEndMethod\r\n\r\n\tMethod TouchX:Float( index:Int )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod TouchY:Float( index:Int )\r\n\t\tReturn 0\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkChannel\r\n\tField channel:TChannel\t' null then not playing\r\n\tField sample:gxtkSample\r\n\tField loops:int\r\n\t'Field transform:SoundTransform=new SoundTransform()\r\n\t'Field pausepos:Number\r\n\tField state:int\r\n\t\r\n\tMethod New()\r\n\t\tchannel = New TChannel\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkAudio\r\n\tField amusicState:Int = 0;\r\n\tField channels:gxtkChannel[] = New gxtkChannel[33];\r\n\t\r\n\tMethod New()\r\n\t\tFor local i:Int = 0 To 33 - 1\r\n\t\t\tchannels[i] = New gxtkChannel\r\n\t\tNext\r\n\tEndMethod\r\n\t\r\n\tMethod MusicState:Int()\r\n'\t\tIf( musicState = 1 And music.isPlaying() = False )\r\n'\t\t\tmusicState = 0;\r\n'\t\tEndif\r\n\t\tReturn amusicState;\r\n\tEndMethod\r\n\t\r\n\tMethod PlayMusic:Int( path:String, flags:Int )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod StopMusic()\r\n\tEndMethod\r\n\t\r\n\tMethod StopChannel( channel:Int )\r\n\tEndMethod\r\n\r\n\tMethod PlaySample( sound:gxtkSample, channel:Int, flags:Int )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\t\r\n\t\t'If chan.state <> 0 Then chan.channel.Stop() <-- this crashes after the first play!?\r\n\t\t\r\n\t\tchan.sample = sound\r\n\t\t'chan.loops = flags ? 0x7fffffff : 0;\r\n\t\t'chan.channel = sample.sound.play( 0,chan.loops,chan.transform );\r\n\t\t'chan.channel = sound\r\n\t\tchan.state=1\r\n\t\r\n\t\tPlaySound( sound.sound, chan.channel )\r\n\tEndMethod\r\n\r\n\tMethod SetPan( channel:Int, pan:Float )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tchan.channel.SetPan(pan)\r\n\tEndMethod\r\n\r\n\tMethod SetRate( channel:Int, rate:Float )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tchan.channel.SetRate(rate)\r\n\tEndMethod\r\n\r\n\tMethod SetMusicVolume:Int( volume:Float )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod SetVolume:Int( channel:Int, volume:Float )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tchan.channel.SetVolume(volume)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod LoadSample:gxtkSample( path:String )\r\n\t\tLocal sound:TSound = LoadSound(\"data\/\"+path)\r\n\t\tIf sound Then\r\n\t\t\tLocal gs:gxtkSample = New gxtkSample\r\n\t\t\tgs.setSound(sound)\r\n\t\t\tReturn gs\r\n\t\tEndIf\r\n\t\tReturn Null\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkSample\r\n\tField sound:TSound\r\n\t\r\n\tMethod setSound(sound:TSound)\r\n\t\tSelf.sound = sound\r\n\tEndMethod\r\n\t\r\n\tMethod Discard()\r\n\t\tSelf.sound = null\r\n\tEndMethod\r\nEndType\r\n\r\nFunction BlitzMaxDrawPoly:Int(vertices:Float[])\r\n\tDrawPoly vertices\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxDrawRect:Int( x:Float, y:Float, w:Float, h:Float )\r\n\tDrawRect x, y, w, h\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxDrawOval:Int( x:Float, y:Float, w:Float, h:Float )\r\n\tDrawOval x, y, w, h\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxDrawLine:Int( x1:Float,y1:Float,x2:Float,y2:Float )\r\n\tDrawLine x1, y1, x2, y2\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxMillisecs:Int()\r\n\tReturn MilliSecs()\r\nEndFunction\r\n\r\nFunction BlitzMaxSetColor(r:Int, g:Int, b:Int)\r\n\tSetColor(r, g, b)\r\nEndFunction\r\n\r\nFunction BlitzMaxSetBlend(blend:Int)\r\n\tSelect blend\r\n\t\tCase 0\r\n\t\t\tSetBlend( ALPHABLEND )\r\n\t\tCase 1\r\n\t\t\tSetBlend( LIGHTBLEND )\r\n\tEnd Select\r\nEndFunction\r\n\r\nFunction BlitzMaxSetAlpha(a:Float)\r\n\tSetAlpha(a)\r\nEndFunction\r\n\r\nFunction BlitzMaxCls(r:Int = 0, g:Int = 0, b:Int = 0)\r\n\tSetClsColor(r, g, b)\r\n\tCls\r\nEndFunction\r\n\r\nType gxtkSurface\r\n\tField w:Int, h:Int\r\n\tField image:TImage\r\n\t\r\n\tMethod setImage(image:TImage)\r\n\t\tSelf.image = image\r\n\tEndMethod\r\n\t\r\n\tMethod Width:Int()\r\n\t\tReturn image.Width\r\n\tEndMethod\r\n\t\r\n\tMethod Height:Int()\r\n\t\tReturn image.Height\r\n\tEndMethod\r\n\t\r\n\tMethod Discard()\r\n\tEndMethod\r\nEndType\r\n\r\n' ***** End mojo.bmax.bmx ******\r\n\r\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"6ad8173a06a131f55db9d30ea5e8632f8384559e","subject":"Added missing BlitzMax Diddy Functions for MonkeyMax","message":"Added missing BlitzMax Diddy Functions for MonkeyMax\n\n--HG--\nextra : convert_revision : svn%3Ae934d3cd-0d57-f34a-94d0-9e8d31ae1c29\/trunk%40368\n","repos":"programmerby\/diddy-mirror,programmerby\/diddy-mirror,programmerby\/diddy-mirror,programmerby\/diddy-mirror","old_file":"monkeymax\/modules\/diddy\/native\/diddy.bmax.bmx","new_file":"monkeymax\/modules\/diddy\/native\/diddy.bmax.bmx","new_contents":"Type diddy\r\n\tFunction systemMillisecs:Float()\r\n\t\tReturn Millisecs()\r\n\tEndFunction\r\n\t\r\n\tFunction flushKeys:Int()\r\n\t\tBlitzMaxFlushKeys()\r\n\tEndFunction\r\n\t\r\n\tFunction getUpdateRate:Int()\r\n\t\tReturn app.updateRate;\r\n\tEndFunction\r\n\t\r\n\tFunction showMouse:Int()\r\n\t\tBlitzMaxShowMouse()\r\n\tEndFunction\r\n\t\r\n\tFunction hideMouse:Int()\r\n\t\tBlitzMaxHideMouse()\r\n\tEndFunction\r\n\t\r\n\tFunction setGraphics(w:int, h:int, fullScreen:Int = False)\r\n\t\tlocal d% = 0\r\n\t\tif fullScreen then d = 32\r\n\t\tGraphics w, h, d, 60\r\n\tEndFunction\r\n\t\r\n\tFunction setMouse(x:Int, y:Int)\r\n\t\tMoveMouse(x, y)\r\n\tEndFunction\r\n\t\r\n\tFunction showKeyboard()\r\n\tEndFunction\r\n\t\r\n\tFunction launchBrowser(address:String, windowName:String)\r\n\tEndFunction\r\n\t\r\n\tFunction launchEmail(email:String, subject:String, text:String)\r\n\tEndFunction\r\n\t\r\n\tFunction realMod:Float( value:Float, amount:Float )\r\n\t\tReturn value Mod amount;\r\n\tEndFunction\r\n\t\r\n\tFunction startVibrate(millisecs:int)\r\n\tEndFunction\r\n\t\r\n\tFunction stopVibrate()\r\n\tEndFunction\r\n\t\r\n\tFunction getDayOfMonth:Int()\r\n\t\tLocal date$ = CurrentDate()\r\n\t\tReturn Int(date[..2])\r\n\tEndFunction\r\n\t\r\n\tFunction getDayOfWeek:Int()\r\n\t\tReturn 0\r\n\tEndFunction\r\n\t\r\n\tFunction getMonth:Int()\r\n\t\tLocal date$ = CurrentDate()\r\n\t\tReturn (Instr(\"JANFEBMARAPRMAYJUNJULAUGSEPOCTNOVDEC\", date$[3..6].ToUpper(), 1) \/ 3) + 1\r\n\tEndFunction\r\n\t\r\n\tFunction getYear:Int()\r\n\t\tLocal date$ = CurrentDate()\r\n\t\tReturn Int(date[date.length - 4..]);\r\n\tEndFunction\r\n\t\r\n\tFunction getHours:Int()\r\n\t\tLocal time$ = CurrentTime()\r\n\t\tReturn Int(time[..2])\r\n\tEndFunction\r\n\t\r\n\tFunction getMinutes:Int()\r\n\t\tLocal time$ = CurrentTime()\r\n\t\tReturn Int(time[3..5])\r\n\tEndFunction\r\n\t\r\n\tFunction getSeconds:Int()\r\n\t\tLocal time$ = CurrentTime()\r\n\t\tReturn Int(time[6..8])\r\n\tEndFunction\r\n\t\r\n\tFunction getMilliSeconds:Int()\r\n\t\tReturn Millisecs()\r\n\tEndFunction\r\n\t\r\n\tFunction startGps()\r\n\tEndFunction\r\n\t\r\n\tFunction getLatitiude:String()\r\n\t\tReturn \"\"\r\n\tEndFunction\r\n\t\r\n\tFunction getLongitude:String()\r\n\t\tReturn \"\"\r\n\tEndFunction\r\n\r\n\tFunction showAlertDialog(title:String, message:String)\r\n\tEndFunction\r\n\t\r\n\tFunction getInputString:String()\r\n\t\tReturn \"\";\r\n\tEndFunction\r\n\t\r\n\tFunction getPixel:Int( x:int, y:int )\r\n'\t\tunsigned char pix[4];\r\n'\t\tglReadPixels(x, app->graphics->height-y ,1 ,1 ,GL_RGBA ,GL_UNSIGNED_BYTE ,pix);\r\n'\t\treturn (pix[3]<<24) | (pix[0]<<16) | (pix[1]<<8) | pix[2];\r\n\t\tReturn 0\r\n\tEndFunction\r\n\t\r\nEndType\r\n\r\nFunction BlitzMaxFlushKeys()\r\n\tFlushKeys()\r\nEndFunction\r\n\r\nFunction BlitzMaxShowMouse()\r\n\tShowMouse()\r\nEndFunction\r\n\r\nFunction BlitzMaxHideMouse()\r\n\tHideMouse()\r\nEndFunction\r\n\r\n","old_contents":"Type diddy\r\n\tFunction systemMillisecs:Float()\r\n\t\treturn Millisecs()\r\n\tEndFunction\r\n\r\n\tFunction realMod:Float( value:Float, amount:Float )\r\n\t\treturn value Mod amount;\r\n\tEndFunction\r\n\t\r\n\tFunction getYear:Int()\r\n\t\treturn 2012;\r\n\tEndFunction\r\nEndType\r\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"4febed01584ae48b1997a44fc94c074d5e7be323","subject":"Set input device bug fixed #51","message":"Set input device bug fixed #51\n","repos":"devolonter\/flixel-monkey,devolonter\/flixel-monkey,devolonter\/flixel-monkey,devolonter\/flixel-monkey","old_file":"native\/flixel.bmax.bmx","new_file":"native\/flixel.bmax.bmx","new_contents":"\nType flixel\n\n\tFunction systemMillisecs:Int()\n\t\tReturn Millisecs()\n\tEnd Function\n\t\n\tFunction hideMouse()\n\t\tbmxHideMouse()\n\tEnd Function\n\t\n\tFunction showMouse()\n\t\tbmxShowMouse()\n\tEnd Function\n\t\n\tFunction isMobile:Int()\n\t\tReturn False\n\tEnd Function\n\t\n\tFunction openURL(url:String)\n\t\tbmxOpenURL(url)\n\tEnd Function\n\nEnd Type\n\nFunction bmxHideMouse()\n\tHideMouse()\nEndFunction\n\nFunction bmxShowMouse()\n\tShowMouse()\nEndFunction\n\nFunction bmxOpenURL(url:String)\n\tOpenURL(url)\nEnd Function\n\nFunction resize_array_array_XYZRecord:bb_xyzrecord__1X_1Y_1Z_1Record[][] (arr:bb_xyzrecord__1X_1Y_1Z_1Record[][], leng:Int)\n\tLocal i:Int = arr.length\n\tarr = arr[..leng]\n\t\n\tIf( leng<=i ) Return arr\n\n\tFor Local l:Int = 0 Until Len(arr)\n\t\tarr[l] = arr[l][..leng]\n\tNext\n\t\n\tWhile( i 2\t'strings have size > 2\n\t\t\t\tLocal length:Double, lp:Int Ptr = Int Ptr(Varptr(length))\n\t\t\t\tlp[0] = buf[koff] ; lp[1] = buf[koff + 1]\n\t\t\t\tLocal s:Byte Ptr = mem.AllocString(length, Short Ptr(Varptr(buf[koff + 2])))\n\t\t\t\tktbl[k] = mem.PtrToVal(s, BlueTypeTag.STR)\n\t\t\tElse\n\t\t\t\tLocal d:Double, dp:Int Ptr = Int Ptr(Varptr(d))\n\t\t\t\tdp[0] = buf[koff] ; dp[1] = buf[koff + 1]\n\t\t\t\tDouble Ptr(Varptr(ktbl[k]))[0] = d\n\t\t\tEndIf\n\t\tNext\n\t\t\n\t\tExtendFunIndex(idMod + fcount)\n\t\tFor Local f:Int = 0 Until fcount\n\t\t\tLocal foff:Int = buf[3 + f]\n\t\t\tLocal ic:Int = buf[foff + 1], kc:Int = buf[foff + 2], pc:Int = buf[foff + 3], uc:Int = buf[foff + 5], fsz:Int = buf[foff + 6]\n\t\t\t\n\t\t\tLocal b:Bytecode = BPtoBC(mem.AllocObjectOldSpace(mem.oldStrSpace, (8 + 2 * (uc + uc Mod 2) + 2 * kc + 2 * ic) * 4, BlueTypeTag.BCODE))\n\t\t\tb.idMod = idMod ; b.kcount = kc ; b.pcount = pc ; b.upvars = uc + (uc Mod 2)\t'round up for alignment\n\t\t\tb.frameSz = BlueJIT.STACKFRAMESZ + b.upvars * 8 + fsz * 8 ; b.icount = ic ; b.vm = convert(Self)\n\t\t\t\n\t\t\tLocal ib:Int Ptr = Int Ptr(Byte Ptr(b) + 4) + 8 + 2 * ic\n\t\t\tFor Local u:Int = 0 Until uc\n\t\t\t\tLocal uoff:Int = 7 + u * 2\n\t\t\t\tib[u * 2] = buf[foff + uoff] ; ib[u * 2 + 1] = buf[foff + uoff + 1]\n\t\t\tNext\n\t\t\tIf uc <> b.upvars\t'ensure padding is safe by copying the first one\n\t\t\t\tib[uc * 2] = buf[foff + 7] ; ib[uc * 2 + 1] = buf[foff + 7 + 1]\n\t\t\tEndIf\n\t\t\t\n\t\t\tLocal db:Long Ptr = Long Ptr(ib + 2 * b.upvars)\n\t\t\tFor Local k:Int = 0 Until kc\n\t\t\t\tdb[k] = ktbl[buf[foff + 7 + uc * 2 + k]]\n\t\t\tNext\n\t\t\t\n\t\t\tLocal ioff:Int = 7 + 2 * uc + kc ; ib = Int Ptr(Byte Ptr(b) + BlueJIT.BYTECODE_INC)\n\t\t\t\n\t\t\tFor Local i:Int = 0 Until ic * 2\n\t\t\t\tib[i] = buf[foff + ioff + i]\n\t\t\tNext\n\t\t\t\n\t\t\tb.mcode = BlueJIT.Compile(Self, ib, ic, b) + BlueJIT.PROLOGUESZ\n\t\t\tfunIndex[idMod + f] = b\n\t\tNext\n\t\t\n\t\tidMod :+ fcount\n\t\tReturn New BlueLuaVal\n\tEnd Method\n\t\n\tMethod ExtendFunIndex(sz:Int)\t'hack: BlitzMax has a bug with arrays of extern types! so we need to use C-style arrays for now\n\t\tLocal newFI:Bytecode Ptr = Bytecode Ptr(MemAlloc(sz * 4))\n\t\tIf _fiSz\n\t\t\tFor Local b:Int = 0 Until _fiSz\n\t\t\t\tnewFI[b] = funIndex[b]\n\t\t\tNext\n\t\t\tMemFree(funIndex)\n\t\t\tFor Local b:Int = _fiSz Until sz\n\t\t\t\tnewFI[b] = Null\n\t\t\tNext\n\t\tEndIf\n\t\tfunIndex = newFI ; _fiSz = sz\n\tEnd Method\n\t\n\tMethod CallToLua()\n\tEnd Method\n\t\n\tGlobal BPtoBC:Bytecode(p:Byte Ptr) = Byte Ptr(BlueJIT.PointerToExtType)\nEnd Type\n\nPrivate\nExtern\n\tType Stack\n\t\tField retIP:Byte Ptr, prevBase:Stack, varp:Long Ptr, func:Bytecode, _:Long Ptr, argv:Long Ptr, retv:Long Ptr, argc:Short, retc:Short\n\tEnd Type\n\tType Bytecode\n\t\tField mcode:Byte Ptr, idMod:Int, kcount:Int, pcount:Int, upvars:Int, frameSz:Int, icount:Int, vm:Byte Ptr\n\tEnd Type\nEnd Extern\nPublic\n\nType BlueJIT Final\n\tConst PROLOGUESZ:Int = 25, ISIZE:Int = 5\n\t\n\tGlobal opTbl:Int(s:Stack, b:Bytecode, r:Byte Ptr)[], opc:BlueOpcode\n\tGlobal Prologue:Int[] = [ ..\n\t\t$90, $90, ..\n\t\t$8b, $44, $24, $04, .. 'mov 4(%esp), %eax\n\t\t$89, $44, $24, $f4, .. 'mov %eax, -12(%esp)\n\t\t$c7, $44, $24, $f8, $FF, $FF, $FF, $FF, .. 'movl ########, -8(%esp)\n\t\t$89, $64, $24, $fc, .. 'mov %esp, -4(%esp)\n\t\t$83, $ec, $0c.. 'sub $12, %esp\n\t]\n\t\n\tFunction Compile:Byte Ptr(vm:BlueVM, ins:Byte Ptr, icount:Int, bytecode:Bytecode)\n\t\t?Not x86\n\t\tRuntimeError \"The Blue Moon JIT does not support your platform (x86-32 only at this time)\"\n\t\t?\n\t\tAssert SizeOf(0:Long) = SizeOf(0:Double) And SizeOf(0:Int) = 4 And SizeOf(0:Long) = 8 And SizeOf(Byte Ptr(0)) = 4, ..\n\t\t\t\"assumptions about platform datatype sizes are invalid\"\n\t\t\n\t\tIf opTbl = Null Then InitOpTbl()\n\t\t\n\t\tLocal sz:Int = PROLOGUESZ + icount * ISIZE\n\t\t\n\t\t' allocate executable space\n\t\tLocal blocks:Int[] = vm.mem.AllocCodeBlock(PROLOGUESZ + icount * ISIZE)\n\t\tLocal code:Byte Ptr = Byte Ptr(blocks[0]), rsize:Int = blocks[1] - (blocks[1] Mod ISIZE)\n\t\t\n\t\tFor Local p:Int = 0 Until PROLOGUESZ\t'emplace prologue (used for calling in from native only)\n\t\t\tcode[p] = Prologue[p]\n\t\tNext\n\t\tByte Ptr Ptr(code + 14)[0] = Byte Ptr(bytecode)\t'replace the ########\n\t\tcode :+ PROLOGUESZ ; rsize :- PROLOGUESZ\t'easier to not have to take this into account below\n\t\t\n\t\tLocal codePage:Int Ptr = Int Ptr(Int(code) & ((Int(2^12)-1) Shl 20))\t'return-to-native for the page\n\t\tcodePage[1] = $c30cc483\t'add $12, %esp ; ret - i.e. restore the stack to normal\n\t\t\n\t\tLocal ktable:Double Ptr = Double Ptr(ins + 8 * bytecode.icount + 8 * bytecode.upvars)\n\t\t\n\t\t' generate machine code!\n\t\tRepeat\n\t\t\t\n\t\t\tLocal i:Int = 0, codep:Byte Ptr = code\n\t\t\tWhile rsize\t'emplace opcode calls and supporting bytecode data\n\t\t\t\tLocal bytecodep:Byte Ptr = Byte Ptr(Int(codep) + vm.mem.PAGESZ)\n\t\t\t\tcodep[0] = $e8\t'call\n\t\t\t\tLocal bi:Int = i * 8, op:Int = ins[bi], ip:Int Ptr = Int Ptr(ins + bi), func:Byte Ptr = opTbl[op]\n\t\t\t\tByte Ptr Ptr(codep + 1)[0] = func - Int(codep + ISIZE)\n\t\t\t\t\n\t\t\t\tbytecodep[0] = ins[bi + 1] ; bytecodep[1] = ins[bi + 2]\t'used by most, may get overwritten\n\t\t\t\t\n\t\t\t\tSelect op\n\t\t\t\t\tCase opc.LOADSI, opc.CLOSURE, opc.RET, opc.POSTCALL\n\t\t\t\t\t\tInt Ptr(bytecodep + 1)[0] = ip[1]\n\t\t\t\t\t\t\n\t\t\t\t\tCase opc.LOADK\n\t\t\t\t\t\tDouble Ptr Ptr(bytecodep + 1)[0] = ktable + ip[1]\n\t\t\t\t\t\t\n\t\t\t\t\tCase opc.SETTABSI, opc.GETTABSI\n\t\t\t\t\t\tShort Ptr(bytecodep)[1] = ip[1]\n\t\t\t\t\t\t\n\t\t\t\t\tCase opc.CALL\n\t\t\t\t\t\tShort Ptr(bytecodep)[1] = ip[1]\n\t\t\t\t\t\t\n\t\t\t\t\tCase opc.JIF, opc.JNOT\n\t\t\t\t\t\tInt Ptr(bytecodep + 1)[0] = Int(codep) + ISIZE * ip[1]\n\t\t\t\t\t\t\n\t\t\t\t\tCase opc.JMP\n\t\t\t\t\t\tcodep[0] = $e9\t'use a true jump\n\t\t\t\t\t\tInt Ptr(codep + 1)[0] = ISIZE * (ip[1] - 1)\n\t\t\t\t\t\t\n\t\t\t\t\tDefault\t'binary operations A = B op C\n\t\t\t\t\t\tbytecodep[2] = ip[1]\n\t\t\t\tEnd Select\n\t\t\t\t\n\t\t\t\trsize :- ISIZE ; codep :+ ISIZE ; icount :- 1\n\t\t\t\ti :+ 1\n\t\t\tWend\n\t\t\t\n\t\t\t'deal with overflowing code sections here\n\t\tUntil icount = 0\n\t\t\n\t\tReturn code - PROLOGUESZ\n\tEnd Function\n\t\n\t\n\tConst STACKFRAMESZ:Int = 8 * 4, BYTECODESZ:Int = 8 * 4, STACKFRAME_INC:Int = STACKFRAMESZ + 4, BYTECODE_INC:Int = BYTECODESZ + 4\n\tConst IP_OFFSET:Int = BlueVMMemory.PAGESZ - ISIZE\n\t\n\t\n\t'note: extern vars must take into account the vtbl offset, so that converting from a typed pointer can be a simple cast (faster)\t\n\t\n\tFunction MOV(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"MOV \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tvarp[rp[0]] = varp[rp[1]]\t'assigning through Double is unsafe as it can corrupt the bit pattern\n\tEnd Function\n\tFunction GETLC(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction SETLC(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"SETLC \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\t'add a write barrier here\n\t\tLong Ptr Ptr(varp + rp[0])[0][0] = varp[rp[1]]\n\tEnd Function\n\tFunction LOADK(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"LOADK \/\/\"\n\t\tLocal rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET, varp:Long Ptr = stk.varp + rp[0], kp:Long Ptr = Long Ptr Ptr(rp + 1)[0]\n\t\tvarp[0] = kp[0]\n\tEnd Function\n\tFunction LOADSI(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"LOADSI \/\/\"\n\t\tLocal rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal val:Int = Int Ptr(rp + 1)[0]\n\t\tDouble Ptr(stk.varp)[rp[0]] = Double(val)\n\tEnd Function\n\tFunction LOADBOOL(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"LOADBOOL \/\/\"\n\t\tLocal rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET, vp:Int Ptr = Int Ptr(stk.varp + rp[0])\n\t\tvp[1] = BlueTypeTag.NANBOX | BlueTypeTag.BOOL\n\t\tvp[0] = Int Ptr(rp + 1)[0]\n\tEnd Function\n\tFunction LOADNIL(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"LOADNIL \/\/\"\n\t\tLocal rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tInt Ptr(stk.varp + rp[0])[1] = BlueTypeTag.NANBOX | BlueTypeTag.NIL\n\tEnd Function\n\t\n\tFunction GETTAB(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction GETTABSI(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction SETTAB(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction SETTABSI(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t\tPrint \"SETTABSI \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal convert:BlueVM(p:Byte Ptr) = Byte Ptr(Identity), vm:BlueVM = convert(bc.vm)\n\t\tLocal tabp:Byte Ptr = varp + rp[0]\n\t\tPrint \" \" + Short Ptr(rp)[1]\n\t\tLocal key:Long ; Double Ptr(Varptr(key))[0] = Short Ptr(rp)[1]\n\t\tBlueTable.Set(vm.mem, Byte Ptr Ptr(tabp)[0], key, varp[rp[1]])\n\tEnd Function\n\tFunction GETTABI(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t\tPrint \"GETTABI \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal tabp:Byte Ptr = varp + rp[1]\n\t\tPrint \" tag: \" + Bin(Int Ptr(varp + rp[2])[1])\n\t\tLocal val:Long = BlueTable.Get(Byte Ptr Ptr(tabp)[0], varp[rp[2]])\n\t\tLocal v:Double = Double Ptr(Varptr(val))[0]\n\t\tPrint \" \" + v\n\t\tvarp[rp[0]] = val\n\tEnd Function\n\tFunction SETTABI(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t\tPrint \"SETTABI \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal convert:BlueVM(p:Byte Ptr) = Byte Ptr(Identity), vm:BlueVM = convert(bc.vm)\n\t\tLocal tabp:Byte Ptr = varp + rp[0]\n\t\tPrint \" \" + Double Ptr(varp)[rp[2]] + \" \" + Double Ptr(varp)[rp[1]]\n\t\tPrint \" tag: \" + Bin(Int Ptr(varp + rp[2])[1])\n\t\tBlueTable.Set(vm.mem, Byte Ptr Ptr(tabp)[0], varp[rp[2]], varp[rp[1]])\n\tEnd Function\n\tFunction GETUPV(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"GETUPV \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, upvp:Byte Ptr Ptr = Byte Ptr Ptr(Byte Ptr(stk) + STACKFRAME_INC)\n\t\tLocal rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET, valp:Long Ptr = Long Ptr(upvp[rp[1]])\n\t\tvarp[rp[0]] = valp[0]\n\tEnd Function\n\tFunction SETUPV(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction NEWTAB(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t\tPrint \"NEWTAB \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal convert:BlueVM(p:Byte Ptr) = Byte Ptr(Identity), vm:BlueVM = convert(bc.vm)\n\t\tLocal tab:Byte Ptr = vm.mem.AllocTable(Null)\n\t\tLocal d:Int Ptr = Int Ptr(varp + rp[0])\n\t\td[0] = Int(tab) ; d[1] = BlueTypeTag.NANBOX | BlueTypeTag.TBL\n\tEnd Function\n\tFunction CLOSURE(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"CLOSURE \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal convert:BlueVM(p:Byte Ptr) = Byte Ptr(Identity), vm:BlueVM = convert(bc.vm)\n\t\tLocal d:Int Ptr = Int Ptr(varp + rp[0])\n\t\tLocal cbytecode:Bytecode = vm.funIndex[Int Ptr(rp + 1)[0]], upvp:Int Ptr = Int Ptr(Byte Ptr(cbytecode) + BYTECODE_INC + 8 * cbytecode.icount)\n\t\tLocal closure:Byte Ptr = vm.mem.AllocClosure(cbytecode, cbytecode.upvars)\t'upvars is always even (alignment)\n\t\t\n\t\t'get upvalues off the stack\n\t\tFor Local u:Int = 0 Until cbytecode.upvars\n\t\t\tIf upvp[2 * u]\n\t\t\t\tByte Ptr Ptr(closure)[2 + u] = Byte Ptr Ptr(Byte Ptr(stk) + STACKFRAME_INC)[upvp[2 * u + 1]]\n\t\t\tElse\n\t\t\t\tByte Ptr Ptr(closure)[2 + u] = Byte Ptr Ptr(varp + upvp[2 * u + 1])[0]\n\t\t\tEndIf\n\t\tNext\n\t\t\n\t\td[0] = Int(closure) ; d[1] = BlueTypeTag.NANBOX | BlueTypeTag.FUN\n\tEnd Function\n\tFunction NEWUPV(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"NEWUPV \/\/\"\n\t\tLocal rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal convert:BlueVM(p:Byte Ptr) = Byte Ptr(Identity), vm:BlueVM = convert(bc.vm)\n\t\tLocal upv:Byte Ptr = vm.mem.AllocObject(8, BlueTypeTag.UPV), d:Int Ptr = Int Ptr(stk.varp + rp[0])\n\t\tLong Ptr(upv)[0] = Long Ptr(d)[0]\t'promote a value if it existed (useful for parameters)\n\t\td[0] = Int(upv) ; d[1] = BlueTypeTag.NANBOX | BlueTypeTag.UPV\n\tEnd Function\n\t\n\tFunction ADD(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t\tPrint \"ADD \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal d:Double Ptr = Double Ptr(varp + rp[0])\n\t\tLocal r:Int Ptr = Int Ptr(varp + rp[1]), l:Int Ptr = Int Ptr(varp + rp[2])\n\t\tIf l[1] & BlueTypeTag.NANBOX_CHK = BlueTypeTag.NANBOX Or r[1] & BlueTypeTag.NANBOX_CHK = BlueTypeTag.NANBOX\n\t\t\tDebugStop\n\t\tElse\n\t\t\tPrint \" \" + Double Ptr(l)[0] + \" \" + Double Ptr(r)[0]\n\t\t\td[0] = Double Ptr(l)[0] + Double Ptr(r)[0]\n\t\tEndIf\n\tEnd Function\n\tFunction SUB(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction MUL(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction DIV(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction NMOD(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction POW(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction CAT(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction IDIV(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction BAND(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction BOR(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction BXOR(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction BSHL(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction BSHR(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction UNM(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction LNOT(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction ALEN(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction BNOT(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction UNP(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction EQ(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"EQ \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = (Byte Ptr Ptr(retptr) - 4)[0] + IP_OFFSET\n\t\tLocal r:Double = Double Ptr(varp)[rp[1]]\n\t\tLocal l:Double = Double Ptr(varp)[rp[2]]\n\t\tInt Ptr(varp + rp[0])[0] = l = r\n\tEnd Function\n\tFunction LT(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction LEQ(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\t\n\tFunction JMP(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t\tPrint \"wait, why are we here?\"\n\tEnd Function\n\tFunction JIF(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"JIF \/\/\"\n\t\tLocal rp:Byte Ptr = (Byte Ptr Ptr(retptr) - 4)[0] + IP_OFFSET\n\t\tIf Int Ptr(stk.varp + rp[0])[0]\n\t\t\tLocal target:Int = Int Ptr(rp + 1)[0]\n\t\t\tInt Ptr(retptr)[-4] = target\n\t\tEndIf\n\tEnd Function\n\tFunction JNOT(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction CALL(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"CALL \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal fp:Int Ptr = Int Ptr(varp + rp[0])\n\t\tIf Not PrepareCall(fp, stk, rp, varp, retptr)\t'PrepareCall sets everything up so there's nothing else to do to make the call happen\n\t\t\t'__call metamethod\n\t\tEndIf\n\tEnd Function\n\tFunction TCALL(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction RET:Byte Ptr(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"RET \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp\n\t\tLocal rp0:Byte Ptr = Byte Ptr Ptr(retptr)[-4], rp:Byte Ptr = rp0 + IP_OFFSET\n\t\t\n\t\tLocal oldStk:Stack = stk.prevBase\n\t\tLocal retv:Long Ptr = varp + rp[0]\n\t\tIf oldStk\n\t\t\toldStk.retv = retv\n\t\t\toldStk.retc = Int Ptr(rp + 1)[0]\n\t\t\tByte Ptr Ptr(retptr)[-4] = stk.retIP\n\t\t\tByte Ptr Ptr(retptr)[-3] = Byte Ptr(oldStk)\n\t\t\tByte Ptr Ptr(retptr)[-2] = Byte Ptr(oldStk.func) + BYTECODE_INC\n\t\tElse\t'return to native code\n\t\t\tLocal codePage:Byte Ptr = Byte Ptr(Int(rp0) & ((Int(2^12)-1) Shl 20))\n\t\t\tByte Ptr Ptr(retptr)[-4] = codePage + 4\n\t\t\tReturn retv\n\t\tEndIf\n\tEnd Function\n\tFunction RETVA(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction POSTCALL(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"POSTCALL \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp\n\t\tLocal rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\t\n\t\tFor Local r:Int = 0 Until Min(Int Ptr(rp + 1)[0], stk.retc)\n\t\t\t(varp + rp[0])[r] = stk.retv[r]\n\t\t'\tPrint \" return \" + r + \": \" + Double Ptr(stk.retv)[r]\n\t\tNext\n\tEnd Function\n\tFunction VARARG(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction VAINIT(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction CALLINIT(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\t\n\t\n\tFunction PrepareCall:Int(fp:Int Ptr, stk:Stack, rp:Byte Ptr, varp:Long Ptr, retptr:Byte Ptr)\n\t\tIf fp[1] = BlueTypeTag.NANBOX | BlueTypeTag.FUN\n\t\t\tLocal newStk0:Stack ; Byte Ptr Ptr(Varptr(newStk0))[0] = Byte Ptr(stk) + stk.func.frameSz\n\t\t\tLocal newStk:Stack = newStk0\t'micro-opt: newStk0 can't be a register because of the unwieldy conversion\n\t\t\t\n\t\t\tnewStk.retIP = Byte Ptr Ptr(retptr)[-4]\n\t\t\tnewStk.prevBase = stk\n\t\t\tLocal closure:Byte Ptr = Byte Ptr(fp[0])\n\t\t\tLocal newBC:Bytecode = Bytecode Ptr(closure)[0]\n\t\t\tLocal voff:Int = STACKFRAME_INC + 4 * newBC.upvars\n\t\t\tnewStk.varp = Long Ptr(Byte Ptr(newStk) + voff)\n\t\t\tnewStk.func = newBC\n\t\t'\tnewStk._IP = 0\n\t\t\t\n\t\t\tLocal argc_actual:Int = Short Ptr(rp)[1], argc_required:Int = newBC.pcount\n\t\t'\tLocal argc_min:Int ; If argc_actual < argc_required Then argc_min = argc_actual Else argc_min = argc_required\n\t\t\tLocal argc_min:Int = argc_actual - argc_required ; argc_min = (argc_min & (argc_min Shr 31)) + argc_required 'branchless 32-bit Min\n\t\t\t\n\t\t\tLocal argv:Long Ptr = varp + rp[1], destv:Long Ptr = newStk.varp\n\t\t\tFor Local a:Int = 0 Until argc_min\n\t\t\t\tdestv[a] = argv[a]\n\t\t\t'\tPrint \" arg \" + a + \": \" + argv[a]\n\t\t\tNext\n\t\t\tFor Local a:Int = argc_min Until argc_required\t'nil any unfilled parameters\n\t\t\t\tInt Ptr(destv + a)[1] = BlueTypeTag.NANBOX | BlueTypeTag.NIL\n\t\t\tNext\n\t\t\tnewStk.argv = argv + argc_min\t'argv should be to the varargs (if any)\n\t\t\tnewStk.argc = argc_actual - argc_min\t'argc is the number of varargs\n\t\t\t\n\t\t\tLocal destup:Byte Ptr Ptr = Byte Ptr Ptr(Byte Ptr(newStk) + STACKFRAME_INC)\n\t\t\tLocal upv:Byte Ptr Ptr = Byte Ptr Ptr(closure + 8)\n\t\t\tFor Local up:Int = 0 Until newBC.upvars\t'emplace upvars\n\t\t\t\tdestup[up] = upv[up]\n\t\t\t'\tPrint \" upv \" + up + \": \" + destv[up]\n\t\t\t'\tPrint \" val: \" + Double Ptr Ptr(Byte Ptr Ptr(closure) + 2 + up)[0][0]\n\t\t\tNext\n\t\t\t\n\t\t\t'note that the following OVERWRITE THE PARAMETERS (in release mode), so no touching stk from here on\n\t\t\tByte Ptr Ptr(retptr)[-4] = newBC.mcode\n\t\t\tByte Ptr Ptr(retptr)[-3] = Byte Ptr(newStk)\n\t\t\tByte Ptr Ptr(retptr)[-2] = Byte Ptr(newBC) + BYTECODE_INC\n\t\t\t\n\t\tElseIf fp[1] = BlueTypeTag.NANBOX | BlueTypeTag.NATFUN\n\t\t\t'native call\n\t\tElse\n\t\t\tReturn False\t'not a function; take appropriate action\n\t\tEndIf\n\t\tReturn True\t'all good and will auto-call when the caller returns\n\tEnd Function\n\t\n\tFunction InitOpTbl()\n\t\topc = New BlueOpcode\n\t\topTbl = [MOV, GETLC, SETLC, LOADK, LOADSI, LOADBOOL, LOADNIL, ..\n\t\t\tGETTAB, GETTABSI, SETTAB, SETTABSI, GETTABI, SETTABI, GETUPV, SETUPV, ..\n\t\t\tNEWTAB, CLOSURE, NEWUPV, ..\n\t\t\tADD, SUB, MUL, DIV, NMOD, POW, CAT, ..\n\t\t\tIDIV, BAND, BOR, BXOR, BSHL, BSHR, ..\n\t\t\tUNM, LNOT, ALEN, BNOT, UNP, ..\n\t\t\tEQ, LT, LEQ, ..\n\t\t\tJMP, JIF, JNOT, CALL, TCALL, RETVA, RETVA, ..\t'not a mistake: RET doesn't fit but we need the spacer\n\t\t\tPOSTCALL, VARARG, VAINIT, CALLINIT]\n\t\t\n\t\topTbl[opc.RET] = Byte Ptr(RET)\n\tEnd Function\n\t\n\tFunction Identity:Byte Ptr(b:Byte Ptr)\n\t\tReturn b\n\tEnd Function\n\tFunction PointerToExtType:Byte Ptr(p:Byte Ptr)\t'horrible pointer abuse (increment down so we can ignore the nonexistent vtbl)\n\t\tReturn p - 4'sizeof(Byte Ptr)\n\tEnd Function\n\tGlobal BPtoS:Stack(p:Byte Ptr) = Byte Ptr(BlueJIT.PointerToExtType)\nEnd Type\n\nType BlueLuaVal\n\tField _obj:BlueGCNode\n\n\tMethod Call()\n\tEnd Method\nEnd Type\n\n\nRem\nLocal files:TList = CreateList()\nLocal as:String, ld:String, showHelp:Int, output:String = \"a.out\", doAssemble:Int = 1\nLocal keepAsm:Int, makeExe:Int = 1, asOpts:String, ldOpts:String, showAST:Int, showVersion:Int\n\n?MacOS\nas = \"clang -m32 -c \" ; ld = \"clang -Wl,-no_pie -m32 -read_only_relocs suppress \"\n?Not MacOS\nas = \"gcc -m32 -c \" ; ld = \"gcc -m32 \"\n?\n\nFor Local a:Int = 1 Until AppArgs.Length\n\tSelect AppArgs[a]\n\t\tCase \"-?\", \"--help\"\n\t\t\tshowHelp = 1\n\t\tCase \"-v\"\n\t\t\tshowVersion = 1\n\t\tCase \"-o\"\n\t\t\tIf makeExe = 0\n\t\t\t\tPrint \"warning: -c and -o are mutually exclusive; -c is overruling -o\"\n\t\t\tElse\n\t\t\t\ta :+ 1 ; output = AppArgs[a] ; makeExe = 2\n\t\t\tEndIf\n\t\tCase \"-c\"\n\t\t\tIf makeExe = 2\n\t\t\t\tPrint \"warning: -o and -c are mutually exclusive; -o is overruling -c\"\n\t\t\tElse\n\t\t\t\tdoAssemble = 1 ; makeExe = 0\n\t\t\tEndIf\n\t\tCase \"-s\"\n\t\t\tkeepAsm = 1\n\t\tCase \"-S\"\n\t\t\tkeepAsm = 1 ; doAssemble = 0 ; makeExe = 0\n\t\tCase \"--as\"\n\t\t\ta :+ 1 ; as = AppArgs[a] + \" \"\n\t\tCase \"--ld\"\n\t\t\ta :+ 1 ; ld = AppArgs[a] + \" \"\n\t\tCase \"--as-opt\"\n\t\t\ta :+ 1 ; asOpts :+ AppArgs[a] + \" \"\n\t\tCase \"--ld-opt\"\n\t\t\ta :+ 1 ; ldOpts :+ AppArgs[a] + \" \"\n\t\tCase \"--tree\"\n\t\t\tshowAST = 1 ; makeExe = 0\n\t\tCase \"-w\" ; YBCodeGen.SetWarningLevel 0\n\t\tCase \"--werr\" ; YBCodeGen.SetWarningLevel 2\n\t\tCase \"--warn\" ; YBCodeGen.SetWarningLevel 1\n\t\tDefault\n\t\t\tfiles.AddLast AppArgs[a]\n\tEnd Select\nNext\nIf AppArgs.Length = 1 Then Print \"ybc: no input files\" ; End\n\nIf showVersion Then DisplayVersion\nIf showHelp Then DisplayHelp\n\n?Win32\nLocal rm:String = \"del \/Q \"\n?Not Win32\nLocal rm:String = \"rm \"\n?\n\nLocal allOFiles:String = \"\"\nFor Local file:String = EachIn files\n\tTry\n\t\tLocal tree:TParseNode = YBParseFile(file)\n\t\tIf showAST\n\t\t\tPrint tree.ToString()\n\t\tElse\n\t\t\tYBCodeGen.Build tree\n\t\t\tYBAssembler.Emit file + \".s\", YBCodeGen.syms, YBCodeGen.funs, YBCodeGen.vars, YBCodeGen.strs\n\t\t\tIf doAssemble\n\t\t\t\tsystem_(as + asOpts + file + \".s -o \" + file + \".o\")\n\t\t\t\tallOFiles :+ file + \".o \"\n\t\t\tEndIf\n\t\t\tIf Not keepAsm\n\t\t\t\tsystem_ rm + file + \".s\"\n\t\t\tEndIf\n\t\tEndIf\n\tCatch e:Object\n\t\tPrint \"Compile error:~n \" + e.ToString()\n\t\tPrint \"Compilation halted.\"\n\t\t?Debug\n\t\tThrow e\n\t\t?\n\t\tEnd\n\tEnd Try\nNext\n\n?Linux\nLocal bLib:String = \"b-lib-linux\"\n?Not Linux\nLocal bLib:String = \"b-lib\"\n?\nIf makeExe\n\tIf Not FileType(\"b-lib.o\") Then system_ as + bLib + \".s -o b-lib.o\"\n\tsystem_(ld + ldOpts + \"-o \" + output + \" \" + allOFiles + \" b-lib.o\")\n\tsystem_(rm + allOFiles)\nEndIf\n\nPrint \"done.\"\nEnd\nEnd Rem\nRem\nFunction DisplayVersion()\n\tPrint \"Shadow SIMD Compiler: version 0.0\"\nEnd Function\n\nFunction DisplayHelp()\n\tPrint \"OVERVIEW: ybc compiler for B~n\"\n\tPrint \"USAGE: ybc [options] ~n\"\n\tPrint \"OPTIONS:~n\"\n\tPrint \" -?, --help Display this message\"\n\tPrint \" -v Show the compiler version\"\n\tPrint \" -o Set the name of the output executable (default 'a.out')\"\n\tPrint \" -c Produce separate .o files instead of an executable\"\n\tPrint \" -s Keep text assembly .s files\"\n\tPrint \" -S Only produce text assembly, do not assemble binaries\"\n\tPrint \" --as Set the command to use as the assembler\"\n\tPrint \" --ld Set the command to use as the linker\"\n\tPrint \" --as-opt Add an option to pass to the assembler (can repeat)\"\n\tPrint \" --ld-opt Add an option to pass to the linker (can repeat)\"\n\tPrint \" --tree Display the AST of the program source instead of compiling\"\n\tPrint \" -w Silence warnings\"\n\tPrint \" --werr Convert warnings to errors\"\n\tPrint \" --warn Notify but do not halt on warnings (default)\"\nEnd Function\nEnd Rem\n","old_contents":"\n' Blue Moon\n' an implementation of Lua in pure BlitzMax\n\nSuperStrict\n\n'Framework Brl.Blitz\n'Import Brl.LinkedList\n'Import Brl.Map\n'Import Brl.Reflection\n\nImport \"bluecompiler.bmx\"\nImport \"blueallocator.bmx\"\nImport \"bluetable.bmx\"\nRem\nImport \"blueasm.o\"\nExtern\nFunction ADD:Int(s:Stack, b:Bytecode, r:Byte Ptr) = \"ADD2\"\nFunction EQ:Int(s:Stack, b:Bytecode, r:Byte Ptr) = \"EQ2\"\nFunction GETUPV:Int(s:Stack, b:Bytecode, r:Byte Ptr) = \"GETUPV2\"\nFunction JIF:Int(s:Stack, b:Bytecode, r:Byte Ptr) = \"JIF2\"\nFunction LOADBOOL:Int(s:Stack, b:Bytecode, r:Byte Ptr) = \"LOADBOOL2\"\nFunction LOADK:Int(s:Stack, b:Bytecode, r:Byte Ptr) = \"LOADK2\"\nFunction LOADNIL:Int(s:Stack, b:Bytecode, r:Byte Ptr) = \"LOADNIL2\"\nFunction LOADSI:Int(s:Stack, b:Bytecode, r:Byte Ptr) = \"LOADSI2\"\nFunction MOV:Int(s:Stack, b:Bytecode, r:Byte Ptr) = \"MOV2\"\nFunction NEWUPV:Int(s:Stack, b:Bytecode, r:Byte Ptr) = \"NEWUPV2\"\nFunction SETLC:Int(s:Stack, b:Bytecode, r:Byte Ptr) = \"SETLC2\"\nEnd Extern\nEnd Rem\n'Const file:String = \"tests\/checktable.lua\"\n'Const file:String = \"tests\/mandelbrot.lua\"\n'Const file:String = \"tests\/sieve.lua\"\n'Const file:String = \"tests\/attrib.lua\"\nConst file:String = \"test.lua\"\n\nConst outFile:String = \"out.lua.so\"\n\n\nPrint BlueCompiler.ShowBytecode(file)\n\nRem\nBlueJIT.InitOpTbl()\n'BlueJIT.opTbl[BlueJIT.opc.ADD] = ADD\n'BlueJIT.opTbl[BlueJIT.opc.EQ] = EQ\n'BlueJIT.opTbl[BlueJIT.opc.GETUPV] = GETUPV\n'BlueJIT.opTbl[BlueJIT.opc.JIF] = JIF\n'BlueJIT.opTbl[BlueJIT.opc.LOADBOOL] = LOADBOOL\n'BlueJIT.opTbl[BlueJIT.opc.LOADK] = LOADK\n'BlueJIT.opTbl[BlueJIT.opc.LOADNIL] = LOADNIL\n'BlueJIT.opTbl[BlueJIT.opc.LOADSI] = LOADSI\nBlueJIT.opTbl[BlueJIT.opc.MOV] = MOV\n'BlueJIT.opTbl[BlueJIT.opc.NEWUPV] = NEWUPV\n'BlueJIT.opTbl[BlueJIT.opc.SETLC] = SETLC\nEnd Rem\n\nLocal code:BlueBinary = BlueCompiler.CompileFileForLoad(file)\nLocal vm:BlueVM = New BlueVM\nLocal tl:BlueLuaVal = vm.LoadObjectCode(code)\n'tl.Call()\n\nLocal stk:Stack = BlueJIT.BPtoS(vm.mem.stack)\nstk.retIP = Null ; stk.prevBase = Null\nLocal vc:Int = 10, upvars:Int = 1\nstk.varp = Long Ptr(Byte Ptr(stk) + BlueJIT.STACKFRAME_INC) + upvars\nstk.func = vm.funIndex[0]\n'stk.IP = 0\nstk.argv = Null\t'may want to add space?\nstk.retv = Null\nstk.argc = 0\nstk.retc = 0\n\nPrint \"running...\"\nLocal t:Int = MilliSecs()\nLocal test:Int(_:Byte Ptr) = stk.func.mcode - BlueJIT.PROLOGUESZ ; test(stk)\nt = MilliSecs() - t\nPrint t\nPrint \"run complete\"\n\n\nPrint \"done.\"\nEnd\n\n' notes:\n' - string constants and bytecode are loaded directly into oldSpc, since they'll be needed often\n' - the structure of a bytecode object is:\n' [ machine code ptr ][ id-offset ][ #k ][ #param ][ #upvar ][ frame sz ][ #instrs ][ vm ][ instructions... ][ upvar table... ][ k table... ]\n' initial fields are all 32b; instructions are each 64b; upvar table is pairs of 32b values (level, pos); k table is NaN-box values\n\n' - the structure of a closure object (actual Lua value representing a function) is:\n' [ bytecode ptr ][ upvar values... ]\n\nType BlueVM\n\tField mem:BlueVMMemory, _ENV:BlueLuaVal\n\tField idMod:Int, funIndex:Bytecode Ptr, _fiSz:Int\n\t\n\tMethod New()\n\t\tmem = New BlueVMMemory\n\tEnd Method\n\t\n\t' Load the procedures and constants of a compiled binary into the VM, returning the function representing the program toplevel\n\tMethod LoadObjectCode:BlueLuaVal(code:BlueBinary)\n\t\tLocal buf:Int[] = code.buf\n\t\tLocal fcount:Int = buf[0], kcount:Int = buf[1], ktblpos:Int = buf[2], ktbl:Long[kcount]\n\t\tLocal convert:Byte Ptr(o:Object) = Byte Ptr(BlueJIT.Identity)\n\t\t\n\t\tFor Local k:Int = 0 Until kcount\n\t\t\tLocal koff:Int = buf[ktblpos + k], sz:Int = buf[ktblpos + k + 1] - koff\n\t\t\tIf sz > 2\t'strings have size > 2\n\t\t\t\tLocal length:Double, lp:Int Ptr = Int Ptr(Varptr(length))\n\t\t\t\tlp[0] = buf[koff] ; lp[1] = buf[koff + 1]\n\t\t\t\tLocal s:Byte Ptr = mem.AllocString(length, Short Ptr(Varptr(buf[koff + 2])))\n\t\t\t\tktbl[k] = mem.PtrToVal(s, BlueTypeTag.STR)\n\t\t\tElse\n\t\t\t\tLocal d:Double, dp:Int Ptr = Int Ptr(Varptr(d))\n\t\t\t\tdp[0] = buf[koff] ; dp[1] = buf[koff + 1]\n\t\t\t\tDouble Ptr(Varptr(ktbl[k]))[0] = d\n\t\t\tEndIf\n\t\tNext\n\t\t\n\t\tExtendFunIndex(idMod + fcount)\n\t\tFor Local f:Int = 0 Until fcount\n\t\t\tLocal foff:Int = buf[3 + f]\n\t\t\tLocal ic:Int = buf[foff + 1], kc:Int = buf[foff + 2], pc:Int = buf[foff + 3], uc:Int = buf[foff + 5], fsz:Int = buf[foff + 6]\n\t\t\t\n\t\t\tLocal b:Bytecode = BPtoBC(mem.AllocObjectOldSpace(mem.oldStrSpace, (8 + 2 * (uc + uc Mod 2) + 2 * kc + 2 * ic) * 4, BlueTypeTag.BCODE))\n\t\t\tb.idMod = idMod ; b.kcount = kc ; b.pcount = pc ; b.upvars = uc + (uc Mod 2)\t'round up for alignment\n\t\t\tb.frameSz = BlueJIT.STACKFRAMESZ + b.upvars * 8 + fsz * 8 ; b.icount = ic ; b.vm = convert(Self)\n\t\t\t\n\t\t\tLocal ib:Int Ptr = Int Ptr(Byte Ptr(b) + 4) + 8 + 2 * ic\n\t\t\tFor Local u:Int = 0 Until uc\n\t\t\t\tLocal uoff:Int = 7 + u * 2\n\t\t\t\tib[u * 2] = buf[foff + uoff] ; ib[u * 2 + 1] = buf[foff + uoff + 1]\n\t\t\tNext\n\t\t\tIf uc <> b.upvars\t'ensure padding is safe by copying the first one\n\t\t\t\tib[uc * 2] = buf[foff + 7] ; ib[uc * 2 + 1] = buf[foff + 7 + 1]\n\t\t\tEndIf\n\t\t\t\n\t\t\tLocal db:Long Ptr = Long Ptr(ib + 2 * b.upvars)\n\t\t\tFor Local k:Int = 0 Until kc\n\t\t\t\tdb[k] = ktbl[buf[foff + 7 + uc * 2 + k]]\n\t\t\tNext\n\t\t\t\n\t\t\tLocal ioff:Int = 7 + 2 * uc + kc ; ib = Int Ptr(Byte Ptr(b) + BlueJIT.BYTECODE_INC)\n\t\t\t\n\t\t\tFor Local i:Int = 0 Until ic * 2\n\t\t\t\tib[i] = buf[foff + ioff + i]\n\t\t\tNext\n\t\t\t\n\t\t\tb.mcode = BlueJIT.Compile(Self, ib, ic, b) + BlueJIT.PROLOGUESZ\n\t\t\tfunIndex[idMod + f] = b\n\t\tNext\n\t\t\n\t\tidMod :+ fcount\n\t\tReturn New BlueLuaVal\n\tEnd Method\n\t\n\tMethod ExtendFunIndex(sz:Int)\t'hack: BlitzMax has a bug with arrays of extern types! so we need to use C-style arrays for now\n\t\tLocal newFI:Bytecode Ptr = Bytecode Ptr(MemAlloc(sz * 4))\n\t\tIf _fiSz\n\t\t\tFor Local b:Int = 0 Until _fiSz\n\t\t\t\tnewFI[b] = funIndex[b]\n\t\t\tNext\n\t\t\tMemFree(funIndex)\n\t\t\tFor Local b:Int = _fiSz Until sz\n\t\t\t\tnewFI[b] = Null\n\t\t\tNext\n\t\tEndIf\n\t\tfunIndex = newFI ; _fiSz = sz\n\tEnd Method\n\t\n\tMethod CallToLua()\n\tEnd Method\n\t\n\tGlobal BPtoBC:Bytecode(p:Byte Ptr) = Byte Ptr(BlueJIT.PointerToExtType)\nEnd Type\n\nPrivate\nExtern\n\tType Stack\n\t\tField retIP:Byte Ptr, prevBase:Stack, varp:Long Ptr, func:Bytecode, _:Long Ptr, argv:Long Ptr, retv:Long Ptr, argc:Short, retc:Short\n\tEnd Type\n\tType Bytecode\n\t\tField mcode:Byte Ptr, idMod:Int, kcount:Int, pcount:Int, upvars:Int, frameSz:Int, icount:Int, vm:Byte Ptr\n\tEnd Type\nEnd Extern\nPublic\n\nType BlueJIT Final\n\tConst PROLOGUESZ:Int = 25, ISIZE:Int = 5\n\t\n\tGlobal opTbl:Int(s:Stack, b:Bytecode, r:Byte Ptr)[], opc:BlueOpcode\n\tGlobal Prologue:Int[] = [ ..\n\t\t$90, $90, ..\n\t\t$8b, $44, $24, $04, .. 'mov 4(%esp), %eax\n\t\t$89, $44, $24, $f4, .. 'mov %eax, -12(%esp)\n\t\t$c7, $44, $24, $f8, $FF, $FF, $FF, $FF, .. 'movl ########, -8(%esp)\n\t\t$89, $64, $24, $fc, .. 'mov %esp, -4(%esp)\n\t\t$83, $ec, $0c.. 'sub $12, %esp\n\t]\n\t\n\tFunction Compile:Byte Ptr(vm:BlueVM, ins:Byte Ptr, icount:Int, bytecode:Bytecode)\n\t\t?Not x86\n\t\tRuntimeError \"The Blue Moon JIT does not support your platform (x86-32 only at this time)\"\n\t\t?\n\t\tAssert SizeOf(0:Long) = SizeOf(0:Double) And SizeOf(0:Int) = 4 And SizeOf(0:Long) = 8 And SizeOf(Byte Ptr(0)) = 4, ..\n\t\t\t\"assumptions about platform datatype sizes are invalid\"\n\t\t\n\t\tIf opTbl = Null Then InitOpTbl()\n\t\t\n\t\tLocal sz:Int = PROLOGUESZ + icount * ISIZE\n\t\t\n\t\t' allocate executable space\n\t\tLocal blocks:Int[] = vm.mem.AllocCodeBlock(PROLOGUESZ + icount * ISIZE)\n\t\tLocal code:Byte Ptr = Byte Ptr(blocks[0]), rsize:Int = blocks[1] - (blocks[1] Mod ISIZE)\n\t\t\n\t\tFor Local p:Int = 0 Until PROLOGUESZ\t'emplace prologue (used for calling in from native only)\n\t\t\tcode[p] = Prologue[p]\n\t\tNext\n\t\tByte Ptr Ptr(code + 14)[0] = Byte Ptr(bytecode)\t'replace the ########\n\t\tcode :+ PROLOGUESZ ; rsize :- PROLOGUESZ\t'easier to not have to take this into account below\n\t\t\n\t\tLocal codePage:Int Ptr = Int Ptr(Int(code) & ((Int(2^12)-1) Shl 20))\t'return-to-native for the page\n\t\tcodePage[1] = $c30cc483\t'add $12, %esp ; ret - i.e. restore the stack to normal\n\t\t\n\t\t' generate machine code!\n\t\tRepeat\n\t\t\t\n\t\t\tFor Local i:Int = 0 Until rsize \/ ISIZE\t'emplace opcode calls and supporting bytecode data\n\t\t\t\tLocal codep:Byte Ptr = code + i * ISIZE, bytecodep:Byte Ptr = Byte Ptr(Int(codep) + vm.mem.PAGESZ)\n\t\t\t\tcodep[0] = $e8\t'call\n\t\t\t\tLocal bi:Int = i * 8, op:Int = ins[bi], ip:Int Ptr = Int Ptr(ins + bi), func:Byte Ptr = opTbl[op]\n\t\t\t\tByte Ptr Ptr(codep + 1)[0] = func - Int(codep + ISIZE)\n\t\t\t\t\n\t\t\t\tSelect op\n\t\t\t\t\tCase opc.LOADSI, opc.CLOSURE, opc.RET, opc.POSTCALL\n\t\t\t\t\t\tbytecodep[0] = ins[bi + 1] ; Int Ptr(bytecodep + 1)[0] = Int Ptr(ins + bi)[1]\n\t\t\t\t\t\t\n\t\t\t\t\tCase opc.LOADK\n\t\t\t\t\t\tLocal kp:Double Ptr = Double Ptr(ins + 8 * bytecode.icount + 8 * bytecode.upvars) + ip[1]\n\t\t\t\t\t\tbytecodep[0] = ins[bi + 1] ; Double Ptr Ptr(bytecodep + 1)[0] = kp\n\t\t\t\t\t\t\n\t\t\t\t\tCase opc.SETTABSI, opc.GETTABSI\n\t\t\t\t\t\tbytecodep[0] = ins[bi + 1] ; bytecodep[1] = ins[bi + 2]\n\t\t\t\t\t\tShort Ptr(bytecodep)[1] = Int Ptr(ins + bi)[1]\n\t\t\t\t\t\t\n\t\t\t\t\tCase opc.CALL\n\t\t\t\t\t\tbytecodep[0] = ins[bi + 1] ; bytecodep[1] = ins[bi + 2]\n\t\t\t\t\t\tShort Ptr(bytecodep)[1] = Int Ptr(ins + bi)[1]\n\t\t\t\t\t\t\n\t\t\t\t\tCase opc.JIF, opc.JNOT\n\t\t\t\t\t\tbytecodep[0] = ins[bi + 1]\n\t\t\t\t\t\tInt Ptr(bytecodep + 1)[0] = Int(codep) + ISIZE * Int Ptr(ins + bi)[1]\n\t\t\t\t\t\t\n\t\t\t\t\tCase opc.JMP\n\t\t\t\t\t\tcodep[0] = $e9\t'use a true jump\n\t\t\t\t\t\tInt Ptr(codep + 1)[0] = ISIZE * (Int Ptr(ins + bi)[1] - 1)\n\t\t\t\t\t\t\n\t\t\t\t\tDefault\t'binary operations A = B op C\n\t\t\t\t\t\tbytecodep[0] = ins[bi + 1] ; bytecodep[1] = ins[bi + 2] ; bytecodep[2] = Int Ptr(ins + bi)[1]\n\t\t\t\tEnd Select\n\t\t\tNext\n\t\t\t\n\t\t\tExit\t'deal with overflowing code sections here\n\t\tForever\n\t\t\n\t\tReturn code - PROLOGUESZ\n\tEnd Function\n\t\n\t\n\tConst STACKFRAMESZ:Int = 8 * 4, BYTECODESZ:Int = 8 * 4, STACKFRAME_INC:Int = STACKFRAMESZ + 4, BYTECODE_INC:Int = BYTECODESZ + 4\n\tConst IP_OFFSET:Int = BlueVMMemory.PAGESZ - ISIZE\n\t\n\t\n\t'note: extern vars must take into account the vtbl offset, so that converting from a typed pointer can be a simple cast (faster)\t\n\t\n\tFunction MOV(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"MOV \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tvarp[rp[0]] = varp[rp[1]]\t'assigning through Double is unsafe as it can corrupt the bit pattern\n\tEnd Function\n\tFunction GETLC(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction SETLC(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"SETLC \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\t'add a write barrier here\n\t\tLong Ptr Ptr(varp + rp[0])[0][0] = varp[rp[1]]\n\tEnd Function\n\tFunction LOADK(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"LOADK \/\/\"\n\t\tLocal rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET, varp:Long Ptr = stk.varp + rp[0], kp:Long Ptr = Long Ptr Ptr(rp + 1)[0]\n\t\tvarp[0] = kp[0]\n\tEnd Function\n\tFunction LOADSI(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"LOADSI \/\/\"\n\t\tLocal rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal val:Int = Int Ptr(rp + 1)[0]\n\t\tDouble Ptr(stk.varp)[rp[0]] = Double(val)\n\tEnd Function\n\tFunction LOADBOOL(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"LOADBOOL \/\/\"\n\t\tLocal rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET, vp:Int Ptr = Int Ptr(stk.varp + rp[0])\n\t\tvp[1] = BlueTypeTag.NANBOX | BlueTypeTag.BOOL\n\t\tvp[0] = Int Ptr(rp + 1)[0]\n\tEnd Function\n\tFunction LOADNIL(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"LOADNIL \/\/\"\n\t\tLocal rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tInt Ptr(stk.varp + rp[0])[1] = BlueTypeTag.NANBOX | BlueTypeTag.NIL\n\tEnd Function\n\t\n\tFunction GETTAB(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction GETTABSI(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction SETTAB(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction SETTABSI(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t\tPrint \"SETTABSI \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal convert:BlueVM(p:Byte Ptr) = Byte Ptr(Identity), vm:BlueVM = convert(bc.vm)\n\t\tLocal tabp:Byte Ptr = varp + rp[0]\n\t\tPrint \" \" + Short Ptr(rp)[1]\n\t\tLocal key:Long ; Double Ptr(Varptr(key))[0] = Short Ptr(rp)[1]\n\t\tBlueTable.Set(vm.mem, Byte Ptr Ptr(tabp)[0], key, varp[rp[1]])\n\tEnd Function\n\tFunction GETTABI(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t\tPrint \"GETTABI \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal tabp:Byte Ptr = varp + rp[1]\n\t\tPrint \" tag: \" + Bin(Int Ptr(varp + rp[2])[1])\n\t\tLocal val:Long = BlueTable.Get(Byte Ptr Ptr(tabp)[0], varp[rp[2]])\n\t\tLocal v:Double = Double Ptr(Varptr(val))[0]\n\t\tPrint \" \" + v\n\t\tvarp[rp[0]] = val\n\tEnd Function\n\tFunction SETTABI(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t\tPrint \"SETTABI \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal convert:BlueVM(p:Byte Ptr) = Byte Ptr(Identity), vm:BlueVM = convert(bc.vm)\n\t\tLocal tabp:Byte Ptr = varp + rp[0]\n\t\tPrint \" \" + Double Ptr(varp)[rp[2]] + \" \" + Double Ptr(varp)[rp[1]]\n\t\tPrint \" tag: \" + Bin(Int Ptr(varp + rp[2])[1])\n\t\tBlueTable.Set(vm.mem, Byte Ptr Ptr(tabp)[0], varp[rp[2]], varp[rp[1]])\n\tEnd Function\n\tFunction GETUPV(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"GETUPV \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, upvp:Byte Ptr Ptr = Byte Ptr Ptr(Byte Ptr(stk) + STACKFRAME_INC)\n\t\tLocal rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET, valp:Long Ptr = Long Ptr(upvp[rp[1]])\n\t\tvarp[rp[0]] = valp[0]\n\tEnd Function\n\tFunction SETUPV(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction NEWTAB(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t\tPrint \"NEWTAB \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal convert:BlueVM(p:Byte Ptr) = Byte Ptr(Identity), vm:BlueVM = convert(bc.vm)\n\t\tLocal tab:Byte Ptr = vm.mem.AllocTable(Null)\n\t\tLocal d:Int Ptr = Int Ptr(varp + rp[0])\n\t\td[0] = Int(tab) ; d[1] = BlueTypeTag.NANBOX | BlueTypeTag.TBL\n\tEnd Function\n\tFunction CLOSURE(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"CLOSURE \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal convert:BlueVM(p:Byte Ptr) = Byte Ptr(Identity), vm:BlueVM = convert(bc.vm)\n\t\tLocal d:Int Ptr = Int Ptr(varp + rp[0])\n\t\tLocal cbytecode:Bytecode = vm.funIndex[Int Ptr(rp + 1)[0]], upvp:Int Ptr = Int Ptr(Byte Ptr(cbytecode) + BYTECODE_INC + 8 * cbytecode.icount)\n\t\tLocal closure:Byte Ptr = vm.mem.AllocClosure(cbytecode, cbytecode.upvars)\t'upvars is always even (alignment)\n\t\t\n\t\t'get upvalues off the stack\n\t\tFor Local u:Int = 0 Until cbytecode.upvars\n\t\t\tIf upvp[2 * u]\n\t\t\t\tByte Ptr Ptr(closure)[2 + u] = Byte Ptr Ptr(Byte Ptr(stk) + STACKFRAME_INC)[upvp[2 * u + 1]]\n\t\t\tElse\n\t\t\t\tByte Ptr Ptr(closure)[2 + u] = Byte Ptr Ptr(varp + upvp[2 * u + 1])[0]\n\t\t\tEndIf\n\t\tNext\n\t\t\n\t\td[0] = Int(closure) ; d[1] = BlueTypeTag.NANBOX | BlueTypeTag.FUN\n\tEnd Function\n\tFunction NEWUPV(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"NEWUPV \/\/\"\n\t\tLocal rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal convert:BlueVM(p:Byte Ptr) = Byte Ptr(Identity), vm:BlueVM = convert(bc.vm)\n\t\tLocal upv:Byte Ptr = vm.mem.AllocObject(8, BlueTypeTag.UPV), d:Int Ptr = Int Ptr(stk.varp + rp[0])\n\t\tLong Ptr(upv)[0] = Long Ptr(d)[0]\t'promote a value if it existed (useful for parameters)\n\t\td[0] = Int(upv) ; d[1] = BlueTypeTag.NANBOX | BlueTypeTag.UPV\n\tEnd Function\n\t\n\tFunction ADD(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t\tPrint \"ADD \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal d:Double Ptr = Double Ptr(varp + rp[0])\n\t\tLocal r:Int Ptr = Int Ptr(varp + rp[1]), l:Int Ptr = Int Ptr(varp + rp[2])\n\t\tIf l[1] & BlueTypeTag.NANBOX_CHK = BlueTypeTag.NANBOX Or r[1] & BlueTypeTag.NANBOX_CHK = BlueTypeTag.NANBOX\n\t\t\tDebugStop\n\t\tElse\n\t\t\tPrint \" \" + Double Ptr(l)[0] + \" \" + Double Ptr(r)[0]\n\t\t\td[0] = Double Ptr(l)[0] + Double Ptr(r)[0]\n\t\tEndIf\n\tEnd Function\n\tFunction SUB(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction MUL(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction DIV(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction NMOD(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction POW(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction CAT(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction IDIV(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction BAND(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction BOR(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction BXOR(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction BSHL(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction BSHR(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction UNM(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction LNOT(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction ALEN(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction BNOT(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction UNP(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction EQ(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"EQ \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = (Byte Ptr Ptr(retptr) - 4)[0] + IP_OFFSET\n\t\tLocal r:Double = Double Ptr(varp)[rp[1]]\n\t\tLocal l:Double = Double Ptr(varp)[rp[2]]\n\t\tInt Ptr(varp + rp[0])[0] = l = r\n\tEnd Function\n\tFunction LT(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction LEQ(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\t\n\tFunction JMP(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t\tPrint \"wait, why are we here?\"\n\tEnd Function\n\tFunction JIF(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"JIF \/\/\"\n\t\tLocal rp:Byte Ptr = (Byte Ptr Ptr(retptr) - 4)[0] + IP_OFFSET\n\t\tIf Int Ptr(stk.varp + rp[0])[0]\n\t\t\tLocal target:Int = Int Ptr(rp + 1)[0]\n\t\t\tInt Ptr(retptr)[-4] = target\n\t\tEndIf\n\tEnd Function\n\tFunction JNOT(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction CALL(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"CALL \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal fp:Int Ptr = Int Ptr(varp + rp[0])\n\t\tIf Not PrepareCall(fp, stk, rp, varp, retptr)\t'PrepareCall sets everything up so there's nothing else to do to make the call happen\n\t\t\t'__call metamethod\n\t\tEndIf\n\tEnd Function\n\tFunction TCALL(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction RET:Byte Ptr(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"RET \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp\n\t\tLocal rp0:Byte Ptr = Byte Ptr Ptr(retptr)[-4], rp:Byte Ptr = rp0 + IP_OFFSET\n\t\t\n\t\tLocal oldStk:Stack = stk.prevBase\n\t\tLocal retv:Long Ptr = varp + rp[0]\n\t\tIf oldStk\n\t\t\toldStk.retv = retv\n\t\t\toldStk.retc = Int Ptr(rp + 1)[0]\n\t\t\tByte Ptr Ptr(retptr)[-4] = stk.retIP\n\t\t\tByte Ptr Ptr(retptr)[-3] = Byte Ptr(oldStk)\n\t\t\tByte Ptr Ptr(retptr)[-2] = Byte Ptr(oldStk.func) + BYTECODE_INC\n\t\tElse\t'return to native code\n\t\t\tLocal codePage:Byte Ptr = Byte Ptr(Int(rp0) & ((Int(2^12)-1) Shl 20))\n\t\t\tByte Ptr Ptr(retptr)[-4] = codePage + 4\n\t\t\tReturn retv\n\t\tEndIf\n\tEnd Function\n\tFunction RETVA(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction POSTCALL(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"POSTCALL \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp\n\t\tLocal rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\t\n\t\tFor Local r:Int = 0 Until Min(Int Ptr(rp + 1)[0], stk.retc)\n\t\t\t(varp + rp[0])[r] = stk.retv[r]\n\t\t'\tPrint \" return \" + r + \": \" + Double Ptr(stk.retv)[r]\n\t\tNext\n\tEnd Function\n\tFunction VARARG(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction VAINIT(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction CALLINIT(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\t\n\t\n\tFunction PrepareCall:Int(fp:Int Ptr, stk:Stack, rp:Byte Ptr, varp:Long Ptr, retptr:Byte Ptr)\n\t\tIf fp[1] = BlueTypeTag.NANBOX | BlueTypeTag.FUN\n\t\t\tLocal newStk0:Stack ; Byte Ptr Ptr(Varptr(newStk0))[0] = Byte Ptr(stk) + stk.func.frameSz\n\t\t\tLocal newStk:Stack = newStk0\t'micro-opt: newStk0 can't be a register because of the unwieldy conversion\n\t\t\t\n\t\t\tnewStk.retIP = Byte Ptr Ptr(retptr)[-4]\n\t\t\tnewStk.prevBase = stk\n\t\t\tLocal closure:Byte Ptr = Byte Ptr(fp[0])\n\t\t\tLocal newBC:Bytecode = Bytecode Ptr(closure)[0]\n\t\t\tLocal voff:Int = STACKFRAME_INC + 4 * newBC.upvars\n\t\t\tnewStk.varp = Long Ptr(Byte Ptr(newStk) + voff)\n\t\t\tnewStk.func = newBC\n\t\t'\tnewStk._IP = 0\n\t\t\t\n\t\t\tLocal argc_actual:Int = Short Ptr(rp)[1], argc_required:Int = newBC.pcount\n\t\t'\tLocal argc_min:Int ; If argc_actual < argc_required Then argc_min = argc_actual Else argc_min = argc_required\n\t\t\tLocal argc_min:Int = argc_actual - argc_required ; argc_min = (argc_min & (argc_min Shr 31)) + argc_required 'branchless 32-bit Min\n\t\t\t\n\t\t\tLocal argv:Long Ptr = varp + rp[1], destv:Long Ptr = newStk.varp\n\t\t\tFor Local a:Int = 0 Until argc_min\n\t\t\t\tdestv[a] = argv[a]\n\t\t\t'\tPrint \" arg \" + a + \": \" + argv[a]\n\t\t\tNext\n\t\t\tFor Local a:Int = argc_min Until argc_required\t'nil any unfilled parameters\n\t\t\t\tInt Ptr(destv + a)[1] = BlueTypeTag.NANBOX | BlueTypeTag.NIL\n\t\t\tNext\n\t\t\tnewStk.argv = argv + argc_min\t'argv should be to the varargs (if any)\n\t\t\tnewStk.argc = argc_actual - argc_min\t'argc is the number of varargs\n\t\t\t\n\t\t\tLocal destup:Byte Ptr Ptr = Byte Ptr Ptr(Byte Ptr(newStk) + STACKFRAME_INC)\n\t\t\tLocal upv:Byte Ptr Ptr = Byte Ptr Ptr(closure + 8)\n\t\t\tFor Local up:Int = 0 Until newBC.upvars\t'emplace upvars\n\t\t\t\tdestup[up] = upv[up]\n\t\t\t'\tPrint \" upv \" + up + \": \" + destv[up]\n\t\t\t'\tPrint \" val: \" + Double Ptr Ptr(Byte Ptr Ptr(closure) + 2 + up)[0][0]\n\t\t\tNext\n\t\t\t\n\t\t\t'note that the following OVERWRITE THE PARAMETERS (in release mode), so no touching stk from here on\n\t\t\tByte Ptr Ptr(retptr)[-4] = newBC.mcode\n\t\t\tByte Ptr Ptr(retptr)[-3] = Byte Ptr(newStk)\n\t\t\tByte Ptr Ptr(retptr)[-2] = Byte Ptr(newBC) + BYTECODE_INC\n\t\t\t\n\t\tElseIf fp[1] = BlueTypeTag.NANBOX | BlueTypeTag.NATFUN\n\t\t\t'native call\n\t\tElse\n\t\t\tReturn False\t'not a function; take appropriate action\n\t\tEndIf\n\t\tReturn True\t'all good and will auto-call when the caller returns\n\tEnd Function\n\t\n\tFunction InitOpTbl()\n\t\topc = New BlueOpcode\n\t\topTbl = [MOV, GETLC, SETLC, LOADK, LOADSI, LOADBOOL, LOADNIL, ..\n\t\t\tGETTAB, GETTABSI, SETTAB, SETTABSI, GETTABI, SETTABI, GETUPV, SETUPV, ..\n\t\t\tNEWTAB, CLOSURE, NEWUPV, ..\n\t\t\tADD, SUB, MUL, DIV, NMOD, POW, CAT, ..\n\t\t\tIDIV, BAND, BOR, BXOR, BSHL, BSHR, ..\n\t\t\tUNM, LNOT, ALEN, BNOT, UNP, ..\n\t\t\tEQ, LT, LEQ, ..\n\t\t\tJMP, JIF, JNOT, CALL, TCALL, RETVA, RETVA, ..\t'not a mistake: RET doesn't fit but we need the spacer\n\t\t\tPOSTCALL, VARARG, VAINIT, CALLINIT]\n\t\t\n\t\topTbl[opc.RET] = Byte Ptr(RET)\n\tEnd Function\n\t\n\tFunction Identity:Byte Ptr(b:Byte Ptr)\n\t\tReturn b\n\tEnd Function\n\tFunction PointerToExtType:Byte Ptr(p:Byte Ptr)\t'horrible pointer abuse (increment down so we can ignore the nonexistent vtbl)\n\t\tReturn p - 4'sizeof(Byte Ptr)\n\tEnd Function\n\tGlobal BPtoS:Stack(p:Byte Ptr) = Byte Ptr(BlueJIT.PointerToExtType)\nEnd Type\n\nType BlueLuaVal\n\tField _obj:BlueGCNode\n\n\tMethod Call()\n\tEnd Method\nEnd Type\n\n\nRem\nLocal files:TList = CreateList()\nLocal as:String, ld:String, showHelp:Int, output:String = \"a.out\", doAssemble:Int = 1\nLocal keepAsm:Int, makeExe:Int = 1, asOpts:String, ldOpts:String, showAST:Int, showVersion:Int\n\n?MacOS\nas = \"clang -m32 -c \" ; ld = \"clang -Wl,-no_pie -m32 -read_only_relocs suppress \"\n?Not MacOS\nas = \"gcc -m32 -c \" ; ld = \"gcc -m32 \"\n?\n\nFor Local a:Int = 1 Until AppArgs.Length\n\tSelect AppArgs[a]\n\t\tCase \"-?\", \"--help\"\n\t\t\tshowHelp = 1\n\t\tCase \"-v\"\n\t\t\tshowVersion = 1\n\t\tCase \"-o\"\n\t\t\tIf makeExe = 0\n\t\t\t\tPrint \"warning: -c and -o are mutually exclusive; -c is overruling -o\"\n\t\t\tElse\n\t\t\t\ta :+ 1 ; output = AppArgs[a] ; makeExe = 2\n\t\t\tEndIf\n\t\tCase \"-c\"\n\t\t\tIf makeExe = 2\n\t\t\t\tPrint \"warning: -o and -c are mutually exclusive; -o is overruling -c\"\n\t\t\tElse\n\t\t\t\tdoAssemble = 1 ; makeExe = 0\n\t\t\tEndIf\n\t\tCase \"-s\"\n\t\t\tkeepAsm = 1\n\t\tCase \"-S\"\n\t\t\tkeepAsm = 1 ; doAssemble = 0 ; makeExe = 0\n\t\tCase \"--as\"\n\t\t\ta :+ 1 ; as = AppArgs[a] + \" \"\n\t\tCase \"--ld\"\n\t\t\ta :+ 1 ; ld = AppArgs[a] + \" \"\n\t\tCase \"--as-opt\"\n\t\t\ta :+ 1 ; asOpts :+ AppArgs[a] + \" \"\n\t\tCase \"--ld-opt\"\n\t\t\ta :+ 1 ; ldOpts :+ AppArgs[a] + \" \"\n\t\tCase \"--tree\"\n\t\t\tshowAST = 1 ; makeExe = 0\n\t\tCase \"-w\" ; YBCodeGen.SetWarningLevel 0\n\t\tCase \"--werr\" ; YBCodeGen.SetWarningLevel 2\n\t\tCase \"--warn\" ; YBCodeGen.SetWarningLevel 1\n\t\tDefault\n\t\t\tfiles.AddLast AppArgs[a]\n\tEnd Select\nNext\nIf AppArgs.Length = 1 Then Print \"ybc: no input files\" ; End\n\nIf showVersion Then DisplayVersion\nIf showHelp Then DisplayHelp\n\n?Win32\nLocal rm:String = \"del \/Q \"\n?Not Win32\nLocal rm:String = \"rm \"\n?\n\nLocal allOFiles:String = \"\"\nFor Local file:String = EachIn files\n\tTry\n\t\tLocal tree:TParseNode = YBParseFile(file)\n\t\tIf showAST\n\t\t\tPrint tree.ToString()\n\t\tElse\n\t\t\tYBCodeGen.Build tree\n\t\t\tYBAssembler.Emit file + \".s\", YBCodeGen.syms, YBCodeGen.funs, YBCodeGen.vars, YBCodeGen.strs\n\t\t\tIf doAssemble\n\t\t\t\tsystem_(as + asOpts + file + \".s -o \" + file + \".o\")\n\t\t\t\tallOFiles :+ file + \".o \"\n\t\t\tEndIf\n\t\t\tIf Not keepAsm\n\t\t\t\tsystem_ rm + file + \".s\"\n\t\t\tEndIf\n\t\tEndIf\n\tCatch e:Object\n\t\tPrint \"Compile error:~n \" + e.ToString()\n\t\tPrint \"Compilation halted.\"\n\t\t?Debug\n\t\tThrow e\n\t\t?\n\t\tEnd\n\tEnd Try\nNext\n\n?Linux\nLocal bLib:String = \"b-lib-linux\"\n?Not Linux\nLocal bLib:String = \"b-lib\"\n?\nIf makeExe\n\tIf Not FileType(\"b-lib.o\") Then system_ as + bLib + \".s -o b-lib.o\"\n\tsystem_(ld + ldOpts + \"-o \" + output + \" \" + allOFiles + \" b-lib.o\")\n\tsystem_(rm + allOFiles)\nEndIf\n\nPrint \"done.\"\nEnd\nEnd Rem\nRem\nFunction DisplayVersion()\n\tPrint \"Shadow SIMD Compiler: version 0.0\"\nEnd Function\n\nFunction DisplayHelp()\n\tPrint \"OVERVIEW: ybc compiler for B~n\"\n\tPrint \"USAGE: ybc [options] ~n\"\n\tPrint \"OPTIONS:~n\"\n\tPrint \" -?, --help Display this message\"\n\tPrint \" -v Show the compiler version\"\n\tPrint \" -o Set the name of the output executable (default 'a.out')\"\n\tPrint \" -c Produce separate .o files instead of an executable\"\n\tPrint \" -s Keep text assembly .s files\"\n\tPrint \" -S Only produce text assembly, do not assemble binaries\"\n\tPrint \" --as Set the command to use as the assembler\"\n\tPrint \" --ld Set the command to use as the linker\"\n\tPrint \" --as-opt Add an option to pass to the assembler (can repeat)\"\n\tPrint \" --ld-opt Add an option to pass to the linker (can repeat)\"\n\tPrint \" --tree Display the AST of the program source instead of compiling\"\n\tPrint \" -w Silence warnings\"\n\tPrint \" --werr Convert warnings to errors\"\n\tPrint \" --warn Notify but do not halt on warnings (default)\"\nEnd Function\nEnd Rem\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"3a05af6b94aa32dc715bcabf5ca46a8e4c804628","subject":"update had the wrong description","message":"update had the wrong description\n","repos":"maximos\/maximus","old_file":"src\/impl\/help.bmx","new_file":"src\/impl\/help.bmx","new_contents":"","old_contents":"","returncode":0,"stderr":"unknown","license":"mit","lang":"BlitzMax"} {"commit":"e9861aba95bf73276cb5a58ba56b56bcebac8123","subject":"Incremented version number to 0.9b. Added LUGI_VERSION_* integers to compare again (e.g., for things like Assert LUGI_VERSION_NUMBER >= LUGI_VERSION_0_9_0B Else \"Must use LuGI 0.9b or later\") - these don't work in 0.8.02, obviously, but I'm willing to accept that.","message":"Incremented version number to 0.9b. Added LUGI_VERSION_* integers to compare again (e.g., for things like Assert LUGI_VERSION_NUMBER >= LUGI_VERSION_0_9_0B Else \"Must use LuGI 0.9b or later\") - these don't work in 0.8.02, obviously, but I'm willing to accept that.","repos":"nilium\/lugi.mod,nilium\/lugi.mod","old_file":"core.mod\/core.bmx","new_file":"core.mod\/core.bmx","new_contents":"Rem\n\tLuGI - Copyright (c) 2009 Noel R. Cower\n\n\tPermission is hereby granted, free of charge, to any person obtaining a copy\n\tof this software and associated documentation files (the \"Software\"), to deal\n\tin the Software without restriction, including without limitation the rights\n\tto use, copy, modify, merge, publish, distribute, sublicense, and\/or sell\n\tcopies of the Software, and to permit persons to whom the Software is\n\tfurnished to do so, subject to the following conditions:\n\n\tThe above copyright notice and this permission notice shall be included in\n\tall copies or substantial portions of the Software.\n\n\tTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n\tIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n\tFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n\tAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n\tLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n\tOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n\tTHE SOFTWARE.\nEndRem\n\nSuperStrict\n\nModule LuGI.Core\n\nModuleInfo \"Name: LuGI Core\"\nModuleInfo \"Description: Core API provided by LuGI to interact with BMax objects via Lua\"\nModuleInfo \"Version: 0.9b\"\nModuleInfo \"Author: Noel Cower\"\nModuleInfo \"License: MIT\"\nModuleInfo \"URL: http:\/\/github.com\/nilium\/lugi.mod\/<\/a>\"\n\n?Threaded\nImport Brl.Threads\n?\nImport Brl.Reflection\nImport Brl.LinkedList\nImport Pub.Lua\nImport \"lgcore.cpp\"\n\nPublic\n\n' Version information\nConst LUGI_VERSION_0_8_2:Int = 00800200\nConst LUGI_VERSION_0_9_0B:Int = 00900002\nConst LUGI_VERSION_NUMBER:Int = 00900002 ' MMmmrrxx where xxx will be any arbitrary digits I assign.\nConst LUGI_VERSION:String = \"0.9b\"\n\n' LuGI field types - used by LuGI to determine how to access fields at runtime\n' The only reason these are public is because the generated code uses them, otherwise I'd hide\n' them away too. But then if I hide them and use number constants in the generated code, we'll\n' get the chance that changing these later will break existing glue code, and doing that is bad.\nConst LUGI_BYTEFIELD:Int = $0001\nConst LUGI_SHORTFIELD:Int = $0002\nConst LUGI_INTFIELD:Int = $0004\nConst LUGI_FLOATFIELD:Int = $0008\nConst LUGI_LONGFIELD:Int = $0010\nConst LUGI_DOUBLEFIELD:Int = $0020\nConst LUGI_STRINGFIELD:Int = $0040\nConst LUGI_OBJECTFIELD:Int = $0080\nConst LUGI_ARRAYFIELD:Int = $0100\n' Optional flag to specify that an integer field (Int, Short, Byte, or Long) should be treated as a\n' boolean value when passed to Lua\nConst LUGI_BOOLFIELDOPT:Int = $8000\n\nType LuGIInitFunction\n\t\n\t' Registers the callback provided as a pre-init stage routine\n\tMethod PreInit:LuGIInitFunction(cb(vm:Byte Ptr, rfield(off%, typ%, name$, clas@ Ptr), rmethod(fn:Int(state@ Ptr), name$, clas@ Ptr)), requiresState%=True)\n\t\t_cb = cb\n\t\t_reqState = requiresState\n\t\t?Threaded\n\t\tp_lugi_initlock.Lock()\n\t\t?\n\t\tIf p_lugi_preinit_cb = Null Then\n\t\t\tp_lugi_preinit_cb = New TList\n\t\tEndIf\n\t\tp_lugi_preinit_cb.AddLast(Self)\n\t\t?Threaded\n\t\tp_lugi_initlock.Unlock()\n\t\t?\n\t\tReturn Self\n\tEnd Method\n\t\n\t' Registers the callback provided as a post-init stage routine\n\tMethod PostInit:LuGIInitFunction(cb(state:Byte Ptr, constructor:Int(state:Byte Ptr)))\n\t\t_cb = cb\n\t\t?Threaded\n\t\tp_lugi_initlock.Lock()\n\t\t?\n\t\tIf p_lugi_postinit_cb = Null Then\n\t\t\tp_lugi_postinit_cb = New TList\n\t\tEndIf\n\t\tp_lugi_postinit_cb.AddLast(Self)\n\t\t?Threaded\n\t\tp_lugi_initlock.Unlock()\n\t\t?\n\t\tReturn Self\n\tEnd Method\n\t\n\t' #region PRIVATE\n\t\n\tField _cb:Byte Ptr\n\tField _reqState:Int\n\t\n\tMethod Pre(vm:Byte Ptr, rfield(off%, typ%, name$, clas@ Ptr), rmethod(fn:Int(state@ Ptr), name$, clas@ Ptr))\n\t\tLocal cb(vm:Byte Ptr, rfield(off%, typ%, name$, clas@ Ptr), rmethod(fn:Int(state@ Ptr), name$, clas@ Ptr)) = _cb\n\t\tIf Not _reqState Then\n\t\t p_lugi_preinit_cb.Remove(Self)\n\t\t cb(Null, rfield, rmethod) ' No VM is passed, since it's not required\n\t\tElse\n \t\tcb(vm, rfield, rmethod)\n \tEndIf\n\tEnd Method\n\t\n\tMethod Post(vm:Byte Ptr, constructor:Int(state:Byte Ptr))\n\t\tLocal cb(vm:Byte Ptr, constructor:Int(state:Byte Ptr)) = _cb\n\t\tcb(vm, constructor)\n\tEnd Method\n\t\n\t' #endregion\n\t\nEnd Type\n\nPrivate\n\n' There is really no good way to do this in a thread-safe manner, so the best I can do is to make\n' all access to the initialization lists a critical section\n?Threaded\nGlobal p_lugi_initlock:TMutex = TMutex.Create()\n?\nGlobal p_lugi_preinit_cb:TList\nGlobal p_lugi_postinit_cb:TList\n\n' Executes init functions that are to occur prior to creation of any BMax objects, VMTs, etc.\n' Doesn't lock the lists since it's only supposed to be called after the lists have been locked\nFunction PreInitLuGI(vm@ Ptr)\n\tIf Not p_lugi_preinit_cb Then\n\t\tReturn\n\tEndIf\n\tFor Local cb:LuGIInitFunction = EachIn p_lugi_preinit_cb\n\t\tcb.Pre(vm, p_lugi_register_field, p_lugi_register_method)\n\tNext\nEnd Function\n\n' Executes init functions that are to occur following the creation of BMax VMTs, metatables, cache, etc.\n' Doesn't lock the lists since it's only supposed to be called after the lists have been locked\nFunction PostInitLuGI(vm@ Ptr)\n\tIf Not p_lugi_postinit_cb Then\n\t\tReturn\n\tEndIf\n\tFor Local cb:LuGIInitFunction = EachIn p_lugi_postinit_cb\n\t\tcb.Post(vm, p_lugi_new_object)\n\tNext\nEnd Function\n\n' Private\/internal code that shouldn't be directly accessed (only provided)\nExtern \"C\"\n\tFunction p_lugi_register_method(fn:Int(state@ Ptr), name$, clas@ Ptr=Null)\n\tFunction p_lugi_register_field(off%, typ%, name$, clas@ Ptr)\n\t\n\tFunction p_lugi_init(state@ Ptr)\n\t\n\t' Constructor object - push with BBClass for type as upvalue\n\tFunction p_lugi_new_object:Int(state@ Ptr)\nEnd Extern\n\nPublic\n\nExtern \"C\"\n\t' Determining if an object on the stack is a BMax object\n\tFunction lua_isbmaxobject:Int(state@ Ptr, index:Int)\n\t\n\t' Pushing\/getting BBObjects (BBObjects, BBStrings, and BBArrays to tables\/tables to BBArrays respectively)\n\tFunction lua_pushbmaxobject(state@ Ptr, obj:Object)\n\tFunction lua_tobmaxobject:Object(state@ Ptr, index:Int)\n\t\n\t' Pushing\/getting BBArrays (BBArrays to tables\/tables to BBArrays respectively)\n\t' @arr has to be treated as an Object in BMax since passing an Int[] as an Object[] doesn't work\n\tFunction lua_pushbmaxarray(state@ Ptr, arr:Object)\n\tFunction lua_tobmaxarray:Object(state@ Ptr, index:Int)\nEnd Extern\n\n' Initializes the Lua state for use with BMax objects via LuGI\nFunction InitLuGI(vm:Byte Ptr)\n\t?Threaded\n\tp_lugi_initlock.Lock()\n\t?\n\tPreInitLuGI(vm)\n\tp_lugi_init(vm)\n\tPostInitLuGI(vm)\n\t?Threaded\n\tp_lugi_initlock.Unlock()\n\t?\nEnd Function\n\nFunction BindFunctionToType(fn:Int(L@Ptr), as$, typ:TTypeID)\n\tp_lugi_register_method(fn, as, Byte Ptr(typ._class))\nEnd Function\n","old_contents":"Rem\n\tLuGI - Copyright (c) 2009 Noel R. Cower\n\n\tPermission is hereby granted, free of charge, to any person obtaining a copy\n\tof this software and associated documentation files (the \"Software\"), to deal\n\tin the Software without restriction, including without limitation the rights\n\tto use, copy, modify, merge, publish, distribute, sublicense, and\/or sell\n\tcopies of the Software, and to permit persons to whom the Software is\n\tfurnished to do so, subject to the following conditions:\n\n\tThe above copyright notice and this permission notice shall be included in\n\tall copies or substantial portions of the Software.\n\n\tTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n\tIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n\tFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n\tAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n\tLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n\tOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n\tTHE SOFTWARE.\nEndRem\n\nSuperStrict\n\nModule LuGI.Core\n\nModuleInfo \"Name: LuGI Core\"\nModuleInfo \"Description: Core API provided by LuGI to interact with BMax objects via Lua\"\nModuleInfo \"Version: 0.8.02\"\nModuleInfo \"Author: Noel Cower\"\nModuleInfo \"License: MIT\"\nModuleInfo \"URL: http:\/\/github.com\/nilium\/lugi.mod\/<\/a>\"\n\n?Threaded\nImport Brl.Threads\n?\nImport Brl.Reflection\nImport Brl.LinkedList\nImport Pub.Lua\nImport \"lgcore.cpp\"\n\nPublic\n\n' LuGI field types - used by LuGI to determine how to access fields at runtime\n' The only reason these are public is because the generated code uses them, otherwise I'd hide\n' them away too. But then if I hide them and use number constants in the generated code, we'll\n' get the chance that changing these later will break existing glue code, and doing that is bad.\nConst LUGI_BYTEFIELD:Int = $0001\nConst LUGI_SHORTFIELD:Int = $0002\nConst LUGI_INTFIELD:Int = $0004\nConst LUGI_FLOATFIELD:Int = $0008\nConst LUGI_LONGFIELD:Int = $0010\nConst LUGI_DOUBLEFIELD:Int = $0020\nConst LUGI_STRINGFIELD:Int = $0040\nConst LUGI_OBJECTFIELD:Int = $0080\nConst LUGI_ARRAYFIELD:Int = $0100\n' Optional flag to specify that an integer field (Int, Short, Byte, or Long) should be treated as a\n' boolean value when passed to Lua\nConst LUGI_BOOLFIELDOPT:Int = $8000\n\nType LuGIInitFunction\n\t\n\t' Registers the callback provided as a pre-init stage routine\n\tMethod PreInit:LuGIInitFunction(cb(vm:Byte Ptr, rfield(off%, typ%, name$, clas@ Ptr), rmethod(fn:Int(state@ Ptr), name$, clas@ Ptr)), requiresState%=True)\n\t\t_cb = cb\n\t\t_reqState = requiresState\n\t\t?Threaded\n\t\tp_lugi_initlock.Lock()\n\t\t?\n\t\tIf p_lugi_preinit_cb = Null Then\n\t\t\tp_lugi_preinit_cb = New TList\n\t\tEndIf\n\t\tp_lugi_preinit_cb.AddLast(Self)\n\t\t?Threaded\n\t\tp_lugi_initlock.Unlock()\n\t\t?\n\t\tReturn Self\n\tEnd Method\n\t\n\t' Registers the callback provided as a post-init stage routine\n\tMethod PostInit:LuGIInitFunction(cb(state:Byte Ptr, constructor:Int(state:Byte Ptr)))\n\t\t_cb = cb\n\t\t?Threaded\n\t\tp_lugi_initlock.Lock()\n\t\t?\n\t\tIf p_lugi_postinit_cb = Null Then\n\t\t\tp_lugi_postinit_cb = New TList\n\t\tEndIf\n\t\tp_lugi_postinit_cb.AddLast(Self)\n\t\t?Threaded\n\t\tp_lugi_initlock.Unlock()\n\t\t?\n\t\tReturn Self\n\tEnd Method\n\t\n\t' #region PRIVATE\n\t\n\tField _cb:Byte Ptr\n\tField _reqState:Int\n\t\n\tMethod Pre(vm:Byte Ptr, rfield(off%, typ%, name$, clas@ Ptr), rmethod(fn:Int(state@ Ptr), name$, clas@ Ptr))\n\t\tLocal cb(vm:Byte Ptr, rfield(off%, typ%, name$, clas@ Ptr), rmethod(fn:Int(state@ Ptr), name$, clas@ Ptr)) = _cb\n\t\tIf Not _reqState Then\n\t\t p_lugi_preinit_cb.Remove(Self)\n\t\t cb(Null, rfield, rmethod) ' No VM is passed, since it's not required\n\t\tElse\n \t\tcb(vm, rfield, rmethod)\n \tEndIf\n\tEnd Method\n\t\n\tMethod Post(vm:Byte Ptr, constructor:Int(state:Byte Ptr))\n\t\tLocal cb(vm:Byte Ptr, constructor:Int(state:Byte Ptr)) = _cb\n\t\tcb(vm, constructor)\n\tEnd Method\n\t\n\t' #endregion\n\t\nEnd Type\n\nPrivate\n\n' There is really no good way to do this in a thread-safe manner, so the best I can do is to make\n' all access to the initialization lists a critical section\n?Threaded\nGlobal p_lugi_initlock:TMutex = TMutex.Create()\n?\nGlobal p_lugi_preinit_cb:TList\nGlobal p_lugi_postinit_cb:TList\n\n' Executes init functions that are to occur prior to creation of any BMax objects, VMTs, etc.\n' Doesn't lock the lists since it's only supposed to be called after the lists have been locked\nFunction PreInitLuGI(vm@ Ptr)\n\tIf Not p_lugi_preinit_cb Then\n\t\tReturn\n\tEndIf\n\tFor Local cb:LuGIInitFunction = EachIn p_lugi_preinit_cb\n\t\tcb.Pre(vm, p_lugi_register_field, p_lugi_register_method)\n\tNext\nEnd Function\n\n' Executes init functions that are to occur following the creation of BMax VMTs, metatables, cache, etc.\n' Doesn't lock the lists since it's only supposed to be called after the lists have been locked\nFunction PostInitLuGI(vm@ Ptr)\n\tIf Not p_lugi_postinit_cb Then\n\t\tReturn\n\tEndIf\n\tFor Local cb:LuGIInitFunction = EachIn p_lugi_postinit_cb\n\t\tcb.Post(vm, p_lugi_new_object)\n\tNext\nEnd Function\n\n' Private\/internal code that shouldn't be directly accessed (only provided)\nExtern \"C\"\n\tFunction p_lugi_register_method(fn:Int(state@ Ptr), name$, clas@ Ptr=Null)\n\tFunction p_lugi_register_field(off%, typ%, name$, clas@ Ptr)\n\t\n\tFunction p_lugi_init(state@ Ptr)\n\t\n\t' Constructor object - push with BBClass for type as upvalue\n\tFunction p_lugi_new_object:Int(state@ Ptr)\nEnd Extern\n\nPublic\n\nExtern \"C\"\n\t' Determining if an object on the stack is a BMax object\n\tFunction lua_isbmaxobject:Int(state@ Ptr, index:Int)\n\t\n\t' Pushing\/getting BBObjects (BBObjects, BBStrings, and BBArrays to tables\/tables to BBArrays respectively)\n\tFunction lua_pushbmaxobject(state@ Ptr, obj:Object)\n\tFunction lua_tobmaxobject:Object(state@ Ptr, index:Int)\n\t\n\t' Pushing\/getting BBArrays (BBArrays to tables\/tables to BBArrays respectively)\n\t' @arr has to be treated as an Object in BMax since passing an Int[] as an Object[] doesn't work\n\tFunction lua_pushbmaxarray(state@ Ptr, arr:Object)\n\tFunction lua_tobmaxarray:Object(state@ Ptr, index:Int)\nEnd Extern\n\n' Initializes the Lua state for use with BMax objects via LuGI\nFunction InitLuGI(vm:Byte Ptr)\n\t?Threaded\n\tp_lugi_initlock.Lock()\n\t?\n\tPreInitLuGI(vm)\n\tp_lugi_init(vm)\n\tPostInitLuGI(vm)\n\t?Threaded\n\tp_lugi_initlock.Unlock()\n\t?\nEnd Function\n\nFunction BindFunctionToType(fn:Int(L@Ptr), as$, typ:TTypeID)\n\tp_lugi_register_method(fn, as, Byte Ptr(typ._class))\nEnd Function\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"69e6bbe4e46e7c8982108f1500fb6aad95cb5aee","subject":"[argparser] (v0.3) \tFixed argument parsing for commands","message":"[argparser] (v0.3)\n\tFixed argument parsing for commands\n","repos":"komiga\/duct-max,komiga\/duct-max,komiga\/duct-max","old_file":"argparser.mod\/argparser.bmx","new_file":"argparser.mod\/argparser.bmx","new_contents":"\nRem\nCopyright (c) 2010 Tim Howard\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and\/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\nEnd Rem\n\nSuperStrict\n\nRem\nbbdoc: Application argument parser\nEnd Rem\nModule duct.argparser\n\nModuleInfo \"Version: 0.3\"\nModuleInfo \"Copyright: Tim Howard\"\nModuleInfo \"License: MIT\"\n\nModuleInfo \"History: Version 0.3\"\nModuleInfo \"History: Fixed argument parsing for commands\"\nModuleInfo \"History: Version 0.2\"\nModuleInfo \"History: Updated for API change\"\nModuleInfo \"History: Version 0.1\"\nModuleInfo \"History: Initial version.\"\n\nImport duct.variables\n\nRem\n\tbbdoc: duct argument parser.\nEnd Rem\nType dArgParser\n\t\n\tRem\n\t\tbbdoc: Parse the given arguments string array.\n\t\treturns: The root identifier containing the parsed arguments.\n\t\tabout: The expected value does not<\/b> (by default) contain the first argument of AppArgs (the application location).\n\t\tYou can override this by passing @fullargs as True. If you leave it as False, the root identifier's name will be set to the first argument (which should be the application location - if you're passing AppArgs).\n\t\t@optarglimit limits how many arguments can be given to an option (options start with \"--\" or \"-\"). If set to -1, there is no limit.\n\tEnd Rem\n\tFunction ParseArray:dIdentifier(args:String[], fullargs:Int = False, optarglimit:Int = 1)\n\t\tLocal root:dIdentifier = New dIdentifier.Create()\n\t\tIf fullargs = True\n\t\t\troot.SetName(args[0])\n\t\t\targs = args[1..]\n\t\tEnd If\n\t\tLocal arg:String, i:Int, length:Int = args.Length - 1\n\t\tLocal sub:dIdentifier, subset:Int = False\n\t\toptarglimit = (optarglimit = -1) And length Or optarglimit\n\t\tFor i = 0 To length\n\t\t\targ = args[i]\n\t\t\tsub = New dIdentifier.CreateByData(arg, Null)\n\t\t\tIf arg <> Null And arg[0] = 45 ' \"-\"\n\t\t\t\tLocal lim:Int = Min(length, i + optarglimit)\n\t\t\t\ti:+1\n\t\t\t\tWhile i <= length\n\t\t\t\t\targ = args[i]\n\t\t\t\t\tIf arg = Null Or arg[0] <> 45 ' \"-\"\n\t\t\t\t\t\tsub.AddValue(dVariable.RawToVariable(arg))\n\t\t\t\t\t\ti:+1\n\t\t\t\t\t\tIf i > lim\n\t\t\t\t\t\t\ti:-1\n\t\t\t\t\t\t\tExit\n\t\t\t\t\t\tEnd If\n\t\t\t\t\tElse\n\t\t\t\t\t\ti:-1\n\t\t\t\t\t\tExit\n\t\t\t\t\tEnd If\n\t\t\t\tEnd While\n\t\t\t\troot.AddValue(sub)\n\t\t\tElse\n\t\t\t\tIf subset = False\n\t\t\t\t\troot.AddValue(sub)\n\t\t\t\t\troot = sub\n\t\t\t\t\tsubset = True\n\t\t\t\tElse\n\t\t\t\t\troot.AddValue(dVariable.RawToVariable(arg))\n\t\t\t\tEnd If\n\t\t\tEnd If\n\t\tNext\n\t\tWhile Not root.GetParent() = Null\n\t\t\troot = dIdentifier(root.GetParent())\n\t\tEnd While\n\t\tReturn root\n\tEnd Function\n\t\nEnd Type\n\n","old_contents":"\nRem\nCopyright (c) 2010 Tim Howard\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and\/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\nEnd Rem\n\nSuperStrict\n\nRem\nbbdoc: Application argument parser\nEnd Rem\nModule duct.argparser\n\nModuleInfo \"Version: 0.2\"\nModuleInfo \"Copyright: Tim Howard\"\nModuleInfo \"License: MIT\"\n\nModuleInfo \"History: Version 0.2\"\nModuleInfo \"History: Updated for API change\"\nModuleInfo \"History: Version 0.1\"\nModuleInfo \"History: Initial version.\"\n\nImport duct.variables\n\nRem\n\tbbdoc: duct argument parser.\nEnd Rem\nType dArgParser\n\t\n\tRem\n\t\tbbdoc: Parse the given arguments string array.\n\t\treturns: The root identifier containing the parsed arguments.\n\t\tabout: The expected value does not<\/b> (by default) contain the first argument of AppArgs (the application location).\n\t\tYou can override this by passing @fullargs as True. If you leave it as False, the root identifier's name will be set to the first argument (which should be the application location - if you're passing AppArgs).\n\t\t@optarglimit limits how many arguments can be given to an option (options start with \"--\" or \"-\"). If set to -1, there is no limit.\n\tEnd Rem\n\tFunction ParseArray:dIdentifier(args:String[], fullargs:Int = False, optarglimit:Int = 1)\n\t\tLocal root:dIdentifier = New dIdentifier.Create()\n\t\tIf fullargs = True\n\t\t\troot.SetName(args[0])\n\t\t\targs = args[1..]\n\t\tEnd If\n\t\tLocal arg:String, i:Int, length:Int = args.Length - 1\n\t\tLocal sub:dIdentifier, subset:Int = False\n\t\toptarglimit = (optarglimit = -1) And length Or optarglimit\n\t\tFor i = 0 To length\n\t\t\targ = args[i]\n\t\t\tsub = New dIdentifier.CreateByData(arg, Null)\n\t\t\tIf arg <> Null And arg[0] = 45 ' \"-\"\n\t\t\t\tLocal lim:Int = Min(length, i + optarglimit)\n\t\t\t\ti:+1\n\t\t\t\tWhile i <= length\n\t\t\t\t\targ = args[i]\n\t\t\t\t\tIf arg = Null Or arg[0] <> 45 ' \"-\"\n\t\t\t\t\t\tsub.AddValue(dVariable.RawToVariable(arg))\n\t\t\t\t\t\ti:+1\n\t\t\t\t\t\tIf i > lim\n\t\t\t\t\t\t\ti:-1\n\t\t\t\t\t\t\tExit\n\t\t\t\t\t\tEnd If\n\t\t\t\t\tElse\n\t\t\t\t\t\ti:-1\n\t\t\t\t\t\tExit\n\t\t\t\t\tEnd If\n\t\t\t\tEnd While\n\t\t\t\troot.AddValue(sub)\n\t\t\tElse\n\t\t\t\troot.AddValue(sub)\n\t\t\t\tIf subset = False\n\t\t\t\t\troot = sub\n\t\t\t\t\tsubset = True\n\t\t\t\tEnd If\n\t\t\tEnd If\n\t\tNext\n\t\tWhile Not root.GetParent() = Null\n\t\t\troot = dIdentifier(root.GetParent())\n\t\tEnd While\n\t\tReturn root\n\tEnd Function\n\t\nEnd Type\n\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"8bd717978e894cfc3b89da9b7a383ba8f0eb5719","subject":"Parameter name correction :|","message":"Parameter name correction :|\n","repos":"komiga\/duct-max,komiga\/duct-max,komiga\/duct-max","old_file":"network.mod\/inc\/types\/server.bmx","new_file":"network.mod\/inc\/types\/server.bmx","new_contents":"\nRem\n\tCopyright (c) 2009 Tim Howard\n\t\n\tPermission is hereby granted, free of charge, to any person obtaining a copy\n\tof this software and associated documentation files (the \"Software\"), to deal\n\tin the Software without restriction, including without limitation the rights\n\tto use, copy, modify, merge, publish, distribute, sublicense, and\/or sell\n\tcopies of the Software, and to permit persons to whom the Software is\n\tfurnished to do so, subject to the following conditions:\n\t\n\tThe above copyright notice and this permission notice shall be included in\n\tall copies or substantial portions of the Software.\n\t\n\tTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n\tIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n\tFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n\tAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n\tLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n\tOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n\tTHE SOFTWARE.\n\t-----------------------------------------------------------------------------\n\t\n\tserver.bmx (Contains: TServer, )\n\t\nEnd Rem\n\nRem\n\tbbdoc: duct generic server type.\nEnd Rem\nType TServer\n\t\n\tField m_socket:TSocket\n\tField m_port:Int, m_accept_timeout:Int\n\t\n\tField m_msgmap:TNetMessageMap\n\tField m_clients:TListEx\n\t\n\tMethod New()\n\t\tm_clients = New TListEx\n\tEnd Method\n\t\n\tMethod _init(msgmap:TNetMessageMap, socket:TSocket, port:Int, accept_timeout:Int)\n\t\tSetMessageMap(msgmap)\n\t\tSetSocket(socket)\n\t\tSetPort(port)\n\t\tSetAcceptTimeout(accept_timeout)\n\tEnd Method\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the timeout when the Server attempts to accept a Client.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetAcceptTimeout(accept_timeout:Int)\n\t\tm_accept_timeout = accept_timeout\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the timout (ms) used when the Server attempts to accept a Client.\n\t\treturns: The accept timeout for this Server.\n\tEnd Rem\n\tMethod GetAcceptTimeout:Int()\n\t\tReturn m_accept_timeout\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the Server's port.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetPort(port:Int)\n\t\tm_port = port\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the Server's port.\n\t\treturns: The port for this Server.\n\tEnd Rem\n\tMethod GetPort:Int()\n\t\tReturn m_port\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the socket for the Server.\n\t\treturns: Nothing.\n\t\tabout: This will close all existing client connections.\n\tEnd Rem\n\tMethod SetSocket(socket:TSocket)\n\t\tClose()\n\t\tm_socket = socket\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the Socket for the Server.\n\t\treturns: The socket for this Server.\n\tEnd Rem\n\tMethod GetSocket:TSocket()\n\t\tReturn m_socket\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the MessageMap for the Server.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetMessageMap(msgmap:TNetMessageMap)\n\t\tm_msgmap = msgmap\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the MessageMap for the Server.\n\t\treturns: The MessageMap for this server.\n\tEnd Rem\n\tMethod GetMessageMap:TNetMessageMap()\n\t\tReturn m_msgmap\n\tEnd Method\n\t\n'#end region (Field accessors)\n\t\n'#region Connection\n\t\n\tRem\n\t\tbbdoc: Start the server connection.\n\t\treturns: True if the socket was able to open on the Server's port, or False if it was unable.\n\tEnd Rem\n\tMethod Start:Int()\n\t\tIf m_socket <> Null\n\t\t\tIf m_socket.Bind(m_port) = True\n\t\t\t\tm_socket.Listen(0)\n\t\t\t\tReturn True\n\t\t\tEnd If\n\t\tEnd If\n\t\tReturn False\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Close the Server and clear the Client list.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod Close()\n\t\tIf m_socket <> Null\n\t\t\tm_socket.Close()\n\t\tEnd If\n\t\tFor Local client:TClient = EachIn m_clients\n\t\t\tDisconnectClient(client)\n\t\tNext\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Check if the Server is open to Clients.\n\t\treturns: True if this Server is open to connections, or False if it is not.\n\tEnd Rem\n\tMethod Connected:Int()\n\t\tReturn m_socket.Connected()\n\tEnd Method\n\t\n'#end region (Connection)\n\t\n\tRem\n\t\tbbdoc: Add a Client to the Server.\n\t\treturns: True if the Client was added to the Server, or False if it was not.\n\tEnd Rem\n\tMethod AddClient:Int(client:TClient)\n\t\tIf client <> Null\n\t\t\tIf client.Connected() = True\n\t\t\t\tclient.m_link = m_clients.AddLast(client)\n\t\t\t\tOnClientAdd(client)\n\t\t\t\tReturn True\n\t\t\tEnd If\n\t\tEnd If\n\t\tReturn False\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Disconnect a Client from the Server.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod DisconnectClient(client:TClient, ondisconnect:Int = True)\n\t\tIf ondisconnect = True\n\t\t\tOnClientDisconnect(client)\n\t\tEnd If\n\t\t\n\t\tclient.Disconnect()\n\t\tclient.m_link.Remove()\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Handle a new Client (if there are any attempting to connect).\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod HandleNewClients:Int()\n\t\tLocal acceptsocket:TSocket, client:TClient\n\t\t\n\t\tacceptsocket = m_socket.Accept(m_accept_timeout)\n\t\tIf acceptsocket <> Null\n\t\t\tclient = OnSocketAccept(acceptsocket)\n\t\t\tReturn AddClient(client)\n\t\tEnd If\n\t\tReturn False\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Check for and handle incoming data from the Clients.\n\t\treturns: Nothing.\n\t\tabout: This calls HandleIncomingData if there is data to be read from a Client.\n\tEnd Rem\n\tMethod CheckTransmissions()\n\t\tFor Local client:TClient = EachIn m_clients\n\t\t\tIf client.Eof() = False\n\t\t\t\tIf client.ReadAvail() > 0\n\t\t\t\t\tHandleIncomingData(client)\n\t\t\t\tEnd If\n\t\t\tElse\n\t\t\t\tDisconnectClient(client)\n\t\t\tEnd If\n\t\tNext\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Handle incoming data from a Client.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod HandleIncomingData(client:TClient)\n\t\tLocal msgid:Int, message:TNetMessage\n\t\t\n\t\tWhile client.ReadAvail() > 0\n\t\t\tmsgid = Int(client.ReadByte())\n\t\t\tmessage = m_msgmap.GetMessageByID(msgid)\n\t\t\tclient.HandleMessage(msgid, message)\n\t\tWend\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Called when a Client is added to the Server (implement in extending types).\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod OnClientAdd(client:TClient) Abstract\n\t\n\tRem\n\t\tbbdoc: Called when a Client is disconnected from the Server (implement in extending types).\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod OnClientDisconnect(client:TClient) Abstract\n\t\n\tRem\n\t\tbbdoc: Called when a socket is accepted to the Server (implement in extending types).\n\t\treturns: A Client, or Null if the socket was further unaccepted.\n\tEnd Rem\n\tMethod OnSocketAccept:TClient(socket:TSocket) Abstract\n\t\nEnd Type\n\n","old_contents":"\nRem\n\tCopyright (c) 2009 Tim Howard\n\t\n\tPermission is hereby granted, free of charge, to any person obtaining a copy\n\tof this software and associated documentation files (the \"Software\"), to deal\n\tin the Software without restriction, including without limitation the rights\n\tto use, copy, modify, merge, publish, distribute, sublicense, and\/or sell\n\tcopies of the Software, and to permit persons to whom the Software is\n\tfurnished to do so, subject to the following conditions:\n\t\n\tThe above copyright notice and this permission notice shall be included in\n\tall copies or substantial portions of the Software.\n\t\n\tTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n\tIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n\tFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n\tAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n\tLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n\tOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n\tTHE SOFTWARE.\n\t-----------------------------------------------------------------------------\n\t\n\tserver.bmx (Contains: TServer, )\n\t\nEnd Rem\n\nRem\n\tbbdoc: duct generic server type.\nEnd Rem\nType TServer\n\t\n\tField m_socket:TSocket\n\tField m_port:Int, m_accept_timeout:Int\n\t\n\tField m_msgmap:TNetMessageMap\n\tField m_clients:TListEx\n\t\n\tMethod New()\n\t\tm_clients = New TListEx\n\tEnd Method\n\t\n\tMethod _init(msgmap:TNetMessageMap, socket:TSocket, port:Int, accept_timeout:Int)\n\t\tSetMessageMap(msgmap)\n\t\tSetSocket(socket)\n\t\tSetPort(port)\n\t\tSetAcceptTimeout(accept_timeout)\n\tEnd Method\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the timeout when the Server attempts to accept a Client.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetAcceptTimeout(accept_timeout:Int)\n\t\tm_accept_timeout = accept_timeout\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the timout (ms) used when the Server attempts to accept a Client.\n\t\treturns: The accept timeout for this Server.\n\tEnd Rem\n\tMethod GetAcceptTimeout:Int()\n\t\tReturn m_accept_timeout\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the Server's port.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetPort(port:Int)\n\t\tm_port = port\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the Server's port.\n\t\treturns: The port for this Server.\n\tEnd Rem\n\tMethod GetPort:Int()\n\t\tReturn m_port\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the socket for the Server.\n\t\treturns: Nothing.\n\t\tabout: This will close all existing client connections.\n\tEnd Rem\n\tMethod SetSocket(socket:TSocket)\n\t\tClose()\n\t\tm_socket = socket\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the Socket for the Server.\n\t\treturns: The socket for this Server.\n\tEnd Rem\n\tMethod GetSocket:TSocket()\n\t\tReturn m_socket\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the MessageMap for the Server.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetMessageMap(msgmap:TNetMessageMap)\n\t\tm_msgmap = msgmap\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the MessageMap for the Server.\n\t\treturns: The MessageMap for this server.\n\tEnd Rem\n\tMethod GetMessageMap:TNetMessageMap()\n\t\tReturn m_msgmap\n\tEnd Method\n\t\n'#end region (Field accessors)\n\t\n'#region Connection\n\t\n\tRem\n\t\tbbdoc: Start the server connection.\n\t\treturns: True if the socket was able to open on the Server's port, or False if it was unable.\n\tEnd Rem\n\tMethod Start:Int()\n\t\tIf m_socket <> Null\n\t\t\tIf m_socket.Bind(m_port) = True\n\t\t\t\tm_socket.Listen(0)\n\t\t\t\tReturn True\n\t\t\tEnd If\n\t\tEnd If\n\t\tReturn False\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Close the Server and clear the Client list.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod Close()\n\t\tIf m_socket <> Null\n\t\t\tm_socket.Close()\n\t\tEnd If\n\t\tFor Local client:TClient = EachIn m_clients\n\t\t\tDisconnectClient(client)\n\t\tNext\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Check if the Server is open to Clients.\n\t\treturns: True if this Server is open to connections, or False if it is not.\n\tEnd Rem\n\tMethod Connected:Int()\n\t\tReturn m_socket.Connected()\n\tEnd Method\n\t\n'#end region (Connection)\n\t\n\tRem\n\t\tbbdoc: Add a Client to the Server.\n\t\treturns: True if the Client was added to the Server, or False if it was not.\n\tEnd Rem\n\tMethod AddClient:Int(client:TClient)\n\t\tIf client <> Null\n\t\t\tIf client.Connected() = True\n\t\t\t\tclient.m_link = m_clients.AddLast(client)\n\t\t\t\tOnClientAdd(client)\n\t\t\t\tReturn True\n\t\t\tEnd If\n\t\tEnd If\n\t\tReturn False\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Disconnect a Client from the Server.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod DisconnectClient(client:TClient, ondisconnect:Int = True)\n\t\tIf ondisconnect = True\n\t\t\tOnClientDisconnect(client)\n\t\tEnd If\n\t\t\n\t\tclient.Disconnect()\n\t\tclient.m_link.Remove()\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Handle a new Client (if there are any attempting to connect).\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod HandleNewClients:Int()\n\t\tLocal acceptsocket:TSocket, client:TClient\n\t\t\n\t\tacceptsocket = m_socket.Accept(m_accept_timeout)\n\t\tIf acceptsocket <> Null\n\t\t\tclient = OnSocketAccept(acceptsocket)\n\t\t\tReturn AddClient(client)\n\t\tEnd If\n\t\tReturn False\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Check for and handle incoming data from the Clients.\n\t\treturns: Nothing.\n\t\tabout: This calls HandleIncomingData if there is data to be read from a Client.\n\tEnd Rem\n\tMethod CheckTransmissions()\n\t\tFor Local client:TClient = EachIn m_clients\n\t\t\tIf client.Eof() = False\n\t\t\t\tIf client.ReadAvail() > 0\n\t\t\t\t\tHandleIncomingData(client)\n\t\t\t\tEnd If\n\t\t\tElse\n\t\t\t\tDisconnectClient(client)\n\t\t\tEnd If\n\t\tNext\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Handle incoming data from a Client.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod HandleIncomingData(client:TClient)\n\t\tLocal msgid:Int, message:TNetMessage\n\t\t\n\t\tWhile client.ReadAvail() > 0\n\t\t\tmsgid = Int(client.ReadByte())\n\t\t\tmessage = m_msgmap.GetMessageByID(msgid)\n\t\t\tclient.HandleMessage(msgid, message)\n\t\tWend\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Called when a Client is added to the Server (implement in extending types).\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod OnClientAdd(client:TClient) Abstract\n\t\n\tRem\n\t\tbbdoc: Called when a Client is disconnected from the Server (implement in extending types).\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod OnClientDisconnect(client:TClient) Abstract\n\t\n\tRem\n\t\tbbdoc: Called when a socket is accepted to the Server (implement in extending types).\n\t\treturns: A Client, or Null if the socket was further unaccepted.\n\tEnd Rem\n\tMethod OnSocketAccept:TClient(m_socket:TSocket) Abstract\n\t\nEnd Type\n\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"5e0a39d002408bf95b1a2f320100bc62b92d2e6d","subject":"Added time delay to the main update loop (to match HTML5 mojo)","message":"Added time delay to the main update loop (to match HTML5 mojo)\n\n--HG--\nextra : convert_revision : svn%3Ae934d3cd-0d57-f34a-94d0-9e8d31ae1c29\/trunk%40385\n","repos":"programmerby\/diddy-mirror,programmerby\/diddy-mirror,programmerby\/diddy-mirror,programmerby\/diddy-mirror","old_file":"monkeymax\/modules\/mojo\/native\/mojo.bmax.bmx","new_file":"monkeymax\/modules\/mojo\/native\/mojo.bmax.bmx","new_contents":"' ***** Start mojo.bmax.bmx ******\r\n\r\nGlobal app:gxtkApp\r\n\r\nType gxtkApp\r\n\tField ginput:gxtkInput\r\n\tField gaudio:gxtkAudio\r\n\tField ggraphics:gxtkGraphics\r\n\r\n\tField dead:Int=0\r\n\tField suspended:Int=0\r\n\tField vloading:Int=0\r\n\tField maxloading:Int=0\r\n\tField updateRate:Int=0\r\n\tField nextUpdate:Float=0\r\n\tField updatePeriod:Float=0\r\n\tField startMillis:Float=0\r\n\t\r\n\tMethod New()' gxtkApp()\r\n\t\tapp=Self\r\n\t\tggraphics=New gxtkGraphics\r\n\tEndMethod\r\n\t\r\n\tMethod Setup()\r\n\t\tginput=New gxtkInput\r\n\t\tgaudio=New gxtkAudio\r\n\r\n\t\tbb_input__1Set_1Input_1Device(ginput)\r\n\t\tbb_audio__1Set_1Audio_1Device(gaudio)\r\n\t\t\r\n\t\tstartMillis=BlitzMaxMillisecs()\r\n\t\t\r\n\t\tSetFrameRate( 0 )\r\n\t\t\r\n\t\tInvokeOnCreate()\r\n\t\tInvokeOnRender()\r\n\t\tUpdate()\r\n\tEndMethod\r\n\t\r\n\tMethod Update()\r\n\t\tWhile Not AppTerminate()\r\n\t\t\tIf Not updatePeriod return\r\n\t\t\tLocal updates:Int = 0\r\n\t\t\t\r\n\t\t\tRepeat\r\n\t\t\t\tnextUpdate:+updatePeriod\r\n\t\t\t\tInvokeOnUpdate()\r\n\t\t\t\tIf Not updatePeriod Then Exit\r\n\t\t\t\tIf nextUpdate>BlitzMaxMillisecs() Then Exit\r\n\t\t\t\tupdates:+1\r\n\t\t\t\tIf updates = 7 Then\r\n\t\t\t\t\tnextUpdate = BlitzMaxMillisecs()\r\n\t\t\t\t\tExit\r\n\t\t\t\tEndIf\r\n\t\t\tForever\r\n\t\t\tInvokeOnRender()\r\n\t\t\tLocal del:Int = nextUpdate - BlitzMaxMillisecs()\r\n\t\t\tIf del < 1 Then del = 1\r\n\t\t\tDelay(del)\r\n\t\tWend\r\n\tEndMethod\r\n\t\r\n\tMethod InvokeOnCreate()\r\n\t\tIf dead Return\r\n\t\tdead = 1\r\n\t\tOnCreate()\r\n\t\tdead = 0\r\n\tEndMethod\r\n\r\n\tMethod InvokeOnUpdate()\r\n\t\tIf dead Or suspended Or Not updateRate Or vloading Return\r\n\t\tOnUpdate()\r\n\tEndMethod\r\n\t\r\n\tMethod InvokeOnRender()\r\n\t\tIf dead Or suspended Return\r\n\t\tggraphics.BeginRender()\r\n\t\tIf vloading\r\n\t\t\tOnLoading()\r\n\t\tElse\r\n\t\t\tOnRender()\r\n\t\tEndIf\r\n\t\tggraphics.EndRender()\r\n\tEndMethod\r\n\t\r\n\t\r\n\tMethod SetFrameRate( fps:Int )\r\n\t\tIf fps\r\n\t\t\tupdatePeriod=1000.0\/fps\r\n\t\t\tnextUpdate=BlitzMaxMillisecs() +updatePeriod\r\n\t\tElse\r\n\t\t\tupdatePeriod=0\r\n\t\tEndIf\r\n\tEndMethod\r\n\r\n\tMethod LoadState:String()\r\n'\t\tvar file:SharedObject=SharedObject.getLocal( \"gxtkapp\" );\r\n'\t\tvar state:String=file.data.state;\r\n'\t\tfile.close();\r\n'\t\tif( state ) return state;\r\n\t\tReturn \"\"\r\n\tEndMethod\r\n\t\r\n\tMethod SaveState:Int( state:String )\r\n'\t\tvar file:SharedObject=SharedObject.getLocal( \"gxtkapp\" );\r\n'\t\tfile.data.state=state;\r\n'\t\tfile.close();\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod LoadString:String( path:String )\r\n\t\tpath = \"data\/\" + path\r\n\t\tReturn LoadText( path )\r\n\tEndMethod\r\n\t\r\n\t' ***** GXTK API *****\r\n\t\r\n\tMethod GraphicsDevice:gxtkGraphics()\r\n\t\tReturn ggraphics\r\n\tEndMethod\r\n\r\n\tMethod InputDevice:gxtkInput()\r\n\t\tReturn ginput\r\n\tEndMethod\r\n\r\n\tMethod AudioDevice:gxtkAudio()\r\n\t\tReturn gaudio\r\n\tEndMethod\r\n\r\n\tMethod SetUpdateRate:Int(hertz:Int)\r\n\t\tupdateRate = hertz\r\n\t\tIf Not vloading Then SetFrameRate(updateRate)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod MilliSecs:Int()\r\n\t\tReturn BlitzMaxMillisecs() - startMillis\r\n\tEndMethod\r\n\t\r\n\tMethod Loading:Int()\r\n\t\tReturn vloading\r\n\tEndMethod\r\n\r\n\tMethod OnCreate:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod OnUpdate:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod OnSuspend:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod OnResume:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod OnRender:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod OnLoading:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkGraphics\r\n\tField gmode:Int = 1\r\n\tField ix:Float=1,iy:Float,jx:Float,jy:Float=1,tx:Float,ty:Float\r\n\tField sx:Float=1,sy:Float=1,rot:Float=0\r\n\t\r\n\tMethod Mode:Int()\r\n\t\tReturn gmode\r\n\tEndMethod\r\n\t\r\n\tMethod Cls:Int(r:Int = 0, g:Int = 0, b:Int = 0)\r\n\t\tBlitzMaxCls(r, g, b)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawPoint:Int(x:Float, y:Float)\r\n\t\tLocal nx:Float = TransX(x,y)\r\n\t\tLocal ny:Float = TransY(x,y)\r\n\t\tPlot nx, ny\r\n\tEndMethod\r\n\t\r\n\tMethod LoadSurface:gxtkSurface(path:String)\r\n\t\tLocal image:TImage = LoadImage(\"data\/\"+path)\r\n\t\tIf image Then\r\n\t\t\tLocal gs:gxtkSurface = New gxtkSurface\r\n\t\t\tgs.setImage(image)\r\n\t\t\tReturn gs\r\n\t\tEndIf\r\n\t\tReturn Null\r\n\tEndMethod\r\n\t\r\n\tMethod BeginRender()\r\n\tEndMethod\r\n\t\r\n\tMethod EndRender()\r\n\t\tFlip\r\n\tEndMethod\r\n\t\r\n\tMethod SetColor:Int(r:Int, g:Int, b:Int)\r\n\t\tBlitzMaxSetColor(r, g, b)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod SetAlpha:Int(a:Float)\r\n\t\tBlitzMaxSetAlpha(a)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod SetBlend:Int(blend:Int)\r\n\t\tBlitzMaxSetBlend(blend)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod Width:Int()\r\n\t\tReturn GraphicsWidth()\r\n\tEndMethod\r\n\t\r\n\tMethod Height:Int()\r\n\t\tReturn GraphicsHeight()\r\n\tEndMethod\r\n\t\r\n\tMethod SetScissor:Int(x:Int, y:Int, w:Int, h:Int)\r\n\t\tSetViewport(x, y, w, h) ' NOT TESTED!\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod TransX:Float(x:Float, y:Float)\r\n\t\tReturn ix*x + jx*y + tx\r\n\tEndMethod\r\n\t\r\n\tMethod TransY:Float(x:Float, y:Float)\r\n\t\tReturn iy*x + jy*y + ty\r\n\tEndMethod\r\n\t\r\n\tMethod SetMatrix:Int(ix:Float,iy:Float,jx:Float,jy:Float,tx:Float,ty:Float)\r\n\t\tSelf.ix = ix ; Self.iy = iy\r\n\t\tSelf.jx = jx ; Self.jy = jy\r\n\t\tSelf.tx = tx ; Self.ty = ty\r\n\t\tsx = Sqr( (ix*ix) + (jx*jx) )\r\n\t\tsy = Sqr( (iy*iy) + (jy*jy) )\r\n\t\trot = -Atan2( jx, ix )\r\n\t\tSetTransform( rot, sx, sy )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawSurface:Int(surface:gxtkSurface,x:Float,y:Float)\r\n\t\tLocal nx:Float = TransX(x,y)\r\n\t\tLocal ny:Float = TransY(x,y)\r\n\t\tDrawImage(surface.image, nx, ny, 0)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawSurface2:Int(surface:gxtkSurface,x:Float,y:Float, srcx:Int, srcy:Int, srcw:Int, srch:Int )\r\n\t\tLocal nx:Float = TransX(x,y)\r\n\t\tLocal ny:Float = TransY(x,y)\r\n\t\tDrawSubImageRect(surface.image, nx, ny, srcw, srch, srcx, srcy, srcw, srch)\t\t\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawLine:Int( x1:Float,y1:Float,x2:Float,y2:Float )\r\n\t\tLocal nx1:Float = TransX(x1,y1)\r\n\t\tLocal ny1:Float = TransY(x1,y1)\r\n\t\tLocal nx2:Float = TransX(x2,y2)\r\n\t\tLocal ny2:Float = TransY(x2,y2)\r\n\t\t' Need to reset transform so that BlitzMax doesn't try to apply rotation\r\n\t\tSetTransform( 0, 1, 1 )\r\n\t\tBlitzMaxDrawLine(nx1, ny1, nx2, ny2)\r\n\t\tSetTransform( rot, sx, sy )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawOval:Int( x:Float, y:Float, w:Float, h:Float )\r\n\t\tLocal nx:Float = TransX(x,y)\r\n\t\tLocal ny:Float = TransY(x,y)\r\n\t\tBlitzMaxDrawOval(nx, ny, w, h)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawPoly:Int(vertices:Float[])\r\n\t\t' setting the origin to use the current rotation translation\r\n\t\tSetOrigin(TransX(0,0), TransY(0,0))\r\n\t\tBlitzMaxDrawPoly( vertices )\r\n\t\tSetOrigin(0, 0)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawRect:Int( x:Float, y:Float, w:Float, h:Float )\r\n\t\tLocal nx:Float = TransX(x,y)\r\n\t\tLocal ny:Float = TransY(x,y)\r\n\t\tBlitzMaxDrawRect(nx, ny, w, h)\r\n\t\tReturn 0\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkInput\r\n\tMethod MouseX:Float()\r\n\t\tReturn BRL.PolledInput.MouseX()\r\n\tEndMethod\r\n\r\n\tMethod MouseY:Float()\r\n\t\tReturn BRL.PolledInput.MouseY()\r\n\tEndMethod\r\n\t\r\n\tMethod KeyDown:Int( key:Int )\r\n\t\tif( key = 384 ) key = 1 ' change TOUCH0 to MOUSE_LMB\r\n\r\n\t\tIf( key >= 1 And key <= 3 )\r\n\t\t\tReturn BRL.PolledInput.MouseDown( key )\r\n\t\tEndIf\r\n\t\tIf key < 256\r\n\t\t\tReturn BRL.PolledInput.KeyDown( key )\r\n\t\tElse\r\n\t\t\tReturn 0\r\n\t\tEndIf\r\n\tEndMethod\r\n\r\n\tMethod KeyHit:Int( key:Int )\r\n\t\tif( key = 384 ) key = 1 ' change TOUCH0 to MOUSE_LMB\r\n\t\tIf( key >= 1 And key <= 3 )\r\n\t\t\tReturn BRL.PolledInput.MouseHit( key )\r\n\t\tEndIf\r\n\t\tIf key < 256\r\n\t\t\tReturn BRL.PolledInput.KeyHit( key )\r\n\t\tElse\r\n\t\t\tReturn 0\r\n\t\tEndIf\r\n\tEndMethod\r\n\r\n\tMethod GetChar:Int()\r\n\t\tReturn BRL.PolledInput.GetChar()\r\n\tEndMethod\r\n\r\n\tMethod JoyX:Int( index:Int )\r\n\t\tReturn Pub.FreeJoy.JoyX( index )\r\n\tEndMethod\r\n\r\n\tMethod JoyY:Int( index:Int )\r\n\t\tReturn Pub.FreeJoy.JoyY( index )\r\n\tEndMethod\r\n\r\n\tMethod JoyZ:Int( index:Int )\r\n\t\tReturn Pub.FreeJoy.JoyZ( index )\r\n\tEndMethod\r\n\r\n\tMethod TouchX:Float( index:Int )\r\n\t\tReturn BRL.PolledInput.MouseX()\r\n\tEndMethod\r\n\r\n\tMethod TouchY:Float( index:Int )\r\n\t\tReturn BRL.PolledInput.MouseY()\r\n\tEndMethod\r\n\t\r\n\tMethod AccelX:Int()\r\n\t\treturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod AccelY:Int()\r\n\t\treturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod AccelZ:Int()\r\n\t\treturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod SetKeyboardEnabled:Int( enabled:int )\r\n\t\tReturn 0\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkChannel\r\n\tField channel:TChannel\t' null then not playing\r\n\tField sample:gxtkSample\r\n\tField loops:int\r\n\t'Field transform:SoundTransform=new SoundTransform()\r\n\t'Field pausepos:Number\r\n\tField state:int\r\n\t\r\n\tMethod New()\r\n\t\tchannel = New TChannel\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkAudio\r\n\tField amusicState:Int = 0\r\n\tField channels:gxtkChannel[] = New gxtkChannel[33]\r\n\t\r\n\tMethod New()\r\n\t\tFor local i:Int = 0 To 33 - 1\r\n\t\t\tchannels[i] = New gxtkChannel\r\n\t\tNext\r\n\tEndMethod\r\n\t\r\n\tMethod MusicState:Int()\r\n'\t\tIf( musicState = 1 And music.isPlaying() = False )\r\n'\t\t\tmusicState = 0;\r\n'\t\tEndif\r\n\t\tReturn amusicState\r\n\tEndMethod\r\n\t\r\n\tMethod PlayMusic:Int( path:String, flags:Int )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod ChannelState:int( channel:int )\r\n\t\tReturn -1\r\n\tEndMethod\r\n\t\r\n\tMethod StopMusic()\r\n\tEndMethod\r\n\t\r\n\tMethod StopChannel( channel:Int )\r\n\tEndMethod\r\n\r\n\tMethod PlaySample( sound:gxtkSample, channel:Int, flags:Int )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\t\r\n\t\t'If chan.state <> 0 Then chan.channel.Stop() <-- this crashes after the first play!?\r\n\t\t\r\n\t\tchan.sample = sound\r\n\t\t'chan.loops = flags ? 0x7fffffff : 0;\r\n\t\t'chan.channel = sample.sound.play( 0,chan.loops,chan.transform );\r\n\t\t'chan.channel = sound\r\n\t\tchan.state=1\r\n\t\r\n\t\tPlaySound( sound.sound, chan.channel )\r\n\tEndMethod\r\n\r\n\tMethod SetPan( channel:Int, pan:Float )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tchan.channel.SetPan(pan)\r\n\tEndMethod\r\n\r\n\tMethod SetRate( channel:Int, rate:Float )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tchan.channel.SetRate(rate)\r\n\tEndMethod\r\n\r\n\tMethod PauseMusic:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod ResumeMusic:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod SetMusicVolume:Int( volume:Float )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod SetVolume:Int( channel:Int, volume:Float )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tchan.channel.SetVolume(volume)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod LoadSample:gxtkSample( path:String )\r\n\t\tLocal extension:String = ExtractExt( path)\r\n\t\tIf extension = \"ogg\" Or extension = \"wav\" Then\r\n\t\t\tLocal sound:TSound = LoadSound(\"data\/\"+path)\r\n\t\t\tIf sound Then\r\n\t\t\t\tLocal gs:gxtkSample = New gxtkSample\r\n\t\t\t\tgs.setSound(sound)\r\n\t\t\t\tReturn gs\r\n\t\t\tEndIf\r\n\t\tElse\r\n\t\t\tRuntimeError \"BlitzMax can only use ogg and wav file formats\"\r\n\t\tEndIf\r\n\t\tReturn Null\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkSample\r\n\tField sound:TSound\r\n\t\r\n\tMethod setSound(sound:TSound)\r\n\t\tSelf.sound = sound\r\n\tEndMethod\r\n\t\r\n\tMethod Discard()\r\n\t\tSelf.sound = null\r\n\tEndMethod\r\nEndType\r\n\r\nFunction BlitzMaxDrawPoly:Int(vertices:Float[])\r\n\tDrawPoly vertices\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxDrawRect:Int( x:Float, y:Float, w:Float, h:Float )\r\n\tDrawRect x, y, w, h\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxDrawOval:Int( x:Float, y:Float, w:Float, h:Float )\r\n\tDrawOval x, y, w, h\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxDrawLine:Int( x1:Float,y1:Float,x2:Float,y2:Float )\r\n\tDrawLine x1, y1, x2, y2\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxMillisecs:Int()\r\n\tReturn MilliSecs()\r\nEndFunction\r\n\r\nFunction BlitzMaxSetColor(r:Int, g:Int, b:Int)\r\n\tSetColor(r, g, b)\r\nEndFunction\r\n\r\nFunction BlitzMaxSetBlend(blend:Int)\r\n\tSelect blend\r\n\t\tCase 0\r\n\t\t\tSetBlend( ALPHABLEND )\r\n\t\tCase 1\r\n\t\t\tSetBlend( LIGHTBLEND )\r\n\tEnd Select\r\nEndFunction\r\n\r\nFunction BlitzMaxSetAlpha(a:Float)\r\n\tSetAlpha(a)\r\nEndFunction\r\n\r\nFunction BlitzMaxCls(r:Int = 0, g:Int = 0, b:Int = 0)\r\n\tSetClsColor(r, g, b)\r\n\tCls\r\nEndFunction\r\n\r\nType gxtkSurface\r\n\tField w:Int, h:Int\r\n\tField image:TImage\r\n\t\r\n\tMethod setImage(image:TImage)\r\n\t\tSelf.image = image\r\n\tEndMethod\r\n\t\r\n\tMethod Width:Int()\r\n\t\tReturn image.Width\r\n\tEndMethod\r\n\t\r\n\tMethod Height:Int()\r\n\t\tReturn image.Height\r\n\tEndMethod\r\n\t\r\n\tMethod Discard()\r\n\tEndMethod\r\nEndType\r\n\r\n' ***** End mojo.bmax.bmx ******\r\n\r\n","old_contents":"' ***** Start mojo.bmax.bmx ******\r\n\r\nGlobal app:gxtkApp\r\n\r\nType gxtkApp\r\n\tField ginput:gxtkInput\r\n\tField gaudio:gxtkAudio\r\n\tField ggraphics:gxtkGraphics\r\n\r\n\tField dead:Int=0\r\n\tField suspended:Int=0\r\n\tField vloading:Int=0\r\n\tField maxloading:Int=0\r\n\tField updateRate:Int=0\r\n\tField nextUpdate:Float=0\r\n\tField updatePeriod:Float=0\r\n\tField startMillis:Float=0\r\n\t\r\n\tMethod New()' gxtkApp()\r\n\t\tapp=Self\r\n\t\tggraphics=New gxtkGraphics\r\n\tEndMethod\r\n\t\r\n\tMethod Setup()\r\n\t\tginput=New gxtkInput\r\n\t\tgaudio=New gxtkAudio\r\n\r\n\t\tbb_input__1Set_1Input_1Device(ginput)\r\n\t\tbb_audio__1Set_1Audio_1Device(gaudio)\r\n\t\t\r\n\t\tstartMillis=BlitzMaxMillisecs()\r\n\t\t\r\n\t\tSetFrameRate( 0 )\r\n\t\t\r\n\t\tInvokeOnCreate()\r\n\t\tInvokeOnRender()\r\n\t\tUpdate()\r\n\tEndMethod\r\n\t\r\n\tMethod Update()\r\n\t\tWhile Not AppTerminate()\r\n\t\t\tLocal updates:Int = 0\r\n\t\t\t\r\n\t\t\tLocal cont:Int = 1\r\n\t\t\tWhile (cont)\r\n\t\t\t\tnextUpdate:+updatePeriod\r\n\t\t\t\tInvokeOnUpdate()\r\n\t\t\t\tIf Not updatePeriod Then cont = 0\r\n\t\t\t\tIf nextUpdate>BlitzMaxMillisecs() Then cont = 0\r\n\t\t\t\tupdates:+1\r\n\t\t\t\tIf updates = 7 Then\r\n\t\t\t\t\tnextUpdate = BlitzMaxMillisecs()\r\n\t\t\t\t\tcont = 0\r\n\t\t\t\tEndIf\r\n\t\t\tWend\r\n\t\t\tInvokeOnRender()\r\n\t\tWend\r\n\tEndMethod\r\n\t\r\n\tMethod InvokeOnCreate()\r\n\t\tIf dead Return\r\n\t\tdead = 1\r\n\t\tOnCreate()\r\n\t\tdead = 0\r\n\tEndMethod\r\n\r\n\tMethod InvokeOnUpdate()\r\n\t\tIf dead Or suspended Or Not updateRate Or vloading Return\r\n\t\tOnUpdate()\r\n\tEndMethod\r\n\t\r\n\tMethod InvokeOnRender()\r\n\t\tIf dead Or suspended Return\r\n\t\tggraphics.BeginRender()\r\n\t\tIf vloading\r\n\t\t\tOnLoading()\r\n\t\tElse\r\n\t\t\tOnRender()\r\n\t\tEndIf\r\n\t\tggraphics.EndRender()\r\n\tEndMethod\r\n\t\r\n\t\r\n\tMethod SetFrameRate( fps:Int )\r\n\t\tIf fps\r\n\t\t\tupdatePeriod=1000.0\/fps\r\n\t\t\tnextUpdate=BlitzMaxMillisecs() +updatePeriod\r\n\t\tElse\r\n\t\t\tupdatePeriod=0\r\n\t\tEndIf\r\n\tEndMethod\r\n\r\n\tMethod LoadState:String()\r\n'\t\tvar file:SharedObject=SharedObject.getLocal( \"gxtkapp\" );\r\n'\t\tvar state:String=file.data.state;\r\n'\t\tfile.close();\r\n'\t\tif( state ) return state;\r\n\t\tReturn \"\"\r\n\tEndMethod\r\n\t\r\n\tMethod SaveState:Int( state:String )\r\n'\t\tvar file:SharedObject=SharedObject.getLocal( \"gxtkapp\" );\r\n'\t\tfile.data.state=state;\r\n'\t\tfile.close();\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod LoadString:String( path:String )\r\n\t\tpath = \"data\/\" + path\r\n\t\tReturn LoadText( path )\r\n\tEndMethod\r\n\t\r\n\t' ***** GXTK API *****\r\n\t\r\n\tMethod GraphicsDevice:gxtkGraphics()\r\n\t\tReturn ggraphics\r\n\tEndMethod\r\n\r\n\tMethod InputDevice:gxtkInput()\r\n\t\tReturn ginput\r\n\tEndMethod\r\n\r\n\tMethod AudioDevice:gxtkAudio()\r\n\t\tReturn gaudio\r\n\tEndMethod\r\n\r\n\tMethod SetUpdateRate:Int(hertz:Int)\r\n\t\tupdateRate = hertz\r\n\t\tIf Not vloading Then SetFrameRate(updateRate)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod MilliSecs:Int()\r\n\t\tReturn BlitzMaxMillisecs() - startMillis\r\n\tEndMethod\r\n\t\r\n\tMethod Loading:Int()\r\n\t\tReturn vloading\r\n\tEndMethod\r\n\r\n\tMethod OnCreate:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod OnUpdate:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod OnSuspend:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod OnResume:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod OnRender:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod OnLoading:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkGraphics\r\n\tField gmode:Int = 1\r\n\tField ix:Float=1,iy:Float,jx:Float,jy:Float=1,tx:Float,ty:Float\r\n\tField sx:Float=1,sy:Float=1,rot:Float=0\r\n\t\r\n\tMethod Mode:Int()\r\n\t\tReturn gmode\r\n\tEndMethod\r\n\t\r\n\tMethod Cls:Int(r:Int = 0, g:Int = 0, b:Int = 0)\r\n\t\tBlitzMaxCls(r, g, b)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawPoint:Int(x:Float, y:Float)\r\n\t\tLocal nx:Float = TransX(x,y)\r\n\t\tLocal ny:Float = TransY(x,y)\r\n\t\tPlot nx, ny\r\n\tEndMethod\r\n\t\r\n\tMethod LoadSurface:gxtkSurface(path:String)\r\n\t\tLocal image:TImage = LoadImage(\"data\/\"+path)\r\n\t\tIf image Then\r\n\t\t\tLocal gs:gxtkSurface = New gxtkSurface\r\n\t\t\tgs.setImage(image)\r\n\t\t\tReturn gs\r\n\t\tEndIf\r\n\t\tReturn Null\r\n\tEndMethod\r\n\t\r\n\tMethod BeginRender()\r\n\tEndMethod\r\n\t\r\n\tMethod EndRender()\r\n\t\tFlip\r\n\tEndMethod\r\n\t\r\n\tMethod SetColor:Int(r:Int, g:Int, b:Int)\r\n\t\tBlitzMaxSetColor(r, g, b)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod SetAlpha:Int(a:Float)\r\n\t\tBlitzMaxSetAlpha(a)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod SetBlend:Int(blend:Int)\r\n\t\tBlitzMaxSetBlend(blend)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod Width:Int()\r\n\t\tReturn GraphicsWidth()\r\n\tEndMethod\r\n\t\r\n\tMethod Height:Int()\r\n\t\tReturn GraphicsHeight()\r\n\tEndMethod\r\n\t\r\n\tMethod SetScissor:Int(x:Int, y:Int, w:Int, h:Int)\r\n\t\tSetViewport(x, y, w, h) ' NOT TESTED!\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod TransX:Float(x:Float, y:Float)\r\n\t\tReturn ix*x + jx*y + tx\r\n\tEndMethod\r\n\t\r\n\tMethod TransY:Float(x:Float, y:Float)\r\n\t\tReturn iy*x + jy*y + ty\r\n\tEndMethod\r\n\t\r\n\tMethod SetMatrix:Int(ix:Float,iy:Float,jx:Float,jy:Float,tx:Float,ty:Float)\r\n\t\tSelf.ix = ix ; Self.iy = iy\r\n\t\tSelf.jx = jx ; Self.jy = jy\r\n\t\tSelf.tx = tx ; Self.ty = ty\r\n\t\tsx = Sqr( (ix*ix) + (jx*jx) )\r\n\t\tsy = Sqr( (iy*iy) + (jy*jy) )\r\n\t\trot = -Atan2( jx, ix )\r\n\t\tSetTransform( rot, sx, sy )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawSurface:Int(surface:gxtkSurface,x:Float,y:Float)\r\n\t\tLocal nx:Float = TransX(x,y)\r\n\t\tLocal ny:Float = TransY(x,y)\r\n\t\tDrawImage(surface.image, nx, ny, 0)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawSurface2:Int(surface:gxtkSurface,x:Float,y:Float, srcx:Int, srcy:Int, srcw:Int, srch:Int )\r\n\t\tLocal nx:Float = TransX(x,y)\r\n\t\tLocal ny:Float = TransY(x,y)\r\n\t\tDrawSubImageRect(surface.image, nx, ny, srcw, srch, srcx, srcy, srcw, srch)\t\t\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawLine:Int( x1:Float,y1:Float,x2:Float,y2:Float )\r\n\t\tLocal nx1:Float = TransX(x1,y1)\r\n\t\tLocal ny1:Float = TransY(x1,y1)\r\n\t\tLocal nx2:Float = TransX(x2,y2)\r\n\t\tLocal ny2:Float = TransY(x2,y2)\r\n\t\t' Need to reset transform so that BlitzMax doesn't try to apply rotation\r\n\t\tSetTransform( 0, 1, 1 )\r\n\t\tBlitzMaxDrawLine(nx1, ny1, nx2, ny2)\r\n\t\tSetTransform( rot, sx, sy )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawOval:Int( x:Float, y:Float, w:Float, h:Float )\r\n\t\tLocal nx:Float = TransX(x,y)\r\n\t\tLocal ny:Float = TransY(x,y)\r\n\t\tBlitzMaxDrawOval(nx, ny, w, h)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawPoly:Int(vertices:Float[])\r\n\t\t' setting the origin to use the current rotation translation\r\n\t\tSetOrigin(TransX(0,0), TransY(0,0))\r\n\t\tBlitzMaxDrawPoly( vertices )\r\n\t\tSetOrigin(0, 0)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawRect:Int( x:Float, y:Float, w:Float, h:Float )\r\n\t\tLocal nx:Float = TransX(x,y)\r\n\t\tLocal ny:Float = TransY(x,y)\r\n\t\tBlitzMaxDrawRect(nx, ny, w, h)\r\n\t\tReturn 0\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkInput\r\n\tMethod MouseX:Float()\r\n\t\tReturn BRL.PolledInput.MouseX()\r\n\tEndMethod\r\n\r\n\tMethod MouseY:Float()\r\n\t\tReturn BRL.PolledInput.MouseY()\r\n\tEndMethod\r\n\t\r\n\tMethod KeyDown:Int( key:Int )\r\n\t\tif( key = 384 ) key = 1 ' change TOUCH0 to MOUSE_LMB\r\n\r\n\t\tIf( key >= 1 And key <= 3 )\r\n\t\t\tReturn BRL.PolledInput.MouseDown( key )\r\n\t\tEndIf\r\n\t\tIf key < 256\r\n\t\t\tReturn BRL.PolledInput.KeyDown( key )\r\n\t\tElse\r\n\t\t\tReturn 0\r\n\t\tEndIf\r\n\tEndMethod\r\n\r\n\tMethod KeyHit:Int( key:Int )\r\n\t\tif( key = 384 ) key = 1 ' change TOUCH0 to MOUSE_LMB\r\n\t\tIf( key >= 1 And key <= 3 )\r\n\t\t\tReturn BRL.PolledInput.MouseHit( key )\r\n\t\tEndIf\r\n\t\tIf key < 256\r\n\t\t\tReturn BRL.PolledInput.KeyHit( key )\r\n\t\tElse\r\n\t\t\tReturn 0\r\n\t\tEndIf\r\n\tEndMethod\r\n\r\n\tMethod GetChar:Int()\r\n\t\tReturn BRL.PolledInput.GetChar()\r\n\tEndMethod\r\n\r\n\tMethod JoyX:Int( index:Int )\r\n\t\tReturn Pub.FreeJoy.JoyX( index )\r\n\tEndMethod\r\n\r\n\tMethod JoyY:Int( index:Int )\r\n\t\tReturn Pub.FreeJoy.JoyY( index )\r\n\tEndMethod\r\n\r\n\tMethod JoyZ:Int( index:Int )\r\n\t\tReturn Pub.FreeJoy.JoyZ( index )\r\n\tEndMethod\r\n\r\n\tMethod TouchX:Float( index:Int )\r\n\t\tReturn BRL.PolledInput.MouseX()\r\n\tEndMethod\r\n\r\n\tMethod TouchY:Float( index:Int )\r\n\t\tReturn BRL.PolledInput.MouseY()\r\n\tEndMethod\r\n\t\r\n\tMethod AccelX:Int()\r\n\t\treturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod AccelY:Int()\r\n\t\treturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod AccelZ:Int()\r\n\t\treturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod SetKeyboardEnabled:Int( enabled:int )\r\n\t\tReturn 0\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkChannel\r\n\tField channel:TChannel\t' null then not playing\r\n\tField sample:gxtkSample\r\n\tField loops:int\r\n\t'Field transform:SoundTransform=new SoundTransform()\r\n\t'Field pausepos:Number\r\n\tField state:int\r\n\t\r\n\tMethod New()\r\n\t\tchannel = New TChannel\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkAudio\r\n\tField amusicState:Int = 0\r\n\tField channels:gxtkChannel[] = New gxtkChannel[33]\r\n\t\r\n\tMethod New()\r\n\t\tFor local i:Int = 0 To 33 - 1\r\n\t\t\tchannels[i] = New gxtkChannel\r\n\t\tNext\r\n\tEndMethod\r\n\t\r\n\tMethod MusicState:Int()\r\n'\t\tIf( musicState = 1 And music.isPlaying() = False )\r\n'\t\t\tmusicState = 0;\r\n'\t\tEndif\r\n\t\tReturn amusicState\r\n\tEndMethod\r\n\t\r\n\tMethod PlayMusic:Int( path:String, flags:Int )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod ChannelState:int( channel:int )\r\n\t\tReturn -1\r\n\tEndMethod\r\n\t\r\n\tMethod StopMusic()\r\n\tEndMethod\r\n\t\r\n\tMethod StopChannel( channel:Int )\r\n\tEndMethod\r\n\r\n\tMethod PlaySample( sound:gxtkSample, channel:Int, flags:Int )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\t\r\n\t\t'If chan.state <> 0 Then chan.channel.Stop() <-- this crashes after the first play!?\r\n\t\t\r\n\t\tchan.sample = sound\r\n\t\t'chan.loops = flags ? 0x7fffffff : 0;\r\n\t\t'chan.channel = sample.sound.play( 0,chan.loops,chan.transform );\r\n\t\t'chan.channel = sound\r\n\t\tchan.state=1\r\n\t\r\n\t\tPlaySound( sound.sound, chan.channel )\r\n\tEndMethod\r\n\r\n\tMethod SetPan( channel:Int, pan:Float )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tchan.channel.SetPan(pan)\r\n\tEndMethod\r\n\r\n\tMethod SetRate( channel:Int, rate:Float )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tchan.channel.SetRate(rate)\r\n\tEndMethod\r\n\r\n\tMethod PauseMusic:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod ResumeMusic:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod SetMusicVolume:Int( volume:Float )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod SetVolume:Int( channel:Int, volume:Float )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tchan.channel.SetVolume(volume)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod LoadSample:gxtkSample( path:String )\r\n\t\tLocal extension:String = ExtractExt( path)\r\n\t\tIf extension = \"ogg\" Or extension = \"wav\" Then\r\n\t\t\tLocal sound:TSound = LoadSound(\"data\/\"+path)\r\n\t\t\tIf sound Then\r\n\t\t\t\tLocal gs:gxtkSample = New gxtkSample\r\n\t\t\t\tgs.setSound(sound)\r\n\t\t\t\tReturn gs\r\n\t\t\tEndIf\r\n\t\tElse\r\n\t\t\tRuntimeError \"BlitzMax can only use ogg and wav file formats\"\r\n\t\tEndIf\r\n\t\tReturn Null\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkSample\r\n\tField sound:TSound\r\n\t\r\n\tMethod setSound(sound:TSound)\r\n\t\tSelf.sound = sound\r\n\tEndMethod\r\n\t\r\n\tMethod Discard()\r\n\t\tSelf.sound = null\r\n\tEndMethod\r\nEndType\r\n\r\nFunction BlitzMaxDrawPoly:Int(vertices:Float[])\r\n\tDrawPoly vertices\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxDrawRect:Int( x:Float, y:Float, w:Float, h:Float )\r\n\tDrawRect x, y, w, h\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxDrawOval:Int( x:Float, y:Float, w:Float, h:Float )\r\n\tDrawOval x, y, w, h\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxDrawLine:Int( x1:Float,y1:Float,x2:Float,y2:Float )\r\n\tDrawLine x1, y1, x2, y2\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxMillisecs:Int()\r\n\tReturn MilliSecs()\r\nEndFunction\r\n\r\nFunction BlitzMaxSetColor(r:Int, g:Int, b:Int)\r\n\tSetColor(r, g, b)\r\nEndFunction\r\n\r\nFunction BlitzMaxSetBlend(blend:Int)\r\n\tSelect blend\r\n\t\tCase 0\r\n\t\t\tSetBlend( ALPHABLEND )\r\n\t\tCase 1\r\n\t\t\tSetBlend( LIGHTBLEND )\r\n\tEnd Select\r\nEndFunction\r\n\r\nFunction BlitzMaxSetAlpha(a:Float)\r\n\tSetAlpha(a)\r\nEndFunction\r\n\r\nFunction BlitzMaxCls(r:Int = 0, g:Int = 0, b:Int = 0)\r\n\tSetClsColor(r, g, b)\r\n\tCls\r\nEndFunction\r\n\r\nType gxtkSurface\r\n\tField w:Int, h:Int\r\n\tField image:TImage\r\n\t\r\n\tMethod setImage(image:TImage)\r\n\t\tSelf.image = image\r\n\tEndMethod\r\n\t\r\n\tMethod Width:Int()\r\n\t\tReturn image.Width\r\n\tEndMethod\r\n\t\r\n\tMethod Height:Int()\r\n\t\tReturn image.Height\r\n\tEndMethod\r\n\t\r\n\tMethod Discard()\r\n\tEndMethod\r\nEndType\r\n\r\n' ***** End mojo.bmax.bmx ******\r\n\r\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"04a9f75c3e50639801ce72bef27e90692ff3ed16","subject":"Whitespace","message":"Whitespace\n","repos":"Htbaa\/zmq.mod,Htbaa\/zmq.mod","old_file":"zmq.bmx","new_file":"zmq.bmx","new_contents":"Rem\n\tCopyright (c) 2012 Christiaan Kras\n\t\n\tPermission is hereby granted, free of charge, to any person obtaining a copy\n\tof this software and associated documentation files (the \"Software\"), to deal\n\tin the Software without restriction, including without limitation the rights\n\tto use, copy, modify, merge, publish, distribute, sublicense, and\/or sell\n\tcopies of the Software, and to permit persons to whom the Software is\n\tfurnished to do so, subject to the following conditions:\n\t\n\tThe above copyright notice and this permission notice shall be included in\n\tall copies or substantial portions of the Software.\n\t\n\tTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n\tIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n\tFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n\tAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n\tLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n\tOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n\tTHE SOFTWARE.\nEnd Rem\n\nSuperStrict\n\nRem\n\tbbdoc: htbaapub.zmq\n\tabout: This module is still an early work in progress. If you run into any\n\tbugs please report them at https:\/\/github.com\/Htbaa\/zmq.mod\/issues<\/a>.\nEndRem\nModule htbaapub.zmq\nModuleInfo \"Name: htbaapub.zmq\"\nModuleInfo \"Description: A wrapper for ZeroMQ\"\nModuleInfo \"Version: 0.02\"\nModuleInfo \"License: MIT\"\nModuleInfo \"Author: Christiaan Kras\"\nModuleInfo \"ZeroMQ: http:\/\/www.zeromq.org<\/a>\"\nModuleInfo \"ZeroMQ License: LGPL (see contents of .\/zeromq)\"\nModuleInfo \"Git repository: https:\/\/github.com\/Htbaa\/zmq.mod\/<\/a>\"\nModuleInfo \"Issues: https:\/\/github.com\/Htbaa\/zmq.mod\/issues<\/a>\"\nModuleInfo \"History: Added a couple of unit tests (bah.maxunit required)\"\nModuleInfo \"History: 0.02\"\nModuleInfo \"History: Added more examples; Hello World server and client\"\nModuleInfo \"History: Added more examples; Weather Update server and client\"\nModuleInfo \"History: TZMQ_Socket.SetSockOpt() now properly sets options\"\nModuleInfo \"History: TZMQ_Message.Close() now properly frees up memory\"\nModuleInfo \"History: 0.01\"\nModuleInfo \"History: First release of htbaapub.zmq using ZMQ 2.1.11. No support yet for input\/output multiplexing with zmq_poll()\"\n\n?Linux\n\tImport \"-lzmq\"\n?Win32\n\tImport \"zeromq\/lib\/libzmq.dll.a\"\n?\n\nImport \"glue.c\"\nInclude \"exception.bmx\"\nInclude \"constants.bmx\"\nInclude \"context.bmx\"\nInclude \"socket.bmx\"\nInclude \"message.bmx\"\n\n'Glue\/Helper functions\nExtern \"C\"\n\n\tRem\n\t\tbbdoc: Create an empty zmq_message_t struct\n\t\treturns: Returns a pointer to a new zmq_message_t struct\n\tEnd Rem\n\tFunction bmx_zmq_message_t:Byte Ptr()\n\n\tRem\n\t\tbbdoc: Create a zmq_message_t struct with preset data\n\t\treturns: Returns a pointer to a new zmq_message_t struct with given data\n\tEnd Rem\n\tFunction bmx_zmq_new_message:Byte Ptr(str$z)\n\t\n\tRem\n\t\tbbdoc: Alias for free(), for cleaning up data structures\n\tEnd Rem\n\tFunction bmx_zmq_free(msg:Byte Ptr)\nEnd Extern\n\n'ZeroMQ functions\nExtern\n\tFunction zmq_version(major:Int Var, minor:Int Var, patch:Int Var)\n\n\tFunction zmq_init:Byte Ptr(io_threads:Int)\n\tFunction zmq_term:Int(context:Byte Ptr)\n\t\n\tFunction zmq_errno:Int()\n\tFunction zmq_strerror$z(errnum:Int)\n\t\n\tFunction zmq_socket:Byte Ptr(context:Byte Ptr, socket_type:Int)\n\tFunction zmq_close:Int(s:Byte Ptr)\n\tFunction zmq_setsockopt:Int(s:Byte Ptr, option:Int, optval$z, length:Int)\n\tFunction zmq_getsockopt:Int(s:Byte Ptr, option:Int, optval:Byte Ptr, length:Int Var)\n\t'ZMQ_EXPORT Int zmq_getsockopt (void *s, Int option, void *optval, size_t *optvallen);\n\tFunction zmq_bind(s:Byte Ptr, addr$z)\n\tFunction zmq_connect:Int(s:Byte Ptr, addr$z)\n\tFunction zmq_send:Int(s:Byte Ptr, msg:Byte Ptr, flags:Int)\n\tFunction zmq_recv:Int(s:Byte Ptr, msg:Byte Ptr, flags:Int)\n\n\tFunction zmq_msg_init:Int(msg:Byte Ptr)\n\tFunction zmq_msg_init_size:Int(msg:Byte Ptr, size:Long)\n\tFunction zmq_msg_init_data:Int(msg:Byte Ptr, data:Byte Ptr, size:Long, ffn:Byte Ptr, hint:Byte Ptr)\n\tFunction zmq_msg_close:Int(msg:Byte Ptr)\n\tFunction zmq_msg_move:Int(dest:Byte Ptr, src:Byte Ptr)\n\tFunction zmq_msg_copy:Int(dest:Byte Ptr, src:Byte Ptr)\n\tFunction zmq_msg_data:Byte Ptr(msg:Byte Ptr)\n\tFunction zmq_msg_size:Int(msg:Byte Ptr)\n\t\n\tFunction zmq_poll:Int(items:Byte Ptr, nitems:Int, timeout:Long)\n\t\n\tFunction zmq_device:Int(device:Int, insocket:Byte Ptr, outsocket:Byte Ptr)\nEnd Extern\n\nRem\n\tbbdoc: General ZMQ functions\nEnd Rem\nType TZMQ\n\n\tRem\n\t\tbbdoc: Get ZMQ Version\n\t\treturns: String\n\tEnd Rem\n\tFunction Version:String()\n\t\tLocal major:Int, minor:Int, patch:Int\n\t\tzmq_version(major, minor, patch)\n\t\tReturn major + \".\" + minor + \".\" + patch\n\tEnd Function\n\n\tRem\n\t\tbbdoc: Get current ZMQ error descriptions\n\t\treturns: String\n\tEnd Rem\n\tFunction Error:String()\n\t\tReturn zmq_strerror( TZMQ.ErrorNumber() )\n\tEnd Function\n\n\tRem\n\t\tbbdoc: Get current ZMQ error number\n\t\treturns: Int\n\tEnd Rem\n\tFunction ErrorNumber:Int()\n\t\tReturn zmq_errno()\n\tEnd Function\nEnd Type","old_contents":"Rem\n\tCopyright (c) 2012 Christiaan Kras\n\t\n\tPermission is hereby granted, free of charge, to any person obtaining a copy\n\tof this software and associated documentation files (the \"Software\"), to deal\n\tin the Software without restriction, including without limitation the rights\n\tto use, copy, modify, merge, publish, distribute, sublicense, and\/or sell\n\tcopies of the Software, and to permit persons to whom the Software is\n\tfurnished to do so, subject to the following conditions:\n\t\n\tThe above copyright notice and this permission notice shall be included in\n\tall copies or substantial portions of the Software.\n\t\n\tTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n\tIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n\tFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n\tAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n\tLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n\tOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n\tTHE SOFTWARE.\nEnd Rem\n\nSuperStrict\n\nRem\n\tbbdoc: htbaapub.zmq\n\tabout: This module is still an early work in progress. If you run into any\n\tbugs please report them at https:\/\/github.com\/Htbaa\/zmq.mod\/issues<\/a>.\nEndRem\nModule htbaapub.zmq\nModuleInfo \"Name: htbaapub.zmq\"\nModuleInfo \"Description: A wrapper for ZeroMQ\"\nModuleInfo \"Version: 0.02\"\nModuleInfo \"License: MIT\"\nModuleInfo \"Author: Christiaan Kras\"\nModuleInfo \"ZeroMQ: http:\/\/www.zeromq.org<\/a>\"\nModuleInfo \"ZeroMQ License: LGPL (see contents of .\/zeromq)\"\nModuleInfo \"Git repository: https:\/\/github.com\/Htbaa\/zmq.mod\/<\/a>\"\nModuleInfo \"Issues: https:\/\/github.com\/Htbaa\/zmq.mod\/issues<\/a>\"\nModuleInfo \"History: Added a couple of unit tests (bah.maxunit required)\"\nModuleInfo \"History: 0.02\"\nModuleInfo \"History: Added more examples; Hello World server and client\"\nModuleInfo \"History: Added more examples; Weather Update server and client\"\nModuleInfo \"History: TZMQ_Socket.SetSockOpt() now properly sets options\"\nModuleInfo \"History: TZMQ_Message.Close() now properly frees up memory\"\nModuleInfo \"History: 0.01\"\nModuleInfo \"History: First release of htbaapub.zmq using ZMQ 2.1.11. No support yet for input\/output multiplexing with zmq_poll()\"\n\n?Linux\n\tImport \"-lzmq\"\n?Win32\n\tImport \"zeromq\/lib\/libzmq.dll.a\"\n?\n\nImport \"glue.c\"\nInclude \"exception.bmx\"\nInclude \"constants.bmx\"\nInclude \"context.bmx\"\nInclude \"socket.bmx\"\nInclude \"message.bmx\"\n\n'Glue\/Helper functions\nExtern \"C\"\n\n\tRem\n\t\tbbdoc: Create an empty zmq_message_t struct\n\t\treturns: Returns a pointer to a new zmq_message_t struct\n\tEnd Rem\n\tFunction bmx_zmq_message_t:Byte Ptr()\n\n\tRem\n\t\tbbdoc: Create a zmq_message_t struct with preset data\n\t\treturns: Returns a pointer to a new zmq_message_t struct with given data\n\tEnd Rem\n\tFunction bmx_zmq_new_message:Byte Ptr(str$z)\n\t\n\tRem\n\t\tbbdoc: Alias for free(), for cleaning up data structures\n\tEnd Rem\n\tFunction bmx_zmq_free(msg:Byte Ptr)\nEnd Extern\n\n'ZeroMQ functions\nExtern\n\tFunction zmq_version(major:Int Var, minor:Int Var, patch:Int Var)\n\n\tFunction zmq_init:Byte Ptr(io_threads:Int)\n\tFunction zmq_term:Int(context:Byte Ptr)\n\t\n\tFunction zmq_errno:Int()\n\tFunction zmq_strerror$z(errnum:Int)\n\t\n\tFunction zmq_socket:Byte Ptr(context:Byte Ptr, socket_type:Int)\n\tFunction zmq_close:Int(s:Byte Ptr)\n\tFunction zmq_setsockopt:Int(s:Byte Ptr, option:Int, optval$z, length:Int)\n\tFunction zmq_getsockopt:Int(s:Byte Ptr, option:Int, optval:Byte Ptr, length:Int Var)\n\t'ZMQ_EXPORT Int zmq_getsockopt (void *s, Int option, void *optval, size_t *optvallen);\n\tFunction zmq_bind(s:Byte Ptr, addr$z)\n\tFunction zmq_connect:Int(s:Byte Ptr, addr$z)\n\tFunction zmq_send:Int(s:Byte Ptr, msg:Byte Ptr, flags:Int)\n\tFunction zmq_recv:Int(s:Byte Ptr, msg:Byte Ptr, flags:Int)\t\n\n\tFunction zmq_msg_init:Int(msg:Byte Ptr)\n\tFunction zmq_msg_init_size:Int(msg:Byte Ptr, size:Long)\n\tFunction zmq_msg_init_data:Int(msg:Byte Ptr, data:Byte Ptr, size:Long, ffn:Byte Ptr, hint:Byte Ptr)\n\tFunction zmq_msg_close:Int(msg:Byte Ptr)\n\tFunction zmq_msg_move:Int(dest:Byte Ptr, src:Byte Ptr)\n\tFunction zmq_msg_copy:Int(dest:Byte Ptr, src:Byte Ptr)\n\tFunction zmq_msg_data:Byte Ptr(msg:Byte Ptr)\n\tFunction zmq_msg_size:Int(msg:Byte Ptr)\n\t\n\tFunction zmq_poll:Int(items:Byte Ptr, nitems:Int, timeout:Long)\n\t\n\tFunction zmq_device:Int(device:Int, insocket:Byte Ptr, outsocket:Byte Ptr)\nEnd Extern\n\nRem\n\tbbdoc: General ZMQ functions\nEnd Rem\nType TZMQ\n\n\tRem\n\t\tbbdoc: Get ZMQ Version\n\t\treturns: String\n\tEnd Rem\n\tFunction Version:String()\n\t\tLocal major:Int, minor:Int, patch:Int\n\t\tzmq_version(major, minor, patch)\n\t\tReturn major + \".\" + minor + \".\" + patch\n\tEnd Function\n\n\tRem\n\t\tbbdoc: Get current ZMQ error descriptions\n\t\treturns: String\n\tEnd Rem\n\tFunction Error:String()\n\t\tReturn zmq_strerror( TZMQ.ErrorNumber() )\n\tEnd Function\n\n\tRem\n\t\tbbdoc: Get current ZMQ error number\n\t\treturns: Int\n\tEnd Rem\n\tFunction ErrorNumber:Int()\n\t\tReturn zmq_errno()\n\tEnd Function\nEnd Type","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"79b50119b7a569f00a556084627e72b277a4e4df","subject":"TSurface.HasAlpha now uses TBrush.HasAlpha","message":"TSurface.HasAlpha now uses TBrush.HasAlpha\n","repos":"kfprimm\/maxb3d,kfprimm\/maxb3d","old_file":"core.mod\/surface.bmx","new_file":"core.mod\/surface.bmx","new_contents":"\nStrict\n\nImport MaxB3D.Math\nImport \"brush.bmx\"\n\nConst SURFACE_POS = 1\nConst SURFACE_NML = 2\nConst SURFACE_CLR = 4\nConst SURFACE_TEX = 8\nConst SURFACE_TRI = 16\nConst SURFACE_ALL = SURFACE_POS|SURFACE_NML|SURFACE_CLR|SURFACE_TEX|SURFACE_TRI\n\nType TSurface\n\tField _brush:TBrush=New TBrush\n\t\n\tField _vertexcnt,_trianglecnt\n\tField _vertexpos#[],_vertexnml#[],_vertexclr#[]\t\n\tField _vertextex#[][],_texcoordsize=-1\n\t\n\tField _triangle[]\n\t\n\tField _res:TSurfaceRes,_reset=-1\n\t\n\tField _resetbounds=True,_minx#,_miny#,_minz#,_maxx#,_maxy#,_maxz#\n\tField _boundsupdatedmsg:TMaxB3DMsg=New TMaxB3DMsg\n\t\n\tMethod Copy:TSurface(data=SURFACE_ALL)\n\t\tLocal surface:TSurface=New TSurface\n\t\tsurface._brush.Load(_brush)\n\t\tsurface._vertexcnt=_vertexcnt\t\t\n\t\tIf data&SURFACE_POS surface._vertexpos=_vertexpos[..]\n\t\tIf data&SURFACE_NML surface._vertexnml=_vertexnml[..]\n\t\tIf data&SURFACE_CLR surface._vertexclr=_vertexclr[..]\n\t\tIf data&SURFACE_TEX surface._vertextex=_vertextex[..];surface._texcoordsize=_texcoordsize\n\t\tIf data&SURFACE_TRI surface._trianglecnt=_trianglecnt;surface._triangle=_triangle[..]\n\t\tReturn surface\n\tEnd Method\n\t\n\tMethod Resize(vertexcount,trianglecount)\n\t\tIf vertexcount>-1\n\t\t\t_vertexpos=_vertexpos[..vertexcount*3]\n\t\t\t_vertexnml=_vertexnml[..vertexcount*3]\n\t\t\t_vertexclr=_vertexclr[..vertexcount*4]\n\t\t\tFor Local i=_vertexcnt*4 To vertexcount*4-1\n\t\t\t\t_vertexclr[i]=1.0\n\t\t\tNext\n\t\t\tFor Local i=0 To _texcoordsize-1\n\t\t\t\t_vertextex[i]=_vertextex[i][..vertexcount*2]\n\t\t\tNext\n\t\t\t_vertexcnt=vertexcount\n\t\tEndIf\n\t\t\n\t\tIf trianglecount>-1\n\t\t\t_triangle=_triangle[..trianglecount*3]\n\t\t\t_trianglecnt=trianglecount\n\t\tEndIf\n\tEnd Method\n\t\n\tMethod GetSize(vertices Var,triangles Var)\n\t\tvertices=_vertexcnt\n\t\ttriangles=_trianglecnt\n\tEnd Method\n\n\tMethod AddVertex(x#,y#,z#,u#=0.0,v#=0.0)\n\t\tResize(_vertexcnt+1,-1)\n\t\tSetCoords(_vertexcnt-1,x,y,z)\n\t\tSetTexCoords(_vertexcnt-1,u,v)\n\t\tReturn _vertexcnt-1\n\tEnd Method\n\t\n\tMethod GetCoords(index,x# Var,y# Var,z# Var)\n\t\tx=_vertexpos[index*3+0]\n\t\ty=_vertexpos[index*3+1]\n\t\tz=_vertexpos[index*3+2]\n\tEnd Method\n\tMethod SetCoords(index,x#,y#,z#)\n\t\t_vertexpos[index*3+0]=x\n\t\t_vertexpos[index*3+1]=y\n\t\t_vertexpos[index*3+2]=z\t\t\n\t\t_reset:|1;_resetbounds=True\n\tEnd Method\n\t\n\tMethod GetNormal(index,nx# Var,ny# Var,nz# Var)\n\t\tnx=_vertexnml[index*3+0]*-1\n\t\tny=_vertexnml[index*3+1]*-1\n\t\tnz=_vertexnml[index*3+2]*-1\n\tEnd Method\n\tMethod SetNormal(index,nx#,ny#,nz#)\n\t\t_vertexnml[index*3+0]=nx*-1\n\t\t_vertexnml[index*3+1]=ny*-1\n\t\t_vertexnml[index*3+2]=nz*-1\n\t\t_reset:|2\n\tEnd Method\n\t\n\tMethod GetColor(index,red Var,green Var,blue Var,alpha# Var)\n\t\tred=_vertexclr[index*4+0]*255.0\n\t\tgreen=_vertexclr[index*4+1]*255.0\n\t\tblue=_vertexclr[index*4+2]*255.0\n\t\talpha=_vertexclr[index*4+3]\n\tEnd Method\n\tMethod SetColor(index,red,green,blue,alpha#)\n\t\t_vertexclr[index*4+0]=red\/255.0\n\t\t_vertexclr[index*4+1]=green\/255.0\n\t\t_vertexclr[index*4+2]=blue\/255.0\n\t\t_vertexclr[index*4+3]=alpha\n\t\t_reset:|4\n\tEnd Method\n\t\n\tMethod GetTexCoords(index,u# Var,v# Var,set=0)\n\t\tResizeTexSets set\n\t\tu=_vertextex[set][index*2+0]\n\t\tv=_vertextex[set][index*2+1]\n\tEnd Method\n\tMethod SetTexCoords(index,u#,v#,set=0)\n\t\tResizeTexSets set\n\t\t_vertextex[set][index*2+0]=u\n\t\t_vertextex[set][index*2+1]=v\n\t\t_reset:|Int(2^(4+set))\n\tEnd Method\n\t\n\tMethod ResizeTexSets(set)\n\t\tIf set+1>_texcoordsize\n\t\t\tLocal size=_vertextex.length\n\t\t\t_vertextex=_vertextex[..set+1]\t\t\t\n\t\t\tFor Local i=size To set\n\t\t\t\t_vertextex[i]=New Float[_vertexcnt*2]\n\t\t\tNext\t\n\t\t\t_texcoordsize=set+1\t\t\n\t\tEndIf\n\tEnd Method\n\t\n\tMethod AddTriangle(v0,v1,v2)\n\t\tResize(-1,_trianglecnt+1)\n\t\tSetTriangle _trianglecnt-1,v0,v1,v2\n\t\tReturn _trianglecnt-1\n\tEnd Method\n\t\n\tMethod GetTriangle(index,v0 Var,v1 Var,v2 Var)\n\t\tv0=_triangle[index*3+0]\n\t\tv1=_triangle[index*3+1]\n\t\tv2=_triangle[index*3+2]\n\tEnd Method\n\tMethod SetTriangle(index,v0,v1,v2)\n\t\t_triangle[index*3+0]=v0\n\t\t_triangle[index*3+1]=v1\n\t\t_triangle[index*3+2]=v2\n\t\t_reset:|8\n\tEnd Method\n\t\n\tMethod Flip()\n\t\tFor Local t=0 To _trianglecnt-1\n\t\t\tLocal v2=_triangle[t*3+2]\n\t\t\t_triangle[t*3+2]=_triangle[t*3+0]\n\t\t\t_triangle[t*3+0]=v2\t\t\t\n\t\tNext\n\t\tFor Local v=0 To _vertexcnt-1\n\t\t\t_vertexnml[(v*3)+0]:*-1\n\t\t\t_vertexnml[(v*3)+1]:*-1\n\t\t\t_vertexnml[(v*3)+2]:*-1\n\t\tNext\n\t\t_reset:|2|8\n\tEnd Method\n\t\n\tMethod Transform(matrix:TMatrix)\n\t\tFor Local i=0 To _vertexcnt-1\n\t\t\tmatrix.TransformVec3 _vertexpos[i*3+0],_vertexpos[i*3+1],_vertexpos[i*3+2]\n\t\t\t'matrix.TransformVector _vertexnml[i+0],_vertexnml[i+1],_vertexnml[i+2],w\n\t\tNext\n\tEnd Method\n\t\n\tMethod UpdateBounds(force=False)\n\t\tIf Not _resetbounds And force=false Return\n\t\t_minx=999999999;_miny=999999999;_minz=999999999\n\t\t_maxx=-999999999;_maxy=-999999999;_maxz=-999999999\n\t\tFor Local v=0 To _vertexcnt-1\n\t\t\tLocal x#,y#,z#\n\t\t\tGetCoords v,x,y,z\t\t\t\t\n\t\t\t_minx=Min(x,_minx);_maxx=Max(x,_maxx)\n\t\t\t_miny=Min(y,_miny);_maxy=Max(y,_maxy)\n\t\t\t_minz=Min(z,_minz);_maxz=Max(z,_maxz)\n\t\tNext\n\t\t_boundsupdatedmsg.Run\n\t\t_resetbounds=False\n\tEnd Method\n\t\n\tMethod UpdateNormals(smoothing=True)\n\t\tIf smoothing\n\t\t\tC_UpdateNormals(_trianglecnt,_vertexcnt,_triangle,_vertexpos,_vertexnml)\n\t\tElse\n\t\t\tLocal face_normal:TVector[_trianglecnt],vertex_triangles[][_vertexcnt]\n\t\t\t\t\t\t\n\t\t\tFor Local i=0 To _trianglecnt-1\n\t\t\t\tLocal v0,v1,v2\n\t\t\t\tGetTriangle i,v0,v1,v2\n\t\t\t\t\n\t\t\t\tvertex_triangles[v0]:+[i]\n\t\t\t\tvertex_triangles[v1]:+[i]\n\t\t\t\tvertex_triangles[v2]:+[i]\n\t\t\t\t\n\t\t\t\tLocal a:TVector=New TVector,b:TVector=New TVector,c:TVector=New TVector\n\t\t\t\tGetCoords v0,a.x,a.y,a.z\n\t\t\t\tGetCoords v1,b.x,b.y,b.z\n\t\t\t\tGetCoords v2,c.x,c.y,c.z\n\t\t\t\t\n\t\t\t\tface_normal[i]=New TVector.FromTriangle(a,b,c)\t\n\t\t\tNext\n\t\n\t\t\tLocal normal:TVector=New TVector\n\t\t\tFor Local i=0 To _vertexcnt-1\n\t\t\t\tnormal.Create3(0,0,0)\n\t\t\t\tFor Local t=0 To vertex_triangles[i].length-1\n\t\t\t\t\tnormal=normal.Add(face_normal[vertex_triangles[i][t]])\t\t\n\t\t\t\tNext\n\t\t\t\tnormal.Normalize()\t\t\t\t\n\t\t\t\tSetNormal i,-normal.x,-normal.y,-normal.z\n\t\t\tNext\t\t\n\t\tEndIf\n\t\t_reset:|2\n\tEnd Method\n\t\n\tMethod SetTriangleNormal(index,nx#,ny#,nz#)\n\t\tLocal v0,v1,v2\n\t\tGetTriangle index,v0,v1,v2\n\t\tSetNormal v0,nx,ny,nz\n\t\tSetNormal v1,nx,ny,nz\n\t\tSetNormal v2,nx,ny,nz\n\tEnd Method\n\t\n\tMethod GetBrush:TBrush()\n\t\tReturn _brush.Copy()\n\tEnd Method\t\n\tMethod SetBrush(brush:TBrush)\n\t\t_brush.Load(brush)\n\tEnd Method\n\t\n\tMethod CountVertices()\n\t\tReturn _vertexcnt\n\tEnd Method\n\tMethod CountTriangles()\n\t\tReturn _trianglecnt\n\tEnd Method\n\t\n\tMethod IsEmpty()\n\t\tReturn _vertexcnt=0 And _trianglecnt=0\n\tEnd Method\n\t\t\n\tMethod HasAlpha()\n\t\tReturn _brush.HasAlpha()\n\tEnd Method\t\nEnd Type\n\nType TSurfaceRes Extends TDriverResource\n\tField _vertexcnt\n\tField _trianglecnt\n\t\n\tMethod Copy:TSurfaceRes() Abstract\nEnd Type\n\nType TMaxB3DMsg\n\tField _succ:TMaxB3DMsg\n\tField _context:Object\n\tField _func(context:Object)\n\t\n\tMethod Add(func(context:Object),context:Object)\n\t\tLocal msg:TMaxB3DMsg=Self\n\t\tWhile msg._succ\n\t\t\tmsg=msg._succ\n\t\tWend\n\t\tmsg._succ=New TMaxB3DMsg\n\t\tmsg._context=context\n\t\tmsg._func=func\n\tEnd Method\n\t\n\tMethod Run()\n\t\tLocal msg:TMaxB3DMsg=Self\n\t\tWhile msg\n\t\t\tIf msg._func msg._func(msg._context)\n\t\t\tmsg=msg._succ\n\t\tWend\n\tEnd Method\nEnd Type\n","old_contents":"\nStrict\n\nImport MaxB3D.Math\nImport \"brush.bmx\"\n\nConst SURFACE_POS = 1\nConst SURFACE_NML = 2\nConst SURFACE_CLR = 4\nConst SURFACE_TEX = 8\nConst SURFACE_TRI = 16\nConst SURFACE_ALL = SURFACE_POS|SURFACE_NML|SURFACE_CLR|SURFACE_TEX|SURFACE_TRI\n\nType TSurface\n\tField _brush:TBrush=New TBrush\n\t\n\tField _vertexcnt,_trianglecnt\n\tField _vertexpos#[],_vertexnml#[],_vertexclr#[]\t\n\tField _vertextex#[][],_texcoordsize=-1\n\t\n\tField _triangle[]\n\t\n\tField _res:TSurfaceRes,_reset=-1\n\t\n\tField _resetbounds=True,_minx#,_miny#,_minz#,_maxx#,_maxy#,_maxz#\n\tField _boundsupdatedmsg:TMaxB3DMsg=New TMaxB3DMsg\n\t\n\tMethod Copy:TSurface(data=SURFACE_ALL)\n\t\tLocal surface:TSurface=New TSurface\n\t\tsurface._brush.Load(_brush)\n\t\tsurface._vertexcnt=_vertexcnt\t\t\n\t\tIf data&SURFACE_POS surface._vertexpos=_vertexpos[..]\n\t\tIf data&SURFACE_NML surface._vertexnml=_vertexnml[..]\n\t\tIf data&SURFACE_CLR surface._vertexclr=_vertexclr[..]\n\t\tIf data&SURFACE_TEX surface._vertextex=_vertextex[..];surface._texcoordsize=_texcoordsize\n\t\tIf data&SURFACE_TRI surface._trianglecnt=_trianglecnt;surface._triangle=_triangle[..]\n\t\tReturn surface\n\tEnd Method\n\t\n\tMethod Resize(vertexcount,trianglecount)\n\t\tIf vertexcount>-1\n\t\t\t_vertexpos=_vertexpos[..vertexcount*3]\n\t\t\t_vertexnml=_vertexnml[..vertexcount*3]\n\t\t\t_vertexclr=_vertexclr[..vertexcount*4]\n\t\t\tFor Local i=_vertexcnt*4 To vertexcount*4-1\n\t\t\t\t_vertexclr[i]=1.0\n\t\t\tNext\n\t\t\tFor Local i=0 To _texcoordsize-1\n\t\t\t\t_vertextex[i]=_vertextex[i][..vertexcount*2]\n\t\t\tNext\n\t\t\t_vertexcnt=vertexcount\n\t\tEndIf\n\t\t\n\t\tIf trianglecount>-1\n\t\t\t_triangle=_triangle[..trianglecount*3]\n\t\t\t_trianglecnt=trianglecount\n\t\tEndIf\n\tEnd Method\n\t\n\tMethod GetSize(vertices Var,triangles Var)\n\t\tvertices=_vertexcnt\n\t\ttriangles=_trianglecnt\n\tEnd Method\n\n\tMethod AddVertex(x#,y#,z#,u#=0.0,v#=0.0)\n\t\tResize(_vertexcnt+1,-1)\n\t\tSetCoords(_vertexcnt-1,x,y,z)\n\t\tSetTexCoords(_vertexcnt-1,u,v)\n\t\tReturn _vertexcnt-1\n\tEnd Method\n\t\n\tMethod GetCoords(index,x# Var,y# Var,z# Var)\n\t\tx=_vertexpos[index*3+0]\n\t\ty=_vertexpos[index*3+1]\n\t\tz=_vertexpos[index*3+2]\n\tEnd Method\n\tMethod SetCoords(index,x#,y#,z#)\n\t\t_vertexpos[index*3+0]=x\n\t\t_vertexpos[index*3+1]=y\n\t\t_vertexpos[index*3+2]=z\t\t\n\t\t_reset:|1;_resetbounds=True\n\tEnd Method\n\t\n\tMethod GetNormal(index,nx# Var,ny# Var,nz# Var)\n\t\tnx=_vertexnml[index*3+0]*-1\n\t\tny=_vertexnml[index*3+1]*-1\n\t\tnz=_vertexnml[index*3+2]*-1\n\tEnd Method\n\tMethod SetNormal(index,nx#,ny#,nz#)\n\t\t_vertexnml[index*3+0]=nx*-1\n\t\t_vertexnml[index*3+1]=ny*-1\n\t\t_vertexnml[index*3+2]=nz*-1\n\t\t_reset:|2\n\tEnd Method\n\t\n\tMethod GetColor(index,red Var,green Var,blue Var,alpha# Var)\n\t\tred=_vertexclr[index*4+0]*255.0\n\t\tgreen=_vertexclr[index*4+1]*255.0\n\t\tblue=_vertexclr[index*4+2]*255.0\n\t\talpha=_vertexclr[index*4+3]\n\tEnd Method\n\tMethod SetColor(index,red,green,blue,alpha#)\n\t\t_vertexclr[index*4+0]=red\/255.0\n\t\t_vertexclr[index*4+1]=green\/255.0\n\t\t_vertexclr[index*4+2]=blue\/255.0\n\t\t_vertexclr[index*4+3]=alpha\n\t\t_reset:|4\n\tEnd Method\n\t\n\tMethod GetTexCoords(index,u# Var,v# Var,set=0)\n\t\tResizeTexSets set\n\t\tu=_vertextex[set][index*2+0]\n\t\tv=_vertextex[set][index*2+1]\n\tEnd Method\n\tMethod SetTexCoords(index,u#,v#,set=0)\n\t\tResizeTexSets set\n\t\t_vertextex[set][index*2+0]=u\n\t\t_vertextex[set][index*2+1]=v\n\t\t_reset:|Int(2^(4+set))\n\tEnd Method\n\t\n\tMethod ResizeTexSets(set)\n\t\tIf set+1>_texcoordsize\n\t\t\tLocal size=_vertextex.length\n\t\t\t_vertextex=_vertextex[..set+1]\t\t\t\n\t\t\tFor Local i=size To set\n\t\t\t\t_vertextex[i]=New Float[_vertexcnt*2]\n\t\t\tNext\t\n\t\t\t_texcoordsize=set+1\t\t\n\t\tEndIf\n\tEnd Method\n\t\n\tMethod AddTriangle(v0,v1,v2)\n\t\tResize(-1,_trianglecnt+1)\n\t\tSetTriangle _trianglecnt-1,v0,v1,v2\n\t\tReturn _trianglecnt-1\n\tEnd Method\n\t\n\tMethod GetTriangle(index,v0 Var,v1 Var,v2 Var)\n\t\tv0=_triangle[index*3+0]\n\t\tv1=_triangle[index*3+1]\n\t\tv2=_triangle[index*3+2]\n\tEnd Method\n\tMethod SetTriangle(index,v0,v1,v2)\n\t\t_triangle[index*3+0]=v0\n\t\t_triangle[index*3+1]=v1\n\t\t_triangle[index*3+2]=v2\n\t\t_reset:|8\n\tEnd Method\n\t\n\tMethod Flip()\n\t\tFor Local t=0 To _trianglecnt-1\n\t\t\tLocal v2=_triangle[t*3+2]\n\t\t\t_triangle[t*3+2]=_triangle[t*3+0]\n\t\t\t_triangle[t*3+0]=v2\t\t\t\n\t\tNext\n\t\tFor Local v=0 To _vertexcnt-1\n\t\t\t_vertexnml[(v*3)+0]:*-1\n\t\t\t_vertexnml[(v*3)+1]:*-1\n\t\t\t_vertexnml[(v*3)+2]:*-1\n\t\tNext\n\t\t_reset:|2|8\n\tEnd Method\n\t\n\tMethod Transform(matrix:TMatrix)\n\t\tFor Local i=0 To _vertexcnt-1\n\t\t\tmatrix.TransformVec3 _vertexpos[i*3+0],_vertexpos[i*3+1],_vertexpos[i*3+2]\n\t\t\t'matrix.TransformVector _vertexnml[i+0],_vertexnml[i+1],_vertexnml[i+2],w\n\t\tNext\n\tEnd Method\n\t\n\tMethod UpdateBounds(force=False)\n\t\tIf Not _resetbounds And force=false Return\n\t\t_minx=999999999;_miny=999999999;_minz=999999999\n\t\t_maxx=-999999999;_maxy=-999999999;_maxz=-999999999\n\t\tFor Local v=0 To _vertexcnt-1\n\t\t\tLocal x#,y#,z#\n\t\t\tGetCoords v,x,y,z\t\t\t\t\n\t\t\t_minx=Min(x,_minx);_maxx=Max(x,_maxx)\n\t\t\t_miny=Min(y,_miny);_maxy=Max(y,_maxy)\n\t\t\t_minz=Min(z,_minz);_maxz=Max(z,_maxz)\n\t\tNext\n\t\t_boundsupdatedmsg.Run\n\t\t_resetbounds=False\n\tEnd Method\n\t\n\tMethod UpdateNormals(smoothing=True)\n\t\tIf smoothing\n\t\t\tC_UpdateNormals(_trianglecnt,_vertexcnt,_triangle,_vertexpos,_vertexnml)\n\t\tElse\n\t\t\tLocal face_normal:TVector[_trianglecnt],vertex_triangles[][_vertexcnt]\n\t\t\t\t\t\t\n\t\t\tFor Local i=0 To _trianglecnt-1\n\t\t\t\tLocal v0,v1,v2\n\t\t\t\tGetTriangle i,v0,v1,v2\n\t\t\t\t\n\t\t\t\tvertex_triangles[v0]:+[i]\n\t\t\t\tvertex_triangles[v1]:+[i]\n\t\t\t\tvertex_triangles[v2]:+[i]\n\t\t\t\t\n\t\t\t\tLocal a:TVector=New TVector,b:TVector=New TVector,c:TVector=New TVector\n\t\t\t\tGetCoords v0,a.x,a.y,a.z\n\t\t\t\tGetCoords v1,b.x,b.y,b.z\n\t\t\t\tGetCoords v2,c.x,c.y,c.z\n\t\t\t\t\n\t\t\t\tface_normal[i]=New TVector.FromTriangle(a,b,c)\t\n\t\t\tNext\n\t\n\t\t\tLocal normal:TVector=New TVector\n\t\t\tFor Local i=0 To _vertexcnt-1\n\t\t\t\tnormal.Create3(0,0,0)\n\t\t\t\tFor Local t=0 To vertex_triangles[i].length-1\n\t\t\t\t\tnormal=normal.Add(face_normal[vertex_triangles[i][t]])\t\t\n\t\t\t\tNext\n\t\t\t\tnormal.Normalize()\t\t\t\t\n\t\t\t\tSetNormal i,-normal.x,-normal.y,-normal.z\n\t\t\tNext\t\t\n\t\tEndIf\n\t\t_reset:|2\n\tEnd Method\n\t\n\tMethod SetTriangleNormal(index,nx#,ny#,nz#)\n\t\tLocal v0,v1,v2\n\t\tGetTriangle index,v0,v1,v2\n\t\tSetNormal v0,nx,ny,nz\n\t\tSetNormal v1,nx,ny,nz\n\t\tSetNormal v2,nx,ny,nz\n\tEnd Method\n\t\n\tMethod GetBrush:TBrush()\n\t\tReturn _brush.Copy()\n\tEnd Method\t\n\tMethod SetBrush(brush:TBrush)\n\t\t_brush.Load(brush)\n\tEnd Method\n\t\n\tMethod CountVertices()\n\t\tReturn _vertexcnt\n\tEnd Method\n\tMethod CountTriangles()\n\t\tReturn _trianglecnt\n\tEnd Method\n\t\n\tMethod IsEmpty()\n\t\tReturn _vertexcnt=0 And _trianglecnt=0\n\tEnd Method\n\t\t\n\tMethod HasAlpha()\n\t\tReturn _brush._a<>1 Or _brush._fx&FX_FORCEALPHA\n\tEnd Method\t\nEnd Type\n\nType TSurfaceRes Extends TDriverResource\n\tField _vertexcnt\n\tField _trianglecnt\n\t\n\tMethod Copy:TSurfaceRes() Abstract\nEnd Type\n\nType TMaxB3DMsg\n\tField _succ:TMaxB3DMsg\n\tField _context:Object\n\tField _func(context:Object)\n\t\n\tMethod Add(func(context:Object),context:Object)\n\t\tLocal msg:TMaxB3DMsg=Self\n\t\tWhile msg._succ\n\t\t\tmsg=msg._succ\n\t\tWend\n\t\tmsg._succ=New TMaxB3DMsg\n\t\tmsg._context=context\n\t\tmsg._func=func\n\tEnd Method\n\t\n\tMethod Run()\n\t\tLocal msg:TMaxB3DMsg=Self\n\t\tWhile msg\n\t\t\tIf msg._func msg._func(msg._context)\n\t\t\tmsg=msg._succ\n\t\tWend\n\tEnd Method\nEnd Type","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"75d4d24cecfd5b19dc74c907b45fb7418dee0d98","subject":"Using IsSuccess to see if http request succeeded","message":"Using IsSuccess to see if http request succeeded\n","repos":"maximos\/maximus","old_file":"src\/impl\/update.bmx","new_file":"src\/impl\/update.bmx","new_contents":"\nRem\n\tbbdoc: Maximus 'update' argument implementation.\nEnd Rem\nType mxUpdateImpl Extends dArgumentImplementation\n\t\n\tField m_sourcesurl:String\n\t\n\tMethod New()\n\t\tinit([\"update\"])\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Check the current arguments for errors (according to the specific implementation).\n\t\treturns: Nothing.\n\t\tabout: This method will throw an error if the arguments are invalid.\n\tEnd Rem\n\tMethod CheckArgs()\n\t\tCheckOptions()\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get a string describing the typical usage of the argument.\n\t\treturns: A string describing the typical usage of the argument.\n\tEnd Rem\n\tMethod GetUsage:String()\n\t\tReturn _s(\"arg.update.usage\")\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Execute the implementation's operation.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod Execute()\n\t\tIf mainapp.m_sourcesupdated Then Return\n\t\tIf m_sourcesurl Then m_sourcesurl = mainapp.m_sourcesurl\n\t\tIf m_sourcesurl\n\t\t\tThrowError(_s(\"error.update.nourl\"))\n\t\tEnd If\n\t\tmainapp.m_sourcesupdated = True\n\t\tLocal file:String = mainapp.m_sourcesfile + \".tmp\"\n\t\tlogger.LogMessage(\"fetching: \" + m_sourcesurl + \" -> \" + file + \"~t\", False)\n\t\tLocal stream:TStream = WriteFileExplicitly(file)\n\t\tIf stream\n\t\t\tLocal request:TRESTRequest = New TRESTRequest, response:TRESTResponse\n\t\t\trequest.SetProgressCallback(_ProgressCallback, New _mxProgressStore)\n\t\t\trequest.SetStream(stream)\n\t\t\tTry\n\t\t\t\tresponse = request.Call(m_sourcesurl, [\"User-Agent: \" + mainapp.m_useragent], \"GET\")\n\t\t\tCatch e:Object\n\t\t\t\tstream.Close()\n\t\t\t\tDeleteFile(file)\n\t\t\t\tlogger.LogMessage(\"\")\n\t\t\t\tThrowError(_s(\"error.fetch.sources\", [e.ToString()]))\n\t\t\tEnd Try\n\t\t\tstream.Close()\n\t\t\tIf response.IsSuccess()\n\t\t\t\tlogger.LogMessage(_s(\"message.fetch.done\", [String(response.responseCode)]))\n\t\t\t\tCopyFile(file, mainapp.m_sourcesfile)\n\t\t\t\tDeleteFile(file)\n\t\t\tElse\n\t\t\t\tDeleteFile(file)\n\t\t\t\tlogger.LogMessage(\"\")\n\t\t\t\tThrowError(_s(\"error.fetch.sources\", [\"Bad response code: \" + String(response.responseCode)]))\n\t\t\tEnd If\n\t\tElse\n\t\t\tThrowError(_s(\"error.writeperms\", [file]))\n\t\tEnd If\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Check the options given to the command.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod CheckOptions()\n\t\tm_sourcesurl = Null\n\t\tFor Local opt:dIdentifier = EachIn m_args\n\t\t\tSelect opt.GetName().ToLower()\n\t\t\t\tCase \"--url\"\n\t\t\t\t\tIf opt.GetChildCount() = 1\n\t\t\t\t\t\tm_sourcesurl = dStringVariable(opt.GetValueAtIndex(0)).Get()\n\t\t\t\t\tElse\n\t\t\t\t\t\tThrowCommonError(mxOptErrors.REQUIRESPARAMS, opt.GetName())\n\t\t\t\t\tEnd If\n\t\t\t\tDefault ThrowCommonError(mxOptErrors.UNKNOWN, opt.GetName())\n\t\t\tEnd Select\n\t\tNext\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Progress callback for sources fetching.\n\t\treturns: Zero (no error).\n\tEnd Rem\n\tFunction _ProgressCallback:Int(data:Object, dltotal:Double, dlnow:Double, ultotal:Double, ulnow:Double)\n\t\tLocal store:_mxProgressStore = _mxProgressStore(data)\n\t\tLocal prog:Int = (dlnow \/ dltotal) * 100\n\t\tIf prog > store.m_progress + 5\n\t\t\tstore.m_progress = prog\n\t\t\tWriteStdOut(\".\")\n\t\tEnd If\n\t\tReturn 0\n\tEnd Function\n\t\nEnd Type\n\n","old_contents":"\nRem\n\tbbdoc: Maximus 'update' argument implementation.\nEnd Rem\nType mxUpdateImpl Extends dArgumentImplementation\n\t\n\tField m_sourcesurl:String\n\t\n\tMethod New()\n\t\tinit([\"update\"])\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Check the current arguments for errors (according to the specific implementation).\n\t\treturns: Nothing.\n\t\tabout: This method will throw an error if the arguments are invalid.\n\tEnd Rem\n\tMethod CheckArgs()\n\t\tCheckOptions()\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get a string describing the typical usage of the argument.\n\t\treturns: A string describing the typical usage of the argument.\n\tEnd Rem\n\tMethod GetUsage:String()\n\t\tReturn _s(\"arg.update.usage\")\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Execute the implementation's operation.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod Execute()\n\t\tIf mainapp.m_sourcesupdated Then Return\n\t\tIf m_sourcesurl Then m_sourcesurl = mainapp.m_sourcesurl\n\t\tIf m_sourcesurl\n\t\t\tThrowError(_s(\"error.update.nourl\"))\n\t\tEnd If\n\t\tmainapp.m_sourcesupdated = True\n\t\tLocal file:String = mainapp.m_sourcesfile + \".tmp\"\n\t\tlogger.LogMessage(\"fetching: \" + m_sourcesurl + \" -> \" + file + \"~t\", False)\n\t\tLocal stream:TStream = WriteFileExplicitly(file)\n\t\tIf stream\n\t\t\tLocal request:TRESTRequest = New TRESTRequest, response:TRESTResponse\n\t\t\trequest.SetProgressCallback(_ProgressCallback, New _mxProgressStore)\n\t\t\trequest.SetStream(stream)\n\t\t\tTry\n\t\t\t\tresponse = request.Call(m_sourcesurl, [\"User-Agent: \" + mainapp.m_useragent], \"GET\")\n\t\t\tCatch e:Object\n\t\t\t\tstream.Close()\n\t\t\t\tDeleteFile(file)\n\t\t\t\tlogger.LogMessage(\"\")\n\t\t\t\tThrowError(_s(\"error.fetch.sources\", [e.ToString()]))\n\t\t\tEnd Try\n\t\t\tstream.Close()\n\t\t\tIf response.responseCode = 200\n\t\t\t\tlogger.LogMessage(_s(\"message.fetch.done\", [String(response.responseCode)]))\n\t\t\t\tCopyFile(file, mainapp.m_sourcesfile)\n\t\t\t\tDeleteFile(file)\n\t\t\tElse\n\t\t\t\tDeleteFile(file)\n\t\t\t\tlogger.LogMessage(\"\")\n\t\t\t\tThrowError(_s(\"error.fetch.sources\", [\"Bad response code: \" + String(response.responseCode)]))\n\t\t\tEnd If\n\t\tElse\n\t\t\tThrowError(_s(\"error.writeperms\", [file]))\n\t\tEnd If\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Check the options given to the command.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod CheckOptions()\n\t\tm_sourcesurl = Null\n\t\tFor Local opt:dIdentifier = EachIn m_args\n\t\t\tSelect opt.GetName().ToLower()\n\t\t\t\tCase \"--url\"\n\t\t\t\t\tIf opt.GetChildCount() = 1\n\t\t\t\t\t\tm_sourcesurl = dStringVariable(opt.GetValueAtIndex(0)).Get()\n\t\t\t\t\tElse\n\t\t\t\t\t\tThrowCommonError(mxOptErrors.REQUIRESPARAMS, opt.GetName())\n\t\t\t\t\tEnd If\n\t\t\t\tDefault ThrowCommonError(mxOptErrors.UNKNOWN, opt.GetName())\n\t\t\tEnd Select\n\t\tNext\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Progress callback for sources fetching.\n\t\treturns: Zero (no error).\n\tEnd Rem\n\tFunction _ProgressCallback:Int(data:Object, dltotal:Double, dlnow:Double, ultotal:Double, ulnow:Double)\n\t\tLocal store:_mxProgressStore = _mxProgressStore(data)\n\t\tLocal prog:Int = (dlnow \/ dltotal) * 100\n\t\tIf prog > store.m_progress + 5\n\t\t\tstore.m_progress = prog\n\t\t\tWriteStdOut(\".\")\n\t\tEnd If\n\t\tReturn 0\n\tEnd Function\n\t\nEnd Type\n\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"f8c6adb6aa6da7d34e4fc05fc6fb4cdef753bdc0","subject":"Now using meta.maximus file when calling GetInstalledVersionFromVerID","message":"Now using meta.maximus file when calling GetInstalledVersionFromVerID\n\nrefs gh-1\n","repos":"maximos\/maximus","old_file":"src\/utils.bmx","new_file":"src\/utils.bmx","new_contents":"\nRem\n\tbbdoc: Maximus module utilities.\nEnd Rem\nType mxModUtils\n\t\n\tGlobal g_modules:dObjectMap\n\t\n\tRem\n\t\tbbdoc: Get an object map of the current modules.\n\t\treturns: An object map containing the current modules.\n\t\tabout: @force can be used to force re-enumeration of the modules.\n\tEnd Rem\n\tFunction GetModules:dObjectMap(force:Int = False)\n\t\tIf Not g_modules Or force\n\t\t\tg_modules = EnumModules(Null, Null)\n\t\tEnd If\n\t\tReturn g_modules\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Check if the user currently has the given module.\n\t\treturns: True if the given module was found.\n\tEnd Rem\n\tFunction HasModule:Int(modul:String)\n\t\tReturn GetModules()._Contains(modul)\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Get the path to the given module or modscope.\n\t\treturns: The path to the given module or modscope, or the modules path if the given modid is Null.\n\tEnd Rem\n\tFunction ModulePath:String(modid:String)\n\t\tLocal p:String = mainapp.m_modpath\n\t\tIf modid Then p:+ \"\/\" + modid.Replace(\".\", \".mod\/\") + \".mod\"\n\t\tReturn p\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Get the path to the main source file for the given module id .\n\t\treturns: The path to the given module's main source file, or Null if the given module id is Null.\n\tEnd Rem\n\tFunction SourceFilePath:String(modid:String)\n\t\tIf modid\n\t\t\tReturn ModulePath(modid) + \"\/\" + GetNameFromID(modid) + \".bmx\"\n\t\tEnd If\n\t\tReturn Null\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Get the module scope from the given versioned-module id (for modules with forced versions (or normal ids), e.g. mxModUtils.GetScopeFromID(\"foo.bar\/dev\") would return \"foo\").\n\t\treturns: The scope of the given versioned-module id, or Null if the given versioned-module id was incorrect.\n\tEnd Rem\n\tFunction GetScopeFromID:String(verid:String)\n\t\tverid = GetIDFromVerID(verid)\n\t\tLocal i:Int = verid.Find(\".\")\n\t\tIf i > -1 Then Return verid[..i]\n\t\tReturn Null\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Get the module name from the given versioned-module id (for modules with forced versions (or normal ids), e.g. mxModUtils.GetNameFromID(\"foo.bar\/dev\") would return \"bar\").\n\t\treturns: The name of the given versioned-module id, or Null if the given versioned-module is was incorrect.\n\tEnd Rem\n\tFunction GetNameFromID:String(verid:String)\n\t\tverid = GetIDFromVerID(verid)\n\t\tLocal i:Int = verid.Find(\".\")\n\t\tIf i > -1 Then Return verid[i + 1..]\n\t\tReturn Null\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Get the actual module id from the given versioned-module id (for modules with forced versions (or normal ids), e.g. mxModUtils.GetIDFromVerID(\"foo.bar\/dev\") would return \"foo.bar\").\n\t\treturns: The id of the given versioned-module id.\n\tEnd Rem\n\tFunction GetIDFromVerID:String(verid:String)\n\t\tLocal i:Int = verid.Find(\"\/\")\n\t\tIf i > -1 Then verid = verid[..i]\n\t\tReturn verid\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Get the version from the given versioned-module id (for modules with forced versions, e.g. mxModUtils.GetVersionFromVerID(\"foo.bar\/dev) would return \"dev\").\n\t\treturns: The version of the given versioned-module id (which will be Null if the given value is not versioned).\n\tEnd Rem\n\tFunction GetVersionFromVerID:String(verid:String)\n\t\tLocal i:Int = verid.Find(\"\/\")\n\t\tIf i > -1 Then Return verid[i + 1..]\n\t\tReturn Null\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Get the version of the module from the given versioned-module id, if it is installed.\n\t\treturns: The module's version (which may be \"dev\" if Subversion or git is found controlling the module's directory), or Null if the module was not found.\n\tEnd Rem\n\tFunction GetInstalledVersionFromVerID:String(verid:String)\n\t\tverid = GetIDFromVerID(verid)\n\t\t'DebugLog(\"(mxModUtils.GetInstalledVersionFromVerID) modid: \" + verid)\n\t\tLocal ver:String\n\t\tLocal path:String = mxModUtils.ModulePath(verid) + \"\/meta.maximus\"\n\t\tIf FileType(Path) = FILETYPE_FILE\n\t\t\tLocal metafile:mxMetaFile = New mxMetaFile.Create(path)\n\t\t\tmetafile.Load()\n\t\t\tver = metafile.m_version\n\t\tEnd If\n\t\tReturn ver\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Enumerate all of the current modules.\n\t\treturns: An object map containing the current modules.\n\tEnd Rem\n\tFunction EnumModules:dObjectMap(modid:String = Null, mods:dObjectMap = Null)\n\t\tIf Not mods Then mods = New dObjectMap\n\t\tLocal dir:String = ModulePath(modid)\n\t\tLocal files:String[] = LoadDir(dir)\n\t\tFor Local file:String = EachIn files\n\t\t\tLocal path:String = dir + \"\/\" + file\n\t\t\tIf file[file.length - 4..] <> \".mod\" Or FileType(path) <> FILETYPE_DIR Then Continue\n\t\t\tLocal t:String = file[..file.length - 4]\n\t\t\tIf modid Then t = modid + \".\" + t\n\t\t\tLocal i:Int = t.Find(\".\")\n\t\t\tIf i > -1 And t.Find(\".\", i + 1) = -1 Then mods._Insert(t, path)\n\t\t\tEnumModules(t, mods)\n\t\tNext\n\t\tReturn mods\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Document all modules, or the modules given (doesn't work yet - all documentation will be built).\n\t\treturns: The exit code from makedocs.\n\tEnd Rem\n\tFunction DocMods:Int(args:String = Null)\n\t\targs = \"docmods \" + args.Trim()\n\t\tlogger.LogMessage(\"run: \" + args)\n\t\tReturn system_(mainapp.m_binpath + \"\/\" + args)\n\tEnd Function\n\t\nEnd Type\n\nRem\n\tbbdoc: Maximus BMK utilities.\nEnd Rem\nType mxBMKUtils\n\t\n\tRem\n\t\tbbdoc: Run BMK with the given arguments.\n\t\treturns: The exit code from bmk (non-zero when an error occured).\n\tEnd Rem\n\tFunction RunBMK:Int(args:String)\n\t\targs = \"bmk \" + args.Trim()\n\t\tlogger.LogMessage(\"run: \" + args)\n\t\tReturn system_(mainapp.m_binpath + \"\/\" + args)\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Make modules with the given arguments.\n\t\treturns: The exit code from bmk (non-zero when an error occured).\n\tEnd Rem\n\tFunction MakeMods:Int(args:String, threaded:Int)\n\t\tLocal opts:String\n\t\tIf threaded Then opts:+ \" -h\"\n\t\tReturn RunBMK(\"makemods\" + opts + \" \" + args)\n\tEnd Function\n\t\nEnd Type\n\nRem\n\tbbdoc: Maximus temporary progress storage for url fetching.\nEnd Rem\nType _mxProgressStore\n\t\n\tField m_progress:Int = 0\n\t\nEnd Type\n\n","old_contents":"\nRem\n\tbbdoc: Maximus module utilities.\nEnd Rem\nType mxModUtils\n\t\n\tGlobal g_modules:dObjectMap\n\t\n\tRem\n\t\tbbdoc: Get an object map of the current modules.\n\t\treturns: An object map containing the current modules.\n\t\tabout: @force can be used to force re-enumeration of the modules.\n\tEnd Rem\n\tFunction GetModules:dObjectMap(force:Int = False)\n\t\tIf Not g_modules Or force\n\t\t\tg_modules = EnumModules(Null, Null)\n\t\tEnd If\n\t\tReturn g_modules\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Check if the user currently has the given module.\n\t\treturns: True if the given module was found.\n\tEnd Rem\n\tFunction HasModule:Int(modul:String)\n\t\tReturn GetModules()._Contains(modul)\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Get the path to the given module or modscope.\n\t\treturns: The path to the given module or modscope, or the modules path if the given modid is Null.\n\tEnd Rem\n\tFunction ModulePath:String(modid:String)\n\t\tLocal p:String = mainapp.m_modpath\n\t\tIf modid Then p:+ \"\/\" + modid.Replace(\".\", \".mod\/\") + \".mod\"\n\t\tReturn p\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Get the path to the main source file for the given module id .\n\t\treturns: The path to the given module's main source file, or Null if the given module id is Null.\n\tEnd Rem\n\tFunction SourceFilePath:String(modid:String)\n\t\tIf modid\n\t\t\tReturn ModulePath(modid) + \"\/\" + GetNameFromID(modid) + \".bmx\"\n\t\tEnd If\n\t\tReturn Null\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Get the module scope from the given versioned-module id (for modules with forced versions (or normal ids), e.g. mxModUtils.GetScopeFromID(\"foo.bar\/dev\") would return \"foo\").\n\t\treturns: The scope of the given versioned-module id, or Null if the given versioned-module id was incorrect.\n\tEnd Rem\n\tFunction GetScopeFromID:String(verid:String)\n\t\tverid = GetIDFromVerID(verid)\n\t\tLocal i:Int = verid.Find(\".\")\n\t\tIf i > -1 Then Return verid[..i]\n\t\tReturn Null\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Get the module name from the given versioned-module id (for modules with forced versions (or normal ids), e.g. mxModUtils.GetNameFromID(\"foo.bar\/dev\") would return \"bar\").\n\t\treturns: The name of the given versioned-module id, or Null if the given versioned-module is was incorrect.\n\tEnd Rem\n\tFunction GetNameFromID:String(verid:String)\n\t\tverid = GetIDFromVerID(verid)\n\t\tLocal i:Int = verid.Find(\".\")\n\t\tIf i > -1 Then Return verid[i + 1..]\n\t\tReturn Null\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Get the actual module id from the given versioned-module id (for modules with forced versions (or normal ids), e.g. mxModUtils.GetIDFromVerID(\"foo.bar\/dev\") would return \"foo.bar\").\n\t\treturns: The id of the given versioned-module id.\n\tEnd Rem\n\tFunction GetIDFromVerID:String(verid:String)\n\t\tLocal i:Int = verid.Find(\"\/\")\n\t\tIf i > -1 Then verid = verid[..i]\n\t\tReturn verid\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Get the version from the given versioned-module id (for modules with forced versions, e.g. mxModUtils.GetVersionFromVerID(\"foo.bar\/dev) would return \"dev\").\n\t\treturns: The version of the given versioned-module id (which will be Null if the given value is not versioned).\n\tEnd Rem\n\tFunction GetVersionFromVerID:String(verid:String)\n\t\tLocal i:Int = verid.Find(\"\/\")\n\t\tIf i > -1 Then Return verid[i + 1..]\n\t\tReturn Null\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Get the version of the module from the given versioned-module id, if it is installed.\n\t\treturns: The module's version (which may be \"dev\" if Subversion or git is found controlling the module's directory), or Null if the module was not found.\n\tEnd Rem\n\tFunction GetInstalledVersionFromVerID:String(verid:String)\n\t\tverid = GetIDFromVerID(verid)\n\t\t'DebugLog(\"(mxModUtils.GetInstalledVersionFromVerID) modid: \" + verid)\n\t\tLocal ver:String\n\t\tLocal path:String = mxModUtils.ModulePath(verid) + \"\/\"\n\t\tIf FileType(path) = FILETYPE_DIR\n\t\t\tIf FileType(path + \".git\") = FILETYPE_DIR Or FileType(path + \".svn\") = FILETYPE_DIR\n\t\t\t\tver = \"dev\"\n\t\t\tElse If FileType(path + GetNameFromID(verid) + \".bmx\") = FILETYPE_FILE\n\t\t\t\tLocal stream:TStream = ReadStream(path + GetNameFromID(verid) + \".bmx\")\n\t\t\t\tIf stream\n\t\t\t\t\tLocal line:String\n\t\t\t\t\tWhile Not stream.Eof()\n\t\t\t\t\t\tline = stream.ReadLine().Trim().ToLower()\n\t\t\t\t\t\tIf line.Contains(\"moduleinfo\") And line.Contains(\"version\")\n\t\t\t\t\t\t\tline = line.Replace(\" \", \"\").Replace(\"~q\", \"\")\n\t\t\t\t\t\t\t'Local vp:Int = line.Find(\"moduleinfoversion:\")\n\t\t\t\t\t\t\tIf line.StartsWith(\"moduleinfoversion:\") ' vp > -1 And (vp + 18 <= line.Length)\n\t\t\t\t\t\t\t\tver = line[18..]\n\t\t\t\t\t\t\t\tExit\n\t\t\t\t\t\t\tEnd If\n\t\t\t\t\t\tEnd If\n\t\t\t\t\tEnd While\n\t\t\t\t\tstream.Close()\n\t\t\t\tEnd If\n\t\t\tEnd If\n\t\tEnd If\n\t\tReturn ver\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Enumerate all of the current modules.\n\t\treturns: An object map containing the current modules.\n\tEnd Rem\n\tFunction EnumModules:dObjectMap(modid:String = Null, mods:dObjectMap = Null)\n\t\tIf Not mods Then mods = New dObjectMap\n\t\tLocal dir:String = ModulePath(modid)\n\t\tLocal files:String[] = LoadDir(dir)\n\t\tFor Local file:String = EachIn files\n\t\t\tLocal path:String = dir + \"\/\" + file\n\t\t\tIf file[file.length - 4..] <> \".mod\" Or FileType(path) <> FILETYPE_DIR Then Continue\n\t\t\tLocal t:String = file[..file.length - 4]\n\t\t\tIf modid Then t = modid + \".\" + t\n\t\t\tLocal i:Int = t.Find(\".\")\n\t\t\tIf i > -1 And t.Find(\".\", i + 1) = -1 Then mods._Insert(t, path)\n\t\t\tEnumModules(t, mods)\n\t\tNext\n\t\tReturn mods\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Document all modules, or the modules given (doesn't work yet - all documentation will be built).\n\t\treturns: The exit code from makedocs.\n\tEnd Rem\n\tFunction DocMods:Int(args:String = Null)\n\t\targs = \"docmods \" + args.Trim()\n\t\tlogger.LogMessage(\"run: \" + args)\n\t\tReturn system_(mainapp.m_binpath + \"\/\" + args)\n\tEnd Function\n\t\nEnd Type\n\nRem\n\tbbdoc: Maximus BMK utilities.\nEnd Rem\nType mxBMKUtils\n\t\n\tRem\n\t\tbbdoc: Run BMK with the given arguments.\n\t\treturns: The exit code from bmk (non-zero when an error occured).\n\tEnd Rem\n\tFunction RunBMK:Int(args:String)\n\t\targs = \"bmk \" + args.Trim()\n\t\tlogger.LogMessage(\"run: \" + args)\n\t\tReturn system_(mainapp.m_binpath + \"\/\" + args)\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Make modules with the given arguments.\n\t\treturns: The exit code from bmk (non-zero when an error occured).\n\tEnd Rem\n\tFunction MakeMods:Int(args:String, threaded:Int)\n\t\tLocal opts:String\n\t\tIf threaded Then opts:+ \" -h\"\n\t\tReturn RunBMK(\"makemods\" + opts + \" \" + args)\n\tEnd Function\n\t\nEnd Type\n\nRem\n\tbbdoc: Maximus temporary progress storage for url fetching.\nEnd Rem\nType _mxProgressStore\n\t\n\tField m_progress:Int = 0\n\t\nEnd Type\n\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"f04309c3eba8cb579e8503fb656167c580cb563d","subject":"Renamed FX_FORCEALPHA to FX_ALPHABLEND","message":"Renamed FX_FORCEALPHA to FX_ALPHABLEND\n","repos":"kfprimm\/maxb3d,kfprimm\/maxb3d","old_file":"core.mod\/brush.bmx","new_file":"core.mod\/brush.bmx","new_contents":"\nStrict\n\nImport Prime.Max2DEx\nImport \"texture.bmx\"\n\nConst FX_NONE = 0\nConst FX_FULLBRIGHT = 1\nConst FX_VERTEXCOLOR = 2\nConst FX_FLATSHADED = 4\nConst FX_NOFOG\t = 8\nConst FX_NOCULLING = 16\nConst FX_ALPHABLEND = 32\nConst FX_WIREFRAME = 64\n\nType TBrush\n\tField _name$\n\tField _r#=1.0,_g#=1.0,_b#=1.0,_a#=1.0\n\tField _shine#\n\tField _texture:TTexture[8],_textureframe[8]\n\tField _blend,_fx\n\tField _shader:TShader\n\t\n\tMethod Copy:TBrush()\n\t\tLocal newbrush:TBrush=New TBrush\n\t\tnewbrush.Load Self\n\t\tReturn newbrush\n\tEnd Method\n\t\n\tMethod Merge:TBrush(master:TBrush)\n\t\tLocal red#,green#,blue#,alpha#,shine#,blend,fx,shader:TShader\n\t\tred=master._r;green=master._g;blue=master._b;alpha=master._a\n\t\tblend=master._blend;fx=master._fx;shader=master._shader\n\t\t\n\t\tred:*_r;green:*_g;blue:*_b;alpha:*_a\n\t\tLocal shine2#=_shine\n\t\tIf shine=0.0 Then shine=shine2\n\t\tIf shine<>0.0 And shine2<>0.0 Then shine:*shine2\n\t\tIf blend=0 Then blend=_blend\n\t\tfx:|_fx\n\t\tIf shader=Null shader=_shader\n\t\t\n\t\tLocal newbrush:TBrush=New TBrush\n\t\tnewbrush.SetColor red*255,green*255,blue*255\n\t\tnewbrush.SetAlpha alpha\n\t\tnewbrush.SetShine shine\n\t\tnewbrush.SetBlend blend\n\t\tnewbrush.SetFX fx\n\t\tnewbrush.SetShader shader\n\t\t\n\t\tFor Local i=0 To 7\n\t\t\tnewbrush.SetTexture _texture[i],i,_textureframe[i]\n\t\t\tIf master._texture[i] newbrush.SetTexture master._texture[i],i,master._textureframe[i]\n\t\tNext\n\t\t\n\t\tReturn newbrush\n\tEnd Method\n\t\t\n\tMethod Load(brush:TBrush)\n\t\tIf brush=Null brush=New TBrush\n\t\t_r=brush._r;_g=brush._g;_b=brush._b;_a=brush._a\n\t\t_shine=brush._shine\n\t\tFor Local i=0 To 7\n\t\t\t_texture[i]=brush._texture[i]\n\t\t\t_textureframe[i]=brush._textureframe[i]\n\t\tNext\n\t\t_blend=brush._blend;_fx=brush._fx\n\tEnd Method\n\t\n\tMethod HasAlpha()\n\t\tIf _a<>1 Or _fx&FX_ALPHABLEND Or _blend = BLEND_MULTIPLY Or _blend = BLEND_ADD Return True\n\t\tIf _texture[0] <> Null If _texture[0]._flags&TEXTURE_ALPHA Return True\n\tEnd Method\n\t\n\tMethod GetName$()\n\t\tReturn _name\n\tEnd Method\n\tMethod SetName(name$)\n\t\t_name=name\n\tEnd Method\n\t\n\tMethod GetColor(red Var,green Var,blue Var)\n\t\tred=_r*255.0;green=_g*255.0;blue=_b*255.0\n\tEnd Method\n\tMethod SetColor(red,green,blue)\n\t\t_r=red\/255.0;_g=green\/255.0;_b=blue\/255.0\n\tEnd Method\n\t\n\tMethod GetAlpha#()\n\t\tReturn _a\n\tEnd Method\n\tMethod SetAlpha(alpha#)\n\t\t_a=alpha\n\tEnd Method\n\t\n\tMethod GetShine#()\n\t\tReturn _shine\n\tEnd Method\n\tMethod SetShine(shine#)\n\t\t_shine=shine\n\tEnd Method\n\t\n\tMethod GetTexture:TTexture(index=0)\n\t\tReturn _texture[index]\n\tEnd Method\n\tMethod SetTexture(texture:TTexture,index=0,frame=0)\n\t\t_texture[index]=texture\n\t\t_textureframe[index]=frame\n\tEnd Method\n\t\n\tMethod GetFrame(index=0)\n\t\tReturn _textureframe[index]\n\tEnd Method\n\tMethod SetFrame(frame,index=0)\n\t\t_textureframe[index]=frame\n\tEnd Method\n\t\n\tMethod GetBlend()\n\t\tReturn _blend\n\tEnd Method\n\tMethod SetBlend(blend)\n\t\t_blend=blend\n\tEnd Method\n\t\n\tMethod GetFX()\n\t\tReturn _fx\n\tEnd Method\n\tMethod SetFX(fx)\n\t\t_fx=fx\n\tEnd Method\t\n\t\n\tMethod GetShader:TShader()\n\t\tReturn _shader\n\tEnd Method\n\tMethod SetShader(shader:TShader)\n\t\t_shader=shader\n\tEnd Method\nEnd Type\n","old_contents":"\nStrict\n\nImport Prime.Max2DEx\nImport \"texture.bmx\"\n\nConst FX_NONE = 0\nConst FX_FULLBRIGHT = 1\nConst FX_VERTEXCOLOR = 2\nConst FX_FLATSHADED = 4\nConst FX_NOFOG\t = 8\nConst FX_NOCULLING = 16\nConst FX_FORCEALPHA = 32\nConst FX_WIREFRAME = 64\n\nType TBrush\n\tField _name$\n\tField _r#=1.0,_g#=1.0,_b#=1.0,_a#=1.0\n\tField _shine#\n\tField _texture:TTexture[8],_textureframe[8]\n\tField _blend,_fx\n\tField _shader:TShader\n\t\n\tMethod Copy:TBrush()\n\t\tLocal newbrush:TBrush=New TBrush\n\t\tnewbrush.Load Self\n\t\tReturn newbrush\n\tEnd Method\n\t\n\tMethod Merge:TBrush(master:TBrush)\n\t\tLocal red#,green#,blue#,alpha#,shine#,blend,fx,shader:TShader\n\t\tred=master._r;green=master._g;blue=master._b;alpha=master._a\n\t\tblend=master._blend;fx=master._fx;shader=master._shader\n\t\t\n\t\tred:*_r;green:*_g;blue:*_b;alpha:*_a\n\t\tLocal shine2#=_shine\n\t\tIf shine=0.0 Then shine=shine2\n\t\tIf shine<>0.0 And shine2<>0.0 Then shine:*shine2\n\t\tIf blend=0 Then blend=_blend\n\t\tfx:|_fx\n\t\tIf shader=Null shader=_shader\n\t\t\n\t\tLocal newbrush:TBrush=New TBrush\n\t\tnewbrush.SetColor red*255,green*255,blue*255\n\t\tnewbrush.SetAlpha alpha\n\t\tnewbrush.SetShine shine\n\t\tnewbrush.SetBlend blend\n\t\tnewbrush.SetFX fx\n\t\tnewbrush.SetShader shader\n\t\t\n\t\tFor Local i=0 To 7\n\t\t\tnewbrush.SetTexture _texture[i],i,_textureframe[i]\n\t\t\tIf master._texture[i] newbrush.SetTexture master._texture[i],i,master._textureframe[i]\n\t\tNext\n\t\t\n\t\tReturn newbrush\n\tEnd Method\n\t\t\n\tMethod Load(brush:TBrush)\n\t\tIf brush=Null brush=New TBrush\n\t\t_r=brush._r;_g=brush._g;_b=brush._b;_a=brush._a\n\t\t_shine=brush._shine\n\t\tFor Local i=0 To 7\n\t\t\t_texture[i]=brush._texture[i]\n\t\t\t_textureframe[i]=brush._textureframe[i]\n\t\tNext\n\t\t_blend=brush._blend;_fx=brush._fx\n\tEnd Method\n\t\n\tMethod HasAlpha()\n\t\tIf _a<>1 Or _fx&FX_FORCEALPHA Or _blend = BLEND_MULTIPLY Or _blend = BLEND_ADD Return True\n\t\tIf _texture[0] <> Null If _texture[0]._flags&TEXTURE_ALPHA Return True\n\tEnd Method\n\t\n\tMethod GetName$()\n\t\tReturn _name\n\tEnd Method\n\tMethod SetName(name$)\n\t\t_name=name\n\tEnd Method\n\t\n\tMethod GetColor(red Var,green Var,blue Var)\n\t\tred=_r*255.0;green=_g*255.0;blue=_b*255.0\n\tEnd Method\n\tMethod SetColor(red,green,blue)\n\t\t_r=red\/255.0;_g=green\/255.0;_b=blue\/255.0\n\tEnd Method\n\t\n\tMethod GetAlpha#()\n\t\tReturn _a\n\tEnd Method\n\tMethod SetAlpha(alpha#)\n\t\t_a=alpha\n\tEnd Method\n\t\n\tMethod GetShine#()\n\t\tReturn _shine\n\tEnd Method\n\tMethod SetShine(shine#)\n\t\t_shine=shine\n\tEnd Method\n\t\n\tMethod GetTexture:TTexture(index=0)\n\t\tReturn _texture[index]\n\tEnd Method\n\tMethod SetTexture(texture:TTexture,index=0,frame=0)\n\t\t_texture[index]=texture\n\t\t_textureframe[index]=frame\n\tEnd Method\n\t\n\tMethod GetFrame(index=0)\n\t\tReturn _textureframe[index]\n\tEnd Method\n\tMethod SetFrame(frame,index=0)\n\t\t_textureframe[index]=frame\n\tEnd Method\n\t\n\tMethod GetBlend()\n\t\tReturn _blend\n\tEnd Method\n\tMethod SetBlend(blend)\n\t\t_blend=blend\n\tEnd Method\n\t\n\tMethod GetFX()\n\t\tReturn _fx\n\tEnd Method\n\tMethod SetFX(fx)\n\t\t_fx=fx\n\tEnd Method\t\n\t\n\tMethod GetShader:TShader()\n\t\tReturn _shader\n\tEnd Method\n\tMethod SetShader(shader:TShader)\n\t\t_shader=shader\n\tEnd Method\nEnd Type\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"7c0eafabb768d932222a8de8faadc5353698124b","subject":"filled out var\/table ops","message":"filled out var\/table ops\n","repos":"Leushenko\/blue-moon","old_file":"bluejit.bmx","new_file":"bluejit.bmx","new_contents":"\n' Blue Moon\n' JIT engine\/opcodes\n\n' this is the core of the runtime: the machine code generator and opcodes\n' it's a halfway blend between JIT and interpreter: a basic JIT generates machine code\n' for \"unrolled\" interpreter loops, theoretically (ha!) providing a speed boost\n' it can also \"inline\" selected operations, coming closer to being a true JIT\n\n' for now this is an Include rather than Import lib due to recursive dependency\n' we'll fix that later\n\nRem\nSuperStrict\n\nImport \"blueerror.bmx\"\nImport \"bluevm.bmx\"\nImport etc etc...\nEnd Rem\n\n'Private\t'may need to rename and open these (in the shared interface?)\nExtern\n\tType Stack\n\t\tField retIP:Byte Ptr, prevBase:Stack, varp:Long Ptr, func:Bytecode, _:Long Ptr, argv:Long Ptr, retv:Long Ptr, argc:Short, retc:Short\n\tEnd Type\n\tType Bytecode\n\t\tField mcode:Byte Ptr, idMod:Int, kcount:Int, pcount:Int, upvars:Int, frameSz:Int, icount:Int, vm:Byte Ptr\n\tEnd Type\nEnd Extern\n'Public\n\nType BlueJIT Final\n\tConst PROLOGUESZ:Int = 25, ISIZE:Int = 5\n\t\n\tGlobal opTbl:Int(s:Stack, b:Bytecode, r:Byte Ptr)[], opc:BlueOpcode\n\tGlobal Prologue:Int[] = [ ..\n\t\t$90, $90, ..\n\t\t$8b, $44, $24, $04, .. 'mov 4(%esp), %eax\n\t\t$89, $44, $24, $f4, .. 'mov %eax, -12(%esp)\n\t\t$c7, $44, $24, $f8, $FF, $FF, $FF, $FF, .. 'movl ########, -8(%esp)\n\t\t$89, $64, $24, $fc, .. 'mov %esp, -4(%esp)\n\t\t$83, $ec, $0c.. 'sub $12, %esp\n\t]\n\t\n\tFunction Compile:Byte Ptr(vm:BlueVM, ins:Byte Ptr, icount:Int, bytecode:Bytecode)\n\t\t?Not x86\n\t\tRuntimeError \"The Blue Moon JIT does not support your platform (x86-32 only at this time)\"\n\t\t?\n\t\tAssert SizeOf(0:Long) = SizeOf(0:Double) And SizeOf(0:Int) = 4 And SizeOf(0:Long) = 8 And SizeOf(Byte Ptr(0)) = 4, ..\n\t\t\t\"assumptions about platform datatype sizes are invalid\"\n\t\t\n\t\tIf opTbl = Null Then InitOpTbl()\n\t\t\n\t\t' compute executable code size\n\t\tLocal codesize:Int = PROLOGUESZ, opPos:Int[icount]\t'since sizes are irregular, looking up offsets is easiest\n\t\tFor Local i:Int = 0 Until icount\n\t\t\topPos[i] = codesize\t'finalized below\n\t\t\tSelect ins[i * 8]\n\t\t\t\tCase opc.SETTAB, opc.GETTAB\n\t\t\t\t\tcodesize :+ ISIZE * 2\n\t\t\t\tDefault\n\t\t\t\t\tcodesize :+ ISIZE\n\t\t\tEnd Select\n\t\tNext\n\t\t\n\t\t' allocate executable space\n\t\tLocal code:Byte Ptr = vm.mem.AllocCodeBlock(codesize)\n\t\t\n\t\t'finalize op offsets se we can look them up\n\t\tFor Local i:Int = 0 Until icount\n\t\t\topPos[i] :+ Int(code)\t'direct to executable space\n\t\tNext\n\t\t\n\t\t' emplace prologue (used for calling in from native only)\n\t\tFor Local p:Int = 0 Until PROLOGUESZ\n\t\t\tcode[p] = Prologue[p]\n\t\tNext\n\t\tByte Ptr Ptr(code + 14)[0] = Byte Ptr(bytecode)\t'replace the ########\n\t\t\n\t\t' epilogue (shared location per-vm, probably already set)\n\t\tvm.mem.returnToNative[0] = $c30cc483\t'add $12, %esp ; ret - i.e. restore the stack to normal\n\t\t\n\t\tLocal ktable:Long Ptr = Long Ptr(ins + 8 * bytecode.icount + 8 * bytecode.upvars)\t'constant table\n\t\t\n\t\t' generate machine code!\n\t\tFor Local i:Int = 0 Until icount\t'emplace opcode calls and supporting bytecode data\n\t\t\tLocal codep:Byte Ptr = Byte Ptr(opPos[i]), bytecodep:Byte Ptr = Byte Ptr(Int(codep) + vm.mem.PAGESZ)\n\t\t\tLocal bi:Int = i * 8, op:Int = ins[bi], ip:Int Ptr = Int Ptr(ins + bi), func:Byte Ptr = opTbl[op]\n\t\t\t\n\t\t\tcodep[0] = $e8\t'call\n\t\t\tByte Ptr Ptr(codep + 1)[0] = func - Int(codep + ISIZE)\n\t\t\t\n\t\t\tbytecodep[0] = ins[bi + 1] ; bytecodep[1] = ins[bi + 2]\t'used by most, may get overwritten\n\t\t\t\n\t\t\tSelect op\n\t\t\t\tCase opc.LOADSI, opc.CLOSURE, opc.RET, opc.POSTCALL\n\t\t\t\t\tInt Ptr(bytecodep + 1)[0] = ip[1]\n\t\t\t\t\t\n\t\t\t\tCase opc.LOADK\n\t\t\t\t\tLong Ptr Ptr(bytecodep + 1)[0] = ktable + ip[1]\n\t\t\t\t\t\n\t\t\t\tCase opc.SETTABSI, opc.GETTABSI\n\t\t\t\t\tShort Ptr(bytecodep)[1] = ip[1]\n\t\t\t\t\t\n\t\t\t\tCase opc.SETTAB, opc.GETTAB\n\t\t\t\t\tcodep[ISIZE] = $90 ; Int Ptr(codep + ISIZE + 1)[0] = $90909090\t'nops; the space is needed in the bytecode\n\t\t\t\t\tLong Ptr Ptr(bytecodep + 2)[0] = ktable + ip[1]\n\t\t\t\t\tLong Ptr Ptr(bytecodep + 2)[1] = Null\t'inline cache space\n\t\t\t\t\t\n\t\t\t\tCase opc.GETUPV\n\t\t\t\t\tIf Int Ptr(ins + icount * 8)[2 * bytecodep[1]] = -1\n\t\t\t\t\t\tByte Ptr Ptr(codep + 1)[0] = Byte Ptr(BlueJIT.GETENV) - Int(codep + ISIZE)\n\t\t\t\t\t\tByte Ptr Ptr(bytecodep + 1)[0] = Varptr(vm._ENV.val)\t'note: doesn't allow _ENV to be changed from Max\n\t\t\t\t\tEndIf\n\t\t\t\t\t\n\t\t\t\tCase opc.CALL\n\t\t\t\t\tShort Ptr(bytecodep)[1] = ip[1]\n\t\t\t\t\t\n\t\t\t\tCase opc.JIF, opc.JNOT\n\t\t\t\t\tInt Ptr(bytecodep + 1)[0] = opPos[i + ip[1]]\n\t\t\t\t\t\n\t\t\t\tCase opc.JMP\n\t\t\t\t\tcodep[0] = $e9\t'use a true jump\n\t\t\t\t\tInt Ptr(codep + 1)[0] = opPos[i + ip[1]] - (opPos[i] + ISIZE)\n\t\t\t\t\t\n\t\t\t\tDefault\t'binary operations A = B op C\n\t\t\t\t\tbytecodep[2] = ip[1]\n\t\t\tEnd Select\n\t\tNext\n\t\t\n\t\tReturn code\n\tEnd Function\n\t\n\t\n\tConst STACKFRAME_INC:Int = BlueVMMemory.STACKFRAMESZ + 4, BYTECODE_INC:Int = BlueVMMemory.BYTECODESZ + 4\n\tConst IP_OFFSET:Int = BlueVMMemory.PAGESZ - ISIZE\n\t\n\t\n\t'note: extern vars must take into account the vtbl offset, so that converting from a typed pointer can be a simple cast (faster)\t\n\t\n\tFunction MOV(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"MOV \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tvarp[rp[0]] = varp[rp[1]]\n\tEnd Function\n\tFunction GETLC(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"GETLC \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tvarp[rp[0]] = Long Ptr Ptr(varp + rp[1])[0][0]\n\tEnd Function\n\tFunction SETLC(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"SETLC \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal convert:BlueVM(p:Byte Ptr) = Byte Ptr(Identity), vm:BlueVM = convert(bc.vm)\n\t\tvm.mem.Write(Long Ptr Ptr(varp + rp[0])[0], varp[rp[1]])\t'unlikely but technically possible to need this\n\tEnd Function\n\tFunction LOADK(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"LOADK \/\/\"\n\t\tLocal rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET, varp:Long Ptr = stk.varp + rp[0], kp:Long Ptr = Long Ptr Ptr(rp + 1)[0]\n\t\tvarp[0] = kp[0]\n\tEnd Function\n\tFunction LOADSI(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"LOADSI \/\/\"\n\t\tLocal rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal val:Int = Int Ptr(rp + 1)[0]\n\t\tDouble Ptr(stk.varp)[rp[0]] = Double(val)\n\tEnd Function\n\tFunction LOADBOOL(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"LOADBOOL \/\/\"\n\t\tLocal rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET, vp:Int Ptr = Int Ptr(stk.varp + rp[0])\n\t\tvp[1] = BlueTypeTag.NANBOX | BlueTypeTag.BOOL\n\t\tvp[0] = Int Ptr(rp + 1)[0]\n\tEnd Function\n\tFunction LOADNIL(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"LOADNIL \/\/\"\n\t\tLocal rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tInt Ptr(stk.varp + rp[0])[1] = BlueTypeTag.NANBOX | BlueTypeTag.NIL\n\tEnd Function\n\t\n\tFunction GETTAB(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"GETTAB \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET, kp:Long Ptr = Long Ptr Ptr(rp + 2)[0]\n\t\tLocal tabp:Byte Ptr = Byte Ptr Ptr(varp + rp[1])[0]\n\t\tIf Int Ptr(varp + rp[1])[1] = BlueTypeTag.TBLBOX\n\t\t\tLocal keyslot:Long Ptr = Null, slot:Long Ptr = BlueTable.GetSlot(tabp, kp[0], Varptr(keyslot))\n\t\t\tIf (slot = Null) Or (keyslot[0] <> kp[0])\n\t\t\t\tIf keyslot = Long Ptr(1) Then varp[rp[0]] = BlueVMMemory.NIL ; Return\t'nil key\n\t\t\tElse\n\t\t\t\tvarp[rp[0]] = slot[0] ; Return\n\t\t\tEndIf\n\t\tEndIf\n\t\tIndexMetamethod bc, retptr, varp + rp[0], varp[rp[1]], kp[0]\t'not in table; invoke metamethod\n\tEnd Function\n\tFunction GETTABSI(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"GETTABSI \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal tabp:Byte Ptr = Byte Ptr Ptr(varp + rp[1])[0], key:Long ; Double Ptr(Varptr(key))[0] = Short Ptr(rp)[1]\n\t\tIf Int Ptr(varp + rp[0])[1] = BlueTypeTag.TBLBOX\n\t\t\tLocal keyslot:Long Ptr = Null, slot:Long Ptr = BlueTable.GetSlot(tabp, key, Varptr(keyslot))\n\t\t\tIf Not (slot = Null Or (keyslot And keyslot[0] <> key)) Then varp[rp[0]] = slot[0] ; Return\n\t\t\tIf keyslot = Long Ptr(1) Then varp[rp[0]] = BlueVMMemory.NIL ; Return\n\t\tEndIf\n\t\tIndexMetamethod bc, retptr, varp + rp[0], varp[rp[1]], key\n\tEnd Function\n\tFunction SETTAB(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"SETTAB \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal tabvp:Byte Ptr = varp + rp[0], kp:Long Ptr = Long Ptr Ptr(rp + 2)[0]\n\t\tIf Int Ptr(tabvp)[1] = BlueTypeTag.TBLBOX\n\t\t\tLocal keyslot:Long Ptr = Null, slot:Long Ptr = BlueTable.GetSlot(Byte Ptr Ptr(tabvp)[0], kp[0], Varptr(keyslot))\n\t\t\tIf Not (slot = Null Or keyslot[0] <> kp[0]) Then slot[0] = varp[rp[1]] ; Return\n\t\tEndIf\n\t\tNewindexMetamethod bc, retptr, varp[rp[0]], varp[rp[1]], kp[0]\t'not in table; invoke metamethod or rawset\n\tEnd Function\n\tFunction SETTABSI(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"SETTABSI \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET, tabvp:Byte Ptr = varp + rp[0]\n\t\tLocal key:Long ; Double Ptr(Varptr(key))[0] = Short Ptr(rp)[1]\n\t\tIf Int Ptr(tabvp)[1] = BlueTypeTag.TBLBOX\n\t\t\tLocal keyslot:Long Ptr = Null, slot:Long Ptr = BlueTable.GetSlot(Byte Ptr Ptr(tabvp)[0], key, Varptr(keyslot))\n\t\t\tIf Not (slot = Null Or (keyslot And keyslot[0] <> key)) Then slot[0] = varp[rp[1]] ; Return\n\t\tEndIf\n\t\tNewindexMetamethod bc, retptr, Long Ptr(tabvp)[0], varp[rp[1]], key\n\tEnd Function\n\tFunction GETTABI(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"GETTABI \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal tabvp:Byte Ptr = varp + rp[1], key:Long = varp[rp[2]]\n\t\tIf Int Ptr(tabvp)[1] = BlueTypeTag.TBLBOX\n\t\t\tLocal keyslot:Long Ptr = Null, slot:Long Ptr = BlueTable.GetSlot(Byte Ptr Ptr(tabvp)[0], key, Varptr(keyslot))\n\t\t\tIf Not (slot = Null Or (keyslot And keyslot[0] <> key)) Then varp[rp[0]] = slot[0] ; Return\n\t\tEndIf\n\t\tIndexMetamethod bc, retptr, varp + rp[0], Long Ptr(tabvp)[0], key\n\tEnd Function\n\tFunction SETTABI(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"SETTABI \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal tabvp:Byte Ptr = varp + rp[0], key:Long = varp[rp[2]]\n\t\tIf Int Ptr(tabvp)[1] = BlueTypeTag.TBLBOX\n\t\t\tLocal keyslot:Long Ptr = Null, slot:Long Ptr = BlueTable.GetSlot(Byte Ptr Ptr(tabvp)[0], key, Varptr(keyslot))\n\t\t\tIf Not (slot = Null Or (keyslot And keyslot[0] <> key)) Then slot[0] = varp[rp[1]] ; Return\n\t\tEndIf\n\t\tNewindexMetamethod bc, retptr, Long Ptr(tabvp)[0], varp[rp[1]], key\n\tEnd Function\n\tFunction GETUPV(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"GETUPV \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal upvp:Byte Ptr Ptr = Byte Ptr Ptr(Byte Ptr(stk) + STACKFRAME_INC), valp:Long Ptr = Long Ptr(upvp[rp[1]])\n\t\tvarp[rp[0]] = valp[0]\n\tEnd Function\n\tFunction GETENV(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\t'\"unlisted\" instruction: GETUPV for _ENV is translated into this at load-time\n\t'\tPrint \"GETENV \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tvarp[rp[0]] = Long Ptr Ptr(rp + 1)[0][0]\t'type check should not be necessary (will be handled by following op)\n\tEnd Function\n\tFunction SETUPV(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"SETUPV \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal convert:BlueVM(p:Byte Ptr) = Byte Ptr(Identity), vm:BlueVM = convert(bc.vm)\n\t\tLocal upvp:Byte Ptr Ptr = Byte Ptr Ptr(Byte Ptr(stk) + STACKFRAME_INC), valp:Long Ptr = Long Ptr(upvp[rp[0]])\n\t\tvm.mem.Write(valp, varp[rp[1]])\n\tEnd Function\n\tFunction NEWTAB(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"NEWTAB \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal convert:BlueVM(p:Byte Ptr) = Byte Ptr(Identity), vm:BlueVM = convert(bc.vm)\n\t\tLocal tab:Byte Ptr = vm.mem.AllocTable(Null)\n\t\tLocal d:Int Ptr = Int Ptr(varp + rp[0])\n\t\td[0] = Int(tab) ; d[1] = BlueTypeTag.TBLBOX\n\tEnd Function\n\tFunction CLOSURE(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"CLOSURE \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal convert:BlueVM(p:Byte Ptr) = Byte Ptr(Identity), vm:BlueVM = convert(bc.vm)\n\t\tLocal d:Int Ptr = Int Ptr(varp + rp[0])\n\t\tLocal cbytecode:Bytecode = vm.funIndex[Int Ptr(rp + 1)[0]], upvp:Int Ptr = Int Ptr(Byte Ptr(cbytecode) + BYTECODE_INC + 8 * cbytecode.icount)\n\t\tLocal closure:Byte Ptr = vm.mem.AllocClosure(cbytecode, cbytecode.upvars)\t'upvars is always even (alignment)\n\t\t\n\t\t'get upvalues off the stack\n\t\tFor Local u:Int = 0 Until cbytecode.upvars\n\t\t\tIf upvp[2 * u]\n\t\t\t\tByte Ptr Ptr(closure)[2 + u] = Byte Ptr Ptr(Byte Ptr(stk) + STACKFRAME_INC)[upvp[2 * u + 1]]\n\t\t\tElse\n\t\t\t\tByte Ptr Ptr(closure)[2 + u] = Byte Ptr Ptr(varp + upvp[2 * u + 1])[0]\n\t\t\tEndIf\n\t\tNext\n\t\t\n\t\td[0] = Int(closure) ; d[1] = BlueTypeTag.FUNBOX\n\tEnd Function\n\tFunction NEWUPV(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"NEWUPV \/\/\"\n\t\tLocal rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal convert:BlueVM(p:Byte Ptr) = Byte Ptr(Identity), vm:BlueVM = convert(bc.vm)\n\t\tLocal upv:Byte Ptr = vm.mem.AllocObject(8, BlueTypeTag.UPV), d:Int Ptr = Int Ptr(stk.varp + rp[0])\n\t\tLong Ptr(upv)[0] = Long Ptr(d)[0]\t'promote a value if it existed (useful for parameters)\n\t\td[0] = Int(upv) ; d[1] = BlueTypeTag.NANBOX | BlueTypeTag.UPV\n\tEnd Function\n\t\n\tFunction ADD(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t\tPrint \"ADD \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal d:Double Ptr = Double Ptr(varp + rp[0])\n\t\tLocal r:Int Ptr = Int Ptr(varp + rp[1]), l:Int Ptr = Int Ptr(varp + rp[2])\n\t\tIf l[1] & BlueTypeTag.NANBOX_CHK = BlueTypeTag.NANBOX Or r[1] & BlueTypeTag.NANBOX_CHK = BlueTypeTag.NANBOX\n\t\t\tDebugStop\n\t\tElse\n\t\t\tPrint \" \" + Double Ptr(l)[0] + \" \" + Double Ptr(r)[0]\n\t\t\td[0] = Double Ptr(l)[0] + Double Ptr(r)[0]\n\t\tEndIf\n\tEnd Function\n\tFunction SUB(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction MUL(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction DIV(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction NMOD(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction POW(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction CAT(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction IDIV(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction BAND(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction BOR(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction BXOR(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction BSHL(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction BSHR(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction UNM(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction LNOT(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction ALEN(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction BNOT(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction UNP(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction EQ(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"EQ \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = (Byte Ptr Ptr(retptr) - 4)[0] + IP_OFFSET\n\t\tLocal r:Double = Double Ptr(varp)[rp[1]]\n\t\tLocal l:Double = Double Ptr(varp)[rp[2]]\n\t\tInt Ptr(varp + rp[0])[0] = l = r\n\tEnd Function\n\tFunction LT(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction LEQ(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\t\n\tFunction JMP(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t\tRuntimeError \"wait, why are we here?\"\n\tEnd Function\n\tFunction JIF(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"JIF \/\/\"\n\t\tLocal rp:Byte Ptr = (Byte Ptr Ptr(retptr) - 4)[0] + IP_OFFSET\n\t\tIf Int Ptr(stk.varp + rp[0])[0]\n\t\t\tLocal target:Int = Int Ptr(rp + 1)[0]\n\t\t\tInt Ptr(retptr)[-4] = target\n\t\tEndIf\n\tEnd Function\n\tFunction JNOT(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction CALL(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"CALL \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal fp:Int Ptr = Int Ptr(varp + rp[0])\n\t\tIf Not PrepareCall(fp, stk, rp, varp, retptr)\t'PrepareCall sets everything up so there's nothing else to do to make the call happen\n\t\t\t'__call metamethod\n\t\tEndIf\n\tEnd Function\n\tFunction TCALL(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction RET:Byte Ptr(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"RET \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp\n\t\tLocal rp0:Byte Ptr = Byte Ptr Ptr(retptr)[-4], rp:Byte Ptr = rp0 + IP_OFFSET\n\t\t\n\t\tLocal oldStk:Stack = stk.prevBase\n\t\tLocal retv:Long Ptr = varp + rp[0]\n\t\tIf oldStk\n\t\t\toldStk.retv = retv\n\t\t\toldStk.retc = Int Ptr(rp + 1)[0]\n\t\t\tByte Ptr Ptr(retptr)[-4] = stk.retIP\n\t\t\tByte Ptr Ptr(retptr)[-3] = Byte Ptr(oldStk)\n\t\t\tByte Ptr Ptr(retptr)[-2] = Byte Ptr(oldStk.func) + BYTECODE_INC\n\t\tElse\t'return to native code\n\t\t\tLocal codePage:Byte Ptr = Byte Ptr(Int(rp0) & ((Int(2^12)-1) Shl 20))\n\t\t\tByte Ptr Ptr(retptr)[-4] = codePage + 4\n\t\t\tReturn retv\n\t\tEndIf\n\tEnd Function\n\tFunction RETVA(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction POSTCALL(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"POSTCALL \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp\n\t\tLocal rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\t\n\t\tFor Local r:Int = 0 Until Min(Int Ptr(rp + 1)[0], stk.retc)\n\t\t\t(varp + rp[0])[r] = stk.retv[r]\n\t\t'\tPrint \" return \" + r + \": \" + Double Ptr(stk.retv)[r]\n\t\tNext\n\t\t'nil the rest\n\tEnd Function\n\tFunction VARARG(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction VAINIT(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction CALLINIT(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\t\n\t\n\tFunction PrepareCall:Int(fp:Int Ptr, stk:Stack, rp:Byte Ptr, varp:Long Ptr, retptr:Byte Ptr)\n\t\tIf fp[1] = BlueTypeTag.NANBOX | BlueTypeTag.FUN\n\t\t\tLocal newStk0:Stack ; Byte Ptr Ptr(Varptr(newStk0))[0] = Byte Ptr(stk) + stk.func.frameSz\n\t\t\tLocal newStk:Stack = newStk0\t'micro-opt: newStk0 can't be a register because of the unwieldy conversion\n\t\t\t\n\t\t\tnewStk.retIP = Byte Ptr Ptr(retptr)[-4]\n\t\t\tnewStk.prevBase = stk\n\t\t\tLocal closure:Byte Ptr = Byte Ptr(fp[0])\n\t\t\tLocal newBC:Bytecode = Bytecode Ptr(closure)[0]\n\t\t\tLocal voff:Int = STACKFRAME_INC + 4 * newBC.upvars\n\t\t\tnewStk.varp = Long Ptr(Byte Ptr(newStk) + voff)\n\t\t\tnewStk.func = newBC\n\t\t\t\n\t\t\tLocal argc_actual:Int = Short Ptr(rp)[1], argc_required:Int = newBC.pcount\n\t\t'\tLocal argc_min:Int ; If argc_actual < argc_required Then argc_min = argc_actual Else argc_min = argc_required\n\t\t\tLocal argc_min:Int = argc_actual - argc_required ; argc_min = (argc_min & (argc_min Shr 31)) + argc_required 'branchless 32-bit Min\n\t\t\t\n\t\t\tLocal argv:Long Ptr = varp + rp[1], destv:Long Ptr = newStk.varp\n\t\t\tFor Local a:Int = 0 Until argc_min\n\t\t\t\tdestv[a] = argv[a]\n\t\t\t'\tPrint \" arg \" + a + \": \" + argv[a]\n\t\t\tNext\n\t\t\tFor Local a:Int = argc_min Until argc_required\t'nil any unfilled parameters\n\t\t\t\tInt Ptr(destv + a)[1] = BlueTypeTag.NANBOX | BlueTypeTag.NIL\n\t\t\tNext\n\t\t\tnewStk.argv = argv + argc_min\t'argv should be to the varargs (if any)\n\t\t\tnewStk.argc = argc_actual - argc_min\t'argc is the number of varargs\n\t\t\t\n\t\t\tLocal destup:Byte Ptr Ptr = Byte Ptr Ptr(Byte Ptr(newStk) + STACKFRAME_INC)\n\t\t\tLocal upv:Byte Ptr Ptr = Byte Ptr Ptr(closure + 8)\n\t\t\tFor Local up:Int = 0 Until newBC.upvars\t'emplace upvars\n\t\t\t\tdestup[up] = upv[up]\n\t\t\t'\tPrint \" upv \" + up + \": \" + destv[up]\n\t\t\t'\tPrint \" val: \" + Double Ptr Ptr(Byte Ptr Ptr(closure) + 2 + up)[0][0]\n\t\t\tNext\n\t\t\t\n\t\t\t'note that the following OVERWRITE THE PARAMETERS (in release mode), so no touching stk from here on\n\t\t\tByte Ptr Ptr(retptr)[-4] = newBC.mcode\n\t\t\tByte Ptr Ptr(retptr)[-3] = Byte Ptr(newStk)\n\t\t\tByte Ptr Ptr(retptr)[-2] = Byte Ptr(newBC) + BYTECODE_INC\n\t\t\t\n\t\tElseIf fp[1] = BlueTypeTag.NANBOX | BlueTypeTag.NATFUN\t'native call\n\t\t\tLocal fun:Int(vm:BlueVM, ac:Int, av:Long Ptr, rv:Long Ptr) = Byte Ptr(fp[0])\n\t\t\tLocal argc:Int = Short Ptr(rp)[1], argv:Long Ptr = varp + rp[1], retv:Long Ptr = Long Ptr(Byte Ptr(stk) + stk.func.frameSz)\n\t\t\tLocal convert:BlueVM(p:Byte Ptr) = Byte Ptr(Identity), vm:BlueVM = convert(stk.func.vm)\n\t\t\tstk.retc = fun(vm, argc, argv, retv)\n\t\t\tstk.retv = retv\n\t\tElse\n\t\t\tReturn False\t'not a function; take appropriate action\n\t\tEndIf\n\t\tReturn True\t'all good and will auto-call when the caller returns\n\tEnd Function\n\t\n\tFunction IndexMetamethod(bc:Bytecode, retptr:Byte Ptr, d:Long Ptr, tbl:Long, key:Long)\t'prep but not execute a call\n\t\t'need to work out a way to return values from this without POSTCALL (maybe can co-opt RET to handle singles by itself)\n\t\tLocal convert:BlueVM(p:Byte Ptr) = Byte Ptr(Identity), vm:BlueVM = convert(bc.vm)\n\t\tvm.Error(\"metamethod access isn't implemented yet\")\n\tEnd Function\n\tFunction NewindexMetamethod(bc:Bytecode, retptr:Byte Ptr, d:Long, val:Long, key:Long)\t'as above\n\t\tLocal convert:BlueVM(p:Byte Ptr) = Byte Ptr(Identity), vm:BlueVM = convert(bc.vm)\n\t'\tvm.Error(\"metamethod access isn't implemented yet\")\n\t\t'just rawset it for now\n\t\t'remember to handle nil key (what is correct?)\n\t\tLocal tabp:Byte Ptr = Byte Ptr(Int(d))\n\t\tBlueTable.RawSet(vm.mem, tabp, key, val)\n\tEnd Function\n\t\n\tFunction BinopMetamethod(op:Int, bc:Bytecode, retptr:Byte Ptr, d:Long Ptr, r:Long Ptr, l:Long Ptr)\t'as above\n\t\tLocal convert:BlueVM(p:Byte Ptr) = Byte Ptr(Identity), vm:BlueVM = convert(bc.vm)\n\t\tvm.Error(\"metamethod access isn't implemented yet\")\n\tEnd Function\n\t\n\tFunction InitOpTbl()\n\t\topc = New BlueOpcode\n\t\topTbl = [MOV, GETLC, SETLC, LOADK, LOADSI, LOADBOOL, LOADNIL, ..\n\t\t\tGETTAB, GETTABSI, SETTAB, SETTABSI, GETTABI, SETTABI, GETUPV, SETUPV, ..\n\t\t\tNEWTAB, CLOSURE, NEWUPV, ..\n\t\t\tADD, SUB, MUL, DIV, NMOD, POW, CAT, ..\n\t\t\tIDIV, BAND, BOR, BXOR, BSHL, BSHR, ..\n\t\t\tUNM, LNOT, ALEN, BNOT, UNP, ..\n\t\t\tEQ, LT, LEQ, ..\n\t\t\tJMP, JIF, JNOT, CALL, TCALL, RETVA, RETVA, ..\t'not a mistake: RET doesn't fit but we need the spacer\n\t\t\tPOSTCALL, VARARG, VAINIT, CALLINIT]\n\t\t\n\t\topTbl[opc.RET] = Byte Ptr(RET)\n\tEnd Function\n\t\n\tFunction Identity:Byte Ptr(b:Byte Ptr)\n\t\tReturn b\n\tEnd Function\n\tFunction PointerToExtType:Byte Ptr(p:Byte Ptr)\t'horrible pointer abuse (increment down so we can ignore the nonexistent vtbl)\n\t\tReturn p - SizeOf(Byte Ptr(0))\n\tEnd Function\n\tGlobal BPtoS:Stack(p:Byte Ptr) = Byte Ptr(BlueJIT.PointerToExtType)\nEnd Type\n\n","old_contents":"\n' Blue Moon\n' JIT engine\/opcodes\n\n' this is the core of the runtime: the machine code generator and opcodes\n' it's a halfway blend between JIT and interpreter: a basic JIT generates machine code\n' for \"unrolled\" interpreter loops, theoretically (ha!) providing a speed boost\n' it can also \"inline\" selected operations, coming closer to being a true JIT\n\n' for now this is an Include rather than Import lib due to recursive dependency\n' we'll fix that later\n\nRem\nSuperStrict\n\nImport \"blueerror.bmx\"\nImport \"bluevm.bmx\"\nImport etc etc...\nEnd Rem\n\n'Private\t'may need to rename and open these (in the shared interface?)\nExtern\n\tType Stack\n\t\tField retIP:Byte Ptr, prevBase:Stack, varp:Long Ptr, func:Bytecode, _:Long Ptr, argv:Long Ptr, retv:Long Ptr, argc:Short, retc:Short\n\tEnd Type\n\tType Bytecode\n\t\tField mcode:Byte Ptr, idMod:Int, kcount:Int, pcount:Int, upvars:Int, frameSz:Int, icount:Int, vm:Byte Ptr\n\tEnd Type\nEnd Extern\n'Public\n\nType BlueJIT Final\n\tConst PROLOGUESZ:Int = 25, ISIZE:Int = 5\n\t\n\tGlobal opTbl:Int(s:Stack, b:Bytecode, r:Byte Ptr)[], opc:BlueOpcode\n\tGlobal Prologue:Int[] = [ ..\n\t\t$90, $90, ..\n\t\t$8b, $44, $24, $04, .. 'mov 4(%esp), %eax\n\t\t$89, $44, $24, $f4, .. 'mov %eax, -12(%esp)\n\t\t$c7, $44, $24, $f8, $FF, $FF, $FF, $FF, .. 'movl ########, -8(%esp)\n\t\t$89, $64, $24, $fc, .. 'mov %esp, -4(%esp)\n\t\t$83, $ec, $0c.. 'sub $12, %esp\n\t]\n\t\n\tFunction Compile:Byte Ptr(vm:BlueVM, ins:Byte Ptr, icount:Int, bytecode:Bytecode)\n\t\t?Not x86\n\t\tRuntimeError \"The Blue Moon JIT does not support your platform (x86-32 only at this time)\"\n\t\t?\n\t\tAssert SizeOf(0:Long) = SizeOf(0:Double) And SizeOf(0:Int) = 4 And SizeOf(0:Long) = 8 And SizeOf(Byte Ptr(0)) = 4, ..\n\t\t\t\"assumptions about platform datatype sizes are invalid\"\n\t\t\n\t\tIf opTbl = Null Then InitOpTbl()\n\t\t\n\t\t' compute executable code size\n\t\tLocal codesize:Int = PROLOGUESZ, opPos:Int[icount]\t'since sizes are irregular, looking up offsets is easiest\n\t\tFor Local i:Int = 0 Until icount\n\t\t\topPos[i] = codesize\t'finalized below\n\t\t\tSelect ins[i * 8]\n\t\t\t\tCase opc.SETTAB, opc.GETTAB\n\t\t\t\t\tcodesize :+ ISIZE * 2\n\t\t\t\tDefault\n\t\t\t\t\tcodesize :+ ISIZE\n\t\t\tEnd Select\n\t\tNext\n\t\t\n\t\t' allocate executable space\n\t\tLocal code:Byte Ptr = vm.mem.AllocCodeBlock(codesize)\n\t\t\n\t\t'finalize op offsets se we can look them up\n\t\tFor Local i:Int = 0 Until icount\n\t\t\topPos[i] :+ Int(code)\t'direct to executable space\n\t\tNext\n\t\t\n\t\t' emplace prologue (used for calling in from native only)\n\t\tFor Local p:Int = 0 Until PROLOGUESZ\n\t\t\tcode[p] = Prologue[p]\n\t\tNext\n\t\tByte Ptr Ptr(code + 14)[0] = Byte Ptr(bytecode)\t'replace the ########\n\t\t\n\t\t' epilogue (shared location per-vm, probably already set)\n\t\tvm.mem.returnToNative[0] = $c30cc483\t'add $12, %esp ; ret - i.e. restore the stack to normal\n\t\t\n\t\tLocal ktable:Long Ptr = Long Ptr(ins + 8 * bytecode.icount + 8 * bytecode.upvars)\t'constant table\n\t\t\n\t\t' generate machine code!\n\t\tFor Local i:Int = 0 Until icount\t'emplace opcode calls and supporting bytecode data\n\t\t\tLocal codep:Byte Ptr = Byte Ptr(opPos[i]), bytecodep:Byte Ptr = Byte Ptr(Int(codep) + vm.mem.PAGESZ)\n\t\t\tLocal bi:Int = i * 8, op:Int = ins[bi], ip:Int Ptr = Int Ptr(ins + bi), func:Byte Ptr = opTbl[op]\n\t\t\t\n\t\t\tcodep[0] = $e8\t'call\n\t\t\tByte Ptr Ptr(codep + 1)[0] = func - Int(codep + ISIZE)\n\t\t\t\n\t\t\tbytecodep[0] = ins[bi + 1] ; bytecodep[1] = ins[bi + 2]\t'used by most, may get overwritten\n\t\t\t\n\t\t\tSelect op\n\t\t\t\tCase opc.LOADSI, opc.CLOSURE, opc.RET, opc.POSTCALL\n\t\t\t\t\tInt Ptr(bytecodep + 1)[0] = ip[1]\n\t\t\t\t\t\n\t\t\t\tCase opc.LOADK\n\t\t\t\t\tLong Ptr Ptr(bytecodep + 1)[0] = ktable + ip[1]\n\t\t\t\t\t\n\t\t\t\tCase opc.SETTABSI, opc.GETTABSI\n\t\t\t\t\tShort Ptr(bytecodep)[1] = ip[1]\n\t\t\t\t\t\n\t\t\t\tCase opc.SETTAB, opc.GETTAB\n\t\t\t\t\tcodep[ISIZE] = $90 ; Int Ptr(codep + ISIZE + 1)[0] = $90909090\t'nops; the space is needed in the bytecode\n\t\t\t\t\tLong Ptr Ptr(bytecodep + 2)[0] = ktable + ip[1]\n\t\t\t\t\tLong Ptr Ptr(bytecodep + 2)[1] = Null\t'inline cache space\n\t\t\t\t\t\n\t\t\t\tCase opc.GETUPV\n\t\t\t\t\tIf Int Ptr(ins + icount * 8)[2 * bytecodep[1]] = -1\n\t\t\t\t\t\tByte Ptr Ptr(codep + 1)[0] = Byte Ptr(BlueJIT.GETENV) - Int(codep + ISIZE)\n\t\t\t\t\t\tByte Ptr Ptr(bytecodep + 1)[0] = Varptr(vm._ENV.val)\t'note: doesn't allow _ENV to be changed from Max\n\t\t\t\t\tEndIf\n\t\t\t\t\t\n\t\t\t\tCase opc.CALL\n\t\t\t\t\tShort Ptr(bytecodep)[1] = ip[1]\n\t\t\t\t\t\n\t\t\t\tCase opc.JIF, opc.JNOT\n\t\t\t\t\tInt Ptr(bytecodep + 1)[0] = opPos[i + ip[1]]\n\t\t\t\t\t\n\t\t\t\tCase opc.JMP\n\t\t\t\t\tcodep[0] = $e9\t'use a true jump\n\t\t\t\t\tInt Ptr(codep + 1)[0] = opPos[i + ip[1]] - (opPos[i] + ISIZE)\n\t\t\t\t\t\n\t\t\t\tDefault\t'binary operations A = B op C\n\t\t\t\t\tbytecodep[2] = ip[1]\n\t\t\tEnd Select\n\t\tNext\n\t\t\n\t\tReturn code\n\tEnd Function\n\t\n\t\n\tConst STACKFRAME_INC:Int = BlueVMMemory.STACKFRAMESZ + 4, BYTECODE_INC:Int = BlueVMMemory.BYTECODESZ + 4\n\tConst IP_OFFSET:Int = BlueVMMemory.PAGESZ - ISIZE\n\t\n\t\n\t'note: extern vars must take into account the vtbl offset, so that converting from a typed pointer can be a simple cast (faster)\t\n\t\n\tFunction MOV(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"MOV \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tvarp[rp[0]] = varp[rp[1]]\n\tEnd Function\n\tFunction GETLC(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction SETLC(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"SETLC \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal convert:BlueVM(p:Byte Ptr) = Byte Ptr(Identity), vm:BlueVM = convert(bc.vm)\n\t\tvm.mem.Write(Long Ptr Ptr(varp + rp[0])[0], varp[rp[1]])\t'unlikely but technically possible to need this\n\tEnd Function\n\tFunction LOADK(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"LOADK \/\/\"\n\t\tLocal rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET, varp:Long Ptr = stk.varp + rp[0], kp:Long Ptr = Long Ptr Ptr(rp + 1)[0]\n\t\tvarp[0] = kp[0]\n\tEnd Function\n\tFunction LOADSI(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"LOADSI \/\/\"\n\t\tLocal rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal val:Int = Int Ptr(rp + 1)[0]\n\t\tDouble Ptr(stk.varp)[rp[0]] = Double(val)\n\tEnd Function\n\tFunction LOADBOOL(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"LOADBOOL \/\/\"\n\t\tLocal rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET, vp:Int Ptr = Int Ptr(stk.varp + rp[0])\n\t\tvp[1] = BlueTypeTag.NANBOX | BlueTypeTag.BOOL\n\t\tvp[0] = Int Ptr(rp + 1)[0]\n\tEnd Function\n\tFunction LOADNIL(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"LOADNIL \/\/\"\n\t\tLocal rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tInt Ptr(stk.varp + rp[0])[1] = BlueTypeTag.NANBOX | BlueTypeTag.NIL\n\tEnd Function\n\t\n\tFunction GETTAB(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t\tPrint \"GETTAB \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET, kp:Long Ptr = Long Ptr Ptr(rp + 2)[0]\n\t\tLocal tabp:Byte Ptr = Byte Ptr Ptr(varp + rp[1])[0]\n\t\tIf Int Ptr(varp + rp[1])[1] = BlueTypeTag.TBLBOX\n\t\t\tLocal keyslot:Long Ptr = Null, slot:Long Ptr = BlueTable.GetSlot(tabp, kp[0], Varptr(keyslot))\n\t\t\tIf (slot = Null) Or (keyslot[0] <> kp[0])\t'not in table; invoke metamethod\n\t\t\t\tIf keyslot = Long Ptr(1) Then varp[rp[0]] = BlueVMMemory.NIL ; Return\t'nil key\n\t\t\tElse\n\t\t\t\tvarp[rp[0]] = slot[0] ; Return\n\t\t\tEndIf\n\t\tEndIf\n\t\tMetamethod opc.GETTAB, bc, retptr, varp + rp[0], varp + rp[1], varp + rp[2]\n\tEnd Function\n\tFunction GETTABSI(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction SETTAB(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t\tPrint \"SETTAB \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET, kp:Long Ptr = Long Ptr Ptr(rp + 2)[0]\n\t\tLocal tabp:Byte Ptr = Byte Ptr Ptr(varp + rp[0])[0]\n\t\tPrint \" tag: \" + Bin(Int Ptr(kp)[1])\n\t\tLocal keyslot:Long Ptr = Null, slot:Long Ptr = BlueTable.GetSlot(tabp, kp[0], Varptr(keyslot))\n\t\tPrint \" slot: \" + Hex(Int(slot))\n\t\tIf (slot = Null) Or (keyslot[0] <> kp[0])\t'not in table; invoke metamethod or rawset\n\t\t\t'if keyslot == 1 then it's invalid\n\t\t\tLocal convert:BlueVM(p:Byte Ptr) = Byte Ptr(Identity), vm:BlueVM = convert(bc.vm)\n\t\t\tBlueTable.RawSet(vm.mem, tabp, kp[0], varp[rp[1]])\n\t\tElse\n\t\t\tslot[0] = varp[rp[1]]\n\t\tEndIf\n\tEnd Function\n\tFunction SETTABSI(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t\tPrint \"SETTABSI \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal convert:BlueVM(p:Byte Ptr) = Byte Ptr(Identity), vm:BlueVM = convert(bc.vm)\n\t\tLocal tabp:Byte Ptr = varp + rp[0]\n\t\tPrint \" \" + Short Ptr(rp)[1]\n\t\tLocal key:Long ; Double Ptr(Varptr(key))[0] = Short Ptr(rp)[1]\n\t\tBlueTable.RawSet(vm.mem, Byte Ptr Ptr(tabp)[0], key, varp[rp[1]])\n\tEnd Function\n\tFunction GETTABI(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t\tPrint \"GETTABI \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal tabp:Byte Ptr = varp + rp[1]\n\t\tPrint \" tag: \" + Bin(Int Ptr(varp + rp[2])[1])\n\t\tLocal val:Long = BlueTable.RawGet(Byte Ptr Ptr(tabp)[0], varp[rp[2]])\n\t\tvarp[rp[0]] = val\n\tEnd Function\n\tFunction SETTABI(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t\tPrint \"SETTABI \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal convert:BlueVM(p:Byte Ptr) = Byte Ptr(Identity), vm:BlueVM = convert(bc.vm)\n\t\tLocal tabp:Byte Ptr = varp + rp[0]\n\t\tPrint \" \" + Double Ptr(varp)[rp[2]] + \" \" + Double Ptr(varp)[rp[1]]\n\t\tPrint \" tag: \" + Bin(Int Ptr(varp + rp[2])[1])\n\t\tBlueTable.RawSet(vm.mem, Byte Ptr Ptr(tabp)[0], varp[rp[2]], varp[rp[1]])\n\tEnd Function\n\tFunction GETUPV(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t\tPrint \"GETUPV \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tPrint \" \" + rp[0] + \" \" + rp[1] + \" \" + rp[2]\n\t\tDebugStop\n\t\tLocal upvp:Byte Ptr Ptr = Byte Ptr Ptr(Byte Ptr(stk) + STACKFRAME_INC), valp:Long Ptr = Long Ptr(upvp[rp[1]])\n\t\tvarp[rp[0]] = valp[0]\n\tEnd Function\n\tFunction GETENV(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\t'\"unlisted\" instruction: GETUPV for _ENV is translated into this at load-time\n\t\tPrint \"GETENV \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tPrint \" \" + rp[0] + \" \" + Hex(Int Ptr(rp + 1)[0])\n\t\t'need a type check\n\t\tvarp[rp[0]] = Long Ptr Ptr(rp + 1)[0][0]\n\tEnd Function\n\tFunction SETUPV(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction NEWTAB(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t\tPrint \"NEWTAB \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal convert:BlueVM(p:Byte Ptr) = Byte Ptr(Identity), vm:BlueVM = convert(bc.vm)\n\t\tLocal tab:Byte Ptr = vm.mem.AllocTable(Null)\n\t\tLocal d:Int Ptr = Int Ptr(varp + rp[0])\n\t\td[0] = Int(tab) ; d[1] = BlueTypeTag.NANBOX | BlueTypeTag.TBL\n\tEnd Function\n\tFunction CLOSURE(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"CLOSURE \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal convert:BlueVM(p:Byte Ptr) = Byte Ptr(Identity), vm:BlueVM = convert(bc.vm)\n\t\tLocal d:Int Ptr = Int Ptr(varp + rp[0])\n\t\tLocal cbytecode:Bytecode = vm.funIndex[Int Ptr(rp + 1)[0]], upvp:Int Ptr = Int Ptr(Byte Ptr(cbytecode) + BYTECODE_INC + 8 * cbytecode.icount)\n\t\tLocal closure:Byte Ptr = vm.mem.AllocClosure(cbytecode, cbytecode.upvars)\t'upvars is always even (alignment)\n\t\t\n\t\t'get upvalues off the stack\n\t\tFor Local u:Int = 0 Until cbytecode.upvars\n\t\t\tIf upvp[2 * u]\n\t\t\t\tByte Ptr Ptr(closure)[2 + u] = Byte Ptr Ptr(Byte Ptr(stk) + STACKFRAME_INC)[upvp[2 * u + 1]]\n\t\t\tElse\n\t\t\t\tByte Ptr Ptr(closure)[2 + u] = Byte Ptr Ptr(varp + upvp[2 * u + 1])[0]\n\t\t\tEndIf\n\t\tNext\n\t\t\n\t\td[0] = Int(closure) ; d[1] = BlueTypeTag.NANBOX | BlueTypeTag.FUN\n\tEnd Function\n\tFunction NEWUPV(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"NEWUPV \/\/\"\n\t\tLocal rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal convert:BlueVM(p:Byte Ptr) = Byte Ptr(Identity), vm:BlueVM = convert(bc.vm)\n\t\tLocal upv:Byte Ptr = vm.mem.AllocObject(8, BlueTypeTag.UPV), d:Int Ptr = Int Ptr(stk.varp + rp[0])\n\t\tLong Ptr(upv)[0] = Long Ptr(d)[0]\t'promote a value if it existed (useful for parameters)\n\t\td[0] = Int(upv) ; d[1] = BlueTypeTag.NANBOX | BlueTypeTag.UPV\n\tEnd Function\n\t\n\tFunction ADD(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t\tPrint \"ADD \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal d:Double Ptr = Double Ptr(varp + rp[0])\n\t\tLocal r:Int Ptr = Int Ptr(varp + rp[1]), l:Int Ptr = Int Ptr(varp + rp[2])\n\t\tIf l[1] & BlueTypeTag.NANBOX_CHK = BlueTypeTag.NANBOX Or r[1] & BlueTypeTag.NANBOX_CHK = BlueTypeTag.NANBOX\n\t\t\tDebugStop\n\t\tElse\n\t\t\tPrint \" \" + Double Ptr(l)[0] + \" \" + Double Ptr(r)[0]\n\t\t\td[0] = Double Ptr(l)[0] + Double Ptr(r)[0]\n\t\tEndIf\n\tEnd Function\n\tFunction SUB(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction MUL(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction DIV(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction NMOD(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction POW(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction CAT(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction IDIV(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction BAND(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction BOR(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction BXOR(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction BSHL(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction BSHR(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction UNM(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction LNOT(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction ALEN(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction BNOT(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction UNP(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction EQ(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"EQ \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = (Byte Ptr Ptr(retptr) - 4)[0] + IP_OFFSET\n\t\tLocal r:Double = Double Ptr(varp)[rp[1]]\n\t\tLocal l:Double = Double Ptr(varp)[rp[2]]\n\t\tInt Ptr(varp + rp[0])[0] = l = r\n\tEnd Function\n\tFunction LT(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction LEQ(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\t\n\tFunction JMP(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t\tRuntimeError \"wait, why are we here?\"\n\tEnd Function\n\tFunction JIF(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"JIF \/\/\"\n\t\tLocal rp:Byte Ptr = (Byte Ptr Ptr(retptr) - 4)[0] + IP_OFFSET\n\t\tIf Int Ptr(stk.varp + rp[0])[0]\n\t\t\tLocal target:Int = Int Ptr(rp + 1)[0]\n\t\t\tInt Ptr(retptr)[-4] = target\n\t\tEndIf\n\tEnd Function\n\tFunction JNOT(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction CALL(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"CALL \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp, rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\tLocal fp:Int Ptr = Int Ptr(varp + rp[0])\n\t\tIf Not PrepareCall(fp, stk, rp, varp, retptr)\t'PrepareCall sets everything up so there's nothing else to do to make the call happen\n\t\t\t'__call metamethod\n\t\tEndIf\n\tEnd Function\n\tFunction TCALL(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction RET:Byte Ptr(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"RET \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp\n\t\tLocal rp0:Byte Ptr = Byte Ptr Ptr(retptr)[-4], rp:Byte Ptr = rp0 + IP_OFFSET\n\t\t\n\t\tLocal oldStk:Stack = stk.prevBase\n\t\tLocal retv:Long Ptr = varp + rp[0]\n\t\tIf oldStk\n\t\t\toldStk.retv = retv\n\t\t\toldStk.retc = Int Ptr(rp + 1)[0]\n\t\t\tByte Ptr Ptr(retptr)[-4] = stk.retIP\n\t\t\tByte Ptr Ptr(retptr)[-3] = Byte Ptr(oldStk)\n\t\t\tByte Ptr Ptr(retptr)[-2] = Byte Ptr(oldStk.func) + BYTECODE_INC\n\t\tElse\t'return to native code\n\t\t\tLocal codePage:Byte Ptr = Byte Ptr(Int(rp0) & ((Int(2^12)-1) Shl 20))\n\t\t\tByte Ptr Ptr(retptr)[-4] = codePage + 4\n\t\t\tReturn retv\n\t\tEndIf\n\tEnd Function\n\tFunction RETVA(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction POSTCALL(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\t'\tPrint \"POSTCALL \/\/\"\n\t\tLocal varp:Long Ptr = stk.varp\n\t\tLocal rp:Byte Ptr = Byte Ptr Ptr(retptr)[-4] + IP_OFFSET\n\t\t\n\t\tFor Local r:Int = 0 Until Min(Int Ptr(rp + 1)[0], stk.retc)\n\t\t\t(varp + rp[0])[r] = stk.retv[r]\n\t\t'\tPrint \" return \" + r + \": \" + Double Ptr(stk.retv)[r]\n\t\tNext\n\t\t'nil the rest\n\tEnd Function\n\tFunction VARARG(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction VAINIT(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\tFunction CALLINIT(stk:Stack, bc:Bytecode, retptr:Byte Ptr)\n\tEnd Function\n\t\n\t\n\tFunction PrepareCall:Int(fp:Int Ptr, stk:Stack, rp:Byte Ptr, varp:Long Ptr, retptr:Byte Ptr)\n\t\tIf fp[1] = BlueTypeTag.NANBOX | BlueTypeTag.FUN\n\t\t\tLocal newStk0:Stack ; Byte Ptr Ptr(Varptr(newStk0))[0] = Byte Ptr(stk) + stk.func.frameSz\n\t\t\tLocal newStk:Stack = newStk0\t'micro-opt: newStk0 can't be a register because of the unwieldy conversion\n\t\t\t\n\t\t\tnewStk.retIP = Byte Ptr Ptr(retptr)[-4]\n\t\t\tnewStk.prevBase = stk\n\t\t\tLocal closure:Byte Ptr = Byte Ptr(fp[0])\n\t\t\tLocal newBC:Bytecode = Bytecode Ptr(closure)[0]\n\t\t\tLocal voff:Int = STACKFRAME_INC + 4 * newBC.upvars\n\t\t\tnewStk.varp = Long Ptr(Byte Ptr(newStk) + voff)\n\t\t\tnewStk.func = newBC\n\t\t\t\n\t\t\tLocal argc_actual:Int = Short Ptr(rp)[1], argc_required:Int = newBC.pcount\n\t\t'\tLocal argc_min:Int ; If argc_actual < argc_required Then argc_min = argc_actual Else argc_min = argc_required\n\t\t\tLocal argc_min:Int = argc_actual - argc_required ; argc_min = (argc_min & (argc_min Shr 31)) + argc_required 'branchless 32-bit Min\n\t\t\t\n\t\t\tLocal argv:Long Ptr = varp + rp[1], destv:Long Ptr = newStk.varp\n\t\t\tFor Local a:Int = 0 Until argc_min\n\t\t\t\tdestv[a] = argv[a]\n\t\t\t'\tPrint \" arg \" + a + \": \" + argv[a]\n\t\t\tNext\n\t\t\tFor Local a:Int = argc_min Until argc_required\t'nil any unfilled parameters\n\t\t\t\tInt Ptr(destv + a)[1] = BlueTypeTag.NANBOX | BlueTypeTag.NIL\n\t\t\tNext\n\t\t\tnewStk.argv = argv + argc_min\t'argv should be to the varargs (if any)\n\t\t\tnewStk.argc = argc_actual - argc_min\t'argc is the number of varargs\n\t\t\t\n\t\t\tLocal destup:Byte Ptr Ptr = Byte Ptr Ptr(Byte Ptr(newStk) + STACKFRAME_INC)\n\t\t\tLocal upv:Byte Ptr Ptr = Byte Ptr Ptr(closure + 8)\n\t\t\tFor Local up:Int = 0 Until newBC.upvars\t'emplace upvars\n\t\t\t\tdestup[up] = upv[up]\n\t\t\t'\tPrint \" upv \" + up + \": \" + destv[up]\n\t\t\t'\tPrint \" val: \" + Double Ptr Ptr(Byte Ptr Ptr(closure) + 2 + up)[0][0]\n\t\t\tNext\n\t\t\t\n\t\t\t'note that the following OVERWRITE THE PARAMETERS (in release mode), so no touching stk from here on\n\t\t\tByte Ptr Ptr(retptr)[-4] = newBC.mcode\n\t\t\tByte Ptr Ptr(retptr)[-3] = Byte Ptr(newStk)\n\t\t\tByte Ptr Ptr(retptr)[-2] = Byte Ptr(newBC) + BYTECODE_INC\n\t\t\t\n\t\tElseIf fp[1] = BlueTypeTag.NANBOX | BlueTypeTag.NATFUN\t'native call\n\t\t\tLocal fun:Int(vm:BlueVM, ac:Int, av:Long Ptr, rv:Long Ptr) = Byte Ptr(fp[0])\n\t\t\tLocal argc:Int = Short Ptr(rp)[1], argv:Long Ptr = varp + rp[1], retv:Long Ptr = Long Ptr(Byte Ptr(stk) + stk.func.frameSz)\n\t\t\tLocal convert:BlueVM(p:Byte Ptr) = Byte Ptr(Identity), vm:BlueVM = convert(stk.func.vm)\n\t\t\tstk.retc = fun(vm, argc, argv, retv)\n\t\t\tstk.retv = retv\n\t\tElse\n\t\t\tReturn False\t'not a function; take appropriate action\n\t\tEndIf\n\t\tReturn True\t'all good and will auto-call when the caller returns\n\tEnd Function\n\t\n\tFunction Metamethod(op:Int, bc:Bytecode, retptr:Byte Ptr, d:Long Ptr, r:Long Ptr, l:Long Ptr)\t'prep but not execute a call\n\t\t'need to work out a way to return values from this without POSTCALL (maybe can co-opt RET to handle singles by itself)\n\t\tLocal convert:BlueVM(p:Byte Ptr) = Byte Ptr(Identity), vm:BlueVM = convert(bc.vm)\n\t\tvm.Error(\"metamethod access isn't implemented yet\")\n\tEnd Function\n\t\n\tFunction InitOpTbl()\n\t\topc = New BlueOpcode\n\t\topTbl = [MOV, GETLC, SETLC, LOADK, LOADSI, LOADBOOL, LOADNIL, ..\n\t\t\tGETTAB, GETTABSI, SETTAB, SETTABSI, GETTABI, SETTABI, GETUPV, SETUPV, ..\n\t\t\tNEWTAB, CLOSURE, NEWUPV, ..\n\t\t\tADD, SUB, MUL, DIV, NMOD, POW, CAT, ..\n\t\t\tIDIV, BAND, BOR, BXOR, BSHL, BSHR, ..\n\t\t\tUNM, LNOT, ALEN, BNOT, UNP, ..\n\t\t\tEQ, LT, LEQ, ..\n\t\t\tJMP, JIF, JNOT, CALL, TCALL, RETVA, RETVA, ..\t'not a mistake: RET doesn't fit but we need the spacer\n\t\t\tPOSTCALL, VARARG, VAINIT, CALLINIT]\n\t\t\n\t\topTbl[opc.RET] = Byte Ptr(RET)\n\tEnd Function\n\t\n\tFunction Identity:Byte Ptr(b:Byte Ptr)\n\t\tReturn b\n\tEnd Function\n\tFunction PointerToExtType:Byte Ptr(p:Byte Ptr)\t'horrible pointer abuse (increment down so we can ignore the nonexistent vtbl)\n\t\tReturn p - SizeOf(Byte Ptr(0))\n\tEnd Function\n\tGlobal BPtoS:Stack(p:Byte Ptr) = Byte Ptr(BlueJIT.PointerToExtType)\nEnd Type\n\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"0c0831244d1e27750282b7e0ae059810547a7e4d","subject":"Added DependencyEnumerator and CheckCompliance to mxModuleDependencies.","message":"Added DependencyEnumerator and CheckCompliance to mxModuleDependencies.\n","repos":"maximos\/maximus","old_file":"src\/dependencies.bmx","new_file":"src\/dependencies.bmx","new_contents":"\nRem\nCopyright (c) 2010 Tim Howard\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and\/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\nEnd Rem\n\nRem\n\tbbdoc: Maximus module dependencies.\nEnd Rem\nType mxModuleDependencies Extends dObjectMap\n\t\n\tRem\n\t\tbbdoc: Add a new dependency with the given key.\n\t\treturns: True if the dependency was added, or False if it was not (given string is Null).\n\tEnd Rem\n\tMethod AddNewDependency:Int(key:String)\n\t\tIf key <> Null\n\t\t\tLocal dep:mxModuleDependency = New mxModuleDependency.Create(key)\n\t\t\t_Insert(key, dep)\n\t\t\tReturn True\n\t\tEnd If\n\t\tReturn False\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Add the given dependency.\n\t\treturns: True if the dependency was added, or False if it was not (given string is Null).\n\tEnd Rem\n\tMethod AddDependency:Int(dep:mxModuleDependency)\n\t\tIf dep <> Null\n\t\t\t_Insert(dep.Get(), dep)\n\t\t\tReturn True\n\t\tEnd If\n\t\tReturn False\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Check if the given dependency exists.\n\t\treturns: True if the given dependency was found, or False if it was not.\n\tEnd Rem\n\tMethod HasDependency:Int(key:String)\n\t\tReturn _Contains(key)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Add the dependencies from the given mxModuleDependencies.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod MergeDependencies(dependencies:mxModuleDependencies)\n\t\tFor Local dep:mxModuleDependency = EachIn dependencies.DependencyEnumerator()\n\t\t\tAddDependency(dep) ' No need to check if they're already in here, they'll just be overwritten with the same thing\n\t\tNext\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Check the dependency compliance of the current module set.\n\t\treturns: Null if all dependencies are matched by existing modules, or a list of module ids that are not yet installed.\n\tEnd Rem\n\tMethod CheckCompliance:TListEx()\n\t\tLocal nocomp:TListEx = New TListEx\n\t\tFor Local dep:mxModuleDependency = EachIn DependencyEnumerator()\n\t\t\tIf mxModUtils.HasModule(dep.Get()) = False\n\t\t\t\tnocomp.AddLast(dep.Get())\n\t\t\tEnd If\n\t\tNext\n\t\tIf nocomp.Count() > 0 Then Return nocomp\n\t\tReturn Null\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Load the dependencies from the given dJArray.\n\t\treturns: Itself, or Null if @root is Null.\n\tEnd Rem\n\tMethod FromJSON:mxModuleDependencies(root:dJArray)\n\t\tIf root <> Null\n\t\t\tFor Local strvar:dStringVariable = EachIn root.GetValues()\n\t\t\t\tAddDependency(New mxModuleDependency.FromVariable(strvar))\n\t\t\tNext\n\t\t\tReturn Self\n\t\tEnd If\n\t\tReturn Null\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get a string containing the list of dependencies, separated by @separator.\n\t\treturns: A string containing the list of dependencies.\n\tEnd Rem\n\tMethod DependencyList:String(separator:String = \", \")\n\t\tLocal a:String, dep:mxModuleDependency\n\t\tFor dep = EachIn DependencyEnumerator()\n\t\t\ta:+ dep.Get() + separator\n\t\tNext\n\t\tIf a.Length > 0 Then a = a[..a.Length - separator.Length]\n\t\tReturn a\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the dependency enumerator.\n\t\treturns: The dependency enumerator.\n\tEnd Rem\n\tMethod DependencyEnumerator:TMapEnumerator()\n\t\tReturn ValueEnumerator()\n\tEnd Method\n\t\nEnd Type\n\nRem\n\tbbdoc: Maximus module dependency.\nEnd Rem\nType mxModuleDependency\n\t\n\tField m_key:String\n\t\n\tRem\n\t\tbbdoc: Create a new mxModuleDependency.\n\t\treturns: Itself.\n\tEnd Rem\n\tMethod Create:mxModuleDependency(key:String)\n\t\tSet(key)\n\t\tReturn Self\n\tEnd Method\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the dependency.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod Set(key:String)\n\t\tAssert key, \"(mxModuleDependency.Set) key cannot be Null\"\n\t\tm_key = key\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the dependency.\n\t\treturns: The dependency.\n\tEnd Rem\n\tMethod Get:String()\n\t\tReturn m_key\n\tEnd Method\n\t\n'#end region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the dependency from the given variable.\n\t\treturns: Itself, or Null if the given variable is Null.\n\tEnd Rem\n\tMethod FromVariable:mxModuleDependency(strvar:dStringVariable)\n\t\tIf strvar <> Null\n\t\t\tSet(strvar.Get())\n\t\t\tReturn Self\n\t\tEnd If\n\t\tReturn Null\n\tEnd Method\n\t\nEnd Type\n\n","old_contents":"\nRem\nCopyright (c) 2010 Tim Howard\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and\/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\nEnd Rem\n\nRem\n\tbbdoc: Maximus module dependencies.\nEnd Rem\nType mxModuleDependencies Extends dObjectMap\n\t\n\tRem\n\t\tbbdoc: Add a new dependency with the given key.\n\t\treturns: True if the dependency was added, or False if it was not (given string is Null).\n\tEnd Rem\n\tMethod AddNewDependency:Int(key:String)\n\t\tIf key <> Null\n\t\t\tLocal dep:mxModuleDependency = New mxModuleDependency.Create(key)\n\t\t\t_Insert(key, dep)\n\t\t\tReturn True\n\t\tEnd If\n\t\tReturn False\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Add the given dependency.\n\t\treturns: True if the dependency was added, or False if it was not (given string is Null).\n\tEnd Rem\n\tMethod AddDependency:Int(dep:mxModuleDependency)\n\t\tIf dep <> Null\n\t\t\t_Insert(dep.Get(), dep)\n\t\t\tReturn True\n\t\tEnd If\n\t\tReturn False\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Check if the given dependency exists.\n\t\treturns: True if the given dependency was found, or False if it was not.\n\tEnd Rem\n\tMethod HasDependency:Int(key:String)\n\t\tReturn _Contains(key)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Add the dependencies from the given mxModuleDependencies.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod MergeDependencies(dependencies:mxModuleDependencies)\n\t\tFor Local dep:mxModuleDependency = EachIn dependencies.ValueEnumerator()\n\t\t\tAddDependency(dep) ' No need to check if they're already in here, they'll just be overwritten with the same thing\n\t\tNext\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Load the dependencies from the given dJArray.\n\t\treturns: Itself, or Null if @root is Null.\n\tEnd Rem\n\tMethod FromJSON:mxModuleDependencies(root:dJArray)\n\t\tIf root <> Null\n\t\t\tFor Local strvar:dStringVariable = EachIn root.GetValues()\n\t\t\t\tAddDependency(New mxModuleDependency.FromVariable(strvar))\n\t\t\tNext\n\t\t\tReturn Self\n\t\tEnd If\n\t\tReturn Null\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get a string containing the list of dependencies, separated by @separator.\n\t\treturns: A string containing the list of dependencies.\n\tEnd Rem\n\tMethod DependencyList:String(separator:String = \", \")\n\t\tLocal a:String, dep:mxModuleDependency\n\t\tFor dep = EachIn ValueEnumerator()\n\t\t\ta:+ dep.Get() + separator\n\t\tNext\n\t\tIf a.Length > 0 Then a = a[..a.Length - separator.Length]\n\t\tReturn a\n\tEnd Method\n\t\nEnd Type\n\nRem\n\tbbdoc: Maximus module dependency.\nEnd Rem\nType mxModuleDependency\n\t\n\tField m_key:String\n\t\n\tRem\n\t\tbbdoc: Create a new mxModuleDependency.\n\t\treturns: Itself.\n\tEnd Rem\n\tMethod Create:mxModuleDependency(key:String)\n\t\tSet(key)\n\t\tReturn Self\n\tEnd Method\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the dependency.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod Set(key:String)\n\t\tAssert key, \"(mxModuleDependency.Set) key cannot be Null\"\n\t\tm_key = key\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the dependency.\n\t\treturns: The dependency.\n\tEnd Rem\n\tMethod Get:String()\n\t\tReturn m_key\n\tEnd Method\n\t\n'#end region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the dependency from the given variable.\n\t\treturns: Itself, or Null if the given variable is Null.\n\tEnd Rem\n\tMethod FromVariable:mxModuleDependency(strvar:dStringVariable)\n\t\tIf strvar <> Null\n\t\t\tSet(strvar.Get())\n\t\t\tReturn Self\n\t\tEnd If\n\t\tReturn Null\n\tEnd Method\n\t\nEnd Type\n\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"bce31b0ae54cd6883ac7993db2e0a9fc84fe3db5","subject":"Made Newton driver compatible with 3.11.","message":"Made Newton driver compatible with 3.11.\n","repos":"kfprimm\/maxb3d,kfprimm\/maxb3d","old_file":"newton.mod\/driver.bmx","new_file":"newton.mod\/driver.bmx","new_contents":"\nStrict\n\nImport MaxB3D.Core\nImport Prime.Newton\n\nImport \"util.c\"\n\nExtern\n\tFunction _byte_ptr_to_object:Object(p:Byte Ptr)\nEnd Extern\n\nType TNewtonCollisionDriver Extends TCollisionDriver\n\tField _world:Byte Ptr\n\t\n\tMethod Init()\n\t\t_world = NewtonCreate()\n\t\t' NewtonSetPlatformArchitecture _world, 0\n\n\t\tLocal minSize#[] = [-500.0, -500.0, -500.0]\n\t\tLocal maxSize#[] = [ 500.0, 500.0, 500.0]\n\t\t'NewtonSetWorldSize _world, minSize, maxSize\t\t\n\t\n\t\tNewtonSetSolverModel _world, 1\n\tEnd Method\n\t\n\tMethod Destroy()\n\t\tNewtonDestroyAllBodies _world\n\t\tNewtonDestroy _world\n\tEnd Method\n\t\n\tMethod Update(config:TWorldConfig,speed#)\n\t\tFor Local body:TBody=EachIn config.List[WORLDLIST_BODY]\n\t\t\tIf Not body._update And body._data<>Null Continue\n\t\t\tIf Not TNewtonData(body._data) body._data=New TNewtonData\n\t\t\tLocal data:TNewtonData=TNewtonData(body._data)\n\t\t\t\n\t\t\tLocal collision:Byte Ptr\n\t\t\tSelect body._shape\n\t\t\tCase BODY_SPHERE,BODY_NONE\n\t\t\t\tcollision=NewtonCreateCapsule(_world,body._radiusx,body._radiusy,0,Null)\n\t\t\tCase BODY_BOX\n\t\t\t\t'Local offset:TMatrix=TMatrix.Translation((body._boxwidth\/2.0)-body._boxx,(body._boxheight\/2.0)-body._boxy,(body._boxdepth\/2.0)-body._boxz)\n\t\t\t\tcollision=NewtonCreateBox(_world,body._boxwidth,body._boxheight,body._boxdepth,0,Null)\n\t\t\tEnd Select\t\t\t\n\n\t\t\tIf data._ptr NewtonDestroyBody(data._ptr)\n\n\t\t\tdata._ptr=NewtonCreateDynamicBody(_world,collision,body._matrix.ToPtr())\n\t\t\tNewtonBodySetUserData data._ptr, Byte Ptr(body) - 8\n\t\t\t\n\t\t\tIf body._mass>0\n\t\t\t\tLocal inertia#[3],origin#[3]\n\t\t\t\tNewtonConvexCollisionCalculateInertialMatrix collision,inertia,origin\t\n\t\t\t\tNewtonBodySetMassMatrix data._ptr,body._mass,body._mass*inertia[0],body._mass*inertia[1],body._mass*inertia[2]\n\t\t\t\tNewtonBodySetCentreOfMass data._ptr,origin\n\t\t\tEndIf\n\t\t\t\n\t\t\tNewtonBodySetDestructorCallback data._ptr, DestroyCallback\t\t\t\t\n\t\t\tNewtonBodySetForceAndTorqueCallback data._ptr, ForceAndTorqueCallback\n\t\t\tNewtonBodySetTransformCallback data._ptr, TransformCallback\t\t\t\n\n\t\t\t'NewtonReleaseCollision _world,collision\n\t\t\tbody._update=False\n\t\tNext\n \tNewtonUpdate _world,speed\n\tEnd Method\n\t\n\tFunction TransformCallback(body:Byte Ptr,matrix_data:Float Ptr,thread_index)\n\t\tLocal entity:TBody = TBody(_byte_ptr_to_object(NewtonBodyGetUserData(body)))\n\t\tentity.SetMatrix TMatrix.FromPtr(matrix_data)\n\t\tentity._update=False\n\tEnd Function\n\t\n\tFunction ForceAndTorqueCallback(body:Byte Ptr,timestep#,thread_index)\n\t\tLocal ixx#,iyy#,izz#,mass#\n\t\tNewtonBodyGetMassMatrix body,Varptr mass,Varptr ixx,Varptr iyy,Varptr izz\n\t\tNewtonBodySetForce body,[0.0,mass*-9.8,0.0]\n\tEnd Function\n\t\n\tFunction DestroyCallback(body:Byte Ptr)\n\t\t\n\tEnd Function\nEnd Type\n\nType TNewtonData\n\tField _ptr:Byte Ptr\nEnd Type\n\n","old_contents":"\nStrict\n\nImport MaxB3D.Core\nImport Prime.Newton\n\nImport \"util.c\"\n\nExtern\n\tFunction _byte_ptr_to_object:Object(p:Byte Ptr)\nEnd Extern\n\nType TNewtonCollisionDriver Extends TCollisionDriver\n\tField _world:Byte Ptr\n\t\n\tMethod Init()\n\t\t_world = NewtonCreate()\n\t\tNewtonSetPlatformArchitecture _world, 0\n\n\t\tLocal minSize#[] = [-500.0, -500.0, -500.0]\n\t\tLocal maxSize#[] = [ 500.0, 500.0, 500.0]\n\t\tNewtonSetWorldSize _world, minSize, maxSize\t\t\n\t\n\t\tNewtonSetSolverModel _world, 1\n\tEnd Method\n\t\n\tMethod Destroy()\n\t\tNewtonDestroyAllBodies _world\n\t\tNewtonDestroy _world\n\tEnd Method\n\t\n\tMethod Update(config:TWorldConfig,speed#)\n\t\tFor Local body:TBody=EachIn config.List[WORLDLIST_BODY]\n\t\t\tIf Not body._update And body._data<>Null Continue\n\t\t\tIf Not TNewtonData(body._data) body._data=New TNewtonData\n\t\t\tLocal data:TNewtonData=TNewtonData(body._data)\n\t\t\t\n\t\t\tLocal collision:Byte Ptr\n\t\t\tSelect body._shape\n\t\t\tCase BODY_SPHERE,BODY_NONE\n\t\t\t\tcollision=NewtonCreateSphere(_world,body._radiusx,body._radiusy,body._radiusx,0,Null)\n\t\t\tCase BODY_BOX\n\t\t\t\t'Local offset:TMatrix=TMatrix.Translation((body._boxwidth\/2.0)-body._boxx,(body._boxheight\/2.0)-body._boxy,(body._boxdepth\/2.0)-body._boxz)\n\t\t\t\tcollision=NewtonCreateBox(_world,body._boxwidth,body._boxheight,body._boxdepth,0,Null)\n\t\t\tEnd Select\t\t\t\n\n\t\t\tIf data._ptr NewtonDestroyBody(_world,data._ptr)\n\n\t\t\tdata._ptr=NewtonCreateBody(_world,collision,body._matrix.ToPtr())\n\t\t\tNewtonBodySetUserData data._ptr, Byte Ptr(body) - 8\n\t\t\t\n\t\t\tIf body._mass>0\n\t\t\t\tLocal inertia#[3],origin#[3]\n\t\t\t\tNewtonConvexCollisionCalculateInertialMatrix collision,inertia,origin\t\n\t\t\t\tNewtonBodySetMassMatrix data._ptr,body._mass,body._mass*inertia[0],body._mass*inertia[1],body._mass*inertia[2]\n\t\t\t\tNewtonBodySetCentreOfMass data._ptr,origin\n\t\t\tEndIf\n\t\t\t\n\t\t\tNewtonBodySetDestructorCallback data._ptr, DestroyCallback\t\t\t\t\n\t\t\tNewtonBodySetForceAndTorqueCallback data._ptr, ForceAndTorqueCallback\n\t\t\tNewtonBodySetTransformCallback data._ptr, TransformCallback\t\t\t\n\n\t\t\tNewtonReleaseCollision _world,collision\n\t\t\tbody._update=False\n\t\tNext\n \tNewtonUpdate _world,speed\n\tEnd Method\n\t\n\tFunction TransformCallback(body:Byte Ptr,matrix_data:Float Ptr,thread_index)\n\t\tLocal entity:TBody = TBody(_byte_ptr_to_object(NewtonBodyGetUserData(body)))\n\t\tentity.SetMatrix TMatrix.FromPtr(matrix_data)\n\t\tentity._update=False\n\tEnd Function\n\t\n\tFunction ForceAndTorqueCallback(body:Byte Ptr,timestep#,thread_index)\n\t\tLocal ixx#,iyy#,izz#,mass#\n\t\tNewtonBodyGetMassMatrix body,Varptr mass,Varptr ixx,Varptr iyy,Varptr izz\n\t\tNewtonBodySetForce body,[0.0,mass*-9.8,0.0]\n\tEnd Function\n\t\n\tFunction DestroyCallback(body:Byte Ptr)\n\t\t\n\tEnd Function\nEnd Type\n\nType TNewtonData\n\tField _ptr:Byte Ptr\nEnd Type\n\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"e1d6d4d0fe58f988dabc02a82c4e3d96bd96b285","subject":"Added some bbdoc","message":"Added some bbdoc\n\nrefs gh-17\n","repos":"maximos\/maximus","old_file":"gui\/logger.bmx","new_file":"gui\/logger.bmx","new_contents":"Rem\n\tbbdoc: This observer for mxLogger will write received messages to a TGadget or use Notify\nEnd Rem\nType mxLoggerObserverGUI\n\n\tRem\n\t\tbbdoc: Object to write message to\n\tEnd Rem\n\tField m_output:Object\n\t\n\tRem\n\t\tbbdoc: Reset content of m_object\n\tEnd Rem\n\tMethod Reset()\n\t\tIf TGadget(m_output)\n\t\t\tSetGadgetText(TGadget(m_output), \"\")\n\t\tEnd If\n\tEnd Method\n\n\tRem\n\t\tbbdoc: Handle messages\n\tEnd Rem\n\tMethod SendMessage:Object(message:Object, context:Object)\n\t\tLocal msg:String = String(message)\n\t\tIf String(context) = \"error\"\n\t\t\tNotify(msg, True)\n\t\tElse If TGadget(m_output)\n\t\t\tLocal gadget:TGadget = TGadget(m_output)\n\t\t\tSetGadgetText(gadget, GadgetText(gadget) + String(message))\n\t\t\t'Refresh GUI\n\t\t\tDriver.Poll\n\t\tElse If m_output = Null\n\t\t\tNotify(msg)\n\t\tEnd If\n\tEnd Method\n\nEnd Type","old_contents":"Type mxLoggerObserverGUI\n\n\tField m_output:Object\n\t\n\tMethod Reset()\n\t\tIf TGadget(m_output)\n\t\t\tSetGadgetText(TGadget(m_output), \"\")\n\t\tEnd If\n\tEnd Method\n\n\tMethod SendMessage:Object(message:Object, context:Object)\n\t\tLocal msg:String = String(message)\n\t\tIf String(context) = \"error\"\n\t\t\tNotify(msg, True)\n\t\tElse If TGadget(m_output)\n\t\t\tLocal gadget:TGadget = TGadget(m_output)\n\t\t\tSetGadgetText(gadget, GadgetText(gadget) + String(message))\n\t\t\t'Refresh GUI\n\t\t\tDriver.Poll\n\t\tElse If m_output = Null\n\t\t\tNotify(msg)\n\t\tEnd If\n\tEnd Method\n\nEnd Type","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"dbbe1ed2e1b7c810d6f7d4c7b291f24a7ab1366e","subject":"Added test for TZMQ_Message.Create","message":"Added test for TZMQ_Message.Create\n","repos":"Htbaa\/zmq.mod,Htbaa\/zmq.mod","old_file":"tests\/main.bmx","new_file":"tests\/main.bmx","new_contents":"SuperStrict\nFramework bah.maxunit\nImport htbaapub.zmq\n\nNew TTestSuite.run()\n\nType TZMQ_Test Extends TTest\n\n\tMethod Setup() {before}\n\tEnd Method\n\t\n\tMethod Teardown() {after}\n\tEnd Method\n\n\tMethod Version() {test}\n\t\tLocal parts:String[] = TZMQ.Version().Split(\".\")\n\t\tassertTrue(parts.Length = 3, \"Version string contains 3 parts\")\n\tEnd Method\n\t\n\t'Make sure recreating an existing context\n\tMethod ContextReCreate() {test}\n\t\tLocal ct:TZMQ_Context = New TZMQ_Context.Create()\n\t\tTry\n\t\t\tct = ct.Create()\n\t\tCatch ex:String\n\t\t\tassertNotNull(ex, \"Recreating context failed properly\")\n\t\tCatch ex:TZMQ_Exception\n\t\t\tfail(ex.ToString())\n\t\tEnd Try\n\t\tct.Term()\n\tEnd Method\n\n\t'Make sure a socket can be created\n\tMethod SocketCreate() {test}\n\t\tLocal ct:TZMQ_Context = New TZMQ_Context.Create()\n\t\tLocal socket:TZMQ_Socket = ct.socket(ZMQ_PUB)\n\t\tassertNotNull(socket, \"Created socket\")\n\t\tassertTrue(socket.socket <> Null, \"Created pointer to socket\")\n\t\tsocket.Close()\n\t\tct.Term()\n\tEnd Method\n\n\t'Make sure created messages contain expected data\n\tMethod MessageCreationFromStringIntegrity() {test}\n\t\tFor Local i:Int = 0 To 1000\n\t\t\tLocal text:String = \"Message \" + i\n\t\t\tLocal msg:TZMQ_Message = New TZMQ_Message.CreateFromString(text)\n\t\t\tassertEquals(text, msg.ToString(), \"Message text match\")\n\t\t\tassertEqualsI(text.Length, msg.Size(), \"Message size match\")\n\t\t\tmsg.Close()\n\t\tNext\n\tEnd Method\n\n\t'Make sure created messages contain expected data\n\tMethod MessageCreationFromPointerIntegrity() {test}\n\t\tFor Local i:Int = 0 To 1000\n\t\t\tLocal text:String = \"Message \" + i\n\t\t\tLocal msg:TZMQ_Message = New TZMQ_Message.Create(text.ToCString(), text.Length)\n\t\t\tassertEquals(text, msg.ToString(), \"Message text match\")\n\t\t\tassertEqualsI(text.Length, msg.Size(), \"Message size match\")\n\t\t\tmsg.Close()\n\t\t\tassertTrue(msg.content = Null, \"Message data freed\")\n\t\tNext\n\tEnd Method\n\t\n\t'Make sure exchanged messages aren't corrupt\n\tMethod MessageExchangingIntegrity() {test}\n\t\tLocal addr:String = \"tcp:\/\/127.0.0.1:6000\"\n\t\tLocal ct:TZMQ_Context = New TZMQ_Context.Create()\n\t\tLocal publisher:TZMQ_Socket = ct.socket(ZMQ_PUB)\n\t\tLocal subscriber:TZMQ_Socket = ct.socket(ZMQ_SUB)\n\t\t\n\t\tpublisher.Bind(addr)\n\t\tsubscriber.Connect(addr)\n\t\tsubscriber.SetSockOpt(ZMQ_SUBSCRIBE , Null)\n\n\t\tDelay 1000\n\t\tFor Local i:Int = 0 To 10\n\t\t\tDelay 10\n\t\t\tLocal text:String = \"Message \" + i\n\t\t\tpublisher.Send(text)\n\t\t\tLocal msg:TZMQ_Message = subscriber.Recv()\n\t\t\tIf msg = Null Then Continue\n\t\t\tassertEquals(text, msg.ToString(), \"Message \" + i + \" match\")\n\t\t\tassertEqualsI(text.Length, msg.Size(), \"Message \" + i + \" size match\")\n\t\t\tmsg.Close()\n\t\tNext\n\t\t\n\t\tsubscriber.Close()\n\t\tpublisher.Close()\n\t\tct.Term()\n\tEnd Method\nEnd Type\n","old_contents":"SuperStrict\nFramework bah.maxunit\nImport htbaapub.zmq\n\nNew TTestSuite.run()\n\nType TZMQ_Test Extends TTest\n\n\tMethod Setup() {before}\n\tEnd Method\n\t\n\tMethod Teardown() {after}\n\tEnd Method\n\n\tMethod Version() {test}\n\t\tLocal parts:String[] = TZMQ.Version().Split(\".\")\n\t\tassertTrue(parts.Length = 3, \"Version string contains 3 parts\")\n\tEnd Method\n\t\n\t'Make sure recreating an existing context\n\tMethod ContextReCreate() {test}\n\t\tLocal ct:TZMQ_Context = New TZMQ_Context.Create()\n\t\tTry\n\t\t\tct = ct.Create()\n\t\tCatch ex:String\n\t\t\tassertNotNull(ex, \"Recreating context failed properly\")\n\t\tCatch ex:TZMQ_Exception\n\t\t\tfail(ex.ToString())\n\t\tEnd Try\n\t\tct.Term()\n\tEnd Method\n\n\t'Make sure a socket can be created\n\tMethod SocketCreate() {test}\n\t\tLocal ct:TZMQ_Context = New TZMQ_Context.Create()\n\t\tLocal socket:TZMQ_Socket = ct.socket(ZMQ_PUB)\n\t\tassertNotNull(socket, \"Created socket\")\n\t\tassertTrue(socket.socket <> Null, \"Created pointer to socket\")\n\t\tsocket.Close()\n\t\tct.Term()\n\tEnd Method\n\n\t'Make sure created messages contain expected data\n\tMethod MessageCreationIntegrity() {test}\n\t\tFor Local i:Int = 0 To 1000\n\t\t\tLocal text:String = \"Message \" + i\n\t\t\tLocal msg:TZMQ_Message = New TZMQ_Message.CreateFromString(text)\n\t\t\tassertEquals(text, msg.ToString(), \"Message text match\")\n\t\t\tassertEqualsI(text.Length, msg.Size(), \"Message size match\")\n\t\t\tmsg.Close()\n\t\tNext\n\tEnd Method\n\t\n\t'Make sure exchanged messages aren't corrupt\n\tMethod MessageExchangingIntegrity() {test}\n\t\tLocal addr:String = \"tcp:\/\/127.0.0.1:6000\"\n\t\tLocal ct:TZMQ_Context = New TZMQ_Context.Create()\n\t\tLocal publisher:TZMQ_Socket = ct.socket(ZMQ_PUB)\n\t\tLocal subscriber:TZMQ_Socket = ct.socket(ZMQ_SUB)\n\t\t\n\t\tpublisher.Bind(addr)\n\t\tsubscriber.Connect(addr)\n\t\tsubscriber.SetSockOpt(ZMQ_SUBSCRIBE , Null)\n\n\t\tDelay 1000\n\t\tFor Local i:Int = 0 To 10\n\t\t\tDelay 10\n\t\t\tLocal text:String = \"Message \" + i\n\t\t\tpublisher.Send(text)\n\t\t\tLocal msg:TZMQ_Message = subscriber.Recv()\n\t\t\tIf msg = Null Then Continue\n\t\t\tassertEquals(text, msg.ToString(), \"Message \" + i + \" match\")\n\t\t\tassertEqualsI(text.Length, msg.Size(), \"Message \" + i + \" size match\")\n\t\t\tmsg.Close()\n\t\tNext\n\t\t\n\t\tsubscriber.Close()\n\t\tpublisher.Close()\n\t\tct.Term()\n\tEnd Method\nEnd Type\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"8913b92494c00a0a61399e763e84ec1b84054644","subject":"Compare to Const","message":"Compare to Const\n","repos":"maximos\/maximus","old_file":"gui\/logger.bmx","new_file":"gui\/logger.bmx","new_contents":"Rem\n\tbbdoc: This observer for mxLogger will write received messages to a TGadget or use Notify\nEnd Rem\nType mxLoggerObserverGUI\n\n\tRem\n\t\tbbdoc: Object to write message to\n\tEnd Rem\n\tField m_output:Object\n\t\n\tRem\n\t\tbbdoc: Reset content of m_object\n\tEnd Rem\n\tMethod Reset()\n\t\tIf TGadget(m_output)\n\t\t\tSetGadgetText(TGadget(m_output), \"\")\n\t\tEnd If\n\tEnd Method\n\n\tRem\n\t\tbbdoc: Handle messages\n\tEnd Rem\n\tMethod SendMessage:Object(message:Object, context:Object)\n\t\tLocal msg:String = String(message)\n\t\tIf String(context) = mxLogger.c_error\n\t\t\tNotify(msg, True)\n\t\tElse If TGadget(m_output)\n\t\t\tLocal gadget:TGadget = TGadget(m_output)\n\t\t\tSetGadgetText(gadget, GadgetText(gadget) + String(message))\n\t\t\t'Refresh GUI\n\t\t\tDriver.Poll\n\t\tElse If m_output = Null\n\t\t\tNotify(msg)\n\t\tEnd If\n\tEnd Method\n\nEnd Type","old_contents":"Rem\n\tbbdoc: This observer for mxLogger will write received messages to a TGadget or use Notify\nEnd Rem\nType mxLoggerObserverGUI\n\n\tRem\n\t\tbbdoc: Object to write message to\n\tEnd Rem\n\tField m_output:Object\n\t\n\tRem\n\t\tbbdoc: Reset content of m_object\n\tEnd Rem\n\tMethod Reset()\n\t\tIf TGadget(m_output)\n\t\t\tSetGadgetText(TGadget(m_output), \"\")\n\t\tEnd If\n\tEnd Method\n\n\tRem\n\t\tbbdoc: Handle messages\n\tEnd Rem\n\tMethod SendMessage:Object(message:Object, context:Object)\n\t\tLocal msg:String = String(message)\n\t\tIf String(context) = \"error\"\n\t\t\tNotify(msg, True)\n\t\tElse If TGadget(m_output)\n\t\t\tLocal gadget:TGadget = TGadget(m_output)\n\t\t\tSetGadgetText(gadget, GadgetText(gadget) + String(message))\n\t\t\t'Refresh GUI\n\t\t\tDriver.Poll\n\t\tElse If m_output = Null\n\t\t\tNotify(msg)\n\t\tEnd If\n\tEnd Method\n\nEnd Type","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"d62420c9d58be22f4d57f9a1878a86ee207289e4","subject":"Newton now skips compilation on MacOS.","message":"Newton now skips compilation on MacOS.\n","repos":"kfprimm\/maxb3d,kfprimm\/maxb3d","old_file":"newton.mod\/newton.bmx","new_file":"newton.mod\/newton.bmx","new_contents":"\nStrict\n\nRem\n\tbbdoc: Netwon Game Dynamics for MaxB3D\nEnd Rem\nModule MaxB3D.Newton\nModuleInfo \"Author: Kevin Primm\"\nModuleInfo \"License: MIT\"\n\n?Not MacOS\n\n' Separated to bypass a \"feature\" that would otherwise result in a linking error...ugh.\nImport \"driver.bmx\" \n\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction NewtonCollisionDriver:TNewtonCollisionDriver()\n\tGlobal _driver:TNewtonCollisionDriver=New TNewtonCollisionDriver\n\tReturn _driver\nEnd Function\n\n?","old_contents":"\nStrict\n\nRem\n\tbbdoc: Netwon Game Dynamics for MaxB3D\nEnd Rem\nModule MaxB3D.Newton\nModuleInfo \"Author: Kevin Primm\"\nModuleInfo \"License: MIT\"\n\n' Seperated to bypass a \"feature\" that would otherwise result in a linking error...ugh.\nImport \"driver.bmx\" \n\nRem\n\tbbdoc: Needs documentation. #TODO\nEnd Rem\nFunction NewtonCollisionDriver:TNewtonCollisionDriver()\n\tGlobal _driver:TNewtonCollisionDriver=New TNewtonCollisionDriver\n\tReturn _driver\nEnd Function\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"5086cf420cbc664cee5a11af2a126685effdae00","subject":"Played with collision tree building.","message":"Played with collision tree building.\n","repos":"kfprimm\/maxb3d,kfprimm\/maxb3d","old_file":"core.mod\/mesh.bmx","new_file":"core.mod\/mesh.bmx","new_contents":"\nStrict\n\nImport \"worldconfig.bmx\"\nImport \"entity.bmx\"\nImport \"surface.bmx\"\nImport \"bone.bmx\"\n\nImport MaxB3D.Logging\n\nPrivate\nFunction ModuleLog(message$)\n\tTMaxB3DLogger.Write \"core\/mesh\",message\nEnd Function\n\nPublic\n\nType TMesh Extends TAnimEntity \n\tField _surfaces:TSurface[]\n\n\tField _bone:TBone[]\n\t\n\tField _tree:Byte Ptr\n\tField _resettree\n\t\n\tField _width,_height,_depth,_updatebounds\n\tField _minx#,_miny#,_minz#,_maxx#,_maxy#,_maxz#\n\t\n\tMethod HasAlpha()\n\t\tIf Super.HasAlpha() Return True\n\t\tFor Local surface:TSurface=EachIn _surfaces\n\t\t\tIf surface.HasAlpha() Return True\n\t\tNext\n\tEnd Method\n\t\n\tMethod Lists[]()\n\t\tReturn Super.Lists()+[WORLDLIST_MESH, WORLDLIST_RENDER]\n\tEnd Method\n\t\n\tMethod CopyData:TEntity(entity:TEntity)\n\t\tLocal mesh:TMesh=TMesh(entity)\n\t\tFor Local surface:TSurface=EachIn mesh._surfaces\n\t\t\tAppendSurface surface\n\t\tNext\t\t\n\t\tReturn Super.CopyData(entity)\n\tEnd Method\n\t\n\tMethod Copy:TMesh(parent:TEntity=Null)\n\t\tReturn TMesh(Super.Copy_(parent))\n\tEnd Method\n\t\n\tMethod Clone:TMesh(parent:TEntity=Null)\n\t\tLocal mesh:TMesh=Copy(parent)\n\t\tFor Local i=0 To _surfaces.length-1\n\t\t\tmesh._surfaces[i] = _surfaces[i].Copy()\n\t\tNext\n\t\tReturn mesh\n\tEnd Method\n\t\n\tMethod Add(mesh:TMesh)\n\t\tFor Local surface:TSurface=EachIn mesh._surfaces\n\t\t\tLocal new_surface:TSurface=surface.Copy()\n\t\t\tnew_surface.SetBrush new_surface._brush.Merge(mesh._brush)\n\t\t\tAppendSurface new_surface\n\t\tNext\n\tEnd Method\n\t\n\tMethod AddSurface:TSurface(brush:TBrush=Null,vertices=0,triangles=0)\n\t\tLocal surface:TSurface=New TSurface\n\t\tsurface.SetBrush brush\n\t\tsurface.Resize vertices,triangles\n\t\tReturn AppendSurface(surface)\n\tEnd Method\n\t\n\tMethod AppendSurface:TSurface(surface:TSurface)\n\t\t_surfaces=_surfaces[.._surfaces.length+1]\n\t\t_surfaces[_surfaces.length-1]=surface\n\t\tsurface._boundsupdatedmsg.Add BoundsUpdated,Self\n\t\tReturn surface\n\tEnd Method\n\t\n\tMethod SwapSurface(surface:TSurface,new_surface:TSurface)\n\t\tFor Local i=0 To _surfaces.length-1\n\t\t\tIf _surfaces[i]=surface _surfaces[i]=new_surface\n\t\tNext\n\tEnd Method\n\t\n\tMethod GetSurface:TSurface(index)\n\t\tReturn _surfaces[index]\n\tEnd Method\n\t\n\tMethod CountSurfaces()\n\t\tReturn _surfaces.length\n\tEnd Method\n\t\n\tMethod UpdateBounds(force=False)\n\t\tFor Local surface:TSurface=EachIn _surfaces\t\t\n\t\t\tsurface.UpdateBounds force\n\t\tNext\n\t\tIf Not _updatebounds Return\n\t\t\n\t\t_minx=INFINITY;_miny=INFINITY;_minz=INFINITY\n\t\t_maxx=-INFINITY;_maxy=-INFINITY;_maxz=-INFINITY\n\t\t\n\t\tFor Local surface:TSurface=EachIn _surfaces\t\t\n\t\t\t_minx=Min(_minx,surface._minx);_maxx=Max(_maxx,surface._maxx)\n\t\t\t_miny=Min(_miny,surface._miny);_maxy=Max(_maxy,surface._maxy)\n\t\t\t_minz=Min(_minz,surface._minz);_maxz=Max(_maxz,surface._maxz)\n\t\tNext\n\t\t\n\t\t_width=_maxx-_minx;_height=_maxy-_miny;_depth=_maxz-_minz\n\t\tIf _cullradius>=0\n\t\t\tLocal radius#=Max(_width,Max(_height,_depth))\/2.0\n\t\t\tLocal radius_sqr#=radius*radius\n\t\t\t_cullradius=Sqr(radius_sqr+radius_sqr+radius_sqr)\n\t\tEndIf\n\t\t_updatebounds=False\n\tEnd Method\n\t\n\tFunction BoundsUpdated(entity:Object)\n\t\tTMesh(entity)._updatebounds=True\n\tEnd Function\n\t\n\tMethod GetSize(width# Var,height# Var,depth# Var)\n\t\tUpdateBounds\n\t\twidth=_width;height=_height;depth=_depth\n\tEnd Method\n\t\n\tMethod Fit(x#,y#,z#,width#,height#,depth#,uniform=False)\n\t\tUpdateBounds\n\t\t\n\t\tLocal wr#,hr#,dr#\n\t\twr=_width\/width;hr=_height\/height;dr=_depth\/depth\n\t\tIf uniform\t\t\t\n\t\t\tIf wr>=hr And wr>=dr\n\t\t\t\ty=y+((height-(_height\/wr))\/2.0)\n\t\t\t\tz=z+((depth-(_depth\/wr))\/2.0)\n\t\t\t\t\n\t\t\t\theight=_height\/wr\n\t\t\t\tdepth=_depth\/wr\n\t\t\tElseIf hr>dr\n\t\t\t\tx=x+((width-(_width\/hr))\/2.0)\n\t\t\t\tz=z+((depth-(_depth\/hr))\/2.0)\n\t\t\t\t\n\t\t\t\twidth=_width\/hr\n\t\t\t\tdepth=_depth\/hr\n\t\t\tElse\n\t\t\t\tx=x+((width-(_width\/dr))\/2.0)\n\t\t\t\ty=y+((height-(_height\/dr))\/2.0)\n\t\t\t\t\n\t\t\t\twidth=_width\/dr\n\t\t\t\theight=_height\/dr\n\t\t\tEndIf\n\t\tEndIf\n\t\twr=_width\/width;hr=_height\/height;dr=_depth\/depth\n\t\t\n\t\tFor Local surface:TSurface=EachIn _surfaces\n\t\t\tFor Local v=0 To surface._vertexcnt-1\n\t\t\t\tLocal vx#,vy#,vz#,nx#,ny#,nz#\n\t\t\t\tsurface.GetCoords v,vx,vy,vz\n\t\t\t\tsurface.GetNormal v,nx,ny,nz\n\t\t\t\t\n\t\t\t\tLocal ux#,uy#,uz#\n\t\t\t\t\n\t\t\t\tIf _width<0.0001 And _width>-0.0001 Then ux=0.0 Else ux=(vx-_minx)\/_width\n\t\t\t\tIf _height<0.0001 And _height>-0.0001 Then uy=0.0 Else uy=(vy-_miny)\/_height\n\t\t\t\tIf _depth<0.0001 And _depth>-0.0001 Then uz=0.0 Else uz=(vz-_minz)\/_depth\n\t\t\t\t\n\t\t\t\tsurface.SetCoords v,x+(ux*width),y+(uy*height),z+(uz*depth)\n\t\t\t\tsurface.SetNormal v,nx*wr,ny*hr,nz*dr\n\t\t\tNext\n\t\tNext\n\t\tUpdateBounds True\n\tEnd Method\n\n\tMethod Center()\n\t\tLocal w#,h#,d#\n\t\tGetSize w,h,d\n\t\tFit -w\/2.0,-h\/2.0,-d\/2.0,w,h,d\n\tEnd Method\n\t\n\tMethod Flip()\n\t\tFor Local surface:TSurface=EachIn _surfaces\n\t\t\tsurface.Flip()\n\t\tNext\n\tEnd Method\n\n\tMethod Unweld()\n\t\tFor Local surface:TSurface=EachIn _surfaces\n\t\t\tsurface.Unweld()\n\t\tNext\n\tEnd Method\n\t\n\tMethod GetCounts(vertices Var, triangles Var)\n\t\tvertices = 0\n\t\ttriangles = 0\n\t\tFor Local surface:TSurface=EachIn _surfaces\n\t\t\ttriangles:+surface._trianglecnt\n\t\t\tvertices:+surface._vertexcnt\n\t\tNext\n\tEnd Method\n\t\n\tMethod UpdateNormals(smoothing=True)\n\t\tFor Local surface:TSurface=EachIn _surfaces\n\t\t\tsurface.UpdateNormals(smoothing)\n\t\tNext\n\tEnd Method\n\t\n\tMethod Scale(x#,y#,z#)\n\t\tReturn Morph(TMatrix.Scale(x,y,z))\n\tEnd Method\n\t\n\tMethod Rotate(pitch#,yaw#,roll#)\n\t\tReturn Morph(TMatrix.YawPitchRoll(yaw,pitch,roll))\n\tEnd Method\n\t\n\tMethod Position(x#,y#,z#)\n\t\tReturn Morph(TMatrix.Translation(x#,y#,z#))\n\tEnd Method\n\t\n\tMethod Morph(matrix:TMatrix)\n\t\tFor Local surface:TSurface=EachIn _surfaces\n\t\t\tsurface.Transform matrix\n\t\tNext\n\tEnd Method\n\t\n\tMethod ForEachSurfaceDo(func(surface:TSurface,data:Object),data:Object=Null)\n\t\tFor Local surface:TSurface=EachIn _surfaces\n\t\t\tfunc surface,data\n\t\tNext\n\tEnd Method\n\t\n\tMethod TreeCheck:Byte Ptr()\n\t\tIf _resettree=True\n\t\t\tIf _tree<>Null C_DeleteColTree(_tree);_tree=Null\n\t\t\t_resettree=False\t\t\t\t\n\t\tEndIf\n\n\t\tIf _tree=Null\n\t\t\tLocal vertextotal,info:Byte Ptr=C_NewMeshInfo(),count\n\t\t\t\n\t\t\tFor Local surface:TSurface=EachIn _surfaces\n\t\t\t\tcount:+1\t\t\t\t\n\t\t\t\tLocal triangles[]=surface._triangle[..]\n\t\t\t\tLocal vertices#[]=surface._vertexpos[..]\n\t\t\t\t\t\t\t\t\t\t\n\t\t\t\tIf surface._trianglecnt<>0 And surface._vertexcnt<>0\n\t\t\t\t\tFor Local i=0 To surface._trianglecnt-1\n\t\t\t\t\t\ttriangles[i*3+0]:+vertextotal\n\t\t\t\t\t\ttriangles[i*3+1]:+vertextotal\n\t\t\t\t\t\ttriangles[i*3+2]:+vertextotal\n\t\t\t\t\t\t\n\t\t\t\t\t\tLocal old=triangles[i*3+0]\n\t\t\t\t\t\ttriangles[i*3+0]=triangles[i*3+2]\n\t\t\t\t\t\ttriangles[i*3+2]=old\n\t\t\t\t\tNext\n\t\t\t\t\t\n\t\t\t\t\tRem\n\n\t\t\t\t\t\n\t\t\t\t\tFor Local i=0 To surface._vertexcnt-1\n\t\t\t\t\t\tvertices[i*3+2]=-vertices[i*3+2]\n\t\t\t\t\tNext\n\n\t\t\t\t\tEnd Rem\n\t\t\t\t\t\n\n\t\t\t\t\t\n\t\t\t\t\tC_AddSurface(info,surface._trianglecnt,surface._vertexcnt,triangles,vertices,count)\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\tvertextotal:+surface._vertexcnt\t\t\t\t\n\t\t\t\tEndIf\t\n\t\t\tNext\n\n\t\t\t_tree=C_CreateColTree(info)\n\t\t\tC_DeleteMeshInfo(info)\n\t\tEndIf\n\t\tReturn _tree\n\tEnd Method\n\t\n\tMethod GetCullParams(x# Var,y# Var,z# Var,radius# Var)\t\t\n\t\tUpdateBounds\n\t\t\n\t\tx=_minx;y=_miny;z=_minz\n\t\tx=x+(_maxx-_minx)\/2.0\n\t\ty=y+(_maxy-_miny)\/2.0\n\t\tz=z+(_maxz-_minz)\/2.0\n\t\t\n\t\t_matrix.TransformVec3 x,y,z\n\t\t\n\t\tLocal sx#,sy#,sz#\n\t\tGetScale sx,sy,sz,True\n\t\t\n\t\tradius=GetCullRadius()\n\t\t\n\t\tLocal rx#=radius*sx,ry#=radius*sy,rz#=radius*sz\n\t\tradius=Max(Max(rx,ry),rz)\n\tEnd Method\n\t\n\tMethod ObjectEnumerator:TObjectArrayEnumerator()\n\t\tReturn New TObjectArrayEnumerator.Create(_surfaces)\n\tEnd Method\nEnd Type\n\n","old_contents":"\nStrict\n\nImport \"worldconfig.bmx\"\nImport \"entity.bmx\"\nImport \"surface.bmx\"\nImport \"bone.bmx\"\n\nImport MaxB3D.Logging\n\nPrivate\nFunction ModuleLog(message$)\n\tTMaxB3DLogger.Write \"core\/mesh\",message\nEnd Function\n\nPublic\n\nType TMesh Extends TAnimEntity \n\tField _surfaces:TSurface[]\n\n\tField _bone:TBone[]\n\t\n\tField _tree:Byte Ptr\n\tField _resettree\n\t\n\tField _width,_height,_depth,_updatebounds\n\tField _minx#,_miny#,_minz#,_maxx#,_maxy#,_maxz#\n\t\n\tMethod HasAlpha()\n\t\tIf Super.HasAlpha() Return True\n\t\tFor Local surface:TSurface=EachIn _surfaces\n\t\t\tIf surface.HasAlpha() Return True\n\t\tNext\n\tEnd Method\n\t\n\tMethod Lists[]()\n\t\tReturn Super.Lists()+[WORLDLIST_MESH, WORLDLIST_RENDER]\n\tEnd Method\n\t\n\tMethod CopyData:TEntity(entity:TEntity)\n\t\tLocal mesh:TMesh=TMesh(entity)\n\t\tFor Local surface:TSurface=EachIn mesh._surfaces\n\t\t\tAppendSurface surface\n\t\tNext\t\t\n\t\tReturn Super.CopyData(entity)\n\tEnd Method\n\t\n\tMethod Copy:TMesh(parent:TEntity=Null)\n\t\tReturn TMesh(Super.Copy_(parent))\n\tEnd Method\n\t\n\tMethod Clone:TMesh(parent:TEntity=Null)\n\t\tLocal mesh:TMesh=Copy(parent)\n\t\tFor Local i=0 To _surfaces.length-1\n\t\t\tmesh._surfaces[i] = _surfaces[i].Copy()\n\t\tNext\n\t\tReturn mesh\n\tEnd Method\n\t\n\tMethod Add(mesh:TMesh)\n\t\tFor Local surface:TSurface=EachIn mesh._surfaces\n\t\t\tLocal new_surface:TSurface=surface.Copy()\n\t\t\tnew_surface.SetBrush new_surface._brush.Merge(mesh._brush)\n\t\t\tAppendSurface new_surface\n\t\tNext\n\tEnd Method\n\t\n\tMethod AddSurface:TSurface(brush:TBrush=Null,vertices=0,triangles=0)\n\t\tLocal surface:TSurface=New TSurface\n\t\tsurface.SetBrush brush\n\t\tsurface.Resize vertices,triangles\n\t\tReturn AppendSurface(surface)\n\tEnd Method\n\t\n\tMethod AppendSurface:TSurface(surface:TSurface)\n\t\t_surfaces=_surfaces[.._surfaces.length+1]\n\t\t_surfaces[_surfaces.length-1]=surface\n\t\tsurface._boundsupdatedmsg.Add BoundsUpdated,Self\n\t\tReturn surface\n\tEnd Method\n\t\n\tMethod SwapSurface(surface:TSurface,new_surface:TSurface)\n\t\tFor Local i=0 To _surfaces.length-1\n\t\t\tIf _surfaces[i]=surface _surfaces[i]=new_surface\n\t\tNext\n\tEnd Method\n\t\n\tMethod GetSurface:TSurface(index)\n\t\tReturn _surfaces[index]\n\tEnd Method\n\t\n\tMethod CountSurfaces()\n\t\tReturn _surfaces.length\n\tEnd Method\n\t\n\tMethod UpdateBounds(force=False)\n\t\tFor Local surface:TSurface=EachIn _surfaces\t\t\n\t\t\tsurface.UpdateBounds force\n\t\tNext\n\t\tIf Not _updatebounds Return\n\t\t\n\t\t_minx=INFINITY;_miny=INFINITY;_minz=INFINITY\n\t\t_maxx=-INFINITY;_maxy=-INFINITY;_maxz=-INFINITY\n\t\t\n\t\tFor Local surface:TSurface=EachIn _surfaces\t\t\n\t\t\t_minx=Min(_minx,surface._minx);_maxx=Max(_maxx,surface._maxx)\n\t\t\t_miny=Min(_miny,surface._miny);_maxy=Max(_maxy,surface._maxy)\n\t\t\t_minz=Min(_minz,surface._minz);_maxz=Max(_maxz,surface._maxz)\n\t\tNext\n\t\t\n\t\t_width=_maxx-_minx;_height=_maxy-_miny;_depth=_maxz-_minz\n\t\tIf _cullradius>=0\n\t\t\tLocal radius#=Max(_width,Max(_height,_depth))\/2.0\n\t\t\tLocal radius_sqr#=radius*radius\n\t\t\t_cullradius=Sqr(radius_sqr+radius_sqr+radius_sqr)\n\t\tEndIf\n\t\t_updatebounds=False\n\tEnd Method\n\t\n\tFunction BoundsUpdated(entity:Object)\n\t\tTMesh(entity)._updatebounds=True\n\tEnd Function\n\t\n\tMethod GetSize(width# Var,height# Var,depth# Var)\n\t\tUpdateBounds\n\t\twidth=_width;height=_height;depth=_depth\n\tEnd Method\n\t\n\tMethod Fit(x#,y#,z#,width#,height#,depth#,uniform=False)\n\t\tUpdateBounds\n\t\t\n\t\tLocal wr#,hr#,dr#\n\t\twr=_width\/width;hr=_height\/height;dr=_depth\/depth\n\t\tIf uniform\t\t\t\n\t\t\tIf wr>=hr And wr>=dr\n\t\t\t\ty=y+((height-(_height\/wr))\/2.0)\n\t\t\t\tz=z+((depth-(_depth\/wr))\/2.0)\n\t\t\t\t\n\t\t\t\theight=_height\/wr\n\t\t\t\tdepth=_depth\/wr\n\t\t\tElseIf hr>dr\n\t\t\t\tx=x+((width-(_width\/hr))\/2.0)\n\t\t\t\tz=z+((depth-(_depth\/hr))\/2.0)\n\t\t\t\t\n\t\t\t\twidth=_width\/hr\n\t\t\t\tdepth=_depth\/hr\n\t\t\tElse\n\t\t\t\tx=x+((width-(_width\/dr))\/2.0)\n\t\t\t\ty=y+((height-(_height\/dr))\/2.0)\n\t\t\t\t\n\t\t\t\twidth=_width\/dr\n\t\t\t\theight=_height\/dr\n\t\t\tEndIf\n\t\tEndIf\n\t\twr=_width\/width;hr=_height\/height;dr=_depth\/depth\n\t\t\n\t\tFor Local surface:TSurface=EachIn _surfaces\n\t\t\tFor Local v=0 To surface._vertexcnt-1\n\t\t\t\tLocal vx#,vy#,vz#,nx#,ny#,nz#\n\t\t\t\tsurface.GetCoords v,vx,vy,vz\n\t\t\t\tsurface.GetNormal v,nx,ny,nz\n\t\t\t\t\n\t\t\t\tLocal ux#,uy#,uz#\n\t\t\t\t\n\t\t\t\tIf _width<0.0001 And _width>-0.0001 Then ux=0.0 Else ux=(vx-_minx)\/_width\n\t\t\t\tIf _height<0.0001 And _height>-0.0001 Then uy=0.0 Else uy=(vy-_miny)\/_height\n\t\t\t\tIf _depth<0.0001 And _depth>-0.0001 Then uz=0.0 Else uz=(vz-_minz)\/_depth\n\t\t\t\t\n\t\t\t\tsurface.SetCoords v,x+(ux*width),y+(uy*height),z+(uz*depth)\n\t\t\t\tsurface.SetNormal v,nx*wr,ny*hr,nz*dr\n\t\t\tNext\n\t\tNext\n\t\tUpdateBounds True\n\tEnd Method\n\n\tMethod Center()\n\t\tLocal w#,h#,d#\n\t\tGetSize w,h,d\n\t\tFit -w\/2.0,-h\/2.0,-d\/2.0,w,h,d\n\tEnd Method\n\t\n\tMethod Flip()\n\t\tFor Local surface:TSurface=EachIn _surfaces\n\t\t\tsurface.Flip()\n\t\tNext\n\tEnd Method\n\n\tMethod Unweld()\n\t\tFor Local surface:TSurface=EachIn _surfaces\n\t\t\tsurface.Unweld()\n\t\tNext\n\tEnd Method\n\t\n\tMethod GetCounts(vertices Var, triangles Var)\n\t\tvertices = 0\n\t\ttriangles = 0\n\t\tFor Local surface:TSurface=EachIn _surfaces\n\t\t\ttriangles:+surface._trianglecnt\n\t\t\tvertices:+surface._vertexcnt\n\t\tNext\n\tEnd Method\n\t\n\tMethod UpdateNormals(smoothing=True)\n\t\tFor Local surface:TSurface=EachIn _surfaces\n\t\t\tsurface.UpdateNormals(smoothing)\n\t\tNext\n\tEnd Method\n\t\n\tMethod Scale(x#,y#,z#)\n\t\tReturn Morph(TMatrix.Scale(x,y,z))\n\tEnd Method\n\t\n\tMethod Rotate(pitch#,yaw#,roll#)\n\t\tReturn Morph(TMatrix.YawPitchRoll(yaw,pitch,roll))\n\tEnd Method\n\t\n\tMethod Position(x#,y#,z#)\n\t\tReturn Morph(TMatrix.Translation(x#,y#,z#))\n\tEnd Method\n\t\n\tMethod Morph(matrix:TMatrix)\n\t\tFor Local surface:TSurface=EachIn _surfaces\n\t\t\tsurface.Transform matrix\n\t\tNext\n\tEnd Method\n\t\n\tMethod ForEachSurfaceDo(func(surface:TSurface,data:Object),data:Object=Null)\n\t\tFor Local surface:TSurface=EachIn _surfaces\n\t\t\tfunc surface,data\n\t\tNext\n\tEnd Method\n\t\n\tMethod TreeCheck:Byte Ptr()\n\t\tIf _resettree=True\n\t\t\tIf _tree<>Null C_DeleteColTree(_tree);_tree=Null\n\t\t\t_resettree=False\t\t\t\t\n\t\tEndIf\n\n\t\tIf _tree=Null\n\t\t\tLocal vertextotal,info:Byte Ptr=C_NewMeshInfo(),count\n\t\t\t\n\t\t\tFor Local surface:TSurface=EachIn _surfaces\n\t\t\t\tcount:+1\t\t\t\t\n\t\t\t\tLocal triangles[]=surface._triangle[..]\n\t\t\t\tLocal vertices:Float[]=surface._vertexpos[..]\n\t\t\t\t\t\t\t\t\t\t\n\t\t\t\tIf surface._trianglecnt<>0 And surface._vertexcnt<>0\n\t\t\t\t\tFor Local i=0 To surface._trianglecnt-1\n\t\t\t\t\t\ttriangles[i*3+0]:+vertextotal\n\t\t\t\t\t\ttriangles[i*3+1]:+vertextotal\n\t\t\t\t\t\ttriangles[i*3+2]:+vertextotal\n\t\t\t\t\tNext\n\t\t\t\t\n\t\t\t\t\tFor Local i=0 To surface._trianglecnt-1\n\t\t\t\t\t\tLocal old=triangles[i*3+0]\n\t\t\t\t\t\ttriangles[i*3+0]=triangles[i*3+2]\n\t\t\t\t\t\ttriangles[i*3+2]=old\n\t\t\t\t\tNext\n\t\t\t\t\t\n\t\t\t\t\tFor Local i=0 To surface._vertexcnt-1\n\t\t\t\t\t\tvertices[i*3+2]=-vertices[i*3+2]\n\t\t\t\t\tNext\n\t\t\n\t\t\t\t\tC_AddSurface(info,surface._trianglecnt,surface._vertexcnt,triangles,vertices,count)\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\tvertextotal:+surface._vertexcnt\t\t\t\t\n\t\t\t\tEndIf\t\n\t\t\tNext\n\n\t\t\t_tree=C_CreateColTree(info)\n\t\t\tC_DeleteMeshInfo(info)\n\t\tEndIf\n\t\tReturn _tree\n\tEnd Method\n\t\n\tMethod GetCullParams(x# Var,y# Var,z# Var,radius# Var)\t\t\n\t\tUpdateBounds\n\t\t\n\t\tx=_minx;y=_miny;z=_minz\n\t\tx=x+(_maxx-_minx)\/2.0\n\t\ty=y+(_maxy-_miny)\/2.0\n\t\tz=z+(_maxz-_minz)\/2.0\n\t\t\n\t\t_matrix.TransformVec3 x,y,z\n\t\t\n\t\tLocal sx#,sy#,sz#\n\t\tGetScale sx,sy,sz,True\n\t\t\n\t\tradius=GetCullRadius()\n\t\t\n\t\tLocal rx#=radius*sx,ry#=radius*sy,rz#=radius*sz\n\t\tradius=Max(Max(rx,ry),rz)\n\tEnd Method\n\t\n\tMethod ObjectEnumerator:TObjectArrayEnumerator()\n\t\tReturn New TObjectArrayEnumerator.Create(_surfaces)\n\tEnd Method\nEnd Type\n\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"5c4da02d0058f6a4cc1fc2d887e7e5b5e459e298","subject":"Documentation correction","message":"Documentation correction\n","repos":"Htbaa\/xmlrpc.mod,Htbaa\/xmlrpc.mod,Htbaa\/xmlrpc.mod,Htbaa\/xmlrpc.mod,Htbaa\/xmlrpc.mod","old_file":"server.bmx","new_file":"server.bmx","new_contents":"Rem\n\tbbdoc: Exception for TXMLRPC_Server\nEnd Rem\nType TXMLRPC_Server_Exception Extends TXMLRPC_Exception\nEnd Type\n\nRem\n\tbbdoc: XML-RPC Server\n\tabout: This type will allow you to create an XML-RPC server.\nEnd Rem\nType TXMLRPC_Server\n\n\tField server:Byte Ptr\n\n\tRem\n\t\tbbdoc: Creates a new XML-RPC server\n\t\tabout: After calling the constructor you might want to use RegisterMethod() to add methods to the server\n\tEnd Rem\n\tMethod New()\n\t\tSelf.server = XMLRPC_ServerCreate()\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Call this method when your done with the server\n\tEnd Rem\n\tMethod Shutdown()\n\t\tIf Self.server\n\t\t\tXMLRPC_ServerDestroy(Self.server)\n\t\tEnd If\n\tEnd Method\n\n\tRem\n\t\tbbdoc: Handles an request\n\t\tabout: Will process the xmlMessage and returns a TXMLRPC_Response_Data object containing the returned values by the callback function\n\tEnd Rem\n\tMethod HandleInput:TXMLRPC_Response_Data(xmlMessage:String)\n\t\tLocal xmlRequest:Byte Ptr = xmlMessage.ToCString()\n\t\t'Create XMLRPC_REQUEST object from given xmlMessage\n\t\tLocal request:Byte Ptr = XMLRPC_REQUEST_FromXML(xmlRequest, Null, Null)\n\t\tMemFree(xmlRequest)\n\t\t\n\t\t'Create response\n\t\tLocal response:Byte Ptr = XMLRPC_RequestNew()\n\t\tXMLRPC_RequestSetRequestType(response, xmlrpc_request_response)\n\t\t'Set response data by calling the callback function\n\t\tXMLRPC_RequestSetData(response, XMLRPC_ServerCallMethod(Self.server, request, Null))\n\t\t'Copy output options from request\n\t\tXMLRPC_RequestSetOutputOptions(response, XMLRPC_RequestGetOutputOptions(request))\n\t\t\n\t\t'Convert response to XML message\n\t\tLocal xmlResponse:Byte Ptr = XMLRPC_REQUEST_ToXML(response, Null)\n\t\t'Create workable response data out of it\n\t\tLocal responseData:TXMLRPC_Response_Data = New TXMLRPC_Response_Data.Create(convertUTF8toISO8859(xmlResponse), XMLRPC_RequestGetOutputOptions(response))\n\t\tXMLRPC_Free(xmlResponse)\n\t\t\n\t\tXMLRPC_RequestFree(request, 1)\n\t\tXMLRPC_RequestFree(response, 1)\n\t\t\n\t\tReturn responseData\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Register a function to the XML-RPC server\n\t\tabout: functionName will be the identifier. callBack is a pointer to a function\n\tEnd Rem\n\tMethod RegisterMethod(functionName:String, callBack:Byte Ptr)\n\t\tLocal cStr:Byte Ptr = functionName.ToCString()\n\t\tXMLRPC_ServerRegisterMethod(Self.server, cStr, callBack)\n\t\tMemFree(cStr)\n\tEnd Method\nEnd Type\n","old_contents":"Rem\n\tbbdoc: Exception for TXMLRPC_Server\nEnd Rem\nType TXMLRPC_Server_Exception Extends TXMLRPC_Exception\nEnd Type\n\nRem\n\tbbdoc: XML-RPC Server\n\tabout: This type will allow you to create an XML-RPC server.\nEnd Rem\nType TXMLRPC_Server\n\n\tField server:Byte Ptr\n\n\tRem\n\t\tbbdoc: Creates a new XML-RPC server\n\t\tabout: After calling the constructor you might want to use RegisterMethod() to add methods to the server\n\tEnd Rem\n\tMethod New()\n\t\tSelf.server = XMLRPC_ServerCreate()\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Call this method when your done with the server\n\tEnd Rem\n\tMethod Shutdown()\n\t\tIf Self.server\n\t\t\tXMLRPC_ServerDestroy(Self.server)\n\t\tEnd If\n\tEnd Method\n\n\tRem\n\t\tbbdoc: Handles an incoming message\n\t\tabout: Will try to execute the method set in the methodName field, and returns a TXMLRPC_Response_Data object containing the returned values\n\tEnd Rem\n\tMethod HandleInput:TXMLRPC_Response_Data(xmlMessage:String)\n\t\tLocal xmlRequest:Byte Ptr = xmlMessage.ToCString()\n\t\t'Create XMLRPC_REQUEST object from given xmlMessage\n\t\tLocal request:Byte Ptr = XMLRPC_REQUEST_FromXML(xmlRequest, Null, Null)\n\t\tMemFree(xmlRequest)\n\t\t\n\t\t'Create response\n\t\tLocal response:Byte Ptr = XMLRPC_RequestNew()\n\t\tXMLRPC_RequestSetRequestType(response, xmlrpc_request_response)\n\t\t'Set response data by calling the callback function\n\t\tXMLRPC_RequestSetData(response, XMLRPC_ServerCallMethod(Self.server, request, Null))\n\t\t'Copy output options from request\n\t\tXMLRPC_RequestSetOutputOptions(response, XMLRPC_RequestGetOutputOptions(request))\n\t\t\n\t\t'Convert response to XML message\n\t\tLocal xmlResponse:Byte Ptr = XMLRPC_REQUEST_ToXML(response, Null)\n\t\t'Create workable response data out of it\n\t\tLocal responseData:TXMLRPC_Response_Data = New TXMLRPC_Response_Data.Create(convertUTF8toISO8859(xmlResponse), XMLRPC_RequestGetOutputOptions(response))\n\t\tXMLRPC_Free(xmlResponse)\n\t\t\n\t\tXMLRPC_RequestFree(request, 1)\n\t\tXMLRPC_RequestFree(response, 1)\n\t\t\n\t\tReturn responseData\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Register a function to the XML-RPC server\n\t\tabout: functionName will be the identifier. callBack is a pointer to a function\n\tEnd Rem\n\tMethod RegisterMethod(functionName:String, callBack:Byte Ptr)\n\t\tLocal cStr:Byte Ptr = functionName.ToCString()\n\t\tXMLRPC_ServerRegisterMethod(Self.server, cStr, callBack)\n\t\tMemFree(cStr)\n\tEnd Method\nEnd Type\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"0219f15b6804ff97f1e8061f6f608ecbf3f8bf76","subject":"changed current to curr.","message":"changed current to curr.\n","repos":"kfprimm\/maxb3d,kfprimm\/maxb3d","old_file":"doc\/samples\/kfprimm\/new-primitives.bmx","new_file":"doc\/samples\/kfprimm\/new-primitives.bmx","new_contents":"\nStrict\n\nImport MaxB3D.Drivers\nImport MaxB3D.Loaders\n\nGraphics 800,600\n\nLocal light:TLight = CreateLight()\n\nLocal camera:TCamera = CreateCamera()\nSetEntityPosition camera,0,0,-3\n\nGlobal primitives:TMesh[3]\n\nprimitives[0] = CreateBunny()\nSetEntityName primitives[0], \"Stanford Bunny\"\nSetEntityScale primitives[0], 2,2,2\n\nprimitives[1] = CreateMonkeyHead()\nSetEntityName primitives[1], \"Suzanne (Blender Monkey)\"\n\nprimitives[2] = CreateTeapot()\nSetEntityName primitives[2], \"Utah Teapot\"\n\nLocal curr\n\nWhile Not KeyDown(KEY_ESCAPE) And Not AppTerminate()\n\tFor Local i = 0 To 9\n\t\tIf KeyHit(KEY_0 + i)\n\t\t\tcurr = i\n\t\t\tExit\n\t\tEndIf\n\tNext\n\t\n\tIf KeyHit(KEY_UP) Or KeyHit(KEY_LEFT) curr :- 1\n\tIf KeyHit(KEY_DOWN) Or KeyHit(KEY_RIGHT) curr :+ 1\n\t\n\tIf curr > primitives.length -1 curr = 0\n\tIf curr < 0 curr = primitives.length - 1 \n\t\n\tFor Local i = 0 To primitives.length-1 \n\t\tSetEntityVisible primitives[i], curr = i\n\tNext\n\t\n\tTurnEntity primitives[curr],0,1,0\n\t\n\tSetWireFrame KeyDown(KEY_W)\n\t\n\tRenderWorld\n\tDoMax2D\n\tDrawText \"Press 1, 2, or 3 to select a particular meshes.\",0,0\n\tDrawText \"Press Up\/Left or Down\/Right to cycle through meshes.\",0,15\n\tDrawText \"Current mesh: \"+GetEntityName(primitives[curr]),0,30\n\t\n\tFlip\nWend\n\n","old_contents":"\nStrict\n\nImport MaxB3D.Drivers\nImport MaxB3D.Loaders\n\nGraphics 800,600\n\nLocal light:TLight = CreateLight()\n\nLocal camera:TCamera = CreateCamera()\nSetEntityPosition camera,0,0,-3\n\nGlobal primitives:TMesh[3]\n\nprimitives[0] = CreateBunny()\nSetEntityName primitives[0], \"Stanford Bunny\"\nSetEntityScale primitives[0], 2,2,2\n\nprimitives[1] = CreateMonkeyHead()\nSetEntityName primitives[1], \"Suzanne (Blender Monkey)\"\n\nprimitives[2] = CreateTeapot()\nSetEntityName primitives[2], \"Utah Teapot\"\n\nLocal current\n\nWhile Not KeyDown(KEY_ESCAPE) And Not AppTerminate()\n\tFor Local i = 0 to 9\n\t\tIf KeyHit(KEY_0 + i)\n\t\t\tcurrent = i\n\t\t\tExit\n\t\tEndIf\n\tNext\n\t\n\tIf KeyHit(KEY_UP) Or KeyHit(KEY_LEFT) current :- 1\n\tIf KeyHit(KEY_DOWN) Or KeyHit(KEY_RIGHT) current :+ 1\n\t\n\tIf current > primitives.length -1 current = 0\n\tIf current < 0 current = primitives.length - 1 \n\t\n\tFor Local i = 0 To primitives.length-1 \n\t\tSetEntityVisible primitives[i], current = i\n\tNext\n\t\n\tTurnEntity primitives[current],0,1,0\n\t\n\tSetWireFrame KeyDown(KEY_W)\n\t\n\tRenderWorld\n\tDoMax2D\n\tDrawText \"Press 1, 2, or 3 to select a particular meshes.\",0,0\n\tDrawText \"Press Up\/Left or Down\/Right to cycle through meshes.\",0,15\n\tDrawText \"Current mesh: \"+GetEntityName(primitives[current]),0,30\n\t\n\tFlip\nWend\n\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"542935e3748349d483aa00884c3e33ed6fa4b8f4","subject":"small fix","message":"small fix\n","repos":"kfprimm\/maxb3d,kfprimm\/maxb3d","old_file":"b3dloader.mod\/b3dloader.bmx","new_file":"b3dloader.mod\/b3dloader.bmx","new_contents":"\nStrict\n\nRem\n\tbbdoc: Blitz3D model loader for MaxB3D\nEnd Rem\nModule MaxB3D.B3DLoader\nModuleInfo \"Author: Kevin Primm\"\nModuleInfo \"License: MIT\"\n\nImport MaxB3D.Core\nImport MaxB3D.BoneAnimator\nImport Prime.libB3D\n\nType TMeshLoaderB3D Extends TMeshLoader\n\tField _mesh:TMesh\n\t\n\tMethod Run(mesh:TMesh,stream:TStream,url:Object)\n\t\tLocal model:TBB3DChunk=TBB3DChunk.Load(url)\n\t\tIf model=Null Return False\t\n\t\t\n\t\tLocal olddir$=CurrentDir()\n\t\tIf String(url) ChangeDir(ExtractDir(String(url)))\n\t\t\n\t\tLocal texture:TTexture[model.texs.length]\n\t\tLocal brush:TBrush[model.brus.length]\n\t\t\n\t\tFor Local i=0 To texture.length-1\n\t\t\tLocal chunk:TTEXSChunk=model.texs[i]\t\t\t\n\t\t\ttexture[i]=_currentworld.AddTexture(chunk.file,chunk.flags)\n\t\t\tIf texture[i]\n\t\t\t\ttexture[i].SetBlend chunk.blend\n\t\t\t\ttexture[i].SetPosition chunk.x_pos,chunk.y_pos\n\t\t\t\ttexture[i].SetScale chunk.x_scale,chunk.y_scale\n\t\t\t\ttexture[i].SetRotation chunk.rotation*(180.0\/Pi)\n\t\t\t\tIf chunk.flags&65536 texture[i].SetCoords 1\n\t\t\tEndIf\n\t\tNext\n\t\t\n\t\tFor Local i=0 To brush.length-1\n\t\t\tLocal chunk:TBRUSChunk=model.brus[i]\n\t\t\tbrush[i]=_currentworld.AddBrush()\n\t\t\tbrush[i].SetName chunk.name\n\t\t\tbrush[i].SetColor chunk.red*255,chunk.green*255,chunk.blue*255;brush[i].SetAlpha chunk.alpha\n\t\t\tbrush[i].SetShine chunk.shininess\n\t\t\tbrush[i].SetBlend chunk.blend;brush[i].SetFX chunk.fx\n\t\t\tFor Local j=0 To chunk.n_texs-1\n\t\t\t\tIf chunk.texture_id[j]>-1 brush[i].SetTexture texture[chunk.texture_id[j]],j\n\t\t\tNext\n\t\tNext\t\t\n\t\tChangeDir olddir\n\t\t\n\t\t' model.dump StandardIOStream\n\t\t \n\t\tIf model.node\n\t\t\tParseNode model.node,mesh,brush,mesh\n\t\t\tReturn True\n\t\tEndIf\n\t\tReturn False\n\tEnd Method\n\t\n\tMethod ParseNode(node:TNODEChunk,parent:TEntity,brush:TBrush[],entity:TEntity=Null)\n\t\tLocal meshchunk:TMESHChunk=TMESHChunk(node.kind),bonechunk:TBONEChunk=TBONEChunk(node.kind)\n\t\t\t\t\n\t\tSelect node.kind\n\t\tCase Null\n\t\t\tentity=_currentworld.AddPivot(parent)\n\t\tCase meshchunk\t\t\t\n\t\t\tIf entity=Null entity=_currentworld.AddMesh(\"\/\/empty\",parent)\n\t\t\tLocal mesh:TMesh=TMesh(entity)\n\t\t\tmesh._animator=New TBoneAnimator\n\t\t\t_mesh=mesh\n\t\t\t\n\t\t\tIf meshchunk.brush_id>-1 entity.SetBrush brush[meshchunk.brush_id]\n\t\t\t\n\t\t\tLocal vrts:TVRTSChunk=meshchunk.vrts\n\t\t\tLocal vertsurface:TSurface=New TSurface\n\t\t\tvertsurface.Resize(vrts.xyz.length\/3,0)\n\t\t\t\n\t\t\tFor Local i=0 To vertsurface.CountVertices()-1\n\t\t\t\tvertsurface.SetCoords i,vrts.xyz[i*3+0],vrts.xyz[i*3+1],vrts.xyz[i*3+2]\n\t\t\t\tIf vrts.nxyz vertsurface.SetNormal i,vrts.nxyz[i*3+0],vrts.nxyz[i*3+1],vrts.nxyz[i*3+2]\n\t\t\t\tIf vrts.rgba vertsurface.SetColor i,vrts.rgba[i*4+0]*255,vrts.rgba[i*4+1]*255,vrts.rgba[i*4+2]*255,vrts.rgba[i*4+3]\n\t\t\t\tIf vrts.SetSize()>1 \n\t\t\t\t\tFor Local j=0 To vrts.SetCount()-1\n\t\t\t\t\t\tvertsurface.SetTexCoords i,1-vrts.tex_coords[i][j,0],vrts.tex_coords[i][j,1],j\n\t\t\t\t\tNext\n\t\t\t\tEndIf\n\t\t\tNext\n\t\t\t\n\t\t\tFor Local i=0 To meshchunk.tris.length-1\n\t\t\t\tLocal tri:TTRISChunk=meshchunk.tris[i]\n\t\t\t\tLocal surface:TSurface=vertsurface.Copy()\n\t\t\t\tsurface.Resize(-1,tri.vertex_id.length\/3)\n\t\t\t\tIf tri.brush_id>-1 surface.SetBrush brush[tri.brush_id]\n\t\t\t\tFor Local t=0 To surface.CountTriangles()-1\n\t\t\t\t\tsurface.SetTriangle t,tri.vertex_id[t*3+0],tri.vertex_id[t*3+1],tri.vertex_id[t*3+2]\n\t\t\t\tNext\n\t\t\t\tIf vrts.nxyz=Null surface.UpdateNormals\t\t\t\n\t\t\t\tmesh.AppendSurface surface\n\t\t\tNext\n\t\tCase bonechunk\n\t\t\tentity=_currentworld.AddBone(parent)\n\t\t\tLocal bone:TBone=TBone(entity)\n\t\t\t\n\t\t\tFor Local surface:TSurface=EachIn _mesh._surfaces\n\t\t\t\tbone.AddSurface surface\n\t\t\t\tFor Local i=0 To bonechunk.vertex_id.length-1\n\t\t\t\t\tbone.AddVertex surface,bonechunk.vertex_id[i],bonechunk.weight[i]\n\t\t\t\tNext\n\t\t\tNext\t\t\t\n\t\t\t\n\t\t\tLocal ident_matrix:TMatrix=TMatrix.Identity()\n\t\t\tFor Local chunk:TKEYSChunk=EachIn node.keys\n\t\t\t\tLocal keys:TAnimKey[chunk.frame.length]\n\t\t\t\tLocal pos#[]=chunk.position,rot#[]=chunk.rotation,scl#[]=chunk.scale\n\t\t\t\tFor Local i=0 To chunk.frame.length-1\n\t\t\t\t\tLocal bonekey:TBoneKey=New TBoneKey\n\t\t\t\t\t\n\t\t\t\t\tIf pos.length>0 bonekey._px=pos[i*3+0];bonekey._py=pos[i*3+1];bonekey._pz=pos[i*3+2]\n\t\t\t\t\tIf rot.length>0 bonekey._rw=rot[i*4+0];bonekey._rx=rot[i*4+1];bonekey._ry=rot[i*4+2];bonekey._rz=rot[i*4+3]\n\t\t\t\t\tIf scl.length>0 bonekey._sx=scl[i*3+0];bonekey._sy=scl[i*3+1];bonekey._sz=scl[i*3+2]\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\tLocal key:TAnimKey=New TAnimKey\n\t\t\t\t\tkey._frame=chunk.frame[i]\n\t\t\t\t\tkey._object=bonekey\n\t\t\t\t\tkeys[i]=key\n\t\t\t\tNext\n\t\t\t\tTBoneAnimator(_mesh._animator).AddBone bone,keys\n\t\t\tNext\n\t\tDefault\n\t\t\tentity=_currentworld.AddPivot(parent)\n\t\tEnd Select\t\t\n\t\t\n\t\tentity.SetName node.name\n\t\tentity.SetPosition node.position[0],node.position[1],node.position[2]\n\t\tLocal pitch#,yaw#,roll#\n\t\tTQuaternion.Euler node.rotation[0],node.rotation[1],node.rotation[2],node.rotation[3],pitch,yaw,roll\n\t\tentity.SetRotation pitch,yaw,roll\n\t\tentity.SetScale node.scale[0],node.scale[1],node.scale[2]\n\t\t\n\t\tFor Local child:TNODEChunk=EachIn node.node\n\t\t\tParseNode child,entity,brush\n\t\tNext\n\t\tIf TMesh(entity) If TBoneAnimator(TMesh(entity)._animator)._root=Null TMesh(entity)._animator=Null\n\t\tIf TBone(entity) TBone(entity)._start_matrix=entity.GetMatrix()\n\tEnd Method\n\t\n\tMethod Info$()\n\t\tReturn \"Blitz3D|b3d\"\n\tEnd Method\n\tMethod ModuleName$()\n\t\tReturn \"b3dloader\"\n\tEnd Method\nEnd Type\nNew TMeshLoaderB3D\n","old_contents":"\nStrict\n\nRem\n\tbbdoc: Blitz3D model loader for MaxB3D\nEnd Rem\nModule MaxB3D.B3DLoader\nModuleInfo \"Author: Kevin Primm\"\nModuleInfo \"License: MIT\"\n\nImport MaxB3D.Core\nImport MaxB3D.BoneAnimator\nImport Prime.libB3D\n\nType TMeshLoaderB3D Extends TMeshLoader\n\tField _mesh:TMesh\n\t\n\tMethod Run(mesh:TMesh,stream:TStream,url:Object)\n\t\tLocal model:TBB3DChunk=TBB3DChunk.Load(url)\n\t\tIf model=Null Return False\t\n\t\t\n\t\tLocal olddir$=CurrentDir()\n\t\tIf String(url) ChangeDir(ExtractDir(String(url)))\n\t\t\n\t\tLocal texture:TTexture[model.texs.length]\n\t\tLocal brush:TBrush[model.brus.length]\n\t\t\n\t\tFor Local i=0 To texture.length-1\n\t\t\tLocal chunk:TTEXSChunk=model.texs[i]\t\t\t\n\t\t\ttexture[i]=_currentworld.AddTexture(chunk.file,chunk.flags)\n\t\t\tIf texture[i]\n\t\t\t\ttexture[i].SetBlend chunk.blend\n\t\t\t\ttexture[i].SetPosition chunk.x_pos,chunk.y_pos\n\t\t\t\ttexture[i].SetScale chunk.x_scale,chunk.y_scale\n\t\t\t\ttexture[i].SetRotation chunk.rotation*(180.0\/Pi)\n\t\t\t\tIf chunk.flags&65536 texture[i].SetCoords 1\n\t\t\tEndIf\n\t\tNext\n\t\t\n\t\tFor Local i=0 To brush.length-1\n\t\t\tLocal chunk:TBRUSChunk=model.brus[i]\n\t\t\tbrush[i]=_currentworld.AddBrush()\n\t\t\tbrush[i].SetName chunk.name\n\t\t\tbrush[i].SetColor chunk.red*255,chunk.green*255,chunk.blue*255;brush[i].SetAlpha chunk.alpha\n\t\t\tbrush[i].SetShine chunk.shininess\n\t\t\tbrush[i].SetBlend chunk.blend;brush[i].SetFX chunk.fx\n\t\t\tFor Local j=0 To chunk.n_texs-1\n\t\t\t\tIf chunk.texture_id[j]>-1 brush[i].SetTexture texture[chunk.texture_id[j]],j\n\t\t\tNext\n\t\tNext\t\t\n\t\tChangeDir olddir\n\t\t\n\t\t' model.dump StandardIOStream\n\t\t \n\t\tIf model.node\n\t\t\tParseNode model.node,mesh,brush,mesh\n\t\t\tReturn True\n\t\tEndIf\n\t\tReturn False\n\tEnd Method\n\t\n\tMethod ParseNode(node:TNODEChunk,parent:TEntity,brush:TBrush[],entity:TEntity=Null)\n\t\tLocal meshchunk:TMESHChunk=TMESHChunk(node.kind),bonechunk:TBONEChunk=TBONEChunk(node.kind)\n\t\t\t\t\n\t\tSelect node.kind\n\t\tCase Null\n\t\t\tentity=_currentworld.AddPivot(parent)\n\t\tCase meshchunk\t\t\t\n\t\t\tIf entity=Null entity=_currentworld.AddMesh(\"*empty*\",parent)\n\t\t\tLocal mesh:TMesh=TMesh(entity)\n\t\t\tmesh._animator=New TBoneAnimator\n\t\t\t_mesh=mesh\n\t\t\t\n\t\t\tIf meshchunk.brush_id>-1 entity.SetBrush brush[meshchunk.brush_id]\n\t\t\t\n\t\t\tLocal vrts:TVRTSChunk=meshchunk.vrts\n\t\t\tLocal vertsurface:TSurface=New TSurface\n\t\t\tvertsurface.Resize(vrts.xyz.length\/3,0)\n\t\t\t\n\t\t\tFor Local i=0 To vertsurface.CountVertices()-1\n\t\t\t\tvertsurface.SetCoords i,vrts.xyz[i*3+0],vrts.xyz[i*3+1],vrts.xyz[i*3+2]\n\t\t\t\tIf vrts.nxyz vertsurface.SetNormal i,vrts.nxyz[i*3+0],vrts.nxyz[i*3+1],vrts.nxyz[i*3+2]\n\t\t\t\tIf vrts.rgba vertsurface.SetColor i,vrts.rgba[i*4+0]*255,vrts.rgba[i*4+1]*255,vrts.rgba[i*4+2]*255,vrts.rgba[i*4+3]\n\t\t\t\tIf vrts.SetSize()>1 \n\t\t\t\t\tFor Local j=0 To vrts.SetCount()-1\n\t\t\t\t\t\tvertsurface.SetTexCoords i,1-vrts.tex_coords[i][j,0],vrts.tex_coords[i][j,1],j\n\t\t\t\t\tNext\n\t\t\t\tEndIf\n\t\t\tNext\n\t\t\t\n\t\t\tFor Local i=0 To meshchunk.tris.length-1\n\t\t\t\tLocal tri:TTRISChunk=meshchunk.tris[i]\n\t\t\t\tLocal surface:TSurface=vertsurface.Copy()\n\t\t\t\tsurface.Resize(-1,tri.vertex_id.length\/3)\n\t\t\t\tIf tri.brush_id>-1 surface.SetBrush brush[tri.brush_id]\n\t\t\t\tFor Local t=0 To surface.CountTriangles()-1\n\t\t\t\t\tsurface.SetTriangle t,tri.vertex_id[t*3+0],tri.vertex_id[t*3+1],tri.vertex_id[t*3+2]\n\t\t\t\tNext\n\t\t\t\tIf vrts.nxyz=Null surface.UpdateNormals\t\t\t\n\t\t\t\tmesh.AppendSurface surface\n\t\t\tNext\n\t\tCase bonechunk\n\t\t\tentity=_currentworld.AddBone(parent)\n\t\t\tLocal bone:TBone=TBone(entity)\n\t\t\t\n\t\t\tFor Local surface:TSurface=EachIn _mesh._surfaces\n\t\t\t\tbone.AddSurface surface\n\t\t\t\tFor Local i=0 To bonechunk.vertex_id.length-1\n\t\t\t\t\tbone.AddVertex surface,bonechunk.vertex_id[i],bonechunk.weight[i]\n\t\t\t\tNext\n\t\t\tNext\t\t\t\n\t\t\t\n\t\t\tLocal ident_matrix:TMatrix=TMatrix.Identity()\n\t\t\tFor Local chunk:TKEYSChunk=EachIn node.keys\n\t\t\t\tLocal keys:TAnimKey[chunk.frame.length]\n\t\t\t\tLocal pos#[]=chunk.position,rot#[]=chunk.rotation,scl#[]=chunk.scale\n\t\t\t\tFor Local i=0 To chunk.frame.length-1\n\t\t\t\t\tLocal bonekey:TBoneKey=New TBoneKey\n\t\t\t\t\t\n\t\t\t\t\tIf pos.length>0 bonekey._px=pos[i*3+0];bonekey._py=pos[i*3+1];bonekey._pz=pos[i*3+2]\n\t\t\t\t\tIf rot.length>0 bonekey._rw=rot[i*4+0];bonekey._rx=rot[i*4+1];bonekey._ry=rot[i*4+2];bonekey._rz=rot[i*4+3]\n\t\t\t\t\tIf scl.length>0 bonekey._sx=scl[i*3+0];bonekey._sy=scl[i*3+1];bonekey._sz=scl[i*3+2]\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\tLocal key:TAnimKey=New TAnimKey\n\t\t\t\t\tkey._frame=chunk.frame[i]\n\t\t\t\t\tkey._object=bonekey\n\t\t\t\t\tkeys[i]=key\n\t\t\t\tNext\n\t\t\t\tTBoneAnimator(_mesh._animator).AddBone bone,keys\n\t\t\tNext\n\t\tDefault\n\t\t\tentity=_currentworld.AddPivot(parent)\n\t\tEnd Select\t\t\n\t\t\n\t\tentity.SetName node.name\n\t\tentity.SetPosition node.position[0],node.position[1],node.position[2]\n\t\tLocal pitch#,yaw#,roll#\n\t\tTQuaternion.Euler node.rotation[0],node.rotation[1],node.rotation[2],node.rotation[3],pitch,yaw,roll\n\t\tentity.SetRotation pitch,yaw,roll\n\t\tentity.SetScale node.scale[0],node.scale[1],node.scale[2]\n\t\t\n\t\tFor Local child:TNODEChunk=EachIn node.node\n\t\t\tParseNode child,entity,brush\n\t\tNext\n\t\tIf TMesh(entity) If TBoneAnimator(TMesh(entity)._animator)._root=Null TMesh(entity)._animator=Null\n\t\tIf TBone(entity) TBone(entity)._start_matrix=entity.GetMatrix()\n\tEnd Method\n\t\n\tMethod Info$()\n\t\tReturn \"Blitz3D|b3d\"\n\tEnd Method\n\tMethod ModuleName$()\n\t\tReturn \"b3dloader\"\n\tEnd Method\nEnd Type\nNew TMeshLoaderB3D\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"9b7e57a9a35932c48f0c4991d62bafe3bf442c84","subject":"added boxtags for convenience","message":"added boxtags for convenience\n","repos":"Leushenko\/blue-moon","old_file":"blueallocator.bmx","new_file":"blueallocator.bmx","new_contents":"\n' Blue Moon\n' Memory allocator\/garbage collector\n' this is a generational three-colour mark\/compact collector\n\n' notes:\n\n' - a basic Lua value is represented as a NaN-box (i.e. a double, unless it's a NaN in which case there's a pointer in the significand)\n\n' - objects are allocated in newSpc, Cheney'd over to cpySpc when it runs out; the Eden spaces are 8MB each\n' - when less than .edenThreshold remains in cpySpc after a scavenge, objects held from oldSpc are promoted\n' - when more than .sizeThreshold has been promoted or less than .edenThreshold still remains, a full GC runs\n' this scan updates usage statistics for each page\n' the \"worst\" N pages are then compacted; if total usage is still poor, mark for another compact after next scavenge\n' the rest of Eden is then promoted\n' - fallback to compacting in one go if usage is catastrophic\/increments aren't keeping up\n' - roots are obtained from the gcroots list, and the stack\n\n' - before compacting\/discarding, the space is scanned for objects with finalizers which are resurrected into newSpc and put on toFinalize\n' - during a FULL collection, weak tables are listed in .weakTables rather than colouring elems, then weakscanned before compaction\n\n' - the stack is an 8M block with the last page protected\n' - stack frames use this format:\n' [ ret ip ][ prev base ][[ 16b frame sz ][ 16b var ofs ]][ func obj ][ ip ][ argv ][ retv ][[ 16b argc ][ 16b retc ]][ upv0 | upv1 | ... ][ v0 | v1 | ... ][ tmp... ]\n' the upvar slots, var slots, and temp slots beyond are all 64-bit NaN-boxes\n' the preceding slots are 32-bit words except otherwise shown\n\n' - pages in oldPtrSpc use this format:\n' [[[ 0..256 metadata ] ..16K dirty bitmap ] ..1M allocated objects ]\n' each 64-byte potential NaN-box in the object-space has a corresponding dirty bit that is set if it points to newSpc\n' a metamap in the metadata in turn marks dirty sectors of the bitmap, for reduced scanning\n' metadata also contains allocation pointer and used space total\n\n' - codeSpace stores executable instruction buffers for Lua functions (bytecode is allocated directly into oldStrSpc)\n\n' - bigSpc is a simple list of conventionally-allocated objects that don't fit on a 1M page\n\n' - objects use this layout:\n' [ 64b header: [ 32b size ][ 16b type tag ][ 8b colour ][ 1b hasFinalizer ][ 2b weak keys, values ] ][ N * 64b data area... ]\n' size includes header. for moved objects the second 32b are replaced by a forwarding pointer\n' pointers in general are to the data area, skipping header\n\n' - data types are: nil, boolean, number, string, closure, natfun, userdata, thread, table ; upvar, tablearray, tablehash, bytecode\n' nil\/boolean\/number\/natfun are value types and need no allocation\n' string uses this structure:\n' [H][ 32b length ][ 32b hash ][ ceil(length\/4) * 64b chars... ]\n' closure uses this structure:\n' [H][ 32b bytecode ptr ][32b][ N * 32b upvar ptrs... ] (N rounded up to 2 for alignment)\n' userdata uses this structure:\n' [H][ 32b metatable ][ 32b value ]\n' thread uses this structure:\n' [H][\n' table uses this structure:\n' [H][ 32b metatable ][32b][ 32b hashpart ptr + 8 ][ 32b arraypart ptr + 8 ]\n' tablearray uses this structure:\n' [H][ 32b len ][ 32b maxlen ][ N * 64b values... ]\n' tablehash uses this structure:\n' [H][ 32b count ][ 32b log2(maxlen) ][ N * [ 64b key ][ 64b value ]... ]\n' upvar uses this structure:\n' [H][ 64b value ]\n' bytecode uses this structure:\n' [H][\n\n\nSuperStrict\n\nImport \"blueerror.bmx\"\nImport \"bluememory.c\"\n\nPrivate\nExtern\n\tFunction PageAlloc:Byte Ptr(size:Int) = \"bluemoon_mmap\"\n\tFunction PageSetRW:Int(p:Byte Ptr, sz:Int) = \"bluemoon_mprotect_rw\"\n\tFunction PageSetRWX:Int(p:Byte Ptr, sz:Int) = \"bluemoon_mprotect_rwx\"\n\tFunction PageSetProtected:Int(p:Byte Ptr, sz:Int) = \"bluemoon_mprotect_none\"\n\tFunction PageFree:Int(p:Byte Ptr, sz:Int) = \"bluemoon_munmap\"\nEnd Extern\nPublic\n\n\nType BlueTypeTag Final\n\tConst NUM:Int = 0, NIL:Int = 1, BOOL:Int = 1 Shl 1, STR:Int = 1 Shl 2, FUN:Int = 1 Shl 3\n\tConst NATFUN:Int = 1 Shl 4, USR:Int = 1 Shl 5, THR:Int = 1 Shl 6, TBL:Int = 1 Shl 7\n\tConst UPV:Int = 1 Shl 8, ARR:Int = 1 Shl 9, HASH:Int = 1 Shl 10, BCODE:Int = 1 Shl 11\n\t\n\tConst NANBOX:Int = Int(2^11 - 1) Shl 20, NANBOX_CHK:Int = NANBOX | (1 Shl 19)\t'test against upper word (and that it's not a genuine NaN)\n\t\n\tConst NILBOX:Int = NANBOX | NIL, BOOLBOX:Int = NANBOX | BOOL, STRBOX:Int = NANBOX | STR\n\tConst FUNBOX:Int = NANBOX | FUN, NATFUNBOX:Int = NANBOX | NATFUN, ANYFUNBOX:Int = NANBOX | FUN | NATFUN\n\tConst USRBOX:Int = NANBOX | USR, THRBOX:Int = NANBOX | THR, TBLBOX:Int = NANBOX | TBL\nEnd Type\n\nType BlueVMMemory Final\n\tConst PAGESZ:Int = 1048576, PAGEBITMAPSZ:Int = 16384, PAGEMETASZ:Int = 256\n\tConst EDENSIZE:Int = 8 * PAGESZ, STACKSZ:Int = 8 * PAGESZ, STACKPROTECT:Int = 4096 * 3, BIGOBJECTSZ:Int = 500000\n\tConst STACKFRAMESZ:Int = 8 * 4, BYTECODESZ:Int = 8 * 4\n\t\n\tConst NIL:Long = Long(BlueTypeTag.NILBOX) * $100000000:Long\t'WHY CAN'T I SHIFT LONGS ARGH\n\t\t\n\tField gcroots:BlueGCNode, stack:Byte Ptr\n\tField newSpace:Byte Ptr, cpySpace:Byte Ptr, oldPtrSpace:Byte Ptr[], oldStrSpace:Byte Ptr[], bigSpace:Byte Ptr[]\n\tField toFinalize:BlueGCNode, weakTables:BlueGCNode\n\tField codeSpace:Byte Ptr[], returnToNative:Int Ptr\n\tField bytecodes:Byte Ptr[], kstrings:Byte Ptr[]\n\t\n\tField memAlloced:Int\n\tField edenThreshold:Int, sizeThreshold:Int\n\tField newPtr:Int\n\t\n\tFunction AlignedAlloc:Byte Ptr(size:Int, align:Int)\t'abuse mmap\/munmap to get greater-than-4K alignments\n\t\t?Not x86\n\t\tRuntimeError \"The Blue Moon memory system does not support your platform (x86-32 only at this time)\"\n\t\t?\n\t\tLocal mem:Byte Ptr = PageAlloc(size + align)\n\t\tIf Not mem Then Throw BlueInterpretError.Make(\"unable to allocate enough memory for system\")\n\t\t\n\t\t' this is where it starts to get unpleasantly x86-32 specific\n\t\tLocal iMem:Int = Int(mem), offset:Int = iMem Mod align\n\t\tIf offset\n\t\t\tLocal preceding:Int = align - offset\n\t\t\tPageFree(mem, preceding) ; mem :+ preceding\n\t\t\tPageFree(mem + size, offset)\t'so we free the surrounding chunks of mem. that aren't aligned, and keep the middle\n\t\tElse\n\t\t\tPageFree(mem + size, align)\n\t\tEndIf\n\t\t\n\t\tReturn mem\n\tEnd Function\n\t\n\tMethod New()\n\t\tgcroots = New BlueGCNode\t'dummy header\n\t\tstack = AlignedAlloc(STACKSZ, PAGESZ)\n\t\tPageSetProtected(stack + STACKSZ - STACKPROTECT, STACKPROTECT)\t' add protection to end of stack\n\t\tnewSpace = AlignedAlloc(EDENSIZE, PAGESZ) ; cpySpace = AlignedAlloc(EDENSIZE, PAGESZ)\n\t\tnewPtr = 0\n\t\t\n\t\tAddCodePage() ; returnToNative = Int Ptr(codeSpace[0]) + 1\n\t\tAddPage(oldStrSpace, PAGEMETASZ)\n\t\tAddPage(oldPtrSpace, PAGEBITMAPSZ)\n\tEnd Method\n\tMethod Delete()\n\t\t' unmap a bunch of stuff\n\t\t' free a bunch of other stuff\n\tEnd Method\n\t\n\tMethod Write(slot:Long Ptr, val:Long)\t'write barrier around old\/big-space\n\t\t'implement it here\n\t\tslot[0] = val\n\tEnd Method\n\t\n\tMethod Collect()\n\tEnd Method\n\t\n\tMethod AllocTable:Byte Ptr(meta:Byte Ptr)\n\t\tLocal ret:Byte Ptr = AllocObject(16, BlueTypeTag.TBL)\n\t\tByte Ptr Ptr(ret)[0] = meta\n\t\tInt Ptr(ret)[2] = 0 ; Int Ptr(ret)[3] = 0\n\t\tReturn ret\n\tEnd Method\n\tMethod AllocClosure:Byte Ptr(bc:Byte Ptr, upvars:Int)\t'already aligned\n\t\tLocal ret:Byte Ptr = AllocObject(8 + upvars * 4, BlueTypeTag.FUN)\n\t\tByte Ptr Ptr(ret)[0] = bc\n\t\tReturn ret\n\tEnd Method\n\tMethod AllocString:Byte Ptr(size:Int, charp:Short Ptr)\n\t\tLocal sz:Int = size\n\t\tIf sz Mod 4 Then sz :+ 4 - sz Mod 4\t'align properly\n\t\tLocal ret:Byte Ptr = AllocObject(8 + sz * 2, BlueTypeTag.STR), destp:Short Ptr = Short Ptr(ret + 8), hash:Int = 5381\n\t\tFor Local c:Int = 0 Until size\t'fill the string and compute hash in one go\n\t\t\tdestp[c] = charp[c]\n\t\t\thash = (hash * 33) ~ charp[c]\t'djb2\n\t\tNext\n\t\tInt Ptr(ret)[0] = size ; Int Ptr(ret)[1] = hash\n\t\tReturn ret\n\tEnd Method\n\tMethod AllocUserdata:Byte Ptr(meta:Byte Ptr, val:Byte Ptr)\n\t\tLocal ret:Byte Ptr = AllocObject(8, BlueTypeTag.USR)\n\t\tByte Ptr Ptr(ret)[0] = meta ; Byte Ptr Ptr(ret)[1] = val\n\t\tReturn ret\n\tEnd Method\n\tMethod AllocThread()\n\tEnd Method\n\t\n\tMethod AllocConstant:Byte Ptr(size:Int, charp:Short Ptr)\t'string constants (the only other kind are doubles)\n\t\tLocal hash:Int = 5381\n\t\tFor Local c:Int = 0 Until size\t'do this first so we can check for duplicates easily\n\t\t\thash = (hash * 33) ~ charp[c]\t'djb2\n\t\tNext\n\t\tFor Local k:Int = 0 Until kstrings.Length\n\t\t\tIf hash = Int Ptr(kstrings[k])[3] And size = Int Ptr(kstrings[k])[2]\n\t\t\t\tLocal eq:Int = True\n\t\t\t\tFor Local ch:Int = 0 Until size\n\t\t\t\t\tIf charp[ch] <> Short Ptr(kstrings[k] + 16)[ch] Then eq = False ; Exit\n\t\t\t\tNext\n\t\t\t\tIf eq Then Return kstrings[k] + 8\t'if it already exists, share it\n\t\t\tEndIf\n\t\tNext\n\t\t\n\t\tLocal ret:Byte Ptr = MemAlloc(8 + 8 + size * 2), destp:Short Ptr = Short Ptr(ret + 16)\n\t\tInt Ptr(ret)[0] = (8 + 8 + size * 2) ; Short Ptr(ret + 4)[0] = BlueTypeTag.STR\t'set colour too?\n\t\tInt Ptr(ret)[2] = size ; Int Ptr(ret)[3] = hash\n\t\tFor Local ch:Int = 0 Until size\n\t\t\tdestp[ch] = charp[ch]\n\t\tNext\n\t\t\n\t\tkstrings :+ [ret]\n\t\tReturn ret + 8\n\tEnd Method\n\tMethod AllocBytecode:Byte Ptr(upvars:Int, kcount:Int, icount:Int)\n\t\tLocal ret:Byte Ptr = MemAlloc(4 * BYTECODESZ + 8 * kcount + 8 * icount + 8 * upvars)\t'not here to do malloc's job for it\n\t\tbytecodes :+ [ret]\n\t\tReturn ret\n\tEnd Method\n\tMethod MaxStringToVal:Long(s:String)\t'allocates as a constant; use sparingly\n\t\tLocal ch:Short Ptr = s.ToWString(), ret:Byte Ptr = AllocConstant(s.Length, ch), val:Long\n\t\tMemFree(ch)\n\t\tInt Ptr(Varptr(val))[0] = Int(ret) ; Int Ptr(Varptr(val))[1] = BlueTypeTag.NANBOX | BlueTypeTag.STR\n\t\tReturn val\n\tEnd Method\n\tMethod ValToMaxString:String(val:Long)\n\t\t'insert type check here (assume string for now)\n\t\tLocal obj:Byte Ptr = Byte Ptr(Int(val))\n\t\tLocal chars:Short[Int Ptr(obj)[0]]\n\t\tFor Local c:Int = 0 Until chars.Length\n\t\t\tchars[c] = Short Ptr(obj + 8)[c]\n\t\tNext\n\t\tReturn String.FromShorts(Short Ptr(chars), chars.Length)\n\tEnd Method\n\tMethod RootObj:BlueGCNode(o:Byte Ptr)\n\t\tgcroots.nx = BlueGCNode.Insert(o, gcroots, gcroots.nx) ; Return gcroots.nx\n\tEnd Method\n\t\n\tMethod AddCodePage()\n\t\tcodeSpace = [AlignedAlloc(2 * PAGESZ, PAGESZ)] + codeSpace\n\t\tPageSetRWX(codeSpace[0], PAGESZ)\n\t\tInt Ptr(codeSpace[0])[0] = PAGEMETASZ\n\tEnd Method\n\tMethod AddPage:Byte Ptr(space:Byte Ptr[] Var, init:Int, exec:Int = False)\n\t\tLocal p:Byte Ptr = AlignedAlloc(PAGESZ, PAGESZ)\t'x86: assume this returns zero-initialized result already\n\t\tspace = [p] + space ; Int Ptr(p)[0] = init\n\t\tIf exec Then PageSetRWX(space[0], PAGESZ)\n\t\tReturn p\n\tEnd Method\n'\tMethod HeaderSize:Int(space:Byte Ptr[])\n'\t\tSelect space\n'\t\t\tCase oldPtrSpace ; Return PAGEBITMAPSZ\n'\t\t\tDefault ; Return PAGEMETASZ\n'\t\tEnd Select\n'\tEnd Method\n\t\n\tMethod AllocCodeBlock:Byte Ptr(sz:Int)\t'this returns the requested size, allocating it externally if necessary\n\t\tLocal page:Byte Ptr = codeSpace[0], pNewPtr:Int = Int Ptr(page)[0]\n\t\tIf pNewPtr + sz > PAGESZ\n\t\t\tRuntimeError \"not yet implemented\"\n\t\tElse\n\t\t\tInt Ptr(page)[0] :+ sz\n\t\t\tReturn page + pNewPtr\n\t\tEndIf\n\tEnd Method\n\t\n\tMethod AllocObject:Byte Ptr(sz:Int, tag:Short)\n\t\tsz :+ 8 ; Local ret:Byte Ptr\n\t\tIf sz < BIGOBJECTSZ\n\t\t\tIf newPtr + sz > EDENSIZE Then Collect()\n\t\t\tret = newSpace + newPtr; newPtr :+ sz\n\t\tElse\n\t\t\tret = MemAlloc(sz)\n\t\t\tIf Not ret Then Throw BlueInterpretError.Make(\"unable to allocate memory for object\")\n\t\t\tbigSpace :+ [ret]\n\t\t\t' track as part of allocated memory\n\t\tEndIf\n\t\tInt Ptr(ret)[0] = sz ; Short Ptr(ret + 4)[0] = tag\n\t\tReturn ret + 8\n\tEnd Method\n\t\n\tFunction PtrToVal:Long(p:Byte Ptr, tag:Short)\n\t\tLocal ret:Long, rp:Int Ptr = Int Ptr(Varptr(ret))\n\t\trp[0] = Int(p) ; rp[1] = BlueTypeTag.NANBOX | tag\n\t\tReturn ret\n\tEnd Function\n\tFunction ValToPtr:Byte Ptr(v:Long)\n\t\tLocal vp:Byte Ptr Ptr = Byte Ptr Ptr(Varptr(v))\n\t\tReturn vp[0]\n\tEnd Function\nEnd Type\n\nType BlueGCNode\n\tField pv:BlueGCNode, nx:BlueGCNode, val:Byte Ptr\n\tMethod Remove()\n\t\tIf pv Then pv.nx = nx ; pv = Null\n\t\tIf nx Then nx.pv = pv ; nx = Null\n\tEnd Method\n\t\n\tFunction Cons:BlueGCNode(val:Byte Ptr, nx:BlueGCNode)\n\t\tLocal n:BlueGCNode = New Self\n\t\tn.nx = nx ; n.val = val\n\t\tReturn n\n\tEnd Function\n\tFunction Insert:BlueGCNode(val:Byte Ptr, pv:BlueGCNode, nx:BlueGCNode)\n\t\tLocal n:BlueGCNode = New Self\n\t\tn.pv = pv ; n.nx = nx ; n.val = val\n\t\tReturn n\n\tEnd Function\nEnd Type\n\nPrivate\n\nPublic\n\n","old_contents":"\n' Blue Moon\n' Memory allocator\/garbage collector\n' this is a generational three-colour mark\/compact collector\n\n' notes:\n\n' - a basic Lua value is represented as a NaN-box (i.e. a double, unless it's a NaN in which case there's a pointer in the significand)\n\n' - objects are allocated in newSpc, Cheney'd over to cpySpc when it runs out; the Eden spaces are 8MB each\n' - when less than .edenThreshold remains in cpySpc after a scavenge, objects held from oldSpc are promoted\n' - when more than .sizeThreshold has been promoted or less than .edenThreshold still remains, a full GC runs\n' this scan updates usage statistics for each page\n' the \"worst\" N pages are then compacted; if total usage is still poor, mark for another compact after next scavenge\n' the rest of Eden is then promoted\n' - fallback to compacting in one go if usage is catastrophic\/increments aren't keeping up\n' - roots are obtained from the gcroots list, and the stack\n\n' - before compacting\/discarding, the space is scanned for objects with finalizers which are resurrected into newSpc and put on toFinalize\n' - during a FULL collection, weak tables are listed in .weakTables rather than colouring elems, then weakscanned before compaction\n\n' - the stack is an 8M block with the last page protected\n' - stack frames use this format:\n' [ ret ip ][ prev base ][[ 16b frame sz ][ 16b var ofs ]][ func obj ][ ip ][ argv ][ retv ][[ 16b argc ][ 16b retc ]][ upv0 | upv1 | ... ][ v0 | v1 | ... ][ tmp... ]\n' the upvar slots, var slots, and temp slots beyond are all 64-bit NaN-boxes\n' the preceding slots are 32-bit words except otherwise shown\n\n' - pages in oldPtrSpc use this format:\n' [[[ 0..256 metadata ] ..16K dirty bitmap ] ..1M allocated objects ]\n' each 64-byte potential NaN-box in the object-space has a corresponding dirty bit that is set if it points to newSpc\n' a metamap in the metadata in turn marks dirty sectors of the bitmap, for reduced scanning\n' metadata also contains allocation pointer and used space total\n\n' - codeSpace stores executable instruction buffers for Lua functions (bytecode is allocated directly into oldStrSpc)\n\n' - bigSpc is a simple list of conventionally-allocated objects that don't fit on a 1M page\n\n' - objects use this layout:\n' [ 64b header: [ 32b size ][ 16b type tag ][ 8b colour ][ 1b hasFinalizer ][ 2b weak keys, values ] ][ N * 64b data area... ]\n' size includes header. for moved objects the second 32b are replaced by a forwarding pointer\n' pointers in general are to the data area, skipping header\n\n' - data types are: nil, boolean, number, string, closure, natfun, userdata, thread, table ; upvar, tablearray, tablehash, bytecode\n' nil\/boolean\/number\/natfun are value types and need no allocation\n' string uses this structure:\n' [H][ 32b length ][ 32b hash ][ ceil(length\/4) * 64b chars... ]\n' closure uses this structure:\n' [H][ 32b bytecode ptr ][32b][ N * 32b upvar ptrs... ] (N rounded up to 2 for alignment)\n' userdata uses this structure:\n' [H][ 32b metatable ][ 32b value ]\n' thread uses this structure:\n' [H][\n' table uses this structure:\n' [H][ 32b metatable ][32b][ 32b hashpart ptr + 8 ][ 32b arraypart ptr + 8 ]\n' tablearray uses this structure:\n' [H][ 32b len ][ 32b maxlen ][ N * 64b values... ]\n' tablehash uses this structure:\n' [H][ 32b count ][ 32b log2(maxlen) ][ N * [ 64b key ][ 64b value ]... ]\n' upvar uses this structure:\n' [H][ 64b value ]\n' bytecode uses this structure:\n' [H][\n\n\nSuperStrict\n\nImport \"blueerror.bmx\"\nImport \"bluememory.c\"\n\nPrivate\nExtern\n\tFunction PageAlloc:Byte Ptr(size:Int) = \"bluemoon_mmap\"\n\tFunction PageSetRW:Int(p:Byte Ptr, sz:Int) = \"bluemoon_mprotect_rw\"\n\tFunction PageSetRWX:Int(p:Byte Ptr, sz:Int) = \"bluemoon_mprotect_rwx\"\n\tFunction PageSetProtected:Int(p:Byte Ptr, sz:Int) = \"bluemoon_mprotect_none\"\n\tFunction PageFree:Int(p:Byte Ptr, sz:Int) = \"bluemoon_munmap\"\nEnd Extern\nPublic\n\n\nType BlueTypeTag Final\n\tConst NUM:Int = 0, NIL:Int = 1, BOOL:Int = 1 Shl 1, STR:Int = 1 Shl 2, FUN:Int = 1 Shl 3\n\tConst NATFUN:Int = 1 Shl 4, USR:Int = 1 Shl 5, THR:Int = 1 Shl 6, TBL:Int = 1 Shl 7\n\tConst UPV:Int = 1 Shl 8, ARR:Int = 1 Shl 9, HASH:Int = 1 Shl 10, BCODE:Int = 1 Shl 11\n\t\n\tConst NANBOX:Int = Int(2^11 - 1) Shl 20, NANBOX_CHK:Int = NANBOX | (1 Shl 19)\t'test against upper word (and that it's not a genuine NaN)\nEnd Type\n\nType BlueVMMemory Final\n\tConst PAGESZ:Int = 1048576, PAGEBITMAPSZ:Int = 16384, PAGEMETASZ:Int = 256\n\tConst EDENSIZE:Int = 8 * PAGESZ, STACKSZ:Int = 8 * PAGESZ, STACKPROTECT:Int = 4096 * 3, BIGOBJECTSZ:Int = 500000\n\tConst STACKFRAMESZ:Int = 8 * 4, BYTECODESZ:Int = 8 * 4\n\t\n\tConst NIL:Long = Long(BlueTypeTag.NANBOX | BlueTypeTag.NIL) * $100000000:Long\t'WHY CAN'T I SHIFT LONGS ARGH\n\t\t\n\tField gcroots:BlueGCNode, stack:Byte Ptr\n\tField newSpace:Byte Ptr, cpySpace:Byte Ptr, oldPtrSpace:Byte Ptr[], oldStrSpace:Byte Ptr[], bigSpace:Byte Ptr[]\n\tField toFinalize:BlueGCNode, weakTables:BlueGCNode\n\tField codeSpace:Byte Ptr[], returnToNative:Int Ptr\n\tField bytecodes:Byte Ptr[], kstrings:Byte Ptr[]\n\t\n\tField memAlloced:Int\n\tField edenThreshold:Int, sizeThreshold:Int\n\tField newPtr:Int\n\t\n\tFunction AlignedAlloc:Byte Ptr(size:Int, align:Int)\t'abuse mmap\/munmap to get greater-than-4K alignments\n\t\t?Not x86\n\t\tRuntimeError \"The Blue Moon memory system does not support your platform (x86-32 only at this time)\"\n\t\t?\n\t\tLocal mem:Byte Ptr = PageAlloc(size + align)\n\t\tIf Not mem Then Throw BlueInterpretError.Make(\"unable to allocate enough memory for system\")\n\t\t\n\t\t' this is where it starts to get unpleasantly x86-32 specific\n\t\tLocal iMem:Int = Int(mem), offset:Int = iMem Mod align\n\t\tIf offset\n\t\t\tLocal preceding:Int = align - offset\n\t\t\tPageFree(mem, preceding) ; mem :+ preceding\n\t\t\tPageFree(mem + size, offset)\t'so we free the surrounding chunks of mem. that aren't aligned, and keep the middle\n\t\tElse\n\t\t\tPageFree(mem + size, align)\n\t\tEndIf\n\t\t\n\t\tReturn mem\n\tEnd Function\n\t\n\tMethod New()\n\t\tgcroots = New BlueGCNode\t'dummy header\n\t\tstack = AlignedAlloc(STACKSZ, PAGESZ)\n\t\tPageSetProtected(stack + STACKSZ - STACKPROTECT, STACKPROTECT)\t' add protection to end of stack\n\t\tnewSpace = AlignedAlloc(EDENSIZE, PAGESZ) ; cpySpace = AlignedAlloc(EDENSIZE, PAGESZ)\n\t\tnewPtr = 0\n\t\t\n\t\tAddCodePage() ; returnToNative = Int Ptr(codeSpace[0]) + 1\n\t\tAddPage(oldStrSpace, PAGEMETASZ)\n\t\tAddPage(oldPtrSpace, PAGEBITMAPSZ)\n\tEnd Method\n\tMethod Delete()\n\t\t' unmap a bunch of stuff\n\t\t' free a bunch of other stuff\n\tEnd Method\n\t\n\tMethod Write(slot:Long Ptr, val:Long)\t'write barrier around old\/big-space\n\t\t'implement it here\n\t\tslot[0] = val\n\tEnd Method\n\t\n\tMethod Collect()\n\tEnd Method\n\t\n\tMethod AllocTable:Byte Ptr(meta:Byte Ptr)\n\t\tLocal ret:Byte Ptr = AllocObject(16, BlueTypeTag.TBL)\n\t\tByte Ptr Ptr(ret)[0] = meta\n\t\tInt Ptr(ret)[2] = 0 ; Int Ptr(ret)[3] = 0\n\t\tReturn ret\n\tEnd Method\n\tMethod AllocClosure:Byte Ptr(bc:Byte Ptr, upvars:Int)\t'already aligned\n\t\tLocal ret:Byte Ptr = AllocObject(8 + upvars * 4, BlueTypeTag.FUN)\n\t\tByte Ptr Ptr(ret)[0] = bc\n\t\tReturn ret\n\tEnd Method\n\tMethod AllocString:Byte Ptr(size:Int, charp:Short Ptr)\n\t\tLocal sz:Int = size\n\t\tIf sz Mod 4 Then sz :+ 4 - sz Mod 4\t'align properly\n\t\tLocal ret:Byte Ptr = AllocObject(8 + sz * 2, BlueTypeTag.STR), destp:Short Ptr = Short Ptr(ret + 8), hash:Int = 5381\n\t\tFor Local c:Int = 0 Until size\t'fill the string and compute hash in one go\n\t\t\tdestp[c] = charp[c]\n\t\t\thash = (hash * 33) ~ charp[c]\t'djb2\n\t\tNext\n\t\tInt Ptr(ret)[0] = size ; Int Ptr(ret)[1] = hash\n\t\tReturn ret\n\tEnd Method\n\tMethod AllocUserdata:Byte Ptr(meta:Byte Ptr, val:Byte Ptr)\n\t\tLocal ret:Byte Ptr = AllocObject(8, BlueTypeTag.USR)\n\t\tByte Ptr Ptr(ret)[0] = meta ; Byte Ptr Ptr(ret)[1] = val\n\t\tReturn ret\n\tEnd Method\n\tMethod AllocThread()\n\tEnd Method\n\t\n\tMethod AllocConstant:Byte Ptr(size:Int, charp:Short Ptr)\t'string constants (the only other kind are doubles)\n\t\tLocal hash:Int = 5381\n\t\tFor Local c:Int = 0 Until size\t'do this first so we can check for duplicates easily\n\t\t\thash = (hash * 33) ~ charp[c]\t'djb2\n\t\tNext\n\t\tFor Local k:Int = 0 Until kstrings.Length\n\t\t\tIf hash = Int Ptr(kstrings[k])[3] And size = Int Ptr(kstrings[k])[2]\n\t\t\t\tLocal eq:Int = True\n\t\t\t\tFor Local ch:Int = 0 Until size\n\t\t\t\t\tIf charp[ch] <> Short Ptr(kstrings[k] + 16)[ch] Then eq = False ; Exit\n\t\t\t\tNext\n\t\t\t\tIf eq Then Return kstrings[k] + 8\t'if it already exists, share it\n\t\t\tEndIf\n\t\tNext\n\t\t\n\t\tLocal ret:Byte Ptr = MemAlloc(8 + 8 + size * 2), destp:Short Ptr = Short Ptr(ret + 16)\n\t\tInt Ptr(ret)[0] = (8 + 8 + size * 2) ; Short Ptr(ret + 4)[0] = BlueTypeTag.STR\t'set colour too?\n\t\tInt Ptr(ret)[2] = size ; Int Ptr(ret)[3] = hash\n\t\tFor Local ch:Int = 0 Until size\n\t\t\tdestp[ch] = charp[ch]\n\t\tNext\n\t\t\n\t\tkstrings :+ [ret]\n\t\tReturn ret + 8\n\tEnd Method\n\tMethod AllocBytecode:Byte Ptr(upvars:Int, kcount:Int, icount:Int)\n\t\tLocal ret:Byte Ptr = MemAlloc(4 * BYTECODESZ + 8 * kcount + 8 * icount + 8 * upvars)\t'not here to do malloc's job for it\n\t\tbytecodes :+ [ret]\n\t\tReturn ret\n\tEnd Method\n\tMethod MaxStringToVal:Long(s:String)\t'allocates as a constant; use sparingly\n\t\tLocal ch:Short Ptr = s.ToWString(), ret:Byte Ptr = AllocConstant(s.Length, ch), val:Long\n\t\tMemFree(ch)\n\t\tInt Ptr(Varptr(val))[0] = Int(ret) ; Int Ptr(Varptr(val))[1] = BlueTypeTag.NANBOX | BlueTypeTag.STR\n\t\tReturn val\n\tEnd Method\n\tMethod ValToMaxString:String(val:Long)\n\t\t'insert type check here (assume string for now)\n\t\tLocal obj:Byte Ptr = Byte Ptr(Int(val))\n\t\tLocal chars:Short[Int Ptr(obj)[0]]\n\t\tFor Local c:Int = 0 Until chars.Length\n\t\t\tchars[c] = Short Ptr(obj + 8)[c]\n\t\tNext\n\t\tReturn String.FromShorts(Short Ptr(chars), chars.Length)\n\tEnd Method\n\tMethod RootObj:BlueGCNode(o:Byte Ptr)\n\t\tgcroots.nx = BlueGCNode.Insert(o, gcroots, gcroots.nx) ; Return gcroots.nx\n\tEnd Method\n\t\n\tMethod AddCodePage()\n\t\tcodeSpace = [AlignedAlloc(2 * PAGESZ, PAGESZ)] + codeSpace\n\t\tPageSetRWX(codeSpace[0], PAGESZ)\n\t\tInt Ptr(codeSpace[0])[0] = PAGEMETASZ\n\tEnd Method\n\tMethod AddPage:Byte Ptr(space:Byte Ptr[] Var, init:Int, exec:Int = False)\n\t\tLocal p:Byte Ptr = AlignedAlloc(PAGESZ, PAGESZ)\t'x86: assume this returns zero-initialized result already\n\t\tspace = [p] + space ; Int Ptr(p)[0] = init\n\t\tIf exec Then PageSetRWX(space[0], PAGESZ)\n\t\tReturn p\n\tEnd Method\n'\tMethod HeaderSize:Int(space:Byte Ptr[])\n'\t\tSelect space\n'\t\t\tCase oldPtrSpace ; Return PAGEBITMAPSZ\n'\t\t\tDefault ; Return PAGEMETASZ\n'\t\tEnd Select\n'\tEnd Method\n\t\n\tMethod AllocCodeBlock:Byte Ptr(sz:Int)\t'this returns the requested size, allocating it externally if necessary\n\t\tLocal page:Byte Ptr = codeSpace[0], pNewPtr:Int = Int Ptr(page)[0]\n\t\tIf pNewPtr + sz > PAGESZ\n\t\t\tRuntimeError \"not yet implemented\"\n\t\tElse\n\t\t\tInt Ptr(page)[0] :+ sz\n\t\t\tReturn page + pNewPtr\n\t\tEndIf\n\tEnd Method\n\t\n\tMethod AllocObject:Byte Ptr(sz:Int, tag:Short)\n\t\tsz :+ 8 ; Local ret:Byte Ptr\n\t\tIf sz < BIGOBJECTSZ\n\t\t\tIf newPtr + sz > EDENSIZE Then Collect()\n\t\t\tret = newSpace + newPtr; newPtr :+ sz\n\t\tElse\n\t\t\tret = MemAlloc(sz)\n\t\t\tIf Not ret Then Throw BlueInterpretError.Make(\"unable to allocate memory for object\")\n\t\t\tbigSpace :+ [ret]\n\t\t\t' track as part of allocated memory\n\t\tEndIf\n\t\tInt Ptr(ret)[0] = sz ; Short Ptr(ret + 4)[0] = tag\n\t\tReturn ret + 8\n\tEnd Method\n\t\n\tFunction PtrToVal:Long(p:Byte Ptr, tag:Short)\n\t\tLocal ret:Long, rp:Int Ptr = Int Ptr(Varptr(ret))\n\t\trp[0] = Int(p) ; rp[1] = BlueTypeTag.NANBOX | tag\n\t\tReturn ret\n\tEnd Function\n\tFunction ValToPtr:Byte Ptr(v:Long)\n\t\tLocal vp:Byte Ptr Ptr = Byte Ptr Ptr(Varptr(v))\n\t\tReturn vp[0]\n\tEnd Function\nEnd Type\n\nType BlueGCNode\n\tField pv:BlueGCNode, nx:BlueGCNode, val:Byte Ptr\n\tMethod Remove()\n\t\tIf pv Then pv.nx = nx ; pv = Null\n\t\tIf nx Then nx.pv = pv ; nx = Null\n\tEnd Method\n\t\n\tFunction Cons:BlueGCNode(val:Byte Ptr, nx:BlueGCNode)\n\t\tLocal n:BlueGCNode = New Self\n\t\tn.nx = nx ; n.val = val\n\t\tReturn n\n\tEnd Function\n\tFunction Insert:BlueGCNode(val:Byte Ptr, pv:BlueGCNode, nx:BlueGCNode)\n\t\tLocal n:BlueGCNode = New Self\n\t\tn.pv = pv ; n.nx = nx ; n.val = val\n\t\tReturn n\n\tEnd Function\nEnd Type\n\nPrivate\n\nPublic\n\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"f177a9ab228a17f30fb77d94153d2490d86f322f","subject":"Stop key going over 256 which causes BlitzMax to crash for MonkeyMax.","message":"Stop key going over 256 which causes BlitzMax to crash for MonkeyMax.\n","repos":"swoolcock\/diddy,swoolcock\/diddy,swoolcock\/diddy,swoolcock\/diddy,swoolcock\/diddy","old_file":"monkeymax\/modules\/mojo\/native\/mojo.bmax.bmx","new_file":"monkeymax\/modules\/mojo\/native\/mojo.bmax.bmx","new_contents":"' ***** Start mojo.bmax.bmx ******\r\n\r\nGlobal app:gxtkApp\r\n\r\nType gxtkApp\r\n\tField ginput:gxtkInput\r\n\tField gaudio:gxtkAudio\r\n\tField ggraphics:gxtkGraphics\r\n\r\n\tField dead:Int=0\r\n\tField suspended:Int=0\r\n\tField vloading:Int=0\r\n\tField maxloading:Int=0\r\n\tField updateRate:Int=0\r\n\tField nextUpdate:Float=0\r\n\tField updatePeriod:Float=0\r\n\tField startMillis:Float=0\r\n\t\r\n\tMethod New()' gxtkApp()\r\n\t\tapp=Self\r\n\t\tggraphics=New gxtkGraphics\r\n\tEndMethod\r\n\t\r\n\tMethod Setup()\r\n\t\tginput=New gxtkInput\r\n\t\tgaudio=New gxtkAudio\r\n\r\n\t\tbb_input_SetInputDevice(ginput)\r\n\t\tbb_audio_SetAudioDevice(gaudio)\r\n\t\t\r\n\t\tstartMillis=BlitzMaxMillisecs()\r\n\t\t\r\n\t\tSetFrameRate( 0 )\r\n\t\t\r\n\t\tInvokeOnCreate()\r\n\t\tInvokeOnRender()\r\n\t\tUpdate()\r\n\tEndMethod\r\n\t\r\n\tMethod Update()\r\n\t\tWhile Not AppTerminate()\r\n\t\t\tLocal updates:Int = 0\r\n\t\t\t\r\n\t\t\tLocal cont:Int = 1\r\n\t\t\tWhile (cont)\r\n\t\t\t\tnextUpdate:+updatePeriod\r\n\t\t\t\tInvokeOnUpdate()\r\n\t\t\t\tIf Not updatePeriod Then cont = 0\r\n\t\t\t\tIf nextUpdate>BlitzMaxMillisecs() Then cont = 0\r\n\t\t\t\tupdates:+1\r\n\t\t\t\tIf updates = 7 Then\r\n\t\t\t\t\tnextUpdate = BlitzMaxMillisecs()\r\n\t\t\t\t\tcont = 0\r\n\t\t\t\tEndIf\r\n\t\t\tWend\r\n\t\t\tInvokeOnRender()\r\n\t\tWend\r\n\tEndMethod\r\n\t\r\n\tMethod InvokeOnCreate()\r\n\t\tIf dead Return\r\n\t\tdead = 1\r\n\t\tOnCreate()\r\n\t\tdead = 0\r\n\tEndMethod\r\n\r\n\tMethod InvokeOnUpdate()\r\n\t\tIf dead Or suspended Or Not updateRate Or vloading Return\r\n\t\tOnUpdate()\r\n\tEndMethod\r\n\t\r\n\tMethod InvokeOnRender()\r\n\t\tIf dead Or suspended Return\r\n\t\tggraphics.BeginRender()\r\n\t\tIf vloading\r\n\t\t\tOnLoading()\r\n\t\tElse\r\n\t\t\tOnRender()\r\n\t\tEndIf\r\n\t\tggraphics.EndRender()\r\n\tEndMethod\r\n\t\r\n\t\r\n\tMethod SetFrameRate( fps:Int )\r\n\t\tIf fps\r\n\t\t\tupdatePeriod=1000.0\/fps\r\n\t\t\tnextUpdate=BlitzMaxMillisecs() +updatePeriod\r\n\t\tElse\r\n\t\t\tupdatePeriod=0\r\n\t\tEndIf\r\n\tEndMethod\r\n\r\n\tMethod LoadState:String()\r\n'\t\tvar file:SharedObject=SharedObject.getLocal( \"gxtkapp\" );\r\n'\t\tvar state:String=file.data.state;\r\n'\t\tfile.close();\r\n'\t\tif( state ) return state;\r\n\t\tReturn \"\"\r\n\tEndMethod\r\n\t\r\n\tMethod SaveState:Int( state:String )\r\n'\t\tvar file:SharedObject=SharedObject.getLocal( \"gxtkapp\" );\r\n'\t\tfile.data.state=state;\r\n'\t\tfile.close();\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod LoadString:String( path:String )\r\n\t\tpath = \"data\/\" + path\r\n\t\tReturn LoadText( path )\r\n\tEndMethod\r\n\t\r\n\t' ***** GXTK API *****\r\n\t\r\n\tMethod GraphicsDevice:gxtkGraphics()\r\n\t\tReturn ggraphics\r\n\tEndMethod\r\n\r\n\tMethod InputDevice:gxtkInput()\r\n\t\tReturn ginput\r\n\tEndMethod\r\n\r\n\tMethod AudioDevice:gxtkAudio()\r\n\t\tReturn gaudio\r\n\tEndMethod\r\n\r\n\tMethod SetUpdateRate:Int(hertz:Int)\r\n\t\tupdateRate = hertz\r\n\t\tIf Not vloading Then SetFrameRate(updateRate)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod MilliSecs:Int()\r\n\t\tReturn BlitzMaxMillisecs() - startMillis\r\n\tEndMethod\r\n\t\r\n\tMethod Loading:Int()\r\n\t\tReturn vloading\r\n\tEndMethod\r\n\r\n\tMethod OnCreate:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod OnUpdate:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod OnSuspend:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod OnResume:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod OnRender:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod OnLoading:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkGraphics\r\n\tField gmode:Int = 1\r\n\r\n\tMethod Mode:Int()\r\n\t\tReturn gmode\r\n\tEndMethod\r\n\t\r\n\tMethod Cls:Int(r:Int = 0, g:Int = 0, b:Int = 0)\r\n\t\tBlitzMaxCls(r, g, b)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawPoint:Int(x:Float, y:Float)\r\n\t\tPlot x, y\r\n\tEndMethod\r\n\t\r\n\tMethod LoadSurface:gxtkSurface(path:String)\r\n\t\tLocal image:TImage = LoadImage(\"data\/\"+path)\r\n\t\tIf image Then\r\n\t\t\tLocal gs:gxtkSurface = New gxtkSurface\r\n\t\t\tgs.setImage(image)\r\n\t\t\tReturn gs\r\n\t\tEndIf\r\n\t\tReturn Null\r\n\tEndMethod\r\n\t\r\n\tMethod BeginRender()\r\n\tEndMethod\r\n\t\r\n\tMethod EndRender()\r\n\t\tFlip\r\n\tEndMethod\r\n\t\r\n\tMethod SetColor:Int(r:Int, g:Int, b:Int)\r\n\t\tBlitzMaxSetColor(r, g, b)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod SetAlpha:Int(a:Float)\r\n\t\tBlitzMaxSetAlpha(a)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod SetBlend:Int(blend:Int)\r\n\t\tBlitzMaxSetBlend(blend)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod Width:Int()\r\n\t\tReturn GraphicsWidth()\r\n\tEndMethod\r\n\t\r\n\tMethod Height:Int()\r\n\t\tReturn GraphicsHeight()\r\n\tEndMethod\r\n\t\r\n\tMethod SetScissor:Int(x:Int, y:Int, w:Int, h:Int)\r\n\t\tSetViewport(x, y, w, h) ' NOT TESTED!\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod SetMatrix:Int(ix:Float,iy:Float,jx:Float,jy:Float,tx:Float,ty:Float)\r\n\t\tLocal sx:Float = Sqr( (ix*ix) + (jx*jx) )\r\n\t\tLocal sy:Float = Sqr( (iy*iy) + (jy*jy) )\r\n\t\tLocal rot:Float = -Atan2( jx, ix )\r\n\t\tSetTransform( rot, sx, sy )\r\n\t\tSetOrigin( tx, ty )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawSurface:Int(surface:gxtkSurface,x:Float,y:Float)\r\n\t\tDrawImage(surface.image, x, y, 0)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawSurface2:Int(surface:gxtkSurface,x:Float,y:Float, srcx:Int, srcy:Int, srcw:Int, srch:Int )\r\n\t\tDrawSubImageRect(surface.image, x, y, srcw, srch, srcx, srcy, srcw, srch)\t\t\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawLine:Int( x1:Float,y1:Float,x2:Float,y2:Float )\r\n\t\tBlitzMaxDrawLine(x1, y1, x2, y2)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawOval:Int( x:Float, y:Float, w:Float, h:Float )\r\n\t\tBlitzMaxDrawOval(x, y, w, h)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawPoly:Int(vertices:Float[])\r\n\t\tBlitzMaxDrawPoly( vertices )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawRect:Int( x:Float, y:Float, w:Float, h:Float )\r\n\t\tBlitzMaxDrawRect(x, y, w, h)\r\n\t\tReturn 0\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkInput\r\n\tMethod MouseX:Float()\r\n\t\tReturn BRL.PolledInput.MouseX()\r\n\tEndMethod\r\n\r\n\tMethod MouseY:Float()\r\n\t\tReturn BRL.PolledInput.MouseY()\r\n\tEndMethod\r\n\t\r\n\tMethod KeyDown:Int( key:Int )\r\n\t\tIf( key >= 1 And key <= 3 )\r\n\t\t\tReturn BRL.PolledInput.MouseDown( key )\r\n\t\tEndIf\r\n\t\tIf key < 256\r\n\t\t\tReturn BRL.PolledInput.KeyDown( key )\r\n\t\tElse\r\n\t\t\tReturn 0\r\n\t\tEndIf\r\n\tEndMethod\r\n\r\n\tMethod KeyHit:Int( key:Int )\r\n\t\tIf( key >= 1 And key <= 3 )\r\n\t\t\tReturn BRL.PolledInput.MouseHit( key )\r\n\t\tEndIf\r\n\t\tIf key < 256\r\n\t\t\tReturn BRL.PolledInput.KeyHit( key )\r\n\t\tElse\r\n\t\t\tReturn 0\r\n\t\tEndIf\r\n\tEndMethod\r\n\r\n\tMethod GetChar:Int()\r\n\t\tReturn BRL.PolledInput.GetChar()\r\n\tEndMethod\r\n\r\n\tMethod JoyX:Int( index:Int )\r\n\t\tReturn Pub.FreeJoy.JoyX( index )\r\n\tEndMethod\r\n\r\n\tMethod JoyY:Int( index:Int )\r\n\t\tReturn Pub.FreeJoy.JoyY( index )\r\n\tEndMethod\r\n\r\n\tMethod JoyZ:Int( index:Int )\r\n\t\tReturn Pub.FreeJoy.JoyZ( index )\r\n\tEndMethod\r\n\r\n\tMethod TouchX:Float( index:Int )\r\n\t\tReturn BRL.PolledInput.MouseX()\r\n\tEndMethod\r\n\r\n\tMethod TouchY:Float( index:Int )\r\n\t\tReturn BRL.PolledInput.MouseY()\r\n\tEndMethod\r\n\t\r\n\tMethod AccelX:Int()\r\n\t\treturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod AccelY:Int()\r\n\t\treturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod AccelZ:Int()\r\n\t\treturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod SetKeyboardEnabled:Int( enabled:int )\r\n\t\tReturn 0\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkChannel\r\n\tField channel:TChannel\t' null then not playing\r\n\tField sample:gxtkSample\r\n\tField loops:int\r\n\t'Field transform:SoundTransform=new SoundTransform()\r\n\t'Field pausepos:Number\r\n\tField state:int\r\n\t\r\n\tMethod New()\r\n\t\tchannel = New TChannel\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkAudio\r\n\tField amusicState:Int = 0\r\n\tField channels:gxtkChannel[] = New gxtkChannel[33]\r\n\t\r\n\tMethod New()\r\n\t\tFor local i:Int = 0 To 33 - 1\r\n\t\t\tchannels[i] = New gxtkChannel\r\n\t\tNext\r\n\tEndMethod\r\n\t\r\n\tMethod MusicState:Int()\r\n'\t\tIf( musicState = 1 And music.isPlaying() = False )\r\n'\t\t\tmusicState = 0;\r\n'\t\tEndif\r\n\t\tReturn amusicState\r\n\tEndMethod\r\n\t\r\n\tMethod PlayMusic:Int( path:String, flags:Int )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod ChannelState:int( channel:int )\r\n\t\tReturn -1\r\n\tEndMethod\r\n\t\r\n\tMethod StopMusic()\r\n\tEndMethod\r\n\t\r\n\tMethod StopChannel( channel:Int )\r\n\tEndMethod\r\n\r\n\tMethod PlaySample( sound:gxtkSample, channel:Int, flags:Int )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\t\r\n\t\t'If chan.state <> 0 Then chan.channel.Stop() <-- this crashes after the first play!?\r\n\t\t\r\n\t\tchan.sample = sound\r\n\t\t'chan.loops = flags ? 0x7fffffff : 0;\r\n\t\t'chan.channel = sample.sound.play( 0,chan.loops,chan.transform );\r\n\t\t'chan.channel = sound\r\n\t\tchan.state=1\r\n\t\r\n\t\tPlaySound( sound.sound, chan.channel )\r\n\tEndMethod\r\n\r\n\tMethod SetPan( channel:Int, pan:Float )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tchan.channel.SetPan(pan)\r\n\tEndMethod\r\n\r\n\tMethod SetRate( channel:Int, rate:Float )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tchan.channel.SetRate(rate)\r\n\tEndMethod\r\n\r\n\tMethod PauseMusic:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod ResumeMusic:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod SetMusicVolume:Int( volume:Float )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod SetVolume:Int( channel:Int, volume:Float )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tchan.channel.SetVolume(volume)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod LoadSample:gxtkSample( path:String )\r\n\t\tLocal sound:TSound = LoadSound(\"data\/\"+path)\r\n\t\tIf sound Then\r\n\t\t\tLocal gs:gxtkSample = New gxtkSample\r\n\t\t\tgs.setSound(sound)\r\n\t\t\tReturn gs\r\n\t\tEndIf\r\n\t\tReturn Null\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkSample\r\n\tField sound:TSound\r\n\t\r\n\tMethod setSound(sound:TSound)\r\n\t\tSelf.sound = sound\r\n\tEndMethod\r\n\t\r\n\tMethod Discard()\r\n\t\tSelf.sound = null\r\n\tEndMethod\r\nEndType\r\n\r\nFunction BlitzMaxDrawPoly:Int(vertices:Float[])\r\n\tDrawPoly vertices\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxDrawRect:Int( x:Float, y:Float, w:Float, h:Float )\r\n\tDrawRect x, y, w, h\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxDrawOval:Int( x:Float, y:Float, w:Float, h:Float )\r\n\tDrawOval x, y, w, h\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxDrawLine:Int( x1:Float,y1:Float,x2:Float,y2:Float )\r\n\tDrawLine x1, y1, x2, y2\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxMillisecs:Int()\r\n\tReturn MilliSecs()\r\nEndFunction\r\n\r\nFunction BlitzMaxSetColor(r:Int, g:Int, b:Int)\r\n\tSetColor(r, g, b)\r\nEndFunction\r\n\r\nFunction BlitzMaxSetBlend(blend:Int)\r\n\tSelect blend\r\n\t\tCase 0\r\n\t\t\tSetBlend( ALPHABLEND )\r\n\t\tCase 1\r\n\t\t\tSetBlend( LIGHTBLEND )\r\n\tEnd Select\r\nEndFunction\r\n\r\nFunction BlitzMaxSetAlpha(a:Float)\r\n\tSetAlpha(a)\r\nEndFunction\r\n\r\nFunction BlitzMaxCls(r:Int = 0, g:Int = 0, b:Int = 0)\r\n\tSetClsColor(r, g, b)\r\n\tCls\r\nEndFunction\r\n\r\nType gxtkSurface\r\n\tField w:Int, h:Int\r\n\tField image:TImage\r\n\t\r\n\tMethod setImage(image:TImage)\r\n\t\tSelf.image = image\r\n\tEndMethod\r\n\t\r\n\tMethod Width:Int()\r\n\t\tReturn image.Width\r\n\tEndMethod\r\n\t\r\n\tMethod Height:Int()\r\n\t\tReturn image.Height\r\n\tEndMethod\r\n\t\r\n\tMethod Discard()\r\n\tEndMethod\r\nEndType\r\n\r\n' ***** End mojo.bmax.bmx ******\r\n\r\n","old_contents":"' ***** Start mojo.bmax.bmx ******\r\n\r\nGlobal app:gxtkApp\r\n\r\nType gxtkApp\r\n\tField ginput:gxtkInput\r\n\tField gaudio:gxtkAudio\r\n\tField ggraphics:gxtkGraphics\r\n\r\n\tField dead:Int=0\r\n\tField suspended:Int=0\r\n\tField vloading:Int=0\r\n\tField maxloading:Int=0\r\n\tField updateRate:Int=0\r\n\tField nextUpdate:Float=0\r\n\tField updatePeriod:Float=0\r\n\tField startMillis:Float=0\r\n\t\r\n\tMethod New()' gxtkApp()\r\n\t\tapp=Self\r\n\t\tggraphics=New gxtkGraphics\r\n\tEndMethod\r\n\t\r\n\tMethod Setup()\r\n\t\tginput=New gxtkInput\r\n\t\tgaudio=New gxtkAudio\r\n\r\n\t\tbb_input_SetInputDevice(ginput)\r\n\t\tbb_audio_SetAudioDevice(gaudio)\r\n\t\t\r\n\t\tstartMillis=BlitzMaxMillisecs()\r\n\t\t\r\n\t\tSetFrameRate( 0 )\r\n\t\t\r\n\t\tInvokeOnCreate()\r\n\t\tInvokeOnRender()\r\n\t\tUpdate()\r\n\tEndMethod\r\n\t\r\n\tMethod Update()\r\n\t\tWhile Not AppTerminate()\r\n\t\t\tLocal updates:Int = 0\r\n\t\t\t\r\n\t\t\tLocal cont:Int = 1\r\n\t\t\tWhile (cont)\r\n\t\t\t\tnextUpdate:+updatePeriod\r\n\t\t\t\tInvokeOnUpdate()\r\n\t\t\t\tIf Not updatePeriod Then cont = 0\r\n\t\t\t\tIf nextUpdate>BlitzMaxMillisecs() Then cont = 0\r\n\t\t\t\tupdates:+1\r\n\t\t\t\tIf updates = 7 Then\r\n\t\t\t\t\tnextUpdate = BlitzMaxMillisecs()\r\n\t\t\t\t\tcont = 0\r\n\t\t\t\tEndIf\r\n\t\t\tWend\r\n\t\t\tInvokeOnRender()\r\n\t\tWend\r\n\tEndMethod\r\n\t\r\n\tMethod InvokeOnCreate()\r\n\t\tIf dead Return\r\n\t\tdead = 1\r\n\t\tOnCreate()\r\n\t\tdead = 0\r\n\tEndMethod\r\n\r\n\tMethod InvokeOnUpdate()\r\n\t\tIf dead Or suspended Or Not updateRate Or vloading Return\r\n\t\tOnUpdate()\r\n\tEndMethod\r\n\t\r\n\tMethod InvokeOnRender()\r\n\t\tIf dead Or suspended Return\r\n\t\tggraphics.BeginRender()\r\n\t\tIf vloading\r\n\t\t\tOnLoading()\r\n\t\tElse\r\n\t\t\tOnRender()\r\n\t\tEndIf\r\n\t\tggraphics.EndRender()\r\n\tEndMethod\r\n\t\r\n\t\r\n\tMethod SetFrameRate( fps:Int )\r\n\t\tIf fps\r\n\t\t\tupdatePeriod=1000.0\/fps\r\n\t\t\tnextUpdate=BlitzMaxMillisecs() +updatePeriod\r\n\t\tElse\r\n\t\t\tupdatePeriod=0\r\n\t\tEndIf\r\n\tEndMethod\r\n\r\n\tMethod LoadState:String()\r\n'\t\tvar file:SharedObject=SharedObject.getLocal( \"gxtkapp\" );\r\n'\t\tvar state:String=file.data.state;\r\n'\t\tfile.close();\r\n'\t\tif( state ) return state;\r\n\t\tReturn \"\"\r\n\tEndMethod\r\n\t\r\n\tMethod SaveState:Int( state:String )\r\n'\t\tvar file:SharedObject=SharedObject.getLocal( \"gxtkapp\" );\r\n'\t\tfile.data.state=state;\r\n'\t\tfile.close();\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod LoadString:String( path:String )\r\n\t\tpath = \"data\/\" + path\r\n\t\tReturn LoadText( path )\r\n\tEndMethod\r\n\t\r\n\t' ***** GXTK API *****\r\n\t\r\n\tMethod GraphicsDevice:gxtkGraphics()\r\n\t\tReturn ggraphics\r\n\tEndMethod\r\n\r\n\tMethod InputDevice:gxtkInput()\r\n\t\tReturn ginput\r\n\tEndMethod\r\n\r\n\tMethod AudioDevice:gxtkAudio()\r\n\t\tReturn gaudio\r\n\tEndMethod\r\n\r\n\tMethod SetUpdateRate:Int(hertz:Int)\r\n\t\tupdateRate = hertz\r\n\t\tIf Not vloading Then SetFrameRate(updateRate)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod MilliSecs:Int()\r\n\t\tReturn BlitzMaxMillisecs() - startMillis\r\n\tEndMethod\r\n\t\r\n\tMethod Loading:Int()\r\n\t\tReturn vloading\r\n\tEndMethod\r\n\r\n\tMethod OnCreate:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod OnUpdate:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod OnSuspend:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod OnResume:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod OnRender:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod OnLoading:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkGraphics\r\n\tField gmode:Int = 1\r\n\r\n\tMethod Mode:Int()\r\n\t\tReturn gmode\r\n\tEndMethod\r\n\t\r\n\tMethod Cls:Int(r:Int = 0, g:Int = 0, b:Int = 0)\r\n\t\tBlitzMaxCls(r, g, b)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawPoint:Int(x:Float, y:Float)\r\n\t\tPlot x, y\r\n\tEndMethod\r\n\t\r\n\tMethod LoadSurface:gxtkSurface(path:String)\r\n\t\tLocal image:TImage = LoadImage(\"data\/\"+path)\r\n\t\tIf image Then\r\n\t\t\tLocal gs:gxtkSurface = New gxtkSurface\r\n\t\t\tgs.setImage(image)\r\n\t\t\tReturn gs\r\n\t\tEndIf\r\n\t\tReturn Null\r\n\tEndMethod\r\n\t\r\n\tMethod BeginRender()\r\n\tEndMethod\r\n\t\r\n\tMethod EndRender()\r\n\t\tFlip\r\n\tEndMethod\r\n\t\r\n\tMethod SetColor:Int(r:Int, g:Int, b:Int)\r\n\t\tBlitzMaxSetColor(r, g, b)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod SetAlpha:Int(a:Float)\r\n\t\tBlitzMaxSetAlpha(a)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod SetBlend:Int(blend:Int)\r\n\t\tBlitzMaxSetBlend(blend)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod Width:Int()\r\n\t\tReturn GraphicsWidth()\r\n\tEndMethod\r\n\t\r\n\tMethod Height:Int()\r\n\t\tReturn GraphicsHeight()\r\n\tEndMethod\r\n\t\r\n\tMethod SetScissor:Int(x:Int, y:Int, w:Int, h:Int)\r\n\t\tSetViewport(x, y, w, h) ' NOT TESTED!\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod SetMatrix:Int(ix:Float,iy:Float,jx:Float,jy:Float,tx:Float,ty:Float)\r\n\t\tLocal sx:Float = Sqr( (ix*ix) + (jx*jx) )\r\n\t\tLocal sy:Float = Sqr( (iy*iy) + (jy*jy) )\r\n\t\tLocal rot:Float = -Atan2( jx, ix )\r\n\t\tSetTransform( rot, sx, sy )\r\n\t\tSetOrigin( tx, ty )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawSurface:Int(surface:gxtkSurface,x:Float,y:Float)\r\n\t\tDrawImage(surface.image, x, y, 0)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawSurface2:Int(surface:gxtkSurface,x:Float,y:Float, srcx:Int, srcy:Int, srcw:Int, srch:Int )\r\n\t\tDrawSubImageRect(surface.image, x, y, srcw, srch, srcx, srcy, srcw, srch)\t\t\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawLine:Int( x1:Float,y1:Float,x2:Float,y2:Float )\r\n\t\tBlitzMaxDrawLine(x1, y1, x2, y2)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawOval:Int( x:Float, y:Float, w:Float, h:Float )\r\n\t\tBlitzMaxDrawOval(x, y, w, h)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawPoly:Int(vertices:Float[])\r\n\t\tBlitzMaxDrawPoly( vertices )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawRect:Int( x:Float, y:Float, w:Float, h:Float )\r\n\t\tBlitzMaxDrawRect(x, y, w, h)\r\n\t\tReturn 0\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkInput\r\n\tMethod MouseX:Float()\r\n\t\tReturn BRL.PolledInput.MouseX()\r\n\tEndMethod\r\n\r\n\tMethod MouseY:Float()\r\n\t\tReturn BRL.PolledInput.MouseY()\r\n\tEndMethod\r\n\t\r\n\tMethod KeyDown:Int( key:Int )\r\n\t\tIf( key >= 1 And key <= 3 )\r\n\t\t\tReturn BRL.PolledInput.MouseDown( key )\r\n\t\tEndIf\r\n\t\tReturn BRL.PolledInput.KeyDown( key )\r\n\tEndMethod\r\n\r\n\tMethod KeyHit:Int( key:Int )\r\n\t\tIf( key >= 1 And key <= 3 )\r\n\t\t\tReturn BRL.PolledInput.MouseHit( key )\r\n\t\tEndIf\r\n\t\tReturn BRL.PolledInput.KeyHit( key )\r\n\tEndMethod\r\n\r\n\tMethod GetChar:Int()\r\n\t\tReturn BRL.PolledInput.GetChar()\r\n\tEndMethod\r\n\r\n\tMethod JoyX:Int( index:Int )\r\n\t\tReturn Pub.FreeJoy.JoyX( index )\r\n\tEndMethod\r\n\r\n\tMethod JoyY:Int( index:Int )\r\n\t\tReturn Pub.FreeJoy.JoyY( index )\r\n\tEndMethod\r\n\r\n\tMethod JoyZ:Int( index:Int )\r\n\t\tReturn Pub.FreeJoy.JoyZ( index )\r\n\tEndMethod\r\n\r\n\tMethod TouchX:Float( index:Int )\r\n\t\tReturn BRL.PolledInput.MouseX()\r\n\tEndMethod\r\n\r\n\tMethod TouchY:Float( index:Int )\r\n\t\tReturn BRL.PolledInput.MouseY()\r\n\tEndMethod\r\n\t\r\n\tMethod AccelX:Int()\r\n\t\treturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod AccelY:Int()\r\n\t\treturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod AccelZ:Int()\r\n\t\treturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod SetKeyboardEnabled:Int( enabled:int )\r\n\t\tReturn 0\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkChannel\r\n\tField channel:TChannel\t' null then not playing\r\n\tField sample:gxtkSample\r\n\tField loops:int\r\n\t'Field transform:SoundTransform=new SoundTransform()\r\n\t'Field pausepos:Number\r\n\tField state:int\r\n\t\r\n\tMethod New()\r\n\t\tchannel = New TChannel\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkAudio\r\n\tField amusicState:Int = 0\r\n\tField channels:gxtkChannel[] = New gxtkChannel[33]\r\n\t\r\n\tMethod New()\r\n\t\tFor local i:Int = 0 To 33 - 1\r\n\t\t\tchannels[i] = New gxtkChannel\r\n\t\tNext\r\n\tEndMethod\r\n\t\r\n\tMethod MusicState:Int()\r\n'\t\tIf( musicState = 1 And music.isPlaying() = False )\r\n'\t\t\tmusicState = 0;\r\n'\t\tEndif\r\n\t\tReturn amusicState\r\n\tEndMethod\r\n\t\r\n\tMethod PlayMusic:Int( path:String, flags:Int )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod ChannelState:int( channel:int )\r\n\t\tReturn -1\r\n\tEndMethod\r\n\t\r\n\tMethod StopMusic()\r\n\tEndMethod\r\n\t\r\n\tMethod StopChannel( channel:Int )\r\n\tEndMethod\r\n\r\n\tMethod PlaySample( sound:gxtkSample, channel:Int, flags:Int )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\t\r\n\t\t'If chan.state <> 0 Then chan.channel.Stop() <-- this crashes after the first play!?\r\n\t\t\r\n\t\tchan.sample = sound\r\n\t\t'chan.loops = flags ? 0x7fffffff : 0;\r\n\t\t'chan.channel = sample.sound.play( 0,chan.loops,chan.transform );\r\n\t\t'chan.channel = sound\r\n\t\tchan.state=1\r\n\t\r\n\t\tPlaySound( sound.sound, chan.channel )\r\n\tEndMethod\r\n\r\n\tMethod SetPan( channel:Int, pan:Float )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tchan.channel.SetPan(pan)\r\n\tEndMethod\r\n\r\n\tMethod SetRate( channel:Int, rate:Float )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tchan.channel.SetRate(rate)\r\n\tEndMethod\r\n\r\n\tMethod PauseMusic:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod ResumeMusic:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod SetMusicVolume:Int( volume:Float )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod SetVolume:Int( channel:Int, volume:Float )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tchan.channel.SetVolume(volume)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod LoadSample:gxtkSample( path:String )\r\n\t\tLocal sound:TSound = LoadSound(\"data\/\"+path)\r\n\t\tIf sound Then\r\n\t\t\tLocal gs:gxtkSample = New gxtkSample\r\n\t\t\tgs.setSound(sound)\r\n\t\t\tReturn gs\r\n\t\tEndIf\r\n\t\tReturn Null\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkSample\r\n\tField sound:TSound\r\n\t\r\n\tMethod setSound(sound:TSound)\r\n\t\tSelf.sound = sound\r\n\tEndMethod\r\n\t\r\n\tMethod Discard()\r\n\t\tSelf.sound = null\r\n\tEndMethod\r\nEndType\r\n\r\nFunction BlitzMaxDrawPoly:Int(vertices:Float[])\r\n\tDrawPoly vertices\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxDrawRect:Int( x:Float, y:Float, w:Float, h:Float )\r\n\tDrawRect x, y, w, h\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxDrawOval:Int( x:Float, y:Float, w:Float, h:Float )\r\n\tDrawOval x, y, w, h\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxDrawLine:Int( x1:Float,y1:Float,x2:Float,y2:Float )\r\n\tDrawLine x1, y1, x2, y2\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxMillisecs:Int()\r\n\tReturn MilliSecs()\r\nEndFunction\r\n\r\nFunction BlitzMaxSetColor(r:Int, g:Int, b:Int)\r\n\tSetColor(r, g, b)\r\nEndFunction\r\n\r\nFunction BlitzMaxSetBlend(blend:Int)\r\n\tSelect blend\r\n\t\tCase 0\r\n\t\t\tSetBlend( ALPHABLEND )\r\n\t\tCase 1\r\n\t\t\tSetBlend( LIGHTBLEND )\r\n\tEnd Select\r\nEndFunction\r\n\r\nFunction BlitzMaxSetAlpha(a:Float)\r\n\tSetAlpha(a)\r\nEndFunction\r\n\r\nFunction BlitzMaxCls(r:Int = 0, g:Int = 0, b:Int = 0)\r\n\tSetClsColor(r, g, b)\r\n\tCls\r\nEndFunction\r\n\r\nType gxtkSurface\r\n\tField w:Int, h:Int\r\n\tField image:TImage\r\n\t\r\n\tMethod setImage(image:TImage)\r\n\t\tSelf.image = image\r\n\tEndMethod\r\n\t\r\n\tMethod Width:Int()\r\n\t\tReturn image.Width\r\n\tEndMethod\r\n\t\r\n\tMethod Height:Int()\r\n\t\tReturn image.Height\r\n\tEndMethod\r\n\t\r\n\tMethod Discard()\r\n\tEndMethod\r\nEndType\r\n\r\n' ***** End mojo.bmax.bmx ******\r\n\r\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"b1dc0f4cd675fc409206ef3bdc100b4a7e11e2cf","subject":"FINALLY fixed matrices.... I hope.","message":"FINALLY fixed matrices.... I hope.\n","repos":"swoolcock\/diddy,swoolcock\/diddy,swoolcock\/diddy,swoolcock\/diddy,swoolcock\/diddy","old_file":"monkeymax\/modules\/mojo\/native\/mojo.bmax.bmx","new_file":"monkeymax\/modules\/mojo\/native\/mojo.bmax.bmx","new_contents":"' ***** Start mojo.bmax.bmx ******\r\n\r\nGlobal app:gxtkApp\r\n\r\nType gxtkApp\r\n\tField ginput:gxtkInput\r\n\tField gaudio:gxtkAudio\r\n\tField ggraphics:gxtkGraphics\r\n\r\n\tField dead:Int=0\r\n\tField suspended:Int=0\r\n\tField vloading:Int=0\r\n\tField maxloading:Int=0\r\n\tField updateRate:Int=0\r\n\tField nextUpdate:Float=0\r\n\tField updatePeriod:Float=0\r\n\tField startMillis:Float=0\r\n\t\r\n\tMethod New()' gxtkApp()\r\n\t\tapp=Self\r\n\t\tggraphics=New gxtkGraphics\r\n\tEndMethod\r\n\t\r\n\tMethod Setup()\r\n\t\tginput=New gxtkInput\r\n\t\tgaudio=New gxtkAudio\r\n\r\n\t\tbb_input__1Set_1Input_1Device(ginput)\r\n\t\tbb_audio__1Set_1Audio_1Device(gaudio)\r\n\t\t\r\n\t\tstartMillis=BlitzMaxMillisecs()\r\n\t\t\r\n\t\tSetFrameRate( 0 )\r\n\t\t\r\n\t\tInvokeOnCreate()\r\n\t\tInvokeOnRender()\r\n\t\tUpdate()\r\n\tEndMethod\r\n\t\r\n\tMethod Update()\r\n\t\tWhile Not AppTerminate()\r\n\t\t\tIf Not updatePeriod return\r\n\t\t\tLocal updates:Int = 0\r\n\t\t\t\r\n\t\t\tRepeat\r\n\t\t\t\tnextUpdate:+updatePeriod\r\n\t\t\t\tInvokeOnUpdate()\r\n\t\t\t\tIf Not updatePeriod Then Exit\r\n\t\t\t\tIf nextUpdate>BlitzMaxMillisecs() Then Exit\r\n\t\t\t\tupdates:+1\r\n\t\t\t\tIf updates = 7 Then\r\n\t\t\t\t\tnextUpdate = BlitzMaxMillisecs()\r\n\t\t\t\t\tExit\r\n\t\t\t\tEndIf\r\n\t\t\tForever\r\n\t\t\tInvokeOnRender()\r\n\t\t\tLocal del:Int = nextUpdate - BlitzMaxMillisecs()\r\n\t\t\tIf del < 1 Then del = 1\r\n\t\t\tDelay(del)\r\n\t\tWend\r\n\tEndMethod\r\n\t\r\n\tMethod InvokeOnCreate()\r\n\t\tIf dead Return\r\n\t\tdead = 1\r\n\t\tOnCreate()\r\n\t\tdead = 0\r\n\tEndMethod\r\n\r\n\tMethod InvokeOnUpdate()\r\n\t\tIf dead Or suspended Or Not updateRate Or vloading Return\r\n\t\tOnUpdate()\r\n\tEndMethod\r\n\t\r\n\tMethod InvokeOnRender()\r\n\t\tIf dead Or suspended Return\r\n\t\tggraphics.BeginRender()\r\n\t\tIf vloading\r\n\t\t\tOnLoading()\r\n\t\tElse\r\n\t\t\tOnRender()\r\n\t\tEndIf\r\n\t\tggraphics.EndRender()\r\n\tEndMethod\r\n\t\r\n\t\r\n\tMethod SetFrameRate( fps:Int )\r\n\t\tIf fps\r\n\t\t\tupdatePeriod=1000.0\/fps\r\n\t\t\tnextUpdate=BlitzMaxMillisecs() +updatePeriod\r\n\t\tElse\r\n\t\t\tupdatePeriod=0\r\n\t\tEndIf\r\n\tEndMethod\r\n\r\n\tMethod LoadState:String()\r\n'\t\tvar file:SharedObject=SharedObject.getLocal( \"gxtkapp\" );\r\n'\t\tvar state:String=file.data.state;\r\n'\t\tfile.close();\r\n'\t\tif( state ) return state;\r\n\t\tReturn \"\"\r\n\tEndMethod\r\n\t\r\n\tMethod SaveState:Int( state:String )\r\n'\t\tvar file:SharedObject=SharedObject.getLocal( \"gxtkapp\" );\r\n'\t\tfile.data.state=state;\r\n'\t\tfile.close();\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod LoadString:String( path:String )\r\n\t\tpath = \"data\/\" + path\r\n\t\tReturn LoadText( path )\r\n\tEndMethod\r\n\t\r\n\t' ***** GXTK API *****\r\n\t\r\n\tMethod GraphicsDevice:gxtkGraphics()\r\n\t\tReturn ggraphics\r\n\tEndMethod\r\n\r\n\tMethod InputDevice:gxtkInput()\r\n\t\tReturn ginput\r\n\tEndMethod\r\n\r\n\tMethod AudioDevice:gxtkAudio()\r\n\t\tReturn gaudio\r\n\tEndMethod\r\n\r\n\tMethod SetUpdateRate:Int(hertz:Int)\r\n\t\tupdateRate = hertz\r\n\t\tIf Not vloading Then SetFrameRate(updateRate)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod MilliSecs:Int()\r\n\t\tReturn BlitzMaxMillisecs() - startMillis\r\n\tEndMethod\r\n\t\r\n\tMethod Loading:Int()\r\n\t\tReturn vloading\r\n\tEndMethod\r\n\r\n\tMethod OnCreate:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod OnUpdate:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod OnSuspend:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod OnResume:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod OnRender:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod OnLoading:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkGraphics\r\n\tField gmode:Int = 1\r\n\tField ix:Float=1,iy:Float,jx:Float,jy:Float=1,tx:Float,ty:Float\r\n\tField sx:Float=1,sy:Float=1,rot:Float=0\r\n\t\r\n\tMethod Mode:Int()\r\n\t\tReturn gmode\r\n\tEndMethod\r\n\t\r\n\tMethod Cls:Int(r:Int = 0, g:Int = 0, b:Int = 0)\r\n\t\tBlitzMaxCls(r, g, b)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawPoint:Int(x:Float, y:Float)\r\n\t\tLocal nx:Float = TransX(x,y)\r\n\t\tLocal ny:Float = TransY(x,y)\r\n\t\tPlot nx, ny\r\n\tEndMethod\r\n\t\r\n\tMethod LoadSurface:gxtkSurface(path:String)\r\n\t\tLocal image:TImage = LoadImage(\"data\/\"+path)\r\n\t\tIf image Then\r\n\t\t\tLocal gs:gxtkSurface = New gxtkSurface\r\n\t\t\tgs.setImage(image)\r\n\t\t\tReturn gs\r\n\t\tEndIf\r\n\t\tReturn Null\r\n\tEndMethod\r\n\t\r\n\tMethod BeginRender()\r\n\tEndMethod\r\n\t\r\n\tMethod EndRender()\r\n\t\tFlip\r\n\tEndMethod\r\n\t\r\n\tMethod SetColor:Int(r:Int, g:Int, b:Int)\r\n\t\tBlitzMaxSetColor(r, g, b)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod SetAlpha:Int(a:Float)\r\n\t\tBlitzMaxSetAlpha(a)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod SetBlend:Int(blend:Int)\r\n\t\tBlitzMaxSetBlend(blend)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod Width:Int()\r\n\t\tReturn GraphicsWidth()\r\n\tEndMethod\r\n\t\r\n\tMethod Height:Int()\r\n\t\tReturn GraphicsHeight()\r\n\tEndMethod\r\n\t\r\n\tMethod SetScissor:Int(x:Int, y:Int, w:Int, h:Int)\r\n\t\tSetViewport(x, y, w, h) ' NOT TESTED!\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod TransX:Float(x:Float, y:Float)\r\n\t\tReturn ix*x + jx*y + tx\r\n\tEndMethod\r\n\t\r\n\tMethod TransY:Float(x:Float, y:Float)\r\n\t\tReturn iy*x + jy*y + ty\r\n\tEndMethod\r\n\t\r\n\tMethod SetMatrix:Int(ix:Float,iy:Float,jx:Float,jy:Float,tx:Float,ty:Float)\r\n\t\tSelf.ix = ix ; Self.iy = iy\r\n\t\tSelf.jx = jx ; Self.jy = jy\r\n\t\tSelf.tx = tx ; Self.ty = ty\r\n\t\tsx = Sqr(ix*ix+iy*iy)\r\n\t\tsy = Sqr(jx*jx+jy*jy)\r\n\t\trot = Atan2( iy, ix )\r\n\t\tIf ix < 0 Then\r\n\t\t\tsx = -sx\r\n\t\t\trot :+ 180\r\n\t\tEndIf\r\n\t\tIf jy < 0 Then sy = -sy\r\n\t\tSetTransform( rot, sx, sy )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawSurface:Int(surface:gxtkSurface,x:Float,y:Float)\r\n\t\tLocal nx:Float = TransX(x,y)\r\n\t\tLocal ny:Float = TransY(x,y)\r\n\t\tDrawImage(surface.image, nx, ny, 0)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawSurface2:Int(surface:gxtkSurface,x:Float,y:Float, srcx:Int, srcy:Int, srcw:Int, srch:Int )\r\n\t\tLocal nx:Float = TransX(x,y)\r\n\t\tLocal ny:Float = TransY(x,y)\r\n\t\tDrawSubImageRect(surface.image, nx, ny, srcw, srch, srcx, srcy, srcw, srch)\t\t\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawLine:Int( x1:Float,y1:Float,x2:Float,y2:Float )\r\n\t\tLocal nx1:Float = TransX(x1,y1)\r\n\t\tLocal ny1:Float = TransY(x1,y1)\r\n\t\tLocal nx2:Float = TransX(x2,y2)\r\n\t\tLocal ny2:Float = TransY(x2,y2)\r\n\t\t' Need to reset transform so that BlitzMax doesn't try to apply rotation\r\n\t\tSetTransform( 0, 1, 1 )\r\n\t\tBlitzMaxDrawLine(nx1, ny1, nx2, ny2)\r\n\t\tSetTransform( rot, sx, sy )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawOval:Int( x:Float, y:Float, w:Float, h:Float )\r\n\t\tLocal nx:Float = TransX(x,y)\r\n\t\tLocal ny:Float = TransY(x,y)\r\n\t\tBlitzMaxDrawOval(nx, ny, w, h)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawPoly:Int(vertices:Float[])\r\n\t\t' setting the origin to use the current rotation translation\r\n\t\tSetOrigin(TransX(0,0), TransY(0,0))\r\n\t\tBlitzMaxDrawPoly( vertices )\r\n\t\tSetOrigin(0, 0)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawRect:Int( x:Float, y:Float, w:Float, h:Float )\r\n\t\tLocal nx:Float = TransX(x,y)\r\n\t\tLocal ny:Float = TransY(x,y)\r\n\t\tBlitzMaxDrawRect(nx, ny, w, h)\r\n\t\tReturn 0\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkInput\r\n\tMethod MouseX:Float()\r\n\t\tReturn BRL.PolledInput.MouseX()\r\n\tEndMethod\r\n\r\n\tMethod MouseY:Float()\r\n\t\tReturn BRL.PolledInput.MouseY()\r\n\tEndMethod\r\n\t\r\n\tMethod KeyDown:Int( key:Int )\r\n\t\tif( key = 384 ) key = 1 ' change TOUCH0 to MOUSE_LMB\r\n\r\n\t\tIf( key >= 1 And key <= 3 )\r\n\t\t\tReturn BRL.PolledInput.MouseDown( key )\r\n\t\tEndIf\r\n\t\tIf key < 256\r\n\t\t\tReturn BRL.PolledInput.KeyDown( key )\r\n\t\tElse\r\n\t\t\tReturn 0\r\n\t\tEndIf\r\n\tEndMethod\r\n\r\n\tMethod KeyHit:Int( key:Int )\r\n\t\tif( key = 384 ) key = 1 ' change TOUCH0 to MOUSE_LMB\r\n\t\tIf( key >= 1 And key <= 3 )\r\n\t\t\tReturn BRL.PolledInput.MouseHit( key )\r\n\t\tEndIf\r\n\t\tIf key < 256\r\n\t\t\tReturn BRL.PolledInput.KeyHit( key )\r\n\t\tElse\r\n\t\t\tReturn 0\r\n\t\tEndIf\r\n\tEndMethod\r\n\r\n\tMethod GetChar:Int()\r\n\t\tReturn BRL.PolledInput.GetChar()\r\n\tEndMethod\r\n\r\n\tMethod JoyX:Int( index:Int )\r\n\t\tReturn Pub.FreeJoy.JoyX( index )\r\n\tEndMethod\r\n\r\n\tMethod JoyY:Int( index:Int )\r\n\t\tReturn Pub.FreeJoy.JoyY( index )\r\n\tEndMethod\r\n\r\n\tMethod JoyZ:Int( index:Int )\r\n\t\tReturn Pub.FreeJoy.JoyZ( index )\r\n\tEndMethod\r\n\r\n\tMethod TouchX:Float( index:Int )\r\n\t\tReturn BRL.PolledInput.MouseX()\r\n\tEndMethod\r\n\r\n\tMethod TouchY:Float( index:Int )\r\n\t\tReturn BRL.PolledInput.MouseY()\r\n\tEndMethod\r\n\t\r\n\tMethod AccelX:Int()\r\n\t\treturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod AccelY:Int()\r\n\t\treturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod AccelZ:Int()\r\n\t\treturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod SetKeyboardEnabled:Int( enabled:int )\r\n\t\tReturn 0\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkChannel\r\n\tField channel:TChannel\t' null then not playing\r\n\tField sample:gxtkSample\r\n\tField loops:int\r\n\t'Field transform:SoundTransform=new SoundTransform()\r\n\t'Field pausepos:Number\r\n\tField state:int\r\n\t\r\n\tMethod New()\r\n\t\tchannel = New TChannel\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkAudio\r\n\tField amusicState:Int = 0\r\n\tField channels:gxtkChannel[] = New gxtkChannel[33]\r\n\t\r\n\tMethod New()\r\n\t\tFor local i:Int = 0 To 33 - 1\r\n\t\t\tchannels[i] = New gxtkChannel\r\n\t\tNext\r\n\tEndMethod\r\n\t\r\n\tMethod MusicState:Int()\r\n'\t\tIf( musicState = 1 And music.isPlaying() = False )\r\n'\t\t\tmusicState = 0;\r\n'\t\tEndif\r\n\t\tReturn amusicState\r\n\tEndMethod\r\n\t\r\n\tMethod PlayMusic:Int( path:String, flags:Int )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod ChannelState:int( channel:int )\r\n\t\tReturn -1\r\n\tEndMethod\r\n\t\r\n\tMethod StopMusic()\r\n\tEndMethod\r\n\t\r\n\tMethod StopChannel( channel:Int )\r\n\tEndMethod\r\n\r\n\tMethod PlaySample( sound:gxtkSample, channel:Int, flags:Int )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\t\r\n\t\t'If chan.state <> 0 Then chan.channel.Stop() <-- this crashes after the first play!?\r\n\t\t\r\n\t\tchan.sample = sound\r\n\t\t'chan.loops = flags ? 0x7fffffff : 0;\r\n\t\t'chan.channel = sample.sound.play( 0,chan.loops,chan.transform );\r\n\t\t'chan.channel = sound\r\n\t\tchan.state=1\r\n\t\r\n\t\tPlaySound( sound.sound, chan.channel )\r\n\tEndMethod\r\n\r\n\tMethod SetPan( channel:Int, pan:Float )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tchan.channel.SetPan(pan)\r\n\tEndMethod\r\n\r\n\tMethod SetRate( channel:Int, rate:Float )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tchan.channel.SetRate(rate)\r\n\tEndMethod\r\n\r\n\tMethod PauseMusic:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod ResumeMusic:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod SetMusicVolume:Int( volume:Float )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod SetVolume:Int( channel:Int, volume:Float )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tchan.channel.SetVolume(volume)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod LoadSample:gxtkSample( path:String )\r\n\t\tLocal extension:String = ExtractExt( path)\r\n\t\tIf extension = \"ogg\" Or extension = \"wav\" Then\r\n\t\t\tLocal sound:TSound = LoadSound(\"data\/\"+path)\r\n\t\t\tIf sound Then\r\n\t\t\t\tLocal gs:gxtkSample = New gxtkSample\r\n\t\t\t\tgs.setSound(sound)\r\n\t\t\t\tReturn gs\r\n\t\t\tEndIf\r\n\t\tElse\r\n\t\t\tRuntimeError \"BlitzMax can only use ogg and wav file formats\"\r\n\t\tEndIf\r\n\t\tReturn Null\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkSample\r\n\tField sound:TSound\r\n\t\r\n\tMethod setSound(sound:TSound)\r\n\t\tSelf.sound = sound\r\n\tEndMethod\r\n\t\r\n\tMethod Discard()\r\n\t\tSelf.sound = null\r\n\tEndMethod\r\nEndType\r\n\r\nFunction BlitzMaxDrawPoly:Int(vertices:Float[])\r\n\tDrawPoly vertices\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxDrawRect:Int( x:Float, y:Float, w:Float, h:Float )\r\n\tDrawRect x, y, w, h\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxDrawOval:Int( x:Float, y:Float, w:Float, h:Float )\r\n\tDrawOval x, y, w, h\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxDrawLine:Int( x1:Float,y1:Float,x2:Float,y2:Float )\r\n\tDrawLine x1, y1, x2, y2\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxMillisecs:Int()\r\n\tReturn MilliSecs()\r\nEndFunction\r\n\r\nFunction BlitzMaxSetColor(r:Int, g:Int, b:Int)\r\n\tSetColor(r, g, b)\r\nEndFunction\r\n\r\nFunction BlitzMaxSetBlend(blend:Int)\r\n\tSelect blend\r\n\t\tCase 0\r\n\t\t\tSetBlend( ALPHABLEND )\r\n\t\tCase 1\r\n\t\t\tSetBlend( LIGHTBLEND )\r\n\tEnd Select\r\nEndFunction\r\n\r\nFunction BlitzMaxSetAlpha(a:Float)\r\n\tSetAlpha(a)\r\nEndFunction\r\n\r\nFunction BlitzMaxCls(r:Int = 0, g:Int = 0, b:Int = 0)\r\n\tSetClsColor(r, g, b)\r\n\tCls\r\nEndFunction\r\n\r\nType gxtkSurface\r\n\tField w:Int, h:Int\r\n\tField image:TImage\r\n\t\r\n\tMethod setImage(image:TImage)\r\n\t\tSelf.image = image\r\n\tEndMethod\r\n\t\r\n\tMethod Width:Int()\r\n\t\tReturn image.Width\r\n\tEndMethod\r\n\t\r\n\tMethod Height:Int()\r\n\t\tReturn image.Height\r\n\tEndMethod\r\n\t\r\n\tMethod Discard()\r\n\tEndMethod\r\nEndType\r\n\r\n' ***** End mojo.bmax.bmx ******\r\n\r\n","old_contents":"' ***** Start mojo.bmax.bmx ******\r\n\r\nGlobal app:gxtkApp\r\n\r\nType gxtkApp\r\n\tField ginput:gxtkInput\r\n\tField gaudio:gxtkAudio\r\n\tField ggraphics:gxtkGraphics\r\n\r\n\tField dead:Int=0\r\n\tField suspended:Int=0\r\n\tField vloading:Int=0\r\n\tField maxloading:Int=0\r\n\tField updateRate:Int=0\r\n\tField nextUpdate:Float=0\r\n\tField updatePeriod:Float=0\r\n\tField startMillis:Float=0\r\n\t\r\n\tMethod New()' gxtkApp()\r\n\t\tapp=Self\r\n\t\tggraphics=New gxtkGraphics\r\n\tEndMethod\r\n\t\r\n\tMethod Setup()\r\n\t\tginput=New gxtkInput\r\n\t\tgaudio=New gxtkAudio\r\n\r\n\t\tbb_input__1Set_1Input_1Device(ginput)\r\n\t\tbb_audio__1Set_1Audio_1Device(gaudio)\r\n\t\t\r\n\t\tstartMillis=BlitzMaxMillisecs()\r\n\t\t\r\n\t\tSetFrameRate( 0 )\r\n\t\t\r\n\t\tInvokeOnCreate()\r\n\t\tInvokeOnRender()\r\n\t\tUpdate()\r\n\tEndMethod\r\n\t\r\n\tMethod Update()\r\n\t\tWhile Not AppTerminate()\r\n\t\t\tIf Not updatePeriod return\r\n\t\t\tLocal updates:Int = 0\r\n\t\t\t\r\n\t\t\tRepeat\r\n\t\t\t\tnextUpdate:+updatePeriod\r\n\t\t\t\tInvokeOnUpdate()\r\n\t\t\t\tIf Not updatePeriod Then Exit\r\n\t\t\t\tIf nextUpdate>BlitzMaxMillisecs() Then Exit\r\n\t\t\t\tupdates:+1\r\n\t\t\t\tIf updates = 7 Then\r\n\t\t\t\t\tnextUpdate = BlitzMaxMillisecs()\r\n\t\t\t\t\tExit\r\n\t\t\t\tEndIf\r\n\t\t\tForever\r\n\t\t\tInvokeOnRender()\r\n\t\t\tLocal del:Int = nextUpdate - BlitzMaxMillisecs()\r\n\t\t\tIf del < 1 Then del = 1\r\n\t\t\tDelay(del)\r\n\t\tWend\r\n\tEndMethod\r\n\t\r\n\tMethod InvokeOnCreate()\r\n\t\tIf dead Return\r\n\t\tdead = 1\r\n\t\tOnCreate()\r\n\t\tdead = 0\r\n\tEndMethod\r\n\r\n\tMethod InvokeOnUpdate()\r\n\t\tIf dead Or suspended Or Not updateRate Or vloading Return\r\n\t\tOnUpdate()\r\n\tEndMethod\r\n\t\r\n\tMethod InvokeOnRender()\r\n\t\tIf dead Or suspended Return\r\n\t\tggraphics.BeginRender()\r\n\t\tIf vloading\r\n\t\t\tOnLoading()\r\n\t\tElse\r\n\t\t\tOnRender()\r\n\t\tEndIf\r\n\t\tggraphics.EndRender()\r\n\tEndMethod\r\n\t\r\n\t\r\n\tMethod SetFrameRate( fps:Int )\r\n\t\tIf fps\r\n\t\t\tupdatePeriod=1000.0\/fps\r\n\t\t\tnextUpdate=BlitzMaxMillisecs() +updatePeriod\r\n\t\tElse\r\n\t\t\tupdatePeriod=0\r\n\t\tEndIf\r\n\tEndMethod\r\n\r\n\tMethod LoadState:String()\r\n'\t\tvar file:SharedObject=SharedObject.getLocal( \"gxtkapp\" );\r\n'\t\tvar state:String=file.data.state;\r\n'\t\tfile.close();\r\n'\t\tif( state ) return state;\r\n\t\tReturn \"\"\r\n\tEndMethod\r\n\t\r\n\tMethod SaveState:Int( state:String )\r\n'\t\tvar file:SharedObject=SharedObject.getLocal( \"gxtkapp\" );\r\n'\t\tfile.data.state=state;\r\n'\t\tfile.close();\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod LoadString:String( path:String )\r\n\t\tpath = \"data\/\" + path\r\n\t\tReturn LoadText( path )\r\n\tEndMethod\r\n\t\r\n\t' ***** GXTK API *****\r\n\t\r\n\tMethod GraphicsDevice:gxtkGraphics()\r\n\t\tReturn ggraphics\r\n\tEndMethod\r\n\r\n\tMethod InputDevice:gxtkInput()\r\n\t\tReturn ginput\r\n\tEndMethod\r\n\r\n\tMethod AudioDevice:gxtkAudio()\r\n\t\tReturn gaudio\r\n\tEndMethod\r\n\r\n\tMethod SetUpdateRate:Int(hertz:Int)\r\n\t\tupdateRate = hertz\r\n\t\tIf Not vloading Then SetFrameRate(updateRate)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod MilliSecs:Int()\r\n\t\tReturn BlitzMaxMillisecs() - startMillis\r\n\tEndMethod\r\n\t\r\n\tMethod Loading:Int()\r\n\t\tReturn vloading\r\n\tEndMethod\r\n\r\n\tMethod OnCreate:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod OnUpdate:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod OnSuspend:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod OnResume:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod OnRender:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod OnLoading:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkGraphics\r\n\tField gmode:Int = 1\r\n\tField ix:Float=1,iy:Float,jx:Float,jy:Float=1,tx:Float,ty:Float\r\n\tField sx:Float=1,sy:Float=1,rot:Float=0\r\n\t\r\n\tMethod Mode:Int()\r\n\t\tReturn gmode\r\n\tEndMethod\r\n\t\r\n\tMethod Cls:Int(r:Int = 0, g:Int = 0, b:Int = 0)\r\n\t\tBlitzMaxCls(r, g, b)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawPoint:Int(x:Float, y:Float)\r\n\t\tLocal nx:Float = TransX(x,y)\r\n\t\tLocal ny:Float = TransY(x,y)\r\n\t\tPlot nx, ny\r\n\tEndMethod\r\n\t\r\n\tMethod LoadSurface:gxtkSurface(path:String)\r\n\t\tLocal image:TImage = LoadImage(\"data\/\"+path)\r\n\t\tIf image Then\r\n\t\t\tLocal gs:gxtkSurface = New gxtkSurface\r\n\t\t\tgs.setImage(image)\r\n\t\t\tReturn gs\r\n\t\tEndIf\r\n\t\tReturn Null\r\n\tEndMethod\r\n\t\r\n\tMethod BeginRender()\r\n\tEndMethod\r\n\t\r\n\tMethod EndRender()\r\n\t\tFlip\r\n\tEndMethod\r\n\t\r\n\tMethod SetColor:Int(r:Int, g:Int, b:Int)\r\n\t\tBlitzMaxSetColor(r, g, b)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod SetAlpha:Int(a:Float)\r\n\t\tBlitzMaxSetAlpha(a)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod SetBlend:Int(blend:Int)\r\n\t\tBlitzMaxSetBlend(blend)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod Width:Int()\r\n\t\tReturn GraphicsWidth()\r\n\tEndMethod\r\n\t\r\n\tMethod Height:Int()\r\n\t\tReturn GraphicsHeight()\r\n\tEndMethod\r\n\t\r\n\tMethod SetScissor:Int(x:Int, y:Int, w:Int, h:Int)\r\n\t\tSetViewport(x, y, w, h) ' NOT TESTED!\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod TransX:Float(x:Float, y:Float)\r\n\t\tReturn ix*x + jx*y + tx\r\n\tEndMethod\r\n\t\r\n\tMethod TransY:Float(x:Float, y:Float)\r\n\t\tReturn iy*x + jy*y + ty\r\n\tEndMethod\r\n\t\r\n\tMethod SetMatrix:Int(ix:Float,iy:Float,jx:Float,jy:Float,tx:Float,ty:Float)\r\n\t\tSelf.ix = ix ; Self.iy = iy\r\n\t\tSelf.jx = jx ; Self.jy = jy\r\n\t\tSelf.tx = tx ; Self.ty = ty\r\n\t\tsx = Sqr( (ix*ix) + (jx*jx) )\r\n\t\tsy = Sqr( (iy*iy) + (jy*jy) )\r\n\t\trot = -Atan2( jx, ix )\r\n\t\tSetTransform( rot, sx, sy )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawSurface:Int(surface:gxtkSurface,x:Float,y:Float)\r\n\t\tLocal nx:Float = TransX(x,y)\r\n\t\tLocal ny:Float = TransY(x,y)\r\n\t\tDrawImage(surface.image, nx, ny, 0)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawSurface2:Int(surface:gxtkSurface,x:Float,y:Float, srcx:Int, srcy:Int, srcw:Int, srch:Int )\r\n\t\tLocal nx:Float = TransX(x,y)\r\n\t\tLocal ny:Float = TransY(x,y)\r\n\t\tDrawSubImageRect(surface.image, nx, ny, srcw, srch, srcx, srcy, srcw, srch)\t\t\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawLine:Int( x1:Float,y1:Float,x2:Float,y2:Float )\r\n\t\tLocal nx1:Float = TransX(x1,y1)\r\n\t\tLocal ny1:Float = TransY(x1,y1)\r\n\t\tLocal nx2:Float = TransX(x2,y2)\r\n\t\tLocal ny2:Float = TransY(x2,y2)\r\n\t\t' Need to reset transform so that BlitzMax doesn't try to apply rotation\r\n\t\tSetTransform( 0, 1, 1 )\r\n\t\tBlitzMaxDrawLine(nx1, ny1, nx2, ny2)\r\n\t\tSetTransform( rot, sx, sy )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawOval:Int( x:Float, y:Float, w:Float, h:Float )\r\n\t\tLocal nx:Float = TransX(x,y)\r\n\t\tLocal ny:Float = TransY(x,y)\r\n\t\tBlitzMaxDrawOval(nx, ny, w, h)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawPoly:Int(vertices:Float[])\r\n\t\t' setting the origin to use the current rotation translation\r\n\t\tSetOrigin(TransX(0,0), TransY(0,0))\r\n\t\tBlitzMaxDrawPoly( vertices )\r\n\t\tSetOrigin(0, 0)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawRect:Int( x:Float, y:Float, w:Float, h:Float )\r\n\t\tLocal nx:Float = TransX(x,y)\r\n\t\tLocal ny:Float = TransY(x,y)\r\n\t\tBlitzMaxDrawRect(nx, ny, w, h)\r\n\t\tReturn 0\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkInput\r\n\tMethod MouseX:Float()\r\n\t\tReturn BRL.PolledInput.MouseX()\r\n\tEndMethod\r\n\r\n\tMethod MouseY:Float()\r\n\t\tReturn BRL.PolledInput.MouseY()\r\n\tEndMethod\r\n\t\r\n\tMethod KeyDown:Int( key:Int )\r\n\t\tif( key = 384 ) key = 1 ' change TOUCH0 to MOUSE_LMB\r\n\r\n\t\tIf( key >= 1 And key <= 3 )\r\n\t\t\tReturn BRL.PolledInput.MouseDown( key )\r\n\t\tEndIf\r\n\t\tIf key < 256\r\n\t\t\tReturn BRL.PolledInput.KeyDown( key )\r\n\t\tElse\r\n\t\t\tReturn 0\r\n\t\tEndIf\r\n\tEndMethod\r\n\r\n\tMethod KeyHit:Int( key:Int )\r\n\t\tif( key = 384 ) key = 1 ' change TOUCH0 to MOUSE_LMB\r\n\t\tIf( key >= 1 And key <= 3 )\r\n\t\t\tReturn BRL.PolledInput.MouseHit( key )\r\n\t\tEndIf\r\n\t\tIf key < 256\r\n\t\t\tReturn BRL.PolledInput.KeyHit( key )\r\n\t\tElse\r\n\t\t\tReturn 0\r\n\t\tEndIf\r\n\tEndMethod\r\n\r\n\tMethod GetChar:Int()\r\n\t\tReturn BRL.PolledInput.GetChar()\r\n\tEndMethod\r\n\r\n\tMethod JoyX:Int( index:Int )\r\n\t\tReturn Pub.FreeJoy.JoyX( index )\r\n\tEndMethod\r\n\r\n\tMethod JoyY:Int( index:Int )\r\n\t\tReturn Pub.FreeJoy.JoyY( index )\r\n\tEndMethod\r\n\r\n\tMethod JoyZ:Int( index:Int )\r\n\t\tReturn Pub.FreeJoy.JoyZ( index )\r\n\tEndMethod\r\n\r\n\tMethod TouchX:Float( index:Int )\r\n\t\tReturn BRL.PolledInput.MouseX()\r\n\tEndMethod\r\n\r\n\tMethod TouchY:Float( index:Int )\r\n\t\tReturn BRL.PolledInput.MouseY()\r\n\tEndMethod\r\n\t\r\n\tMethod AccelX:Int()\r\n\t\treturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod AccelY:Int()\r\n\t\treturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod AccelZ:Int()\r\n\t\treturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod SetKeyboardEnabled:Int( enabled:int )\r\n\t\tReturn 0\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkChannel\r\n\tField channel:TChannel\t' null then not playing\r\n\tField sample:gxtkSample\r\n\tField loops:int\r\n\t'Field transform:SoundTransform=new SoundTransform()\r\n\t'Field pausepos:Number\r\n\tField state:int\r\n\t\r\n\tMethod New()\r\n\t\tchannel = New TChannel\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkAudio\r\n\tField amusicState:Int = 0\r\n\tField channels:gxtkChannel[] = New gxtkChannel[33]\r\n\t\r\n\tMethod New()\r\n\t\tFor local i:Int = 0 To 33 - 1\r\n\t\t\tchannels[i] = New gxtkChannel\r\n\t\tNext\r\n\tEndMethod\r\n\t\r\n\tMethod MusicState:Int()\r\n'\t\tIf( musicState = 1 And music.isPlaying() = False )\r\n'\t\t\tmusicState = 0;\r\n'\t\tEndif\r\n\t\tReturn amusicState\r\n\tEndMethod\r\n\t\r\n\tMethod PlayMusic:Int( path:String, flags:Int )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod ChannelState:int( channel:int )\r\n\t\tReturn -1\r\n\tEndMethod\r\n\t\r\n\tMethod StopMusic()\r\n\tEndMethod\r\n\t\r\n\tMethod StopChannel( channel:Int )\r\n\tEndMethod\r\n\r\n\tMethod PlaySample( sound:gxtkSample, channel:Int, flags:Int )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\t\r\n\t\t'If chan.state <> 0 Then chan.channel.Stop() <-- this crashes after the first play!?\r\n\t\t\r\n\t\tchan.sample = sound\r\n\t\t'chan.loops = flags ? 0x7fffffff : 0;\r\n\t\t'chan.channel = sample.sound.play( 0,chan.loops,chan.transform );\r\n\t\t'chan.channel = sound\r\n\t\tchan.state=1\r\n\t\r\n\t\tPlaySound( sound.sound, chan.channel )\r\n\tEndMethod\r\n\r\n\tMethod SetPan( channel:Int, pan:Float )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tchan.channel.SetPan(pan)\r\n\tEndMethod\r\n\r\n\tMethod SetRate( channel:Int, rate:Float )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tchan.channel.SetRate(rate)\r\n\tEndMethod\r\n\r\n\tMethod PauseMusic:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod ResumeMusic:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod SetMusicVolume:Int( volume:Float )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod SetVolume:Int( channel:Int, volume:Float )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tchan.channel.SetVolume(volume)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod LoadSample:gxtkSample( path:String )\r\n\t\tLocal extension:String = ExtractExt( path)\r\n\t\tIf extension = \"ogg\" Or extension = \"wav\" Then\r\n\t\t\tLocal sound:TSound = LoadSound(\"data\/\"+path)\r\n\t\t\tIf sound Then\r\n\t\t\t\tLocal gs:gxtkSample = New gxtkSample\r\n\t\t\t\tgs.setSound(sound)\r\n\t\t\t\tReturn gs\r\n\t\t\tEndIf\r\n\t\tElse\r\n\t\t\tRuntimeError \"BlitzMax can only use ogg and wav file formats\"\r\n\t\tEndIf\r\n\t\tReturn Null\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkSample\r\n\tField sound:TSound\r\n\t\r\n\tMethod setSound(sound:TSound)\r\n\t\tSelf.sound = sound\r\n\tEndMethod\r\n\t\r\n\tMethod Discard()\r\n\t\tSelf.sound = null\r\n\tEndMethod\r\nEndType\r\n\r\nFunction BlitzMaxDrawPoly:Int(vertices:Float[])\r\n\tDrawPoly vertices\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxDrawRect:Int( x:Float, y:Float, w:Float, h:Float )\r\n\tDrawRect x, y, w, h\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxDrawOval:Int( x:Float, y:Float, w:Float, h:Float )\r\n\tDrawOval x, y, w, h\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxDrawLine:Int( x1:Float,y1:Float,x2:Float,y2:Float )\r\n\tDrawLine x1, y1, x2, y2\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxMillisecs:Int()\r\n\tReturn MilliSecs()\r\nEndFunction\r\n\r\nFunction BlitzMaxSetColor(r:Int, g:Int, b:Int)\r\n\tSetColor(r, g, b)\r\nEndFunction\r\n\r\nFunction BlitzMaxSetBlend(blend:Int)\r\n\tSelect blend\r\n\t\tCase 0\r\n\t\t\tSetBlend( ALPHABLEND )\r\n\t\tCase 1\r\n\t\t\tSetBlend( LIGHTBLEND )\r\n\tEnd Select\r\nEndFunction\r\n\r\nFunction BlitzMaxSetAlpha(a:Float)\r\n\tSetAlpha(a)\r\nEndFunction\r\n\r\nFunction BlitzMaxCls(r:Int = 0, g:Int = 0, b:Int = 0)\r\n\tSetClsColor(r, g, b)\r\n\tCls\r\nEndFunction\r\n\r\nType gxtkSurface\r\n\tField w:Int, h:Int\r\n\tField image:TImage\r\n\t\r\n\tMethod setImage(image:TImage)\r\n\t\tSelf.image = image\r\n\tEndMethod\r\n\t\r\n\tMethod Width:Int()\r\n\t\tReturn image.Width\r\n\tEndMethod\r\n\t\r\n\tMethod Height:Int()\r\n\t\tReturn image.Height\r\n\tEndMethod\r\n\t\r\n\tMethod Discard()\r\n\tEndMethod\r\nEndType\r\n\r\n' ***** End mojo.bmax.bmx ******\r\n\r\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"257987e725dcbddaa77c1f08f5886d402e9c8c98","subject":"Added RuntimeError if developer tries to load a non-valid sound format into MonkeyMax","message":"Added RuntimeError if developer tries to load a non-valid sound format into MonkeyMax\n\n--HG--\nextra : convert_revision : svn%3Ae934d3cd-0d57-f34a-94d0-9e8d31ae1c29\/trunk%40355\n","repos":"programmerby\/diddy-mirror,programmerby\/diddy-mirror,programmerby\/diddy-mirror,programmerby\/diddy-mirror","old_file":"monkeymax\/modules\/mojo\/native\/mojo.bmax.bmx","new_file":"monkeymax\/modules\/mojo\/native\/mojo.bmax.bmx","new_contents":"' ***** Start mojo.bmax.bmx ******\r\n\r\nGlobal app:gxtkApp\r\n\r\nType gxtkApp\r\n\tField ginput:gxtkInput\r\n\tField gaudio:gxtkAudio\r\n\tField ggraphics:gxtkGraphics\r\n\r\n\tField dead:Int=0\r\n\tField suspended:Int=0\r\n\tField vloading:Int=0\r\n\tField maxloading:Int=0\r\n\tField updateRate:Int=0\r\n\tField nextUpdate:Float=0\r\n\tField updatePeriod:Float=0\r\n\tField startMillis:Float=0\r\n\t\r\n\tMethod New()' gxtkApp()\r\n\t\tapp=Self\r\n\t\tggraphics=New gxtkGraphics\r\n\tEndMethod\r\n\t\r\n\tMethod Setup()\r\n\t\tginput=New gxtkInput\r\n\t\tgaudio=New gxtkAudio\r\n\r\n\t\tbb_input_SetInputDevice(ginput)\r\n\t\tbb_audio_SetAudioDevice(gaudio)\r\n\t\t\r\n\t\tstartMillis=BlitzMaxMillisecs()\r\n\t\t\r\n\t\tSetFrameRate( 0 )\r\n\t\t\r\n\t\tInvokeOnCreate()\r\n\t\tInvokeOnRender()\r\n\t\tUpdate()\r\n\tEndMethod\r\n\t\r\n\tMethod Update()\r\n\t\tWhile Not AppTerminate()\r\n\t\t\tLocal updates:Int = 0\r\n\t\t\t\r\n\t\t\tLocal cont:Int = 1\r\n\t\t\tWhile (cont)\r\n\t\t\t\tnextUpdate:+updatePeriod\r\n\t\t\t\tInvokeOnUpdate()\r\n\t\t\t\tIf Not updatePeriod Then cont = 0\r\n\t\t\t\tIf nextUpdate>BlitzMaxMillisecs() Then cont = 0\r\n\t\t\t\tupdates:+1\r\n\t\t\t\tIf updates = 7 Then\r\n\t\t\t\t\tnextUpdate = BlitzMaxMillisecs()\r\n\t\t\t\t\tcont = 0\r\n\t\t\t\tEndIf\r\n\t\t\tWend\r\n\t\t\tInvokeOnRender()\r\n\t\tWend\r\n\tEndMethod\r\n\t\r\n\tMethod InvokeOnCreate()\r\n\t\tIf dead Return\r\n\t\tdead = 1\r\n\t\tOnCreate()\r\n\t\tdead = 0\r\n\tEndMethod\r\n\r\n\tMethod InvokeOnUpdate()\r\n\t\tIf dead Or suspended Or Not updateRate Or vloading Return\r\n\t\tOnUpdate()\r\n\tEndMethod\r\n\t\r\n\tMethod InvokeOnRender()\r\n\t\tIf dead Or suspended Return\r\n\t\tggraphics.BeginRender()\r\n\t\tIf vloading\r\n\t\t\tOnLoading()\r\n\t\tElse\r\n\t\t\tOnRender()\r\n\t\tEndIf\r\n\t\tggraphics.EndRender()\r\n\tEndMethod\r\n\t\r\n\t\r\n\tMethod SetFrameRate( fps:Int )\r\n\t\tIf fps\r\n\t\t\tupdatePeriod=1000.0\/fps\r\n\t\t\tnextUpdate=BlitzMaxMillisecs() +updatePeriod\r\n\t\tElse\r\n\t\t\tupdatePeriod=0\r\n\t\tEndIf\r\n\tEndMethod\r\n\r\n\tMethod LoadState:String()\r\n'\t\tvar file:SharedObject=SharedObject.getLocal( \"gxtkapp\" );\r\n'\t\tvar state:String=file.data.state;\r\n'\t\tfile.close();\r\n'\t\tif( state ) return state;\r\n\t\tReturn \"\"\r\n\tEndMethod\r\n\t\r\n\tMethod SaveState:Int( state:String )\r\n'\t\tvar file:SharedObject=SharedObject.getLocal( \"gxtkapp\" );\r\n'\t\tfile.data.state=state;\r\n'\t\tfile.close();\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod LoadString:String( path:String )\r\n\t\tpath = \"data\/\" + path\r\n\t\tReturn LoadText( path )\r\n\tEndMethod\r\n\t\r\n\t' ***** GXTK API *****\r\n\t\r\n\tMethod GraphicsDevice:gxtkGraphics()\r\n\t\tReturn ggraphics\r\n\tEndMethod\r\n\r\n\tMethod InputDevice:gxtkInput()\r\n\t\tReturn ginput\r\n\tEndMethod\r\n\r\n\tMethod AudioDevice:gxtkAudio()\r\n\t\tReturn gaudio\r\n\tEndMethod\r\n\r\n\tMethod SetUpdateRate:Int(hertz:Int)\r\n\t\tupdateRate = hertz\r\n\t\tIf Not vloading Then SetFrameRate(updateRate)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod MilliSecs:Int()\r\n\t\tReturn BlitzMaxMillisecs() - startMillis\r\n\tEndMethod\r\n\t\r\n\tMethod Loading:Int()\r\n\t\tReturn vloading\r\n\tEndMethod\r\n\r\n\tMethod OnCreate:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod OnUpdate:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod OnSuspend:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod OnResume:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod OnRender:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod OnLoading:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkGraphics\r\n\tField gmode:Int = 1\r\n\r\n\tMethod Mode:Int()\r\n\t\tReturn gmode\r\n\tEndMethod\r\n\t\r\n\tMethod Cls:Int(r:Int = 0, g:Int = 0, b:Int = 0)\r\n\t\tBlitzMaxCls(r, g, b)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawPoint:Int(x:Float, y:Float)\r\n\t\tPlot x, y\r\n\tEndMethod\r\n\t\r\n\tMethod LoadSurface:gxtkSurface(path:String)\r\n\t\tLocal image:TImage = LoadImage(\"data\/\"+path)\r\n\t\tIf image Then\r\n\t\t\tLocal gs:gxtkSurface = New gxtkSurface\r\n\t\t\tgs.setImage(image)\r\n\t\t\tReturn gs\r\n\t\tEndIf\r\n\t\tReturn Null\r\n\tEndMethod\r\n\t\r\n\tMethod BeginRender()\r\n\tEndMethod\r\n\t\r\n\tMethod EndRender()\r\n\t\tFlip\r\n\tEndMethod\r\n\t\r\n\tMethod SetColor:Int(r:Int, g:Int, b:Int)\r\n\t\tBlitzMaxSetColor(r, g, b)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod SetAlpha:Int(a:Float)\r\n\t\tBlitzMaxSetAlpha(a)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod SetBlend:Int(blend:Int)\r\n\t\tBlitzMaxSetBlend(blend)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod Width:Int()\r\n\t\tReturn GraphicsWidth()\r\n\tEndMethod\r\n\t\r\n\tMethod Height:Int()\r\n\t\tReturn GraphicsHeight()\r\n\tEndMethod\r\n\t\r\n\tMethod SetScissor:Int(x:Int, y:Int, w:Int, h:Int)\r\n\t\tSetViewport(x, y, w, h) ' NOT TESTED!\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod SetMatrix:Int(ix:Float,iy:Float,jx:Float,jy:Float,tx:Float,ty:Float)\r\n\t\tLocal sx:Float = Sqr( (ix*ix) + (jx*jx) )\r\n\t\tLocal sy:Float = Sqr( (iy*iy) + (jy*jy) )\r\n\t\tLocal rot:Float = -Atan2( jx, ix )\r\n\t\tSetTransform( rot, sx, sy )\r\n\t\tSetOrigin( tx, ty )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawSurface:Int(surface:gxtkSurface,x:Float,y:Float)\r\n\t\tDrawImage(surface.image, x, y, 0)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawSurface2:Int(surface:gxtkSurface,x:Float,y:Float, srcx:Int, srcy:Int, srcw:Int, srch:Int )\r\n\t\tDrawSubImageRect(surface.image, x, y, srcw, srch, srcx, srcy, srcw, srch)\t\t\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawLine:Int( x1:Float,y1:Float,x2:Float,y2:Float )\r\n\t\tBlitzMaxDrawLine(x1, y1, x2, y2)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawOval:Int( x:Float, y:Float, w:Float, h:Float )\r\n\t\tBlitzMaxDrawOval(x, y, w, h)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawPoly:Int(vertices:Float[])\r\n\t\tBlitzMaxDrawPoly( vertices )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawRect:Int( x:Float, y:Float, w:Float, h:Float )\r\n\t\tBlitzMaxDrawRect(x, y, w, h)\r\n\t\tReturn 0\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkInput\r\n\tMethod MouseX:Float()\r\n\t\tReturn BRL.PolledInput.MouseX()\r\n\tEndMethod\r\n\r\n\tMethod MouseY:Float()\r\n\t\tReturn BRL.PolledInput.MouseY()\r\n\tEndMethod\r\n\t\r\n\tMethod KeyDown:Int( key:Int )\r\n\t\tif( key = 384 ) key = 1 ' change TOUCH0 to MOUSE_LMB\r\n\r\n\t\tIf( key >= 1 And key <= 3 )\r\n\t\t\tReturn BRL.PolledInput.MouseDown( key )\r\n\t\tEndIf\r\n\t\tIf key < 256\r\n\t\t\tReturn BRL.PolledInput.KeyDown( key )\r\n\t\tElse\r\n\t\t\tReturn 0\r\n\t\tEndIf\r\n\tEndMethod\r\n\r\n\tMethod KeyHit:Int( key:Int )\r\n\t\tif( key = 384 ) key = 1 ' change TOUCH0 to MOUSE_LMB\r\n\t\tIf( key >= 1 And key <= 3 )\r\n\t\t\tReturn BRL.PolledInput.MouseHit( key )\r\n\t\tEndIf\r\n\t\tIf key < 256\r\n\t\t\tReturn BRL.PolledInput.KeyHit( key )\r\n\t\tElse\r\n\t\t\tReturn 0\r\n\t\tEndIf\r\n\tEndMethod\r\n\r\n\tMethod GetChar:Int()\r\n\t\tReturn BRL.PolledInput.GetChar()\r\n\tEndMethod\r\n\r\n\tMethod JoyX:Int( index:Int )\r\n\t\tReturn Pub.FreeJoy.JoyX( index )\r\n\tEndMethod\r\n\r\n\tMethod JoyY:Int( index:Int )\r\n\t\tReturn Pub.FreeJoy.JoyY( index )\r\n\tEndMethod\r\n\r\n\tMethod JoyZ:Int( index:Int )\r\n\t\tReturn Pub.FreeJoy.JoyZ( index )\r\n\tEndMethod\r\n\r\n\tMethod TouchX:Float( index:Int )\r\n\t\tReturn BRL.PolledInput.MouseX()\r\n\tEndMethod\r\n\r\n\tMethod TouchY:Float( index:Int )\r\n\t\tReturn BRL.PolledInput.MouseY()\r\n\tEndMethod\r\n\t\r\n\tMethod AccelX:Int()\r\n\t\treturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod AccelY:Int()\r\n\t\treturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod AccelZ:Int()\r\n\t\treturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod SetKeyboardEnabled:Int( enabled:int )\r\n\t\tReturn 0\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkChannel\r\n\tField channel:TChannel\t' null then not playing\r\n\tField sample:gxtkSample\r\n\tField loops:int\r\n\t'Field transform:SoundTransform=new SoundTransform()\r\n\t'Field pausepos:Number\r\n\tField state:int\r\n\t\r\n\tMethod New()\r\n\t\tchannel = New TChannel\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkAudio\r\n\tField amusicState:Int = 0\r\n\tField channels:gxtkChannel[] = New gxtkChannel[33]\r\n\t\r\n\tMethod New()\r\n\t\tFor local i:Int = 0 To 33 - 1\r\n\t\t\tchannels[i] = New gxtkChannel\r\n\t\tNext\r\n\tEndMethod\r\n\t\r\n\tMethod MusicState:Int()\r\n'\t\tIf( musicState = 1 And music.isPlaying() = False )\r\n'\t\t\tmusicState = 0;\r\n'\t\tEndif\r\n\t\tReturn amusicState\r\n\tEndMethod\r\n\t\r\n\tMethod PlayMusic:Int( path:String, flags:Int )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod ChannelState:int( channel:int )\r\n\t\tReturn -1\r\n\tEndMethod\r\n\t\r\n\tMethod StopMusic()\r\n\tEndMethod\r\n\t\r\n\tMethod StopChannel( channel:Int )\r\n\tEndMethod\r\n\r\n\tMethod PlaySample( sound:gxtkSample, channel:Int, flags:Int )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\t\r\n\t\t'If chan.state <> 0 Then chan.channel.Stop() <-- this crashes after the first play!?\r\n\t\t\r\n\t\tchan.sample = sound\r\n\t\t'chan.loops = flags ? 0x7fffffff : 0;\r\n\t\t'chan.channel = sample.sound.play( 0,chan.loops,chan.transform );\r\n\t\t'chan.channel = sound\r\n\t\tchan.state=1\r\n\t\r\n\t\tPlaySound( sound.sound, chan.channel )\r\n\tEndMethod\r\n\r\n\tMethod SetPan( channel:Int, pan:Float )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tchan.channel.SetPan(pan)\r\n\tEndMethod\r\n\r\n\tMethod SetRate( channel:Int, rate:Float )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tchan.channel.SetRate(rate)\r\n\tEndMethod\r\n\r\n\tMethod PauseMusic:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod ResumeMusic:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod SetMusicVolume:Int( volume:Float )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod SetVolume:Int( channel:Int, volume:Float )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tchan.channel.SetVolume(volume)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod LoadSample:gxtkSample( path:String )\r\n\t\tLocal extension:String = ExtractExt( path)\r\n\t\tIf extension = \"ogg\" Or extension = \"wav\" Then\r\n\t\t\tLocal sound:TSound = LoadSound(\"data\/\"+path)\r\n\t\t\tIf sound Then\r\n\t\t\t\tLocal gs:gxtkSample = New gxtkSample\r\n\t\t\t\tgs.setSound(sound)\r\n\t\t\t\tReturn gs\r\n\t\t\tEndIf\r\n\t\tElse\r\n\t\t\tRuntimeError \"BlitzMax can only use ogg and wav file formats\"\r\n\t\tEndIf\r\n\t\tReturn Null\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkSample\r\n\tField sound:TSound\r\n\t\r\n\tMethod setSound(sound:TSound)\r\n\t\tSelf.sound = sound\r\n\tEndMethod\r\n\t\r\n\tMethod Discard()\r\n\t\tSelf.sound = null\r\n\tEndMethod\r\nEndType\r\n\r\nFunction BlitzMaxDrawPoly:Int(vertices:Float[])\r\n\tDrawPoly vertices\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxDrawRect:Int( x:Float, y:Float, w:Float, h:Float )\r\n\tDrawRect x, y, w, h\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxDrawOval:Int( x:Float, y:Float, w:Float, h:Float )\r\n\tDrawOval x, y, w, h\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxDrawLine:Int( x1:Float,y1:Float,x2:Float,y2:Float )\r\n\tDrawLine x1, y1, x2, y2\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxMillisecs:Int()\r\n\tReturn MilliSecs()\r\nEndFunction\r\n\r\nFunction BlitzMaxSetColor(r:Int, g:Int, b:Int)\r\n\tSetColor(r, g, b)\r\nEndFunction\r\n\r\nFunction BlitzMaxSetBlend(blend:Int)\r\n\tSelect blend\r\n\t\tCase 0\r\n\t\t\tSetBlend( ALPHABLEND )\r\n\t\tCase 1\r\n\t\t\tSetBlend( LIGHTBLEND )\r\n\tEnd Select\r\nEndFunction\r\n\r\nFunction BlitzMaxSetAlpha(a:Float)\r\n\tSetAlpha(a)\r\nEndFunction\r\n\r\nFunction BlitzMaxCls(r:Int = 0, g:Int = 0, b:Int = 0)\r\n\tSetClsColor(r, g, b)\r\n\tCls\r\nEndFunction\r\n\r\nType gxtkSurface\r\n\tField w:Int, h:Int\r\n\tField image:TImage\r\n\t\r\n\tMethod setImage(image:TImage)\r\n\t\tSelf.image = image\r\n\tEndMethod\r\n\t\r\n\tMethod Width:Int()\r\n\t\tReturn image.Width\r\n\tEndMethod\r\n\t\r\n\tMethod Height:Int()\r\n\t\tReturn image.Height\r\n\tEndMethod\r\n\t\r\n\tMethod Discard()\r\n\tEndMethod\r\nEndType\r\n\r\n' ***** End mojo.bmax.bmx ******\r\n\r\n","old_contents":"' ***** Start mojo.bmax.bmx ******\r\n\r\nGlobal app:gxtkApp\r\n\r\nType gxtkApp\r\n\tField ginput:gxtkInput\r\n\tField gaudio:gxtkAudio\r\n\tField ggraphics:gxtkGraphics\r\n\r\n\tField dead:Int=0\r\n\tField suspended:Int=0\r\n\tField vloading:Int=0\r\n\tField maxloading:Int=0\r\n\tField updateRate:Int=0\r\n\tField nextUpdate:Float=0\r\n\tField updatePeriod:Float=0\r\n\tField startMillis:Float=0\r\n\t\r\n\tMethod New()' gxtkApp()\r\n\t\tapp=Self\r\n\t\tggraphics=New gxtkGraphics\r\n\tEndMethod\r\n\t\r\n\tMethod Setup()\r\n\t\tginput=New gxtkInput\r\n\t\tgaudio=New gxtkAudio\r\n\r\n\t\tbb_input_SetInputDevice(ginput)\r\n\t\tbb_audio_SetAudioDevice(gaudio)\r\n\t\t\r\n\t\tstartMillis=BlitzMaxMillisecs()\r\n\t\t\r\n\t\tSetFrameRate( 0 )\r\n\t\t\r\n\t\tInvokeOnCreate()\r\n\t\tInvokeOnRender()\r\n\t\tUpdate()\r\n\tEndMethod\r\n\t\r\n\tMethod Update()\r\n\t\tWhile Not AppTerminate()\r\n\t\t\tLocal updates:Int = 0\r\n\t\t\t\r\n\t\t\tLocal cont:Int = 1\r\n\t\t\tWhile (cont)\r\n\t\t\t\tnextUpdate:+updatePeriod\r\n\t\t\t\tInvokeOnUpdate()\r\n\t\t\t\tIf Not updatePeriod Then cont = 0\r\n\t\t\t\tIf nextUpdate>BlitzMaxMillisecs() Then cont = 0\r\n\t\t\t\tupdates:+1\r\n\t\t\t\tIf updates = 7 Then\r\n\t\t\t\t\tnextUpdate = BlitzMaxMillisecs()\r\n\t\t\t\t\tcont = 0\r\n\t\t\t\tEndIf\r\n\t\t\tWend\r\n\t\t\tInvokeOnRender()\r\n\t\tWend\r\n\tEndMethod\r\n\t\r\n\tMethod InvokeOnCreate()\r\n\t\tIf dead Return\r\n\t\tdead = 1\r\n\t\tOnCreate()\r\n\t\tdead = 0\r\n\tEndMethod\r\n\r\n\tMethod InvokeOnUpdate()\r\n\t\tIf dead Or suspended Or Not updateRate Or vloading Return\r\n\t\tOnUpdate()\r\n\tEndMethod\r\n\t\r\n\tMethod InvokeOnRender()\r\n\t\tIf dead Or suspended Return\r\n\t\tggraphics.BeginRender()\r\n\t\tIf vloading\r\n\t\t\tOnLoading()\r\n\t\tElse\r\n\t\t\tOnRender()\r\n\t\tEndIf\r\n\t\tggraphics.EndRender()\r\n\tEndMethod\r\n\t\r\n\t\r\n\tMethod SetFrameRate( fps:Int )\r\n\t\tIf fps\r\n\t\t\tupdatePeriod=1000.0\/fps\r\n\t\t\tnextUpdate=BlitzMaxMillisecs() +updatePeriod\r\n\t\tElse\r\n\t\t\tupdatePeriod=0\r\n\t\tEndIf\r\n\tEndMethod\r\n\r\n\tMethod LoadState:String()\r\n'\t\tvar file:SharedObject=SharedObject.getLocal( \"gxtkapp\" );\r\n'\t\tvar state:String=file.data.state;\r\n'\t\tfile.close();\r\n'\t\tif( state ) return state;\r\n\t\tReturn \"\"\r\n\tEndMethod\r\n\t\r\n\tMethod SaveState:Int( state:String )\r\n'\t\tvar file:SharedObject=SharedObject.getLocal( \"gxtkapp\" );\r\n'\t\tfile.data.state=state;\r\n'\t\tfile.close();\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod LoadString:String( path:String )\r\n\t\tpath = \"data\/\" + path\r\n\t\tReturn LoadText( path )\r\n\tEndMethod\r\n\t\r\n\t' ***** GXTK API *****\r\n\t\r\n\tMethod GraphicsDevice:gxtkGraphics()\r\n\t\tReturn ggraphics\r\n\tEndMethod\r\n\r\n\tMethod InputDevice:gxtkInput()\r\n\t\tReturn ginput\r\n\tEndMethod\r\n\r\n\tMethod AudioDevice:gxtkAudio()\r\n\t\tReturn gaudio\r\n\tEndMethod\r\n\r\n\tMethod SetUpdateRate:Int(hertz:Int)\r\n\t\tupdateRate = hertz\r\n\t\tIf Not vloading Then SetFrameRate(updateRate)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod MilliSecs:Int()\r\n\t\tReturn BlitzMaxMillisecs() - startMillis\r\n\tEndMethod\r\n\t\r\n\tMethod Loading:Int()\r\n\t\tReturn vloading\r\n\tEndMethod\r\n\r\n\tMethod OnCreate:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod OnUpdate:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod OnSuspend:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod OnResume:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod OnRender:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod OnLoading:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkGraphics\r\n\tField gmode:Int = 1\r\n\r\n\tMethod Mode:Int()\r\n\t\tReturn gmode\r\n\tEndMethod\r\n\t\r\n\tMethod Cls:Int(r:Int = 0, g:Int = 0, b:Int = 0)\r\n\t\tBlitzMaxCls(r, g, b)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawPoint:Int(x:Float, y:Float)\r\n\t\tPlot x, y\r\n\tEndMethod\r\n\t\r\n\tMethod LoadSurface:gxtkSurface(path:String)\r\n\t\tLocal image:TImage = LoadImage(\"data\/\"+path)\r\n\t\tIf image Then\r\n\t\t\tLocal gs:gxtkSurface = New gxtkSurface\r\n\t\t\tgs.setImage(image)\r\n\t\t\tReturn gs\r\n\t\tEndIf\r\n\t\tReturn Null\r\n\tEndMethod\r\n\t\r\n\tMethod BeginRender()\r\n\tEndMethod\r\n\t\r\n\tMethod EndRender()\r\n\t\tFlip\r\n\tEndMethod\r\n\t\r\n\tMethod SetColor:Int(r:Int, g:Int, b:Int)\r\n\t\tBlitzMaxSetColor(r, g, b)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod SetAlpha:Int(a:Float)\r\n\t\tBlitzMaxSetAlpha(a)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod SetBlend:Int(blend:Int)\r\n\t\tBlitzMaxSetBlend(blend)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod Width:Int()\r\n\t\tReturn GraphicsWidth()\r\n\tEndMethod\r\n\t\r\n\tMethod Height:Int()\r\n\t\tReturn GraphicsHeight()\r\n\tEndMethod\r\n\t\r\n\tMethod SetScissor:Int(x:Int, y:Int, w:Int, h:Int)\r\n\t\tSetViewport(x, y, w, h) ' NOT TESTED!\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod SetMatrix:Int(ix:Float,iy:Float,jx:Float,jy:Float,tx:Float,ty:Float)\r\n\t\tLocal sx:Float = Sqr( (ix*ix) + (jx*jx) )\r\n\t\tLocal sy:Float = Sqr( (iy*iy) + (jy*jy) )\r\n\t\tLocal rot:Float = -Atan2( jx, ix )\r\n\t\tSetTransform( rot, sx, sy )\r\n\t\tSetOrigin( tx, ty )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawSurface:Int(surface:gxtkSurface,x:Float,y:Float)\r\n\t\tDrawImage(surface.image, x, y, 0)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawSurface2:Int(surface:gxtkSurface,x:Float,y:Float, srcx:Int, srcy:Int, srcw:Int, srch:Int )\r\n\t\tDrawSubImageRect(surface.image, x, y, srcw, srch, srcx, srcy, srcw, srch)\t\t\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawLine:Int( x1:Float,y1:Float,x2:Float,y2:Float )\r\n\t\tBlitzMaxDrawLine(x1, y1, x2, y2)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawOval:Int( x:Float, y:Float, w:Float, h:Float )\r\n\t\tBlitzMaxDrawOval(x, y, w, h)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawPoly:Int(vertices:Float[])\r\n\t\tBlitzMaxDrawPoly( vertices )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawRect:Int( x:Float, y:Float, w:Float, h:Float )\r\n\t\tBlitzMaxDrawRect(x, y, w, h)\r\n\t\tReturn 0\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkInput\r\n\tMethod MouseX:Float()\r\n\t\tReturn BRL.PolledInput.MouseX()\r\n\tEndMethod\r\n\r\n\tMethod MouseY:Float()\r\n\t\tReturn BRL.PolledInput.MouseY()\r\n\tEndMethod\r\n\t\r\n\tMethod KeyDown:Int( key:Int )\r\n\t\tif( key = 384 ) key = 1 ' change TOUCH0 to MOUSE_LMB\r\n\r\n\t\tIf( key >= 1 And key <= 3 )\r\n\t\t\tReturn BRL.PolledInput.MouseDown( key )\r\n\t\tEndIf\r\n\t\tIf key < 256\r\n\t\t\tReturn BRL.PolledInput.KeyDown( key )\r\n\t\tElse\r\n\t\t\tReturn 0\r\n\t\tEndIf\r\n\tEndMethod\r\n\r\n\tMethod KeyHit:Int( key:Int )\r\n\t\tif( key = 384 ) key = 1 ' change TOUCH0 to MOUSE_LMB\r\n\t\tIf( key >= 1 And key <= 3 )\r\n\t\t\tReturn BRL.PolledInput.MouseHit( key )\r\n\t\tEndIf\r\n\t\tIf key < 256\r\n\t\t\tReturn BRL.PolledInput.KeyHit( key )\r\n\t\tElse\r\n\t\t\tReturn 0\r\n\t\tEndIf\r\n\tEndMethod\r\n\r\n\tMethod GetChar:Int()\r\n\t\tReturn BRL.PolledInput.GetChar()\r\n\tEndMethod\r\n\r\n\tMethod JoyX:Int( index:Int )\r\n\t\tReturn Pub.FreeJoy.JoyX( index )\r\n\tEndMethod\r\n\r\n\tMethod JoyY:Int( index:Int )\r\n\t\tReturn Pub.FreeJoy.JoyY( index )\r\n\tEndMethod\r\n\r\n\tMethod JoyZ:Int( index:Int )\r\n\t\tReturn Pub.FreeJoy.JoyZ( index )\r\n\tEndMethod\r\n\r\n\tMethod TouchX:Float( index:Int )\r\n\t\tReturn BRL.PolledInput.MouseX()\r\n\tEndMethod\r\n\r\n\tMethod TouchY:Float( index:Int )\r\n\t\tReturn BRL.PolledInput.MouseY()\r\n\tEndMethod\r\n\t\r\n\tMethod AccelX:Int()\r\n\t\treturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod AccelY:Int()\r\n\t\treturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod AccelZ:Int()\r\n\t\treturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod SetKeyboardEnabled:Int( enabled:int )\r\n\t\tReturn 0\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkChannel\r\n\tField channel:TChannel\t' null then not playing\r\n\tField sample:gxtkSample\r\n\tField loops:int\r\n\t'Field transform:SoundTransform=new SoundTransform()\r\n\t'Field pausepos:Number\r\n\tField state:int\r\n\t\r\n\tMethod New()\r\n\t\tchannel = New TChannel\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkAudio\r\n\tField amusicState:Int = 0\r\n\tField channels:gxtkChannel[] = New gxtkChannel[33]\r\n\t\r\n\tMethod New()\r\n\t\tFor local i:Int = 0 To 33 - 1\r\n\t\t\tchannels[i] = New gxtkChannel\r\n\t\tNext\r\n\tEndMethod\r\n\t\r\n\tMethod MusicState:Int()\r\n'\t\tIf( musicState = 1 And music.isPlaying() = False )\r\n'\t\t\tmusicState = 0;\r\n'\t\tEndif\r\n\t\tReturn amusicState\r\n\tEndMethod\r\n\t\r\n\tMethod PlayMusic:Int( path:String, flags:Int )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod ChannelState:int( channel:int )\r\n\t\tReturn -1\r\n\tEndMethod\r\n\t\r\n\tMethod StopMusic()\r\n\tEndMethod\r\n\t\r\n\tMethod StopChannel( channel:Int )\r\n\tEndMethod\r\n\r\n\tMethod PlaySample( sound:gxtkSample, channel:Int, flags:Int )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\t\r\n\t\t'If chan.state <> 0 Then chan.channel.Stop() <-- this crashes after the first play!?\r\n\t\t\r\n\t\tchan.sample = sound\r\n\t\t'chan.loops = flags ? 0x7fffffff : 0;\r\n\t\t'chan.channel = sample.sound.play( 0,chan.loops,chan.transform );\r\n\t\t'chan.channel = sound\r\n\t\tchan.state=1\r\n\t\r\n\t\tPlaySound( sound.sound, chan.channel )\r\n\tEndMethod\r\n\r\n\tMethod SetPan( channel:Int, pan:Float )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tchan.channel.SetPan(pan)\r\n\tEndMethod\r\n\r\n\tMethod SetRate( channel:Int, rate:Float )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tchan.channel.SetRate(rate)\r\n\tEndMethod\r\n\r\n\tMethod PauseMusic:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod ResumeMusic:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod SetMusicVolume:Int( volume:Float )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod SetVolume:Int( channel:Int, volume:Float )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tchan.channel.SetVolume(volume)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod LoadSample:gxtkSample( path:String )\r\n\t\tLocal sound:TSound = LoadSound(\"data\/\"+path)\r\n\t\tIf sound Then\r\n\t\t\tLocal gs:gxtkSample = New gxtkSample\r\n\t\t\tgs.setSound(sound)\r\n\t\t\tReturn gs\r\n\t\tEndIf\r\n\t\tReturn Null\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkSample\r\n\tField sound:TSound\r\n\t\r\n\tMethod setSound(sound:TSound)\r\n\t\tSelf.sound = sound\r\n\tEndMethod\r\n\t\r\n\tMethod Discard()\r\n\t\tSelf.sound = null\r\n\tEndMethod\r\nEndType\r\n\r\nFunction BlitzMaxDrawPoly:Int(vertices:Float[])\r\n\tDrawPoly vertices\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxDrawRect:Int( x:Float, y:Float, w:Float, h:Float )\r\n\tDrawRect x, y, w, h\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxDrawOval:Int( x:Float, y:Float, w:Float, h:Float )\r\n\tDrawOval x, y, w, h\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxDrawLine:Int( x1:Float,y1:Float,x2:Float,y2:Float )\r\n\tDrawLine x1, y1, x2, y2\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxMillisecs:Int()\r\n\tReturn MilliSecs()\r\nEndFunction\r\n\r\nFunction BlitzMaxSetColor(r:Int, g:Int, b:Int)\r\n\tSetColor(r, g, b)\r\nEndFunction\r\n\r\nFunction BlitzMaxSetBlend(blend:Int)\r\n\tSelect blend\r\n\t\tCase 0\r\n\t\t\tSetBlend( ALPHABLEND )\r\n\t\tCase 1\r\n\t\t\tSetBlend( LIGHTBLEND )\r\n\tEnd Select\r\nEndFunction\r\n\r\nFunction BlitzMaxSetAlpha(a:Float)\r\n\tSetAlpha(a)\r\nEndFunction\r\n\r\nFunction BlitzMaxCls(r:Int = 0, g:Int = 0, b:Int = 0)\r\n\tSetClsColor(r, g, b)\r\n\tCls\r\nEndFunction\r\n\r\nType gxtkSurface\r\n\tField w:Int, h:Int\r\n\tField image:TImage\r\n\t\r\n\tMethod setImage(image:TImage)\r\n\t\tSelf.image = image\r\n\tEndMethod\r\n\t\r\n\tMethod Width:Int()\r\n\t\tReturn image.Width\r\n\tEndMethod\r\n\t\r\n\tMethod Height:Int()\r\n\t\tReturn image.Height\r\n\tEndMethod\r\n\t\r\n\tMethod Discard()\r\n\tEndMethod\r\nEndType\r\n\r\n' ***** End mojo.bmax.bmx ******\r\n\r\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"d75d238f5ccf2b3564a5110531b8cf6a4c5a6cd2","subject":"[variables] (v0.18) \tTIdentifier.AddValue now sets the variable's parent to itself \tAdded SetParent and GetParent to TVaraible","message":"[variables] (v0.18)\n\tTIdentifier.AddValue now sets the variable's parent to itself\n\tAdded SetParent and GetParent to TVaraible\n","repos":"komiga\/duct-max,komiga\/duct-max,komiga\/duct-max","old_file":"variables.mod\/variables.bmx","new_file":"variables.mod\/variables.bmx","new_contents":"\nRem\n\tCopyright (c) 2009 Tim Howard\n\t\n\tPermission is hereby granted, free of charge, to any person obtaining a copy\n\tof this software and associated documentation files (the \"Software\"), to deal\n\tin the Software without restriction, including without limitation the rights\n\tto use, copy, modify, merge, publish, distribute, sublicense, and\/or sell\n\tcopies of the Software, and to permit persons to whom the Software is\n\tfurnished to do so, subject to the following conditions:\n\t\n\tThe above copyright notice and this permission notice shall be included in\n\tall copies or substantial portions of the Software.\n\t\n\tTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n\tIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n\tFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n\tAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n\tLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n\tOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n\tTHE SOFTWARE.\n\t-----------------------------------------------------------------------------\n\t\n\tvariables.bmx (Contains: TV_INTEGER, TV_STRING, TV_FLOAT, TV_EVAL,\n\t\t\t\t\t\t\tTVariable, TStringVariable, TFloatVariable, TIntVariable, TEvalVariable, TIdentifier,\n\t\t\t\t\t\t\tTVariableMap, )\n\t\nEnd Rem\n\nSuperStrict\n\nRem\nbbdoc: Variables module\nEnd Rem\nModule duct.variables\n\nModuleInfo \"Version: 0.18\"\nModuleInfo \"Copyright: Tim Howard\"\nModuleInfo \"License: MIT\"\n\nModuleInfo \"History: Version 0.18\"\nModuleInfo \"History: TIdentifier.AddValue now sets the variable's parent to itself\"\nModuleInfo \"History: Added SetParent and GetParent to TVaraible\"\nModuleInfo \"History: Version 0.17\"\nModuleInfo \"History: General cleanup\"\nModuleInfo \"History: Version 0.16\"\nModuleInfo \"History: Added SetAmbiguous to all TVariable types\"\nModuleInfo \"History: Added option to always use quoting with TStringVariables (on by default)\"\nModuleInfo \"History: Fixed TStringVariable.ConvToString returning of Null strings\"\nModuleInfo \"History: Version 0.15\"\nModuleInfo \"History: Change the Create method definition for easier use\"\nModuleInfo \"History: Changed the '\/eval::' recognizer to '\/e:' (as per SNode format change)\"\nModuleInfo \"History: Added the Copy method to every variable type\"\nModuleInfo \"History: Changed some formatting\"\nModuleInfo \"History: Version 0.14\"\nModuleInfo \"History: Changed type tabbing\"\nModuleInfo \"History: Fixed script output for TStringVariable (quotes are now only added if whitespace is present)\"\nModuleInfo \"History: Fixed script output for TIdentifier (identifier names can now contain whitespace, in which case they must be quoted)\"\nModuleInfo \"History: Version 0.13\"\nModuleInfo \"History: Added the DeSerializeUniversal function to TVariable\"\nModuleInfo \"History: Added Serialize and DeSerialize methods to all variable types\"\nModuleInfo \"History: Version 0.12\"\nModuleInfo \"History: Changed module name from 'variablemap' to 'variables'\"\nModuleInfo \"History: Moved all of duct.utilparser here\"\nModuleInfo \"History: Added the GetTVType function to all variable types\"\nModuleInfo \"History: Moved TV_* constants from duct.template here\"\nModuleInfo \"History: Version 0.11\"\nModuleInfo \"History: Added the ReportType function to all variable types\"\nModuleInfo \"History: Version 0.10\"\nModuleInfo \"History: Added the RawToVariable function to TVariable\"\nModuleInfo \"History: General code cleanup\"\nModuleInfo \"History: Version 0.09\"\nModuleInfo \"History: Corrected usage of syntax (in Returns, Cases, News and Selects)\"\nModuleInfo \"History: Version 0.08\"\nModuleInfo \"History: Added the TEvalVariable type\"\nModuleInfo \"History: Initial release\"\n\nImport brl.stream\nImport brl.linkedlist\n\nImport duct.etc\nImport duct.objectmap\n\nRem\n\tbbdoc: Template variable type for the TIntVariable type.\nEnd Rem\nConst TV_INTEGER:Int = 1\nRem\n\tbbdoc: Template variable type for the TTStringVariable type.\nEnd Rem\nConst TV_STRING:Int = 2\nRem\n\tbbdoc: Template variable type for the TFloatVariable type.\nEnd Rem\nConst TV_FLOAT:Int = 3\nRem\n\tbbdoc: Template variable type for the TEvalVariable type.\nEnd Rem\nConst TV_EVAL:Int = 4\nRem\n\tbbdoc: Template variable type for the TIdentifier type.\nEnd Rem\nConst TV_IDEN:Int = 5\n\nRem\n\tbbdoc: The Variable type.\n\tabout: This is the base variable type, you should extend from this to use it.\nEnd Rem\nType TVariable Abstract\n\t\n\tField m_name:String\n\tField m_parent:TVariable\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the variable's name.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetName(name:String)\n\t\tm_name = name\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the variable's name.\n\t\treturns: The variable's name.\n\tEnd Rem\n\tMethod GetName:String()\n\t\tReturn m_name\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the variable's parent.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetParent(parent:TVariable)\n\t\tm_parent = parent\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the variable's parent.\n\t\treturns: The variable's parent.\n\tEnd Rem\n\tMethod GetParent:TVariable()\n\t\tReturn m_parent\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Base method for setting the value of the variable to the given string (conversion).\n\tEnd Rem\n\tMethod SetAmbiguous(value:String) Abstract\n\t\n\tRem\n\t\tbbdoc: Base method for converting variable data to a script-ready string.\n\tEnd Rem\n\tMethod ConvToString:String() Abstract\n\t\n\tRem\n\t\tbbdoc: Base method for converting variable data to a printable\/usable-in-code string.\n\tEnd Rem\n\tMethod ValueAsString:String() Abstract\n\t\n'#end region (Field accessors)\n\t\n'#region Data handling\n\t\n\tRem\n\t\tbbdoc: Create a copy of the variable.\n\t\treturns: A clone of the variable.\n\tEnd Rem\n\tMethod Copy:TVariable() Abstract\n\t\n\tRem\n\t\tbbdoc: Serialize the variable to a stream.\n\t\treturns: Nothing.\n\t\tabout: @tv tells the method whether it should serialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod Serialize(stream:TStream, tv:Int = True, name:Int = False) Abstract\n\t\n\tRem\n\t\tbbdoc: Deserialize the variable from a stream.\n\t\treturns: The deserialized variable.\n\t\tabout: @tv tells the method whether it should deserialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod DeSerialize:TVariable(stream:TStream, tv:Int = True, name:Int = False) Abstract\n\t\n'#end region (Data handling)\n\t\n\tRem\n\t\tbbdoc: Base method: Get the type of this variable.\n\tEnd Rem\n\tFunction ReportType:String() Abstract\n\t\n\tRem\n\t\tbbdoc: Base method: Get the TV_* type of this variable.\n\tEnd Rem\n\tFunction GetTVType:Int() Abstract\n\t\n\tRem\n\t\tbbdoc: Convert raw data (raw data being things like: \"\/eval::(a+b\/0.4181)*a-b\" - an EvalVariable, \"A String variable1!!\", 3452134 - an IntVariable, 1204.00321 - a FloatVariable) into a Variable.\n\t\treturns: A new Variable, or Null if something whacky occured.\n\t\tabout: @etype is optional, it is used to go automagically to one type of a Variable (1 & 4=String (will check for '\/eval::' - EvalVariables), 2=Integer, 3=Float).
\n\t\t@varname is also an optional parameter. It will be used as the name of the variable.\n\tEnd Rem\n\tFunction RawToVariable:TVariable(vraw:String, etype:Int = 0, varname:String = \"\")\n\t\tLocal variable:TVariable\n\t\t\n\t\tIf vraw = Null\n\t\t\tDebugLog(\"(TVariable.RawToVariable) @vraw = Null; returning StringVariable (with @varname and Null value)\")\n\t\t\tReturn New TStringVariable.Create(varname, Null)\n\t\tEnd If\n\t\t\n\t\t'If etype = 1 ' Explicitly a string\n\t\t'\t\n\t\t'\tvariable = TVariable(New TStringVariable.Create(\"\", vraw))\n\t\t'\t\n\t\tIf etype = 0 ' Determine the value's type (must be either integer, double, or a string with no spaces)\n\t\t\tLocal i:Int\n\t\t\t\n\t\t\t' ASCII '0' to '9' = 48-57; '-' = 45, '+' = 43; and '.' = 46\n\t\t\tFor i = 0 To vraw.Length - 1\n\t\t\t\tLocal c:Int\n\t\t\t\t\n\t\t\t\tc = vraw[i]\n\t\t\t\tIf c >= 48 And c <= 57 Or c = 43 Or c = 45\n\t\t\t\t\tIf etype = 0 ' Leave float and string alone\n\t\t\t\t\t\tetype = 2 ' Integer so far..\n\t\t\t\t\tEnd If\n\t\t\t\tElse If c = 46\n\t\t\t\t\tIf etype = 2 ' Already declared as an integer?\n\t\t\t\t\t\tetype = 3\n\t\t\t\t\tEnd If\n\t\t\t\tElse ' If the character is not numerical there is nothing else to deduce and the value is a string\n\t\t\t\t\tetype = 4\n\t\t\t\t\tExit\n\t\t\t\tEnd If\n\t\t\tNext\n\t\t\t\n\t\t\tSelect etype\n\t\t\t\tCase 2 ' Integer\n\t\t\t\t\tvariable = TVariable(New TIntVariable.Create(varname, Int(vraw)))\n\t\t\t\tCase 3 ' Double\/Float\n\t\t\t\t\tvariable = TVariable(New TFloatVariable.Create(varname, Float(vraw)))\n\t\t\t\t'Case 4 ' String - non-explicit\n\t\t\t\t' Local evaltest:Int = vraw.ToLower().Find(\"\/eval::\")\n\t\t\t\t'\t\n\t\t\t\t'\tIf evaltest >= 0\n\t\t\t\t'\t\tvariable = TVariable(New TEvalVariable.Create(varname, vraw[evaltest + 7..]))\n\t\t\t\t'\tElse\n\t\t\t\t'\t\tvariable = TVariable(New TStringVariable.Create(varname, vraw))\n\t\t\t\t'\tEnd If\n\t\t\tEnd Select\n\t\t\t\n\t\tEnd If\n\t\t\n\t\tIf etype = 1 Or etype = 4\n\t\t\tLocal evaltest:Int = vraw.ToLower().Find(\"\/e:\")\n\t\t\tIf evaltest >= 0\n\t\t\t\tvariable = TVariable(New TEvalVariable.Create(varname, vraw[evaltest + 7..]))\n\t\t\tElse\n\t\t\t\tvariable = TVariable(New TStringVariable.Create(varname, vraw))\n\t\t\tEnd If\n\t\tEnd If\n\t\t' DebugLog(\"TSNode.LoadScriptFromStream().RawToVariable(); vraw = ~q\" + vraw + \"~q \\\" + etype)\n\t\t?Debug\n\t\tIf variable = Null Then DebugLog(\"( TVariable.RawToVariable() ) Unknown error, 'variable' is Null.\")\n\t\t?\n\t\tReturn variable\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Universally deserialize a variable from the given stream.\n\t\treturns: A DeSerialized variable.\n\t\tabout: This will deserialize any variable from the stream.
\n\t\tThis requires the variable to have been serialized with the template type (see #Serialize parameters).
\n\t\t@name tells the further DeSerialize calls if the name should be DeSerialized or not.\n\tEnd Rem\n\tFunction DeSerializeUniversal:TVariable(stream:TStream, name:Int = False)\n\t\tLocal tv:Int\n\t\t\n\t\ttv = Int(stream.ReadByte())\n\t\t\n\t\tSelect tv\n\t\t\tCase TV_INTEGER\n\t\t\t\tReturn New TIntVariable.DeSerialize(stream, True, name)\n\t\t\tCase TV_STRING\n\t\t\t\tReturn New TStringVariable.DeSerialize(stream, True, name)\n\t\t\tCase TV_FLOAT\n\t\t\t\tReturn New TFloatVariable.DeSerialize(stream, True, name)\n\t\t\tCase TV_EVAL\n\t\t\t\tReturn New TEvalVariable.DeSerialize(stream, True, name)\n\t\t\tCase TV_IDEN\n\t\t\t\tReturn New TIdentifier.DeSerialize(stream, True, name)\n\t\t\t\t\n\t\t\tDefault\n\t\t\t\tDebugLog(\"(TVariable.DeSerializeUniversal) Failed to recognize the TV in the stream: \" + tv)\n\t\t\t\t\n\t\tEnd Select\n\t\tReturn Null\n\tEnd Function\n\t\nEnd Type\n\nRem\n\tbbdoc: The TStringVariable type.\nEnd Rem\nType TStringVariable Extends TVariable\n\t\n\tGlobal m_alwaysusequotes:Int = True\n\t\n\tField m_value:String\n\t\n\tRem\n\t\tbbdoc: Create a new StringVariable.\n\t\treturns: The new StringVariable (itself).\n\tEnd Rem\n\tMethod Create:TStringVariable(name:String = Null, value:String)\n\t\tSetName(name)\n\t\tSet(value)\n\t\tReturn Self\n\tEnd Method\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the variable's value.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod Set(value:String)\n\t\tm_value = value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the variable's value.\n\t\treturns: The value of the variable.\n\tEnd Rem\n\tMethod Get:String()\n\t\tReturn m_value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the value of the TStringVariable to the given string (ambiguous).\n\t\treturns: Nothing.\n\t\tabout: For this type, this method is no different than calling #Set.\n\tEnd Rem\n\tMethod SetAmbiguous(value:String)\n\t\tm_value = value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Convert the variable to a String.\n\t\treturns: A String representation of the variable.\n\t\tabout: This function is for script output, for in-code use see #ValueAsString.\n\tEnd Rem\n\tMethod ConvToString:String()\n\t\tIf m_alwaysusequotes = True Or m_value.Contains(\"~t\") Or m_value.Contains(\" \") Or m_value = Null\n\t\t\tReturn \"~q\" + m_value + \"~q\"\n\t\tElse\n\t\t\tReturn m_value\n\t\tEnd If\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the StringVariable as a String.\n\t\treturns: The variable's value converted to a String.\n\t\tabout: Here for complete-ness, no difference to `instance.Get()`.\n\tEnd Rem\n\tMethod ValueAsString:String()\n\t\tReturn m_value\n\tEnd Method\n\t\n'#end region (Field accessors)\n\t\n'#region Data handling\n\t\n\tRem\n\t\tbbdoc: Create a copy of the variable\n\t\treturns: A clone of the variable.\n\tEnd Rem\n\tMethod Copy:TStringVariable()\n\t\tReturn New TStringVariable.Create(m_name, m_value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Serialize the variable to a stream.\n\t\treturns: Nothing.\n\t\tabout: @tv tells the method whether it should serialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod Serialize(stream:TStream, tv:Int = True, name:Int = False)\n\t\tIf tv = True\n\t\t\tstream.WriteByte(TV_STRING)\n\t\tEnd If\n\t\tIf name = True\n\t\t\tWriteLString(stream, m_name)\n\t\tEnd If\n\t\t\n\t\tWriteLString(stream, m_value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Deserialize the variable from a stream.\n\t\treturns: The deserialized variable.\n\t\tabout: @tv tells the method whether it should deserialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod DeSerialize:TStringVariable(stream:TStream, tv:Int = True, name:Int = False)\n\t\tIf tv = True\n\t\t\tstream.ReadByte()\n\t\tEnd If\n\t\tIf name = True\n\t\t\tm_name = ReadLString(stream)\n\t\tEnd If\n\t\t\n\t\tm_value = ReadLString(stream)\n\t\tReturn Self\n\tEnd Method\n\t\n'#end region (Data handling)\n\t\n\tRem\n\t\tbbdoc: Get the type of this variable.\n\t\treturns: The type of this variable (\"string\").\n\tEnd Rem\n\tFunction ReportType:String()\n\t\tReturn \"string\"\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Get the TV type of this variable.\n\t\treturns: The TV_* type of this variable (TV_STRING).\n\tEnd Rem\n\tFunction GetTVType:Int()\n\t\tReturn TV_STRING\n\tEnd Function\n\t\nEnd Type\n\nRem\n\tbbdoc: The TFloatVariable type.\nEnd Rem\nType TFloatVariable Extends TVariable\n\t\n\tField m_value:Float\n\t\n\tRem\n\t\tbbdoc: Create a new FloatVariable.\n\t\treturns: The new FloatVariable (itself).\n\tEnd Rem\n\tMethod Create:TFloatVariable(name:String = Null, value:Float)\n\t\tSetName(name)\n\t\tSet(value)\n\t\tReturn Self\n\tEnd Method\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the variable's value.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod Set(value:Float)\n\t\tm_value = value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the variable's value.\n\t\treturns: The value of the variable.\n\tEnd Rem\n\tMethod Get:Float()\n\t\tReturn m_value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the value of the variable to the given string (ambiguous).\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetAmbiguous(value:String)\n\t\tm_value = Float(value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Convert the variable to a String.\n\t\treturns: A scriptable form of the StringVariable.\n\t\tabout: This function is for script output, for in-code use see #ValueAsString.\n\tEnd Rem\n\tMethod ConvToString:String()\n\t\tLocal conv:String = String(m_value), i:Int, encountered:Int\n\t\t\n\t\tFor i = conv.Find(\".\") To conv.Length - 1\n\t\t\tIf conv[i] = 48\n\t\t\t\tIf encountered = True\n\t\t\t\t\tconv = conv[..i]\n\t\t\t\t\tExit\n\t\t\t\tEnd If\n\t\t\tElse If conv[i] <> 46\n\t\t\t\tencountered = True\n\t\t\tEnd If\n\t\tNext\n\t\t\n\t\tReturn conv\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the FloatVariable as a String.\n\t\treturns: The variable's value converted to a String.\n\tEnd Rem\n\tMethod ValueAsString:String()\n\t\tReturn String(m_value)\n\tEnd Method\n\t\n'#end region (Field accessors)\n\t\n'#region Data handling\n\t\n\tRem\n\t\tbbdoc: Create a copy of the variable\n\t\treturns: A clone of the variable.\n\tEnd Rem\n\tMethod Copy:TFloatVariable()\n\t\tReturn New TFloatVariable.Create(m_name, m_value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Serialize the variable to a stream.\n\t\treturns: Nothing.\n\t\tabout: @tv tells the method whether it should serialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod Serialize(stream:TStream, tv:Int = True, name:Int = False)\n\t\tIf tv = True\n\t\t\tstream.WriteByte(TV_FLOAT)\n\t\tEnd If\n\t\tIf name = True\n\t\t\tWriteLString(stream, m_name)\n\t\tEnd If\n\t\tstream.WriteFloat(m_value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Deserialize the variable from a stream.\n\t\treturns: The deserialized variable.\n\t\tabout: @tv tells the method whether it should deserialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod DeSerialize:TFloatVariable(stream:TStream, tv:Int = True, name:Int = False)\n\t\tIf tv = True\n\t\t\tstream.ReadByte()\n\t\tEnd If\n\t\tIf name = True\n\t\t\tm_name = ReadLString(stream)\n\t\tEnd If\n\t\tm_value = stream.ReadFloat()\n\t\tReturn Self\n\tEnd Method\n\t\n'#end region (Data handling)\n\t\n\tRem\n\t\tbbdoc: Get the type of this variable.\n\t\treturns: The type of this variable (\"float\").\n\tEnd Rem\n\tFunction ReportType:String()\n\t\tReturn \"float\"\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Get the TV type of this variable.\n\t\treturns: The TV_* type of this variable (TV_FLOAT).\n\tEnd Rem\n\tFunction GetTVType:Int()\n\t\tReturn TV_FLOAT\n\tEnd Function\n\t\nEnd Type\n\nRem\n\tbbdoc: The TIntVariable type.\nEnd Rem\nType TIntVariable Extends TVariable\n\t\t\n\tField m_value:Int\n\t\n\tRem\n\t\tbbdoc: Create a new IntVariable.\n\t\treturns: The new IntVariable (itself).\n\tEnd Rem\n\tMethod Create:TIntVariable(name:String = Null, value:Int)\n\t\tSetName(name)\n\t\tSet(value)\n\t\tReturn Self\n\tEnd Method\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the variable's value.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod Set(value:Int)\n\t\tm_value = value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the variable's value.\n\t\treturns: The value of the variable.\n\tEnd Rem\n\tMethod Get:Int()\n\t\tReturn m_value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the value of the variable to the given string (ambiguous).\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetAmbiguous(value:String)\n\t\tm_value = Int(value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Convert the variable to a String.\n\t\treturns: A string representation of the variable.\n\t\tabout: This function is for script output, for in-code use see #ValueAsString.\n\tEnd Rem\n\tMethod ConvToString:String()\n\t\tReturn String(m_value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the IntVariable as a String.\n\t\treturns: The variable value converted to a String.\n\tEnd Rem\n\tMethod ValueAsString:String()\n\t\tReturn String(m_value)\n\tEnd Method\n\t\n'#end region (Field accessors)\n\t\n'#region Data handling\n\t\n\tRem\n\t\tbbdoc: Create a copy of the variable\n\t\treturns: A clone of the variable.\n\tEnd Rem\n\tMethod Copy:TIntVariable()\n\t\tReturn New TIntVariable.Create(m_name, m_value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Serialize the variable to a stream.\n\t\treturns: Nothing.\n\t\tabout: @tv tells the method whether it should serialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod Serialize(stream:TStream, tv:Int = True, name:Int = False)\n\t\tIf tv = True\n\t\t\tstream.WriteByte(TV_INTEGER)\n\t\tEnd If\n\t\tIf name = True\n\t\t\tWriteLString(stream, m_name)\n\t\tEnd If\n\t\t\n\t\tstream.WriteInt(m_value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Deserialize the variable from a stream.\n\t\treturns: The deserialized variable.\n\t\tabout: @tv tells the method whether it should deserialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod DeSerialize:TIntVariable(stream:TStream, tv:Int = True, name:Int = False)\n\t\tIf tv = True\n\t\t\tstream.ReadByte()\n\t\tEnd If\n\t\tIf name = True\n\t\t\tm_name = ReadLString(stream)\n\t\tEnd If\n\t\t\n\t\tm_value = stream.ReadInt()\n\t\tReturn Self\n\tEnd Method\n\t\n'#end region (Data handling)\n\t\n\tRem\n\t\tbbdoc: Get the type of this variable.\n\t\treturns: The type of this variable (\"int\").\n\tEnd Rem\n\tFunction ReportType:String()\n\t\tReturn \"int\"\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Get the TV type of this variable.\n\t\treturns: The TV_* type of this variable (TV_INTEGER).\n\tEnd Rem\n\tFunction GetTVType:Int()\n\t\tReturn TV_INTEGER\n\tEnd Function\n\t\nEnd Type\n\n\nRem\n\tbbdoc: The TEvalVariable type.\nEnd Rem\nType TEvalVariable Extends TVariable\n\t\n\tField m_value:String\n\t\n\tRem\n\t\tbbdoc: Create a new EvalVariable.\n\t\treturns: The new EvalVariable (itself).\n\tEnd Rem\n\tMethod Create:TEvalVariable(name:String = Null, value:String)\n\t\tSetName(name)\n\t\tSet(value)\n\t\tReturn Self\n\tEnd Method\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the equation string for the EvalVariable.\n\t\treturns: Nothing\n\tEnd Rem\n\tMethod Set(value:String)\n\t\tm_value = value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the equation string.\n\t\treturns: The equation string.\n\tEnd Rem\n\tMethod Get:String()\n\t\tReturn m_value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the value of the variable to the given string (ambiguous).\n\t\treturns: Nothing.\n\t\tabout: For this type, this method is no different than calling #Set.\n\tEnd Rem\n\tMethod SetAmbiguous(value:String)\n\t\tm_value = value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Convert the EvalVariable to a visual representation of its data.\n\t\treturns: The scriptable form of the EvalVariable.\n\t\tabout: This function is for script output, for in-code use see #ValueAsString.\n\tEnd Rem\n\tMethod ConvToString:String()\n\t\tReturn \"~q\/e:\" + m_value + \"~q\"\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the EvalVariable as a String.\n\t\treturns: The variable value converted to a String.\n\tEnd Rem\n\tMethod ValueAsString:String()\n\t\tReturn m_value\n\tEnd Method\n\t\n'#end region (Field accessors)\n\t\n'#region Data handling\n\t\n\tRem\n\t\tbbdoc: Create a copy of the variable\n\t\treturns: A clone of the variable.\n\tEnd Rem\n\tMethod Copy:TEvalVariable()\n\t\tReturn New TEvalVariable.Create(m_name, m_value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Serialize the variable to a stream.\n\t\treturns: Nothing.\n\t\tabout: @tv tells the method whether it should serialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod Serialize(stream:TStream, tv:Int = True, name:Int = False)\n\t\tIf tv = True\n\t\t\tstream.WriteByte(TV_EVAL)\n\t\tEnd If\n\t\tIf name = True\n\t\t\tWriteLString(stream, m_name)\n\t\tEnd If\n\t\t\n\t\tWriteLString(stream, m_value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Deserialize the variable from a stream.\n\t\treturns: The deserialized variable.\n\t\tabout: @tv tells the method whether it should deserialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod DeSerialize:TEvalVariable(stream:TStream, tv:Int = True, name:Int = False)\n\t\tIf tv = True\n\t\t\tstream.ReadByte()\n\t\tEnd If\n\t\tIf name = True\n\t\t\tm_name = ReadLString(stream)\n\t\tEnd If\n\t\t\n\t\tm_value = ReadLString(stream)\n\t\tReturn Self\n\tEnd Method\n\t\n'#end region (Data handling)\n\t\n\tRem\n\t\tbbdoc: Get the type of this variable.\n\t\treturns: The type of this variable (\"eval\").\n\tEnd Rem\n\tFunction ReportType:String()\n\t\tReturn \"eval\"\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Get the TV type of this variable.\n\t\treturns: The TV_* type of this variable (TV_EVAL).\n\tEnd Rem\n\tFunction GetTVType:Int()\n\t\tReturn TV_EVAL\n\tEnd Function\n\t\nEnd Type\n\nRem\n\tbbdoc: The Identifier type.\nEnd Rem\nType TIdentifier Extends TVariable\n\t\n\tField m_values:TList\n\t\n\tMethod New()\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Create a new Identifier.\n\t\treturns: The new Identfier (itself).\n\tEnd Rem\n\tMethod Create:TIdentifier()\n\t\tm_values = New TList\n\t\tReturn Self\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Create a new Identifier with the given data.\n\t\treturns: The new Identfier (itself).\n\t\tabout: If the @values parameter is Null a new list will be created.\n\tEnd Rem\n\tMethod CreateByData:TIdentifier(name:String, values:TList = Null)\n\t\tSetName(name)\n\t\tIf values = Null\n\t\t\tm_values = New TList\n\t\tElse\n\t\t\tm_values = values\n\t\tEnd If\n\t\tReturn Self\n\tEnd Method\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the Identifier's values.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetValues(values:TList)\n\t\tm_values = values\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the Identifier's values.\n\t\treturns: A list containing the values which the Identifier holds.\n\tEnd Rem\n\tMethod GetValues:TList()\n\t\tReturn m_values\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Deprecated for this type.\n\t\treturns: Nothing.\n\t\tabout: This does nothing.\n\tEnd Rem\n\tMethod SetAmbiguous(value:String)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Convert the identifier to a string.\n\t\treturns: A string representation of the identifier.\n\tEnd Rem\n\tMethod ConvToString:String()\n\t\tLocal op:String, variable:TVariable\n\t\t\n\t\tIf m_name.Contains(\"~t\") = True Or m_name.Contains(\" \") = True\n\t\t\top = \"~q\" + m_name + \"~q \"\n\t\tElse\n\t\t\top = m_name + \" \"\n\t\tEnd If\n\t\t\n\t\tFor variable = EachIn m_values\n\t\t\top:+variable.ConvToString() + \" \"\n\t\tNext\n\t\top = op[..op.Length - 1]\n\t\tReturn op\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the Identifier as a string.\n\t\treturns: The Identifier contents converted to a string.\n\t\tabout: Here for complete-ness, simply calls #ConvToString.\n\tEnd Rem\n\tMethod ValueAsString:String()\n\t\tReturn ConvToString()\n\tEnd Method\n\t\n'#end region (Field accessors)\n\t\n'#region Value handling\n\t\n\tRem\n\t\tbbdoc: Get a value at an index.\n\t\treturns: The value in the identifier's list at the given index, or Null if it could not be retrieved.\n\t\tabout: The index is zero-based.\n\tEnd Rem\n\tMethod GetValueAtIndex:TVariable(index:Int)\n\t\tIf m_values <> Null And index > - 1 And index < m_values.Count()\n\t\t\tReturn TVariable(m_values.ValueAtIndex(index))\n\t\tEnd If\n\t\tReturn Null\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the number of values.\n\t\treturns: The number of values the Identifier contains.\n\tEnd Rem\n\tMethod GetValueCount:Int()\n\t\tIf m_values <> Null\n\t\t\tReturn m_values.Count()\n\t\tEnd If\n\t\tReturn 0\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Add a value to the Identifier.\n\t\treturns: True for success, or False for failure.\n\t\tabout: NOTE: This will set the given value's parent.\n\tEnd Rem\n\tMethod AddValue:Int(value:TVariable)\n\t\tIf m_values <> Null And value <> Null\n\t\t\tm_values.AddLast(value)\n\t\t\tvalue.SetParent(Self)\n\t\t\tReturn True\n\t\tEnd If\n\t\tReturn False\n\tEnd Method\n\t\n'#end region (Value handling)\n\t\n'#region Data handling\n\t\n\tRem\n\t\tbbdoc: Create a copy of the variable\n\t\treturns: A clone of the variable.\n\tEnd Rem\n\tMethod Copy:TIdentifier()\n\t\tLocal clone:TIdentifier\n\t\tclone = New TIdentifier.CreateByData(m_name)\n\t\tFor Local variable:TVariable = EachIn m_values\n\t\t\tclone.AddValue(variable.Copy())\n\t\tNext\n\t\tReturn clone\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Serialize the variable to a stream.\n\t\treturns: Nothing.\n\t\tabout: @tv tells the method whether it should serialize the TV type for the variable, or to not.
\n\t\tIn this case @name tells the method whether it should serialize the values<\/b><\/i>' name (the Identifier's name is always read\/written to the stream).\n\tEnd Rem\n\tMethod Serialize(stream:TStream, tv:Int = True, name:Int = False)\n\t\tLocal variable:TVariable\n\t\t\n\t\tIf tv = True\n\t\t\tstream.WriteByte(TV_STRING)\n\t\tEnd If\n\t\tWriteLString(stream, m_name)\n\t\t\n\t\tIf m_values = Null\n\t\t\tstream.WriteInt(0)\n\t\tElse\n\t\t\tstream.WriteInt(m_values.Count())\n\t\t\tFor variable = EachIn m_values\n\t\t\t\tvariable.Serialize(stream, True, name)\n\t\t\tNext\n\t\tEnd If\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Deserialize the variable from a stream.\n\t\treturns: The deserialized variable.\n\t\tabout: @tv tells the method whether it should deserialize the TV type for the variable, or to not.
\n\t\tIn this case @name tells the method whether it should deserialize the values<\/b><\/i>' name (the Identifier's name is always read\/written to the stream).\n\tEnd Rem\n\tMethod DeSerialize:TIdentifier(stream:TStream, tv:Int = True, name:Int = False)\n\t\tLocal count:Int, n:Int\n\t\t\n\t\tIf tv = True\n\t\t\tstream.ReadByte()\n\t\tEnd If\n\t\tm_name = ReadLString(stream)\n\t\t\n\t\tcount = stream.ReadInt()\n\t\tIf count > 0\n\t\t\tFor n = 0 To count - 1\n\t\t\t\tDeSerializeUniversal(stream, name)\n\t\t\tNext\n\t\tEnd If\n\t\t\n\t\tReturn Self\n\tEnd Method\n\t\n'#end region (Data handling)\n\t\n\tRem\n\t\tbbdoc: Get the type of this variable.\n\t\treturns: The type of this variable (\"identifier\").\n\tEnd Rem\n\tFunction ReportType:String()\n\t\tReturn \"identifier\"\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Get the TV type of this variable.\n\t\treturns: The TV_* type of this variable (TV_IDEN).\n\tEnd Rem\n\tFunction GetTVType:Int()\n\t\tReturn TV_IDEN\n\tEnd Function\n\t\nEnd Type\n\nRem\n\tbbdoc: The VariableMap type.\nEndRem\nType TVariableMap Extends TObjectMap\n\t\n\tRem\n\t\tbbdoc: Create a new VariableMap.\n\t\treturns: The new VariableMap (itself).\n\tEnd Rem\n\tMethod Create:TVariableMap()\n\t\tReturn Self\n\tEnd Method\n\t\n'#region Collections\n\t\n\tRem\n\t\tbbdoc: Insert a variable into the map.\n\t\treturns: True if the variable was added, or False if it was not (the variable's name is Null).\n\tEnd Rem\n\tMethod InsertVariable:Int(variable:TVariable)\n\t\tIf variable.GetName() <> Null\n\t\t\t_Insert(variable.GetName(), variable)\n\t\t\tReturn True\n\t\tEnd If\n\t\tReturn False\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Remove a variable by the name given.\n\t\treturns: True if a variable was removed, or False if it was not (the map contains no variable with the name given).\n\t\tabout: The name is<\/b> case-sensitive.\n\tEnd Rem\n\tMethod RemoveVariableByName:Int(name:String)\n\t\tReturn _Remove(name)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get a variable from the map by its name.\n\t\treturns: The variable object, or if the variable was not found, Null.\n\t\tabout: The name is<\/b> case-sensitive.\n\tEnd Rem\n\tMethod GetVariableByName:TVariable(name:String)\n\t\tReturn TVariable(_ValueByKey(name))\n\tEnd Method\n\t\n'#end region (Collections)\n\t\nEnd Type\n\n","old_contents":"\nRem\n\tCopyright (c) 2009 Tim Howard\n\t\n\tPermission is hereby granted, free of charge, to any person obtaining a copy\n\tof this software and associated documentation files (the \"Software\"), to deal\n\tin the Software without restriction, including without limitation the rights\n\tto use, copy, modify, merge, publish, distribute, sublicense, and\/or sell\n\tcopies of the Software, and to permit persons to whom the Software is\n\tfurnished to do so, subject to the following conditions:\n\t\n\tThe above copyright notice and this permission notice shall be included in\n\tall copies or substantial portions of the Software.\n\t\n\tTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n\tIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n\tFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n\tAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n\tLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n\tOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n\tTHE SOFTWARE.\n\t-----------------------------------------------------------------------------\n\t\n\tvariables.bmx (Contains: TV_INTEGER, TV_STRING, TV_FLOAT, TV_EVAL,\n\t\t\t\t\t\t\tTVariable, TStringVariable, TFloatVariable, TIntVariable, TEvalVariable, TIdentifier,\n\t\t\t\t\t\t\tTVariableMap, )\n\t\nEnd Rem\n\nSuperStrict\n\nRem\nbbdoc: Variables module\nEnd Rem\nModule duct.variables\n\nModuleInfo \"Version: 0.17\"\nModuleInfo \"Copyright: Tim Howard\"\nModuleInfo \"License: MIT\"\n\nModuleInfo \"History: Version 0.17\"\nModuleInfo \"History: General cleanup\"\nModuleInfo \"History: Version 0.16\"\nModuleInfo \"History: Added SetAmbiguous to all TVariable types\"\nModuleInfo \"History: Added option to always use quoting with TStringVariables (on by default)\"\nModuleInfo \"History: Fixed TStringVariable.ConvToString returning of Null strings\"\nModuleInfo \"History: Version 0.15\"\nModuleInfo \"History: Change the Create method definition for easier use\"\nModuleInfo \"History: Changed the '\/eval::' recognizer to '\/e:' (as per SNode format change)\"\nModuleInfo \"History: Added the Copy method to every variable type\"\nModuleInfo \"History: Changed some formatting\"\nModuleInfo \"History: Version 0.14\"\nModuleInfo \"History: Changed type tabbing\"\nModuleInfo \"History: Fixed script output for TStringVariable (quotes are now only added if whitespace is present)\"\nModuleInfo \"History: Fixed script output for TIdentifier (identifier names can now contain whitespace, in which case they must be quoted)\"\nModuleInfo \"History: Version 0.13\"\nModuleInfo \"History: Added the DeSerializeUniversal function to TVariable\"\nModuleInfo \"History: Added Serialize and DeSerialize methods to all variable types\"\nModuleInfo \"History: Version 0.12\"\nModuleInfo \"History: Changed module name from 'variablemap' to 'variables'\"\nModuleInfo \"History: Moved all of duct.utilparser here\"\nModuleInfo \"History: Added the GetTVType function to all variable types\"\nModuleInfo \"History: Moved TV_* constants from duct.template here\"\nModuleInfo \"History: Version 0.11\"\nModuleInfo \"History: Added the ReportType function to all variable types\"\nModuleInfo \"History: Version 0.10\"\nModuleInfo \"History: Added the RawToVariable function to TVariable\"\nModuleInfo \"History: General code cleanup\"\nModuleInfo \"History: Version 0.09\"\nModuleInfo \"History: Corrected usage of syntax (in Returns, Cases, News and Selects)\"\nModuleInfo \"History: Version 0.08\"\nModuleInfo \"History: Added the TEvalVariable type\"\nModuleInfo \"History: Initial release\"\n\nImport brl.stream\nImport brl.linkedlist\n\nImport duct.etc\nImport duct.objectmap\n\nRem\n\tbbdoc: Template variable type for the TIntVariable type.\nEnd Rem\nConst TV_INTEGER:Int = 1\nRem\n\tbbdoc: Template variable type for the TTStringVariable type.\nEnd Rem\nConst TV_STRING:Int = 2\nRem\n\tbbdoc: Template variable type for the TFloatVariable type.\nEnd Rem\nConst TV_FLOAT:Int = 3\nRem\n\tbbdoc: Template variable type for the TEvalVariable type.\nEnd Rem\nConst TV_EVAL:Int = 4\nRem\n\tbbdoc: Template variable type for the TIdentifier type.\nEnd Rem\nConst TV_IDEN:Int = 5\n\nRem\n\tbbdoc: The Variable type.\n\tabout: This is the base variable type, you should extend from this to use it.\nEnd Rem\nType TVariable Abstract\n\t\n\tField m_name:String\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the variable's name.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetName(name:String)\n\t\tm_name = name\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the variable's name.\n\t\treturns: The variable's name.\n\tEnd Rem\n\tMethod GetName:String()\n\t\tReturn m_name\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Base method for setting the value of the variable to the given string (conversion).\n\tEnd Rem\n\tMethod SetAmbiguous(value:String) Abstract\n\t\n\tRem\n\t\tbbdoc: Base method for converting variable data to a script-ready string.\n\tEnd Rem\n\tMethod ConvToString:String() Abstract\n\t\n\tRem\n\t\tbbdoc: Base method for converting variable data to a printable\/usable-in-code string.\n\tEnd Rem\n\tMethod ValueAsString:String() Abstract\n\t\n'#end region (Field accessors)\n\t\n'#region Data handling\n\t\n\tRem\n\t\tbbdoc: Create a copy of the variable.\n\t\treturns: A clone of the variable.\n\tEnd Rem\n\tMethod Copy:TVariable() Abstract\n\t\n\tRem\n\t\tbbdoc: Serialize the variable to a stream.\n\t\treturns: Nothing.\n\t\tabout: @tv tells the method whether it should serialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod Serialize(stream:TStream, tv:Int = True, name:Int = False) Abstract\n\t\n\tRem\n\t\tbbdoc: Deserialize the variable from a stream.\n\t\treturns: The deserialized variable.\n\t\tabout: @tv tells the method whether it should deserialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod DeSerialize:TVariable(stream:TStream, tv:Int = True, name:Int = False) Abstract\n\t\n'#end region (Data handling)\n\t\n\tRem\n\t\tbbdoc: Base method: Get the type of this variable.\n\tEnd Rem\n\tFunction ReportType:String() Abstract\n\t\n\tRem\n\t\tbbdoc: Base method: Get the TV_* type of this variable.\n\tEnd Rem\n\tFunction GetTVType:Int() Abstract\n\t\n\tRem\n\t\tbbdoc: Convert raw data (raw data being things like: \"\/eval::(a+b\/0.4181)*a-b\" - an EvalVariable, \"A String variable1!!\", 3452134 - an IntVariable, 1204.00321 - a FloatVariable) into a Variable.\n\t\treturns: A new Variable, or Null if something whacky occured.\n\t\tabout: @etype is optional, it is used to go automagically to one type of a Variable (1 & 4=String (will check for '\/eval::' - EvalVariables), 2=Integer, 3=Float).
\n\t\t@varname is also an optional parameter. It will be used as the name of the variable.\n\tEnd Rem\n\tFunction RawToVariable:TVariable(vraw:String, etype:Int = 0, varname:String = \"\")\n\t\tLocal variable:TVariable\n\t\t\n\t\tIf vraw = Null\n\t\t\tDebugLog(\"(TVariable.RawToVariable) @vraw = Null; returning StringVariable (with @varname and Null value)\")\n\t\t\tReturn New TStringVariable.Create(varname, Null)\n\t\tEnd If\n\t\t\n\t\t'If etype = 1 ' Explicitly a string\n\t\t'\t\n\t\t'\tvariable = TVariable(New TStringVariable.Create(\"\", vraw))\n\t\t'\t\n\t\tIf etype = 0 ' Determine the value's type (must be either integer, double, or a string with no spaces)\n\t\t\tLocal i:Int\n\t\t\t\n\t\t\t' ASCII '0' to '9' = 48-57; '-' = 45, '+' = 43; and '.' = 46\n\t\t\tFor i = 0 To vraw.Length - 1\n\t\t\t\tLocal c:Int\n\t\t\t\t\n\t\t\t\tc = vraw[i]\n\t\t\t\tIf c >= 48 And c <= 57 Or c = 43 Or c = 45\n\t\t\t\t\tIf etype = 0 ' Leave float and string alone\n\t\t\t\t\t\tetype = 2 ' Integer so far..\n\t\t\t\t\tEnd If\n\t\t\t\tElse If c = 46\n\t\t\t\t\tIf etype = 2 ' Already declared as an integer?\n\t\t\t\t\t\tetype = 3\n\t\t\t\t\tEnd If\n\t\t\t\tElse ' If the character is not numerical there is nothing else to deduce and the value is a string\n\t\t\t\t\tetype = 4\n\t\t\t\t\tExit\n\t\t\t\tEnd If\n\t\t\tNext\n\t\t\t\n\t\t\tSelect etype\n\t\t\t\tCase 2 ' Integer\n\t\t\t\t\tvariable = TVariable(New TIntVariable.Create(varname, Int(vraw)))\n\t\t\t\tCase 3 ' Double\/Float\n\t\t\t\t\tvariable = TVariable(New TFloatVariable.Create(varname, Float(vraw)))\n\t\t\t\t'Case 4 ' String - non-explicit\n\t\t\t\t' Local evaltest:Int = vraw.ToLower().Find(\"\/eval::\")\n\t\t\t\t'\t\n\t\t\t\t'\tIf evaltest >= 0\n\t\t\t\t'\t\tvariable = TVariable(New TEvalVariable.Create(varname, vraw[evaltest + 7..]))\n\t\t\t\t'\tElse\n\t\t\t\t'\t\tvariable = TVariable(New TStringVariable.Create(varname, vraw))\n\t\t\t\t'\tEnd If\n\t\t\tEnd Select\n\t\t\t\n\t\tEnd If\n\t\t\n\t\tIf etype = 1 Or etype = 4\n\t\t\tLocal evaltest:Int = vraw.ToLower().Find(\"\/e:\")\n\t\t\tIf evaltest >= 0\n\t\t\t\tvariable = TVariable(New TEvalVariable.Create(varname, vraw[evaltest + 7..]))\n\t\t\tElse\n\t\t\t\tvariable = TVariable(New TStringVariable.Create(varname, vraw))\n\t\t\tEnd If\n\t\tEnd If\n\t\t' DebugLog(\"TSNode.LoadScriptFromStream().RawToVariable(); vraw = ~q\" + vraw + \"~q \\\" + etype)\n\t\t?Debug\n\t\tIf variable = Null Then DebugLog(\"( TVariable.RawToVariable() ) Unknown error, 'variable' is Null.\")\n\t\t?\n\t\tReturn variable\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Universally deserialize a variable from the given stream.\n\t\treturns: A DeSerialized variable.\n\t\tabout: This will deserialize any variable from the stream.
\n\t\tThis requires the variable to have been serialized with the template type (see #Serialize parameters).
\n\t\t@name tells the further DeSerialize calls if the name should be DeSerialized or not.\n\tEnd Rem\n\tFunction DeSerializeUniversal:TVariable(stream:TStream, name:Int = False)\n\t\tLocal tv:Int\n\t\t\n\t\ttv = Int(stream.ReadByte())\n\t\t\n\t\tSelect tv\n\t\t\tCase TV_INTEGER\n\t\t\t\tReturn New TIntVariable.DeSerialize(stream, True, name)\n\t\t\tCase TV_STRING\n\t\t\t\tReturn New TStringVariable.DeSerialize(stream, True, name)\n\t\t\tCase TV_FLOAT\n\t\t\t\tReturn New TFloatVariable.DeSerialize(stream, True, name)\n\t\t\tCase TV_EVAL\n\t\t\t\tReturn New TEvalVariable.DeSerialize(stream, True, name)\n\t\t\tCase TV_IDEN\n\t\t\t\tReturn New TIdentifier.DeSerialize(stream, True, name)\n\t\t\t\t\n\t\t\tDefault\n\t\t\t\tDebugLog(\"(TVariable.DeSerializeUniversal) Failed to recognize the TV in the stream: \" + tv)\n\t\t\t\t\n\t\tEnd Select\n\t\tReturn Null\n\tEnd Function\n\t\nEnd Type\n\nRem\n\tbbdoc: The TStringVariable type.\nEnd Rem\nType TStringVariable Extends TVariable\n\t\n\tGlobal m_alwaysusequotes:Int = True\n\t\n\tField m_value:String\n\t\n\tRem\n\t\tbbdoc: Create a new StringVariable.\n\t\treturns: The new StringVariable (itself).\n\tEnd Rem\n\tMethod Create:TStringVariable(name:String = Null, value:String)\n\t\tSetName(name)\n\t\tSet(value)\n\t\tReturn Self\n\tEnd Method\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the variable's value.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod Set(value:String)\n\t\tm_value = value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the variable's value.\n\t\treturns: The value of the variable.\n\tEnd Rem\n\tMethod Get:String()\n\t\tReturn m_value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the value of the TStringVariable to the given string (ambiguous).\n\t\treturns: Nothing.\n\t\tabout: For this type, this method is no different than calling #Set.\n\tEnd Rem\n\tMethod SetAmbiguous(value:String)\n\t\tm_value = value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Convert the variable to a String.\n\t\treturns: A String representation of the variable.\n\t\tabout: This function is for script output, for in-code use see #ValueAsString.\n\tEnd Rem\n\tMethod ConvToString:String()\n\t\tIf m_alwaysusequotes = True Or m_value.Contains(\"~t\") Or m_value.Contains(\" \") Or m_value = Null\n\t\t\tReturn \"~q\" + m_value + \"~q\"\n\t\tElse\n\t\t\tReturn m_value\n\t\tEnd If\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the StringVariable as a String.\n\t\treturns: The variable's value converted to a String.\n\t\tabout: Here for complete-ness, no difference to `instance.Get()`.\n\tEnd Rem\n\tMethod ValueAsString:String()\n\t\tReturn m_value\n\tEnd Method\n\t\n'#end region (Field accessors)\n\t\n'#region Data handling\n\t\n\tRem\n\t\tbbdoc: Create a copy of the variable\n\t\treturns: A clone of the variable.\n\tEnd Rem\n\tMethod Copy:TStringVariable()\n\t\tReturn New TStringVariable.Create(m_name, m_value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Serialize the variable to a stream.\n\t\treturns: Nothing.\n\t\tabout: @tv tells the method whether it should serialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod Serialize(stream:TStream, tv:Int = True, name:Int = False)\n\t\tIf tv = True\n\t\t\tstream.WriteByte(TV_STRING)\n\t\tEnd If\n\t\tIf name = True\n\t\t\tWriteLString(stream, m_name)\n\t\tEnd If\n\t\t\n\t\tWriteLString(stream, m_value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Deserialize the variable from a stream.\n\t\treturns: The deserialized variable.\n\t\tabout: @tv tells the method whether it should deserialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod DeSerialize:TStringVariable(stream:TStream, tv:Int = True, name:Int = False)\n\t\tIf tv = True\n\t\t\tstream.ReadByte()\n\t\tEnd If\n\t\tIf name = True\n\t\t\tm_name = ReadLString(stream)\n\t\tEnd If\n\t\t\n\t\tm_value = ReadLString(stream)\n\t\tReturn Self\n\tEnd Method\n\t\n'#end region (Data handling)\n\t\n\tRem\n\t\tbbdoc: Get the type of this variable.\n\t\treturns: The type of this variable (\"string\").\n\tEnd Rem\n\tFunction ReportType:String()\n\t\tReturn \"string\"\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Get the TV type of this variable.\n\t\treturns: The TV_* type of this variable (TV_STRING).\n\tEnd Rem\n\tFunction GetTVType:Int()\n\t\tReturn TV_STRING\n\tEnd Function\n\t\nEnd Type\n\nRem\n\tbbdoc: The TFloatVariable type.\nEnd Rem\nType TFloatVariable Extends TVariable\n\t\n\tField m_value:Float\n\t\n\tRem\n\t\tbbdoc: Create a new FloatVariable.\n\t\treturns: The new FloatVariable (itself).\n\tEnd Rem\n\tMethod Create:TFloatVariable(name:String = Null, value:Float)\n\t\tSetName(name)\n\t\tSet(value)\n\t\tReturn Self\n\tEnd Method\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the variable's value.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod Set(value:Float)\n\t\tm_value = value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the variable's value.\n\t\treturns: The value of the variable.\n\tEnd Rem\n\tMethod Get:Float()\n\t\tReturn m_value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the value of the variable to the given string (ambiguous).\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetAmbiguous(value:String)\n\t\tm_value = Float(value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Convert the variable to a String.\n\t\treturns: A scriptable form of the StringVariable.\n\t\tabout: This function is for script output, for in-code use see #ValueAsString.\n\tEnd Rem\n\tMethod ConvToString:String()\n\t\tLocal conv:String = String(m_value), i:Int, encountered:Int\n\t\t\n\t\tFor i = conv.Find(\".\") To conv.Length - 1\n\t\t\tIf conv[i] = 48\n\t\t\t\tIf encountered = True\n\t\t\t\t\tconv = conv[..i]\n\t\t\t\t\tExit\n\t\t\t\tEnd If\n\t\t\tElse If conv[i] <> 46\n\t\t\t\tencountered = True\n\t\t\tEnd If\n\t\tNext\n\t\t\n\t\tReturn conv\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the FloatVariable as a String.\n\t\treturns: The variable's value converted to a String.\n\tEnd Rem\n\tMethod ValueAsString:String()\n\t\tReturn String(m_value)\n\tEnd Method\n\t\n'#end region (Field accessors)\n\t\n'#region Data handling\n\t\n\tRem\n\t\tbbdoc: Create a copy of the variable\n\t\treturns: A clone of the variable.\n\tEnd Rem\n\tMethod Copy:TFloatVariable()\n\t\tReturn New TFloatVariable.Create(m_name, m_value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Serialize the variable to a stream.\n\t\treturns: Nothing.\n\t\tabout: @tv tells the method whether it should serialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod Serialize(stream:TStream, tv:Int = True, name:Int = False)\n\t\tIf tv = True\n\t\t\tstream.WriteByte(TV_FLOAT)\n\t\tEnd If\n\t\tIf name = True\n\t\t\tWriteLString(stream, m_name)\n\t\tEnd If\n\t\tstream.WriteFloat(m_value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Deserialize the variable from a stream.\n\t\treturns: The deserialized variable.\n\t\tabout: @tv tells the method whether it should deserialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod DeSerialize:TFloatVariable(stream:TStream, tv:Int = True, name:Int = False)\n\t\tIf tv = True\n\t\t\tstream.ReadByte()\n\t\tEnd If\n\t\tIf name = True\n\t\t\tm_name = ReadLString(stream)\n\t\tEnd If\n\t\tm_value = stream.ReadFloat()\n\t\tReturn Self\n\tEnd Method\n\t\n'#end region (Data handling)\n\t\n\tRem\n\t\tbbdoc: Get the type of this variable.\n\t\treturns: The type of this variable (\"float\").\n\tEnd Rem\n\tFunction ReportType:String()\n\t\tReturn \"float\"\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Get the TV type of this variable.\n\t\treturns: The TV_* type of this variable (TV_FLOAT).\n\tEnd Rem\n\tFunction GetTVType:Int()\n\t\tReturn TV_FLOAT\n\tEnd Function\n\t\nEnd Type\n\nRem\n\tbbdoc: The TIntVariable type.\nEnd Rem\nType TIntVariable Extends TVariable\n\t\t\n\tField m_value:Int\n\t\n\tRem\n\t\tbbdoc: Create a new IntVariable.\n\t\treturns: The new IntVariable (itself).\n\tEnd Rem\n\tMethod Create:TIntVariable(name:String = Null, value:Int)\n\t\tSetName(name)\n\t\tSet(value)\n\t\tReturn Self\n\tEnd Method\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the variable's value.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod Set(value:Int)\n\t\tm_value = value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the variable's value.\n\t\treturns: The value of the variable.\n\tEnd Rem\n\tMethod Get:Int()\n\t\tReturn m_value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the value of the variable to the given string (ambiguous).\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetAmbiguous(value:String)\n\t\tm_value = Int(value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Convert the variable to a String.\n\t\treturns: A string representation of the variable.\n\t\tabout: This function is for script output, for in-code use see #ValueAsString.\n\tEnd Rem\n\tMethod ConvToString:String()\n\t\tReturn String(m_value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the IntVariable as a String.\n\t\treturns: The variable value converted to a String.\n\tEnd Rem\n\tMethod ValueAsString:String()\n\t\tReturn String(m_value)\n\tEnd Method\n\t\n'#end region (Field accessors)\n\t\n'#region Data handling\n\t\n\tRem\n\t\tbbdoc: Create a copy of the variable\n\t\treturns: A clone of the variable.\n\tEnd Rem\n\tMethod Copy:TIntVariable()\n\t\tReturn New TIntVariable.Create(m_name, m_value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Serialize the variable to a stream.\n\t\treturns: Nothing.\n\t\tabout: @tv tells the method whether it should serialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod Serialize(stream:TStream, tv:Int = True, name:Int = False)\n\t\tIf tv = True\n\t\t\tstream.WriteByte(TV_INTEGER)\n\t\tEnd If\n\t\tIf name = True\n\t\t\tWriteLString(stream, m_name)\n\t\tEnd If\n\t\t\n\t\tstream.WriteInt(m_value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Deserialize the variable from a stream.\n\t\treturns: The deserialized variable.\n\t\tabout: @tv tells the method whether it should deserialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod DeSerialize:TIntVariable(stream:TStream, tv:Int = True, name:Int = False)\n\t\tIf tv = True\n\t\t\tstream.ReadByte()\n\t\tEnd If\n\t\tIf name = True\n\t\t\tm_name = ReadLString(stream)\n\t\tEnd If\n\t\t\n\t\tm_value = stream.ReadInt()\n\t\tReturn Self\n\tEnd Method\n\t\n'#end region (Data handling)\n\t\n\tRem\n\t\tbbdoc: Get the type of this variable.\n\t\treturns: The type of this variable (\"int\").\n\tEnd Rem\n\tFunction ReportType:String()\n\t\tReturn \"int\"\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Get the TV type of this variable.\n\t\treturns: The TV_* type of this variable (TV_INTEGER).\n\tEnd Rem\n\tFunction GetTVType:Int()\n\t\tReturn TV_INTEGER\n\tEnd Function\n\t\nEnd Type\n\n\nRem\n\tbbdoc: The TEvalVariable type.\nEnd Rem\nType TEvalVariable Extends TVariable\n\t\n\tField m_value:String\n\t\n\tRem\n\t\tbbdoc: Create a new EvalVariable.\n\t\treturns: The new EvalVariable (itself).\n\tEnd Rem\n\tMethod Create:TEvalVariable(name:String = Null, value:String)\n\t\tSetName(name)\n\t\tSet(value)\n\t\tReturn Self\n\tEnd Method\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the equation string for the EvalVariable.\n\t\treturns: Nothing\n\tEnd Rem\n\tMethod Set(value:String)\n\t\tm_value = value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the equation string.\n\t\treturns: The equation string.\n\tEnd Rem\n\tMethod Get:String()\n\t\tReturn m_value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Set the value of the variable to the given string (ambiguous).\n\t\treturns: Nothing.\n\t\tabout: For this type, this method is no different than calling #Set.\n\tEnd Rem\n\tMethod SetAmbiguous(value:String)\n\t\tm_value = value\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Convert the EvalVariable to a visual representation of its data.\n\t\treturns: The scriptable form of the EvalVariable.\n\t\tabout: This function is for script output, for in-code use see #ValueAsString.\n\tEnd Rem\n\tMethod ConvToString:String()\n\t\tReturn \"~q\/e:\" + m_value + \"~q\"\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the EvalVariable as a String.\n\t\treturns: The variable value converted to a String.\n\tEnd Rem\n\tMethod ValueAsString:String()\n\t\tReturn m_value\n\tEnd Method\n\t\n'#end region (Field accessors)\n\t\n'#region Data handling\n\t\n\tRem\n\t\tbbdoc: Create a copy of the variable\n\t\treturns: A clone of the variable.\n\tEnd Rem\n\tMethod Copy:TEvalVariable()\n\t\tReturn New TEvalVariable.Create(m_name, m_value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Serialize the variable to a stream.\n\t\treturns: Nothing.\n\t\tabout: @tv tells the method whether it should serialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod Serialize(stream:TStream, tv:Int = True, name:Int = False)\n\t\tIf tv = True\n\t\t\tstream.WriteByte(TV_EVAL)\n\t\tEnd If\n\t\tIf name = True\n\t\t\tWriteLString(stream, m_name)\n\t\tEnd If\n\t\t\n\t\tWriteLString(stream, m_value)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Deserialize the variable from a stream.\n\t\treturns: The deserialized variable.\n\t\tabout: @tv tells the method whether it should deserialize the TV type for the variable, or to not.\n\tEnd Rem\n\tMethod DeSerialize:TEvalVariable(stream:TStream, tv:Int = True, name:Int = False)\n\t\tIf tv = True\n\t\t\tstream.ReadByte()\n\t\tEnd If\n\t\tIf name = True\n\t\t\tm_name = ReadLString(stream)\n\t\tEnd If\n\t\t\n\t\tm_value = ReadLString(stream)\n\t\tReturn Self\n\tEnd Method\n\t\n'#end region (Data handling)\n\t\n\tRem\n\t\tbbdoc: Get the type of this variable.\n\t\treturns: The type of this variable (\"eval\").\n\tEnd Rem\n\tFunction ReportType:String()\n\t\tReturn \"eval\"\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Get the TV type of this variable.\n\t\treturns: The TV_* type of this variable (TV_EVAL).\n\tEnd Rem\n\tFunction GetTVType:Int()\n\t\tReturn TV_EVAL\n\tEnd Function\n\t\nEnd Type\n\nRem\n\tbbdoc: The Identifier type.\nEnd Rem\nType TIdentifier Extends TVariable\n\t\n\tField m_values:TList\n\t\n\tMethod New()\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Create a new Identifier.\n\t\treturns: The new Identfier (itself).\n\tEnd Rem\n\tMethod Create:TIdentifier()\n\t\tm_values = New TList\n\t\tReturn Self\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Create a new Identifier with the given data.\n\t\treturns: The new Identfier (itself).\n\t\tabout: If the @values parameter is Null a new list will be created.\n\tEnd Rem\n\tMethod CreateByData:TIdentifier(name:String, values:TList = Null)\n\t\tSetName(name)\n\t\tIf values = Null\n\t\t\tm_values = New TList\n\t\tElse\n\t\t\tm_values = values\n\t\tEnd If\n\t\tReturn Self\n\tEnd Method\n\t\n'#region Field accessors\n\t\n\tRem\n\t\tbbdoc: Set the Identifier's values.\n\t\treturns: Nothing.\n\tEnd Rem\n\tMethod SetValues(values:TList)\n\t\tm_values = values\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the Identifier's values.\n\t\treturns: A list containing the values which the Identifier holds.\n\tEnd Rem\n\tMethod GetValues:TList()\n\t\tReturn m_values\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Deprecated for this type.\n\t\treturns: Nothing.\n\t\tabout: This does nothing.\n\tEnd Rem\n\tMethod SetAmbiguous(value:String)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Convert the identifier to a string.\n\t\treturns: A string representation of the identifier.\n\tEnd Rem\n\tMethod ConvToString:String()\n\t\tLocal op:String, variable:TVariable\n\t\t\n\t\tIf m_name.Contains(\"~t\") = True Or m_name.Contains(\" \") = True\n\t\t\top = \"~q\" + m_name + \"~q \"\n\t\tElse\n\t\t\top = m_name + \" \"\n\t\tEnd If\n\t\t\n\t\tFor variable = EachIn m_values\n\t\t\top:+variable.ConvToString() + \" \"\n\t\tNext\n\t\top = op[..op.Length - 1]\n\t\tReturn op\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the Identifier as a string.\n\t\treturns: The Identifier contents converted to a string.\n\t\tabout: Here for complete-ness, simply calls #ConvToString.\n\tEnd Rem\n\tMethod ValueAsString:String()\n\t\tReturn ConvToString()\n\tEnd Method\n\t\n'#end region (Field accessors)\n\t\n'#region Value handling\n\t\n\tRem\n\t\tbbdoc: Get a value at an index.\n\t\treturns: The value in the identifier's list at the given index, or Null if it could not be retrieved.\n\t\tabout: The index is zero-based.\n\tEnd Rem\n\tMethod GetValueAtIndex:TVariable(index:Int)\n\t\tIf m_values <> Null And index > - 1 And index < m_values.Count()\n\t\t\tReturn TVariable(m_values.ValueAtIndex(index))\n\t\tEnd If\n\t\tReturn Null\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get the number of values.\n\t\treturns: The number of values the Identifier contains.\n\tEnd Rem\n\tMethod GetValueCount:Int()\n\t\tIf m_values <> Null\n\t\t\tReturn m_values.Count()\n\t\tEnd If\n\t\tReturn 0\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Add a value to the Identifier.\n\t\treturns: True for success, or False for failure.\n\tEnd Rem\n\tMethod AddValue:Int(value:TVariable)\n\t\tIf m_values <> Null And value <> Null\n\t\t\tm_values.AddLast(value)\n\t\t\tReturn True\n\t\tEnd If\n\t\tReturn False\n\tEnd Method\n\t\n'#end region (Value handling)\n\t\n'#region Data handling\n\t\n\tRem\n\t\tbbdoc: Create a copy of the variable\n\t\treturns: A clone of the variable.\n\tEnd Rem\n\tMethod Copy:TIdentifier()\n\t\tLocal clone:TIdentifier\n\t\tclone = New TIdentifier.CreateByData(m_name)\n\t\tFor Local variable:TVariable = EachIn m_values\n\t\t\tclone.AddValue(variable.Copy())\n\t\tNext\n\t\tReturn clone\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Serialize the variable to a stream.\n\t\treturns: Nothing.\n\t\tabout: @tv tells the method whether it should serialize the TV type for the variable, or to not.
\n\t\tIn this case @name tells the method whether it should serialize the values<\/b><\/i>' name (the Identifier's name is always read\/written to the stream).\n\tEnd Rem\n\tMethod Serialize(stream:TStream, tv:Int = True, name:Int = False)\n\t\tLocal variable:TVariable\n\t\t\n\t\tIf tv = True\n\t\t\tstream.WriteByte(TV_STRING)\n\t\tEnd If\n\t\tWriteLString(stream, m_name)\n\t\t\n\t\tIf m_values = Null\n\t\t\tstream.WriteInt(0)\n\t\tElse\n\t\t\tstream.WriteInt(m_values.Count())\n\t\t\tFor variable = EachIn m_values\n\t\t\t\tvariable.Serialize(stream, True, name)\n\t\t\tNext\n\t\tEnd If\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Deserialize the variable from a stream.\n\t\treturns: The deserialized variable.\n\t\tabout: @tv tells the method whether it should deserialize the TV type for the variable, or to not.
\n\t\tIn this case @name tells the method whether it should deserialize the values<\/b><\/i>' name (the Identifier's name is always read\/written to the stream).\n\tEnd Rem\n\tMethod DeSerialize:TIdentifier(stream:TStream, tv:Int = True, name:Int = False)\n\t\tLocal count:Int, n:Int\n\t\t\n\t\tIf tv = True\n\t\t\tstream.ReadByte()\n\t\tEnd If\n\t\tm_name = ReadLString(stream)\n\t\t\n\t\tcount = stream.ReadInt()\n\t\tIf count > 0\n\t\t\tFor n = 0 To count - 1\n\t\t\t\tDeSerializeUniversal(stream, name)\n\t\t\tNext\n\t\tEnd If\n\t\t\n\t\tReturn Self\n\tEnd Method\n\t\n'#end region (Data handling)\n\t\n\tRem\n\t\tbbdoc: Get the type of this variable.\n\t\treturns: The type of this variable (\"identifier\").\n\tEnd Rem\n\tFunction ReportType:String()\n\t\tReturn \"identifier\"\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Get the TV type of this variable.\n\t\treturns: The TV_* type of this variable (TV_IDEN).\n\tEnd Rem\n\tFunction GetTVType:Int()\n\t\tReturn TV_IDEN\n\tEnd Function\n\t\nEnd Type\n\nRem\n\tbbdoc: The VariableMap type.\nEndRem\nType TVariableMap Extends TObjectMap\n\t\n\tRem\n\t\tbbdoc: Create a new VariableMap.\n\t\treturns: The new VariableMap (itself).\n\tEnd Rem\n\tMethod Create:TVariableMap()\n\t\tReturn Self\n\tEnd Method\n\t\n'#region Collections\n\t\n\tRem\n\t\tbbdoc: Insert a variable into the map.\n\t\treturns: True if the variable was added, or False if it was not (the variable's name is Null).\n\tEnd Rem\n\tMethod InsertVariable:Int(variable:TVariable)\n\t\tIf variable.GetName() <> Null\n\t\t\t_Insert(variable.GetName(), variable)\n\t\t\tReturn True\n\t\tEnd If\n\t\tReturn False\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Remove a variable by the name given.\n\t\treturns: True if a variable was removed, or False if it was not (the map contains no variable with the name given).\n\t\tabout: The name is<\/b> case-sensitive.\n\tEnd Rem\n\tMethod RemoveVariableByName:Int(name:String)\n\t\tReturn _Remove(name)\n\tEnd Method\n\t\n\tRem\n\t\tbbdoc: Get a variable from the map by its name.\n\t\treturns: The variable object, or if the variable was not found, Null.\n\t\tabout: The name is<\/b> case-sensitive.\n\tEnd Rem\n\tMethod GetVariableByName:TVariable(name:String)\n\t\tReturn TVariable(_ValueByKey(name))\n\tEnd Method\n\t\n'#end region (Collections)\n\t\nEnd Type\n\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"39a2d106b2398f01ba1f706e938c782b1cc6d95e","subject":"Update pick sample to API change.","message":"Update pick sample to API change.\n","repos":"kfprimm\/maxb3d,kfprimm\/maxb3d","old_file":"doc\/samples\/mak\/pick.bmx","new_file":"doc\/samples\/mak\/pick.bmx","new_contents":"\nStrict\n\nImport MaxB3D.Drivers\n\nGraphics 800,600\nHideMouse()\nSeedRnd MilliSecs()\n\nLocal sphere:TMesh = CreateSphere()\nSetEntityPickMode sphere, PICKMODE_SPHERE\n\nFor Local k = 0 To 99\n\tLocal model:TEntity = CopyEntity(sphere)\n\tSetEntityColor model, Rand(255), Rand(255), Rand(255)\n\tSetEntityShine model, Rnd()\n\t\n\tLocal rad# = Rnd(1, 2)\n\tSetEntityRadius model, rad\n\tSetEntityScale model, rad, rad, rad\n\tTurnEntity model, Rand(360), Rand(360), 0\n\tMoveEntity model, 0, 0, Rand(20)+20\nNext\n\nFreeEntity sphere\n\nLocal light:TLight = CreateLight()\nTurnEntity light, 45, 45, 0\n\nLocal camera:TCamera = CreateCamera()\nSetCameraRange camera, 0.1, 1000\n\nLocal zoom# = 1, entity:TEntity\n\nWhile Not KeyDown(KEY_ESCAPE) And Not AppTerminate()\n\tIf KeyDown(KEY_A) zoom :* 1.1\n\tIf KeyDown(KEY_Z) zoom :\/ 1.1\n\tSetCameraZoom camera, zoom\n\t\n\tLocal x# = MouseX(), y# = MouseY()\t\n\t\n\tIf y<32 TurnEntity camera,-2,0,0\n\tIf y>GraphicsHeight()-32 TurnEntity camera,2,0,0\n\t\n\tIf x<32 TurnEntity camera,0,2,0\n\tIf x>GraphicsWidth()-32 TurnEntity camera,0,-2,0\n\t\n\tLocal pick:TPick = WorldPick(camera, [x, y])\n\tIf pick\n\t\tSetEntityColor pick.entity, 255,0,0\n\tEndIf\n\tRem\n\te=CameraPick( camera,x,y )\n\n\tIf e<>entity\n\n\t\tIf entity Then EntityAlpha entity,1\n\n\t\tentity=e\n\n\tEndIf\n\tEnd Rem\n\n\tIf entity SetEntityAlpha entity,Sin( MilliSecs() )*.5+.5\n\t\n\tRenderWorld\t\n\tDoMax2D\n\tDrawRect x,y-3,1,7\n\tDrawRect x-3,y,7,1\n\t\n\tFlip\nWend\n","old_contents":"\nStrict\n\nImport MaxB3D.Drivers\n\nGraphics 800,600\nHideMouse()\nSeedRnd MilliSecs()\n\nLocal sphere:TMesh = CreateSphere()\nSetEntityPickMode sphere, PICKMODE_SPHERE\n\nFor Local k = 0 To 99\n\tLocal model:TEntity = CopyEntity(sphere)\n\tSetEntityColor model, Rand(255), Rand(255), Rand(255)\n\tSetEntityShine model, Rnd()\n\t\n\tLocal rad# = Rnd(1, 2)\n\tSetEntityRadius model, rad\n\tSetEntityScale model, rad, rad, rad\n\tTurnEntity model, Rand(360), Rand(360), 0\n\tMoveEntity model, 0, 0, Rand(20)+20\nNext\n\nFreeEntity sphere\n\nLocal light:TLight = CreateLight()\nTurnEntity light, 45, 45, 0\n\nLocal camera:TCamera = CreateCamera()\nSetCameraRange camera, 0.1, 1000\n\nLocal zoom# = 1, entity:TEntity\n\nWhile Not KeyDown(KEY_ESCAPE) And Not AppTerminate()\n\tIf KeyDown(KEY_A) zoom :* 1.1\n\tIf KeyDown(KEY_Z) zoom :\/ 1.1\n\tSetCameraZoom camera, zoom\n\t\n\tLocal x# = MouseX(), y# = MouseY()\t\n\t\n\tIf y<32 TurnEntity camera,-2,0,0\n\tIf y>GraphicsHeight()-32 TurnEntity camera,2,0,0\n\t\n\tIf x<32 TurnEntity camera,0,2,0\n\tIf x>GraphicsWidth()-32 TurnEntity camera,0,-2,0\n\t\n\tLocal picks:TPick[] = WorldPick(camera, [x, y])\n\tFor Local pick:TPick = EachIn picks\n\t\tSetEntityColor pick.entity, 255,0,0\n\tNext\n\tRem\n\te=CameraPick( camera,x,y )\n\n\tIf e<>entity\n\n\t\tIf entity Then EntityAlpha entity,1\n\n\t\tentity=e\n\n\tEndIf\n\tEnd Rem\n\n\tIf entity SetEntityAlpha entity,Sin( MilliSecs() )*.5+.5\n\t\n\tRenderWorld\t\n\tDoMax2D\n\tDrawRect x,y-3,1,7\n\tDrawRect x-3,y,7,1\n\t\n\tFlip\nWend\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"e893f30dcb759183fcb06dacbc1fd433171cd109","subject":"Don't add extra newlines, mxLogger handles this","message":"Don't add extra newlines, mxLogger handles this\n\nrefs gh-17\n","repos":"maximos\/maximus","old_file":"gui\/logger.bmx","new_file":"gui\/logger.bmx","new_contents":"Type mxLoggerObserverGUI\n\n\tField m_output:Object\n\t\n\tMethod Reset()\n\t\tIf TGadget(m_output)\n\t\t\tSetGadgetText(TGadget(m_output), \"\")\n\t\tEnd If\n\tEnd Method\n\n\tMethod SendMessage:Object(message:Object, context:Object)\n\t\tLocal msg:String = String(message)\n\t\tIf String(context) = \"error\"\n\t\t\tNotify(msg, True)\n\t\tElse If TGadget(m_output)\n\t\t\tLocal gadget:TGadget = TGadget(m_output)\n\t\t\tSetGadgetText(gadget, GadgetText(gadget) + String(message))\n\t\t\t'Refresh GUI\n\t\t\tDriver.Poll\n\t\tElse If m_output = Null\n\t\t\tNotify(msg)\n\t\tEnd If\n\tEnd Method\n\nEnd Type","old_contents":"Type mxLoggerObserverGUI\n\n\tField m_output:Object\n\t\n\tMethod Reset()\n\t\tIf TGadget(m_output)\n\t\t\tSetGadgetText(TGadget(m_output), \"\")\n\t\tEnd If\n\tEnd Method\n\n\tMethod SendMessage:Object(message:Object, context:Object)\n\t\tLocal msg:String = String(message)\n\t\tIf String(context) = \"error\"\n\t\t\tNotify(msg, True)\n\t\tElse If TGadget(m_output)\n\t\t\tLocal gadget:TGadget = TGadget(m_output)\n\t\t\tSetGadgetText(gadget, GadgetText(gadget) + \"~n\" + String(message))\n\t\t\t'Refresh GUI\n\t\t\tDriver.Poll\n\t\tElse If m_output = Null\n\t\t\tNotify(msg)\n\t\tEnd If\n\tEnd Method\n\nEnd Type","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"9ecd9194e88df4b807732295e0c212ddbeabceca","subject":"[argparser] (v0.4) \tChanged parsing for single-dash options","message":"[argparser] (v0.4)\n\tChanged parsing for single-dash options\n","repos":"komiga\/duct-max,komiga\/duct-max,komiga\/duct-max","old_file":"argparser.mod\/argparser.bmx","new_file":"argparser.mod\/argparser.bmx","new_contents":"\nRem\nCopyright (c) 2010 Tim Howard\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and\/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\nEnd Rem\n\nSuperStrict\n\nRem\nbbdoc: Application argument parser\nEnd Rem\nModule duct.argparser\n\nModuleInfo \"Version: 0.4\"\nModuleInfo \"Copyright: Tim Howard\"\nModuleInfo \"License: MIT\"\n\nModuleInfo \"History: Version 0.4\"\nModuleInfo \"History: Changed parsing for single-dash options\"\nModuleInfo \"History: Version 0.3\"\nModuleInfo \"History: Fixed argument parsing for commands\"\nModuleInfo \"History: Version 0.2\"\nModuleInfo \"History: Updated for API change\"\nModuleInfo \"History: Version 0.1\"\nModuleInfo \"History: Initial version.\"\n\nImport duct.variables\n\nRem\n\tbbdoc: duct argument parser.\nEnd Rem\nType dArgParser\n\t\n\tRem\n\t\tbbdoc: Parse the given arguments string array.\n\t\treturns: The root identifier containing the parsed arguments.\n\t\tabout: The expected value does not<\/b> (by default) contain the first argument of AppArgs (the application location).
\n\t\tYou can override this by passing @fullargs as True. If you leave it as False, the root identifier's name will be set to the first argument (which should be the application location - if you're passing AppArgs).
\n\t\t@optarglimit limits how many arguments can be given to an option (options start with \"--\" or \"-\"). If set to -1, there is no limit.
\n\t\tSingle-dash options (e.g. \"-a\") are not parsed for arguments, whereas double-dash options (e.g. \"--foobar wakka\") will be.\n\tEnd Rem\n\tFunction ParseArray:dIdentifier(args:String[], fullargs:Int = False, optarglimit:Int = 1)\n\t\tLocal root:dIdentifier = New dIdentifier.Create()\n\t\tIf fullargs = True\n\t\t\troot.SetName(args[0])\n\t\t\targs = args[1..]\n\t\tEnd If\n\t\tLocal arg:String, i:Int, length:Int = args.Length - 1\n\t\tLocal sub:dIdentifier, subset:Int = False\n\t\toptarglimit = (optarglimit = -1) And length Or optarglimit\n\t\tFor i = 0 To length\n\t\t\targ = args[i]\n\t\t\tsub = New dIdentifier.CreateByData(arg, Null)\n\t\t\tIf arg <> Null And arg[0] = 45 ' \"-\"\n\t\t\t\tIf arg[1] = 45 ' \"-\"\n\t\t\t\t\tLocal lim:Int = Min(length, i + optarglimit)\n\t\t\t\t\ti:+1\n\t\t\t\t\tWhile i <= length\n\t\t\t\t\t\targ = args[i]\n\t\t\t\t\t\tIf arg = Null Or arg[0] <> 45 ' \"-\"\n\t\t\t\t\t\t\tsub.AddValue(dVariable.RawToVariable(arg))\n\t\t\t\t\t\t\ti:+1\n\t\t\t\t\t\t\tIf i > lim\n\t\t\t\t\t\t\t\ti:-1\n\t\t\t\t\t\t\t\tExit\n\t\t\t\t\t\t\tEnd If\n\t\t\t\t\t\tElse\n\t\t\t\t\t\t\ti:-1\n\t\t\t\t\t\t\tExit\n\t\t\t\t\t\tEnd If\n\t\t\t\t\tEnd While\n\t\t\t\t\troot.AddValue(sub)\n\t\t\t\tElse\n\t\t\t\t\troot.AddValue(sub)\n\t\t\t\tEnd If\n\t\t\tElse\n\t\t\t\tIf subset = False\n\t\t\t\t\troot.AddValue(sub)\n\t\t\t\t\troot = sub\n\t\t\t\t\tsubset = True\n\t\t\t\tElse\n\t\t\t\t\troot.AddValue(dVariable.RawToVariable(arg))\n\t\t\t\tEnd If\n\t\t\tEnd If\n\t\tNext\n\t\tWhile Not root.GetParent() = Null\n\t\t\troot = dIdentifier(root.GetParent())\n\t\tEnd While\n\t\tReturn root\n\tEnd Function\n\t\nEnd Type\n\n","old_contents":"\nRem\nCopyright (c) 2010 Tim Howard\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and\/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\nEnd Rem\n\nSuperStrict\n\nRem\nbbdoc: Application argument parser\nEnd Rem\nModule duct.argparser\n\nModuleInfo \"Version: 0.3\"\nModuleInfo \"Copyright: Tim Howard\"\nModuleInfo \"License: MIT\"\n\nModuleInfo \"History: Version 0.3\"\nModuleInfo \"History: Fixed argument parsing for commands\"\nModuleInfo \"History: Version 0.2\"\nModuleInfo \"History: Updated for API change\"\nModuleInfo \"History: Version 0.1\"\nModuleInfo \"History: Initial version.\"\n\nImport duct.variables\n\nRem\n\tbbdoc: duct argument parser.\nEnd Rem\nType dArgParser\n\t\n\tRem\n\t\tbbdoc: Parse the given arguments string array.\n\t\treturns: The root identifier containing the parsed arguments.\n\t\tabout: The expected value does not<\/b> (by default) contain the first argument of AppArgs (the application location).\n\t\tYou can override this by passing @fullargs as True. If you leave it as False, the root identifier's name will be set to the first argument (which should be the application location - if you're passing AppArgs).\n\t\t@optarglimit limits how many arguments can be given to an option (options start with \"--\" or \"-\"). If set to -1, there is no limit.\n\tEnd Rem\n\tFunction ParseArray:dIdentifier(args:String[], fullargs:Int = False, optarglimit:Int = 1)\n\t\tLocal root:dIdentifier = New dIdentifier.Create()\n\t\tIf fullargs = True\n\t\t\troot.SetName(args[0])\n\t\t\targs = args[1..]\n\t\tEnd If\n\t\tLocal arg:String, i:Int, length:Int = args.Length - 1\n\t\tLocal sub:dIdentifier, subset:Int = False\n\t\toptarglimit = (optarglimit = -1) And length Or optarglimit\n\t\tFor i = 0 To length\n\t\t\targ = args[i]\n\t\t\tsub = New dIdentifier.CreateByData(arg, Null)\n\t\t\tIf arg <> Null And arg[0] = 45 ' \"-\"\n\t\t\t\tLocal lim:Int = Min(length, i + optarglimit)\n\t\t\t\ti:+1\n\t\t\t\tWhile i <= length\n\t\t\t\t\targ = args[i]\n\t\t\t\t\tIf arg = Null Or arg[0] <> 45 ' \"-\"\n\t\t\t\t\t\tsub.AddValue(dVariable.RawToVariable(arg))\n\t\t\t\t\t\ti:+1\n\t\t\t\t\t\tIf i > lim\n\t\t\t\t\t\t\ti:-1\n\t\t\t\t\t\t\tExit\n\t\t\t\t\t\tEnd If\n\t\t\t\t\tElse\n\t\t\t\t\t\ti:-1\n\t\t\t\t\t\tExit\n\t\t\t\t\tEnd If\n\t\t\t\tEnd While\n\t\t\t\troot.AddValue(sub)\n\t\t\tElse\n\t\t\t\tIf subset = False\n\t\t\t\t\troot.AddValue(sub)\n\t\t\t\t\troot = sub\n\t\t\t\t\tsubset = True\n\t\t\t\tElse\n\t\t\t\t\troot.AddValue(dVariable.RawToVariable(arg))\n\t\t\t\tEnd If\n\t\t\tEnd If\n\t\tNext\n\t\tWhile Not root.GetParent() = Null\n\t\t\troot = dIdentifier(root.GetParent())\n\t\tEnd While\n\t\tReturn root\n\tEnd Function\n\t\nEnd Type\n\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"4399b683bf598348aec7f866ac545f99095ee811","subject":"Create 4Djulia.bmx","message":"Create 4Djulia.bmx","repos":"Jaulers\/fractals","old_file":"4DJuliaShader\/4Djulia.bmx","new_file":"4DJuliaShader\/4Djulia.bmx","new_contents":"SuperStrict\nFramework brl.GLGraphics\nImport brl.TIMER\nImport brl.TextStream\nImport pub.OpenGL\nImport pub.Glew\nImport brl.Retro\nImport brl.PNGLoader\n\nConst GW:Int = 640, GH:Int = 360\n\nIf AppArgs.Length > 1\n\tTAnimFrame.LoadFromFile(AppArgs[1])\nEnd If\n\nGlobal TIMER:TTimer = CreateTimer(30)\nGlobal VERTEX_SHADER_CODE:String = LoadText(\"vs.glsl\")\nGlobal FRAGMENT_SHADER_CODE:String = LoadText(\"fs.glsl\")\n\nInitGL\nGlobal ProgramObj:Int\nInitShaders\nglUseProgram(ProgramObj)\n\nGlobal camS:Float = 0.04\nGlobal camX:Float = -0.9, camY:Float = -1.35, camZ:Float = -3.6, camW:Float = 0.0\nGlobal camP:Float = 0.2, camT:Float = -0.37\n\nGlobal lightX:Float = -1.6, lightY:Float = -0.9, lightZ:Float = -2.4\n\nGlobal camZoom:Float = 1.0\n\nGlobal cx:Float = 0, cy:Float = 0, cz:Float = 0, cw:Float = 0\nGlobal itr:Int = 11\nGlobal eps:Float = 0.001\n\nGlobal disphelp:Int = 0\n\nGlobal cf:TAnimFrame, cflink:TLink\n\n'Render()\n'SaveSceenshot()\n'End\n\nGlobal MDown:Int, MXS:Int, MYS:Int\nGlobal zwsp:Float\nWhile Not KeyHit(KEY_ESCAPE)\n\tMDown = MouseDown(MOUSE_LEFT) Shl 2 + MouseDown(MOUSE_MIDDLE) Shl 1 + MouseDown(MOUSE_RIGHT)\n\tMXS = MouseXSpeed()\n\tMYS = MouseYSpeed()\n\tIf MDown & %100\n\t\tMoveMouse GW \/ 2, GH \/ 2\n\t\tMouseXSpeed()\n\t\tMouseYSpeed()\n\tEnd If\n\t\n\tCheckInput()\n\t\n\tRender()\n\t\n\tIf disphelp Then glUseProgram(0) DrawHelp() glUseProgram(ProgramObj)\n\t\n\tFlip 0\n\tglCls\n\tWaitTimer TIMER\nWend\nEnd\n\nFunction CheckInput()\n\tIf KeyDown(KEY_2) camS:*1.05 Else If KeyDown(KEY_1) camS:\/1.05\n\t\n\tIf KeyDown(KEY_4) eps:*1.1 Else If KeyDown(KEY_3) eps:\/1.1\n\t\n\titr:+KeyHit(KEY_6) - KeyHit(KEY_5)\n\t\n\tIf KeyDown(KEY_8) camZoom:*1.05 Else If KeyDown(KEY_7) camZoom:\/1.05\n\t\n\tIf MDown & 010\n\t\tlightX = camX\n\t\tlightY = camY\n\t\tlightZ = camZ\n\tEnd If\n\t\n\tIf KeyDown(KEY_W)\n\t\tcamX = camX + cos_(camT) * sin_(camP) * camS\n\t\tcamY = camY - sin_(camT) * camS\n\t\tcamZ = camZ + cos_(camT) * cos_(camP) * camS\n\tEnd If\n\tIf KeyDown(KEY_S)\n\t\tcamX = camX - cos_(camT) * sin_(camP) * camS\n\t\tcamY = camY + sin_(camT) * camS\n\t\tcamZ = camZ - cos_(camT) * cos_(camP) * camS\n\tEnd If\n\tIf KeyDown(KEY_D)\n\t\tcamX = camX + sin_(camP + 1.57079633) * camS\n\t\tcamZ = camZ + cos_(camP + 1.57079633) * camS\n\tEnd If\n\tIf KeyDown(KEY_A)\n\t\tcamX = camX - sin_(camP + 1.57079633) * camS\n\t\tcamZ = camZ - cos_(camP + 1.57079633) * camS\n\tEnd If\n\tcamY:+(KeyDown(KEY_LSHIFT) - KeyDown(KEY_SPACE)) * camS\n\tcamW:+(KeyDown(KEY_E) - KeyDown(KEY_Q)) * camS\n\t\n\t\n\tIf MDown & %100\n\t\tcamT:-MYS * 0.01'(KeyDown(KEY_UP) - KeyDown(KEY_DOWN)) * 0.01\n\t\tcamP:+MXS * 0.01'(KeyDown(KEY_RIGHT) - KeyDown(KEY_LEFT)) * 0.01\n\tEnd If\n\t\n\tcx:+(KeyDown(KEY_R) - KeyDown(KEY_F)) * camS\n\tcy:+(KeyDown(KEY_T) - KeyDown(KEY_G)) * camS\n\tcz:+(KeyDown(KEY_Z) - KeyDown(KEY_H)) * camS\n\tcw:+(KeyDown(KEY_U) - KeyDown(KEY_J)) * camS\n\t\n\tIf KeyHit(KEY_ENTER) disphelp = 1 - disphelp\n\t\n\t\n\tIf KeyHit(KEY_DOWN)\n\t\tIf KeyDown(KEY_RCONTROL)\n\t\t\tTAnimFrame.AddFrame(cflink, 1)\n\t\t\tPrint \"frame modified\"\n\t\tElse\n\t\t\tcf = TAnimFrame.AddFrame(cflink) Print \"frame added\"\n\t\t\tIf cflink = Null Then cflink = TAnimFrame.list.FindLink(cf) Else cflink = cflink.NextLink()\n\t\tEnd If\n\tEnd If\n\t\n\tIf KeyHit(KEY_RIGHT)\n\t\tIf KeyDown(KEY_RCONTROL)\n\t\t\tcflink = TAnimFrame.list.LastLink()\n\t\t\tcf = TAnimFrame(TAnimFrame.list.Last())\n\t\t\tIf cf Then cf.setGlobalsToFrame()\n\t\tElse If cflink.NextLink()\n\t\t\tcflink = cflink.NextLink()\n\t\t\tcf = TAnimFrame(TAnimFrame(cflink.Value()))\n\t\t\tIf cf Then cf.setGlobalsToFrame()\n\t\tEnd If\n\tEnd If\n\t\n\tIf KeyHit(KEY_LEFT)\n\t\tIf KeyDown(KEY_RCONTROL)\n\t\t\tcflink = TAnimFrame.list.FirstLink()\n\t\t\tcf = TAnimFrame(TAnimFrame.list.First())\n\t\t\tIf cf Then cf.setGlobalsToFrame()\n\t\tElse If cflink.PrevLink()\n\t\t\tcflink = cflink.PrevLink()\n\t\t\tcf = TAnimFrame(TAnimFrame(cflink.Value()))\n\t\t\tIf cf Then cf.setGlobalsToFrame()\n\t\tEnd If\n\tEnd If\n\t\n\tIf KeyHit(KEY_BACKSPACE) And cf\n\t\tcflink = cflink.PrevLink()\n\t\tcf.list.Remove(cf)\n\t\tIf cf Then cf = TAnimFrame(cflink.Value())\n\t\tPrint \"frame deleted\"\n\tEnd If\n\t\n\tIf cf\n\t\tLocal timevar:TFloat = TFloat(cf.getVar(\"time\"))\n\t\tIf KeyDown(KEY_PAGEUP) Then timevar.v:*1.1 Print timevar.v Else ..\n\t\tIf KeyDown(KEY_PAGEDOWN) Then timevar.v:\/1.1 Print timevar.v\n\tEnd If\n\t\n\tIf KeyHit(KEY_RSHIFT) And cf Then cf.setGlobalsToFrame()\n\t\n\tIf KeyHit(KEY_UP) Then TAnimFrame.PlayAnim(0.04)\n\t\n\tIf KeyHit(KEY_F10) Then TAnimFrame.SaveToFile(\"anim\" + MilliSecs() + \".txt\")\n\t\n\tIf KeyHit(KEY_F11)\n\t\tIf KeyDown(KEY_RCONTROL)\n\t\t\tTAnimFrame.SaveAnim(0.02, \"anim\" + MilliSecs(), Input(\"Skip Nr Frames:\").ToInt())\n\t\tElse\n\t\t\tTAnimFrame.SaveAnim(0.02, \"anim\" + MilliSecs())\n\t\tEnd If\n\tEnd If\n\t\n\tIf KeyHit(KEY_F12)\n\t\tIf KeyDown(KEY_RCONTROL)\n\t\t\tSaveSceenshot(Input(\"resolution multiplier:\").ToInt())\n\t\tElse\n\t\t\tSaveSceenshot(6)\n\t\tEnd If\n\tEnd If\nEnd Function\n\nFunction Render(x:Int = 0, y:Int = 0, s:Int = 1)\n\tglUniform4f(glGetUniformLocation(ProgramObj, \"cpos\"), camX, camY, camZ, camW)\n\tglUniform2f(glGetUniformLocation(ProgramObj, \"crot\"), camP, camT)\n\tglUniform3f(glGetUniformLocation(ProgramObj, \"light\"), lightX, lightY, lightZ)\n\tglUniform4f(glGetUniformLocation(ProgramObj, \"c\"), cx, cy, cz, cw)\n\tglUniform1i(glGetUniformLocation(ProgramObj, \"itr\"), itr)\n\tglUniform1f(glGetUniformLocation(ProgramObj, \"eps\"), eps)\n\t\n\t\n\tLocal w:Float = 2.0 * camZoom \/ Float(s), h:Float = GH \/ Float(GW)\n\tLocal vx:Float = x * w - camZoom, vy:Float = -camZoom * h\n\th = w * h\n\tvy = vy + y * h\n\t\n\tglBegin(GL_QUADS)\n\t\tglTexCoord2f(vx, vy) ;glVertex2i(0, 0)\n\t\tglTexCoord2f(vx + w, vy) ;glVertex2i(GW, 0)\n\t\tglTexCoord2f(vx + w, vy + h) ;glVertex2i(GW, GH)\n\t\tglTexCoord2f(vx, vy + h) ;glVertex2i(0, GH)\n\tglEnd\nEnd Function\n\nFunction InitGL()\n\tGraphics GW, GH', 32, 60, 0\n\tSetGraphicsDriver(GLGraphicsDriver())\n\tglewInit()\n\t\n\tglMatrixMode(GL_PROJECTION)\n\tglLoadIdentity()\n\t\n\tglOrtho(0, GW, GH, 0, -1, 1)\n\t\n\tglMatrixMode(GL_MODELVIEW)\n\tglLoadIdentity()\nEnd Function\n\nFunction glCls()\n\tglClear GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT\nEnd Function\n\nFunction InitShaders()\n\tProgramObj = glCreateProgram()\n\tLocal VertexShdr:Int = glCreateShader(GL_VERTEX_SHADER_ARB)\n\tLocal FragmentShdr:Int = glCreateShader(GL_FRAGMENT_SHADER_ARB)\n\t\n\tLocal vsc:Byte Ptr = VERTEX_SHADER_CODE.ToCString()\n\tLocal vsl:Int = VERTEX_SHADER_CODE.Length\n\tLocal fsc:Byte Ptr = FRAGMENT_SHADER_CODE.ToCString()\n\tLocal fsl:Int = FRAGMENT_SHADER_CODE.Length\n\t\n\tglShaderSource(VertexShdr, 1, Varptr vsc, Varptr vsl)\n\t\tglShaderSource(FragmentShdr, 1, Varptr fsc, Varptr fsl)\n\t\n\t\tMemFree(vsc)\n\tMemFree(fsc)\n\t\n\tglCompileShader(VertexShdr) ;CheckForErrors(VertexShdr)\n\tglCompileShader(FragmentShdr) ;CheckForErrors(FragmentShdr)\n\t\n\tglAttachShader(ProgramObj, VertexShdr)\n\tglAttachShader(ProgramObj, FragmentShdr)\n\t\n\tglDeleteShader(VertexShdr)\n\tglDeleteShader(FragmentShdr)\n\t\n\tglLinkProgram(ProgramObj) ;CheckForErrors(ProgramObj)\nEnd Function\n\nFunction CheckForErrors(ShaderObject:Int)\n\tLocal ErrorLength:Int\n\t\n\tglGetShaderiv(ShaderObject, GL_OBJECT_INFO_LOG_LENGTH_ARB, Varptr ErrorLength)\n\t\n\t\tIf ErrorLength\n\t\tLocal Message:Byte[ErrorLength], Dummy:Int\n\t\t\n\t\tglGetShaderInfoLog(ShaderObject, ErrorLength, Varptr Dummy, Varptr Message[0])\n\t\t'\t\tSaveText(\"Shader object '\" + ShaderObject + \"':~n\" + StringFromCharArray(Message), \"error.txt\")\n\t\tWriteStdout \"Shader object '\" + ShaderObject + \"':~n\" + StringFromCharArray(Message)\n\t\tWriteStdout \"~n\"\n\tEndIf\nEnd Function\n\nFunction StringFromCharArray:String(Array:Byte[])\n\tLocal Output:String\n\tFor Local I:Int = 0 To Array.Length - 1\n\t\tOutput:+Chr(Array[I])\n\tNext\n\t\n\tReturn Output\nEnd Function\n\n\nFunction SaveSceenshot(s:Int = 3, fn:String = \"\", compression:Int = 5, infosdtout:Int = 1)\n\tLocal cnt:Int\n\tLocal pm:TPixmap = CreatePixmap(GW * s, GH * s, PF_BGRA8888)\n\tLocal c:Byte Ptr = MemAlloc(3 * (GW + GW Mod 4) * (GH + GH Mod 4))\n\t\n\tFor Local x1:Int = 0 Until s\n\t\tIf infosdtout WriteStdout (x1 + 1) + \" of \" + s + \"~n\"\n\t\tFor Local y1:Int = 0 Until s\n\t\t\tRender(x1, y1, s)\n\t\t\tglReadPixels(0, 0, (GW + GW Mod 4), (GH + GH Mod 4), GL_RGB, GL_UNSIGNED_BYTE, c)\n\t\t\tcnt = 0\n\t\t\tFor Local y:Int = GH - 1 To 0 Step - 1\n\t\t\t\tFor Local x:Int = 0 Until GW\n\t\t\t\t\tWritePixel(pm, x1 * GW + x, y1 * GH + y, $ff000000 + $10000 * c[cnt] + $100 * c[cnt + 1] + c[cnt + 2])\n\t\t\t\t\tcnt:+3\n\t\t\t\tNext\n\t\t\t\tcnt:+3 * (GW Mod 4)\n\t\t\tNext\n\t\tNext\n\tNext\n\t\n\tIf infosdtout WriteStdout \"Saving...\"\n\tIf fn = \"\" Then fn = (MilliSecs()) + \".png\"\n\tSavePixmapPNG(pm, fn, compression)\n\tIf infosdtout WriteStdout \"Done.~n~n\"\nEnd Function\n\nFunction DrawHelp()\n\tGLDrawText \"cam =\" + camX + \", \" + camY + \", \" + camZ, 0, 0\n\tGLDrawText \"c =\" + cx + \", \" + cy + \", \" + cz, 0, 16\n\tGLDrawText \"itr =\" + itr, 0, 32\n\tGLDrawText \"eps =\" + eps, 0, 48\nEnd Function\n\nFunction Catmul:Float(v0:Float, v1:Float, v2:Float, v3:Float, x:Float)\n\tLocal a0:Float, a1:Float, a2:Float, a3:Float, x2:Float\n\t\n\tx2 = x * x\n'\ta0 = -0.5 * v0 + 1.5 * v1 - 1.5 * v2 + 0.5 * v3\n'\ta1 = v0 - 2.5 * v1 + 2 * v2 - 0.5 * v3\n'\ta2 = -0.5 * v0 + 0.5 * v2\n'\ta3 = v1\n\ta0 = v3 - v2 - v0 + v1\n\ta1 = v0 - v1 - a0\n\ta2 = v2 - v0\n\ta3 = v1\n\t\n\tReturn a0 * x * x2 + a1 * x2 + a2 * x + a3\nEnd Function\n\nFunction Clip:Float(v1:Float, v2:Float, x:Float)\n\tReturn x * v2 + v1 * (1.0 - x)\nEnd Function\n\nType TAnimFrame\n\tGlobal list:TList = CreateList()\n\t\n\tField varlist:TList\n\t\n\tMethod New()\n\t\tvarlist = CreateList()\n\tEnd Method\n\t\n\tMethod Del()\n\t\tlist.Remove(Self)\n\tEnd Method\n\t\n\tFunction AddFrame:TAnimFrame(link:TLink = Null, modify:Int = 0)\n\t\tLocal t:TAnimFrame\n\t\tIf modify\n\t\t\tIf link = Null\n\t\t\t\tt = New TAnimFrame\n\t\t\t\tt.list.AddLast(t)\n\t\t\tElse\n\t\t\t\tt = TAnimFrame(link.Value())\n\t\t\tEnd If\n\t\tElse\n\t\t\tt = New TAnimFrame\n\t\t\tIf link = Null\n\t\t\t\tt.list.AddLast(t)\n\t\t\tElse\n\t\t\t\tt.list.InsertAfterLink(t, link)\n\t\t\tEnd If\n\t\tEnd If\n\t\t\n\t\tLocal timevar:Object = t.getVar(\"time\")\n\t\tIf timevar = Null\n\t\t\tt.setVar(\"time\", TFloat.N(1.0))\n\t\tElse\n\t\t\tt.setVar(\"time\", TFloat(timevar))\n\t\tEnd If\n\t\t\n\t\tt.setVar(\"camX\", TFloat.N(camX))\n\t\tt.setVar(\"camY\", TFloat.N(camY))\n\t\tt.setVar(\"camZ\", TFloat.N(camZ))\n\t\tt.setVar(\"camP\", TFloat.N(camP))\n\t\tt.setVar(\"camT\", TFloat.N(camT))\n\t\t\n\t\tt.setVar(\"camZoom\", TFloat.N(camZoom))\n\t\t\n\t\tt.setVar(\"lightX\", TFloat.N(lightX))\n\t\tt.setVar(\"lightY\", TFloat.N(lightY))\n\t\tt.setVar(\"lightZ\", TFloat.N(lightZ))\n\t\t\n\t\tt.setVar(\"eps\", TFloat.N(eps))\n\t\t\n\t\tt.setVar(\"itr\", TInt.N(itr))\n\t\t\n\t\tt.setVar(\"cx\", TFloat.N(cx))\n\t\tt.setVar(\"cy\", TFloat.N(cy))\n\t\tt.setVar(\"cz\", TFloat.N(cz))\n\t\tReturn t\n\tEnd Function\n\t\n\tMethod getVar:Object(name:String)\n\t\tFor Local t:TAnimFrameVar = EachIn varlist\n\t\t\tIf t.name = name\n\t\t\t\tReturn t.v\n\t\t\tEnd If\n\t\tNext\n\t\tReturn Null\n\tEnd Method\n\t\n\tMethod setVar(name:String, v:Object)\n\t\tFor Local t:TAnimFrameVar = EachIn varlist\n\t\t\tIf t.name = name\n\t\t\t\tt.v = v\n\t\t\t\tReturn\n\t\t\tEnd If\n\t\tNext\n\t\tLocal t:TAnimFrameVar = New TAnimFrameVar\n\t\tt.name = name\n\t\tt.v = v\n\t\tvarlist.AddLast(t)\n\t\tReturn\n\tEnd Method\n\t\n\tFunction PlayAnim(speed:Float)\n\t\tLocal f1:TAnimFrame, f1link:TLink\n\t\tLocal f2:TAnimFrame, f2link:TLink\n\t\tLocal time:Float\n\t\tLocal x:Float = 0\n\t\t\n\t\tf1 = TAnimFrame(f1.list.First())\n\t\tf1link = f1.list.FirstLink()\n\t\tIf f1link = Null Then Return\n\t\tf2link = f1link.NextLink()\n\t\tIf f2link = Null Then Return\n\t\tf2 = TAnimFrame(f2link.Value())\n\t\t\n\t\tWhile Not KeyHit(KEY_ESCAPE)\n\t\t\t\n\t\t\tsetGlobals(f1, f1link, f2, f2link, x)\n\t\t\t\n\t\t\tRender()\n\t\t\t\n\t\t\tIf disphelp DrawHelp()\n\t\t\t\n\t\t\ttime = Clip(TFloat(f1.getVar(\"time\")).v, ..\n\t\t\tTFloat(f2.getVar(\"time\")).v, x)\n\t\t\t\n\t\t\tx:+speed \/ time\n\t\t\tIf x >= 1\n\t\t\t\tf1link = f2link\n\t\t\t\tf1 = f2\n\t\t\t\tf2link = f1link.NextLink()\n\t\t\t\tIf f2link = Null Return\n\t\t\t\tf2 = TAnimFrame(f2link.Value())\n\t\t\t\tx = x - 1.0\n\t\t\tEnd If\n\t\t\t\n\t\t\tFlip 0\n\t\t\tglCls\n\t\t\tWaitTimer TIMER\n\t\tWend\n\tEnd Function\n\t\n\tFunction SaveAnim(speed:Float, folder:String, skip:Int = 0)\n\t\tLocal framenr:Int = 0\n\t\t\n\t\tCreateDir(folder)\n\t\t\n\t\tLocal f1:TAnimFrame, f1link:TLink\n\t\tLocal f2:TAnimFrame, f2link:TLink\n\t\tLocal time:Float\n\t\tLocal x:Float = 0\n\t\t\n\t\tf1 = TAnimFrame(f1.list.First())\n\t\tf1link = f1.list.FirstLink()\n\t\tIf f1link = Null Then Return\n\t\tf2link = f1link.NextLink()\n\t\tIf f2link = Null Then Return\n\t\tf2 = TAnimFrame(f2link.Value())\n\t\t\n\t\tWhile Not KeyHit(KEY_ESCAPE)\n\t\t\tsetGlobals(f1, f1link, f2, f2link, x)\n\t\t\t\n\t\t\tIf framenr >= skip\n\t\t\t\tSaveSceenshot(3, folder + \"\/\" + framenr + \".png\", 1, 0)\n\t\t\t\tPrint \"Frame Nr. \" + framenr\n\t\t\tEnd If\n\t\t\t\n\t\t\ttime = Clip(TFloat(f1.getVar(\"time\")).v, ..\n\t\t\tTFloat(f2.getVar(\"time\")).v, x)\n\t\t\t\n\t\t\tx:+speed \/ time\n\t\t\tIf x >= 1\n\t\t\t\tf1link = f2link\n\t\t\t\tf1 = f2\n\t\t\t\tf2link = f1link.NextLink()\n\t\t\t\tIf f2link = Null Then End\n\t\t\t\tf2 = TAnimFrame(f2link.Value())\n\t\t\t\tx = x - 1.0\n\t\t\tEnd If\n\t\t\t\n\t\t\t\n\t\t\tframenr:+1\n\t\t\t'Flip 0\n\t\t\t'glCls\n\t\t\t'WaitTimer TIMER\n\t\tWend\n\tEnd Function\n\t\n\tFunction setGlobals(f1:TAnimFrame, f1link:TLink, f2:TAnimFrame, f2link:TLink, x:Float)\n\t\tLocal f0:TAnimFrame, f3:TAnimFrame\n\t\tLocal f0link:TLink, f3link:TLink\n\t\t\n\t\tf0link = f1link.PrevLink()\n\t\tf3link = f2link.NextLink()\n\t\t\n\t\tIf f0link = Null Then f0link = f1link\n\t\tIf f3link = Null Then f3link = f2link\n\t\t\n\t\tf0 = TAnimFrame(f0link.Value())\n\t\tf3 = TAnimFrame(f3link.Value())\n\t\t\n\t\t\n\t\tcamX = Catmul(TFloat(f0.getVar(\"camX\")).v, ..\n\t\tTFloat(f1.getVar(\"camX\")).v, ..\n\t\tTFloat(f2.getVar(\"camX\")).v, ..\n\t\tTFloat(f3.getVar(\"camX\")).v, x)\n\t\t \n\t\tcamY = Catmul(TFloat(f0.getVar(\"camY\")).v, ..\n\t\tTFloat(f1.getVar(\"camY\")).v, ..\n\t\tTFloat(f2.getVar(\"camY\")).v, ..\n\t\tTFloat(f3.getVar(\"camY\")).v, x)\n\t\t\n\t\tcamZ = Catmul(TFloat(f0.getVar(\"camZ\")).v, ..\n\t\tTFloat(f1.getVar(\"camZ\")).v, ..\n\t\tTFloat(f2.getVar(\"camZ\")).v, ..\n\t\tTFloat(f3.getVar(\"camZ\")).v, x)\n\t\t\n\t\tcamP = Catmul(TFloat(f0.getVar(\"camP\")).v, ..\n\t\tTFloat(f1.getVar(\"camP\")).v, ..\n\t\tTFloat(f2.getVar(\"camP\")).v, ..\n\t\tTFloat(f3.getVar(\"camP\")).v, x)\n\t\t\n\t\tcamT = Catmul(TFloat(f0.getVar(\"camT\")).v, ..\n\t\tTFloat(f1.getVar(\"camT\")).v, ..\n\t\tTFloat(f2.getVar(\"camT\")).v, ..\n\t\tTFloat(f3.getVar(\"camT\")).v, x)\n\t\t\n\t\tcamZoom = Catmul(TFloat(f0.getVar(\"camZoom\")).v, ..\n\t\tTFloat(f1.getVar(\"camZoom\")).v, ..\n\t\tTFloat(f2.getVar(\"camZoom\")).v, ..\n\t\tTFloat(f3.getVar(\"camZoom\")).v, x)\n\t\t\n\t\t\n\t\tlightX = Catmul(TFloat(f0.getVar(\"lightX\")).v, ..\n\t\tTFloat(f1.getVar(\"lightX\")).v, ..\n\t\tTFloat(f2.getVar(\"lightX\")).v, ..\n\t\tTFloat(f3.getVar(\"lightX\")).v, x)\n\t\t \n\t\tlightY = Catmul(TFloat(f0.getVar(\"lightY\")).v, ..\n\t\tTFloat(f1.getVar(\"lightY\")).v, ..\n\t\tTFloat(f2.getVar(\"lightY\")).v, ..\n\t\tTFloat(f3.getVar(\"lightY\")).v, x)\n\t\t\n\t\tlightZ = Catmul(TFloat(f0.getVar(\"lightZ\")).v, ..\n\t\tTFloat(f1.getVar(\"lightZ\")).v, ..\n\t\tTFloat(f2.getVar(\"lightZ\")).v, ..\n\t\tTFloat(f3.getVar(\"lightZ\")).v, x)\n\t\t\n\t\t\n\t\teps = Clip(TFloat(f1.getVar(\"eps\")).v, ..\n\t\tTFloat(f2.getVar(\"eps\")).v, x)\n\t\t\n\t\titr = Clip(TInt(f1.getVar(\"itr\")).v, ..\n\t\tTInt(f2.getVar(\"itr\")).v, x)\n\t\t\n\t\t\n\t\tcx = Clip(TFloat(f1.getVar(\"cx\")).v, ..\n\t\tTFloat(f2.getVar(\"cx\")).v, x)\n\t\t\n\t\tcy = Clip(TFloat(f1.getVar(\"cy\")).v, ..\n\t\tTFloat(f2.getVar(\"cy\")).v, x)\n\t\t\n\t\tcz = Clip(TFloat(f1.getVar(\"cz\")).v, ..\n\t\tTFloat(f2.getVar(\"cz\")).v, x)\n\tEnd Function\n\t\n\tMethod setGlobalsToFrame()\n\t\tcamX = TFloat(getVar(\"camX\")).v\n\t\tcamY = TFloat(getVar(\"camY\")).v\n\t\tcamZ = TFloat(getVar(\"camZ\")).v\n\t\tcamP = TFloat(getVar(\"camP\")).v\n\t\tcamT = TFloat(getVar(\"camT\")).v\n\t\tcamZoom = TFloat(getVar(\"camZoom\")).v\n\t\t\n\t\tlightX = TFloat(getVar(\"lightX\")).v\n\t\tlightY = TFloat(getVar(\"lightY\")).v\n\t\tlightZ = TFloat(getVar(\"lightZ\")).v\n\t\t\n\t\teps = TFloat(getVar(\"eps\")).v\n\t\titr = TInt(getVar(\"itr\")).v\n\t\t\n\t\tcx = TFloat(getVar(\"cx\")).v\n\t\tcy = TFloat(getVar(\"cy\")).v\n\t\tcz = TFloat(getVar(\"cz\")).v\n\tEnd Method\n\t\n\tFunction SaveToFile(filename:String)\n\t\tLocal f:TStream = WriteFile(filename)\n\t\tFor Local t:TAnimFrame = EachIn TAnimFrame.list\n\t\t\tf.WriteLine \"{\"\n\t\t\tFor Local v:TAnimFrameVar = EachIn t.varlist\n\t\t\t\tIf TFloat(v.v) <> Null\n\t\t\t\t\tf.WriteLine \"~t\" + v.name + \" = \" + TFloat(v.v).v + \"f;\"\n\t\t\t\tElse If TInt(v.v) <> Null\n\t\t\t\t\tf.WriteLine \"~t\" + v.name + \" = \" + TInt(v.v).v + \"i;\"\n\t\t\t\tElse If TDouble(v.v) <> Null\n\t\t\t\t\tf.WriteLine \"~t\" + v.name + \" = \" + TDouble(v.v).v + \"d;\"\n\t\t\t\tEnd If\n\t\t\tNext\n\t\t\tf.WriteLine \"}\"\n\t\tNext\n\t\tf.Close\n\tEnd Function\n\t\n\tFunction LoadFromFile(file:String)\n\t\tIf FileType(file) = 1\n\t\t\tfile = LoadText(file)\n\t\t\tfile = Replace(file, \" \", \"\")\n\t\t\tfile = Replace(file, Chr(9), \"\")\n\t\t\tfile = Replace(file, Chr(10), \"\")\n\t\t\tfile = Replace(file, Chr(13), \"\")\n\t\t\t\n\t\t\tLocal gs:Int = 1, ge:Int = 0, content:String\n\t\t\t\n\t\t\tWhile ge < Len(file)\n\t\t\t\tgs = Instr(file, \"{\", ge)\n\t\t\t\tge = Instr(file, \"}\", gs + 1)\n\t\t\t\tcontent = Mid(file, gs + 1, ge - gs - 1)\n\t\t\t\t\n\t\t\t\tLocal cs:Int = 1, ce:Int = 0, eq:Int\n\t\t\t\tLocal name:String, value:String, dt:String\n\t\t\t\t\n\t\t\t\tLocal t:TAnimFrame = New TAnimFrame\n\t\t\t\tt.list.AddLast(t)\n\t\t\t\t\n\t\t\t\tWhile ce < Len(content)\n\t\t\t\t\tce = Instr(content, \";\", cs)\n\t\t\t\t\tvalue = Mid(content, cs, ce - cs)\n\t\t\t\t\teq = Instr(value, \"=\")\n\t\t\t\t\t\n\t\t\t\t\tname = Left(value, eq - 1)\n\t\t\t\t\tdt = Right(value, 1)\n\t\t\t\t\tvalue = Mid(Left(value, value.Length - 1), eq + 1)\n\t\t\t\t\t\n\t\t\t\t\tSelect dt\n\t\t\t\t\t\tCase \"f\"\n\t\t\t\t\t\t\tt.setVar(name, TFloat.N(value.ToFloat()))\n\t\t\t\t\t\tCase \"i\"\n\t\t\t\t\t\t\tt.setVar(name, TInt.N(value.ToInt()))\n\t\t\t\t\t\tCase \"d\"\n\t\t\t\t\t\t\tt.setVar(name, TDouble.N(value.ToDouble()))\n\t\t\t\t\tEnd Select\n\t\t\t\t\t\n\t\t\t\t\tcs = ce + 1\n\t\t\t\tWend\n\t\t\t\t\n\t\t\tWend\n\t\tElse\n\t\t\tRuntimeError(\"File does not exist!\")\n\t\tEnd If\n\tEnd Function\n\t\nEnd Type\n\nType TAnimFrameVar\n\tField name:String\n\tField v:Object\nEnd Type\n\nType TInt\n\tField v:Int\n\tFunction N:TInt(v:Int)\n\t\tLocal t:TInt = New TInt\n\t\tt.v = v\n\t\tReturn t\n\tEnd Function\nEnd Type\n\nType TFloat\n\tField v:Float\n\tFunction N:TFloat(v:Float)\n\t\tLocal t:TFloat = New TFloat\n\t\tt.v = v\n\t\tReturn t\n\tEnd Function\nEnd Type\n\nType TDouble\n\tField v:Double\n\tFunction N:TDouble(v:Double)\n\t\tLocal t:TDouble = New TDouble\n\t\tt.v = v\n\t\tReturn t\n\tEnd Function\nEnd Type\n","old_contents":"","returncode":1,"stderr":"error: pathspec '4DJuliaShader\/4Djulia.bmx' did not match any file(s) known to git\n","license":"mit","lang":"BlitzMax"} {"commit":"6ea22c7e31f5807049242833de02ca6d164d91ab","subject":"Added BlitzMax (MonkeyMax) native file","message":"Added BlitzMax (MonkeyMax) native file\n","repos":"swoolcock\/diddy,swoolcock\/diddy,swoolcock\/diddy,swoolcock\/diddy,swoolcock\/diddy","old_file":"src\/diddy\/native\/diddy.bmax.bmx","new_file":"src\/diddy\/native\/diddy.bmax.bmx","new_contents":"' ***** Start diddy.bmax.bmx ******\r\nGlobal diddy_mouseWheel:Float = 0.0\r\n\r\nType diddy\r\n\tFunction systemMillisecs:Float()\r\n\t\tReturn Millisecs()\r\n\tEndFunction\r\n\t\r\n\tFunction setGraphics(w:int, h:int, fullScreen:Int = False)\r\n\t\tlocal d% = 0\r\n\t\tif fullScreen then d = 32\r\n\t\tGraphics w, h, d, 60\r\n\tEndFunction\r\n\t\r\n\tFunction setMouse(x:Int, y:Int)\r\n\t\tMoveMouse(x, y)\r\n\tEndFunction\r\n\t\r\n\tFunction showKeyboard()\r\n\tEndFunction\r\n\t\r\n\tFunction launchBrowser(address:String, windowName:String)\r\n\tEndFunction\r\n\t\r\n\tFunction launchEmail(email:String, subject:String, text:String)\r\n\tEndFunction\r\n\t\r\n\tFunction realMod:Float( value:Float, amount:Float )\r\n\t\tReturn value Mod amount\r\n\tEndFunction\r\n\t\r\n\tFunction startVibrate(millisecs:int)\r\n\tEndFunction\r\n\t\r\n\tFunction stopVibrate()\r\n\tEndFunction\r\n\t\r\n\tFunction getDayOfMonth:Int()\r\n\t\tLocal date$ = CurrentDate()\r\n\t\tReturn Int(date[..2])\r\n\tEndFunction\r\n\t\r\n\tFunction getDayOfWeek:Int()\r\n\t\tReturn 0\r\n\tEndFunction\r\n\t\r\n\tFunction getMonth:Int()\r\n\t\tLocal date$ = CurrentDate()\r\n\t\tReturn (Instr(\"JANFEBMARAPRMAYJUNJULAUGSEPOCTNOVDEC\", date$[3..6].ToUpper(), 1) \/ 3) + 1\r\n\tEndFunction\r\n\t\r\n\tFunction getYear:Int()\r\n\t\tLocal date$ = CurrentDate()\r\n\t\tReturn Int(date[date.length - 4..]);\r\n\tEndFunction\r\n\t\r\n\tFunction getHours:Int()\r\n\t\tLocal time$ = CurrentTime()\r\n\t\tReturn Int(time[..2])\r\n\tEndFunction\r\n\t\r\n\tFunction getMinutes:Int()\r\n\t\tLocal time$ = CurrentTime()\r\n\t\tReturn Int(time[3..5])\r\n\tEndFunction\r\n\t\r\n\tFunction getSeconds:Int()\r\n\t\tLocal time$ = CurrentTime()\r\n\t\tReturn Int(time[6..8])\r\n\tEndFunction\r\n\t\r\n\tFunction getMilliSeconds:Int()\r\n\t\tReturn Millisecs()\r\n\tEndFunction\r\n\t\r\n\tFunction startGps()\r\n\tEndFunction\r\n\t\r\n\tFunction getLatitiude:String()\r\n\t\tReturn \"\"\r\n\tEndFunction\r\n\t\r\n\tFunction getLongitude:String()\r\n\t\tReturn \"\"\r\n\tEndFunction\r\n\r\n\tFunction showAlertDialog(title:String, message:String)\r\n\tEndFunction\r\n\t\r\n\tFunction getInputString:String()\r\n\t\tReturn \"\";\r\n\tEndFunction\r\n\t\r\n\tFunction getPixel:Int( x:int, y:int )\r\n'\t\tunsigned char pix[4];\r\n'\t\tglReadPixels(x, app->graphics->height-y ,1 ,1 ,GL_RGBA ,GL_UNSIGNED_BYTE ,pix);\r\n'\t\treturn (pix[3]<<24) | (pix[0]<<16) | (pix[1]<<8) | pix[2];\r\n\t\tReturn 0\r\n\tEndFunction\r\n\t\r\n\tFunction mouseZInit()\r\n\tEndFunction\r\n\r\n\tFunction mouseZ:Float()\r\n\t\tLocal ret:Float = BlitzMaxMouseZ() - diddy_mouseWheel\r\n\t\tdiddy_mouseWheel = BlitzMaxMouseZ()\r\n\t\tReturn ret\r\n\tEndFunction\r\nEndType\r\n\r\nFunction BlitzMaxMouseZ:Float()\r\n\tReturn MouseZ()\r\nEndFunction\r\n\r\n' ***** End diddy.bmax.bmx ******\r\n\r\n\r\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'src\/diddy\/native\/diddy.bmax.bmx' did not match any file(s) known to git\n","license":"mit","lang":"BlitzMax"} {"commit":"82ca5e301c6639a0c1f09a056db27587602da727","subject":"Fixed matrix stuff.","message":"Fixed matrix stuff.\n\n--HG--\nextra : convert_revision : svn%3Ae934d3cd-0d57-f34a-94d0-9e8d31ae1c29\/trunk%40373\n","repos":"programmerby\/diddy-mirror,programmerby\/diddy-mirror,programmerby\/diddy-mirror,programmerby\/diddy-mirror","old_file":"monkeymax\/modules\/mojo\/native\/mojo.bmax.bmx","new_file":"monkeymax\/modules\/mojo\/native\/mojo.bmax.bmx","new_contents":"' ***** Start mojo.bmax.bmx ******\r\n\r\nGlobal app:gxtkApp\r\n\r\nType gxtkApp\r\n\tField ginput:gxtkInput\r\n\tField gaudio:gxtkAudio\r\n\tField ggraphics:gxtkGraphics\r\n\r\n\tField dead:Int=0\r\n\tField suspended:Int=0\r\n\tField vloading:Int=0\r\n\tField maxloading:Int=0\r\n\tField updateRate:Int=0\r\n\tField nextUpdate:Float=0\r\n\tField updatePeriod:Float=0\r\n\tField startMillis:Float=0\r\n\t\r\n\tMethod New()' gxtkApp()\r\n\t\tapp=Self\r\n\t\tggraphics=New gxtkGraphics\r\n\tEndMethod\r\n\t\r\n\tMethod Setup()\r\n\t\tginput=New gxtkInput\r\n\t\tgaudio=New gxtkAudio\r\n\r\n\t\tbb_input_SetInputDevice(ginput)\r\n\t\tbb_audio_SetAudioDevice(gaudio)\r\n\t\t\r\n\t\tstartMillis=BlitzMaxMillisecs()\r\n\t\t\r\n\t\tSetFrameRate( 0 )\r\n\t\t\r\n\t\tInvokeOnCreate()\r\n\t\tInvokeOnRender()\r\n\t\tUpdate()\r\n\tEndMethod\r\n\t\r\n\tMethod Update()\r\n\t\tWhile Not AppTerminate()\r\n\t\t\tLocal updates:Int = 0\r\n\t\t\t\r\n\t\t\tLocal cont:Int = 1\r\n\t\t\tWhile (cont)\r\n\t\t\t\tnextUpdate:+updatePeriod\r\n\t\t\t\tInvokeOnUpdate()\r\n\t\t\t\tIf Not updatePeriod Then cont = 0\r\n\t\t\t\tIf nextUpdate>BlitzMaxMillisecs() Then cont = 0\r\n\t\t\t\tupdates:+1\r\n\t\t\t\tIf updates = 7 Then\r\n\t\t\t\t\tnextUpdate = BlitzMaxMillisecs()\r\n\t\t\t\t\tcont = 0\r\n\t\t\t\tEndIf\r\n\t\t\tWend\r\n\t\t\tInvokeOnRender()\r\n\t\tWend\r\n\tEndMethod\r\n\t\r\n\tMethod InvokeOnCreate()\r\n\t\tIf dead Return\r\n\t\tdead = 1\r\n\t\tOnCreate()\r\n\t\tdead = 0\r\n\tEndMethod\r\n\r\n\tMethod InvokeOnUpdate()\r\n\t\tIf dead Or suspended Or Not updateRate Or vloading Return\r\n\t\tOnUpdate()\r\n\tEndMethod\r\n\t\r\n\tMethod InvokeOnRender()\r\n\t\tIf dead Or suspended Return\r\n\t\tggraphics.BeginRender()\r\n\t\tIf vloading\r\n\t\t\tOnLoading()\r\n\t\tElse\r\n\t\t\tOnRender()\r\n\t\tEndIf\r\n\t\tggraphics.EndRender()\r\n\tEndMethod\r\n\t\r\n\t\r\n\tMethod SetFrameRate( fps:Int )\r\n\t\tIf fps\r\n\t\t\tupdatePeriod=1000.0\/fps\r\n\t\t\tnextUpdate=BlitzMaxMillisecs() +updatePeriod\r\n\t\tElse\r\n\t\t\tupdatePeriod=0\r\n\t\tEndIf\r\n\tEndMethod\r\n\r\n\tMethod LoadState:String()\r\n'\t\tvar file:SharedObject=SharedObject.getLocal( \"gxtkapp\" );\r\n'\t\tvar state:String=file.data.state;\r\n'\t\tfile.close();\r\n'\t\tif( state ) return state;\r\n\t\tReturn \"\"\r\n\tEndMethod\r\n\t\r\n\tMethod SaveState:Int( state:String )\r\n'\t\tvar file:SharedObject=SharedObject.getLocal( \"gxtkapp\" );\r\n'\t\tfile.data.state=state;\r\n'\t\tfile.close();\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod LoadString:String( path:String )\r\n\t\tpath = \"data\/\" + path\r\n\t\tReturn LoadText( path )\r\n\tEndMethod\r\n\t\r\n\t' ***** GXTK API *****\r\n\t\r\n\tMethod GraphicsDevice:gxtkGraphics()\r\n\t\tReturn ggraphics\r\n\tEndMethod\r\n\r\n\tMethod InputDevice:gxtkInput()\r\n\t\tReturn ginput\r\n\tEndMethod\r\n\r\n\tMethod AudioDevice:gxtkAudio()\r\n\t\tReturn gaudio\r\n\tEndMethod\r\n\r\n\tMethod SetUpdateRate:Int(hertz:Int)\r\n\t\tupdateRate = hertz\r\n\t\tIf Not vloading Then SetFrameRate(updateRate)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod MilliSecs:Int()\r\n\t\tReturn BlitzMaxMillisecs() - startMillis\r\n\tEndMethod\r\n\t\r\n\tMethod Loading:Int()\r\n\t\tReturn vloading\r\n\tEndMethod\r\n\r\n\tMethod OnCreate:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod OnUpdate:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod OnSuspend:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod OnResume:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod OnRender:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod OnLoading:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkGraphics\r\n\tField gmode:Int = 1\r\n\tField ix:Float=1,iy:Float,jx:Float,jy:Float=1,tx:Float,ty:Float\r\n\tField sx:Float=1,sy:Float=1,rot:Float=0\r\n\t\r\n\tMethod Mode:Int()\r\n\t\tReturn gmode\r\n\tEndMethod\r\n\t\r\n\tMethod Cls:Int(r:Int = 0, g:Int = 0, b:Int = 0)\r\n\t\tBlitzMaxCls(r, g, b)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawPoint:Int(x:Float, y:Float)\r\n\t\tLocal nx:Float = TransX(x,y)\r\n\t\tLocal ny:Float = TransY(x,y)\r\n\t\tPlot nx, ny\r\n\tEndMethod\r\n\t\r\n\tMethod LoadSurface:gxtkSurface(path:String)\r\n\t\tLocal image:TImage = LoadImage(\"data\/\"+path)\r\n\t\tIf image Then\r\n\t\t\tLocal gs:gxtkSurface = New gxtkSurface\r\n\t\t\tgs.setImage(image)\r\n\t\t\tReturn gs\r\n\t\tEndIf\r\n\t\tReturn Null\r\n\tEndMethod\r\n\t\r\n\tMethod BeginRender()\r\n\tEndMethod\r\n\t\r\n\tMethod EndRender()\r\n\t\tFlip\r\n\tEndMethod\r\n\t\r\n\tMethod SetColor:Int(r:Int, g:Int, b:Int)\r\n\t\tBlitzMaxSetColor(r, g, b)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod SetAlpha:Int(a:Float)\r\n\t\tBlitzMaxSetAlpha(a)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod SetBlend:Int(blend:Int)\r\n\t\tBlitzMaxSetBlend(blend)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod Width:Int()\r\n\t\tReturn GraphicsWidth()\r\n\tEndMethod\r\n\t\r\n\tMethod Height:Int()\r\n\t\tReturn GraphicsHeight()\r\n\tEndMethod\r\n\t\r\n\tMethod SetScissor:Int(x:Int, y:Int, w:Int, h:Int)\r\n\t\tSetViewport(x, y, w, h) ' NOT TESTED!\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod TransX:Float(x:Float, y:Float)\r\n\t\tReturn ix*x + jx*y + tx\r\n\tEndMethod\r\n\t\r\n\tMethod TransY:Float(x:Float, y:Float)\r\n\t\tReturn iy*x + jy*y + ty\r\n\tEndMethod\r\n\t\r\n\tMethod SetMatrix:Int(ix:Float,iy:Float,jx:Float,jy:Float,tx:Float,ty:Float)\r\n\t\tSelf.ix = ix ; Self.iy = iy\r\n\t\tSelf.jx = jx ; Self.jy = jy\r\n\t\tSelf.tx = tx ; Self.ty = ty\r\n\t\tsx = Sqr( (ix*ix) + (jx*jx) )\r\n\t\tsy = Sqr( (iy*iy) + (jy*jy) )\r\n\t\trot = -Atan2( jx, ix )\r\n\t\tSetTransform( rot, sx, sy )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawSurface:Int(surface:gxtkSurface,x:Float,y:Float)\r\n\t\tLocal nx:Float = TransX(x,y)\r\n\t\tLocal ny:Float = TransY(x,y)\r\n\t\tDrawImage(surface.image, nx, ny, 0)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawSurface2:Int(surface:gxtkSurface,x:Float,y:Float, srcx:Int, srcy:Int, srcw:Int, srch:Int )\r\n\t\tLocal nx:Float = TransX(x,y)\r\n\t\tLocal ny:Float = TransY(x,y)\r\n\t\tDrawSubImageRect(surface.image, nx, ny, srcw, srch, srcx, srcy, srcw, srch)\t\t\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawLine:Int( x1:Float,y1:Float,x2:Float,y2:Float )\r\n\t\tLocal nx1:Float = TransX(x1,y1)\r\n\t\tLocal ny1:Float = TransY(x1,y1)\r\n\t\tLocal nx2:Float = TransX(x2,y2)\r\n\t\tLocal ny2:Float = TransY(x2,y2)\r\n\t\t' Need to reset transform so that BlitzMax doesn't try to apply rotation\r\n\t\tSetTransform( 0, 1, 1 )\r\n\t\tBlitzMaxDrawLine(nx1, ny1, nx2, ny2)\r\n\t\tSetTransform( rot, sx, sy )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawOval:Int( x:Float, y:Float, w:Float, h:Float )\r\n\t\tLocal nx:Float = TransX(x,y)\r\n\t\tLocal ny:Float = TransY(x,y)\r\n\t\tBlitzMaxDrawOval(nx, ny, w, h)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawPoly:Int(vertices:Float[])\r\n\t\t' setting the origin to use the current rotation translation\r\n\t\tSetOrigin(TransX(0,0), TransY(0,0))\r\n\t\tBlitzMaxDrawPoly( vertices )\r\n\t\tSetOrigin(0, 0)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawRect:Int( x:Float, y:Float, w:Float, h:Float )\r\n\t\tLocal nx:Float = TransX(x,y)\r\n\t\tLocal ny:Float = TransY(x,y)\r\n\t\tBlitzMaxDrawRect(nx, ny, w, h)\r\n\t\tReturn 0\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkInput\r\n\tMethod MouseX:Float()\r\n\t\tReturn BRL.PolledInput.MouseX()\r\n\tEndMethod\r\n\r\n\tMethod MouseY:Float()\r\n\t\tReturn BRL.PolledInput.MouseY()\r\n\tEndMethod\r\n\t\r\n\tMethod KeyDown:Int( key:Int )\r\n\t\tif( key = 384 ) key = 1 ' change TOUCH0 to MOUSE_LMB\r\n\r\n\t\tIf( key >= 1 And key <= 3 )\r\n\t\t\tReturn BRL.PolledInput.MouseDown( key )\r\n\t\tEndIf\r\n\t\tIf key < 256\r\n\t\t\tReturn BRL.PolledInput.KeyDown( key )\r\n\t\tElse\r\n\t\t\tReturn 0\r\n\t\tEndIf\r\n\tEndMethod\r\n\r\n\tMethod KeyHit:Int( key:Int )\r\n\t\tif( key = 384 ) key = 1 ' change TOUCH0 to MOUSE_LMB\r\n\t\tIf( key >= 1 And key <= 3 )\r\n\t\t\tReturn BRL.PolledInput.MouseHit( key )\r\n\t\tEndIf\r\n\t\tIf key < 256\r\n\t\t\tReturn BRL.PolledInput.KeyHit( key )\r\n\t\tElse\r\n\t\t\tReturn 0\r\n\t\tEndIf\r\n\tEndMethod\r\n\r\n\tMethod GetChar:Int()\r\n\t\tReturn BRL.PolledInput.GetChar()\r\n\tEndMethod\r\n\r\n\tMethod JoyX:Int( index:Int )\r\n\t\tReturn Pub.FreeJoy.JoyX( index )\r\n\tEndMethod\r\n\r\n\tMethod JoyY:Int( index:Int )\r\n\t\tReturn Pub.FreeJoy.JoyY( index )\r\n\tEndMethod\r\n\r\n\tMethod JoyZ:Int( index:Int )\r\n\t\tReturn Pub.FreeJoy.JoyZ( index )\r\n\tEndMethod\r\n\r\n\tMethod TouchX:Float( index:Int )\r\n\t\tReturn BRL.PolledInput.MouseX()\r\n\tEndMethod\r\n\r\n\tMethod TouchY:Float( index:Int )\r\n\t\tReturn BRL.PolledInput.MouseY()\r\n\tEndMethod\r\n\t\r\n\tMethod AccelX:Int()\r\n\t\treturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod AccelY:Int()\r\n\t\treturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod AccelZ:Int()\r\n\t\treturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod SetKeyboardEnabled:Int( enabled:int )\r\n\t\tReturn 0\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkChannel\r\n\tField channel:TChannel\t' null then not playing\r\n\tField sample:gxtkSample\r\n\tField loops:int\r\n\t'Field transform:SoundTransform=new SoundTransform()\r\n\t'Field pausepos:Number\r\n\tField state:int\r\n\t\r\n\tMethod New()\r\n\t\tchannel = New TChannel\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkAudio\r\n\tField amusicState:Int = 0\r\n\tField channels:gxtkChannel[] = New gxtkChannel[33]\r\n\t\r\n\tMethod New()\r\n\t\tFor local i:Int = 0 To 33 - 1\r\n\t\t\tchannels[i] = New gxtkChannel\r\n\t\tNext\r\n\tEndMethod\r\n\t\r\n\tMethod MusicState:Int()\r\n'\t\tIf( musicState = 1 And music.isPlaying() = False )\r\n'\t\t\tmusicState = 0;\r\n'\t\tEndif\r\n\t\tReturn amusicState\r\n\tEndMethod\r\n\t\r\n\tMethod PlayMusic:Int( path:String, flags:Int )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod ChannelState:int( channel:int )\r\n\t\tReturn -1\r\n\tEndMethod\r\n\t\r\n\tMethod StopMusic()\r\n\tEndMethod\r\n\t\r\n\tMethod StopChannel( channel:Int )\r\n\tEndMethod\r\n\r\n\tMethod PlaySample( sound:gxtkSample, channel:Int, flags:Int )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\t\r\n\t\t'If chan.state <> 0 Then chan.channel.Stop() <-- this crashes after the first play!?\r\n\t\t\r\n\t\tchan.sample = sound\r\n\t\t'chan.loops = flags ? 0x7fffffff : 0;\r\n\t\t'chan.channel = sample.sound.play( 0,chan.loops,chan.transform );\r\n\t\t'chan.channel = sound\r\n\t\tchan.state=1\r\n\t\r\n\t\tPlaySound( sound.sound, chan.channel )\r\n\tEndMethod\r\n\r\n\tMethod SetPan( channel:Int, pan:Float )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tchan.channel.SetPan(pan)\r\n\tEndMethod\r\n\r\n\tMethod SetRate( channel:Int, rate:Float )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tchan.channel.SetRate(rate)\r\n\tEndMethod\r\n\r\n\tMethod PauseMusic:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod ResumeMusic:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod SetMusicVolume:Int( volume:Float )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod SetVolume:Int( channel:Int, volume:Float )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tchan.channel.SetVolume(volume)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod LoadSample:gxtkSample( path:String )\r\n\t\tLocal extension:String = ExtractExt( path)\r\n\t\tIf extension = \"ogg\" Or extension = \"wav\" Then\r\n\t\t\tLocal sound:TSound = LoadSound(\"data\/\"+path)\r\n\t\t\tIf sound Then\r\n\t\t\t\tLocal gs:gxtkSample = New gxtkSample\r\n\t\t\t\tgs.setSound(sound)\r\n\t\t\t\tReturn gs\r\n\t\t\tEndIf\r\n\t\tElse\r\n\t\t\tRuntimeError \"BlitzMax can only use ogg and wav file formats\"\r\n\t\tEndIf\r\n\t\tReturn Null\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkSample\r\n\tField sound:TSound\r\n\t\r\n\tMethod setSound(sound:TSound)\r\n\t\tSelf.sound = sound\r\n\tEndMethod\r\n\t\r\n\tMethod Discard()\r\n\t\tSelf.sound = null\r\n\tEndMethod\r\nEndType\r\n\r\nFunction BlitzMaxDrawPoly:Int(vertices:Float[])\r\n\tDrawPoly vertices\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxDrawRect:Int( x:Float, y:Float, w:Float, h:Float )\r\n\tDrawRect x, y, w, h\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxDrawOval:Int( x:Float, y:Float, w:Float, h:Float )\r\n\tDrawOval x, y, w, h\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxDrawLine:Int( x1:Float,y1:Float,x2:Float,y2:Float )\r\n\tDrawLine x1, y1, x2, y2\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxMillisecs:Int()\r\n\tReturn MilliSecs()\r\nEndFunction\r\n\r\nFunction BlitzMaxSetColor(r:Int, g:Int, b:Int)\r\n\tSetColor(r, g, b)\r\nEndFunction\r\n\r\nFunction BlitzMaxSetBlend(blend:Int)\r\n\tSelect blend\r\n\t\tCase 0\r\n\t\t\tSetBlend( ALPHABLEND )\r\n\t\tCase 1\r\n\t\t\tSetBlend( LIGHTBLEND )\r\n\tEnd Select\r\nEndFunction\r\n\r\nFunction BlitzMaxSetAlpha(a:Float)\r\n\tSetAlpha(a)\r\nEndFunction\r\n\r\nFunction BlitzMaxCls(r:Int = 0, g:Int = 0, b:Int = 0)\r\n\tSetClsColor(r, g, b)\r\n\tCls\r\nEndFunction\r\n\r\nType gxtkSurface\r\n\tField w:Int, h:Int\r\n\tField image:TImage\r\n\t\r\n\tMethod setImage(image:TImage)\r\n\t\tSelf.image = image\r\n\tEndMethod\r\n\t\r\n\tMethod Width:Int()\r\n\t\tReturn image.Width\r\n\tEndMethod\r\n\t\r\n\tMethod Height:Int()\r\n\t\tReturn image.Height\r\n\tEndMethod\r\n\t\r\n\tMethod Discard()\r\n\tEndMethod\r\nEndType\r\n\r\n' ***** End mojo.bmax.bmx ******\r\n\r\n","old_contents":"' ***** Start mojo.bmax.bmx ******\r\n\r\nGlobal app:gxtkApp\r\n\r\nType gxtkApp\r\n\tField ginput:gxtkInput\r\n\tField gaudio:gxtkAudio\r\n\tField ggraphics:gxtkGraphics\r\n\r\n\tField dead:Int=0\r\n\tField suspended:Int=0\r\n\tField vloading:Int=0\r\n\tField maxloading:Int=0\r\n\tField updateRate:Int=0\r\n\tField nextUpdate:Float=0\r\n\tField updatePeriod:Float=0\r\n\tField startMillis:Float=0\r\n\t\r\n\tMethod New()' gxtkApp()\r\n\t\tapp=Self\r\n\t\tggraphics=New gxtkGraphics\r\n\tEndMethod\r\n\t\r\n\tMethod Setup()\r\n\t\tginput=New gxtkInput\r\n\t\tgaudio=New gxtkAudio\r\n\r\n\t\tbb_input_SetInputDevice(ginput)\r\n\t\tbb_audio_SetAudioDevice(gaudio)\r\n\t\t\r\n\t\tstartMillis=BlitzMaxMillisecs()\r\n\t\t\r\n\t\tSetFrameRate( 0 )\r\n\t\t\r\n\t\tInvokeOnCreate()\r\n\t\tInvokeOnRender()\r\n\t\tUpdate()\r\n\tEndMethod\r\n\t\r\n\tMethod Update()\r\n\t\tWhile Not AppTerminate()\r\n\t\t\tLocal updates:Int = 0\r\n\t\t\t\r\n\t\t\tLocal cont:Int = 1\r\n\t\t\tWhile (cont)\r\n\t\t\t\tnextUpdate:+updatePeriod\r\n\t\t\t\tInvokeOnUpdate()\r\n\t\t\t\tIf Not updatePeriod Then cont = 0\r\n\t\t\t\tIf nextUpdate>BlitzMaxMillisecs() Then cont = 0\r\n\t\t\t\tupdates:+1\r\n\t\t\t\tIf updates = 7 Then\r\n\t\t\t\t\tnextUpdate = BlitzMaxMillisecs()\r\n\t\t\t\t\tcont = 0\r\n\t\t\t\tEndIf\r\n\t\t\tWend\r\n\t\t\tInvokeOnRender()\r\n\t\tWend\r\n\tEndMethod\r\n\t\r\n\tMethod InvokeOnCreate()\r\n\t\tIf dead Return\r\n\t\tdead = 1\r\n\t\tOnCreate()\r\n\t\tdead = 0\r\n\tEndMethod\r\n\r\n\tMethod InvokeOnUpdate()\r\n\t\tIf dead Or suspended Or Not updateRate Or vloading Return\r\n\t\tOnUpdate()\r\n\tEndMethod\r\n\t\r\n\tMethod InvokeOnRender()\r\n\t\tIf dead Or suspended Return\r\n\t\tggraphics.BeginRender()\r\n\t\tIf vloading\r\n\t\t\tOnLoading()\r\n\t\tElse\r\n\t\t\tOnRender()\r\n\t\tEndIf\r\n\t\tggraphics.EndRender()\r\n\tEndMethod\r\n\t\r\n\t\r\n\tMethod SetFrameRate( fps:Int )\r\n\t\tIf fps\r\n\t\t\tupdatePeriod=1000.0\/fps\r\n\t\t\tnextUpdate=BlitzMaxMillisecs() +updatePeriod\r\n\t\tElse\r\n\t\t\tupdatePeriod=0\r\n\t\tEndIf\r\n\tEndMethod\r\n\r\n\tMethod LoadState:String()\r\n'\t\tvar file:SharedObject=SharedObject.getLocal( \"gxtkapp\" );\r\n'\t\tvar state:String=file.data.state;\r\n'\t\tfile.close();\r\n'\t\tif( state ) return state;\r\n\t\tReturn \"\"\r\n\tEndMethod\r\n\t\r\n\tMethod SaveState:Int( state:String )\r\n'\t\tvar file:SharedObject=SharedObject.getLocal( \"gxtkapp\" );\r\n'\t\tfile.data.state=state;\r\n'\t\tfile.close();\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod LoadString:String( path:String )\r\n\t\tpath = \"data\/\" + path\r\n\t\tReturn LoadText( path )\r\n\tEndMethod\r\n\t\r\n\t' ***** GXTK API *****\r\n\t\r\n\tMethod GraphicsDevice:gxtkGraphics()\r\n\t\tReturn ggraphics\r\n\tEndMethod\r\n\r\n\tMethod InputDevice:gxtkInput()\r\n\t\tReturn ginput\r\n\tEndMethod\r\n\r\n\tMethod AudioDevice:gxtkAudio()\r\n\t\tReturn gaudio\r\n\tEndMethod\r\n\r\n\tMethod SetUpdateRate:Int(hertz:Int)\r\n\t\tupdateRate = hertz\r\n\t\tIf Not vloading Then SetFrameRate(updateRate)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod MilliSecs:Int()\r\n\t\tReturn BlitzMaxMillisecs() - startMillis\r\n\tEndMethod\r\n\t\r\n\tMethod Loading:Int()\r\n\t\tReturn vloading\r\n\tEndMethod\r\n\r\n\tMethod OnCreate:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod OnUpdate:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod OnSuspend:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod OnResume:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod OnRender:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod OnLoading:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkGraphics\r\n\tField gmode:Int = 1\r\n\r\n\tMethod Mode:Int()\r\n\t\tReturn gmode\r\n\tEndMethod\r\n\t\r\n\tMethod Cls:Int(r:Int = 0, g:Int = 0, b:Int = 0)\r\n\t\tBlitzMaxCls(r, g, b)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawPoint:Int(x:Float, y:Float)\r\n\t\tPlot x, y\r\n\tEndMethod\r\n\t\r\n\tMethod LoadSurface:gxtkSurface(path:String)\r\n\t\tLocal image:TImage = LoadImage(\"data\/\"+path)\r\n\t\tIf image Then\r\n\t\t\tLocal gs:gxtkSurface = New gxtkSurface\r\n\t\t\tgs.setImage(image)\r\n\t\t\tReturn gs\r\n\t\tEndIf\r\n\t\tReturn Null\r\n\tEndMethod\r\n\t\r\n\tMethod BeginRender()\r\n\tEndMethod\r\n\t\r\n\tMethod EndRender()\r\n\t\tFlip\r\n\tEndMethod\r\n\t\r\n\tMethod SetColor:Int(r:Int, g:Int, b:Int)\r\n\t\tBlitzMaxSetColor(r, g, b)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod SetAlpha:Int(a:Float)\r\n\t\tBlitzMaxSetAlpha(a)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod SetBlend:Int(blend:Int)\r\n\t\tBlitzMaxSetBlend(blend)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod Width:Int()\r\n\t\tReturn GraphicsWidth()\r\n\tEndMethod\r\n\t\r\n\tMethod Height:Int()\r\n\t\tReturn GraphicsHeight()\r\n\tEndMethod\r\n\t\r\n\tMethod SetScissor:Int(x:Int, y:Int, w:Int, h:Int)\r\n\t\tSetViewport(x, y, w, h) ' NOT TESTED!\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod SetMatrix:Int(ix:Float,iy:Float,jx:Float,jy:Float,tx:Float,ty:Float)\r\n\t\tLocal sx:Float = Sqr( (ix*ix) + (jx*jx) )\r\n\t\tLocal sy:Float = Sqr( (iy*iy) + (jy*jy) )\r\n\t\tLocal rot:Float = -Atan2( jx, ix )\r\n\t\tSetTransform( rot, sx, sy )\r\n\t\tSetOrigin( tx, ty )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawSurface:Int(surface:gxtkSurface,x:Float,y:Float)\r\n\t\tDrawImage(surface.image, x, y, 0)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawSurface2:Int(surface:gxtkSurface,x:Float,y:Float, srcx:Int, srcy:Int, srcw:Int, srch:Int )\r\n\t\tDrawSubImageRect(surface.image, x, y, srcw, srch, srcx, srcy, srcw, srch)\t\t\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawLine:Int( x1:Float,y1:Float,x2:Float,y2:Float )\r\n\t\tBlitzMaxDrawLine(x1, y1, x2, y2)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawOval:Int( x:Float, y:Float, w:Float, h:Float )\r\n\t\tBlitzMaxDrawOval(x, y, w, h)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawPoly:Int(vertices:Float[])\r\n\t\tBlitzMaxDrawPoly( vertices )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod DrawRect:Int( x:Float, y:Float, w:Float, h:Float )\r\n\t\tBlitzMaxDrawRect(x, y, w, h)\r\n\t\tReturn 0\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkInput\r\n\tMethod MouseX:Float()\r\n\t\tReturn BRL.PolledInput.MouseX()\r\n\tEndMethod\r\n\r\n\tMethod MouseY:Float()\r\n\t\tReturn BRL.PolledInput.MouseY()\r\n\tEndMethod\r\n\t\r\n\tMethod KeyDown:Int( key:Int )\r\n\t\tif( key = 384 ) key = 1 ' change TOUCH0 to MOUSE_LMB\r\n\r\n\t\tIf( key >= 1 And key <= 3 )\r\n\t\t\tReturn BRL.PolledInput.MouseDown( key )\r\n\t\tEndIf\r\n\t\tIf key < 256\r\n\t\t\tReturn BRL.PolledInput.KeyDown( key )\r\n\t\tElse\r\n\t\t\tReturn 0\r\n\t\tEndIf\r\n\tEndMethod\r\n\r\n\tMethod KeyHit:Int( key:Int )\r\n\t\tif( key = 384 ) key = 1 ' change TOUCH0 to MOUSE_LMB\r\n\t\tIf( key >= 1 And key <= 3 )\r\n\t\t\tReturn BRL.PolledInput.MouseHit( key )\r\n\t\tEndIf\r\n\t\tIf key < 256\r\n\t\t\tReturn BRL.PolledInput.KeyHit( key )\r\n\t\tElse\r\n\t\t\tReturn 0\r\n\t\tEndIf\r\n\tEndMethod\r\n\r\n\tMethod GetChar:Int()\r\n\t\tReturn BRL.PolledInput.GetChar()\r\n\tEndMethod\r\n\r\n\tMethod JoyX:Int( index:Int )\r\n\t\tReturn Pub.FreeJoy.JoyX( index )\r\n\tEndMethod\r\n\r\n\tMethod JoyY:Int( index:Int )\r\n\t\tReturn Pub.FreeJoy.JoyY( index )\r\n\tEndMethod\r\n\r\n\tMethod JoyZ:Int( index:Int )\r\n\t\tReturn Pub.FreeJoy.JoyZ( index )\r\n\tEndMethod\r\n\r\n\tMethod TouchX:Float( index:Int )\r\n\t\tReturn BRL.PolledInput.MouseX()\r\n\tEndMethod\r\n\r\n\tMethod TouchY:Float( index:Int )\r\n\t\tReturn BRL.PolledInput.MouseY()\r\n\tEndMethod\r\n\t\r\n\tMethod AccelX:Int()\r\n\t\treturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod AccelY:Int()\r\n\t\treturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod AccelZ:Int()\r\n\t\treturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod SetKeyboardEnabled:Int( enabled:int )\r\n\t\tReturn 0\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkChannel\r\n\tField channel:TChannel\t' null then not playing\r\n\tField sample:gxtkSample\r\n\tField loops:int\r\n\t'Field transform:SoundTransform=new SoundTransform()\r\n\t'Field pausepos:Number\r\n\tField state:int\r\n\t\r\n\tMethod New()\r\n\t\tchannel = New TChannel\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkAudio\r\n\tField amusicState:Int = 0\r\n\tField channels:gxtkChannel[] = New gxtkChannel[33]\r\n\t\r\n\tMethod New()\r\n\t\tFor local i:Int = 0 To 33 - 1\r\n\t\t\tchannels[i] = New gxtkChannel\r\n\t\tNext\r\n\tEndMethod\r\n\t\r\n\tMethod MusicState:Int()\r\n'\t\tIf( musicState = 1 And music.isPlaying() = False )\r\n'\t\t\tmusicState = 0;\r\n'\t\tEndif\r\n\t\tReturn amusicState\r\n\tEndMethod\r\n\t\r\n\tMethod PlayMusic:Int( path:String, flags:Int )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod ChannelState:int( channel:int )\r\n\t\tReturn -1\r\n\tEndMethod\r\n\t\r\n\tMethod StopMusic()\r\n\tEndMethod\r\n\t\r\n\tMethod StopChannel( channel:Int )\r\n\tEndMethod\r\n\r\n\tMethod PlaySample( sound:gxtkSample, channel:Int, flags:Int )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\t\r\n\t\t'If chan.state <> 0 Then chan.channel.Stop() <-- this crashes after the first play!?\r\n\t\t\r\n\t\tchan.sample = sound\r\n\t\t'chan.loops = flags ? 0x7fffffff : 0;\r\n\t\t'chan.channel = sample.sound.play( 0,chan.loops,chan.transform );\r\n\t\t'chan.channel = sound\r\n\t\tchan.state=1\r\n\t\r\n\t\tPlaySound( sound.sound, chan.channel )\r\n\tEndMethod\r\n\r\n\tMethod SetPan( channel:Int, pan:Float )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tchan.channel.SetPan(pan)\r\n\tEndMethod\r\n\r\n\tMethod SetRate( channel:Int, rate:Float )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tchan.channel.SetRate(rate)\r\n\tEndMethod\r\n\r\n\tMethod PauseMusic:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod ResumeMusic:Int()\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod SetMusicVolume:Int( volume:Float )\r\n\t\tReturn 0\r\n\tEndMethod\r\n\r\n\tMethod SetVolume:Int( channel:Int, volume:Float )\r\n\t\tLocal chan:gxtkChannel = channels[channel]\r\n\t\tchan.channel.SetVolume(volume)\r\n\t\tReturn 0\r\n\tEndMethod\r\n\t\r\n\tMethod LoadSample:gxtkSample( path:String )\r\n\t\tLocal extension:String = ExtractExt( path)\r\n\t\tIf extension = \"ogg\" Or extension = \"wav\" Then\r\n\t\t\tLocal sound:TSound = LoadSound(\"data\/\"+path)\r\n\t\t\tIf sound Then\r\n\t\t\t\tLocal gs:gxtkSample = New gxtkSample\r\n\t\t\t\tgs.setSound(sound)\r\n\t\t\t\tReturn gs\r\n\t\t\tEndIf\r\n\t\tElse\r\n\t\t\tRuntimeError \"BlitzMax can only use ogg and wav file formats\"\r\n\t\tEndIf\r\n\t\tReturn Null\r\n\tEndMethod\r\nEndType\r\n\r\nType gxtkSample\r\n\tField sound:TSound\r\n\t\r\n\tMethod setSound(sound:TSound)\r\n\t\tSelf.sound = sound\r\n\tEndMethod\r\n\t\r\n\tMethod Discard()\r\n\t\tSelf.sound = null\r\n\tEndMethod\r\nEndType\r\n\r\nFunction BlitzMaxDrawPoly:Int(vertices:Float[])\r\n\tDrawPoly vertices\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxDrawRect:Int( x:Float, y:Float, w:Float, h:Float )\r\n\tDrawRect x, y, w, h\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxDrawOval:Int( x:Float, y:Float, w:Float, h:Float )\r\n\tDrawOval x, y, w, h\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxDrawLine:Int( x1:Float,y1:Float,x2:Float,y2:Float )\r\n\tDrawLine x1, y1, x2, y2\r\n\tReturn 0\r\nEndFunction\r\n\r\nFunction BlitzMaxMillisecs:Int()\r\n\tReturn MilliSecs()\r\nEndFunction\r\n\r\nFunction BlitzMaxSetColor(r:Int, g:Int, b:Int)\r\n\tSetColor(r, g, b)\r\nEndFunction\r\n\r\nFunction BlitzMaxSetBlend(blend:Int)\r\n\tSelect blend\r\n\t\tCase 0\r\n\t\t\tSetBlend( ALPHABLEND )\r\n\t\tCase 1\r\n\t\t\tSetBlend( LIGHTBLEND )\r\n\tEnd Select\r\nEndFunction\r\n\r\nFunction BlitzMaxSetAlpha(a:Float)\r\n\tSetAlpha(a)\r\nEndFunction\r\n\r\nFunction BlitzMaxCls(r:Int = 0, g:Int = 0, b:Int = 0)\r\n\tSetClsColor(r, g, b)\r\n\tCls\r\nEndFunction\r\n\r\nType gxtkSurface\r\n\tField w:Int, h:Int\r\n\tField image:TImage\r\n\t\r\n\tMethod setImage(image:TImage)\r\n\t\tSelf.image = image\r\n\tEndMethod\r\n\t\r\n\tMethod Width:Int()\r\n\t\tReturn image.Width\r\n\tEndMethod\r\n\t\r\n\tMethod Height:Int()\r\n\t\tReturn image.Height\r\n\tEndMethod\r\n\t\r\n\tMethod Discard()\r\n\tEndMethod\r\nEndType\r\n\r\n' ***** End mojo.bmax.bmx ******\r\n\r\n","returncode":0,"stderr":"","license":"mit","lang":"BlitzMax"} {"commit":"63cef2e050e9c5301eca77c435dff4680bef4786","subject":"Added example2","message":"Added example2\n","repos":"Htbaa\/xmlrpc.mod,Htbaa\/xmlrpc.mod,Htbaa\/xmlrpc.mod,Htbaa\/xmlrpc.mod,Htbaa\/xmlrpc.mod","old_file":"examples\/example2.bmx","new_file":"examples\/example2.bmx","new_contents":"SuperStrict\nImport htbaapub.xmlrpc\n\nLocal client:TXMLRPC_Client = New TXMLRPC_Client.Create()\nclient.SetTransport(New TXMLRPC_Transport_Http.Create(\"www.upcdatabase.com\", \"\/rpc\"))\n\nLocal parameters:TXMLRPC_Call_Parameters = TXMLRPC_Call_Parameters.Create(xmlrpc_vector_array)\nparameters.AppendString(Null, \"0045496718749\")\n\nLocal response:TXMLRPC_Response_Data = client.Call(\"lookupEAN\", parameters)\n\nLocal description:TXMLRPC_Value_String = TXMLRPC_Value_String(response.data.ValueForKey(\"description\"))\nLocal issuerCountry:TXMLRPC_Value_String = TXMLRPC_Value_String(response.data.ValueForKey(\"issuerCountry\"))\nLocal ean:TXMLRPC_Value_String = TXMLRPC_Value_String(response.data.ValueForKey(\"ean\"))\n\nPrint description.name + \": \" + description.ToString()\nPrint description.name + \": \" + issuerCountry.ToString()\nPrint description.name + \": \" + ean.ToString()","old_contents":"","returncode":1,"stderr":"error: pathspec 'examples\/example2.bmx' did not match any file(s) known to git\n","license":"mit","lang":"BlitzMax"} {"commit":"53cc35292a806ede25804b5a78b1f9adae138de4","subject":"Create mandelbrot.bmx","message":"Create mandelbrot.bmx","repos":"Jaulers\/fractals","old_file":"MandelbrotShader2\/mandelbrot.bmx","new_file":"MandelbrotShader2\/mandelbrot.bmx","new_contents":"SuperStrict\nFramework brl.GLGraphics\nImport brl.TIMER\nImport brl.TextStream\nImport pub.OpenGL\nImport pub.Glew\nImport brl.Retro\nImport brl.PNGLoader\n\nConst GW:Int = 1120, GH:Int = 630\nConst aspectratio:Float = 16.0 \/ 9.0\n\nIf AppArgs.Length > 1\n\tTAnimFrame.LoadFromFile(AppArgs[1])\nEnd If\n\nGlobal TIMER:TTimer = CreateTimer(30)\nGlobal VERTEX_SHADER_CODE:String = LoadText(\"vs.glsl\")\nGlobal FRAGMENT_SHADER_CODE:String = LoadText(\"fs.glsl\")\n\nInitGL\nGlobal ProgramObj:Int\nInitShaders\nglUseProgram(ProgramObj)\n\nGlobal camS:Float = 0.02\nGlobal camX:Float = 0.0, camY:Float = 0.0\nGlobal camZoom:Float = 4.0\n\nGlobal itr:Int = 50\nGlobal uk:Int = 0\nGlobal threshold:Float = 4.0\n\nGlobal v1x:Float = 1.0, v1y:Float = 0.0\nGlobal v2x:Float = 1.0, v2y:Float = 0.0\nGlobal v3x:Float = 1.0, v3y:Float = 0.0\n\nGlobal p1x:Float = -1.0, p1y:Float = 0.0\nGlobal p2x:Float = 1.0, p2y:Float = 0.0\n\nGlobal p3x:Float = 0.0, p3y:Float = -1.0\nGlobal p4x:Float = 0.0, p4y:Float = 1.0\n\nGlobal orbittrapradius1:Float = 0.25\nGlobal orbittrapradius2:Float = 0.25\nGlobal aa:Int = 0\n\nGlobal disphelp:Int = 0\n\nGlobal cf:TAnimFrame, cflink:TLink\n\n'Render()\n'SaveSceenshot()\n'End\n\nGlobal MDown:Int, MX:Int, MY:Int\nGlobal zwsp:Float\nWhile Not KeyHit(KEY_ESCAPE)\n\tMDown = MouseDown(MOUSE_LEFT) Shl 2 + MouseDown(MOUSE_MIDDLE) Shl 1 + MouseDown(MOUSE_RIGHT)\n\tMX = MouseX()\n\tMY = MouseY()\n\t\n\tCheckInput()\n\t\n\tRender()\n\t\n\tIf disphelp\n\t\tglUseProgram(0)\n\t\tDrawHelp\n\t\tglUseProgram(ProgramObj)\n\tEnd If\n\t\n\tFlip 0\n\tglCls\n\tWaitTimer TIMER\nWend\nEnd\n\nFunction CheckInput()\n\tIf KeyDown(KEY_2) camS:*1.05 Else If KeyDown(KEY_1) camS:\/1.05\n\t\n\titr:+KeyDown(KEY_4) - KeyDown(KEY_3)\n\tuk:+KeyHit(KEY_V) - KeyHit(KEY_C)\n\t\n\tIf KeyDown(KEY_Y) camZoom:*(1.01) Else If KeyDown(KEY_X) camZoom:\/(1.01)\n\t\n\tIf KeyDown(KEY_6) threshold:*(1.05) Else If KeyDown(KEY_5) threshold:\/(1.05)\n\t\n\tIf KeyDown(KEY_8) orbittrapradius1:*(1.05) Else If KeyDown(KEY_7) orbittrapradius1:\/(1.05)\n\tIf KeyDown(KEY_0) orbittrapradius2:*(1.05) Else If KeyDown(KEY_9) orbittrapradius2:\/(1.05)\n\t\n\tIf KeyHit(KEY_B) Then aa = 1 - aa\n\t\n\tcamX:+(KeyDown(KEY_D) - KeyDown(KEY_A)) * camS\n\tcamY:+(KeyDown(KEY_W) - KeyDown(KEY_S)) * camS\n\t\n\tv1x:+(KeyDown(KEY_R) - KeyDown(KEY_F)) * camS\n\tv1y:+(KeyDown(KEY_T) - KeyDown(KEY_G)) * camS\n\tv2x:+(KeyDown(KEY_Z) - KeyDown(KEY_H)) * camS\n\tv2y:+(KeyDown(KEY_U) - KeyDown(KEY_J)) * camS\n\tv3x:+(KeyDown(KEY_I) - KeyDown(KEY_K)) * camS\n\tv3y:+(KeyDown(KEY_O) - KeyDown(KEY_L)) * camS\n\t\n\tIf MDown & %100\n\t\tIf KeyDown(KEY_LCONTROL)\n\t\t\tp3x = camX + camZoom * MX \/ Float(GW) - camZoom \/ 2.0\n\t\t\tp3y = camY - camZoom \/ aspectratio * MY \/ Float(GH) + camZoom \/ aspectratio \/ 2.0\n\t\tElse\n\t\t\tp1x = camX + camZoom * MX \/ Float(GW) - camZoom \/ 2.0\n\t\t\tp1y = camY - camZoom \/ aspectratio * MY \/ Float(GH) + camZoom \/ aspectratio \/ 2.0\n\t\tEnd If\n\tEnd If\n\tIf MDown & %001\n\t\tIf KeyDown(KEY_LCONTROL)\n\t\t\tp4x = camX + camZoom * MX \/ Float(GW) - camZoom \/ 2.0\n\t\t\tp4y = camY - camZoom \/ aspectratio * MY \/ Float(GH) + camZoom \/ aspectratio \/ 2.0\n\t\tElse\n\t\t\tp2x = camX + camZoom * MX \/ Float(GW) - camZoom \/ 2.0\n\t\t\tp2y = camY - camZoom \/ aspectratio * MY \/ Float(GH) + camZoom \/ aspectratio \/ 2.0\n\t\tEnd If\n\tEnd If\n\t\n\tIf KeyHit(KEY_ENTER) disphelp = 1 - disphelp\n\t\n\tIf KeyHit(KEY_DOWN)\n\t\tIf KeyDown(KEY_RCONTROL)\n\t\t\tTAnimFrame.AddFrame(cflink, 1)\n\t\t\tPrint \"frame modified\"\n\t\tElse\n\t\t\tcf = TAnimFrame.AddFrame(cflink) Print \"frame added\"\n\t\t\tIf cflink = Null Then cflink = TAnimFrame.list.FindLink(cf) Else cflink = cflink.NextLink()\n\t\tEnd If\n\tEnd If\n\t\n\tIf KeyHit(KEY_RIGHT)\n\t\tIf KeyDown(KEY_RCONTROL)\n\t\t\tcflink = TAnimFrame.list.LastLink()\n\t\t\tcf = TAnimFrame(TAnimFrame.list.Last())\n\t\t\tIf cf Then cf.setGlobalsToFrame()\n\t\tElse If cflink.NextLink()\n\t\t\tcflink = cflink.NextLink()\n\t\t\tcf = TAnimFrame(TAnimFrame(cflink.Value()))\n\t\t\tIf cf Then cf.setGlobalsToFrame()\n\t\tEnd If\n\tEnd If\n\t\n\tIf KeyHit(KEY_LEFT)\n\t\tIf KeyDown(KEY_RCONTROL)\n\t\t\tcflink = TAnimFrame.list.FirstLink()\n\t\t\tcf = TAnimFrame(TAnimFrame.list.First())\n\t\t\tIf cf Then cf.setGlobalsToFrame()\n\t\tElse If cflink.PrevLink()\n\t\t\tcflink = cflink.PrevLink()\n\t\t\tcf = TAnimFrame(TAnimFrame(cflink.Value()))\n\t\t\tIf cf Then cf.setGlobalsToFrame()\n\t\tEnd If\n\tEnd If\n\t\n\tIf KeyHit(KEY_BACKSPACE) And cf\n\t\tcflink = cflink.PrevLink()\n\t\tcf.list.Remove(cf)\n\t\tIf cf Then cf = TAnimFrame(cflink.Value())\n\t\tPrint \"frame deleted\"\n\tEnd If\n\t\n\tIf cf\n\t\tLocal timevar:TFloat = TFloat(cf.getVar(\"time\"))\n\t\tIf KeyDown(KEY_PAGEUP) Then timevar.v:*1.1 Print timevar.v Else ..\n\t\tIf KeyDown(KEY_PAGEDOWN) Then timevar.v:\/1.1 Print timevar.v\n\tEnd If\n\t\n\tIf KeyHit(KEY_RSHIFT) And cf Then cf.setGlobalsToFrame()\n\t\n\tIf KeyHit(KEY_UP) Then TAnimFrame.PlayAnim(0.04)\n\t\n\tIf KeyHit(KEY_F10) Then TAnimFrame.SaveToFile(\"anim\" + MilliSecs() + \".txt\")\n\t\n\tIf KeyHit(KEY_F11)\n\t\tIf KeyDown(KEY_RCONTROL)\n\t\t\tTAnimFrame.SaveAnim(0.02, \"anim\" + MilliSecs(), Input(\"Skip Nr Frames:\").ToInt())\n\t\tElse\n\t\t\tTAnimFrame.SaveAnim(0.02, \"anim\" + MilliSecs())\n\t\tEnd If\n\tEnd If\n\t\n\tIf KeyHit(KEY_F12)\n\t\tIf KeyDown(KEY_RCONTROL)\n\t\t\tSaveSceenshot(Input(\"resolution multiplier:\").ToInt())\n\t\tElse\n\t\t\tSaveSceenshot(4)\n\t\tEnd If\n\tEnd If\nEnd Function\n\nFunction Render(x:Int = 0, y:Int = 0, s:Int = 1)\n\tglUniform1f(glGetUniformLocation(ProgramObj, \"pixelsize\"), (camZoom \/ Float(s)) \/ Float(GW))\n\tglUniform1i(glGetUniformLocation(ProgramObj, \"MaxItr\"), itr)\n\tglUniform1i(glGetUniformLocation(ProgramObj, \"uk\"), uk)\n\tglUniform1f(glGetUniformLocation(ProgramObj, \"threshold\"), threshold * threshold)\n\tglUniform2f(glGetUniformLocation(ProgramObj, \"v1\"), v1x, v1y)\n\tglUniform2f(glGetUniformLocation(ProgramObj, \"v2\"), v2x, v2y)\n\tglUniform2f(glGetUniformLocation(ProgramObj, \"v3\"), v3x, v3y)\n\tglUniform2f(glGetUniformLocation(ProgramObj, \"p1\"), p1x, p1y)\n\tglUniform2f(glGetUniformLocation(ProgramObj, \"p2\"), p2x, p2y)\n\tglUniform2f(glGetUniformLocation(ProgramObj, \"p3\"), p3x, p3y)\n\tglUniform2f(glGetUniformLocation(ProgramObj, \"p4\"), p4x, p4y)\n\tglUniform1f(glGetUniformLocation(ProgramObj, \"orbittrapradius1\"), orbittrapradius1)\n\tglUniform1f(glGetUniformLocation(ProgramObj, \"orbittrapradius2\"), orbittrapradius2)\n\tglUniform1i(glGetUniformLocation(ProgramObj, \"aa\"), aa)\n\t\n\tLocal vx:Float, vy:Float\n\tLocal w:Float, h:Float\n\tvy = camZoom \/ 2.0\n\t\n\tw = camZoom \/ Float(s)\n\th = camZoom \/ Float(s) \/ aspectratio\n\t\n\tvx = camX - vy + w * x\n\tvy = camY + vy \/ aspectratio - h * y\n\t\n\tglBegin(GL_QUADS)\n\t\tglTexCoord2f(vx, vy) ;glVertex2i(0, 0)\n\t\tglTexCoord2f(vx + w, vy) ;glVertex2i(GW, 0)\n\t\tglTexCoord2f(vx + w, vy - h) ;glVertex2i(GW, GH)\n\t\tglTexCoord2f(vx, vy - h) ;glVertex2i(0, GH)\n\tglEnd\nEnd Function\n\nFunction InitGL()\n\tGraphics GW, GH', 32, 60, 0\n\tSetGraphicsDriver(GLGraphicsDriver())\n\tglewInit()\n\t\n\tglMatrixMode(GL_PROJECTION)\n\tglLoadIdentity()\n\t\n\tglOrtho(0, GW, GH, 0, -1, 1)\n\t\n\tglMatrixMode(GL_MODELVIEW)\n\tglLoadIdentity()\nEnd Function\n\nFunction glCls()\n\tglClear GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT\nEnd Function\n\nFunction InitShaders()\n\tProgramObj = glCreateProgram()\n\tLocal VertexShdr:Int = glCreateShader(GL_VERTEX_SHADER_ARB)\n\tLocal FragmentShdr:Int = glCreateShader(GL_FRAGMENT_SHADER_ARB)\n\t\n\tLocal vsc:Byte Ptr = VERTEX_SHADER_CODE.ToCString()\n\tLocal vsl:Int = VERTEX_SHADER_CODE.Length\n\tLocal fsc:Byte Ptr = FRAGMENT_SHADER_CODE.ToCString()\n\tLocal fsl:Int = FRAGMENT_SHADER_CODE.Length\n\t\n\tglShaderSource(VertexShdr, 1, Varptr vsc, Varptr vsl)\n\t\tglShaderSource(FragmentShdr, 1, Varptr fsc, Varptr fsl)\n\t\n\t\tMemFree(vsc)\n\tMemFree(fsc)\n\t\n\tglCompileShader(VertexShdr) ;CheckForErrors(VertexShdr)\n\tglCompileShader(FragmentShdr) ;CheckForErrors(FragmentShdr)\n\t\n\tglAttachShader(ProgramObj, VertexShdr)\n\tglAttachShader(ProgramObj, FragmentShdr)\n\t\n\tglDeleteShader(VertexShdr)\n\tglDeleteShader(FragmentShdr)\n\t\n\tglLinkProgram(ProgramObj) ;CheckForErrors(ProgramObj)\nEnd Function\n\nFunction CheckForErrors(ShaderObject:Int)\n\tLocal ErrorLength:Int\n\t\n\tglGetShaderiv(ShaderObject, GL_OBJECT_INFO_LOG_LENGTH_ARB, Varptr ErrorLength)\n\t\n\t\tIf ErrorLength\n\t\tLocal Message:Byte[ErrorLength], Dummy:Int\n\t\t\n\t\tglGetShaderInfoLog(ShaderObject, ErrorLength, Varptr Dummy, Varptr Message[0])\n\t\t'\t\tSaveText(\"Shader object '\" + ShaderObject + \"':~n\" + StringFromCharArray(Message), \"error.txt\")\n\t\tWriteStdout \"Shader object '\" + ShaderObject + \"':~n\" + StringFromCharArray(Message)\n\t\tWriteStdout \"~n\"\n\tEndIf\nEnd Function\n\nFunction StringFromCharArray:String(Array:Byte[])\n\tLocal Output:String\n\tFor Local I:Int = 0 To Array.Length - 1\n\t\tOutput:+Chr(Array[I])\n\tNext\n\t\n\tReturn Output\nEnd Function\n\n\nFunction SaveSceenshot(s:Int = 3, fn:String = \"\", compression:Int = 5, infosdtout:Int = 1)\n\tLocal cnt:Int\n\tLocal pm:TPixmap = CreatePixmap(GW * s, GH * s, PF_BGRA8888)\n\tLocal c:Byte Ptr = MemAlloc(3 * (GW + GW Mod 4) * (GH + GH Mod 4))\n\t\n\tFor Local x1:Int = 0 Until s\n\t\tIf infosdtout WriteStdout (x1 + 1) + \" of \" + s + \"~n\"\n\t\tFor Local y1:Int = 0 Until s\n\t\t\tRender(x1, y1, s)\n\t\t\tglReadPixels(0, 0, (GW + GW Mod 4), (GH + GH Mod 4), GL_RGB, GL_UNSIGNED_BYTE, c)\n\t\t\tcnt = 0\n\t\t\tFor Local y:Int = GH - 1 To 0 Step - 1\n\t\t\t\tFor Local x:Int = 0 Until GW\n\t\t\t\t\tWritePixel(pm, x1 * GW + x, y1 * GH + y, $ff000000 + $10000 * c[cnt] + $100 * c[cnt + 1] + c[cnt + 2])\n\t\t\t\t\tcnt:+3\n\t\t\t\tNext\n\t\t\t\tcnt:+3 * (GW Mod 4)\n\t\t\tNext\n\t\tNext\n\tNext\n\t\n\tIf infosdtout WriteStdout \"Saving...\"\n\tIf fn = \"\" Then fn = (MilliSecs()) + \".png\"\n\tSavePixmapPNG(pm, fn, compression)\n\tIf infosdtout WriteStdout \"Done.~n~n\"\nEnd Function\n\nFunction DrawHelp()\n\tGLDrawText \"cam =\" + camX + \", \" + camY, 0, 0\n\tGLDrawText \"v1 =\" + v1x + \", \" + v1y, 0, 16\n\tGLDrawText \"v2 =\" + v2x + \", \" + v2y, 0, 32\n\tGLDrawText \"v3 =\" + v3x + \", \" + v3y, 0, 48\n\tGLDrawText \"p1 =\" + p1x + \", \" + p1y, 0, 64\n\tGLDrawText \"p2 =\" + p2x + \", \" + p2y, 0, 80\n\tGLDrawText \"p3 =\" + p3x + \", \" + p3y, 0, 96\n\tGLDrawText \"p4 =\" + p4x + \", \" + p4y, 0, 112\n\tGLDrawText \"thd =\" + threshold, 0, 128\n\tGLDrawText \"otr1=\" + orbittrapradius1, 0, 144\n\tGLDrawText \"otr2=\" + orbittrapradius2, 0, 160\n\tGLDrawText \"itr =\" + itr, 0, 176\n\tGLDrawText \"k =\" + uk, 0, 192\nEnd Function\n\nFunction Catmul:Float(v0:Float, v1:Float, v2:Float, v3:Float, x:Float)\n\tLocal a0:Float, a1:Float, a2:Float, a3:Float, x2:Float\n\t\n\tx2 = x * x\n\ta0 = -0.5 * v0 + 1.5 * v1 - 1.5 * v2 + 0.5 * v3\n\ta1 = v0 - 2.5 * v1 + 2 * v2 - 0.5 * v3\n\ta2 = -0.5 * v0 + 0.5 * v2\n\ta3 = v1\n'\ta0 = v3 - v2 - v0 + v1\n'\ta1 = v0 - v1 - a0\n'\ta2 = v2 - v0\n'\ta3 = v1\n\t\n\tReturn a0 * x * x2 + a1 * x2 + a2 * x + a3\nEnd Function\n\nFunction Clip:Float(v1:Float, v2:Float, x:Float)\n\tReturn x * v2 + v1 * (1.0 - x)\nEnd Function\n\nType TAnimFrame\n\tGlobal list:TList = CreateList()\n\t\n\tField varlist:TList\n\t\n\tMethod New()\n\t\tvarlist = CreateList()\n\tEnd Method\n\t\n\tMethod Del()\n\t\tlist.Remove(Self)\n\tEnd Method\n\t\n\tFunction AddFrame:TAnimFrame(link:TLink = Null, modify:Int = 0)\n\t\tLocal t:TAnimFrame\n\t\tIf modify\n\t\t\tIf link = Null\n\t\t\t\tt = New TAnimFrame\n\t\t\t\tt.list.AddLast(t)\n\t\t\tElse\n\t\t\t\tt = TAnimFrame(link.Value())\n\t\t\tEnd If\n\t\tElse\n\t\t\tt = New TAnimFrame\n\t\t\tIf link = Null\n\t\t\t\tt.list.AddLast(t)\n\t\t\tElse\n\t\t\t\tt.list.InsertAfterLink(t, link)\n\t\t\tEnd If\n\t\tEnd If\n\t\t\n\t\tLocal timevar:Object = t.getVar(\"time\")\n\t\tIf timevar = Null\n\t\t\tt.setVar(\"time\", TFloat.N(1.0))\n\t\tElse\n\t\t\tt.setVar(\"time\", TFloat(timevar))\n\t\tEnd If\n\t\t\n\t\tt.setVar(\"camX\", TFloat.N(camX))\n\t\tt.setVar(\"camY\", TFloat.N(camY))\n\t\t\n\t\tt.setVar(\"camZoom\", TFloat.N(camZoom))\n\t\t\n\t\tt.setVar(\"itr\", TInt.N(itr))\n\t\t\n\t\tt.setVar(\"v1x\", TFloat.N(v1x))\n\t\tt.setVar(\"v1y\", TFloat.N(v1y))\n\t\tt.setVar(\"v2x\", TFloat.N(v2x))\n\t\tt.setVar(\"v2y\", TFloat.N(v2y))\n\t\tt.setVar(\"v3x\", TFloat.N(v3x))\n\t\tt.setVar(\"v3y\", TFloat.N(v3y))\n\t\t\n\t\tt.setVar(\"p1x\", TFloat.N(p1x))\n\t\tt.setVar(\"p1y\", TFloat.N(p1y))\n\t\tt.setVar(\"p2x\", TFloat.N(p2x))\n\t\tt.setVar(\"p2y\", TFloat.N(p2y))\n\t\tt.setVar(\"p3x\", TFloat.N(p3x))\n\t\tt.setVar(\"p3y\", TFloat.N(p3y))\n\t\tt.setVar(\"p4x\", TFloat.N(p4x))\n\t\tt.setVar(\"p4y\", TFloat.N(p4y))\n\t\t\n\t\tt.setVar(\"uk\", TInt.N(uk))\n\t\t\n\t\tt.setVar(\"threshold\", TFloat.N(threshold))\n\t\t\n\t\tt.setVar(\"orbittrapradius1\", TFloat.N(orbittrapradius1))\n\t\tt.setVar(\"orbittrapradius2\", TFloat.N(orbittrapradius2))\n\t\tReturn t\n\tEnd Function\n\t\n\tMethod getVar:Object(name:String)\n\t\tFor Local t:TAnimFrameVar = EachIn varlist\n\t\t\tIf t.name = name\n\t\t\t\tReturn t.v\n\t\t\tEnd If\n\t\tNext\n\t\tReturn Null\n\tEnd Method\n\t\n\tMethod setVar(name:String, v:Object)\n\t\tFor Local t:TAnimFrameVar = EachIn varlist\n\t\t\tIf t.name = name\n\t\t\t\tt.v = v\n\t\t\t\tReturn\n\t\t\tEnd If\n\t\tNext\n\t\tLocal t:TAnimFrameVar = New TAnimFrameVar\n\t\tt.name = name\n\t\tt.v = v\n\t\tvarlist.AddLast(t)\n\t\tReturn\n\tEnd Method\n\t\n\tFunction PlayAnim(speed:Float)\n\t\tLocal f1:TAnimFrame, f1link:TLink\n\t\tLocal f2:TAnimFrame, f2link:TLink\n\t\tLocal time:Float\n\t\tLocal x:Float = 0\n\t\t\n\t\tf1 = TAnimFrame(f1.list.First())\n\t\tf1link = f1.list.FirstLink()\n\t\tIf f1link = Null Then Return\n\t\tf2link = f1link.NextLink()\n\t\tIf f2link = Null Then Return\n\t\tf2 = TAnimFrame(f2link.Value())\n\t\t\n\t\tWhile Not KeyHit(KEY_ESCAPE)\n\t\t\t\n\t\t\tsetGlobals(f1, f1link, f2, f2link, x)\n\t\t\t\n\t\t\tRender()\n\t\t\t\n\t\t\tIf disphelp DrawHelp()\n\t\t\t\n\t\t\ttime = Clip(TFloat(f1.getVar(\"time\")).v, ..\n\t\t\tTFloat(f2.getVar(\"time\")).v, x)\n\t\t\t\n\t\t\tx:+speed \/ time\n\t\t\tIf x >= 1\n\t\t\t\tf1link = f2link\n\t\t\t\tf1 = f2\n\t\t\t\tf2link = f1link.NextLink()\n\t\t\t\tIf f2link = Null Return\n\t\t\t\tf2 = TAnimFrame(f2link.Value())\n\t\t\t\tx = x - 1.0\n\t\t\tEnd If\n\t\t\t\n\t\t\tFlip 0\n\t\t\tglCls\n\t\t\tWaitTimer TIMER\n\t\tWend\n\tEnd Function\n\t\n\tFunction SaveAnim(speed:Float, folder:String, skip:Int = 0)\n\t\tLocal framenr:Int = 0\n\t\t\n\t\tCreateDir(folder)\n\t\t\n\t\tLocal f1:TAnimFrame, f1link:TLink\n\t\tLocal f2:TAnimFrame, f2link:TLink\n\t\tLocal time:Float\n\t\tLocal x:Float = 0\n\t\t\n\t\tf1 = TAnimFrame(f1.list.First())\n\t\tf1link = f1.list.FirstLink()\n\t\tIf f1link = Null Then Return\n\t\tf2link = f1link.NextLink()\n\t\tIf f2link = Null Then Return\n\t\tf2 = TAnimFrame(f2link.Value())\n\t\t\n\t\tWhile Not KeyHit(KEY_ESCAPE)\n\t\t\tsetGlobals(f1, f1link, f2, f2link, x)\n\t\t\t\n\t\t\tIf framenr >= skip\n\t\t\t\tSaveSceenshot(2, folder + \"\/\" + framenr + \".png\", 1, 0)\n\t\t\t\tPrint \"Frame Nr. \" + framenr\n\t\t\tEnd If\n\t\t\t\n\t\t\ttime = Clip(TFloat(f1.getVar(\"time\")).v, ..\n\t\t\tTFloat(f2.getVar(\"time\")).v, x)\n\t\t\t\n\t\t\tx:+speed \/ time\n\t\t\tIf x >= 1\n\t\t\t\tf1link = f2link\n\t\t\t\tf1 = f2\n\t\t\t\tf2link = f1link.NextLink()\n\t\t\t\tIf f2link = Null Then End\n\t\t\t\tf2 = TAnimFrame(f2link.Value())\n\t\t\t\tx = x - 1.0\n\t\t\tEnd If\n\t\t\t\n\t\t\t\n\t\t\tframenr:+1\n\t\t\t'Flip 0\n\t\t\t'glCls\n\t\t\t'WaitTimer TIMER\n\t\tWend\n\tEnd Function\n\t\n\tFunction setGlobals(f1:TAnimFrame, f1link:TLink, f2:TAnimFrame, f2link:TLink, x:Float)\n\t\tLocal f0:TAnimFrame, f3:TAnimFrame\n\t\tLocal f0link:TLink, f3link:TLink\n\t\t\n\t\tf0link = f1link.PrevLink()\n\t\tf3link = f2link.NextLink()\n\t\t\n\t\tIf f0link = Null Then f0link = f1link\n\t\tIf f3link = Null Then f3link = f2link\n\t\t\n\t\tf0 = TAnimFrame(f0link.Value())\n\t\tf3 = TAnimFrame(f3link.Value())\n\t\t\n\t\t\n\t\tcamX = Catmul(TFloat(f0.getVar(\"camX\")).v, ..\n\t\tTFloat(f1.getVar(\"camX\")).v, ..\n\t\tTFloat(f2.getVar(\"camX\")).v, ..\n\t\tTFloat(f3.getVar(\"camX\")).v, x)\n\t\t \n\t\tcamY = Catmul(TFloat(f0.getVar(\"camY\")).v, ..\n\t\tTFloat(f1.getVar(\"camY\")).v, ..\n\t\tTFloat(f2.getVar(\"camY\")).v, ..\n\t\tTFloat(f3.getVar(\"camY\")).v, x)\n\t\t\n\t\tcamZoom = Catmul(TFloat(f0.getVar(\"camZoom\")).v, ..\n\t\tTFloat(f1.getVar(\"camZoom\")).v, ..\n\t\tTFloat(f2.getVar(\"camZoom\")).v, ..\n\t\tTFloat(f3.getVar(\"camZoom\")).v, x)\n'\t\tcamZoom = Clip(TFloat(f1.getVar(\"camZoom\")).v, ..\n'\t\tTFloat(f2.getVar(\"camZoom\")).v, x)\n\t\t\n\t\titr = Clip(TInt(f1.getVar(\"itr\")).v, ..\n\t\tTInt(f2.getVar(\"itr\")).v, x)\n\t\t\n\t\t\n\t\tv1x = Catmul(TFloat(f0.getVar(\"v1x\")).v, ..\n\t\tTFloat(f1.getVar(\"v1x\")).v, ..\n\t\tTFloat(f2.getVar(\"v1x\")).v, ..\n\t\tTFloat(f3.getVar(\"v1x\")).v, x)\n\t\t \n\t\tv1y = Catmul(TFloat(f0.getVar(\"v1y\")).v, ..\n\t\tTFloat(f1.getVar(\"v1y\")).v, ..\n\t\tTFloat(f2.getVar(\"v1y\")).v, ..\n\t\tTFloat(f3.getVar(\"v1y\")).v, x)\n\t\t\n\t\tv2x = Catmul(TFloat(f0.getVar(\"v2x\")).v, ..\n\t\tTFloat(f1.getVar(\"v2x\")).v, ..\n\t\tTFloat(f2.getVar(\"v2x\")).v, ..\n\t\tTFloat(f3.getVar(\"v2x\")).v, x)\n\t\t \n\t\tv2y = Catmul(TFloat(f0.getVar(\"v2y\")).v, ..\n\t\tTFloat(f1.getVar(\"v2y\")).v, ..\n\t\tTFloat(f2.getVar(\"v2y\")).v, ..\n\t\tTFloat(f3.getVar(\"v2y\")).v, x)\n\t\t\n\t\tv3x = Catmul(TFloat(f0.getVar(\"v3x\")).v, ..\n\t\tTFloat(f1.getVar(\"v3x\")).v, ..\n\t\tTFloat(f2.getVar(\"v3x\")).v, ..\n\t\tTFloat(f3.getVar(\"v3x\")).v, x)\n\t\t \n\t\tv3y = Catmul(TFloat(f0.getVar(\"v3y\")).v, ..\n\t\tTFloat(f1.getVar(\"v3y\")).v, ..\n\t\tTFloat(f2.getVar(\"v3y\")).v, ..\n\t\tTFloat(f3.getVar(\"v3y\")).v, x)\n\t\t\n\t\t\n\t\tp1x = Catmul(TFloat(f0.getVar(\"p1x\")).v, ..\n\t\tTFloat(f1.getVar(\"p1x\")).v, ..\n\t\tTFloat(f2.getVar(\"p1x\")).v, ..\n\t\tTFloat(f3.getVar(\"p1x\")).v, x)\n\t\t \n\t\tp1y = Catmul(TFloat(f0.getVar(\"p1y\")).v, ..\n\t\tTFloat(f1.getVar(\"p1y\")).v, ..\n\t\tTFloat(f2.getVar(\"p1y\")).v, ..\n\t\tTFloat(f3.getVar(\"p1y\")).v, x)\n\t\t\n\t\tp2x = Catmul(TFloat(f0.getVar(\"p2x\")).v, ..\n\t\tTFloat(f1.getVar(\"p2x\")).v, ..\n\t\tTFloat(f2.getVar(\"p2x\")).v, ..\n\t\tTFloat(f3.getVar(\"p2x\")).v, x)\n\t\t \n\t\tp2y = Catmul(TFloat(f0.getVar(\"p2y\")).v, ..\n\t\tTFloat(f1.getVar(\"p2y\")).v, ..\n\t\tTFloat(f2.getVar(\"p2y\")).v, ..\n\t\tTFloat(f3.getVar(\"p2y\")).v, x)\n\t\t\n\t\tp3x = Catmul(TFloat(f0.getVar(\"p3x\")).v, ..\n\t\tTFloat(f1.getVar(\"p3x\")).v, ..\n\t\tTFloat(f2.getVar(\"p3x\")).v, ..\n\t\tTFloat(f3.getVar(\"p3x\")).v, x)\n\t\t \n\t\tp3y = Catmul(TFloat(f0.getVar(\"p3y\")).v, ..\n\t\tTFloat(f1.getVar(\"p3y\")).v, ..\n\t\tTFloat(f2.getVar(\"p3y\")).v, ..\n\t\tTFloat(f3.getVar(\"p3y\")).v, x)\n\t\t\n\t\tp4x = Catmul(TFloat(f0.getVar(\"p4x\")).v, ..\n\t\tTFloat(f1.getVar(\"p4x\")).v, ..\n\t\tTFloat(f2.getVar(\"p4x\")).v, ..\n\t\tTFloat(f3.getVar(\"p4x\")).v, x)\n\t\t \n\t\tp4y = Catmul(TFloat(f0.getVar(\"p4y\")).v, ..\n\t\tTFloat(f1.getVar(\"p4y\")).v, ..\n\t\tTFloat(f2.getVar(\"p4y\")).v, ..\n\t\tTFloat(f3.getVar(\"p4y\")).v, x)\n\t\t\n\t\t\n\t\tuk = Clip(TInt(f1.getVar(\"uk\")).v, ..\n\t\tTInt(f2.getVar(\"uk\")).v, x)\n\t\t\n\t\tthreshold = Clip(TFloat(f1.getVar(\"threshold\")).v, ..\n\t\tTFloat(f2.getVar(\"threshold\")).v, x)\n\t\t\n\t\torbittrapradius1 = Clip(TFloat(f1.getVar(\"orbittrapradius1\")).v, ..\n\t\tTFloat(f2.getVar(\"orbittrapradius1\")).v, x)\n\t\t\n\t\torbittrapradius2 = Clip(TFloat(f1.getVar(\"orbittrapradius2\")).v, ..\n\t\tTFloat(f2.getVar(\"orbittrapradius2\")).v, x)\n\t\t\n\tEnd Function\n\t\n\tMethod setGlobalsToFrame()\n\t\tcamX = TFloat(getVar(\"camX\")).v\n\t\t \n\t\tcamY = TFloat(getVar(\"camY\")).v\n\t\tcamZoom = TFloat(getVar(\"camZoom\")).v\n\t\t\n\t\titr = TInt(getVar(\"itr\")).v\n\t\t\n\t\tv1x = TFloat(getVar(\"v1x\")).v\n\t\tv1y = TFloat(getVar(\"v1y\")).v\n\t\tv2x = TFloat(getVar(\"v2x\")).v\n\t\tv2y = TFloat(getVar(\"v2y\")).v\n\t\tv3x = TFloat(getVar(\"v3x\")).v\n\t\tv3y = TFloat(getVar(\"v3y\")).v\n\t\t\n\t\tp1x = TFloat(getVar(\"p1x\")).v\n\t\tp1y = TFloat(getVar(\"p1y\")).v\n\t\tp2x = TFloat(getVar(\"p2x\")).v\n\t\tp2y = TFloat(getVar(\"p2y\")).v\n\t\tp3x = TFloat(getVar(\"p3x\")).v\n\t\tp3y = TFloat(getVar(\"p3y\")).v\n\t\tp4x = TFloat(getVar(\"p4x\")).v\n\t\tp4y = TFloat(getVar(\"p4y\")).v\n\t\t\n\t\tuk = TInt(getVar(\"uk\")).v\n\t\tthreshold = TFloat(getVar(\"threshold\")).v\n\t\torbittrapradius1 = TFloat(getVar(\"orbittrapradius1\")).v\n\t\torbittrapradius2 = TFloat(getVar(\"orbittrapradius2\")).v\n\tEnd Method\n\t\n\tFunction SaveToFile(filename:String)\n\t\tLocal f:TStream = WriteFile(filename)\n\t\tFor Local t:TAnimFrame = EachIn TAnimFrame.list\n\t\t\tf.WriteLine \"{\"\n\t\t\tFor Local v:TAnimFrameVar = EachIn t.varlist\n\t\t\t\tIf TFloat(v.v) <> Null\n\t\t\t\t\tf.WriteLine \"~t\" + v.name + \" = \" + TFloat(v.v).v + \"f;\"\n\t\t\t\tElse If TInt(v.v) <> Null\n\t\t\t\t\tf.WriteLine \"~t\" + v.name + \" = \" + TInt(v.v).v + \"i;\"\n\t\t\t\tElse If TDouble(v.v) <> Null\n\t\t\t\t\tf.WriteLine \"~t\" + v.name + \" = \" + TDouble(v.v).v + \"d;\"\n\t\t\t\tEnd If\n\t\t\tNext\n\t\t\tf.WriteLine \"}\"\n\t\tNext\n\t\tf.Close\n\tEnd Function\n\t\n\tFunction LoadFromFile(file:String)\n\t\tIf FileType(file) = 1\n\t\t\tfile = LoadText(file)\n\t\t\tfile = Replace(file, \" \", \"\")\n\t\t\tfile = Replace(file, Chr(9), \"\")\n\t\t\tfile = Replace(file, Chr(10), \"\")\n\t\t\tfile = Replace(file, Chr(13), \"\")\n\t\t\t\n\t\t\tLocal gs:Int = 1, ge:Int = 0, content:String\n\t\t\t\n\t\t\tWhile ge < Len(file)\n\t\t\t\tgs = Instr(file, \"{\", ge)\n\t\t\t\tge = Instr(file, \"}\", gs + 1)\n\t\t\t\tcontent = Mid(file, gs + 1, ge - gs - 1)\n\t\t\t\t\n\t\t\t\tLocal cs:Int = 1, ce:Int = 0, eq:Int\n\t\t\t\tLocal name:String, value:String, dt:String\n\t\t\t\t\n\t\t\t\tLocal t:TAnimFrame = New TAnimFrame\n\t\t\t\tt.list.AddLast(t)\n\t\t\t\t\n\t\t\t\tWhile ce < Len(content)\n\t\t\t\t\tce = Instr(content, \";\", cs)\n\t\t\t\t\tvalue = Mid(content, cs, ce - cs)\n\t\t\t\t\teq = Instr(value, \"=\")\n\t\t\t\t\t\n\t\t\t\t\tname = Left(value, eq - 1)\n\t\t\t\t\tdt = Right(value, 1)\n\t\t\t\t\tvalue = Mid(Left(value, value.Length - 1), eq + 1)\n\t\t\t\t\t\n\t\t\t\t\tSelect dt\n\t\t\t\t\t\tCase \"f\"\n\t\t\t\t\t\t\tt.setVar(name, TFloat.N(value.ToFloat()))\n\t\t\t\t\t\tCase \"i\"\n\t\t\t\t\t\t\tt.setVar(name, TInt.N(value.ToInt()))\n\t\t\t\t\t\tCase \"d\"\n\t\t\t\t\t\t\tt.setVar(name, TDouble.N(value.ToDouble()))\n\t\t\t\t\tEnd Select\n\t\t\t\t\t\n\t\t\t\t\tcs = ce + 1\n\t\t\t\tWend\n\t\t\t\t\n\t\t\tWend\n\t\tElse\n\t\t\tRuntimeError(\"File does not exist!\")\n\t\tEnd If\n\tEnd Function\n\t\nEnd Type\n\nType TAnimFrameVar\n\tField name:String\n\tField v:Object\nEnd Type\n\nType TInt\n\tField v:Int\n\tFunction N:TInt(v:Int)\n\t\tLocal t:TInt = New TInt\n\t\tt.v = v\n\t\tReturn t\n\tEnd Function\nEnd Type\n\nType TFloat\n\tField v:Float\n\tFunction N:TFloat(v:Float)\n\t\tLocal t:TFloat = New TFloat\n\t\tt.v = v\n\t\tReturn t\n\tEnd Function\nEnd Type\n\nType TDouble\n\tField v:Double\n\tFunction N:TDouble(v:Double)\n\t\tLocal t:TDouble = New TDouble\n\t\tt.v = v\n\t\tReturn t\n\tEnd Function\nEnd Type\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'MandelbrotShader2\/mandelbrot.bmx' did not match any file(s) known to git\n","license":"mit","lang":"BlitzMax"} {"commit":"a05a8c5361142be8dcc358229bd6077b4bd8b986","subject":"Create fractal_music.bmx","message":"Create fractal_music.bmx","repos":"Jaulers\/fractals","old_file":"lindenmayr_notevalues\/fractal_music.bmx","new_file":"lindenmayr_notevalues\/fractal_music.bmx","new_contents":"SuperStrict\nFramework brl.Retro\nImport BRL.Timer\nImport bah.rtmidi\n\nLocal filename:String\nIf AppArgs.Length > 1\n\tfilename = AppArgs[1]\nElse\n\tfilename = Input(\"Datei angeben: \")\nEnd If\n\n\nGlobal score:TmidiScore = New TmidiScore\nscore.midiOut = New TRtMidiOut.Create()\nscore.midiOut.openPort(0)\nOnEnd(CleanUp)\n\nscore.loadMusic(filename)\n\nscore.saveAsMidi(StripExt(filename) + \".mid\")\n\n'score.play\n\nEnd\n\nFunction CleanUp()\n\tscore.midiOut.closePort()\n\tscore.midiOut.Free()\n\tDelay(300)\nEnd Function\n\nFunction NoteFromString:Byte(n:String)\n\tIf n = \"p\" Then Return $ff\n\tLocal os:Int = 0\n\tLocal t:String = Mid(n, 2, 1)\n\tIf t = \"#\" Or t = \"b\"\n\t\tt = Left(n, 2)\n\t\tos = Mid(n, 3).ToInt() + 2\n\tElse\n\t\tt = Left(n, 1)\n\t\tos = Mid(n, 2).ToInt() + 2\n\tEnd If\n\tSelect t\n\t\tCase \"C\"\n\t\t\tReturn 0 + $0C * os\n\t\tCase \"C#\"\n\t\t\tReturn 1 + $0C * os\n\t\tCase \"D\"\n\t\t\tReturn 2 + $0C * os\n\t\tCase \"D#\"\n\t\t\tReturn 3 + $0C * os\n\t\tCase \"E\"\n\t\t\tReturn 4 + $0C * os\n\t\tCase \"F\"\n\t\t\tReturn 5 + $0C * os\n\t\tCase \"F#\"\n\t\t\tReturn 6 + $0C * os\n\t\tCase \"G\"\n\t\t\tReturn 7 + $0C * os\n\t\tCase \"G#\"\n\t\t\tReturn 8 + $0C * os\n\t\tCase \"A\"\n\t\t\tReturn 9 + $0C * os\n\t\tCase \"A#\"\n\t\t\tReturn 10 + $0C * os\n\t\tCase \"B\"\n\t\t\tReturn 11 + $0C * os\n\tEnd Select\nEnd Function\n\nFunction L_System:String(itr:Int, a:String, rules:String[])\n\tFor Local n:Int = 0 Until itr\n\t\tLocal a1:String\n\t\tFor Local i:Int = 0 Until Len(a)\n\t\t\tFor Local s:String = EachIn rules\n\t\t\t\tIf Chr(s[0]) = Chr(a[i])\n\t\t\t\t\ta1 = a1 + Mid(s, 3)\n\t\t\t\t\tExit\n\t\t\t\tEnd If\n\t\t\tNext\n\t\tNext\n\t\ta = a1\n\tNext\n\tReturn a\nEnd Function\n\n\nType TmidiNote\n\tField note:Byte\n\tField length:Int\nEnd Type\n\nType TmidiChannel\n\tField id:Int\n\t\n\tField notes:TmidiNote[]\n\tField instrument:Byte\n\tField volume:Byte\n\t\n\tField currentNote:Int\n\tField arrlength:Int\n\tField currentNoteTimer:Int\n\t\n\tMethod fromStrings(pstr:String, pindex:String[], vstr:String, vindex:String[])\n\t\tpstr = Left(pstr, Len(vstr))\n\t\tvstr = Left(vstr, Len(pstr))\n\t\t\n\t\tLocal l:Int = Len(pstr)\n\t\t\n\t\tnotes = New TmidiNote[l]\n\t\tarrlength = l\n\t\t\n\t\tFor Local i:Int = 0 Until l\n\t\t\tLocal p:Int, t:TmidiNote = New TmidiNote\n\t\t\tp = 0\n\t\t\tFor Local s:String = EachIn pindex\n\t\t\t\tIf Chr(s[0]) = Chr(pstr[i])\n\t\t\t\t\tt.note = NoteFromString(Mid(s, 3))\n\t\t\t\t\tp = 1\n\t\t\t\tEnd If\n\t\t\tNext\n\t\t\tIf p = 0 Then t.Note = $ff\n\t\t\tp = 0\n\t\t\tFor Local s:String = EachIn vindex\n\t\t\t\tIf Chr(s[0]) = Chr(vstr[i])\n\t\t\t\t\tt.length = Mid(s, 3).ToInt()\n\t\t\t\t\tp = 1\n\t\t\t\tEnd If\n\t\t\tNext\n\t\t\tIf p = 0 Then t.length = 4\n\t\t\tnotes[i] = t\n\t\tNext\n\tEnd Method\nEnd Type\n\nType TmidiScore\n\tField channels:TList\n\tField speedHz:Float\n\tField midiOut:TRtMidiOut\n\t\n\tMethod New()\n\t\tchannels = CreateList()\n\tEnd Method\n\t\n\tMethod addChannel(channel:TmidiChannel)\n\t\tSelf.channels.AddLast(channel)\n\tEnd Method\n\t\n\tMethod play()\n\t\tLocal timer:TTimer = CreateTimer(speedHz)\n\t\t\n\t\t\n\t\tLocal channelnr:Int = 0, channels_finished:Byte = 0\n\t\tFor Local c:TmidiChannel = EachIn channels\n\t\t\tmidi2Byte(midiOut, $C0 | c.id, c.instrument)\n\t\t\tmidi3Byte(midiOut, $B0 | c.id, $07, c.volume)\n\t\t\tc.currentNote = 0\n\t\t\tc.currentNoteTimer = 0\n\t\t\t\n\t\t\tchannelnr:+1\n\t\tNext\n\t\tWhile channels_finished <> channelnr\n\t\t\tchannelnr = 0\n\t\t\tchannels_finished = 0\n\t\t\tFor Local c:TmidiChannel = EachIn channels\n\t\t\t\tIf c.currentNote < c.arrlength\n\t\t\t\t\tIf c.currentNoteTimer = c.notes[c.currentNote].length\n\t\t\t\t\t\tIf c.notes[c.currentNote].Note <> $ff\n\t\t\t\t\t\t\tmidi3Byte(midiOut, $80 | c.id, c.notes[c.currentNote].Note, $3F)\n\t\t\t\t\t\tEnd If\n\t\t\t\t\t\t\n\t\t\t\t\t\tc.currentNote:+1\n\t\t\t\t\t\tc.currentNoteTimer = 0\n\t\t\t\t\tEnd If\n\t\t\t\t\t\n\t\t\t\t\tIf c.currentNoteTimer = 0 And c.currentNote < c.arrlength And c.notes[c.currentNote].Note <> $ff\n\t\t\t\t\t\tmidi3Byte(midiOut, $90 | c.id, c.notes[c.currentNote].note, $3F)\n\t\t\t\t\tEnd If\n\t\t\t\t\tc.currentNoteTimer:+1\n\t\t\t\tElse\n\t\t\t\t\tchannels_finished:+1\n\t\t\t\tEnd If\n\t\t\t\tchannelnr:+1\n\t\t\tNext\n\t\t\tWaitTimer(timer)\n\t\tWend\n\tEnd Method\n\t\n\tMethod loadMusic(file:String)\n\t\tIf FileType(file) = 1\n\t\t\tfile = LoadText(file)\n\t\t\tfile = Replace(file, \" \", \"\")\n\t\t\tfile = Replace(file, Chr(9), \"\")\n\t\t\tfile = Replace(file, Chr(10), \"\")\n\t\t\tfile = Replace(file, Chr(13), \"\")\n\t\t\t\n\t\t\tLocal gs:Int = 1, ge:Int = 0, content:String, title:String\n\t\t\t\n\t\t\tRepeat\n\t\t\t\tgs = Instr(file, \"\/*\")\n\t\t\t\tIf gs = 0 Exit\n\t\t\t\tge = Instr(file, \"*\/\", gs)\n\t\t\t\tfile = Mid(file, 1, gs - 1) + Mid(file, ge + 2)\n\t\t\tForever\n\t\t\t\n\t\t\tgs = 1;ge = 0\n\t\t\t\n\t\t\tWhile ge < Len(file)\n\t\t\t\tgs = Instr(file, \"{\", ge)\n\t\t\t\ttitle = Mid(file, ge + 1, gs - ge - 1)\n\t\t\t\tge = Instr(file, \"}\", gs + 1)\n\t\t\t\tcontent = Mid(file, gs + 1, ge - gs - 1)\n\t\t\t\t\n\t\t\t\tLocal cs:Int = 0, ce:Int = 0\n\t\t\t\tSelect title\n\t\t\t\t\tCase \"general\"\n\t\t\t\t\t\tcs = Instr(content, \"speed\")\n\t\t\t\t\t\tIf cs <> 0\n\t\t\t\t\t\t\tcs:+6\n\t\t\t\t\t\t\tce = Instr(content, \";\", cs)\n\t\t\t\t\t\t\tspeedHz = Mid(content, cs, ce - cs).ToFloat()\n\t\t\t\t\t\tEnd If\n\t\t\t\t\t\t\n\t\t\t\t\tCase \"channel\"\n\t\t\t\t\t\tLocal c:TmidiChannel = New TmidiChannel\n\t\t\t\t\t\tSelf.addChannel(c)\n\t\t\t\t\t\t\n\t\t\t\t\t\tLocal pitr:Int, pstart:String, prules:String[], pindex:String[], pbegin:String, pend:String\n\t\t\t\t\t\tLocal vitr:Int, vstart:String, vrules:String[], vindex:String[], vbegin:String, vend:String\n\t\t\t\t\t\t\n\t\t\t\t\t\tcs = Instr(content, \"id\")\n\t\t\t\t\t\tIf cs <> 0\n\t\t\t\t\t\t\tcs:+3\n\t\t\t\t\t\t\tce = Instr(content, \";\", cs)\n\t\t\t\t\t\t\tc.id = Mid(content, cs, ce - cs).ToInt()\n\t\t\t\t\t\tEnd If\n\t\t\t\t\t\t\n\t\t\t\t\t\tcs = Instr(content, \"instrument\")\n\t\t\t\t\t\tIf cs <> 0\n\t\t\t\t\t\t\tcs:+11\n\t\t\t\t\t\t\tce = Instr(content, \";\", cs)\n\t\t\t\t\t\t\tc.instrument = Mid(content, cs, ce - cs).ToInt()\n\t\t\t\t\t\tEnd If\n\t\t\t\t\t\t\n\t\t\t\t\t\tcs = Instr(content, \"volume\")\n\t\t\t\t\t\tIf cs <> 0\n\t\t\t\t\t\t\tcs:+7\n\t\t\t\t\t\t\tce = Instr(content, \";\", cs)\n\t\t\t\t\t\t\tc.volume = Mid(content, cs, ce - cs).ToInt()\n\t\t\t\t\t\tEnd If\n\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\tcs = Instr(content, \"pitch_iterations\")\n\t\t\t\t\t\tIf cs <> 0\n\t\t\t\t\t\t\tcs:+17\n\t\t\t\t\t\t\tce = Instr(content, \";\", cs)\n\t\t\t\t\t\t\tpitr = Mid(content, cs, ce - cs).ToInt()\n\t\t\t\t\t\tEnd If\n\t\t\t\t\t\t\n\t\t\t\t\t\tcs = Instr(content, \"pitch_start\")\n\t\t\t\t\t\tIf cs <> 0\n\t\t\t\t\t\t\tcs:+12\n\t\t\t\t\t\t\tce = Instr(content, \";\", cs)\n\t\t\t\t\t\t\tpstart = Mid(content, cs, ce - cs)\n\t\t\t\t\t\tEnd If\n\t\t\t\t\t\t\n\t\t\t\t\t\tcs = Instr(content, \"pitch_rules\")\n\t\t\t\t\t\tIf cs <> 0\n\t\t\t\t\t\t\tcs:+12\n\t\t\t\t\t\t\tce = Instr(content, \";\", cs)\n\t\t\t\t\t\t\tprules = Mid(content, cs, ce - cs).Split(\",\")\n\t\t\t\t\t\tEnd If\n\t\t\t\t\t\t\n\t\t\t\t\t\tcs = Instr(content, \"pitch_index\")\n\t\t\t\t\t\tIf cs <> 0\n\t\t\t\t\t\t\tcs:+12\n\t\t\t\t\t\t\tce = Instr(content, \";\", cs)\n\t\t\t\t\t\t\tpindex = Mid(content, cs, ce - cs).Split(\",\")\n\t\t\t\t\t\tEnd If\n\t\t\t\t\t\t\n\t\t\t\t\t\tcs = Instr(content, \"pitch_begin\")\n\t\t\t\t\t\tIf cs <> 0\n\t\t\t\t\t\t\tcs:+12\n\t\t\t\t\t\t\tce = Instr(content, \";\", cs)\n\t\t\t\t\t\t\tpbegin = Mid(content, cs, ce - cs)\n\t\t\t\t\t\tEnd If\n\t\t\t\t\t\t\n\t\t\t\t\t\tcs = Instr(content, \"pitch_end\")\n\t\t\t\t\t\tIf cs <> 0\n\t\t\t\t\t\t\tcs:+10\n\t\t\t\t\t\t\tce = Instr(content, \";\", cs)\n\t\t\t\t\t\t\tpend = Mid(content, cs, ce - cs)\n\t\t\t\t\t\tEnd If\n\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\tcs = Instr(content, \"value_iterations\")\n\t\t\t\t\t\tIf cs <> 0\n\t\t\t\t\t\t\tcs:+17\n\t\t\t\t\t\t\tce = Instr(content, \";\", cs)\n\t\t\t\t\t\t\tvitr = Mid(content, cs, ce - cs).ToInt()\n\t\t\t\t\t\tEnd If\n\t\t\t\t\t\t\n\t\t\t\t\t\tcs = Instr(content, \"value_start\")\n\t\t\t\t\t\tIf cs <> 0\n\t\t\t\t\t\t\tcs:+12\n\t\t\t\t\t\t\tce = Instr(content, \";\", cs)\n\t\t\t\t\t\t\tvstart = Mid(content, cs, ce - cs)\n\t\t\t\t\t\tEnd If\n\t\t\t\t\t\t\n\t\t\t\t\t\tcs = Instr(content, \"value_rules\")\n\t\t\t\t\t\tIf cs <> 0\n\t\t\t\t\t\t\tcs:+12\n\t\t\t\t\t\t\tce = Instr(content, \";\", cs)\n\t\t\t\t\t\t\tvrules = Mid(content, cs, ce - cs).Split(\",\")\n\t\t\t\t\t\tEnd If\n\t\t\t\t\t\t\n\t\t\t\t\t\tcs = Instr(content, \"value_index\")\n\t\t\t\t\t\tIf cs <> 0\n\t\t\t\t\t\t\tcs:+12\n\t\t\t\t\t\t\tce = Instr(content, \";\", cs)\n\t\t\t\t\t\t\tvindex = Mid(content, cs, ce - cs).Split(\",\")\n\t\t\t\t\t\tEnd If\n\t\t\t\t\t\t\n\t\t\t\t\t\tcs = Instr(content, \"value_begin\")\n\t\t\t\t\t\tIf cs <> 0\n\t\t\t\t\t\t\tcs:+12\n\t\t\t\t\t\t\tce = Instr(content, \";\", cs)\n\t\t\t\t\t\t\tvbegin = Mid(content, cs, ce - cs)\n\t\t\t\t\t\tEnd If\n\t\t\t\t\t\t\n\t\t\t\t\t\tcs = Instr(content, \"value_end\")\n\t\t\t\t\t\tIf cs <> 0\n\t\t\t\t\t\t\tcs:+10\n\t\t\t\t\t\t\tce = Instr(content, \";\", cs)\n\t\t\t\t\t\t\tvend = Mid(content, cs, ce - cs)\n\t\t\t\t\t\tEnd If\n\t\t\t\t\t\t\n\t\t\t\t\t\tLocal pstr:String, vstr:String\n\t\t\t\t\t\tpstr = pbegin + L_System(pitr, pstart, prules) + pend\n\t\t\t\t\t\tvstr = vbegin + L_System(vitr, vstart, vrules) + vend\n\t\t\t\t\t\t\n\t\t\t\t\t\tc.fromStrings(pstr, pindex, vstr, vindex)\n\t\t\t\tEnd Select\n\t\t\tWend\n\t\tElse\n\t\t\tRuntimeError(\"File does not exist!\")\n\t\tEnd If\n\tEnd Method\n\t\n\tMethod saveAsMidi(filename:String)\n\t\tLocal file:TStream = WriteFile(filename)\n\t\t\n\t\tLocal bytelist:TList = CreateList()\n\t\t\n\t\t'HEADER\t\t\n\t\ttoByteArr($4D546864, 4, bytelist)'Name=\"MThd\"\n\t\ttoByteArr($00000006, 4, bytelist)'Chunck Size\n\t\ttoByteArr($0000, 2, bytelist)'Format Type\n\t\ttoByteArr(channels.Count(), 2, bytelist)'Nr of Tracks\n\t\ttoByteArr($7fff & Int(speedHz * 10), 2, bytelist)'Time Division\n\t\t\n\t\tFor Local t:TByte = EachIn bytelist\n\t\t\tfile.WriteByte(t.v)\n\t\tNext\n\t\t\n\t\tbytelist.Clear()\n\t\t\n\t\t'TRACKS\n\t\t\n'\t\t'End of Track Marker\n'\t\tbytelist.AddLast(TByte.N(0)) 'delta time\n'\t\tbytelist.AddLast(TByte.N($FF))'metaevent\n'\t\tbytelist.AddLast(TByte.N($2F))'type\n'\t\tbytelist.AddLast(TByte.N($0))'length\n'\t\t\n'\t\t'TRACK header\n'\t\tfile.WriteBytes(toByteArr($4D54726B, 4), 4)\n'\t\tfile.WriteBytes(toByteArr(bytelist.Count(), 4), 4)\n\t\t\n\t\tFor Local c:TmidiChannel = EachIn channels\n\t\t\tbytelist.Clear()\n\t\t\t\n\t\t\tLocal dt:Int = 0\n\t\t\t\n\t\t\tIf c.id <> 9\n\t\t\t\t'''''''Set Instrument\n\t\t\t\tbytelist.AddLast(TByte.N(0))'delta time\n\t\t\t\tbytelist.AddLast(TByte.N($C0 | c.id))'eventtype0|channelnr\n\t\t\t\tbytelist.AddLast(TByte.N(c.instrument))'p1\n\t\t\tEnd If\n\t\t\t\n\t\t\t'''''''Set Volume\n\t\t\tbytelist.AddLast(TByte.N(0))'delta time\n\t\t\tbytelist.AddLast(TByte.N($B0 | c.id))'eventtype0|channelnr\n\t\t\tbytelist.AddLast(TByte.N($07))'p1\n\t\t\tbytelist.addlast(TByte.N(c.volume))'p2\n\t\t\t\n\t\t\tFor Local mn:TmidiNote = EachIn c.notes\n\t\t\t\tIf mn.note <> $ff\n\t\t\t\t\t''''''''Note On\n\t\t\t\t\ttoVariableLength(dt, bytelist)'delta time\n\t\t\t\t\tbytelist.AddLast(TByte.N($90 | c.id))'eventtype0|channelnr\n\t\t\t\t\tbytelist.AddLast(TByte.N(mn.note))'p1\n\t\t\t\t\tbytelist.AddLast(TByte.N($3F))'p2\n\t\t\t\t\tdt = mn.length * 20\n\t\t\t\t\t''''''''Note Off\n\t\t\t\t\ttoVariableLength(dt, bytelist)'delta time\n\t\t\t\t\tbytelist.AddLast(TByte.N($80 | c.id))'eventtype0|channelnr\n\t\t\t\t\tbytelist.AddLast(TByte.N(mn.note))'p1\n\t\t\t\t\tbytelist.addlast(TByte.N($3F))'p2\n\t\t\t\t\tdt = 0\n\t\t\t\tElse\n\t\t\t\t\tdt:+mn.length * 20\n\t\t\t\tEnd If\n\t\t\tNext\n\t\t\t\n\t\t\t'End of Track Marker\n\t\t\tbytelist.AddLast(TByte.N(0))'delta time\n\t\t\tbytelist.AddLast(TByte.N($FF))'metaevent\n\t\t\tbytelist.AddLast(TByte.N($2F))'type\n\t\t\tbytelist.AddLast(TByte.N($0))'length\n\t\t\t\n\t\t\t'TRACK header\n\t\t\tfile.WriteBytes(toByteArr($4D54726B, 4), 4)\n\t\t\tfile.WriteBytes(toByteArr(bytelist.Count(), 4), 4)\n\t\t\t\n\t\t\tFor Local t:TByte = EachIn bytelist\n\t\t\t\tfile.WriteByte(t.v)\n\t\t\tNext\n\t\tNext\n\t\t\n\t\tfile.Close()\n\tEnd Method\nEnd Type\n\nType TByte\n\tField v:Byte\n\tFunction N:TByte(v:Byte)\n\t\tLocal t:TByte = New TByte\n\t\tt.v = v\n\t\tReturn t\n\tEnd Function\nEnd Type\n\nFunction midi3Byte(midiOut:TRtMidiOut, v1:Byte, v2:Byte, v3:Byte)\n\tLocal m:Byte[3]\n\tm[0] = v1\n\tm[1] = v2\n\tm[2] = v3\n\tmidiOut.putMessage(m, 3)\nEnd Function\n\nFunction midi2Byte(midiOut:TRtMidiOut, v1:Byte, v2:Byte)\n\tLocal m:Byte[2]\n\tm[0] = v1\n\tm[1] = v2\n\tmidiOut.putMessage(m, 2)\nEnd Function\n\nFunction Count:Int(str:String, char:Byte)\n\tLocal cnt:Int = 0\n\tFor Local n:Int = 0 Until Len(str)\n\t\tIf char = str[n] Then cnt:+1\n\tNext\n\tReturn cnt\nEnd Function\n\nFunction toByteArr:Byte[] (v:Long, length:Int, list:TList = Null)\n\tLocal bytes:Byte[length]\n\tFor Local n:Int = 0 Until length\n\t\tLocal n2:Int = length - n - 1\n\t\tbytes[n] = (v & ($ff Shl (n2 * 8))) Shr (n2 * 8)\n\t\tIf list <> Null Then list.AddLast(TByte.N(bytes[n]))\n\tNext\n\tReturn bytes\nEnd Function\n\nFunction toVariableLength:Byte[] (v:Int, list:TList = Null)\n\tIf v < %10000000\n\t\tLocal bytes:Byte[1]\n\t\tbytes[0] = v & %01111111\n\t\tIf list <> Null Then list.AddLast(TByte.n(bytes[0]))\n\t\tReturn bytes\n\tElse If v < %100000000000000\n\t\tLocal bytes:Byte[2]\n\t\tbytes[1] = v & %01111111\n\t\tbytes[0] = ((v & %011111110000000) Shr 7) | %10000000\n\t\tIf list <> Null\n\t\t\tlist.AddLast(TByte.N(bytes[0]))\n\t\t\tlist.AddLast(TByte.N(bytes[1]))\n\t\tEnd If\n\t\tReturn bytes\n\tElse If v < %1000000000000000000000\n\t\tLocal bytes:Byte[3]\n\t\tbytes[2] = v & %01111111\n\t\tbytes[1] = ((v & %011111110000000) Shr 7) | %10000000\n\t\tbytes[0] = ((v & %0111111100000000000000) Shr 14) | %10000000\n\t\tIf list <> Null\n\t\t\tlist.AddLast(TByte.N(bytes[0]))\n\t\t\tlist.AddLast(TByte.N(bytes[1]))\n\t\t\tlist.AddLast(TByte.N(bytes[2]))\n\t\tEnd If\n\t\tReturn bytes\n\tElse\n\t\tLocal bytes:Byte[4]\n\t\tbytes[3] = v & %01111111\n\t\tbytes[2] = ((v & %011111110000000) Shr 7) | %10000000\n\t\tbytes[1] = ((v & %0111111100000000000000) Shr 14) | %10000000\n\t\tbytes[0] = ((v & %01111111000000000000000000000) Shr 21) | %10000000\n\t\tIf list <> Null\n\t\t\tlist.AddLast(TByte.N(bytes[0]))\n\t\t\tlist.AddLast(TByte.N(bytes[1]))\n\t\t\tlist.AddLast(TByte.N(bytes[2]))\n\t\t\tlist.AddLast(TByte.N(bytes[3]))\n\t\tEnd If\n\t\tReturn bytes\n\tEnd If\nEnd Function\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'lindenmayr_notevalues\/fractal_music.bmx' did not match any file(s) known to git\n","license":"mit","lang":"BlitzMax"} {"commit":"fb30dd8e4ca9986022799da5166e43670d502fa3","subject":"Added WorldPick sample.","message":"Added WorldPick sample.\n","repos":"kfprimm\/maxb3d,kfprimm\/maxb3d","old_file":"functions.mod\/doc\/worldpick.bmx","new_file":"functions.mod\/doc\/worldpick.bmx","new_contents":"\nStrict\n\nImport MaxB3D.Drivers\nImport MaxB3D.MonkeyHeadLoader\nImport MaxB3D.TeapotLoader\n\nImport MaxB3DEx.Helper\n\nGraphics 800,600\n\nLocal light:TLight = CreateLight()\n\nLocal camera:TCamera = CreateCamera()\n\nLocal mesh:TMesh = CreateMonkeyHead()\nSetEntityScale mesh,10,10,10\nSetEntityPosition mesh,0,0,3\nSetEntityPickMode mesh,PICKMODE_POLYGON\n\nLocal sphere:TMesh = CreateSphere(32)\nSetEntityScale sphere,.125,.125,.125\nSetEntityColor sphere,255,0,0\n\nWhile Not KeyDown(KEY_ESCAPE) And Not AppTerminate()\n\tIf MouseDown(1)\n\t\tLocal pick:TPick = WorldPick(camera, [Float(MouseX()), Float(MouseY())])\n\t\tIf pick\n\t\t\tSetEntityPosition sphere,pick.x,pick.y,pick.z\n\t\tEndIf\n\tEndIf\n\t\n\tFlyCam camera\n\t\n\tSetWireFrame KeyDown(KEY_F1)\n\t''TurnEntity mesh,0,1,0\n\n\tRenderWorld\n\tFlip\nWend\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'functions.mod\/doc\/worldpick.bmx' did not match any file(s) known to git\n","license":"mit","lang":"BlitzMax"} {"commit":"d0f37a99e1c85377b1adb3e73bb4bebcc6ff4609","subject":"Create fracta_music.bmx","message":"Create fracta_music.bmx","repos":"Jaulers\/fractals","old_file":"perlinnoise\/fracta_music.bmx","new_file":"perlinnoise\/fracta_music.bmx","new_contents":"SuperStrict\nFramework brl.Retro\nImport BRL.Timer\nImport bah.rtmidi\n'Graphics 1000, 200\n'\n'For Local n:Int = 0 Until 1000\n'\tLocal c:Byte\n'\tc = Min(Max(PerlinNoise(n \/ 100.0, 10, 0.98, 0.0), 0.0), 1.0) * 255\n'\tSetColor c, c, c\n'\tDrawLine n, 0, n, 200\n'Next\n'Flip 0\n'WaitKey()\n'End\n\n'Local filename:String\n'If AppArgs.Length > 1\n'\tfilename = AppArgs[1]\n'Else\n'\tfilename = Input(\"Datei angeben: \")\n'End If\n\n\nGlobal score:TmidiScore = New TmidiScore\nscore.midiOut = New TRtMidiOut.Create()\nscore.midiOut.openPort(0)\nOnEnd(CleanUp)\nSeedRnd MilliSecs()\n'score.loadMusic(filename)\n\nLocal pitchlist:TList, valuelist:TList\nLocal notelist:TByte[]\nnotelist = [TByte.N(60), TByte.N(62), TByte.N(64), TByte.N(65), TByte.N(67), TByte.N(69), TByte.N(71), ..\n\t\t\tTByte.N(72), TByte.N(74), TByte.N(76), TByte.N(77), TByte.N(79), TByte.N(91), TByte.N(83)]\npitchlist = TList.FromArray(notelist)\nnotelist = [TByte.N(1), TByte.N(2), TByte.N(4)]\nvaluelist = TList.FromArray(notelist)\n\nLocal channel1:TmidiChannel = New TmidiChannel\nchannel1.generate(100, 8, 0.95, 0.25, 0.1, pitchlist, 3, 0.99, 0.25, 0.3, valuelist)\nchannel1.id = 0\n\nchannel1.instrument = 0\nchannel1.volume = 127\nscore.addChannel(channel1)\n\nFor Local t:TByte = EachIn pitchlist\n\tt.v:-24\nNext\n\nLocal channel2:TmidiChannel = New TmidiChannel\nchannel2.generate(100, 8, 0.95, 0.25, 0.1, pitchlist, 3, 0.99, 0.25, 0.3, valuelist)\nchannel2.id = 1\n\nchannel2.instrument = 0\nchannel2.volume = 127\nscore.addChannel(channel2)\n\nscore.speedHz = 4\n\nscore.saveAsMidi(\"asdf.midi\")\n\n'score.play\n\nEnd\n\nFunction CleanUp()\n\tscore.midiOut.closePort()\n\tscore.midiOut.Free()\n\tDelay(300)\nEnd Function\n\nFunction NoteFromString:Byte(n:String)\n\tIf n = \"p\" Then Return $ff\n\tLocal os:Int = 0\n\tLocal t:String = Mid(n, 2, 1)\n\tIf t = \"#\" Or t = \"b\"\n\t\tt = Left(n, 2)\n\t\tos = Mid(n, 3).ToInt() + 2\n\tElse\n\t\tt = Left(n, 1)\n\t\tos = Mid(n, 2).ToInt() + 2\n\tEnd If\n\tSelect t\n\t\tCase \"C\"\n\t\t\tReturn 0 + $0C * os\n\t\tCase \"C#\"\n\t\t\tReturn 1 + $0C * os\n\t\tCase \"D\"\n\t\t\tReturn 2 + $0C * os\n\t\tCase \"D#\"\n\t\t\tReturn 3 + $0C * os\n\t\tCase \"E\"\n\t\t\tReturn 4 + $0C * os\n\t\tCase \"F\"\n\t\t\tReturn 5 + $0C * os\n\t\tCase \"F#\"\n\t\t\tReturn 6 + $0C * os\n\t\tCase \"G\"\n\t\t\tReturn 7 + $0C * os\n\t\tCase \"G#\"\n\t\t\tReturn 8 + $0C * os\n\t\tCase \"A\"\n\t\t\tReturn 9 + $0C * os\n\t\tCase \"A#\"\n\t\t\tReturn 10 + $0C * os\n\t\tCase \"B\"\n\t\t\tReturn 11 + $0C * os\n\tEnd Select\nEnd Function\n\nType TmidiNote\n\tField note:Byte\n\tField length:Int\nEnd Type\n\nType TmidiChannel\n\tField id:Int\n\t\n\tField notes:TmidiNote[]\n\tField instrument:Byte\n\tField volume:Byte\n\t\n\tField currentNote:Int\n\tField arrlength:Int\n\tField currentNoteTimer:Int\n\t\n\tMethod generate(l:Int, ..\n\tpitch_octaves:Int, pitch_p:Float, pitch_frq:Float, pitch_frqdstr:Float, pitch_list:TList, ..\n\tvalue_octaves:Int, value_p:Float, value_frq:Float, value_frqdstr:Float, value_list:TList)\n\t\tLocal arr:TmidiNote[l]\n\t\tLocal tmp:Float\n\t\tnotes = arr\n\t\tFor Local n:Int = 0 Until l\n\t\t\tnotes[n] = New TmidiNote\n\t\t\ttmp = PerlinNoise(n \/ pitch_frq, pitch_octaves, pitch_p, pitch_frqdstr)\n\t\t\tnotes[n].note = TByte(pitch_list.ValueAtIndex(Max(Min(tmp * pitch_list.Count(), pitch_list.Count() - 1), 0))).v\n\t\t\ttmp = PerlinNoise(n \/ value_frq, value_octaves, value_p, value_frqdstr)\n\t\t\tnotes[n].length = TByte(value_list.ValueAtIndex(Max(Min(tmp * value_list.Count(), value_list.Count() - 1), 0))).v\n\t\tNext\n\t\t\n\tEnd Method\nEnd Type\n\nType TmidiScore\n\tField channels:TList\n\tField speedHz:Float\n\tField midiOut:TRtMidiOut\n\t\n\tMethod New()\n\t\tchannels = CreateList()\n\tEnd Method\n\t\n\tMethod addChannel(channel:TmidiChannel)\n\t\tSelf.channels.AddLast(channel)\n\tEnd Method\n\t\n\tMethod play()\n\t\tLocal timer:TTimer = CreateTimer(speedHz)\n\t\t\n\t\t\n\t\tLocal channelnr:Int = 0, channels_finished:Byte = 0\n\t\tFor Local c:TmidiChannel = EachIn channels\n\t\t\tmidi2Byte(midiOut, $C0 | c.id, c.instrument)\n\t\t\tmidi3Byte(midiOut, $B0 | c.id, $07, c.volume)\n\t\t\tc.currentNote = 0\n\t\t\tc.currentNoteTimer = 0\n\t\t\t\n\t\t\tchannelnr:+1\n\t\tNext\n\t\tWhile channels_finished <> channelnr\n\t\t\tchannelnr = 0\n\t\t\tchannels_finished = 0\n\t\t\tFor Local c:TmidiChannel = EachIn channels\n\t\t\t\tIf c.currentNote < c.arrlength\n\t\t\t\t\tIf c.currentNoteTimer = c.notes[c.currentNote].length\n\t\t\t\t\t\tIf c.notes[c.currentNote].Note <> $ff\n\t\t\t\t\t\t\tmidi3Byte(midiOut, $80 | c.id, c.notes[c.currentNote].Note, $3F)\n\t\t\t\t\t\tEnd If\n\t\t\t\t\t\t\n\t\t\t\t\t\tc.currentNote:+1\n\t\t\t\t\t\tc.currentNoteTimer = 0\n\t\t\t\t\tEnd If\n\t\t\t\t\t\n\t\t\t\t\tIf c.currentNoteTimer = 0 And c.currentNote < c.arrlength And c.notes[c.currentNote].Note <> $ff\n\t\t\t\t\t\tmidi3Byte(midiOut, $90 | c.id, c.notes[c.currentNote].note, $3F)\n\t\t\t\t\tEnd If\n\t\t\t\t\tc.currentNoteTimer:+1\n\t\t\t\tElse\n\t\t\t\t\tchannels_finished:+1\n\t\t\t\tEnd If\n\t\t\t\tchannelnr:+1\n\t\t\tNext\n\t\t\tWaitTimer(timer)\n\t\tWend\n\tEnd Method\n\t\n\tMethod loadMusic(file:String)\n\t\tIf FileType(file) = 1\n\t\t\tfile = LoadText(file)\n\t\t\tfile = Replace(file, \" \", \"\")\n\t\t\tfile = Replace(file, Chr(9), \"\")\n\t\t\tfile = Replace(file, Chr(10), \"\")\n\t\t\tfile = Replace(file, Chr(13), \"\")\n\t\t\t\n\t\t\tLocal gs:Int = 1, ge:Int = 0, content:String, title:String\n\t\t\t\n\t\t\tRepeat\n\t\t\t\tgs = Instr(file, \"\/*\")\n\t\t\t\tIf gs = 0 Exit\n\t\t\t\tge = Instr(file, \"*\/\", gs)\n\t\t\t\tfile = Mid(file, 1, gs - 1) + Mid(file, ge + 2)\n\t\t\tForever\n\t\t\t\n\t\t\tgs = 1;ge = 0\n\t\t\t\n\t\t\tWhile ge < Len(file)\n\t\t\t\tgs = Instr(file, \"{\", ge)\n\t\t\t\ttitle = Mid(file, ge + 1, gs - ge - 1)\n\t\t\t\tge = Instr(file, \"}\", gs + 1)\n\t\t\t\tcontent = Mid(file, gs + 1, ge - gs - 1)\n\t\t\t\t\n\t\t\t\tLocal cs:Int = 0, ce:Int = 0\n\t\t\t\tSelect title\n\t\t\t\t\tCase \"general\"\n\t\t\t\t\t\tcs = Instr(content, \"speed\")\n\t\t\t\t\t\tIf cs <> 0\n\t\t\t\t\t\t\tcs:+6\n\t\t\t\t\t\t\tce = Instr(content, \";\", cs)\n\t\t\t\t\t\t\tspeedHz = Mid(content, cs, ce - cs).ToFloat()\n\t\t\t\t\t\tEnd If\n\t\t\t\t\t\t\n\t\t\t\t\tCase \"channel\"\n\t\t\t\t\t\tLocal c:TmidiChannel = New TmidiChannel\n\t\t\t\t\t\tSelf.addChannel(c)\n\t\t\t\t\t\t\n\t\t\t\t\t\tLocal pitr:Int, pstart:String, prules:String[], pindex:String[], pbegin:String, pend:String\n\t\t\t\t\t\tLocal vitr:Int, vstart:String, vrules:String[], vindex:String[], vbegin:String, vend:String\n\t\t\t\t\t\t\n\t\t\t\t\t\tcs = Instr(content, \"id\")\n\t\t\t\t\t\tIf cs <> 0\n\t\t\t\t\t\t\tcs:+3\n\t\t\t\t\t\t\tce = Instr(content, \";\", cs)\n\t\t\t\t\t\t\tc.id = Mid(content, cs, ce - cs).ToInt()\n\t\t\t\t\t\tEnd If\n\t\t\t\t\t\t\n\t\t\t\t\t\tcs = Instr(content, \"instrument\")\n\t\t\t\t\t\tIf cs <> 0\n\t\t\t\t\t\t\tcs:+11\n\t\t\t\t\t\t\tce = Instr(content, \";\", cs)\n\t\t\t\t\t\t\tc.instrument = Mid(content, cs, ce - cs).ToInt()\n\t\t\t\t\t\tEnd If\n\t\t\t\t\t\t\n\t\t\t\t\t\tcs = Instr(content, \"volume\")\n\t\t\t\t\t\tIf cs <> 0\n\t\t\t\t\t\t\tcs:+7\n\t\t\t\t\t\t\tce = Instr(content, \";\", cs)\n\t\t\t\t\t\t\tc.volume = Mid(content, cs, ce - cs).ToInt()\n\t\t\t\t\t\tEnd If\n\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\tcs = Instr(content, \"pitch_iterations\")\n\t\t\t\t\t\tIf cs <> 0\n\t\t\t\t\t\t\tcs:+17\n\t\t\t\t\t\t\tce = Instr(content, \";\", cs)\n\t\t\t\t\t\t\tpitr = Mid(content, cs, ce - cs).ToInt()\n\t\t\t\t\t\tEnd If\n\t\t\t\t\t\t\n\t\t\t\t\t\tcs = Instr(content, \"pitch_start\")\n\t\t\t\t\t\tIf cs <> 0\n\t\t\t\t\t\t\tcs:+12\n\t\t\t\t\t\t\tce = Instr(content, \";\", cs)\n\t\t\t\t\t\t\tpstart = Mid(content, cs, ce - cs)\n\t\t\t\t\t\tEnd If\n\t\t\t\t\t\t\n\t\t\t\t\t\tcs = Instr(content, \"pitch_rules\")\n\t\t\t\t\t\tIf cs <> 0\n\t\t\t\t\t\t\tcs:+12\n\t\t\t\t\t\t\tce = Instr(content, \";\", cs)\n\t\t\t\t\t\t\tprules = Mid(content, cs, ce - cs).Split(\",\")\n\t\t\t\t\t\tEnd If\n\t\t\t\t\t\t\n\t\t\t\t\t\tcs = Instr(content, \"pitch_index\")\n\t\t\t\t\t\tIf cs <> 0\n\t\t\t\t\t\t\tcs:+12\n\t\t\t\t\t\t\tce = Instr(content, \";\", cs)\n\t\t\t\t\t\t\tpindex = Mid(content, cs, ce - cs).Split(\",\")\n\t\t\t\t\t\tEnd If\n\t\t\t\t\t\t\n\t\t\t\t\t\tcs = Instr(content, \"pitch_begin\")\n\t\t\t\t\t\tIf cs <> 0\n\t\t\t\t\t\t\tcs:+12\n\t\t\t\t\t\t\tce = Instr(content, \";\", cs)\n\t\t\t\t\t\t\tpbegin = Mid(content, cs, ce - cs)\n\t\t\t\t\t\tEnd If\n\t\t\t\t\t\t\n\t\t\t\t\t\tcs = Instr(content, \"pitch_end\")\n\t\t\t\t\t\tIf cs <> 0\n\t\t\t\t\t\t\tcs:+10\n\t\t\t\t\t\t\tce = Instr(content, \";\", cs)\n\t\t\t\t\t\t\tpend = Mid(content, cs, ce - cs)\n\t\t\t\t\t\tEnd If\n\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\tcs = Instr(content, \"value_iterations\")\n\t\t\t\t\t\tIf cs <> 0\n\t\t\t\t\t\t\tcs:+17\n\t\t\t\t\t\t\tce = Instr(content, \";\", cs)\n\t\t\t\t\t\t\tvitr = Mid(content, cs, ce - cs).ToInt()\n\t\t\t\t\t\tEnd If\n\t\t\t\t\t\t\n\t\t\t\t\t\tcs = Instr(content, \"value_start\")\n\t\t\t\t\t\tIf cs <> 0\n\t\t\t\t\t\t\tcs:+12\n\t\t\t\t\t\t\tce = Instr(content, \";\", cs)\n\t\t\t\t\t\t\tvstart = Mid(content, cs, ce - cs)\n\t\t\t\t\t\tEnd If\n\t\t\t\t\t\t\n\t\t\t\t\t\tcs = Instr(content, \"value_rules\")\n\t\t\t\t\t\tIf cs <> 0\n\t\t\t\t\t\t\tcs:+12\n\t\t\t\t\t\t\tce = Instr(content, \";\", cs)\n\t\t\t\t\t\t\tvrules = Mid(content, cs, ce - cs).Split(\",\")\n\t\t\t\t\t\tEnd If\n\t\t\t\t\t\t\n\t\t\t\t\t\tcs = Instr(content, \"value_index\")\n\t\t\t\t\t\tIf cs <> 0\n\t\t\t\t\t\t\tcs:+12\n\t\t\t\t\t\t\tce = Instr(content, \";\", cs)\n\t\t\t\t\t\t\tvindex = Mid(content, cs, ce - cs).Split(\",\")\n\t\t\t\t\t\tEnd If\n\t\t\t\t\t\t\n\t\t\t\t\t\tcs = Instr(content, \"value_begin\")\n\t\t\t\t\t\tIf cs <> 0\n\t\t\t\t\t\t\tcs:+12\n\t\t\t\t\t\t\tce = Instr(content, \";\", cs)\n\t\t\t\t\t\t\tvbegin = Mid(content, cs, ce - cs)\n\t\t\t\t\t\tEnd If\n\t\t\t\t\t\t\n\t\t\t\t\t\tcs = Instr(content, \"value_end\")\n\t\t\t\t\t\tIf cs <> 0\n\t\t\t\t\t\t\tcs:+10\n\t\t\t\t\t\t\tce = Instr(content, \";\", cs)\n\t\t\t\t\t\t\tvend = Mid(content, cs, ce - cs)\n\t\t\t\t\t\tEnd If\n\t\t\t\t\t\t\n\t\t\t\tEnd Select\n\t\t\tWend\n\t\tElse\n\t\t\tRuntimeError(\"File does not exist!\")\n\t\tEnd If\n\tEnd Method\n\t\n\tMethod saveAsMidi(filename:String)\n\t\tLocal file:TStream = WriteFile(filename)\n\t\t\n\t\tLocal bytelist:TList = CreateList()\n\t\t\n\t\t'HEADER\t\t\n\t\ttoByteArr($4D546864, 4, bytelist)'Name=\"MThd\"\n\t\ttoByteArr($00000006, 4, bytelist)'Chunck Size\n\t\ttoByteArr($0000, 2, bytelist)'Format Type\n\t\ttoByteArr(channels.Count(), 2, bytelist)'Nr of Tracks\n\t\ttoByteArr($7fff & Int(speedHz * 10), 2, bytelist)'Time Division\n\t\t\n\t\tFor Local t:TByte = EachIn bytelist\n\t\t\tfile.WriteByte(t.v)\n\t\tNext\n\t\t\n\t\tbytelist.Clear()\n\t\t\n\t\t'TRACKS\n\t\t\n'\t\t'End of Track Marker\n'\t\tbytelist.AddLast(TByte.N(0)) 'delta time\n'\t\tbytelist.AddLast(TByte.N($FF))'metaevent\n'\t\tbytelist.AddLast(TByte.N($2F))'type\n'\t\tbytelist.AddLast(TByte.N($0))'length\n'\t\t\n'\t\t'TRACK header\n'\t\tfile.WriteBytes(toByteArr($4D54726B, 4), 4)\n'\t\tfile.WriteBytes(toByteArr(bytelist.Count(), 4), 4)\n\t\t\n\t\tFor Local c:TmidiChannel = EachIn channels\n\t\t\tbytelist.Clear()\n\t\t\t\n\t\t\tLocal dt:Int = 0\n\t\t\t\n\t\t\tIf c.id <> 9\n\t\t\t\t'''''''Set Instrument\n\t\t\t\tbytelist.AddLast(TByte.N(0))'delta time\n\t\t\t\tbytelist.AddLast(TByte.N($C0 | c.id))'eventtype0|channelnr\n\t\t\t\tbytelist.AddLast(TByte.N(c.instrument))'p1\n\t\t\tEnd If\n\t\t\t\n\t\t\t'''''''Set Volume\n\t\t\tbytelist.AddLast(TByte.N(0))'delta time\n\t\t\tbytelist.AddLast(TByte.N($B0 | c.id))'eventtype0|channelnr\n\t\t\tbytelist.AddLast(TByte.N($07))'p1\n\t\t\tbytelist.addlast(TByte.N(c.volume))'p2\n\t\t\t\n\t\t\tFor Local mn:TmidiNote = EachIn c.notes\n\t\t\t\tIf mn.note <> $ff\n\t\t\t\t\t''''''''Note On\n\t\t\t\t\ttoVariableLength(dt, bytelist)'delta time\n\t\t\t\t\tbytelist.AddLast(TByte.N($90 | c.id))'eventtype0|channelnr\n\t\t\t\t\tbytelist.AddLast(TByte.N(mn.note))'p1\n\t\t\t\t\tbytelist.AddLast(TByte.N($3F))'p2\n\t\t\t\t\tdt = mn.length * 20\n\t\t\t\t\t''''''''Note Off\n\t\t\t\t\ttoVariableLength(dt, bytelist)'delta time\n\t\t\t\t\tbytelist.AddLast(TByte.N($80 | c.id))'eventtype0|channelnr\n\t\t\t\t\tbytelist.AddLast(TByte.N(mn.note))'p1\n\t\t\t\t\tbytelist.addlast(TByte.N($3F))'p2\n\t\t\t\t\tdt = 0\n\t\t\t\tElse\n\t\t\t\t\tdt:+mn.length * 20\n\t\t\t\tEnd If\n\t\t\tNext\n\t\t\t\n\t\t\t'End of Track Marker\n\t\t\tbytelist.AddLast(TByte.N(0))'delta time\n\t\t\tbytelist.AddLast(TByte.N($FF))'metaevent\n\t\t\tbytelist.AddLast(TByte.N($2F))'type\n\t\t\tbytelist.AddLast(TByte.N($0))'length\n\t\t\t\n\t\t\t'TRACK header\n\t\t\tfile.WriteBytes(toByteArr($4D54726B, 4), 4)\n\t\t\tfile.WriteBytes(toByteArr(bytelist.Count(), 4), 4)\n\t\t\t\n\t\t\tFor Local t:TByte = EachIn bytelist\n\t\t\t\tfile.WriteByte(t.v)\n\t\t\tNext\n\t\tNext\n\t\t\n\t\tfile.Close()\n\tEnd Method\nEnd Type\n\nType TByte\n\tField v:Byte\n\tFunction N:TByte(v:Byte)\n\t\tLocal t:TByte = New TByte\n\t\tt.v = v\n\t\tReturn t\n\tEnd Function\nEnd Type\n\nFunction midi3Byte(midiOut:TRtMidiOut, v1:Byte, v2:Byte, v3:Byte)\n\tLocal m:Byte[3]\n\tm[0] = v1\n\tm[1] = v2\n\tm[2] = v3\n\tmidiOut.putMessage(m, 3)\nEnd Function\n\nFunction midi2Byte(midiOut:TRtMidiOut, v1:Byte, v2:Byte)\n\tLocal m:Byte[2]\n\tm[0] = v1\n\tm[1] = v2\n\tmidiOut.putMessage(m, 2)\nEnd Function\n\nFunction Count:Int(str:String, char:Byte)\n\tLocal cnt:Int = 0\n\tFor Local n:Int = 0 Until Len(str)\n\t\tIf char = str[n] Then cnt:+1\n\tNext\n\tReturn cnt\nEnd Function\n\nFunction toByteArr:Byte[] (v:Long, length:Int, list:TList = Null)\n\tLocal bytes:Byte[length]\n\tFor Local n:Int = 0 Until length\n\t\tLocal n2:Int = length - n - 1\n\t\tbytes[n] = (v & ($ff Shl (n2 * 8))) Shr (n2 * 8)\n\t\tIf list <> Null Then list.AddLast(TByte.N(bytes[n]))\n\tNext\n\tReturn bytes\nEnd Function\n\nFunction toVariableLength:Byte[] (v:Int, list:TList = Null)\n\tIf v < %10000000\n\t\tLocal bytes:Byte[1]\n\t\tbytes[0] = v & %01111111\n\t\tIf list <> Null Then list.AddLast(TByte.n(bytes[0]))\n\t\tReturn bytes\n\tElse If v < %100000000000000\n\t\tLocal bytes:Byte[2]\n\t\tbytes[1] = v & %01111111\n\t\tbytes[0] = ((v & %011111110000000) Shr 7) | %10000000\n\t\tIf list <> Null\n\t\t\tlist.AddLast(TByte.N(bytes[0]))\n\t\t\tlist.AddLast(TByte.N(bytes[1]))\n\t\tEnd If\n\t\tReturn bytes\n\tElse If v < %1000000000000000000000\n\t\tLocal bytes:Byte[3]\n\t\tbytes[2] = v & %01111111\n\t\tbytes[1] = ((v & %011111110000000) Shr 7) | %10000000\n\t\tbytes[0] = ((v & %0111111100000000000000) Shr 14) | %10000000\n\t\tIf list <> Null\n\t\t\tlist.AddLast(TByte.N(bytes[0]))\n\t\t\tlist.AddLast(TByte.N(bytes[1]))\n\t\t\tlist.AddLast(TByte.N(bytes[2]))\n\t\tEnd If\n\t\tReturn bytes\n\tElse\n\t\tLocal bytes:Byte[4]\n\t\tbytes[3] = v & %01111111\n\t\tbytes[2] = ((v & %011111110000000) Shr 7) | %10000000\n\t\tbytes[1] = ((v & %0111111100000000000000) Shr 14) | %10000000\n\t\tbytes[0] = ((v & %01111111000000000000000000000) Shr 21) | %10000000\n\t\tIf list <> Null\n\t\t\tlist.AddLast(TByte.N(bytes[0]))\n\t\t\tlist.AddLast(TByte.N(bytes[1]))\n\t\t\tlist.AddLast(TByte.N(bytes[2]))\n\t\t\tlist.AddLast(TByte.N(bytes[3]))\n\t\tEnd If\n\t\tReturn bytes\n\tEnd If\nEnd Function\n\n\n\nFunction Catmul:Float(v0:Float, v1:Float, v2:Float, v3:Float, x:Float)\n\tLocal a0:Float, a1:Float, a2:Float, a3:Float, x2:Float\n\t\n\tx2 = x * x\n'\ta0 = -0.5 * v0 + 1.5 * v1 - 1.5 * v2 + 0.5 * v3\n'\ta1 = v0 - 2.5 * v1 + 2 * v2 - 0.5 * v3\n'\ta2 = -0.5 * v0 + 0.5 * v2\n'\ta3 = v1\n\ta0 = v3 - v2 - v0 + v1\n\ta1 = v0 - v1 - a0\n\ta2 = v2 - v0\n\ta3 = v1\n\t\n\tReturn a0 * x * x2 + a1 * x2 + a2 * x + a3\nEnd Function\n\nFunction Noise:Float(x:Int, s:Int = 789221)\n\tx = (x Shl 13) ~ x\n\tReturn 1.0 - ((x * (x * x * 15731 + s) + 1376312589) & $7fffffff) \/ 2147480774.0'1073740387.0\nEnd Function\n\nFunction InterpolatedNoise:Float(x:Float, s:Int = 789221)\n\tLocal intx:Int = Int(x)\n\tLocal fracx:Float = x - intx\n\tLocal v0:Float, v1:Float, v2:Float, v3:Float\n\t\n\tv0 = Noise(intx - 1, s)\n\tv1 = Noise(intx, s)\n\tv2 = Noise(intx + 1, s)\n\tv3 = Noise(intx + 2, s)\n\t\n\tReturn Catmul(v0, v1, v2, v3, fracx)\nEnd Function\n\nFunction PerlinNoise:Float(x:Float, octaves:Int = 8, p:Float = 0.25, frqdistur:Float = 0.1, s:Int = 789221)\n\tLocal v:Float = 0.0, cnt:Float = 0.0\n\n\tLocal frq:Float = 1.0\n\tFor Local n:Int = 0 Until octaves\n\t\tv:+InterpolatedNoise((x) \/ frq) * p\n\t\tcnt:+p\n\t\tp:*p\n\t\tfrq:\/(2.0 + Rnd(-frqdistur, frqdistur))\n\tNext\n\t\n\tReturn v \/ cnt\nEnd Function\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'perlinnoise\/fracta_music.bmx' did not match any file(s) known to git\n","license":"mit","lang":"BlitzMax"} {"commit":"72c3814e11f1f819b3a70ae02982483fadf06850","subject":"Added new primitives sample.","message":"Added new primitives sample.\n","repos":"kfprimm\/maxb3d,kfprimm\/maxb3d","old_file":"doc\/samples\/kfprimm\/new-primitives.bmx","new_file":"doc\/samples\/kfprimm\/new-primitives.bmx","new_contents":"\nStrict\n\nImport MaxB3D.Drivers\nImport MaxB3D.Loaders\n\nGraphics 800,600\n\nLocal light:TLight = CreateLight()\n\nLocal camera:TCamera = CreateCamera()\nSetEntityPosition camera,0,0,-3\n\nGlobal primitives:TMesh[3]\n\nprimitives[0] = CreateBunny()\nSetEntityName primitives[0], \"Stanford Bunny\"\nSetEntityScale primitives[0], 2,2,2\n\nprimitives[1] = CreateMonkeyHead()\nSetEntityName primitives[1], \"Suzanne (Blender Monkey)\"\n\nprimitives[2] = CreateTeapot()\nSetEntityName primitives[2], \"Utah Teapot\"\n\nLocal current\n\nWhile Not KeyDown(KEY_ESCAPE) And Not AppTerminate()\n\tFor Local i = 0 to 9\n\t\tIf KeyHit(KEY_0 + i)\n\t\t\tcurrent = i\n\t\t\tExit\n\t\tEndIf\n\tNext\n\t\n\tIf KeyHit(KEY_UP) Or KeyHit(KEY_LEFT) current :- 1\n\tIf KeyHit(KEY_DOWN) Or KeyHit(KEY_RIGHT) current :+ 1\n\t\n\tIf current > primitives.length -1 current = 0\n\tIf current < 0 current = primitives.length - 1 \n\t\n\tFor Local i = 0 To primitives.length-1 \n\t\tSetEntityVisible primitives[i], current = i\n\tNext\n\t\n\tTurnEntity primitives[current],0,1,0\n\t\n\tSetWireFrame KeyDown(KEY_W)\n\t\n\tRenderWorld\n\tDoMax2D\n\tDrawText \"Press 1, 2, or 3 to select a particular meshes.\",0,0\n\tDrawText \"Press Up\/Left or Down\/Right to cycle through meshes.\",0,15\n\tDrawText \"Current mesh: \"+GetEntityName(primitives[current]),0,30\n\t\n\tFlip\nWend\n\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'doc\/samples\/kfprimm\/new-primitives.bmx' did not match any file(s) known to git\n","license":"mit","lang":"BlitzMax"} {"commit":"26876024d3d64c10e77c9a32aa998841f1fae068","subject":"Added module and bmk utils.","message":"Added module and bmk utils.\n","repos":"maximos\/maximus","old_file":"src\/utils.bmx","new_file":"src\/utils.bmx","new_contents":"\nRem\nCopyright (c) 2010 Tim Howard\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and\/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\nEnd Rem\n\nRem\n\tbbdoc: Maximus module utilities.\nEnd Rem\nType mxModUtils\n\t\n\tGlobal g_modules:dObjectMap\n\t\n\tRem\n\t\tbbdoc: Get an object map of the current modules.\n\t\treturns: An object map containing the current modules.\n\t\tabout: @force can be used to force re-enumeration of the modules.\n\tEnd Rem\n\tFunction GetModules:dObjectMap(force:Int = False)\n\t\tIf g_modules = Null Or force = True\n\t\t\tg_modules = EnumModules(Null, Null)\n\t\tEnd If\n\t\tReturn g_modules\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Check if the user currently has the given module.\n\t\treturns: True if the given module was found.\n\tEnd Rem\n\tFunction HasModule:Int(modul:String)\n\t\tReturn GetModules()._Contains(modul)\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Get the path to the given module or modscope.\n\t\treturns: The path to the given module or modscope, or the modules path if the given modid is Null.\n\tEnd Rem\n\tFunction ModulePath:String(modid:String)\n\t\tLocal p:String = mainapp.m_modpath\n\t\tIf modid Then p:+\"\/\" + modid.Replace(\".\", \".mod\/\") + \".mod\"\n\t\tReturn p\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Get the module scope from the given versioned-module id (for modules with forced versions (or normal ids), e.g. mxModUtils.GetScopeFromID(\"foo.bar\/dev\") would return \"foo\").\n\t\treturns: The scope of the given versioned-module id, or Null if the given versioned-module id was incorrect.\n\tEnd Rem\n\tFunction GetScopeFromID:String(verid:String)\n\t\tLocal i:Int = verid.Find(\".\")\n\t\tIf i > -1 Then Return verid[..i]\n\t\tReturn Null\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Get the module name from the given versioned-module id (for modules with forced versions (or normal ids), e.g. mxModUtils.GetNameFromID(\"foo.bar\/dev\") would return \"bar\").\n\t\treturns: The name of the given versioned-module id, or Null if the given versioned-module is was incorrect.\n\tEnd Rem\n\tFunction GetNameFromID:String(verid:String)\n\t\tLocal i:Int = verid.Find(\".\")\n\t\tIf i > -1 Then Return verid[i + 1..]\n\t\tReturn Null\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Get the actual module id from the given versioned-module id (for modules with forced versions (or normal ids), e.g. mxModUtils.GetIDFromVerID(\"foo.bar\/dev\") would return \"foo.bar\").\n\t\treturns: The id of the given versioned-module id.\n\tEnd Rem\n\tFunction GetIDFromVerID:String(verid:String)\n\t\tLocal i:Int = verid.Find(\"\/\")\n\t\tIf i > -1 Then verid = verid[..i]\n\t\tReturn verid\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Get the version from the given versioned-module id (for modules with forced versions, e.g. mxModUtils.GetVersionFromVerID(\"foo.bar\/dev) would return \"dev\").\n\t\treturns: The version of the given versioned-module id (which will be Null if the given value is not versioned).\n\tEnd Rem\n\tFunction GetVersionFromVerID:String(verid:String)\n\t\tLocal i:Int = verid.Find(\"\/\")\n\t\tIf i > -1 Then Return verid[i + 1..]\n\t\tReturn Null\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Enumerate all of the current modules.\n\t\treturns: An object map containing the current modules.\n\tEnd Rem\n\tFunction EnumModules:dObjectMap(modid:String = Null, mods:dObjectMap = Null)\n\t\tIf mods = Null Then mods = New dObjectMap\n\t\tLocal dir:String = ModulePath(modid)\n\t\tLocal files:String[] = LoadDir(dir)\n\t\tFor Local file:String = EachIn files\n\t\t\tLocal path:String = dir + \"\/\" + file\n\t\t\tIf file[file.length - 4..] <> \".mod\" Or FileType(path) <> FILETYPE_DIR Then Continue\n\t\t\tLocal t:String = file[..file.length - 4]\n\t\t\tIf modid Then t = modid + \".\" + t\n\t\t\tLocal i:Int = t.Find(\".\")\n\t\t\tIf i > -1 And t.Find(\".\", i + 1) = -1 Then mods._Insert(t, path)\n\t\t\tEnumModules(t, mods)\n\t\tNext\n\t\tReturn mods\n\tEnd Function\n\t\nEnd Type\n\nRem\n\tbbdoc: Maximus BMK utilities.\nEnd Rem\nType mxBMKUtils\n\t\n\tRem\n\t\tbbdoc: Run BMK with the given arguments.\n\t\treturns: The exit code from bmk (non-zero when an error occured).\n\tEnd Rem\n\tFunction RunBMK:Int(args:String)\n\t\targs = \"bmk \" + args.Trim()\n\t\tlogger.LogMessage(\"run: \" + args)\n\t\tReturn system_(args)\n\tEnd Function\n\t\n\tRem\n\t\tbbdoc: Make modules with the given arguments.\n\t\treturns: The exit code from bmk (non-zero when an error occured).\n\tEnd Rem\n\tFunction MakeMods:Int(args:String)\n\t\tReturn RunBMK(\"makemods \" + args)\n\tEnd Function\n\t\nEnd Type\n\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'src\/utils.bmx' did not match any file(s) known to git\n","license":"mit","lang":"BlitzMax"} {"commit":"70ed9921d1f3d44910c00f36dfe5a04d6aa40abf","subject":"BlitzMax native code added","message":"BlitzMax native code added\n","repos":"devolonter\/flixel-monkey,devolonter\/flixel-monkey,devolonter\/flixel-monkey,devolonter\/flixel-monkey","old_file":"native\/flixel.bmax.bmx","new_file":"native\/flixel.bmax.bmx","new_contents":"\nType flixel\n\n\tFunction systemMillisecs:Int()\n\t\tReturn Millisecs()\n\tEnd Function\n\t\n\tFunction hideMouse()\n\t\tbmxHideMouse()\n\tEnd Function\n\t\n\tFunction showMouse()\n\t\tbmxShowMouse()\n\tEnd Function\n\t\n\tFunction isMobile:Int()\n\t\tReturn False\n\tEnd Function\n\t\n\tFunction openURL(url:String)\n\t\tbmxOpenURL(url)\n\tEnd Function\n\nEnd Type\n\nFunction bmxHideMouse()\n\tHideMouse()\nEndFunction\n\nFunction bmxShowMouse()\n\tShowMouse()\nEndFunction\n\nFunction bmxOpenURL(url:String)\n\tOpenURL(url)\nEnd Function\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'native\/flixel.bmax.bmx' did not match any file(s) known to git\n","license":"mit","lang":"BlitzMax"} {"commit":"ebef34830321d7b4b99948264c5213628fa767c6","subject":"Added a threaded PUB\/SUB example","message":"Added a threaded PUB\/SUB example\n","repos":"Htbaa\/zmq.mod,Htbaa\/zmq.mod","old_file":"examples\/example1.bmx","new_file":"examples\/example1.bmx","new_contents":"Rem\n\n\tThis is a simple example of a threaded application which uses one PUBLISHER\n\tthread and serveral SUBSCRIBER threads.\nEnd Rem\nSuperStrict\nImport htbaapub.zmq\n\nPrint \"ZMQ Version: \" + TZMQ.Version()\n\nGlobal context:TZMQ_Context = New TZMQ_Context.Create(1)\nGlobal addr:String = \"tcp:\/\/127.0.0.1:6000\"\n\n'The Publisher\nFunction MyPublisherThread:Object(data:Object)\n\t'Create a ZMQ_PUB socket\n\tLocal socket:TZMQ_Socket = context.Socket(ZMQ_PUB)\n\t'Bind to socket to the given address\n\tsocket.Bind(addr)\n\tRepeat\n\t\t'Manually create a TZMQ_Message\n\t\tLocal msg:TZMQ_Message = New TZMQ_Message.Create(\"Hello world! \" + Rnd(100))\n\t\t'Send the message to any SUBSCRIBERs\n\t\tsocket.Send(msg)\n\t\t'Free the message\n\t\t'would otherwise be garbage collected, but it doesn't hurt to clean up yourself\n\t\tmsg.Close()\n\t\tDelay 1000\n\t\t'Send a String without manually creating a TZMQ_Message object\n\t\tsocket.Send(\"Foo Bar \" + Rnd(100))\n\t\tDelay 1000\n\tForever\n\t'We won't get here, but otherwise clean up\n\tsocket.Close()\n\tReturn Null\nEnd Function\n\n'A Subscriber\nFunction MySubscriberThread:Object(data:Object)\n\t'Create a SUBSCRIBER socket\n\tLocal socket:TZMQ_Socket = context.Socket(ZMQ_SUB)\n\t'Connect to given address\n\tsocket.Connect(addr)\n\t'Set socket option to subscribe, no filter\n\tsocket.SetSockOpt(ZMQ_SUBSCRIBE, Null)\n\tRepeat\n\t\t'Receive message\n\t\tLocal msg:TZMQ_Message = socket.Recv()\n\t\tIf msg <> Null\n\t\t\tPrint \"Subscriber \" + String(data) + \" received: \" + msg.ToString()\n\t\t\tmsg.Close()\n\t\tEnd If\n\tForever\n\t'We won't get here, but otherwise clean up\n\tsocket.Close()\n\tReturn Null\nEnd Function\n\n'create a thread!\nLocal thread1:TThread = CreateThread(MyPublisherThread, Null)\n'Increase amount of subcribers to add more SUBSCRIBERS\n'but do note that STDOUT will be scrambled\nLocal subcribers:Int = 1\nFor Local i:Int = 1 To subcribers\n\tPrint \"Starting subscriber \" + i\n\tCreateThread(MySubscriberThread, String(i))\nNext\n\n'Wait for the main thread to finish, which is never\nPrint WaitThread(thread1).ToString()\n'Terminate context\ncontext.Term()\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'examples\/example1.bmx' did not match any file(s) known to git\n","license":"mit","lang":"BlitzMax"} {"commit":"562f313f62f792a634c80083cd15793c176d72d0","subject":"Create KIFS.bmx","message":"Create KIFS.bmx","repos":"Jaulers\/fractals","old_file":"KIFS\/KIFS.bmx","new_file":"KIFS\/KIFS.bmx","new_contents":"SuperStrict\nFramework brl.GLGraphics\nImport brl.TIMER\nImport brl.TextStream\nImport pub.OpenGL\nImport pub.Glew\nImport brl.Retro\nImport brl.PNGLoader\n\nConst GW:Int = 640, GH:Int = 360\n\nIf AppArgs.Length > 1\n\tTAnimFrame.LoadFromFile(AppArgs[1])\nEnd If\n\nGlobal TIMER:TTimer = CreateTimer(30)\nGlobal VERTEX_SHADER_CODE:String = LoadText(\"vs.glsl\")\nGlobal FRAGMENT_SHADER_CODE:String = LoadText(\"fs.glsl\")\n\nInitGL\nGlobal ProgramObj:Int\nInitShaders\nglUseProgram(ProgramObj)\n\nGlobal camS:Float = 0.04\nGlobal camX:Float = -0.9, camY:Float = -1.35, camZ:Float = -3.6\nGlobal camP:Float = 0.2, camT:Float = -0.37\n\nGlobal lightX:Float = -1.6, lightY:Float = -1.9, lightZ:Float = -2.4\nGlobal camZoom:Float = 1.0\nGlobal eps:Float = 0.002\n\nGlobal itr:Int = 10\nGlobal offsetX:Float = 1.0, offsetY:Float = 0.0, offsetZ:Float = 0.0\nGlobal scale:Float = 3.0\nGlobal rotvecX:Float = 0.0, rotvecY:Float = 0.0, rotvecZ:Float = 1.0\nGlobal rotangel:Float = 0.0\n\nGlobal disphelp:Int = 0\n\nGlobal cf:TAnimFrame, cflink:TLink\n\nGlobal MDown:Int, MXS:Int, MYS:Int\nWhile Not KeyHit(KEY_ESCAPE)\n\tMDown = MouseDown(MOUSE_LEFT) Shl 2 + MouseDown(MOUSE_MIDDLE) Shl 1 + MouseDown(MOUSE_RIGHT)\n\tMXS = MouseXSpeed()\n\tMYS = MouseYSpeed()\n\tIf MDown & %100\n\t\tMoveMouse GW \/ 2, GH \/ 2\n\t\tMouseXSpeed()\n\t\tMouseYSpeed()\n\tEnd If\n\t\n\tCheckInput()\n\t\n\tRender()\n\t\n\tIf disphelp DrawHelp()\n\t\n\tFlip 0\n\tglCls\n\tWaitTimer TIMER\nWend\nEnd\n\nFunction CheckInput()\n\toffsetX:+(KeyDown(KEY_R) - KeyDown(KEY_F)) * camS\n\toffsetY:+(KeyDown(KEY_T) - KeyDown(KEY_G)) * camS\n\toffsetZ:+(KeyDown(KEY_Z) - KeyDown(KEY_H)) * camS\n\t\n\tscale:+(KeyDown(KEY_B) - KeyDown(KEY_V)) * camS\n\t\n\trotvecX:+(KeyDown(KEY_U) - KeyDown(KEY_J)) * camS\n\trotvecY:+(KeyDown(KEY_I) - KeyDown(KEY_K)) * camS\n\trotvecZ:+(KeyDown(KEY_O) - KeyDown(KEY_L)) * camS\n\t\n\trotangel:+(KeyDown(KEY_M) - KeyDown(KEY_N)) * camS * 10.0\n\t\n\titr:+(KeyDown(KEY_X) - KeyDown(KEY_Y))\n\t\n\tIf KeyDown(KEY_2) camS:*1.1 Else If KeyDown(KEY_1) camS:\/1.1\n\t\n\tIf KeyDown(KEY_4) eps:*1.1 Else If KeyDown(KEY_3) eps:\/1.1\n\t\n\tIf KeyDown(KEY_6) camZoom:*1.05 Else If KeyDown(KEY_5) camZoom:\/1.05\n\t\n\tIf MDown & 010\n\t\tlightX = camX\n\t\tlightY = camY\n\t\tlightZ = camZ\n\tEnd If\n\t\n\tIf KeyDown(KEY_W)\n\t\tcamX = camX + cos_(camT) * sin_(camP) * camS\n\t\tcamY = camY - sin_(camT) * camS\n\t\tcamZ = camZ + cos_(camT) * cos_(camP) * camS\n\tEnd If\n\tIf KeyDown(KEY_S)\n\t\tcamX = camX - cos_(camT) * sin_(camP) * camS\n\t\tcamY = camY + sin_(camT) * camS\n\t\tcamZ = camZ - cos_(camT) * cos_(camP) * camS\n\tEnd If\n\tIf KeyDown(KEY_D)\n\t\tcamX = camX + sin_(camP + 1.57079633) * camS\n\t\tcamZ = camZ + cos_(camP + 1.57079633) * camS\n\tEnd If\n\tIf KeyDown(KEY_A)\n\t\tcamX = camX - sin_(camP + 1.57079633) * camS\n\t\tcamZ = camZ - cos_(camP + 1.57079633) * camS\n\tEnd If\n\tcamY:+(KeyDown(KEY_LSHIFT) - KeyDown(KEY_SPACE)) * camS\n\t\n\t\n\tIf MDown & %100\n\t\tcamT:-MYS * 0.01'(KeyDown(KEY_UP) - KeyDown(KEY_DOWN)) * 0.01\n\t\tcamP:+MXS * 0.01'(KeyDown(KEY_RIGHT) - KeyDown(KEY_LEFT)) * 0.01\n\tEnd If\n\t\n\tIf KeyHit(KEY_ENTER) disphelp = 1 - disphelp\n\t\n\t\n\tIf KeyHit(KEY_DOWN)\n\t\tIf KeyDown(KEY_RCONTROL)\n\t\t\tTAnimFrame.AddFrame(cflink, 1)\n\t\t\tPrint \"frame modified\"\n\t\tElse\n\t\t\tcf = TAnimFrame.AddFrame(cflink) Print \"frame added\"\n\t\t\tIf cflink = Null Then cflink = TAnimFrame.list.FindLink(cf) Else cflink = cflink.NextLink()\n\t\tEnd If\n\tEnd If\n\t\n\tIf KeyHit(KEY_RIGHT)\n\t\tIf KeyDown(KEY_RCONTROL)\n\t\t\tcflink = TAnimFrame.list.LastLink()\n\t\t\tcf = TAnimFrame(TAnimFrame.list.Last())\n\t\t\tIf cf Then cf.setGlobalsToFrame()\n\t\tElse If cflink.NextLink()\n\t\t\tcflink = cflink.NextLink()\n\t\t\tcf = TAnimFrame(TAnimFrame(cflink.Value()))\n\t\t\tIf cf Then cf.setGlobalsToFrame()\n\t\tEnd If\n\tEnd If\n\t\n\tIf KeyHit(KEY_LEFT)\n\t\tIf KeyDown(KEY_RCONTROL)\n\t\t\tcflink = TAnimFrame.list.FirstLink()\n\t\t\tcf = TAnimFrame(TAnimFrame.list.First())\n\t\t\tIf cf Then cf.setGlobalsToFrame()\n\t\tElse If cflink.PrevLink()\n\t\t\tcflink = cflink.PrevLink()\n\t\t\tcf = TAnimFrame(TAnimFrame(cflink.Value()))\n\t\t\tIf cf Then cf.setGlobalsToFrame()\n\t\tEnd If\n\tEnd If\n\t\n\tIf KeyHit(KEY_BACKSPACE) And cf\n\t\tcflink = cflink.PrevLink()\n\t\tcf.list.Remove(cf)\n\t\tIf cf Then cf = TAnimFrame(cflink.Value())\n\t\tPrint \"frame deleted\"\n\tEnd If\n\t\n\tIf cf\n\t\tLocal timevar:TFloat = TFloat(cf.getVar(\"time\"))\n\t\tIf KeyDown(KEY_PAGEUP) Then timevar.v:*1.1 Print timevar.v Else ..\n\t\tIf KeyDown(KEY_PAGEDOWN) Then timevar.v:\/1.1 Print timevar.v\n\tEnd If\n\t\n\tIf KeyHit(KEY_RSHIFT) And cf Then cf.setGlobalsToFrame()\n\t\n\tIf KeyHit(KEY_UP) Then TAnimFrame.PlayAnim(0.04)\n\t\n\tIf KeyHit(KEY_F10) Then TAnimFrame.SaveToFile(\"anim\" + MilliSecs() + \".txt\")\n\t\n\tIf KeyHit(KEY_F11)\n\t\tIf KeyDown(KEY_RCONTROL)\n\t\t\tTAnimFrame.SaveAnim(0.02, \"anim\" + MilliSecs(), Input(\"Skip Nr Frames:\").ToInt())\n\t\tElse\n\t\t\tTAnimFrame.SaveAnim(0.02, \"anim\" + MilliSecs())\n\t\tEnd If\n\tEnd If\n\t\n\tIf KeyHit(KEY_F12)\n\t\tIf KeyDown(KEY_RCONTROL)\n\t\t\tSaveSceenshot(Input(\"resolution multiplier:\").ToInt())\n\t\tElse\n\t\t\tSaveSceenshot(6)\n\t\tEnd If\n\tEnd If\nEnd Function\n\nFunction Render(x:Int = 0, y:Int = 0, s:Int = 1)\n\tglUseProgram(ProgramObj)\n\t\n\tglUniform3f(glGetUniformLocation(ProgramObj, \"cpos\"), camX, camY, camZ)\n\tglUniform2f(glGetUniformLocation(ProgramObj, \"crot\"), camP, camT)\n\tglUniform3f(glGetUniformLocation(ProgramObj, \"light\"), lightX, lightY, lightZ)\n\tglUniform1f(glGetUniformLocation(ProgramObj, \"eps\"), eps)\n\t\n\tglUniform1i(glGetUniformLocation(ProgramObj, \"itr\"), itr)\n\tglUniform1f(glGetUniformLocation(ProgramObj, \"scale\"), scale)\n\tglUniform3f(glGetUniformLocation(ProgramObj, \"offset\"), offsetX, offsetY, offsetZ)\n\tglUniform3f(glGetUniformLocation(ProgramObj, \"rotvec\"), rotvecX, rotvecY, rotvecZ)\n\tglUniform1f(glGetUniformLocation(ProgramObj, \"rotangel\"), rotangel)\n\t\n\t\n\tLocal w:Float = 2.0 * camZoom \/ Float(s), h:Float = GH \/ Float(GW)\n\tLocal vx:Float = x * w - camZoom, vy:Float = -camZoom * h\n\th = w * h\n\tvy = vy + y * h\n\t\n\tglBegin(GL_QUADS)\n\t\tglTexCoord2f(vx, vy) ;glVertex2i(0, 0)\n\t\tglTexCoord2f(vx + w, vy) ;glVertex2i(GW, 0)\n\t\tglTexCoord2f(vx + w, vy + h) ;glVertex2i(GW, GH)\n\t\tglTexCoord2f(vx, vy + h) ;glVertex2i(0, GH)\n\tglEnd\n\t\n\t\n\tglUseProgram(0)\nEnd Function\n\nFunction InitGL()\n\tGLGraphics GW, GH', 32, 60, 0\n\tSetGraphicsDriver(GLGraphicsDriver())\n\tglewInit()\n\t\n\tglMatrixMode(GL_PROJECTION)\n\tglLoadIdentity()\n\t\n\tglOrtho(0, GW, GH, 0, -1, 1)\n\t\n\tglMatrixMode(GL_MODELVIEW)\n\tglLoadIdentity()\nEnd Function\n\nFunction glCls()\n\tglClear GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT\nEnd Function\n\nFunction InitShaders()\n\tProgramObj = glCreateProgram()\n\tLocal VertexShdr:Int = glCreateShader(GL_VERTEX_SHADER_ARB)\n\tLocal FragmentShdr:Int = glCreateShader(GL_FRAGMENT_SHADER_ARB)\n\t\n\tLocal vsc:Byte Ptr = VERTEX_SHADER_CODE.ToCString()\n\tLocal vsl:Int = VERTEX_SHADER_CODE.Length\n\tLocal fsc:Byte Ptr = FRAGMENT_SHADER_CODE.ToCString()\n\tLocal fsl:Int = FRAGMENT_SHADER_CODE.Length\n\t\n\tglShaderSource(VertexShdr, 1, Varptr vsc, Varptr vsl)\n\t\tglShaderSource(FragmentShdr, 1, Varptr fsc, Varptr fsl)\n\t\n\t\tMemFree(vsc)\n\tMemFree(fsc)\n\t\n\tglCompileShader(VertexShdr) ;CheckForErrors(VertexShdr)\n\tglCompileShader(FragmentShdr) ;CheckForErrors(FragmentShdr)\n\t\n\tglAttachShader(ProgramObj, VertexShdr)\n\tglAttachShader(ProgramObj, FragmentShdr)\n\t\n\tglDeleteShader(VertexShdr)\n\tglDeleteShader(FragmentShdr)\n\t\n\tglLinkProgram(ProgramObj) ;CheckForErrors(ProgramObj)\nEnd Function\n\nFunction CheckForErrors(ShaderObject:Int)\n\tLocal ErrorLength:Int\n\t\n\tglGetShaderiv(ShaderObject, GL_OBJECT_INFO_LOG_LENGTH_ARB, Varptr ErrorLength)\n\t\n\tIf ErrorLength\n\t\tLocal Message:Byte[ErrorLength], Dummy:Int\n\t\t\n\t\tglGetShaderInfoLog(ShaderObject, ErrorLength, Varptr Dummy, Varptr Message[0])\n\t\t'SaveText(\"Shader object '\" + ShaderObject + \"':~n\" + Trim(StringFromCharArray(Message)), \"err.txt\")\n\t\tWriteStdout(\"Shader object '\" + ShaderObject + \"':~n\" + Trim(StringFromCharArray(Message)))\n\tEndIf\nEnd Function\n\nFunction StringFromCharArray:String(Array:Byte[])\n\tLocal Output:String\n\tFor Local I:Int = 0 To Array.Length - 1\n\t\tOutput:+Chr(Array[I])\n\tNext\n\t\n\tReturn Output\nEnd Function\n\n\nFunction SaveSceenshot(s:Int = 3, fn:String = \"\", compression:Int = 5, infosdtout:Int = 1)\n\tLocal cnt:Int\n\tLocal pm:TPixmap = CreatePixmap(GW * s, GH * s, PF_BGRA8888)\n\tLocal c:Byte Ptr = MemAlloc(3 * (GW + GW Mod 4) * (GH + GH Mod 4))\n\t\n\tFor Local x1:Int = 0 Until s\n\t\tIf infosdtout WriteStdout (x1 + 1) + \" of \" + s + \"~n\"\n\t\tFor Local y1:Int = 0 Until s\n\t\t\tRender(x1, y1, s)\n\t\t\tglReadPixels(0, 0, (GW + GW Mod 4), (GH + GH Mod 4), GL_RGB, GL_UNSIGNED_BYTE, c)\n\t\t\tcnt = 0\n\t\t\tFor Local y:Int = GH - 1 To 0 Step - 1\n\t\t\t\tFor Local x:Int = 0 Until GW\n\t\t\t\t\tWritePixel(pm, x1 * GW + x, y1 * GH + y, $ff000000 + $10000 * c[cnt] + $100 * c[cnt + 1] + c[cnt + 2])\n\t\t\t\t\tcnt:+3\n\t\t\t\tNext\n\t\t\t\tcnt:+3 * (GW Mod 4)\n\t\t\tNext\n\t\tNext\n\tNext\n\t\n\tIf infosdtout WriteStdout \"Saving...\"\n\tIf fn = \"\" Then fn = (MilliSecs()) + \".png\"\n\tSavePixmapPNG(pm, fn, compression)\n\tIf infosdtout WriteStdout \"Done.~n~n\"\nEnd Function\n\nFunction DrawHelp()\n\tGLDrawText \"cam =\" + camX + \", \" + camY + \", \" + camZ, 0, 0\n\tGLDrawText \"offset=\" + offsetX + \", \" + offsetY + \", \" + offsetZ, 0, 16\n\tGLDrawText \"rotvec=\" + rotvecX + \", \" + rotvecY + \", \" + rotvecZ, 0, 32\n\tGLDrawText \"rotang=\" + rotangel, 0, 48\n\tGLDrawText \"scale =\" + scale, 0, 64\n\tGLDrawText \"itr =\" + itr, 0, 80\n\tGLDrawText \"eps =\" + eps, 0, 96\nEnd Function\n\nFunction Catmul:Float(v0:Float, v1:Float, v2:Float, v3:Float, x:Float)\n\tLocal a0:Float, a1:Float, a2:Float, a3:Float, x2:Float\n\t\n\tx2 = x * x\n'\ta0 = -0.5 * v0 + 1.5 * v1 - 1.5 * v2 + 0.5 * v3\n'\ta1 = v0 - 2.5 * v1 + 2 * v2 - 0.5 * v3\n'\ta2 = -0.5 * v0 + 0.5 * v2\n'\ta3 = v1\n\ta0 = v3 - v2 - v0 + v1\n\ta1 = v0 - v1 - a0\n\ta2 = v2 - v0\n\ta3 = v1\n\t\n\tReturn a0 * x * x2 + a1 * x2 + a2 * x + a3\nEnd Function\n\nFunction Clip:Float(v1:Float, v2:Float, x:Float)\n\tReturn x * v2 + v1 * (1.0 - x)\nEnd Function\n\nType TAnimFrame\n\tGlobal list:TList = CreateList()\n\t\n\tField varlist:TList\n\t\n\tMethod New()\n\t\tvarlist = CreateList()\n\tEnd Method\n\t\n\tMethod Del()\n\t\tlist.Remove(Self)\n\tEnd Method\n\t\n\tFunction AddFrame:TAnimFrame(link:TLink = Null, modify:Int = 0)\n\t\tLocal t:TAnimFrame\n\t\tIf modify\n\t\t\tIf link = Null\n\t\t\t\tt = New TAnimFrame\n\t\t\t\tt.list.AddLast(t)\n\t\t\tElse\n\t\t\t\tt = TAnimFrame(link.Value())\n\t\t\tEnd If\n\t\tElse\n\t\t\tt = New TAnimFrame\n\t\t\tIf link = Null\n\t\t\t\tt.list.AddLast(t)\n\t\t\tElse\n\t\t\t\tt.list.InsertAfterLink(t, link)\n\t\t\tEnd If\n\t\tEnd If\n\t\t\n\t\tLocal timevar:Object = t.getVar(\"time\")\n\t\tIf timevar = Null\n\t\t\tt.setVar(\"time\", TFloat.N(1.0))\n\t\tElse\n\t\t\tt.setVar(\"time\", TFloat(timevar))\n\t\tEnd If\n\t\t\n\t\tt.setVar(\"camX\", TFloat.N(camX))\n\t\tt.setVar(\"camY\", TFloat.N(camY))\n\t\tt.setVar(\"camZ\", TFloat.N(camZ))\n\t\tt.setVar(\"camP\", TFloat.N(camP))\n\t\tt.setVar(\"camT\", TFloat.N(camT))\n\t\t\n\t\tt.setVar(\"camZoom\", TFloat.N(camZoom))\n\t\t\n\t\tt.setVar(\"lightX\", TFloat.N(lightX))\n\t\tt.setVar(\"lightY\", TFloat.N(lightY))\n\t\tt.setVar(\"lightZ\", TFloat.N(lightZ))\n\t\t\n\t\tt.setVar(\"eps\", TFloat.N(eps))\n\t\t\n\t\tt.setVar(\"itr\", TInt.N(itr))\n\t\t\n\t\tt.setVar(\"offsetX\", TFloat.N(offsetX))\n\t\tt.setVar(\"offsetY\", TFloat.N(offsetY))\n\t\tt.setVar(\"offsetZ\", TFloat.N(offsetZ))\n\t\tt.setVar(\"scale\", TFloat.N(scale))\n\t\tt.setVar(\"rotvecX\", TFloat.N(rotvecX))\n\t\tt.setVar(\"rotvecY\", TFloat.N(rotvecY))\n\t\tt.setVar(\"rotvecZ\", TFloat.N(rotvecZ))\n\t\tt.setVar(\"rotangel\", TFloat.N(rotangel))\n\t\t\n\t\tReturn t\n\tEnd Function\n\t\n\tMethod getVar:Object(name:String)\n\t\tFor Local t:TAnimFrameVar = EachIn varlist\n\t\t\tIf t.name = name\n\t\t\t\tReturn t.v\n\t\t\tEnd If\n\t\tNext\n\t\tReturn Null\n\tEnd Method\n\t\n\tMethod setVar(name:String, v:Object)\n\t\tFor Local t:TAnimFrameVar = EachIn varlist\n\t\t\tIf t.name = name\n\t\t\t\tt.v = v\n\t\t\t\tReturn\n\t\t\tEnd If\n\t\tNext\n\t\tLocal t:TAnimFrameVar = New TAnimFrameVar\n\t\tt.name = name\n\t\tt.v = v\n\t\tvarlist.AddLast(t)\n\t\tReturn\n\tEnd Method\n\t\n\tFunction PlayAnim(speed:Float)\n\t\tLocal f1:TAnimFrame, f1link:TLink\n\t\tLocal f2:TAnimFrame, f2link:TLink\n\t\tLocal time:Float\n\t\tLocal x:Float = 0\n\t\t\n\t\tf1 = TAnimFrame(f1.list.First())\n\t\tf1link = f1.list.FirstLink()\n\t\tIf f1link = Null Then Return\n\t\tf2link = f1link.NextLink()\n\t\tIf f2link = Null Then Return\n\t\tf2 = TAnimFrame(f2link.Value())\n\t\t\n\t\tWhile Not KeyHit(KEY_ESCAPE)\n\t\t\t\n\t\t\tsetGlobals(f1, f1link, f2, f2link, x)\n\t\t\t\n\t\t\tRender()\n\t\t\t\n\t\t\tIf disphelp DrawHelp()\n\t\t\t\n\t\t\ttime = Clip(TFloat(f1.getVar(\"time\")).v, ..\n\t\t\tTFloat(f2.getVar(\"time\")).v, x)\n\t\t\t\n\t\t\tx:+speed \/ time\n\t\t\tIf x >= 1\n\t\t\t\tf1link = f2link\n\t\t\t\tf1 = f2\n\t\t\t\tf2link = f1link.NextLink()\n\t\t\t\tIf f2link = Null Return\n\t\t\t\tf2 = TAnimFrame(f2link.Value())\n\t\t\t\tx = x - 1.0\n\t\t\tEnd If\n\t\t\t\n\t\t\tFlip 0\n\t\t\tglCls\n\t\t\tWaitTimer TIMER\n\t\tWend\n\tEnd Function\n\t\n\tFunction SaveAnim(speed:Float, folder:String, skip:Int = 0)\n\t\tLocal framenr:Int = 0\n\t\t\n\t\tCreateDir(folder)\n\t\t\n\t\tLocal f1:TAnimFrame, f1link:TLink\n\t\tLocal f2:TAnimFrame, f2link:TLink\n\t\tLocal time:Float\n\t\tLocal x:Float = 0\n\t\t\n\t\tf1 = TAnimFrame(f1.list.First())\n\t\tf1link = f1.list.FirstLink()\n\t\tIf f1link = Null Then Return\n\t\tf2link = f1link.NextLink()\n\t\tIf f2link = Null Then Return\n\t\tf2 = TAnimFrame(f2link.Value())\n\t\t\n\t\tWhile Not KeyHit(KEY_ESCAPE)\n\t\t\tsetGlobals(f1, f1link, f2, f2link, x)\n\t\t\t\n\t\t\tIf framenr >= skip\n\t\t\t\tSaveSceenshot(3, folder + \"\/\" + framenr + \".png\", 1, 0)\n\t\t\t\tPrint \"Frame Nr. \" + framenr\n\t\t\tEnd If\n\t\t\t\n\t\t\ttime = Clip(TFloat(f1.getVar(\"time\")).v, ..\n\t\t\tTFloat(f2.getVar(\"time\")).v, x)\n\t\t\t\n\t\t\tx:+speed \/ time\n\t\t\tIf x >= 1\n\t\t\t\tf1link = f2link\n\t\t\t\tf1 = f2\n\t\t\t\tf2link = f1link.NextLink()\n\t\t\t\tIf f2link = Null Then End\n\t\t\t\tf2 = TAnimFrame(f2link.Value())\n\t\t\t\tx = x - 1.0\n\t\t\tEnd If\n\t\t\t\n\t\t\t\n\t\t\tframenr:+1\n\t\t\t'Flip 0\n\t\t\t'glCls\n\t\t\t'WaitTimer TIMER\n\t\tWend\n\tEnd Function\n\t\n\tFunction setGlobals(f1:TAnimFrame, f1link:TLink, f2:TAnimFrame, f2link:TLink, x:Float)\n\t\tLocal f0:TAnimFrame, f3:TAnimFrame\n\t\tLocal f0link:TLink, f3link:TLink\n\t\t\n\t\tf0link = f1link.PrevLink()\n\t\tf3link = f2link.NextLink()\n\t\t\n\t\tIf f0link = Null Then f0link = f1link\n\t\tIf f3link = Null Then f3link = f2link\n\t\t\n\t\tf0 = TAnimFrame(f0link.Value())\n\t\tf3 = TAnimFrame(f3link.Value())\n\t\t\n\t\t\n\t\tcamX = Catmul(TFloat(f0.getVar(\"camX\")).v, ..\n\t\tTFloat(f1.getVar(\"camX\")).v, ..\n\t\tTFloat(f2.getVar(\"camX\")).v, ..\n\t\tTFloat(f3.getVar(\"camX\")).v, x)\n\t\t \n\t\tcamY = Catmul(TFloat(f0.getVar(\"camY\")).v, ..\n\t\tTFloat(f1.getVar(\"camY\")).v, ..\n\t\tTFloat(f2.getVar(\"camY\")).v, ..\n\t\tTFloat(f3.getVar(\"camY\")).v, x)\n\t\t\n\t\tcamZ = Catmul(TFloat(f0.getVar(\"camZ\")).v, ..\n\t\tTFloat(f1.getVar(\"camZ\")).v, ..\n\t\tTFloat(f2.getVar(\"camZ\")).v, ..\n\t\tTFloat(f3.getVar(\"camZ\")).v, x)\n\t\t\n\t\tcamP = Catmul(TFloat(f0.getVar(\"camP\")).v, ..\n\t\tTFloat(f1.getVar(\"camP\")).v, ..\n\t\tTFloat(f2.getVar(\"camP\")).v, ..\n\t\tTFloat(f3.getVar(\"camP\")).v, x)\n\t\t\n\t\tcamT = Catmul(TFloat(f0.getVar(\"camT\")).v, ..\n\t\tTFloat(f1.getVar(\"camT\")).v, ..\n\t\tTFloat(f2.getVar(\"camT\")).v, ..\n\t\tTFloat(f3.getVar(\"camT\")).v, x)\n\t\t\n\t\tcamZoom = Catmul(TFloat(f0.getVar(\"camZoom\")).v, ..\n\t\tTFloat(f1.getVar(\"camZoom\")).v, ..\n\t\tTFloat(f2.getVar(\"camZoom\")).v, ..\n\t\tTFloat(f3.getVar(\"camZoom\")).v, x)\n\t\t\n\t\t\n\t\tlightX = Catmul(TFloat(f0.getVar(\"lightX\")).v, ..\n\t\tTFloat(f1.getVar(\"lightX\")).v, ..\n\t\tTFloat(f2.getVar(\"lightX\")).v, ..\n\t\tTFloat(f3.getVar(\"lightX\")).v, x)\n\t\t \n\t\tlightY = Catmul(TFloat(f0.getVar(\"lightY\")).v, ..\n\t\tTFloat(f1.getVar(\"lightY\")).v, ..\n\t\tTFloat(f2.getVar(\"lightY\")).v, ..\n\t\tTFloat(f3.getVar(\"lightY\")).v, x)\n\t\t\n\t\tlightZ = Catmul(TFloat(f0.getVar(\"lightZ\")).v, ..\n\t\tTFloat(f1.getVar(\"lightZ\")).v, ..\n\t\tTFloat(f2.getVar(\"lightZ\")).v, ..\n\t\tTFloat(f3.getVar(\"lightZ\")).v, x)\n\t\t\n\t\t\n\t\teps = Clip(TFloat(f1.getVar(\"eps\")).v, ..\n\t\tTFloat(f2.getVar(\"eps\")).v, x)\n\t\t\n\t\titr = Clip(TInt(f1.getVar(\"itr\")).v, ..\n\t\tTInt(f2.getVar(\"itr\")).v, x)\n\t\t\n\t\t\n\t\toffsetX = Clip(TFloat(f1.getVar(\"offsetX\")).v, ..\n\t\tTFloat(f2.getVar(\"offsetX\")).v, x)\n\t\t\n\t\toffsetY = Clip(TFloat(f1.getVar(\"offsetY\")).v, ..\n\t\tTFloat(f2.getVar(\"offsetY\")).v, x)\n\t\t\n\t\toffsetZ = Clip(TFloat(f1.getVar(\"offsetZ\")).v, ..\n\t\tTFloat(f2.getVar(\"offsetZ\")).v, x)\n\t\t\n\t\tscale = Catmul(TFloat(f0.getVar(\"scale\")).v, ..\n\t\tTFloat(f1.getVar(\"scale\")).v, ..\n\t\tTFloat(f2.getVar(\"scale\")).v, ..\n\t\tTFloat(f3.getVar(\"scale\")).v, x)\n\t\t\n\t\trotvecX = Clip(TFloat(f1.getVar(\"rotvecX\")).v, ..\n\t\tTFloat(f2.getVar(\"rotvecX\")).v, x)\n\t\t\n\t\trotvecY = Clip(TFloat(f1.getVar(\"rotvecY\")).v, ..\n\t\tTFloat(f2.getVar(\"rotvecY\")).v, x)\n\t\t\n\t\trotvecZ = Clip(TFloat(f1.getVar(\"rotvecZ\")).v, ..\n\t\tTFloat(f2.getVar(\"rotvecZ\")).v, x)\n\t\t\n\t\trotangel = Catmul(TFloat(f0.getVar(\"rotangel\")).v, ..\n\t\tTFloat(f1.getVar(\"rotangel\")).v, ..\n\t\tTFloat(f2.getVar(\"rotangel\")).v, ..\n\t\tTFloat(f3.getVar(\"rotangel\")).v, x)\n\t\t\n\tEnd Function\n\t\n\tMethod setGlobalsToFrame()\n\t\tcamX = TFloat(getVar(\"camX\")).v\n\t\tcamY = TFloat(getVar(\"camY\")).v\n\t\tcamZ = TFloat(getVar(\"camZ\")).v\n\t\tcamP = TFloat(getVar(\"camP\")).v\n\t\tcamT = TFloat(getVar(\"camT\")).v\n\t\tcamZoom = TFloat(getVar(\"camZoom\")).v\n\t\t\n\t\tlightX = TFloat(getVar(\"lightX\")).v\n\t\tlightY = TFloat(getVar(\"lightY\")).v\n\t\tlightZ = TFloat(getVar(\"lightZ\")).v\n\t\t\n\t\teps = TFloat(getVar(\"eps\")).v\n\t\titr = TInt(getVar(\"itr\")).v\n\t\t\n\t\toffsetX = TFloat(getVar(\"offsetX\")).v\n\t\toffsetY = TFloat(getVar(\"offsetY\")).v\n\t\toffsetZ = TFloat(getVar(\"offsetZ\")).v\n\t\tscale = TFloat(getVar(\"scale\")).v\n\t\trotvecX = TFloat(getVar(\"rotvecX\")).v\n\t\trotvecY = TFloat(getVar(\"rotvecY\")).v\n\t\trotvecZ = TFloat(getVar(\"rotvecZ\")).v\n\t\trotangel = TFloat(getVar(\"rotangel\")).v\n\tEnd Method\n\t\n\tFunction SaveToFile(filename:String)\n\t\tLocal f:TStream = WriteFile(filename)\n\t\tFor Local t:TAnimFrame = EachIn TAnimFrame.list\n\t\t\tf.WriteLine \"{\"\n\t\t\tFor Local v:TAnimFrameVar = EachIn t.varlist\n\t\t\t\tIf TFloat(v.v) <> Null\n\t\t\t\t\tf.WriteLine \"~t\" + v.name + \" = \" + TFloat(v.v).v + \"f;\"\n\t\t\t\tElse If TInt(v.v) <> Null\n\t\t\t\t\tf.WriteLine \"~t\" + v.name + \" = \" + TInt(v.v).v + \"i;\"\n\t\t\t\tElse If TDouble(v.v) <> Null\n\t\t\t\t\tf.WriteLine \"~t\" + v.name + \" = \" + TDouble(v.v).v + \"d;\"\n\t\t\t\tEnd If\n\t\t\tNext\n\t\t\tf.WriteLine \"}\"\n\t\tNext\n\t\tf.Close\n\tEnd Function\n\t\n\tFunction LoadFromFile(file:String)\n\t\tIf FileType(file) = 1\n\t\t\tfile = LoadText(file)\n\t\t\tfile = Replace(file, \" \", \"\")\n\t\t\tfile = Replace(file, Chr(9), \"\")\n\t\t\tfile = Replace(file, Chr(10), \"\")\n\t\t\tfile = Replace(file, Chr(13), \"\")\n\t\t\t\n\t\t\tLocal gs:Int = 1, ge:Int = 0, content:String\n\t\t\t\n\t\t\tWhile ge < Len(file)\n\t\t\t\tgs = Instr(file, \"{\", ge)\n\t\t\t\tge = Instr(file, \"}\", gs + 1)\n\t\t\t\tcontent = Mid(file, gs + 1, ge - gs - 1)\n\t\t\t\t\n\t\t\t\tLocal cs:Int = 1, ce:Int = 0, eq:Int\n\t\t\t\tLocal name:String, value:String, dt:String\n\t\t\t\t\n\t\t\t\tLocal t:TAnimFrame = New TAnimFrame\n\t\t\t\tt.list.AddLast(t)\n\t\t\t\t\n\t\t\t\tWhile ce < Len(content)\n\t\t\t\t\tce = Instr(content, \";\", cs)\n\t\t\t\t\tvalue = Mid(content, cs, ce - cs)\n\t\t\t\t\teq = Instr(value, \"=\")\n\t\t\t\t\t\n\t\t\t\t\tname = Left(value, eq - 1)\n\t\t\t\t\tdt = Right(value, 1)\n\t\t\t\t\tvalue = Mid(Left(value, value.Length - 1), eq + 1)\n\t\t\t\t\t\n\t\t\t\t\tSelect dt\n\t\t\t\t\t\tCase \"f\"\n\t\t\t\t\t\t\tt.setVar(name, TFloat.N(value.ToFloat()))\n\t\t\t\t\t\tCase \"i\"\n\t\t\t\t\t\t\tt.setVar(name, TInt.N(value.ToInt()))\n\t\t\t\t\t\tCase \"d\"\n\t\t\t\t\t\t\tt.setVar(name, TDouble.N(value.ToDouble()))\n\t\t\t\t\tEnd Select\n\t\t\t\t\t\n\t\t\t\t\tcs = ce + 1\n\t\t\t\tWend\n\t\t\t\t\n\t\t\tWend\n\t\tElse\n\t\t\tRuntimeError(\"File does not exist!\")\n\t\tEnd If\n\tEnd Function\n\t\nEnd Type\n\nType TAnimFrameVar\n\tField name:String\n\tField v:Object\nEnd Type\n\nType TInt\n\tField v:Int\n\tFunction N:TInt(v:Int)\n\t\tLocal t:TInt = New TInt\n\t\tt.v = v\n\t\tReturn t\n\tEnd Function\nEnd Type\n\nType TFloat\n\tField v:Float\n\tFunction N:TFloat(v:Float)\n\t\tLocal t:TFloat = New TFloat\n\t\tt.v = v\n\t\tReturn t\n\tEnd Function\nEnd Type\n\nType TDouble\n\tField v:Double\n\tFunction N:TDouble(v:Double)\n\t\tLocal t:TDouble = New TDouble\n\t\tt.v = v\n\t\tReturn t\n\tEnd Function\nEnd Type\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'KIFS\/KIFS.bmx' did not match any file(s) known to git\n","license":"mit","lang":"BlitzMax"} {"commit":"86acd642e726b667ccb3be56e8191cdc9ff0fe2a","subject":"Added start of gile[s] loader.","message":"Added start of gile[s] loader.\n","repos":"kfprimm\/maxb3d,kfprimm\/maxb3d","old_file":"glsloader.mod\/glsloader.bmx","new_file":"glsloader.mod\/glsloader.bmx","new_contents":"\nStrict\n\nRem\n\tbbdoc: Gile[s] mesh loader\nEnd Rem\nModule MaxB3D.GLSLoader\nModuleInfo \"Author: Kevin Primm\"\nModuleInfo \"License: MIT\"\n\nImport MaxB3D.Core\nImport Prime.LibGLS\n\n\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'glsloader.mod\/glsloader.bmx' did not match any file(s) known to git\n","license":"mit","lang":"BlitzMax"} {"commit":"43f50276dd76082aa9aba6655e02a0f2b5089d71","subject":"Added BlitzMax (MonkeyMax) native file","message":"Added BlitzMax (MonkeyMax) native file\n","repos":"programmerby\/diddy-mirror,programmerby\/diddy-mirror,programmerby\/diddy-mirror,programmerby\/diddy-mirror","old_file":"src\/diddy\/native\/diddy.bmax.bmx","new_file":"src\/diddy\/native\/diddy.bmax.bmx","new_contents":"' ***** Start diddy.bmax.bmx ******\r\nGlobal diddy_mouseWheel:Float = 0.0\r\n\r\nType diddy\r\n\tFunction systemMillisecs:Float()\r\n\t\tReturn Millisecs()\r\n\tEndFunction\r\n\t\r\n\tFunction setGraphics(w:int, h:int, fullScreen:Int = False)\r\n\t\tlocal d% = 0\r\n\t\tif fullScreen then d = 32\r\n\t\tGraphics w, h, d, 60\r\n\tEndFunction\r\n\t\r\n\tFunction setMouse(x:Int, y:Int)\r\n\t\tMoveMouse(x, y)\r\n\tEndFunction\r\n\t\r\n\tFunction showKeyboard()\r\n\tEndFunction\r\n\t\r\n\tFunction launchBrowser(address:String, windowName:String)\r\n\tEndFunction\r\n\t\r\n\tFunction launchEmail(email:String, subject:String, text:String)\r\n\tEndFunction\r\n\t\r\n\tFunction realMod:Float( value:Float, amount:Float )\r\n\t\tReturn value Mod amount\r\n\tEndFunction\r\n\t\r\n\tFunction startVibrate(millisecs:int)\r\n\tEndFunction\r\n\t\r\n\tFunction stopVibrate()\r\n\tEndFunction\r\n\t\r\n\tFunction getDayOfMonth:Int()\r\n\t\tLocal date$ = CurrentDate()\r\n\t\tReturn Int(date[..2])\r\n\tEndFunction\r\n\t\r\n\tFunction getDayOfWeek:Int()\r\n\t\tReturn 0\r\n\tEndFunction\r\n\t\r\n\tFunction getMonth:Int()\r\n\t\tLocal date$ = CurrentDate()\r\n\t\tReturn (Instr(\"JANFEBMARAPRMAYJUNJULAUGSEPOCTNOVDEC\", date$[3..6].ToUpper(), 1) \/ 3) + 1\r\n\tEndFunction\r\n\t\r\n\tFunction getYear:Int()\r\n\t\tLocal date$ = CurrentDate()\r\n\t\tReturn Int(date[date.length - 4..]);\r\n\tEndFunction\r\n\t\r\n\tFunction getHours:Int()\r\n\t\tLocal time$ = CurrentTime()\r\n\t\tReturn Int(time[..2])\r\n\tEndFunction\r\n\t\r\n\tFunction getMinutes:Int()\r\n\t\tLocal time$ = CurrentTime()\r\n\t\tReturn Int(time[3..5])\r\n\tEndFunction\r\n\t\r\n\tFunction getSeconds:Int()\r\n\t\tLocal time$ = CurrentTime()\r\n\t\tReturn Int(time[6..8])\r\n\tEndFunction\r\n\t\r\n\tFunction getMilliSeconds:Int()\r\n\t\tReturn Millisecs()\r\n\tEndFunction\r\n\t\r\n\tFunction startGps()\r\n\tEndFunction\r\n\t\r\n\tFunction getLatitiude:String()\r\n\t\tReturn \"\"\r\n\tEndFunction\r\n\t\r\n\tFunction getLongitude:String()\r\n\t\tReturn \"\"\r\n\tEndFunction\r\n\r\n\tFunction showAlertDialog(title:String, message:String)\r\n\tEndFunction\r\n\t\r\n\tFunction getInputString:String()\r\n\t\tReturn \"\";\r\n\tEndFunction\r\n\t\r\n\tFunction getPixel:Int( x:int, y:int )\r\n'\t\tunsigned char pix[4];\r\n'\t\tglReadPixels(x, app->graphics->height-y ,1 ,1 ,GL_RGBA ,GL_UNSIGNED_BYTE ,pix);\r\n'\t\treturn (pix[3]<<24) | (pix[0]<<16) | (pix[1]<<8) | pix[2];\r\n\t\tReturn 0\r\n\tEndFunction\r\n\t\r\n\tFunction mouseZInit()\r\n\tEndFunction\r\n\r\n\tFunction mouseZ:Float()\r\n\t\tLocal ret:Float = BlitzMaxMouseZ() - diddy_mouseWheel\r\n\t\tdiddy_mouseWheel = BlitzMaxMouseZ()\r\n\t\tReturn ret\r\n\tEndFunction\r\nEndType\r\n\r\nFunction BlitzMaxMouseZ:Float()\r\n\tReturn MouseZ()\r\nEndFunction\r\n\r\n' ***** End diddy.bmax.bmx ******\r\n\r\n\r\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'src\/diddy\/native\/diddy.bmax.bmx' did not match any file(s) known to git\n","license":"mit","lang":"BlitzMax"} {"commit":"2c526b7ada7253d7ea35e43f96a620ff6c3fb160","subject":"...","message":"...\n\nno idea why git thinks this is a change\n","repos":"Leushenko\/blue-moon","old_file":"blue.bmx","new_file":"blue.bmx","new_contents":"\n' Blue Moon\n' an implementation of Lua in pure BlitzMax\n\nSuperStrict\n\n'Framework Brl.Blitz\n'Import Brl.LinkedList\n'Import Brl.Map\n'Import Brl.Reflection\n\nImport \"bluecompiler.bmx\"\nImport \"bluevm.bmx\"\n\n'Const file:String = \"tests\/checktable.lua\"\n'Const file:String = \"tests\/mandelbrot.lua\"\n'Const file:String = \"tests\/sieve.lua\"\n'Const file:String = \"tests\/attrib.lua\"\nConst file:String = \"test1.lua\"\n\nConst outFile:String = \"out.lua.so\"\n\n\nPrint BlueCompiler.ShowBytecode(file)\n\nLocal code:BlueBinary = BlueCompiler.CompileFileForLoad(file)\nLocal vm:BlueVM = New BlueVM\nLocal tl:BlueLuaVal = vm.LoadObjectCode(code)\n\nLocal stk:Stack = BlueJIT.BPtoS(vm.mem.stack)\nstk.retIP = Null ; stk.prevBase = Null\nLocal vc:Int = 10, upvars:Int = 1\nstk.varp = Long Ptr(Byte Ptr(stk) + BlueJIT.STACKFRAME_INC) + upvars\nstk.func = vm.funIndex[0]\nstk.argv = Null\t'may want to add space?\nstk.retv = Null\nstk.argc = 0\nstk.retc = 0\n\nFunction lpr:Int(vm:BlueVM, argc:Int, argv:Long Ptr, retv:Long Ptr)\n\tPrint vm.mem.ValToMaxString(argv[0])\n\tReturn 0\nEnd Function\nFunction addtri:Int(vm:BlueVM, argc:Int, argv:Long Ptr, retv:Long Ptr)\n\tDouble Ptr(retv)[0] = Double Ptr(argv)[0] + Double Ptr(argv)[1] + Double Ptr(argv)[2]\n\tReturn 1\nEnd Function\nFunction ret3:Int(vm:BlueVM, argc:Int, argv:Long Ptr, retv:Long Ptr)\n\tDouble Ptr(retv)[0] = 21\n\tDouble Ptr(retv)[1] = 23\n\tDouble Ptr(retv)[2] = 25\n\tReturn 3\nEnd Function\nvm._ENV.Set(\"pr\", vm.ValueFromFunction(lpr))\nvm._ENV.Set(\"quux\", vm.ValueFromNumber(7.5))\nvm._ENV.Set(\"addtriple\", vm.ValueFromFunction(addtri))\nvm._ENV.Set(\"ret3\", vm.ValueFromFunction(ret3))\n\nPrint \"running...\"\nLocal t:Int = MilliSecs()\nLocal test:Int(_:Byte Ptr) = stk.func.mcode - BlueJIT.PROLOGUESZ ; test(stk)\nt = MilliSecs() - t\nPrint t\nPrint \"run complete\"\n\n\nPrint \"done.\"\nEnd\n\n\nRem\nLocal files:TList = CreateList()\nLocal as:String, ld:String, showHelp:Int, output:String = \"a.out\", doAssemble:Int = 1\nLocal keepAsm:Int, makeExe:Int = 1, asOpts:String, ldOpts:String, showAST:Int, showVersion:Int\n\n?MacOS\nas = \"clang -m32 -c \" ; ld = \"clang -Wl,-no_pie -m32 -read_only_relocs suppress \"\n?Not MacOS\nas = \"gcc -m32 -c \" ; ld = \"gcc -m32 \"\n?\n\nFor Local a:Int = 1 Until AppArgs.Length\n\tSelect AppArgs[a]\n\t\tCase \"-?\", \"--help\"\n\t\t\tshowHelp = 1\n\t\tCase \"-v\"\n\t\t\tshowVersion = 1\n\t\tCase \"-o\"\n\t\t\tIf makeExe = 0\n\t\t\t\tPrint \"warning: -c and -o are mutually exclusive; -c is overruling -o\"\n\t\t\tElse\n\t\t\t\ta :+ 1 ; output = AppArgs[a] ; makeExe = 2\n\t\t\tEndIf\n\t\tCase \"-c\"\n\t\t\tIf makeExe = 2\n\t\t\t\tPrint \"warning: -o and -c are mutually exclusive; -o is overruling -c\"\n\t\t\tElse\n\t\t\t\tdoAssemble = 1 ; makeExe = 0\n\t\t\tEndIf\n\t\tCase \"-s\"\n\t\t\tkeepAsm = 1\n\t\tCase \"-S\"\n\t\t\tkeepAsm = 1 ; doAssemble = 0 ; makeExe = 0\n\t\tCase \"--as\"\n\t\t\ta :+ 1 ; as = AppArgs[a] + \" \"\n\t\tCase \"--ld\"\n\t\t\ta :+ 1 ; ld = AppArgs[a] + \" \"\n\t\tCase \"--as-opt\"\n\t\t\ta :+ 1 ; asOpts :+ AppArgs[a] + \" \"\n\t\tCase \"--ld-opt\"\n\t\t\ta :+ 1 ; ldOpts :+ AppArgs[a] + \" \"\n\t\tCase \"--tree\"\n\t\t\tshowAST = 1 ; makeExe = 0\n\t\tCase \"-w\" ; YBCodeGen.SetWarningLevel 0\n\t\tCase \"--werr\" ; YBCodeGen.SetWarningLevel 2\n\t\tCase \"--warn\" ; YBCodeGen.SetWarningLevel 1\n\t\tDefault\n\t\t\tfiles.AddLast AppArgs[a]\n\tEnd Select\nNext\nIf AppArgs.Length = 1 Then Print \"ybc: no input files\" ; End\n\nIf showVersion Then DisplayVersion\nIf showHelp Then DisplayHelp\n\n?Win32\nLocal rm:String = \"del \/Q \"\n?Not Win32\nLocal rm:String = \"rm \"\n?\n\nLocal allOFiles:String = \"\"\nFor Local file:String = EachIn files\n\tTry\n\t\tLocal tree:TParseNode = YBParseFile(file)\n\t\tIf showAST\n\t\t\tPrint tree.ToString()\n\t\tElse\n\t\t\tYBCodeGen.Build tree\n\t\t\tYBAssembler.Emit file + \".s\", YBCodeGen.syms, YBCodeGen.funs, YBCodeGen.vars, YBCodeGen.strs\n\t\t\tIf doAssemble\n\t\t\t\tsystem_(as + asOpts + file + \".s -o \" + file + \".o\")\n\t\t\t\tallOFiles :+ file + \".o \"\n\t\t\tEndIf\n\t\t\tIf Not keepAsm\n\t\t\t\tsystem_ rm + file + \".s\"\n\t\t\tEndIf\n\t\tEndIf\n\tCatch e:Object\n\t\tPrint \"Compile error:~n \" + e.ToString()\n\t\tPrint \"Compilation halted.\"\n\t\t?Debug\n\t\tThrow e\n\t\t?\n\t\tEnd\n\tEnd Try\nNext\n\n?Linux\nLocal bLib:String = \"b-lib-linux\"\n?Not Linux\nLocal bLib:String = \"b-lib\"\n?\nIf makeExe\n\tIf Not FileType(\"b-lib.o\") Then system_ as + bLib + \".s -o b-lib.o\"\n\tsystem_(ld + ldOpts + \"-o \" + output + \" \" + allOFiles + \" b-lib.o\")\n\tsystem_(rm + allOFiles)\nEndIf\n\nPrint \"done.\"\nEnd\nEnd Rem\nRem\nFunction DisplayVersion()\n\tPrint \"Shadow SIMD Compiler: version 0.0\"\nEnd Function\n\nFunction DisplayHelp()\n\tPrint \"OVERVIEW: ybc compiler for B~n\"\n\tPrint \"USAGE: ybc [options] ~n\"\n\tPrint \"OPTIONS:~n\"\n\tPrint \" -?, --help Display this message\"\n\tPrint \" -v Show the compiler version\"\n\tPrint \" -o Set the name of the output executable (default 'a.out')\"\n\tPrint \" -c Produce separate .o files instead of an executable\"\n\tPrint \" -s Keep text assembly .s files\"\n\tPrint \" -S Only produce text assembly, do not assemble binaries\"\n\tPrint \" --as Set the command to use as the assembler\"\n\tPrint \" --ld Set the command to use as the linker\"\n\tPrint \" --as-opt Add an option to pass to the assembler (can repeat)\"\n\tPrint \" --ld-opt Add an option to pass to the linker (can repeat)\"\n\tPrint \" --tree Display the AST of the program source instead of compiling\"\n\tPrint \" -w Silence warnings\"\n\tPrint \" --werr Convert warnings to errors\"\n\tPrint \" --warn Notify but do not halt on warnings (default)\"\nEnd Function\nEnd Rem\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'blue.bmx' did not match any file(s) known to git\n","license":"mit","lang":"BlitzMax"} {"commit":"32306583146427baeb2c352f75121df32a045320","subject":"Forgot to add new test file","message":"Forgot to add new test file\n\nrefs gh-115\n","repos":"maximos\/maximus-web,maximos\/maximus-web,maximos\/maximus-web","old_file":"t\/data\/test.mod1\/inc\/include.bmx","new_file":"t\/data\/test.mod1\/inc\/include.bmx","new_contents":"'For testing if including from another directory works\n","old_contents":"","returncode":1,"stderr":"error: pathspec 't\/data\/test.mod1\/inc\/include.bmx' did not match any file(s) known to git\n","license":"mit","lang":"BlitzMax"} {"commit":"c1ce330f9a787080bb33d2e9600d1eeba07bd087","subject":"Added mak collide sample.","message":"Added mak collide sample.\n","repos":"kfprimm\/maxb3d,kfprimm\/maxb3d","old_file":"doc\/samples\/mak\/collide.bmx","new_file":"doc\/samples\/mak\/collide.bmx","new_contents":"\nStrict\n\nImport MaxB3D.Drivers\n\nConst T_DUDE=1,T_WALLS=2\n\nType TDude\n\tField mesh:TMesh\n\tField speed#\nEnd Type\n\nConst DUDE_COUNT = 50\n\nGraphics 800,600\n\nSetCollisions T_DUDE,T_DUDE,COLLISION_METHOD_POLYGON,COLLISION_RESPONSE_SLIDE\nSetCollisions T_DUDE,T_WALLS,COLLISION_METHOD_POLYGON,COLLISION_RESPONSE_SLIDE\n\nLocal walls:TMesh=CreateCube()\nSetEntityColor walls,0,32,192\nSetEntityType walls,T_WALLS\nFitMesh walls,-40,0,-40,80,80,80\nFlipMesh walls\n\nLocal col:TMesh=CreateCube()\nFitMesh col,-1,0,-1,2,40,2\nSetEntityColor col,255,0,0\nSetEntityAlpha col,.75\nSetEntityType col,T_WALLS\nFor Local k=30 To 359+30 Step 60\n\tLocal t:TEntity=CopyEntity( col )\n\tSetEntityRotation t,0,k,0\n\tMoveEntity t,0,0,34\nNext\nFreeEntity col\n\nLocal camera:TCamera=CreateCamera()\nSetEntityPosition camera,0,50,-46\nTurnEntity camera,45,0,0\n\nLocal light:TLight=CreateLight()\nTurnEntity light,45,45,0\n\nLocal player:TMesh=CreateCube()\nSetEntityColor player,0,255,0\nSetEntityPosition player,0,3,0\nSetEntityRadius player,2\nSetEntityType player,T_DUDE\n\nLocal nose:TMesh=CreateCube( player )\nSetEntityColor nose,0,255,0\nSetEntityScale nose,.5,.5,.5\nSetEntityPosition nose,0,0,1.5\n\nRem\nsphere=CreateSphere()\nEntityShininess sphere,.5\nEntityType sphere,T_DUDE\n\nan#=0\nan_step#=360.0\/n_dudes\n\nFor k=1 To n_dudes\n\td.Dude=New Dude\n\td\\entity=CopyEntity( sphere )\n\tEntityColor d\\entity,Rnd(255),Rnd(255),Rnd(255)\n\tTurnEntity d\\entity,0,an,0\n\tMoveEntity d\\entity,0,2,37\n\tResetEntity d\\entity\n\td\\speed=Rnd( .4,.49 )\n\tan=an+an_step\nNext\n\nFreeEntity sphere\n\nok=True\t\n\nEnd Rem\n\nWhile Not KeyHit(KEY_ESCAPE) And Not AppTerminate()\n\tIf KeyDown(KEY_LEFT) TurnEntity player,0,5,0\n\tIf KeyDown(KEY_RIGHT) TurnEntity player,0,-5,0\n\tIf KeyDown(KEY_UP) MoveEntity player,0,0,.5\n\tIf KeyDown(KEY_DOWN) MoveEntity player,0,0,-.5\n\tIf KeyDown(KEY_A) TranslateEntity player,0,.2,0\n\tIf KeyDown(KEY_Z) TranslateEntity player,0,-.2,0\n\t\n\tRem\n\tFor d.Dude=Each Dude\n\t\tIf EntityDistance( player,d\\entity )>2\n\t\t\tPointEntity d\\entity,player\n\t\t\tIf KeyDown(15) TurnEntity d\\entity,0,180,0\n\t\tEndIf\n\t\tMoveEntity d\\entity,0,0,d\\speed\n\tNext\n\tEnd Rem\n\tUpdateWorld\n\tRenderWorld\n\t\n\tRem\n\tGoto skip\n\tIf ok\n\t\t'\n\t\t'sanity check!\n\t\t'make sure nothings gone through anything else...\n\t\t'\n\t\tFor d=Each Dude\n\t\t\tIf EntityY( d\\entity )<.9\n\t\t\t\tok=False\n\t\t\t\tbad$=\"Bad Dude Y: \"+EntityY( d\\entity )\n\t\t\tEndIf\n\t\t\tFor d2.Dude=Each Dude\n\t\t\t\tIf d=d2 Then Exit\n\t\t\t\tIf EntityDistance( d\\entity,d2\\entity )<.9\n\t\t\t\t\tok=False\n\t\t\t\t\tbad$=\"Dude overlap!\"\n\t\t\t\tEndIf\n\t\t\tNext\n\t\tNext\n\tEndIf\n\t\n\tIf ok\n\t\tText 0,0,\"Dudes OK\"\n\tElse\n\t\tCameraClsColor camera,255,0,0\n\t\tText 0,0,bad$\n\tEndIf\n\t.skip\n\tEnd Rem\n\t\n\tFlip\nWend\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'doc\/samples\/mak\/collide.bmx' did not match any file(s) known to git\n","license":"mit","lang":"BlitzMax"}