Skip to content

Commit

Permalink
🔖 λcommon v1.10.0: New types, renamed resourcenames to identifiers, e…
Browse files Browse the repository at this point in the history
…tc...
  • Loading branch information
LambdAurora committed Dec 17, 2019
1 parent abaad57 commit 3d0f94d
Show file tree
Hide file tree
Showing 33 changed files with 796 additions and 744 deletions.
11 changes: 8 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#
# AperLambda ignore file
# LambdAurora's ignore file
#
# v0.8
# v0.12

# JetBrains
.idea/
Expand Down Expand Up @@ -41,6 +41,10 @@ node_modules/
logs/

# Languages
## Java
classes/
## Python
__pycache__/
## Rust
**/*.rs.bk

Expand All @@ -54,10 +58,11 @@ desktop.ini
*.dylib
*.lib
lib*.a
*.png~

# Common
bin/
build/
dist/
run/
target/
target/
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,18 @@ set(CMAKE_CXX_STANDARD 17)
# Options
option(LAMBDACOMMON_BUILD_STATIC "Build static libraries" OFF)
option(LAMBDACOMMON_INSTALL "Generate installation target" ON)
option(LAMBDACOMMON_BUILD_C_WRAPPER "Build the λcommon C wrapper" ON)
option(LAMBDACOMMON_BUILD_C_WRAPPER "Build the λcommon C wrapper" OFF)
option(LAMBDACOMMON_BUILD_TESTS "Build the λcommon test programs" ON)

# Version
set(LAMBDACOMMON_VERSION_MAJOR 1)
set(LAMBDACOMMON_VERSION_MINOR 10)
set(LAMBDACOMMON_VERSION_PATCH 0)
set(LAMBDACOMMON_VERSION_TYPE "indev")
set(LAMBDACOMMON_VERSION_TYPE "Release")

# Generate compile flags.
generate_flags(LAMBDACOMMON_COMPILE_FLAGS "native" 2 true)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}${LAMBDACOMMON_COMPILE_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}${LAMBDACOMMON_COMPILE_FLAGS} -Wno-attributes")

if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -framework CoreFoundation -framework ApplicationServices -Wno-unused-command-line-argument")
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,4 +129,4 @@ Build the sources with CMake and make and install with `make install`, and keep
## Use in CMake
Use `Findlambdacommon.cmake` in [LambdaCMakeModules](https://github.com/LambdAurora/lcmm.git) to find λcommon on your computer.
Use `Findlambdacommon.cmake` in [LambdaCMakeModules](https://github.com/LambdAurora/lcmm.git) to find λcommon on your computer.
2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ echo "cd to build directory"
mkdir -p build/
cd build/
echo "Building project..."
cmake ..
cmake -DLAMBDACOMMON_BUILD_C_WRAPPER=ON ..
if [ $? -ne 0 ]; then
echo "${RED}Error: CMake doesn't exit with success! Cleaning...${NC}"
cd ..
Expand Down
43 changes: 22 additions & 21 deletions c_wrapper/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,40 +32,41 @@ endfunction()
set(C_HEADERS_GRAPHICS include/clambdacommon/graphics/color.h)
set(C_HEADERS_MATHS include/clambdacommon/maths/geometry/point.h include/clambdacommon/maths/geometry/vector.h)
set(C_HEADERS_SYSTEM include/clambdacommon/system/os.h include/clambdacommon/system/terminal.h include/clambdacommon/system/system.h include/clambdacommon/system/time.h)
set(C_HEADERS_BASE include/clambdacommon/clambdacommon.h include/clambdacommon/lstring.h include/clambdacommon/maths.h include/clambdacommon/resources.h)
set(C_HEADERS_BASE include/clambdacommon/clambdacommon.h include/clambdacommon/lstring.h include/clambdacommon/maths.h include/clambdacommon/resources.h include/clambdacommon/types.h)
set(C_HEADERS_FILES ${C_HEADERS_GRAPHICS} ${C_HEADERS_MATHS} ${C_HEADERS_SYSTEM} ${C_HEADERS_BASE})
# This is the C sources files.
set(C_SOURCES_GRAPHICS src/graphics/color.cpp)
set(C_SOURCES_SYSTEM src/system/os.cpp src/system/terminal.cpp src/system/system.cpp src/time.cpp)
set(C_SOURCES_BASE src/clambdacommon.cpp src/lstring.cpp src/maths.cpp src/resources.cpp)
set(C_SOURCES_FILES ${C_SOURCES_GRAPHICS} ${C_SOURCES_SYSTEM} ${C_SOURCES_BASE})

generate_template_wrapper(point int8_t)
generate_template_wrapper(point uint8_t)
generate_template_wrapper(point int16_t)
generate_template_wrapper(point uint16_t)
generate_template_wrapper(point int32_t)
generate_template_wrapper(point uint32_t)
generate_template_wrapper(point int64_t)
generate_template_wrapper(point uint64_t)
generate_template_wrapper(point float)
generate_template_wrapper(point double)
generate_template_wrapper(vector int8_t)
generate_template_wrapper(vector uint8_t)
generate_template_wrapper(vector int16_t)
generate_template_wrapper(vector uint16_t)
generate_template_wrapper(vector int32_t)
generate_template_wrapper(vector uint32_t)
generate_template_wrapper(vector int64_t)
generate_template_wrapper(vector uint64_t)
generate_template_wrapper(vector float)
generate_template_wrapper(vector double)
generate_template_wrapper(point i8)
generate_template_wrapper(point u8)
generate_template_wrapper(point i16)
generate_template_wrapper(point u16)
generate_template_wrapper(point i32)
generate_template_wrapper(point u32)
generate_template_wrapper(point i64)
generate_template_wrapper(point u64)
generate_template_wrapper(point f32)
generate_template_wrapper(point f64)
generate_template_wrapper(vector i8)
generate_template_wrapper(vector u8)
generate_template_wrapper(vector i16)
generate_template_wrapper(vector u16)
generate_template_wrapper(vector i32)
generate_template_wrapper(vector u32)
generate_template_wrapper(vector i64)
generate_template_wrapper(vector u64)
generate_template_wrapper(vector f32)
generate_template_wrapper(vector f64)

# Now build the library
# Build the shared library
add_library(clambdacommon ${C_HEADERS_FILES} ${C_SOURCES_FILES})
target_link_libraries(clambdacommon lambdacommon)

target_include_directories(clambdacommon PUBLIC "include")
target_include_directories(clambdacommon PUBLIC "${CMAKE_BINARY_DIR}/c_wrapper/exports")

# Install if the option is on.
Expand Down
24 changes: 12 additions & 12 deletions c_wrapper/include/clambdacommon/graphics/color.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,33 +11,33 @@
#define CLAMBDACOMMON_COLOR_H

#include "../clambdacommon.h"
#include <inttypes.h>
#include "../types.h"

#ifdef __cplusplus
extern "C" {
#endif

typedef struct lcColor lcColor;

lcColor* lc_new_Color(float red, float green, float blue, float alpha);
lcColor* lc_new_Color(f32 red, f32 green, f32 blue, f32 alpha);

void lc_delete_Color(lcColor* color);

float lc_Color_get_red(const lcColor* color);
f32 lc_Color_get_red(const lcColor* color);

float lc_Color_get_green(const lcColor* color);
f32 lc_Color_get_green(const lcColor* color);

float lc_Color_get_blue(const lcColor* color);
f32 lc_Color_get_blue(const lcColor* color);

float lc_Color_get_alpha(const lcColor* color);
f32 lc_Color_get_alpha(const lcColor* color);

uint8_t lc_Color_get_red_as_int(const lcColor* color);
u8 lc_Color_get_red_as_int(const lcColor* color);

uint8_t lc_Color_get_green_as_int(const lcColor* color);
u8 lc_Color_get_green_as_int(const lcColor* color);

uint8_t lc_Color_get_blue_as_int(const lcColor* color);
u8 lc_Color_get_blue_as_int(const lcColor* color);

uint8_t lc_Color_get_alpha_as_int(const lcColor* color);
u8 lc_Color_get_alpha_as_int(const lcColor* color);

const char* lc_Color_to_string(const lcColor* color, bool hex);

Expand All @@ -47,11 +47,11 @@ lcColor* lc_color_blend(const lcColor* bg, const lcColor* fg);

lcColor* lc_color_mix(const lcColor* a, const lcColor* b, float ratio);

lcColor* lc_color_from_hex(uint64_t hex_color, bool has_alpha);
lcColor* lc_color_from_hex(u64 hex_color, bool has_alpha);

lcColor* lc_color_from_hex_str(const char* hex_color);

lcColor* lc_color_from_int_rgba(uint8_t red, uint8_t green, uint8_t blue, uint8_t alpha);
lcColor* lc_color_from_int_rgba(u8 red, u8 green, u8 blue, u8 alpha);

#ifdef __cplusplus
}
Expand Down
10 changes: 6 additions & 4 deletions c_wrapper/include/clambdacommon/maths.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
#ifndef CLAMBDACOMMON_MATHS_H
#define CLAMBDACOMMON_MATHS_H

#include "types.h"

#define LCOMMON_PI 3.14159265359
#define LCOMMON_TAU 6.28318530718

Expand All @@ -24,13 +26,13 @@ extern "C"
{
#endif

double lc_maths_radians(double degrees);
f64 lc_maths_radians(f64 degrees);

float lc_maths_fradians(float degrees);
f32 lc_maths_fradians(f32 degrees);

double lc_maths_degrees(double radians);
f64 lc_maths_degrees(f64 radians);

float lc_maths_fdegrees(float radians);
f32 lc_maths_fdegrees(f32 radians);

#ifdef __cplusplus
}
Expand Down
20 changes: 10 additions & 10 deletions c_wrapper/include/clambdacommon/maths/geometry/point.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@
#ifndef CLAMBDACOMMON_POINT_H
#define CLAMBDACOMMON_POINT_H

#include <clambdacommon/maths/geometry/point_int8_t.h>
#include <clambdacommon/maths/geometry/point_uint8_t.h>
#include <clambdacommon/maths/geometry/point_int16_t.h>
#include <clambdacommon/maths/geometry/point_uint16_t.h>
#include <clambdacommon/maths/geometry/point_int32_t.h>
#include <clambdacommon/maths/geometry/point_uint32_t.h>
#include <clambdacommon/maths/geometry/point_int64_t.h>
#include <clambdacommon/maths/geometry/point_uint64_t.h>
#include <clambdacommon/maths/geometry/point_double.h>
#include <clambdacommon/maths/geometry/point_float.h>
#include <clambdacommon/maths/geometry/point_i8.h>
#include <clambdacommon/maths/geometry/point_u8.h>
#include <clambdacommon/maths/geometry/point_i16.h>
#include <clambdacommon/maths/geometry/point_u16.h>
#include <clambdacommon/maths/geometry/point_i32.h>
#include <clambdacommon/maths/geometry/point_u32.h>
#include <clambdacommon/maths/geometry/point_i64.h>
#include <clambdacommon/maths/geometry/point_u64.h>
#include <clambdacommon/maths/geometry/point_f32.h>
#include <clambdacommon/maths/geometry/point_f64.h>

#endif //CLAMBDACOMMON_POINT_H
2 changes: 1 addition & 1 deletion c_wrapper/include/clambdacommon/maths/geometry/point.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#ifndef CLAMBDACOMMON_POINT_@LC_C_TYPE@_H
#define CLAMBDACOMMON_POINT_@LC_C_TYPE@_H

#include <inttypes.h>
#include <clambdacommon/types.h>

#ifdef __cplusplus
extern "C" {
Expand Down
20 changes: 10 additions & 10 deletions c_wrapper/include/clambdacommon/maths/geometry/vector.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@
#ifndef CLAMBDACOMMON_VECTOR_H
#define CLAMBDACOMMON_VECTOR_H

#include <clambdacommon/maths/geometry/vector_int8_t.h>
#include <clambdacommon/maths/geometry/vector_uint8_t.h>
#include <clambdacommon/maths/geometry/vector_int16_t.h>
#include <clambdacommon/maths/geometry/vector_uint16_t.h>
#include <clambdacommon/maths/geometry/vector_int32_t.h>
#include <clambdacommon/maths/geometry/vector_uint32_t.h>
#include <clambdacommon/maths/geometry/vector_int64_t.h>
#include <clambdacommon/maths/geometry/vector_uint64_t.h>
#include <clambdacommon/maths/geometry/vector_double.h>
#include <clambdacommon/maths/geometry/vector_float.h>
#include <clambdacommon/maths/geometry/vector_i8.h>
#include <clambdacommon/maths/geometry/vector_u8.h>
#include <clambdacommon/maths/geometry/vector_i16.h>
#include <clambdacommon/maths/geometry/vector_u16.h>
#include <clambdacommon/maths/geometry/vector_i32.h>
#include <clambdacommon/maths/geometry/vector_u32.h>
#include <clambdacommon/maths/geometry/vector_i64.h>
#include <clambdacommon/maths/geometry/vector_u64.h>
#include <clambdacommon/maths/geometry/vector_f32.h>
#include <clambdacommon/maths/geometry/vector_f64.h>

#endif //CLAMBDACOMMON_VECTOR_H
2 changes: 1 addition & 1 deletion c_wrapper/include/clambdacommon/maths/geometry/vector.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#ifndef CLAMBDACOMMON_VECTOR_@LC_C_TYPE@_H
#define CLAMBDACOMMON_VECTOR_@LC_C_TYPE@_H

#include <inttypes.h>
#include <clambdacommon/types.h>

#ifdef __cplusplus
extern "C" {
Expand Down
20 changes: 10 additions & 10 deletions c_wrapper/include/clambdacommon/resources.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,36 +17,36 @@
extern "C" {
#endif

typedef struct lc_ResourceName lc_ResourceName;
typedef struct lc_Identifier lc_Identifier;

lc_ResourceName* lc_new_ResourceName(const char* name);
lc_Identifier* lc_new_Identifier(const char* name);

lc_ResourceName* lc_new_ResourceName_DP(const char* domain, const char* path);
lc_Identifier* lc_new_Identifier_DP(const char* domain, const char* path);

void lc_delete_ResourceName(lc_ResourceName* resourceName);
void lc_delete_Identifier(lc_Identifier* resourceName);

/*!
* Gets the domain of the resource.
* Gets the namespace of the resource.
* @param resourceName The resource name instance.
* @return The domain of the resource as a dynamically allocated string.
* @return The namespace of the resource as a dynamically allocated string.
*/
const char* lc_ResourceName_get_domain(const lc_ResourceName* resourceName);
const char* lc_Identifier_get_namespace(const lc_Identifier* resourceName);

