* Work arounds for Visual Studio bugs gscript

Sun, 29 Mar 2015 15:14:31 +0300

author
cemkalyoncu
date
Sun, 29 Mar 2015 15:14:31 +0300
branch
gscript
changeset 668
ae70f10f79fb
parent 667
4736255adde1
child 669
6a6aa7868741

* Work arounds for Visual Studio bugs

.hgignore file | annotate | diff | comparison | revisions
Source/Scripting/Builtin.cpp file | annotate | diff | comparison | revisions
Source/Scripting/Compilers/IL.cpp file | annotate | diff | comparison | revisions
Source/Scripting/Data.h file | annotate | diff | comparison | revisions
Source/Scripting/Reflection.h file | annotate | diff | comparison | revisions
Source/Scripting/Scope.cpp file | annotate | diff | comparison | revisions
Testing/Source/Unit/Scripting.cpp file | annotate | diff | comparison | revisions
--- a/.hgignore	Wed Mar 25 15:19:52 2015 +0200
+++ b/.hgignore	Sun Mar 29 15:14:31 2015 +0300
@@ -1,4 +1,6 @@
 Build
+build
+VSBuild
 Debug
 Lib
 Bin
--- a/Source/Scripting/Builtin.cpp	Wed Mar 25 15:19:52 2015 +0200
+++ b/Source/Scripting/Builtin.cpp	Sun Mar 29 15:14:31 2015 +0300
@@ -224,7 +224,7 @@
 					)
 				})
 			});
