Commits

Igor Baidiuk committed 169c7b8

Added empty-check method; maybe default ctor should be opened

Comments (0)

Files changed (2)

src/common/Variant.cpp

 		cleanup();
 	}
 
+	bool Variant::empty() const
+	{
+		return type == UNKNOWN;
+	}
+
 	Variant Variant::getVariant(lua_State *L, int n)
 	{
 		size_t len = 0;
 		}
 		return 1;
 	}
-
-	void Variant::prettyPrint()
-	{
-		static int offset = 0;
-		printf("%*s", offset*2, "");
-		switch (type)
-		{
-		case BOOLEAN:
-			printf("Boolean %s\n", data.boolean ? "true" : "false");
-			break;
-		case NUMBER:
-			printf("Number %g\n", data.number);
-			break;
-		case CHARACTER:
-			printf("Character '%c'\n", data.character);
-			break;
-		case STRING:
-			if (data.string)
-			{
-				RefString* str = (RefString*)data.string;
-				printf("String '%.*s'\n", str->size() - 1, str->begin());
-			}
-			else
-				printf("String ''\n");
-			break;
-		case LUSERDATA:
-			printf("Light userdata at %p\n", data.light);
-			break;
-		case FUSERDATA:
-			printf("Userdata at %p\n", data.full.data);
-			break;
-		case TUPLE:
-			if (data.tuple)
-			{
-				RefTuple* tuple = (RefTuple*)data.tuple;
-				printf("%u-tuple:\n", tuple->size());
-				++offset;
-				for (Variant *i = tuple->begin(), *e = tuple->end(); i != e; ++i)
-					i->prettyPrint();
-				--offset;
-			}
-			else
-				printf("0-tuple\n");
-			break;
-		case TABLE:
-			if (data.table)
-			{
-				RefTable *t = (RefTable*)data.table;
-				printf("%u-table:\n", t->size());
-				++offset;
-				for (Pair *i = t->begin(), *e = t->end(); i != e; ++i)
-				{
-					printf("%*sPair:\n", offset*2, "");
-					++offset;
-					i->first.prettyPrint();
-					i->second.prettyPrint();
-					--offset;
-				}
-				--offset;
-			}
-			else
-				printf("0-table\n");
-			break;
-		default:
-			printf("NIL\n");
-		}
-	}
 } // love

src/common/Variant.h

 
 		virtual ~Variant();
 
+		bool empty() const;
+
 		static Variant *fromLua(lua_State *L, int n_from, int n_to = 0);
 		int toLua(lua_State *L);
-
-		void prettyPrint();
 	}; // Variant
 
 	typedef Ptr<Variant> VariantPtr;
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.