/*!
* Gets the name of the resource.
* @param resourceName The resource name instance.
* @return The name of the resource as a dynamically allocated string.
*/
const char* lc_ResourceName_get_name(const lc_ResourceName* resourceName);
const char* lc_Identifier_get_name(const lc_Identifier* resourceName);

/*!
* Gets the resource name as a string.
* @param resourceName The resource name instance.
* @return The resource name as a dynamically allocated string.
*/
const char* lc_ResourceName_to_string(const lc_ResourceName* resourceName);
const char* lc_Identifier_to_string(const lc_Identifier* resourceName);

bool lc_ResourceName_equals(const lc_ResourceName* resourceName, const lc_ResourceName* other);
bool lc_Identifier_equals(const lc_Identifier* resourceName, const lc_Identifier* other);

#ifdef __cplusplus
}
Expand Down
33 changes: 33 additions & 0 deletions c_wrapper/include/clambdacommon/types.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Copyright © 2019 LambdAurora <aurora42lambda@gmail.com>
*
* This file is part of λcommon.
*
* Licensed under the MIT license. For more information,
* see the LICENSE file.
*/

#ifndef CLAMBDACOMMON_TYPES_H
#define CLAMBDACOMMON_TYPES_H

#include <inttypes.h>

/*
* Integers
*/
typedef int8_t i8;
typedef int16_t i16;
typedef int32_t i32;
typedef int64_t i64;
typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
typedef uint64_t u64;

/*
* Floats
*/
typedef float f32;
typedef double f64;

#endif //CLAMBDACOMMON_TYPES_H
Loading

0 comments on commit 3d0f94d

Please sign in to comment.