Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ endif()
set(GENERATOR_INSTALL_PATH "${CMAKE_INSTALL_INCLUDEDIR}/${NAMESPACE}" CACHE PATH "Location to install the generators.")
set(GENERATOR_MODULE_INSTALL_PATH "${GENERATOR_INSTALL_PATH}/Modules" CACHE INTERNAL "Location where to install the generator cmake modules")

option(JSON_GENERATOR_ENABLE_STATS "Globally enable JSON-RPC stats" OFF)
option(PROXYSTUB_GENERATOR_ENABLE_SECURITY "Globally enable security checks in proxystubs" OFF)
option(PROXYSTUB_GENERATOR_ENABLE_COHERENCY "Globally enable frame coherency checks in proxystubs" OFF)

Expand Down
9 changes: 9 additions & 0 deletions JsonGenerator/source/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ def Parse(cmdline):
global AUTO_PREFIX
global DEFAULT_CASE_CONVENTION
global IGNORE_SOURCE_CASE_CONVENTION
global STATS_FOR_NERDS

argparser = argparse.ArgumentParser(
description='Generate JSON C++ classes, stub code and API documentation from JSON definition files and C++ header files',
Expand Down Expand Up @@ -154,6 +155,12 @@ def Parse(cmdline):
action="store_true",
default=False,
help= "disable all warnings (default: warnings enabled)")
argparser.add_argument(
"--stats",
dest="stats",
action="store_true",
default=False,
help= "regiter version with extra stats (default: stats enabled)")

json_group = argparser.add_argument_group("JSON parser arguments (optional)")
json_group.add_argument("-i",
Expand Down Expand Up @@ -389,6 +396,8 @@ def Parse(cmdline):
if "force" in args.format:
RPC_FORMAT_FORCED = True

STATS_FOR_NERDS = args.stats

NO_INCLUDES = args.no_includes
NO_VERSIONING = args.no_versioning
NO_PUSH_WARNING = args.no_push_warning
Expand Down
13 changes: 12 additions & 1 deletion JsonGenerator/source/rpc_emitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -1696,12 +1696,15 @@ def _Invoke(method, conditional_invoke, sorted_vars, params, response, parent=""

methods_and_properties = [x for x in root.properties if not isinstance(x, (JsonNotification))]
methods = [x for x in methods_and_properties if not isinstance(x, (JsonNotification, JsonProperty))]
properties = [x for x in methods_and_properties if isinstance(x, (JsonProperty))]
events = [x for x in root.properties if isinstance(x, JsonNotification)]
async_events = []
async_methods = []
listener_events = [x for x in events if x.is_status_listener]
auto_lookup_events = [x for x in events if "@lookup" in x.schema and x.schema["@lookup"].get("id") == "generate"]
custom_lookup_events = [x for x in events if "@lookup" in x.schema and x.schema["@lookup"].get("id") == "custom"]
alt_methods = [x for x in methods if x.alternative]
alt_properties = [x for x in properties if x.alternative]
alt_events = [x for x in events if x.alternative]
lookup_methods = [x for x in methods_and_properties if x.schema.get("@lookup)")]

Expand Down Expand Up @@ -1831,7 +1834,15 @@ def _Invoke(method, conditional_invoke, sorted_vars, params, response, parent=""
emit.Line("ASSERT(%s.template Exists<%s>() == true);" % (names.module, trim(i["fullname"])))
emit.Line()

emit.Line("%s.PluginHost::JSONRPC::RegisterVersion(%s, Version::Major, Version::Minor, Version::Patch);" % (names.module, Tstring(names.namespace)))
version_info = [ Tstring(names.namespace), "Version::Major", "Version::Minor", "Version::Patch" ]

if config.STATS_FOR_NERDS:
method_count = len(methods) + len(alt_methods)
property_count = len(properties) + len(alt_properties)
event_count = len(events) + len(alt_events)
version_info.extend([str(method_count), str(property_count), str(event_count)])

emit.Line("%s.PluginHost::JSONRPC::RegisterVersion(%s);" % (names.module, ", ".join(version_info)))

if auto_lookup_interfaces:
emit.Line()
Expand Down
6 changes: 5 additions & 1 deletion cmake/FindJsonGenerator.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function(JsonGenerator)
message(FATAL_ERROR "JsonGenerator path ${JSON_GENERATOR} invalid.")
endif()

set(optionsArgs CODE STUBS DOCS LEGACY_ALT AUTO_PREFIX NO_INCLUDES NO_WARNINGS NO_STYLE_WARNINGS DUPLICATE_OBJ_WARNINGS COPY_CTOR NO_REF_NAMES NO_INTERFACES_SECTION VERBOSE FORCE_GENERATE EMIT_INTERFACE_PATH IGNORE_CASE_CONVENTION)
set(optionsArgs CODE STUBS DOCS LEGACY_ALT AUTO_PREFIX NO_INCLUDES NO_WARNINGS NO_STYLE_WARNINGS DUPLICATE_OBJ_WARNINGS COPY_CTOR NO_REF_NAMES NO_INTERFACES_SECTION VERBOSE FORCE_GENERATE EMIT_INTERFACE_PATH IGNORE_CASE_CONVENTION STATS)
set(oneValueArgs OUTPUT CPP_OUTPUT INDENT DEF_STRING DEF_INT_SIZE PATH FORMAT CPP_INTERFACE_PATH JSON_INTERFACE_PATH FRAMEWORK_NAMESPACE CASE_CONVENTION)
set(multiValueArgs INPUT IFDIR CPPIFDIR INCLUDE_PATH NAMESPACE)

Expand Down Expand Up @@ -104,6 +104,10 @@ function(JsonGenerator)
list(APPEND _execute_command "--emit-cpp-interface-path")
endif()

if(Argument_STATS OR @JSON_GENERATOR_ENABLE_STATS@)
list(APPEND _execute_command "--stats")
endif()

if (Argument_PATH)
list(APPEND _execute_command "-p" "${Argument_PATH}")
endif()
Expand Down
Loading