def writeConstantCode(self, constant, localvars):
    lines = []
    ws = localvars['ws']
    if (not isinstance(constant, autosar.constant.Constant)):
        raise ValueError('expected type autosar.constant.Constant')
    if (constant.value is not None):
        dataType = ws.find(constant.value.typeRef, role='DataType')
        constructor = None
        if (dataType is None):
            raise ValueError(('invalid reference: ' + constant.value.typeRef))
        if isinstance(constant.value, autosar.constant.ArrayValue):
            initValue = self._writeArrayValueConstantCode(constant.value, localvars)
        elif isinstance(constant.value, autosar.constant.IntegerValue):
            initValue = self._writeIntegerValueConstantCode(constant.value, localvars)
        elif isinstance(constant.value, autosar.constant.StringValue):
            initValue = self._writeStringValueConstantCode(constant.value, localvars)
        elif isinstance(constant.value, autosar.constant.BooleanValue):
            initValue = self._writeBooleanValueConstantCode(constant.value, localvars)
        elif isinstance(constant.value, autosar.constant.RecordValue):
            initValue = self._writeRecordValueConstantCode(constant.value, localvars)
        else:
            raise ValueError(('unknown value type: ' + type(constant.value)))
        params = [repr(constant.name)]
        if (ws.roles['DataType'] is not None):
            params.append(repr(dataType.name))
        else:
            params.append(repr(dataType.ref))
        if (initValue is not None):
            if isinstance(initValue, list):
                lines.extend(self.writeDictCode('initValue', initValue))
                params.append('initValue')
            else:
                params.append(initValue)
        else:
            print(constant.name)
        if (constant.adminData is not None):
            param = self.writeAdminDataCode(constant.adminData, localvars)
            assert (len(param) > 0)
            params.append(('adminData=' + param))
        lines.append(('package.createConstant(%s)' % ', '.join(params)))
    return lines
def writeConstantCode(self, constant, localvars):
    lines = []
    ws = localvars['ws']
    if (not isinstance(constant, autosar.constant.Constant)):
        raise ValueError('expected type autosar.constant.Constant')
    if (constant.value is not None):
        dataType = ws.find(constant.value.typeRef, role='DataType')
        constructor = None
        if (dataType is None):
            raise ValueError(('invalid reference: ' + constant.value.typeRef))
        if isinstance(constant.value, autosar.constant.ArrayValue):
            initValue = self._writeArrayValueConstantCode(constant.value, localvars)
        elif isinstance(constant.value, autosar.constant.IntegerValue):
            initValue = self._writeIntegerValueConstantCode(constant.value, localvars)
        elif isinstance(constant.value, autosar.constant.StringValue):
            initValue = self._writeStringValueConstantCode(constant.value, localvars)
        elif isinstance(constant.value, autosar.constant.BooleanValue):
            initValue = self._writeBooleanValueConstantCode(constant.value, localvars)
        elif isinstance(constant.value, autosar.constant.RecordValue):
            initValue = self._writeRecordValueConstantCode(constant.value, localvars)
        else:
            raise ValueError(('unknown value type: ' + type(constant.value)))
        params = [repr(constant.name)]
        if (ws.roles['DataType'] is not None):
            params.append(repr(dataType.name))
        else:
            params.append(repr(dataType.ref))
        if (initValue is not None):
            if isinstance(initValue, list):
                lines.extend(self.writeDictCode('initValue', initValue))
                params.append('initValue')
            else:
                params.append(initValue)
        else:
            print(constant.name)
        if (constant.adminData is not None):
            param = self.writeAdminDataCode(constant.adminData, localvars)
            assert (len(param) > 0)
            params.append(('adminData=' + param))
        lines.append(('package.createConstant(%s)' % ', '.join(params)))
    return lines