Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: C Language Support #130

Merged
merged 69 commits into from
Aug 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
c44e9a6
chore: Copy JS templates to C and create language.config.json
jlacivita Apr 26, 2023
b61188f
feat(languages): Add support for a distinct JSON-type for each schema
jlacivita Apr 26, 2023
02e2e73
chore: Dropped debug logs
jlacivita Apr 26, 2023
5814d9d
fix: Stop passing non-schemas in to getSchemaType
jlacivita Apr 26, 2023
c1ba6ae
feat(accessors): New macro section for schema property accessors
jlacivita Apr 28, 2023
ef9c924
fix: Sort the macrofied schemas based on schema refs (#90)
sramani-metro May 23, 2023
7c8d025
Enum fixes (#93)
HaseenaSainul Jun 1, 2023
e3cf471
Types and Accessor related fixes (#94)
HaseenaSainul Jun 5, 2023
77abef6
Static code implementation updates (#96)
HaseenaSainul Jun 8, 2023
8818654
Add support to generate file inclusion for common schema also (#97)
HaseenaSainul Jun 15, 2023
a168c8d
C-Language: Templates based property methods (#100)
sramani-metro Jun 20, 2023
8e716e5
Add support to keep original file permissions of template/sdk files (…
HaseenaSainul Jun 22, 2023
8d9ac14
Event template implementation added (#101)
HaseenaSainul Jun 22, 2023
db4c7fe
Template for Polymorphic pull method (#102)
sramani-metro Jun 22, 2023
014e4fb
fix: Promote and name sub-schemas in one place
jlacivita Jul 5, 2023
044e528
fix: Add extractSubSchemas flag to C language
jlacivita Jul 5, 2023
45280e0
fix: Uncomment writeFilePermissions
jlacivita Jul 5, 2023
d3ef7f3
polymorphic-pull: method and event implementation added (#107)
HaseenaSainul Jul 10, 2023
9687033
SchemaSorting: logic updated to consider all schemas (#106)
HaseenaSainul Jul 10, 2023
5a15e16
fix: Fix the reentrancy of methods from callback (#105)
sramani-metro Jul 11, 2023
daf6ec6
Default template implementation added (#103)
HaseenaSainul Jul 11, 2023
161b347
Naming + void* to struct* changes based on sky review, removed redund…
HaseenaSainul Jul 12, 2023
5f12311
language-c: re-arrange files locations (#112)
HaseenaSainul Jul 17, 2023
923de60
fixes to generate array inside subschemas (#111)
HaseenaSainul Jul 17, 2023
14dfca7
include test always (#113)
HaseenaSainul Jul 17, 2023
e7e9eba
use String type if there is any issue with anyOf merge (#114)
HaseenaSainul Jul 17, 2023
51f3043
calls-metrics: support added (#115)
HaseenaSainul Jul 17, 2023
6a17ba2
Generate polymorphci methods for anyOf param/result case (#110)
HaseenaSainul Jul 17, 2023
934fcfd
Create namespaces only if there is value to put (#117)
HaseenaSainul Jul 24, 2023
6d43093
Changes to avoid duplication of sub-array schema with same reference …
HaseenaSainul Jul 24, 2023
3a94727
detach setter declaration from property template and add setter templ…
HaseenaSainul Jul 26, 2023
5fd33a4
SubArray generation issue fix (#121)
HaseenaSainul Aug 7, 2023
6c3b417
cmake changes to install proper files (#119)
HaseenaSainul Aug 7, 2023
0db1758
Merge branch 'next' into feature/c-language
jlacivita Aug 10, 2023
37dd5a6
chore: Copy JS templates to C and create language.config.json
jlacivita Apr 26, 2023
e4779e2
feat(languages): Add support for a distinct JSON-type for each schema
jlacivita Apr 26, 2023
f2cd197
chore: Dropped debug logs
jlacivita Apr 26, 2023
38dc633
fix: Stop passing non-schemas in to getSchemaType
jlacivita Apr 26, 2023
6cb39c3
feat(accessors): New macro section for schema property accessors
jlacivita Apr 28, 2023
3700c99
fix: Sort the macrofied schemas based on schema refs (#90)
sramani-metro May 23, 2023
56c6278
Enum fixes (#93)
HaseenaSainul Jun 1, 2023
57550c1
Types and Accessor related fixes (#94)
HaseenaSainul Jun 5, 2023
3ab8bad
Static code implementation updates (#96)
HaseenaSainul Jun 8, 2023
0e742f2
Add support to generate file inclusion for common schema also (#97)
HaseenaSainul Jun 15, 2023
99c0033
C-Language: Templates based property methods (#100)
sramani-metro Jun 20, 2023
133f8e3
Add support to keep original file permissions of template/sdk files (…
HaseenaSainul Jun 22, 2023
b5528f8
Event template implementation added (#101)
HaseenaSainul Jun 22, 2023
d08f0d2
Template for Polymorphic pull method (#102)
sramani-metro Jun 22, 2023
757fc46
fix: Promote and name sub-schemas in one place
jlacivita Jul 5, 2023
1186b96
fix: Add extractSubSchemas flag to C language
jlacivita Jul 5, 2023
b1dbf18
fix: Uncomment writeFilePermissions
jlacivita Jul 5, 2023
aa321aa
polymorphic-pull: method and event implementation added (#107)
HaseenaSainul Jul 10, 2023
e73a67a
SchemaSorting: logic updated to consider all schemas (#106)
HaseenaSainul Jul 10, 2023
6015caf
fix: Fix the reentrancy of methods from callback (#105)
sramani-metro Jul 11, 2023
2f3b237
Default template implementation added (#103)
HaseenaSainul Jul 11, 2023
8b1e5fc
Naming + void* to struct* changes based on sky review, removed redund…
HaseenaSainul Jul 12, 2023
76d9009
language-c: re-arrange files locations (#112)
HaseenaSainul Jul 17, 2023
2f866c2
fixes to generate array inside subschemas (#111)
HaseenaSainul Jul 17, 2023
f9c324e
include test always (#113)
HaseenaSainul Jul 17, 2023
31ddf5e
use String type if there is any issue with anyOf merge (#114)
HaseenaSainul Jul 17, 2023
eb0023b
calls-metrics: support added (#115)
HaseenaSainul Jul 17, 2023
06f0f39
Generate polymorphci methods for anyOf param/result case (#110)
HaseenaSainul Jul 17, 2023
260fa65
Create namespaces only if there is value to put (#117)
HaseenaSainul Jul 24, 2023
a6eb5df
Changes to avoid duplication of sub-array schema with same reference …
HaseenaSainul Jul 24, 2023
f8faf1f
detach setter declaration from property template and add setter templ…
HaseenaSainul Jul 26, 2023
1563c64
SubArray generation issue fix (#121)
HaseenaSainul Aug 7, 2023
3c9a909
cmake changes to install proper files (#119)
HaseenaSainul Aug 7, 2023
46a8a1c
Merge branch 'feature/c-language' of https://github.com/rdkcentral/fi…
jlacivita Aug 11, 2023
6a0f4e6
native code: changed return type from uint32_t to int32_t (#127)
HaseenaSainul Aug 15, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
789 changes: 789 additions & 0 deletions languages/c/Types.mjs

Large diffs are not rendered by default.

18 changes: 18 additions & 0 deletions languages/c/language.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "C",
"langcode": "c",
"createModuleDirectories": false,
"extractSubSchemas": true,
"templatesPerModule": [
"/include/module.h",
"/src/module.cpp"
],
"templatesPerSchema": [
"/include/common/module.h",
"/src/module_common.cpp",
"/src/jsondata_module.h"
],
"persistPermission": true,
"createPolymorphicMethods": true,
"excludeDeclarations":true
}
19 changes: 19 additions & 0 deletions languages/c/src/index.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
* Copyright 2021 Comcast Cable Communications Management, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* SPDX-License-Identifier: Apache-2.0
*/

export { default as Transport } from './shared/Transport/index.mjs'
56 changes: 56 additions & 0 deletions languages/c/src/shared/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Copyright 2023 Comcast Cable Communications Management, LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0

cmake_minimum_required(VERSION 3.3)

project(Firebolt)

set(FIREBOLT_TRANSPORT_WAITTIME 1000 CACHE STRING "Maximum time to wait for Transport layer to get response")
set(FIREBOLT_LOGLEVEL "Info" CACHE STRING "Log level to be enabled")
option(FIREBOLT_ENABLE_STATIC_LIB "Create Firebolt library as Static library" OFF)
option(ENABLE_TESTS "Build openrpc native test" OFF)

if (FIREBOLT_ENABLE_STATIC_LIB)
set(FIREBOLT_LIBRARY_TYPE STATIC)
else ()
set(FIREBOLT_LIBRARY_TYPE SHARED)
endif ()

if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX "${SYSROOT_PATH}/usr" CACHE INTERNAL "" FORCE)
set(CMAKE_PREFIX_PATH ${SYSROOT_PATH}/usr/lib/cmake CACHE INTERNAL "" FORCE)
endif()

list(APPEND CMAKE_MODULE_PATH
"${CMAKE_SOURCE_DIR}/cmake"
"${SYSROOT_PATH}/usr/lib/cmake"
"${SYSROOT_PATH}/tools/cmake")
include(HelperFunctions)

set(FIREBOLT_NAMESPACE ${PROJECT_NAME} CACHE STRING "Namespace of the project")

find_package(WPEFramework CONFIG REQUIRED)

add_subdirectory(src)

if (ENABLE_TESTS)
add_subdirectory(test)
endif()

# make sure others can make use cmake settings of Firebolt OpenRPC
configure_file( "${CMAKE_SOURCE_DIR}/cmake/project.cmake.in"
"${CMAKE_BINARY_DIR}/${FIREBOLT_NAMESPACE}Config.cmake"
@ONLY)
72 changes: 72 additions & 0 deletions languages/c/src/shared/cmake/HelperFunctions.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# Copyright 2023 Comcast Cable Communications Management, LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0

macro(GetSubDirs subdirs currentdir)
file(GLOB subdirectories RELATIVE ${currentdir} ${currentdir}/*)
set(subdirs "")
foreach(subdir ${subdirectories})
if (IS_DIRECTORY ${currentdir}/${subdir})
list(APPEND subdirs ${subdir})
endif()
endforeach()
endmacro()

function(InstallHeaders)
set(optionsArgs EXCLUDE_ROOT_DIR)
set(oneValueArgs TARGET NAMESPACE SOURCE DESTINATION)
set(multiValueArgs HEADERS)

cmake_parse_arguments(Argument "${optionsArgs}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} )
if (Argument_UNPARSED_ARGUMENTS)
message(FATAL_ERROR "Unknown keywords given to InstallHeaders(): \"${Argument_UNPARSED_ARGUMENTS}\"")
endif()
if (Argument_HEADERS)
add_custom_command(
TARGET ${Argument_TARGET}
POST_BUILD
COMMENT "=================== Installing Headers ======================"
)
foreach(directory ${Argument_HEADERS})
if (Argument_EXCLUDE_ROOT_DIR)
set(destination ${Argument_DESTINATION})
else()
set(destination ${Argument_DESTINATION}/${directory})
endif()

if (Argument_SOURCE)
set(source ${Argument_SOURCE})
else()
set(source ${CMAKE_CURRENT_LIST_DIR})
endif()

GetSubDirs(subdirs ${source}/${directory})
list(APPEND subdirs ${directory})

foreach(subdir ${subdirs})
if (NOT subdir STREQUAL ".")
set(dest ${destination}/${subdir})
file(GLOB headers "${source}/${directory}/${subdir}/*.h")
if (headers)
install(
DIRECTORY "${source}/${directory}/${subdir}"
DESTINATION include/${dest}
FILES_MATCHING PATTERN "*.h")
endif()
endif()
endforeach(subdir)
endforeach(directory)
endif()
endfunction(InstallHeaders)
35 changes: 35 additions & 0 deletions languages/c/src/shared/cmake/project.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Copyright 2023 Comcast Cable Communications Management, LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0

set(FIREBOLT_NAMESPACE "@FIREBOLT_NAMESPACE@" CACHE INTERNAL "" FORCE)
set("${FIREBOLT_NAMESPACE}_FOUND" TRUE CACHE INTERNAL "" FORCE)

list(APPEND CMAKE_MODULE_PATH
"${CMAKE_SOURCE_DIR}/cmake"
"${SYSROOT_PATH}/usr/lib/cmake"
"${SYSROOT_PATH}/usr/lib/cmake/Firebolt"
"${SYSROOT_PATH}/tools/cmake")

if (NOT DEFINED CMAKE_PREFIX_PATH)
set(CMAKE_PREFIX_PATH ${SYSROOT_PATH}/usr/lib/cmake CACHE INTERNAL "" FORCE)
endif()

if (FIREBOLT_ENABLE_STATIC_LIB)
set(FIREBOLT_LIBRARY_TYPE STATIC)
else ()
set(FIREBOLT_LIBRARY_TYPE SHARED)
endif ()

41 changes: 41 additions & 0 deletions languages/c/src/shared/include/error.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* Copyright 2023 Comcast Cable Communications Management, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* SPDX-License-Identifier: Apache-2.0
*/

#ifndef FIREBOLT_ERROR_H
#define FIREBOLT_ERROR_H

#ifdef __cplusplus
extern "C" {
#endif

typedef enum FireboltSDKError {
FireboltSDKErrorNone = 0,
FireboltSDKErrorGeneral = 1,
FireboltSDKErrorUnavailable = 2,
FireboltSDKErrorTimedout = 3,
FireboltSDKErrorNotSubscribed = 4,
FireboltSDKErrorUnknown = 5,
FireboltSDKErrorInUse = 6,
FireboltSDKErrorNotSupported = 7
} FireboltSDKError_t;

#ifdef __cplusplus
}
#endif

#endif // FIREBOLT_ERROR_H
68 changes: 68 additions & 0 deletions languages/c/src/shared/include/firebolt.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/*
* Copyright 2023 Comcast Cable Communications Management, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* SPDX-License-Identifier: Apache-2.0
*/

#ifndef FIREBOLT_H
#define FIREBOLT_H

#include "error.h"
#include "types.h"

#ifdef __cplusplus
extern "C" {
#endif

#define IN
#define OUT

/**
* @brief Intitialize the Firebolt SDK
*
* @param configLine JSON String with configuration options
*
* CONFIG Format:
* {
* "waitTime": 1000,
* "logLevel": "Info",
* "workerPool":{
* "queueSize": 8,
* "threadCount": 3
* },
* "wsUrl": "ws://127.0.0.1:9998"
* }
*
*
* @return FireboltSDKErrorNone if success, appropriate error otherwise.
*
*/
uint32_t FireboltSDK_Initialize(char* configLine);


/**
* @brief Deintitialize the Firebolt SDK
*
* @return FireboltSDKErrorNone if success, appropriate error otherwise.
*
*/
uint32_t FireboltSDK_Deinitialize(void);

#ifdef __cplusplus
}
#endif


#endif // FIREBOLT_H
37 changes: 37 additions & 0 deletions languages/c/src/shared/include/types.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Copyright 2023 Comcast Cable Communications Management, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* SPDX-License-Identifier: Apache-2.0
*/

#ifndef FIREBOLT_TYPES_H
#define FIREBOLT_TYPES_H

#include <stdint.h>
#include <stdbool.h>

#ifdef __cplusplus
extern "C" {
#endif

typedef struct Firebolt_String_s* Firebolt_String_t;
const char* Firebolt_String(Firebolt_String_t handle);
void Firebolt_String_Release(Firebolt_String_t handle);

#ifdef __cplusplus
}
#endif

#endif // FIREBOLT_TYPES_H
Loading