def test_incremental(self): param = ParameterSymbol(type_tokens=[Link(None, "test-struct", "test-struct")]) func = self.doc_database.get_or_create_symbol( FunctionSymbol, unique_name="test-symbol", filename="text_b.x", parameters=[param] ) func.resolve_links(self.link_resolver) self.assertEqual(param.get_type_link().get_link(), None) struct = self.doc_database.get_or_create_symbol(StructSymbol, unique_name="test-struct", filename="test_a.x") struct.resolve_links(self.link_resolver) func.resolve_links(self.link_resolver) # Not in a page but still self.assertEqual(param.get_type_link().get_link(), "test-struct") self.doc_database.persist() self.doc_database.close() self.doc_database = DocDatabase() self.doc_database.setup(self.__priv_dir) self.link_resolver = LinkResolver(self.doc_database) param = ParameterSymbol(type_tokens=[Link(None, "test-struct", "test-struct")]) func = self.doc_database.get_or_create_symbol( FunctionSymbol, unique_name="test-symbol", filename="text_b.x", parameters=[param] ) func.resolve_links(self.link_resolver) self.assertEqual(param.get_type_link().get_link(), "test-struct")
def __create_signal_symbol(self, obj, parent_uniquename, name, signal, element_name, parent_name=None): atypes = signal['args'] instance_type = obj['hierarchy'][0] unique_name = "%s::%s" % (parent_uniquename, name) aliases = self._get_aliases(["%s::%s" % (instance_type, name)]) gi_extension = self.project.extensions.get('gi-extension') python_lang = gi_extension.get_language('python') args_type_names = [] args_type_names = [ (type_tokens_from_type_name('GstElement', python_lang), 'param_0') ] for i, _ in enumerate(atypes): args_type_names.append( (type_tokens_from_type_name(atypes[i], python_lang), 'param_%s' % (i + 1))) args_type_names.append( (type_tokens_from_type_name('gpointer', python_lang), "udata")) params = [] for comment_name in [unique_name] + aliases: comment = self.app.database.get_comment(comment_name) if comment: for i, argname in enumerate(comment.params.keys()): args_type_names[i] = (args_type_names[i][0], argname) for tokens, argname in args_type_names: params.append(ParameterSymbol(argname=argname, type_tokens=tokens)) type_name = signal['retval'] if type_name == 'void': retval = [None] else: tokens = type_tokens_from_type_name(type_name, python_lang) enum = signal.get('return-values') if enum: self.__create_enum_symbol(type_name, enum, obj.get('name', parent_uniquename), parent_name=parent_name) retval = [ReturnItemSymbol(type_tokens=tokens)] return self.create_symbol(SignalSymbol, parameters=params, return_value=retval, display_name=name, unique_name=unique_name, extra={'gst-element-name': element_name}, aliases=aliases, parent_name=parent_name)
def test_incremental(self): param = ParameterSymbol( type_tokens=[Link(None, 'test-struct', 'test-struct')]) func = self.database.get_or_create_symbol( FunctionSymbol, unique_name='test-symbol', filename='text_b.x', parameters=[param]) func.resolve_links(self.link_resolver) self.assertEqual(param.get_type_link().get_link(self.link_resolver), None) struct = self.database.get_or_create_symbol( StructSymbol, unique_name='test-struct', filename='test_a.x') struct.resolve_links(self.link_resolver) func.resolve_links(self.link_resolver) # Not in a page but still self.assertEqual(param.get_type_link().get_link(self.link_resolver), 'test-struct') self.database.persist() self.database.close() self.database = Database() self.database.setup(self.__priv_dir) self.link_resolver = LinkResolver(self.database) param = ParameterSymbol( type_tokens=[Link(None, 'test-struct', 'test-struct')]) func = self.database.get_or_create_symbol( FunctionSymbol, unique_name='test-symbol', filename='text_b.x', parameters=[param]) func.resolve_links(self.link_resolver) self.assertEqual(param.get_type_link().get_link(self.link_resolver), 'test-struct')
def __create_signal_symbol(self, obj, parent_uniquename, name, signal, pagename, parent_name=None): args = signal['args'] instance_type = obj['hierarchy'][0] unique_name = "%s::%s" % (parent_uniquename, name) aliases = ["%s::%s" % (instance_type, name)] gi_extension = self.project.extensions.get('gi-extension') python_lang = gi_extension.get_language('python') args_type_names = [ (type_tokens_from_type_name('GstElement', python_lang), 'param_0') ] for arg in args: arg_name = arg["name"] arg_type_name = self._remember_symbol_type(arg["type"], pagename) type_tokens = type_tokens_from_type_name(arg_type_name, python_lang) args_type_names.append((type_tokens, arg_name)) if not signal.get('action'): args_type_names.append( (type_tokens_from_type_name('gpointer', python_lang), "udata")) params = [] for comment_name in [unique_name] + aliases: comment = self.app.database.get_comment(comment_name) if comment: for i, argname in enumerate(comment.params.keys()): args_type_names[i] = (args_type_names[i][0], argname) for tokens, argname in args_type_names: params.append(ParameterSymbol(argname=argname, type_tokens=tokens)) return_type_name = self._remember_symbol_type(signal["return-type"], pagename) if return_type_name == 'void': retval = [None] else: tokens = type_tokens_from_type_name(return_type_name, python_lang) retval = [ReturnItemSymbol(type_tokens=tokens)] if signal.get('action'): typ = ActionSignalSymbol for param in params: self.add_attrs(param, action=True) else: typ = SignalSymbol res = self.create_symbol(typ, parameters=params, return_value=retval, display_name=name, unique_name=unique_name, extra={'gst-element-name': pagename}, aliases=aliases, parent_name=parent_name) if res: flags = [] when = signal.get('when') if when == "first": flags.append(gi.flags.RunFirstFlag()) elif when == "last": flags.append(gi.flags.RunLastFlag()) elif when == "cleanup": flags.append(gi.flags.RunCleanupFlag()) no_hooks = signal.get('no-hooks') if no_hooks: flags.append(gi.flags.NoHooksFlag()) action = signal.get('action') if action: flags.append(gi.flags.ActionFlag()) # This is incorrect, it's not yet format time extra_content = self.formatter.format_flags(flags) res.extension_contents['Flags'] = extra_content return res
def __create_signal_symbol(self, obj, parent_uniquename, name, signal, element_name, parent_name=None): atypes = signal['args'] instance_type = obj['hierarchy'][0] unique_name = "%s::%s" % (parent_uniquename, name) aliases = self._get_aliases(["%s::%s" % (instance_type, name)]) gi_extension = self.project.extensions.get('gi-extension') python_lang = gi_extension.get_language('python') args_type_names = [] args_type_names = [ (type_tokens_from_type_name('GstElement', python_lang), 'param_0') ] for i, _ in enumerate(atypes): args_type_names.append( (type_tokens_from_type_name(atypes[i], python_lang), 'param_%s' % (i + 1))) args_type_names.append( (type_tokens_from_type_name('gpointer', python_lang), "udata")) params = [] for comment_name in [unique_name] + aliases: comment = self.app.database.get_comment(comment_name) if comment: for i, argname in enumerate(comment.params.keys()): args_type_names[i] = (args_type_names[i][0], argname) for tokens, argname in args_type_names: params.append(ParameterSymbol(argname=argname, type_tokens=tokens)) type_name = signal['retval'] if type_name == 'void': retval = [None] else: tokens = type_tokens_from_type_name(type_name, python_lang) enum = signal.get('return-values') if enum: self.__create_enum_symbol(type_name, enum, obj.get('name', parent_uniquename), parent_name=parent_name) retval = [ReturnItemSymbol(type_tokens=tokens)] res = self.create_symbol(SignalSymbol, parameters=params, return_value=retval, display_name=name, unique_name=unique_name, extra={'gst-element-name': element_name}, aliases=aliases, parent_name=parent_name) if res: flags = [] when = signal.get('when') if when == "first": flags.append(gi.flags.RunFirstFlag()) elif when == "last": flags.append(gi.flags.RunLastFlag()) elif when == "cleanup": flags.append(gi.flags.RunCleanupFlag()) no_hooks = signal.get('no-hooks') if no_hooks: flags.append(gi.flags.NoHooksFlag()) action = signal.get('action') if action: flags.append(gi.flags.ActionFlag()) # This is incorrect, it's not yet format time extra_content = self.formatter.format_flags(flags) res.extension_contents['Flags'] = extra_content return res