⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bgenvariable.py

📁 reduced python source for embedded apps
💻 PY
字号:
"""Variables, arguments and argument transfer modes etc."""# Values to represent argument transfer modesInMode    = 1 # input-only argumentOutMode   = 2 # output-only argumentInOutMode = 3 # input-output argumentModeMask  = 3 # bits to keep for mode# Special cases for mode/flags argument# XXX This is still a mess!SelfMode   =  4+InMode  # this is 'self' -- don't declare itReturnMode =  8+OutMode # this is the function return valueErrorMode  = 16+OutMode # this is an error status -- turn it into an exceptionclass Variable:	"""A Variable holds a type, a name, a transfer mode and flags.	Most of its methods call the correponding type method with the	variable name.	"""	def __init__(self, type, name = None, flags = InMode):		"""Call with a type, a name and flags.		If name is None, it muse be set later.		flags defaults to InMode.		"""		self.type = type		self.name = name		self.flags = flags		self.mode = flags & ModeMask	def declare(self):		"""Declare the variable if necessary.		If it is "self", it is not declared.		"""		if self.flags != SelfMode:			self.type.declare(self.name)	def getargsFormat(self):		"""Call the type's getargsFormatmethod."""		return self.type.getargsFormat()	def getargsArgs(self):		"""Call the type's getargsArgsmethod."""		return self.type.getargsArgs(self.name)	def getargsCheck(self):		return self.type.getargsCheck(self.name)	def passArgument(self):		"""Return the string required to pass the variable as argument.		For "in" arguments, return the variable name.		For "out" and "in out" arguments,		return its name prefixed with "&".		"""		if self.mode == InMode:			return self.type.passInput(self.name)		if self.mode in (OutMode, InOutMode):			return self.type.passOutput(self.name)		# XXX Shouldn't get here		return "/*mode?*/" + self.type.passInput(self.name)	def errorCheck(self):		"""Check for an error if necessary.		This only generates code if the variable's mode is ErrorMode.		"""		if self.flags == ErrorMode:			self.type.errorCheck(self.name)	def mkvalueFormat (self):		"""Call the type's mkvalueFormat method."""		return self.type.mkvalueFormat()	def mkvalueArgs(self):		"""Call the type's mkvalueArgs method."""		return self.type.mkvalueArgs(self.name)	def cleanup(self):		"""Call the type's cleanup method."""		return self.type.cleanup(self.name)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -