Преглед изворни кода

src/*: code-style: do not allow function definition one-liners

Daniele Bartolini пре 3 година
родитељ
комит
9f5beeca10

+ 8 - 2
src/core/memory/linear_allocator.h

@@ -41,10 +41,16 @@ struct LinearAllocator : public Allocator
 	void clear();
 
 	/// @copydoc Allocator::allocated_size()
-	u32 allocated_size(const void* /*ptr*/) { return SIZE_NOT_TRACKED; }
+	u32 allocated_size(const void* /*ptr*/)
+	{
+		return SIZE_NOT_TRACKED;
+	}
 
 	/// @copydoc Allocator::total_allocated()
-	u32 total_allocated() { return _offset; }
+	u32 total_allocated()
+	{
+		return _offset;
+	}
 };
 
 } // namespace crown

+ 4 - 1
src/core/memory/pool_allocator.h

@@ -39,7 +39,10 @@ struct PoolAllocator : public Allocator
 	void deallocate(void* data);
 
 	/// @copydoc Allocator::allocated_size()
-	u32 allocated_size(const void* /*ptr*/) { return SIZE_NOT_TRACKED; }
+	u32 allocated_size(const void* /*ptr*/)
+	{
+		return SIZE_NOT_TRACKED;
+	}
 
 	/// @copydoc Allocator::total_allocated()
 	u32 total_allocated();

+ 8 - 2
src/core/memory/proxy_allocator.h

@@ -30,10 +30,16 @@ struct ProxyAllocator : public Allocator
 	virtual void* reallocate(void* data, u32 size, u32 align = DEFAULT_ALIGN);
 
 	/// @copydoc Allocator::allocated_size()
-	u32 allocated_size(const void* ptr) { return _allocator.allocated_size(ptr); }
+	u32 allocated_size(const void* ptr)
+	{
+		return _allocator.allocated_size(ptr);
+	}
 
 	/// @copydoc Allocator::total_allocated()
-	u32 total_allocated() { return _allocator.total_allocated(); }
+	u32 total_allocated()
+	{
+		return _allocator.total_allocated();
+	}
 
 	/// Returns the name of the proxy allocator
 	const char* name() const;

+ 4 - 1
src/core/memory/stack_allocator.h

@@ -40,7 +40,10 @@ struct StackAllocator : public Allocator
 	void deallocate(void* data);
 
 	/// @copydoc Allocator::allocated_size()
-	u32 allocated_size(const void* /*ptr*/) { return SIZE_NOT_TRACKED; }
+	u32 allocated_size(const void* /*ptr*/)
+	{
+		return SIZE_NOT_TRACKED;
+	}
 
 	/// @copydoc Allocator::total_allocated()
 	u32 total_allocated();

+ 11 - 3
src/core/memory/temp_allocator.inl

@@ -42,13 +42,21 @@ struct TempAllocator : public Allocator
 
 	/// Deallocation is a NOP for the TempAllocator. The memory is automatically
 	/// deallocated when the TempAllocator is destroyed.
-	virtual void deallocate(void *) {}
+	virtual void deallocate(void *)
+	{
+	}
 
 	/// Returns SIZE_NOT_TRACKED.
-	virtual u32 allocated_size(const void*) {return SIZE_NOT_TRACKED;}
+	virtual u32 allocated_size(const void*)
+	{
+		return SIZE_NOT_TRACKED;
+	}
 
 	/// Returns SIZE_NOT_TRACKED.
-	virtual u32 total_allocated() {return SIZE_NOT_TRACKED;}
+	virtual u32 total_allocated()
+	{
+		return SIZE_NOT_TRACKED;
+	}
 };
 
 // If possible, use one of these predefined sizes for the TempAllocator to avoid

+ 8 - 2
src/device/device.h

@@ -78,10 +78,16 @@ struct Device
 	void run();
 
 	/// Returns the number of command line parameters.
-	int argc() const { return _options._argc; }
+	int argc() const
+	{
+		return _options._argc;
+	}
 
 	/// Returns command line parameters.
-	const char** argv() const { return (const char**)_options._argv; }
+	const char** argv() const
+	{
+		return (const char**)_options._argv;
+	}
 
 	/// Quits the application.
 	void quit();

+ 63 - 13
src/resource/expression_language.cpp

@@ -22,10 +22,16 @@ namespace expression_language
 	enum ByteCode {BC_FUNCTION = 0x7f800000, BC_PUSH_VAR = 0x7f900000, BC_END = 0x7fa00000};
 
 	/// Returns the byte code operation part of the byte code word.
-	static inline unsigned bc_mask(unsigned i) {return i & 0xfff00000;}
+	static inline unsigned bc_mask(unsigned i)
+	{
+		return i & 0xfff00000;
+	}
 
 	/// Returns the id part of the byte code word.
-	static inline unsigned id_mask(unsigned i) {return i & 0x000fffff;}
+	static inline unsigned id_mask(unsigned i)
+	{
+		return i & 0x000fffff;
+	}
 
 	/// Opcodes for functions
 	enum OpCode
@@ -43,8 +49,17 @@ namespace expression_language
 		OP_MATCH_2D
 	};
 
-	static inline float pop(Stack &stack) 			{CE_ASSERT(stack.size > 0, "Stack underflow"); return stack.data[--stack.size];}
-	static inline void push(Stack &stack, float f)	{CE_ASSERT(stack.size < stack.capacity, "Stack overflow"); stack.data[stack.size++] = f;}
+	static inline float pop(Stack &stack)
+	{
+		CE_ASSERT(stack.size > 0, "Stack underflow");
+		return stack.data[--stack.size];
+	}
+
+	static inline void push(Stack &stack, float f)
+	{
+		CE_ASSERT(stack.size < stack.capacity, "Stack overflow");
+		stack.data[stack.size++] = f;
+	}
 
 	inline float fmax(float a, float b)
 	{
@@ -101,7 +116,12 @@ namespace expression_language
 		unsigned u;
 	};
 
-	static inline float unsigned_to_float(unsigned u)	{FloatAndUnsigned fu; fu.u = u; return fu.f;}
+	static inline float unsigned_to_float(unsigned u)
+	{
+		FloatAndUnsigned fu;
+		fu.u = u;
+		return fu.f;
+	}
 
 	bool run(const unsigned *byte_code, const float *variables, Stack &stack)
 	{
@@ -133,10 +153,18 @@ namespace expression_language
 #if CROWN_CAN_COMPILE
 namespace expression_language
 {
-	static inline unsigned float_to_unsigned(float f)	{FloatAndUnsigned fu; fu.f = f; return fu.u;}
+	static inline unsigned float_to_unsigned(float f)
+	{
+		FloatAndUnsigned fu;
+		fu.f = f;
+		return fu.u;
+	}
 
 #ifdef WIN32
-		float strtof(const char *nptr, char **endptr) {return (float)strtod(nptr, endptr);}
+	float strtof(const char *nptr, char **endptr)
+	{
+		return (float)strtod(nptr, endptr);
+	}
 #endif
 
 	/// Represents a token in the expression language. The tokens are used
@@ -413,15 +441,37 @@ namespace expression_language
 		{
 		}
 
-		inline int cmp(const FunctionStackItem &f) const {
+		inline int cmp(const FunctionStackItem &f) const
+		{
 			if (par_level != f.par_level) return par_level - f.par_level;
 			return precedence - f.precedence;
 		}
-		inline bool operator<(const FunctionStackItem &other) const {return cmp(other) < 0;}
-		inline bool operator<=(const FunctionStackItem &other) const {return cmp(other) <= 0;}
-		inline bool operator==(const FunctionStackItem &other) const {return cmp(other) == 0;}
-		inline bool operator>=(const FunctionStackItem &other) const {return cmp(other) >= 0;}
-		inline bool operator>(const FunctionStackItem &other) const {return cmp(other) > 0;}
+
+		inline bool operator<(const FunctionStackItem &other) const
+		{
+			return cmp(other) < 0;
+		}
+
+		inline bool operator<=(const FunctionStackItem &other) const
+		{
+			return cmp(other) <= 0;
+		}
+
+		inline bool operator==(const FunctionStackItem &other) const
+		{
+			return cmp(other) == 0;
+		}
+
+		inline bool operator>=(const FunctionStackItem &other) const
+		{
+			return cmp(other) >= 0;
+		}
+
+		inline bool operator>(const FunctionStackItem &other) const
+		{
+			return cmp(other) > 0;
+		}
+
 		Token token;
 		int precedence;
 		int par_level;

+ 18 - 7
src/world/physics_world_bullet.cpp

@@ -289,7 +289,7 @@ struct PhysicsWorldImpl
 		btTriangleIndexVertexArray* vertex_array = NULL;
 		btCollisionShape* child_shape = NULL;
 
-		switch(sd->type)
+		switch (sd->type)
 		{
 		case ColliderType::SPHERE:
 			child_shape = CE_NEW(*_allocator, btSphereShape)(sd->sphere.radius);
@@ -333,8 +333,8 @@ struct PhysicsWorldImpl
 			vertex_array = CE_NEW(*_allocator, btTriangleIndexVertexArray)();
 			vertex_array->addIndexedMesh(part, PHY_SHORT);
 
-			const btVector3 aabb_min(-1000.0f,-1000.0f,-1000.0f);
-			const btVector3 aabb_max(1000.0f,1000.0f,1000.0f);
+			const btVector3 aabb_min(-1000.0f, -1000.0f, -1000.0f);
+			const btVector3 aabb_max(1000.0f, 1000.0f, 1000.0f);
 			child_shape = CE_NEW(*_allocator, btBvhTriangleMeshShape)(vertex_array, false, aabb_min, aabb_max);
 			break;
 		}
@@ -777,7 +777,7 @@ struct PhysicsWorldImpl
 		btRigidBody* body_1 = is_valid(a1) ? _actor[a1.i].body : NULL;
 
 		btTypedConstraint* joint = NULL;
-		switch(jd.type)
+		switch (jd.type)
 		{
 		case JointType::FIXED:
 		{
@@ -1100,9 +1100,20 @@ struct PhysicsWorldImpl
 		static_cast<PhysicsWorldImpl*>(user_ptr)->unit_destroyed_callback(unit);
 	}
 
-	static ColliderInstance make_collider_instance(u32 i) { ColliderInstance inst = { i }; return inst; }
-	static ActorInstance make_actor_instance(u32 i) { ActorInstance inst = { i }; return inst; }
-	static JointInstance make_joint_instance(u32 i) { JointInstance inst = { i }; return inst; }
+	static ColliderInstance make_collider_instance(u32 i)
+	{
+		ColliderInstance inst = { i }; return inst;
+	}
+
+	static ActorInstance make_actor_instance(u32 i)
+	{
+		ActorInstance inst = { i }; return inst;
+	}
+
+	static JointInstance make_joint_instance(u32 i)
+	{
+		JointInstance inst = { i }; return inst;
+	}
 };
 
 PhysicsWorld::PhysicsWorld(Allocator& a, ResourceManager& rm, UnitManager& um, DebugLine& dl)

+ 14 - 3
src/world/physics_world_noop.cpp

@@ -271,9 +271,20 @@ struct PhysicsWorldImpl
 	{
 	}
 
-	ColliderInstance make_collider_instance(u32 i) { ColliderInstance inst = { i }; return inst; }
-	ActorInstance make_actor_instance(u32 i) { ActorInstance inst = { i }; return inst; }
-	JointInstance make_joint_instance(u32 i) { JointInstance inst = { i }; return inst; }
+	ColliderInstance make_collider_instance(u32 i)
+	{
+		ColliderInstance inst = { i }; return inst;
+	}
+
+	ActorInstance make_actor_instance(u32 i)
+	{
+		ActorInstance inst = { i }; return inst;
+	}
+
+	JointInstance make_joint_instance(u32 i)
+	{
+		JointInstance inst = { i }; return inst;
+	}
 };
 
 PhysicsWorld::PhysicsWorld(Allocator& a, ResourceManager& /*rm*/, UnitManager& /*um*/, DebugLine& /*dl*/)

+ 12 - 3
src/world/render_world.h

@@ -230,7 +230,10 @@ struct RenderWorld
 			);
 
 		///
-		MeshInstance make_instance(u32 i) { MeshInstance inst = { i }; return inst; }
+		MeshInstance make_instance(u32 i)
+		{
+			MeshInstance inst = { i }; return inst;
+		}
 	};
 
 	/// List of meshes to be rendered.
@@ -306,7 +309,10 @@ struct RenderWorld
 			);
 
 		///
-		SpriteInstance make_instance(u32 i) { SpriteInstance inst = { i }; return inst; }
+		SpriteInstance make_instance(u32 i)
+		{
+			SpriteInstance inst = { i }; return inst;
+		}
 	};
 
 	struct LightManager
@@ -363,7 +369,10 @@ struct RenderWorld
 		void destroy();
 
 		///
-		LightInstance make_instance(u32 i) { LightInstance inst = { i }; return inst; }
+		LightInstance make_instance(u32 i)
+		{
+			LightInstance inst = { i }; return inst;
+		}
 	};
 
 	u32 _marker;

+ 4 - 1
src/world/world.h

@@ -71,7 +71,10 @@ struct World
 
 	ListNode _node;
 
-	CameraInstance camera_make_instance(u32 i) { CameraInstance inst = { i }; return inst; }
+	CameraInstance camera_make_instance(u32 i)
+	{
+		CameraInstance inst = { i }; return inst;
+	}
 
 	///
 	World(Allocator& a, ResourceManager& rm, ShaderManager& sm, MaterialManager& mm, UnitManager& um, LuaEnvironment& env);