-			
+
 			Bool->AddConstructors({
 				Map_Typecast<Gorgon::Byte, bool>(Byte, Bool),
 				Map_Typecast<unsigned, bool>(Unsigned, Bool),
--- a/Source/Scripting/Compilers/IL.cpp	Wed Mar 25 15:19:52 2015 +0200
+++ b/Source/Scripting/Compilers/IL.cpp	Sun Mar 29 15:14:31 2015 +0300
@@ -1,7 +1,7 @@
 #include "../Compilers.h"
 #include "Utils.h"
 #include "../../Scripting.h"
-
+
 #pragma warning(disable:4018)
 
 namespace Gorgon { namespace Scripting { namespace Compilers {
@@ -171,7 +171,7 @@
 				List.resize(List.size()+1);
 				auto &inst=List.back();
 				inst.Type  = InstructionType::RemoveTemp;
-				inst.Store = parsetemporary(input, ch);
+				inst.Store = Byte(parsetemporary(input, ch));
 				ret=1;
 				break;
 			}
@@ -199,7 +199,7 @@
 		fncall(input, ch, false);
 
 		auto &inst=List.back();
-		inst.Store=temp;
+		inst.Store=Byte(temp);
 	}
 	
 	void Intermediate::fncall(const std::string& input, int &ch, bool allowmethod) {
--- a/Source/Scripting/Data.h	Wed Mar 25 15:19:52 2015 +0200
+++ b/Source/Scripting/Data.h	Sun Mar 29 15:14:31 2015 +0300
@@ -25,6 +25,10 @@
 			/// therefore, use of this function should be very limited.
 			static Data Invalid() { return {}; }
 
+			/// Constructs an invalid data. Performing any operation on this data might cause
+			/// crashes. Never use this constructor unless its absolutely necessary
+			Data() {}
+
 			/// Copy constructor
 			Data(const Data &other);
 
@@ -121,9 +125,6 @@
 			
 			
 		private:
-			/// Constructs an invalid data. Performing any operation on this data might cause
-			/// crashes. Never use this constructor unless its absolutely necessary
-			Data() {}
 			
 			void check();
 		};
--- a/Source/Scripting/Reflection.h	Wed Mar 25 15:19:52 2015 +0200
+++ b/Source/Scripting/Reflection.h	Sun Mar 29 15:14:31 2015 +0300
@@ -30,8 +30,7 @@
 			
 			/// Marks the object as a reference. When this tag affects types, it marks the
 			/// type as a reference type, meaning it will always be moved around as a reference.
-			/// When this tag affects parameters or variables, object becomes a reference to the
-			/// parameter
+			/// When this tag affects parameters, object becomes a reference to the parameter
 			ReferenceTag,
 			
 			/// Marks the object as input
@@ -105,26 +104,29 @@
 			template <class ...Params_>
 			Parameter(const std::string &name, const std::string &help, const Type *type, 
 					 Data defaultvalue, OptionList options, Params_ ...tags) : 
-			name(name), type(type), help(help), Options(std::move(options)), defaultvalue(defaultvalue) {
+			name(name), type(type), help(help), Options(this->options), defaultvalue(defaultvalue) {
 				ASSERT((type!=nullptr), "Parameter type cannot be nullptr", 1, 2);
-				
+				using std::swap;
+
+				swap(options, this->options);
+
 				UnpackTags(tags...);
 			}
 			
 			/// @cond INTERNAL
 			Parameter(const std::string &name, const std::string &help, const Type *type, Data defaultvalue=Data::Invalid()) : 
-			Parameter(name, help, type, defaultvalue, OptionList{}) { }
+			Parameter(name, help, type, defaultvalue, OptionList()) { }
 			
 			template <class ...Params_>
 			Parameter(const std::string &name, const std::string &help, const Type *type, Tag firsttag,
 					  Params_ ...tags) : 
-			Parameter(name, help, type, Data::Invalid(), OptionList{}, firsttag, std::forward<Params_>(tags)...) {
+			Parameter(name, help, type, Data::Invalid(), OptionList(), firsttag, std::forward<Params_>(tags)...) {
 			}
 			
 			template <class ...Params_>
 			Parameter(const std::string &name, const std::string &help, const Type *type, Data defaultvalue,
 					  Tag firsttag, Params_ ...tags) : 
-			Parameter(name, help, type, defaultvalue, OptionList{}, firsttag, std::forward<Params_>(tags)...) {
+			Parameter(name, help, type, defaultvalue, OptionList(), firsttag, std::forward<Params_>(tags)...) {
 			}
 			 
 			Parameter(const std::string &name, const std::string &help, const Type *type, 
@@ -135,6 +137,20 @@
 				}
 			}
 			/// @endcond
+
+			Parameter &operator =(const Parameter &p) {
+				name		= p.name		;
+				help		= p.help		;
+				type		= p.type		;
+				defaultvalue= p.defaultvalue;
+				options		= p.options		;
+				optional	= p.optional	;
+				reference	= p.reference	;
+				constant	= p.constant	;
+				variable	= p.variable	;
+
+				return *this;
+			}
 			
 			/// Returns the name of the parameter
 			std::string GetName() const {
@@ -218,6 +234,8 @@
 			std::string help;
 			const Type *type;
 			Data defaultvalue=Data::Invalid();
+
+			OptionList options;
 			
 			bool optional  = false;
 			bool reference = false;
--- a/Source/Scripting/Scope.cpp	Wed Mar 25 15:19:52 2015 +0200
+++ b/Source/Scripting/Scope.cpp	Sun Mar 29 15:14:31 2015 +0300
@@ -30,7 +30,7 @@
 					throw err;
 				}
 				
-				for(int i=parser->List.size()-compiled;i<parser->List.size();i++) {
+				for(unsigned i=parser->List.size()-compiled;i<parser->List.size();i++) {
 					lines.push_back({parser->List[i], pline});
 				}
 				
--- a/Testing/Source/Unit/Scripting.cpp	Wed Mar 25 15:19:52 2015 +0200
+++ b/Testing/Source/Unit/Scripting.cpp	Sun Mar 29 15:14:31 2015 +0300
@@ -53,7 +53,7 @@
 	}
 	
 	int b(float a) {
-		return 42*a;
+		return int(42*a);
 	}
 	
 	explicit operator std::string() const {
@@ -80,7 +80,7 @@
 	}
 	
 	int b(float a) {
-		return 42*a;
+		return int(42*a);
 	}
 	
 	explicit operator std::string() const {

mercurial