2018-06-17 01:59:39 +08:00
|
|
|
#
|
|
|
|
# Copyright (c) 2018 Bobby Noelte
|
|
|
|
#
|
|
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
#
|
|
|
|
|
|
|
|
from extract.globals import *
|
|
|
|
from extract.directive import DTDirective
|
|
|
|
|
|
|
|
##
|
|
|
|
# @brief Manage directives in a default way.
|
|
|
|
#
|
|
|
|
class DTDefault(DTDirective):
|
|
|
|
|
|
|
|
def __init__(self):
|
|
|
|
pass
|
|
|
|
|
|
|
|
##
|
|
|
|
# @brief Extract directives in a default way
|
|
|
|
#
|
|
|
|
# @param node_address Address of node owning the clockxxx definition.
|
|
|
|
# @param prop property name
|
2018-10-19 05:42:45 +08:00
|
|
|
# @param prop type (string, boolean, etc)
|
2018-06-17 01:59:39 +08:00
|
|
|
# @param def_label Define label string of node owning the directive.
|
|
|
|
#
|
2018-12-05 03:26:05 +08:00
|
|
|
def extract(self, node_address, prop, prop_type, def_label):
|
2018-06-17 01:59:39 +08:00
|
|
|
prop_def = {}
|
|
|
|
prop_alias = {}
|
2018-10-19 05:42:45 +08:00
|
|
|
|
|
|
|
if prop_type == 'boolean':
|
2019-02-07 01:12:09 +08:00
|
|
|
if prop in reduced[node_address]['props']:
|
2018-10-19 05:42:45 +08:00
|
|
|
prop_values = 1
|
|
|
|
else:
|
|
|
|
prop_values = 0
|
|
|
|
else:
|
|
|
|
prop_values = reduced[node_address]['props'][prop]
|
2018-06-17 01:59:39 +08:00
|
|
|
|
|
|
|
if isinstance(prop_values, list):
|
|
|
|
for i, prop_value in enumerate(prop_values):
|
|
|
|
prop_name = convert_string_to_label(prop)
|
|
|
|
label = def_label + '_' + prop_name
|
|
|
|
if isinstance(prop_value, str):
|
|
|
|
prop_value = "\"" + prop_value + "\""
|
|
|
|
prop_def[label + '_' + str(i)] = prop_value
|
2019-01-11 03:31:39 +08:00
|
|
|
add_compat_alias(node_address,
|
|
|
|
prop_name + '_' + str(i),
|
|
|
|
label + '_' + str(i),
|
|
|
|
prop_alias)
|
2018-06-17 01:59:39 +08:00
|
|
|
else:
|
|
|
|
prop_name = convert_string_to_label(prop)
|
|
|
|
label = def_label + '_' + prop_name
|
|
|
|
|
|
|
|
if prop_values == 'parent-label':
|
|
|
|
prop_values = find_parent_prop(node_address, 'label')
|
|
|
|
|
|
|
|
if isinstance(prop_values, str):
|
|
|
|
prop_values = "\"" + prop_values + "\""
|
|
|
|
prop_def[label] = prop_values
|
2019-01-11 03:31:39 +08:00
|
|
|
add_compat_alias(node_address, prop_name, label, prop_alias)
|
2018-06-17 01:59:39 +08:00
|
|
|
|
|
|
|
# generate defs for node aliases
|
|
|
|
if node_address in aliases:
|
2018-11-01 02:19:54 +08:00
|
|
|
add_prop_aliases(
|
|
|
|
node_address,
|
|
|
|
lambda alias:
|
|
|
|
convert_string_to_label(alias) + '_' + prop_name,
|
|
|
|
label,
|
|
|
|
prop_alias)
|
2018-06-17 01:59:39 +08:00
|
|
|
|
2018-07-04 17:24:07 +08:00
|
|
|
insert_defs(node_address, prop_def, prop_alias)
|
2018-06-17 01:59:39 +08:00
|
|
|
|
|
|
|
##
|
|
|
|
# @brief Management information for directives handled by default.
|
|
|
|
default = DTDefault()
|