text:
Python Parser
=============

Setup
-----

Set up a test environment. Create a temporary directory and copy
``parseme.py`` file into it::

    >>> import os
    >>> modulepath = os.path.join(datadir, 'parseme.py')

Test parsing
------------

Create a ``Module``. ``name`` is the abspath of the destination Python file, if
it already exists, read and parse it::

    >>> from node.ext.python import Module

Disable auto parsing::

    >>> Module._do_parse = False

Factor ``Module``::

    >>> module = Module(modulepath)
    >>> module
    <Module object '.../parseme.py' at ...>

Now simulate the contents of ``Module._parse()`` and check the results. Read
the existing file and write to ``Module._buffer``::

    >>> file = open(module.filepath, 'r')
    >>> module._buffer = file.readlines()
    >>> file.close()
    >>> module.buffer
    ['# -*- coding: utf-8 -*-\n',
    ...]

Extract the module name::

    >>> module.readlines = list()
    >>> module.modulename
    u'parseme'

Extract file encoding::

    >>> module.parser._extractencoding()
    >>> module.encoding
    u'utf-8'

Set pointer Attributes on module::

    >>> module.bufstart = 0
    >>> module.bufend = len(module._buffer)

Parse the abstract syntax tree::

    >>> import ast
    >>> module.astnode = ast.parse(''.join(module.buffer))

Convert ``Module._buffer`` to ``unicode`` and strip new lines::

    >>> module._buffer = [unicode(l.strip('\n')) \
    ...                   for l in module._buffer]

Parse ``ProtectedSection`` objects from ``PythonNode.buffer``::

    >>> sections = module.parser._protectedsections()
    >>> for node in sections:
    ...     module.parser._marklines(*range(node.bufstart, node.bufend))

Hook ast children::

    >>> for astnode in module.astnode.body:
    ...     module.parser._createastchild(astnode)
    >>> module.parser._markastrelated(module)

    >>> module.printtree()
    <class 'node.ext.python.nodes.Module'>: [1:194] - -1
      <class 'node.ext.python.nodes.Docstring'>: [5:8] - 0
      <class 'node.ext.python.nodes.Docstring'>: [10:10] - 0
      <class 'node.ext.python.nodes.Import'>: [12:12] - 0
      <class 'node.ext.python.nodes.Import'>: [13:13] - 0
      <class 'node.ext.python.nodes.Import'>: [14:14] - 0
      <class 'node.ext.python.nodes.Import'>: [15:15] - 0
      <class 'node.ext.python.nodes.Import'>: [16:16] - 0
      <class 'node.ext.python.nodes.Function'>: [81:82] - 0
      <class 'node.ext.python.nodes.Attribute'>: [86:86] - 0
      <class 'node.ext.python.nodes.Attribute'>: [88:88] - 0
      <class 'node.ext.python.nodes.Attribute'>: [90:92] - 0
      <class 'node.ext.python.nodes.Attribute'>: [94:99] - 0
      <class 'node.ext.python.nodes.Attribute'>: [101:103] - 0
      <class 'node.ext.python.nodes.Attribute'>: [105:105] - 0
      <class 'node.ext.python.nodes.Attribute'>: [107:107] - 0
      <class 'node.ext.python.nodes.Attribute'>: [109:109] - 0
      <class 'node.ext.python.nodes.Function'>: [115:116] - 0
        <class 'node.ext.python.nodes.Decorator'>: [114:114] - 0
      <class 'node.ext.python.nodes.Function'>: [122:125] - 0
      <class 'node.ext.python.nodes.Class'>: [127:144] - 0
        <class 'node.ext.python.nodes.Docstring'>: [128:129] - 1
        <class 'node.ext.python.nodes.Attribute'>: [131:131] - 1
        <class 'node.ext.python.nodes.Attribute'>: [132:132] - 1
        <class 'node.ext.python.nodes.Function'>: [137:140] - 1
          <class 'node.ext.python.nodes.Docstring'>: [138:139] - 2
        <class 'node.ext.python.nodes.Function'>: [143:144] - 1
          <class 'node.ext.python.nodes.Decorator'>: [142:142] - 1
      <class 'node.ext.python.nodes.Class'>: [146:160] - 0
        <class 'node.ext.python.nodes.Docstring'>: [147:148] - 1
        <class 'node.ext.python.nodes.Function'>: [157:160] - 1
          <class 'node.ext.python.nodes.Docstring'>: [158:159] - 2
      <class 'node.ext.python.nodes.Class'>: [162:165] - 0
        <class 'node.ext.python.nodes.Docstring'>: [164:165] - 1
      <class 'node.ext.python.nodes.Function'>: [170:171] - 0
        <class 'node.ext.python.nodes.Decorator'>: [167:167] - 0
        <class 'node.ext.python.nodes.Decorator'>: [168:168] - 0
        <class 'node.ext.python.nodes.Decorator'>: [169:169] - 0
      <class 'node.ext.python.nodes.Function'>: [176:177] - 0
        <class 'node.ext.python.nodes.Decorator'>: [173:175] - 0
      <class 'node.ext.python.nodes.Import'>: [179:180] - 0
      <class 'node.ext.python.nodes.Import'>: [182:185] - 0
      <class 'node.ext.python.nodes.Import'>: [187:187] - 0
      <class 'node.ext.python.nodes.Function'>: [189:194] - 0
        <class 'node.ext.python.nodes.Docstring'>: [190:191] - 1

Parse Code Blocks and hook children::

    >>> children = sections + module.parser._parsecodeblocks()
    >>> module.parser._hookchildren(children)

Check pointers of ``ProtectedSection``. Case filled::

    >>> sec = sections[0]
    >>> sec.buffer[sec.bufstart:sec.bufend]
    [u'##code-section module',
    u"print 'something'",
    u'##/code-section module']
    >>> sec.bufstart, sec.bufend, sec.startlineno, sec.endlineno, sec.indent
    (117, 120, 118, 120, 0)

Check pointers of ``ProtectedSection``. Case empty::

    >>> sec = sections[1]
    >>> sec.buffer[sec.bufstart:sec.bufend]
    [u'    ##code-section class',
    u'    ##/code-section class']
    >>> sec.bufstart, sec.bufend, sec.startlineno, sec.endlineno, sec.indent
    (133, 135, 134, 135, 1)

Check ``Import.parser._definitionends`` method::

    >>> from node.ext.python import Import
    >>> import_ = Import(buffer=module.buffer)
    >>> import_.buffer[11:12]
    [u'import foo']
    >>> import_.parser._definitionends(11)
    True

    >>> import_.buffer[178:185]
    [u'from foo import bar, \\',
    u'                baz',
    u'',
    u'from baz import (',
    u'    foo,',
    u'    bar,',
    u')']
    >>> import_.parser._definitionends(178)
    False
    >>> import_.parser._definitionends(179)
    True
    >>> import_.parser._definitionends(181)
    False
    >>> import_.parser._definitionends(182)
    False
    >>> import_.parser._definitionends(183)
    False
    >>> import_.parser._definitionends(184)
    True

Check ``Decorator.parser._definitionends`` method::

    >>> from node.ext.python import Decorator
    >>> decorator = Decorator(buffer=module.buffer)
    >>> decorator.buffer[166:169]
    [u"@decorator_1('a')",
    u'@decorator_2(object(1, foo=anothercall()))',
    u'@decorator_3(0)']
    >>> decorator.parser._definitionends(166)
    True
    >>> decorator.parser._definitionends(167)
    True
    >>> decorator.parser._definitionends(168)
    True

    >>> decorator.buffer[172:175]
    [u'@multilinedecorator(a=object,',
    u'                    b=object(),',
    u'                    c=None)']
    >>> decorator.parser._definitionends(172)
    False
    >>> decorator.parser._definitionends(173)
    False
    >>> decorator.parser._definitionends(174)
    True

Check ``Function.parser._definitionends`` method::

    >>> from node.ext.python import Function
    >>> func = Function(buffer=module.buffer)
    >>> func.buffer[114:115]
    [u'def somedecoratedfunction(param):']
    >>> func.parser._definitionends(114)
    True

    >>> func.buffer[121:125]
    [u'def multilinefunctiondef(aa,',
    u'                         bb,',
    u"                         cc='hello'):",
    u'    print a, b, c']

    >>> func.parser._definitionends(121)
    False
    >>> func.parser._definitionends(122)
    False
    >>> func.parser._definitionends(123)
    True

Check ``Class.parser._definitionends`` method::

    >>> from node.ext.python import Class
    >>> class_ = Class(buffer=module.buffer)
    >>> class_.buffer[126:127]
    [u'class SomeClass(object):']
    >>> class_.parser._definitionends(126)
    True

    >>> class_.buffer[145:146]
    [u'class OtherClass(A, B): # some comment']
    >>> class_.parser._definitionends(145)
    True

    >>> class_.buffer[161:163]
    [u'class MultiLineClassDef(A, B,',
    u'                        C, D):']
    >>> class_.parser._definitionends(161)
    False
    >>> class_.parser._definitionends(162)
    True

Check pointers of ``Import``. Case one-liner::

    >>> from node.ext.python.interfaces import IImport
    >>> imports = [i for i in module.filtereditems(IImport)]
    >>> len(imports)
    8

    >>> imp = imports[0]
    >>> imp.buffer[imp.bufstart:imp.bufend]
    [u'import foo']
    >>> imp.bufstart, imp.bufend, imp.startlineno, imp.endlineno, imp.indent
    (11, 12, 12, 12, 0)

Check pointers of ``Import``. Case multi-liner::

    >>> imp = imports[6]
    >>> imp.buffer[imp.bufstart:imp.bufend]
    [u'from baz import (',
    u'    foo,',
    u'    bar,',
    u')']
    >>> imp.bufstart, imp.bufend, imp.startlineno, imp.endlineno, imp.indent
    (181, 185, 182, 185, 0)

Check pointers of ``Function``. Case function def one-liner::

    >>> func = module.functions(name='somefunction')[0]
    >>> func.buffer[func.bufstart:func.bufend]
    [u'def somefunction(x, y, z):',
    u'    return x, y, z']
    >>> func.bufstart, func.bufend, func.startlineno, func.endlineno, \
    ...     func.defendlineno, func.indent
    (80, 82, 81, 82, 81, 0)

Check pointers of ``Function``. Case function def multi-liner::

    >>> func = module.functions(name=u'multilinefunctiondef')[0]
    >>> func.buffer[func.bufstart:func.bufend]
    [u'def multilinefunctiondef(aa,',
    u'                         bb,',
    u"                         cc='hello'):",
    u'    print a, b, c']
    >>> func.bufstart, func.bufend, func.startlineno, func.endlineno, \
    ...     func.defendlineno, func.indent
    (121, 125, 122, 125, 124, 0)

Check pointers of ``Function``. Case function end multi-liner::

    >>> func = module.functions(name=u'functionwithdocstring')[0]
    >>> func.buffer[func.bufstart:func.bufend]
    [u"def functionwithdocstring(d={'foo': 1}, l=[1, 2, 3], t=(1, 2, 3), o=object()):",
    u'    """docstring',
    u'    """',
    u'    return a, \\',
    u'           b, \\',
    u'           c']
    >>> func.bufstart, func.bufend, func.startlineno, func.endlineno, \
    ...     func.defendlineno, func.indent
    (188, 194, 189, 194, 189, 0)

Check pointers of ``Function``. Case function as child::

    >>> func = module.classes(name=u'SomeClass')[0].functions(name=u'__init__')[0]
    >>> func.buffer[func.bufstart:func.bufend]
    [u'    def __init__(self, param):',
    u'        """Do something',
    u'        """',
    u'        self.param = param']
    >>> func.bufstart, func.bufend, func.startlineno, func.endlineno, \
    ...     func.defendlineno, func.indent
    (136, 140, 137, 140, 137, 1)

Check pointers of ``Function``. Case decorated function::

    >>> func = module.functions(name=u'somedecoratedfunction')[0]
    >>> func.buffer[func.bufstart:func.bufend]
    [u'def somedecoratedfunction(param):',
    u'    return param']
    >>> func.bufstart, func.bufend, func.startlineno, func.endlineno, \
    ...     func.defendlineno, func.indent
    (114, 116, 115, 116, 115, 0)

Check pointers of ``Attribute``::

    >>> attr = module.attributes(name=u'param')[0]
    >>> attr.buffer[attr.bufstart:attr.bufend]
    [u'param = 1']
    >>> attr.bufstart, attr.bufend, attr.startlineno, attr.endlineno, attr.indent
    (85, 86, 86, 86, 0)

    >>> attr = module.attributes(name=u'param_3')[0]
    >>> attr.buffer[attr.bufstart:attr.bufend]
    [u'param_3 = """',
    u'    %(hello)s %(world)s',
    u'""" % {',
    u"    'hello': 'hello',",
    u"    'world': 'world',",
    u'}']
    >>> attr.bufstart, attr.bufend, attr.startlineno, attr.endlineno, attr.indent
    (93, 99, 94, 99, 0)

    >>> attr = module.classes('SomeClass')[0].attributes('anotherattr')[0]
    >>> attr.buffer[attr.bufstart:attr.bufend]
    [u'    anotherattr = 1']
    >>> attr.bufstart, attr.bufend, attr.startlineno, attr.endlineno, attr.indent
    (131, 132, 132, 132, 1)

Check pointers of ``Decorator``. Single line decorator::

    >>> func = module.functions(name='somedecoratedfunction')[0]
    >>> deco = func.decorators()[0]
    >>> deco.buffer[deco.bufstart:deco.bufend]
    [u"@myfunctiondecorator(A, b='foo')"]
    >>> deco.bufstart, deco.bufend, deco.startlineno, deco.endlineno, deco.indent
    (113, 114, 114, 114, 0)

Check pointers of ``Decorator``. Multiple decorators, single line decorators::

    >>> func = module.functions(name='multidecoratedfunction')[0]
    >>> len(func.decorators())
    3

    >>> deco = func.decorators(name='decorator_1')[0]
    >>> deco.buffer[deco.bufstart:deco.bufend]
    [u"@decorator_1('a')"]
    >>> deco.bufstart, deco.bufend, deco.startlineno, deco.endlineno, deco.indent
    (166, 167, 167, 167, 0)

    >>> deco = func.decorators(name='decorator_2')[0]
    >>> deco.buffer[deco.bufstart:deco.bufend]
    [u'@decorator_2(object(1, foo=anothercall()))']
    >>> deco.bufstart, deco.bufend, deco.startlineno, deco.endlineno, deco.indent
    (167, 168, 168, 168, 0)

    >>> deco = func.decorators(name='decorator_3')[0]
    >>> deco.buffer[deco.bufstart:deco.bufend]
    [u'@decorator_3(0)']
    >>> deco.bufstart, deco.bufend, deco.startlineno, deco.endlineno, deco.indent
    (168, 169, 169, 169, 0)

Check pointers of ``Decorator``. Multi line decorator::

    >>> func = module.functions(name='multilinedecorated')[0]
    >>> len(func.decorators())
    1

    >>> deco = func.decorators()[0]
    >>> deco.buffer[deco.bufstart:deco.bufend]
    [u'@multilinedecorator(a=object,',
    u'                    b=object(),',
    u'                    c=None)']
    >>> deco.bufstart, deco.bufend, deco.startlineno, deco.endlineno, deco.indent
    (172, 175, 173, 175, 0)

Check pointers of ``Class``. Single line class def::

    >>> class_ = module.classes(name='SomeClass')[0]
    >>> class_.buffer[class_.bufstart:class_.bufend][:3]
    [u'class SomeClass(object):',
    u'    """Some docstring.',
    u'    """']
    >>> class_.bufstart, class_.bufend, class_.startlineno, class_.endlineno, \
    ...     class_.defendlineno, class_.indent
    (126, 144, 127, 144, 127, 0)

Check pointers of ``Class``. Multi line class def::

    >>> class_ = module.classes(name='MultiLineClassDef')[0]
    >>> class_.buffer[class_.bufstart:class_.bufend][:4]
    [u'class MultiLineClassDef(A, B,',
    u'                        C, D):',
    u'    """Multi line class def',
    u'    """']
    >>> class_.bufstart, class_.bufend, class_.startlineno, class_.endlineno, \
    ...     class_.defendlineno, class_.indent
    (161, 165, 162, 165, 163, 0)

Check pointers of ``Class``. Case comment after class def::

    >>> class_ = module.classes(name='OtherClass')[0]
    >>> class_.buffer[class_.bufstart:class_.bufend][:3]
    [u'class OtherClass(A, B): # some comment',
    u'    """Some other docstring.',
    u'    """']
    >>> class_.bufstart, class_.bufend, class_.startlineno, class_.endlineno, \
    ...     class_.defendlineno, class_.indent
    (145, 160, 146, 160, 146, 0)

Check pointers of ``Docstring``. Case multi line::

    >>> from node.ext.python.interfaces import IDocstring
    >>> docstrings = [d for d in module.filtereditems(IDocstring)]
    >>> len(docstrings)
    2

    >>> doc = docstrings[0]
    >>> doc.buffer[doc.bufstart:doc.bufend]
    [u'"""This file is used as test source for python nodes.',
    u'',
    u'The code itself does nothing useful and is not executable.',
    u'"""']
    >>> doc.bufstart, doc.bufend, doc.startlineno, doc.endlineno, doc.indent
    (4, 8, 5, 8, 0)

Check pointers of ``Docstring``. Case single line::

    >>> doc = docstrings[1]
    >>> doc.buffer[doc.bufstart:doc.bufend]
    [u"'''Another docstring.'''"]
    >>> doc.bufstart, doc.bufend, doc.startlineno, doc.endlineno, doc.indent
    (9, 10, 10, 10, 0)

Check pointers of ``Docstring``. Case docstring as child::

    >>> docstrings = [d for d in module.classes()[0].filtereditems(IDocstring)]
    >>> len(docstrings)
    1

    >>> doc = docstrings[0]
    >>> doc.buffer[doc.bufstart:doc.bufend]
    [u'    """Some docstring.',
    u'    """']
    >>> doc.bufstart, doc.bufend, doc.startlineno, doc.endlineno, doc.indent
    (127, 129, 128, 129, 1)

Check the ``Module.parser._createcodeblocks`` method. Case no split::

    >>> blocks = module.parser._createcodeblocks(72, 77)
    >>> len(blocks)
    1

    >>> block = blocks[0]
    >>> block.buffer[block.bufstart:block.bufend]
    [u'if a is True \\',
    u'  or b is True \\',
    u'  or c is True:',
    u'    print d',
    u'']
    >>> block.bufstart, block.bufend, block.startlineno, block.endlineno, \
    ...     block.indent
    (72, 77, 73, 76, 0)

Check the ``Module.parser._createcodeblocks`` method. Case split::

    >>> module.buffer[81:86]
    [u'    return x, y, z',
    u'',
    u'assert(1 == 1)',
    u'',
    u'param = 1']

    >>> blocks = module.parser._createcodeblocks(81, 86)
    >>> len(blocks)
    2

    >>> block = blocks[0]
    >>> block.buffer[block.bufstart:block.bufend]
    [u'    return x, y, z',
    u'']
    >>> block.bufstart, block.bufend, block.startlineno, block.endlineno, \
    ...     block.indent
    (81, 83, 82, 82, 1)

    >>> block = blocks[1]
    >>> block.buffer[block.bufstart:block.bufend]
    [u'assert(1 == 1)',
    u'',
    u'param = 1']
    >>> block.bufstart, block.bufend, block.startlineno, block.endlineno, \
    ...     block.indent
    (83, 86, 84, 86, 0)

Check the ``Module.parser._createcodeblocks`` method. Case block as child::

    >>> blocks = module.parser._createcodeblocks(148, 156)
    >>> len(blocks)
    1

    >>> block = blocks[0]
    >>> block.buffer[block.bufstart:block.bufend]
    [u'    ',
    u'    if True:',
    u'        a = 0',
    u'    else:',
    u'        a = 1',
    u'    ',
    u'    # some doc',
    u'    ']
    >>> block.bufstart, block.bufend, block.startlineno, block.endlineno, \
    ...     block.indent
    (148, 156, 150, 155, 1)

Check the ``Module.parser._createcodeblocks`` method. Case empty block::

    >>> module.buffer[196:198]
    []

    >>> blocks = module.parser._createcodeblocks(196, 198)
    >>> len(blocks)
    0

Check the ``Module.parser._parsecodeblocks`` method::

    >>> blocks = module.parser._parsecodeblocks()
    >>> len(blocks)
    14

    >>> def blockbystartlineno(lineno):
    ...     for block in blocks:
    ...         if block.startlineno == lineno:
    ...             return block

    >>> block = blockbystartlineno(125)
    >>> block.buffer[block.bufstart:block.bufend]
    [u'    print a, b, c',
    u'']
    >>> block.bufstart, block.bufend, block.startlineno, block.endlineno, \
    ...     block.indent
    (124, 126, 125, 125, 1)

    >>> block = blockbystartlineno(140)
    >>> block.buffer[block.bufstart:block.bufend]
    [u'        self.param = param',
    u'    ']
    >>> block.bufstart, block.bufend, block.startlineno, block.endlineno, \
    ...     block.indent
    (139, 141, 140, 140, 2)

Check the ``PythonNode.parser._findnodeposition`` method::

    X[1..15]
      Y[1..4]
      Z[7..10]

    >>> from node.ext.python.nodes import PythonNode
    >>> from node.ext.python.parser import BaseParser
    >>> class TestNode(PythonNode):
    ...     def __init__(self, name):
    ...         PythonNode.__init__(self, name)
    ...         self.parser = BaseParser(self)
    ...     @property
    ...     def indent(self):
    ...         return self._testindent
    ...     def _get_startlineno(self): return self._teststartlineno
    ...     def _set_startlineno(self, n): self._teststartlineno = n
    ...     startlineno = property(_get_startlineno, _set_startlineno)
    ...     def _get_endlineno(self): return self._testendlineno
    ...     def _set_endlineno(self, n): self._testendlineno = n
    ...     endlineno = property(_get_endlineno, _set_endlineno)
    >>> node = TestNode('x')
    >>> node.startlineno = 1
    >>> node.endlineno = 15
    >>> node._testindent = 0
    >>> node['y'] = TestNode('y')
    >>> node['y'].startlineno = 1
    >>> node['y'].endlineno = 4
    >>> node['y']._testindent = 1
    >>> node['z'] = TestNode('z')
    >>> node['z'].startlineno = 7
    >>> node['z'].endlineno = 10
    >>> node['z']._testindent = 1

Case insert before 'z'::

    >>> node.parser._findnodeposition(5, 6, 1)
    (<TestNode object 'z' at ...>, -1)

Case insert after 'z'::

    >>> node.parser._findnodeposition(11, 15, 1)
    (<TestNode object 'z' at ...>, 1)

Case insert after 'x'::

    >>> node.parser._findnodeposition(11, 15, 0)
    (<TestNode object 'x' at ...>, 1)

Case insert into 'x'::

    X[1..2]

    >>> node = TestNode('x')
    >>> node.startlineno = 1
    >>> node.endlineno = 2
    >>> node._testindent = 0
    >>> node.parser._findnodeposition(2, 2, 0)
    (<TestNode object 'x' at ...>, 0)

Case insert into 'y'::

    X[1..5]
      y[2..3]

    >>> node = TestNode('x')
    >>> node.startlineno = 1
    >>> node.endlineno = 5
    >>> node._testindent = 0
    >>> node['y'] = TestNode('y')
    >>> node['y'].startlineno = 2
    >>> node['y'].endlineno = 3
    >>> node['y']._testindent = 1
    >>> node.parser._findnodeposition(3, 3, 2)
    (<TestNode object 'y' at ...>, 0)

Now the protected sections and blocks are added::

    >>> module.printtree()
    <class 'node.ext.python.nodes.Module'>: [1:194] - -1
      <class 'node.ext.python.nodes.Block'>: [2:3] - 0
      <class 'node.ext.python.nodes.Docstring'>: [5:8] - 0
      <class 'node.ext.python.nodes.Docstring'>: [10:10] - 0
      <class 'node.ext.python.nodes.Import'>: [12:12] - 0
      <class 'node.ext.python.nodes.Import'>: [13:13] - 0
      <class 'node.ext.python.nodes.Import'>: [14:14] - 0
      <class 'node.ext.python.nodes.Import'>: [15:15] - 0
      <class 'node.ext.python.nodes.Import'>: [16:16] - 0
      <class 'node.ext.python.nodes.Block'>: [18:79] - 0
      <class 'node.ext.python.nodes.Function'>: [81:82] - 0
        <class 'node.ext.python.nodes.Block'>: [82:82] - 1
      <class 'node.ext.python.nodes.Block'>: [84:84] - 0
      <class 'node.ext.python.nodes.Attribute'>: [86:86] - 0
      <class 'node.ext.python.nodes.Attribute'>: [88:88] - 0
      <class 'node.ext.python.nodes.Attribute'>: [90:92] - 0
      <class 'node.ext.python.nodes.Attribute'>: [94:99] - 0
      <class 'node.ext.python.nodes.Attribute'>: [101:103] - 0
      <class 'node.ext.python.nodes.Attribute'>: [105:105] - 0
      <class 'node.ext.python.nodes.Attribute'>: [107:107] - 0
      <class 'node.ext.python.nodes.Attribute'>: [109:109] - 0
      <class 'node.ext.python.nodes.Block'>: [111:112] - 0
      <class 'node.ext.python.nodes.Function'>: [115:116] - 0
        <class 'node.ext.python.nodes.Decorator'>: [114:114] - 0
        <class 'node.ext.python.nodes.Block'>: [116:116] - 1
      <class 'node.ext.python.nodes.ProtectedSection'>: [118:120] - 0
      <class 'node.ext.python.nodes.Function'>: [122:125] - 0
        <class 'node.ext.python.nodes.Block'>: [125:125] - 1
      <class 'node.ext.python.nodes.Class'>: [127:144] - 0
        <class 'node.ext.python.nodes.Docstring'>: [128:129] - 1
        <class 'node.ext.python.nodes.Attribute'>: [131:131] - 1
        <class 'node.ext.python.nodes.Attribute'>: [132:132] - 1
        <class 'node.ext.python.nodes.ProtectedSection'>: [134:135] - 1
        <class 'node.ext.python.nodes.Function'>: [137:140] - 1
          <class 'node.ext.python.nodes.Docstring'>: [138:139] - 2
          <class 'node.ext.python.nodes.Block'>: [140:140] - 2
        <class 'node.ext.python.nodes.Function'>: [143:144] - 1
          <class 'node.ext.python.nodes.Decorator'>: [142:142] - 1
          <class 'node.ext.python.nodes.Block'>: [144:144] - 2
      <class 'node.ext.python.nodes.Class'>: [146:160] - 0
        <class 'node.ext.python.nodes.Docstring'>: [147:148] - 1
        <class 'node.ext.python.nodes.Block'>: [150:155] - 1
        <class 'node.ext.python.nodes.Function'>: [157:160] - 1
          <class 'node.ext.python.nodes.Docstring'>: [158:159] - 2
          <class 'node.ext.python.nodes.Block'>: [160:160] - 2
      <class 'node.ext.python.nodes.Class'>: [162:165] - 0
        <class 'node.ext.python.nodes.Docstring'>: [164:165] - 1
      <class 'node.ext.python.nodes.Function'>: [170:171] - 0
        <class 'node.ext.python.nodes.Decorator'>: [167:167] - 0
        <class 'node.ext.python.nodes.Decorator'>: [168:168] - 0
        <class 'node.ext.python.nodes.Decorator'>: [169:169] - 0
        <class 'node.ext.python.nodes.Block'>: [171:171] - 1
      <class 'node.ext.python.nodes.Function'>: [176:177] - 0
        <class 'node.ext.python.nodes.Decorator'>: [173:175] - 0
        <class 'node.ext.python.nodes.Block'>: [177:177] - 1
      <class 'node.ext.python.nodes.Import'>: [179:180] - 0
      <class 'node.ext.python.nodes.Import'>: [182:185] - 0
      <class 'node.ext.python.nodes.Import'>: [187:187] - 0
      <class 'node.ext.python.nodes.Function'>: [189:194] - 0
        <class 'node.ext.python.nodes.Docstring'>: [190:191] - 1
        <class 'node.ext.python.nodes.Block'>: [192:194] - 1

Check some ``Block`` contents::

    >>> from node.ext.python.interfaces import IBlock
    >>> blocks = [b for b in module.filtereditems(IBlock)]
    >>> block = blocks[0]
    >>> block.nodelevel
    0
    >>> block.lines
    [u'# Copyright 2009, BlueDynamics Alliance - http://bluedynamics.com',
    u'# GNU General Public License Version 2']

    >>> block = blocks[1]
    >>> block.nodelevel
    0
    >>> block.lines[0]
    u'# here we add a comment'
    >>> block.lines[-1]
    u'    i += 1'

    >>> block = blocks[2]
    >>> block.lines[0]
    u'assert(1 == 1)'

Check some ``ProtectedSection`` contents::

    >>> from node.ext.python.interfaces import IProtectedSection
    >>> sec = [s for s in module.filtereditems(IProtectedSection)][0]
    >>> sec.nodelevel
    0
    >>> sec.lines
    [u"print 'something'"]

    >>> sec = [s for s in \
    ...        module.classes()[0].filtereditems(IProtectedSection)][0]
    >>> sec.nodelevel
    1
    >>> sec.lines
    []

Check some ``Docstring`` contents::

    >>> from node.ext.python.interfaces import IDocstring
    >>> docstrings = [d for d in module.filtereditems(IDocstring)]
    >>> doc = docstrings[0]
    >>> doc.nodelevel
    0
    >>> doc.lines
    [u'This file is used as test source for python nodes.',
    u'',
    u'The code itself does nothing useful and is not executable.']

    >>> doc = [d for d in module.classes()[0].filtereditems(IDocstring)][0]
    >>> doc.nodelevel
    1
    >>> doc.lines
    [u'Some docstring.']

Check some ``Import`` attributes::

    >>> from node.ext.python.interfaces import IImport
    >>> imports = [i for i in module.filtereditems(IImport)]
    >>> imp = imports[0]
    >>> imp.nodelevel
    0
    >>> imp.fromimport
    >>> imp.names
    [[u'foo', None]]

    >>> imp = imports[1]
    >>> imp.nodelevel
    0
    >>> imp.fromimport
    >>> imp.names
    [[u'bar', None], [u'baz', None]]

    >>> imp = imports[2]
    >>> imp.nodelevel
    0
    >>> imp.fromimport
    u'pkg'
    >>> imp.names
    [[u'Something', None]]

    >>> imp = imports[3]
    >>> imp.nodelevel
    0
    >>> imp.fromimport
    u'pkg'
    >>> imp.names
    [[u'A', None], [u'B', None]]

    >>> imp = imports[4]
    >>> imp.nodelevel
    0
    >>> imp.fromimport
    u'pkg.subpkg'
    >>> imp.names
    [[u'C', u'D'], [u'E', u'F']]

Check some ``Decorator`` contents::

    >>> dec = module.functions(name=u'somedecoratedfunction')[0].decorators()[0]
    >>> dec.args
    ['A']
    >>> dec.kwargs
    odict([('b', "'foo'")])

    >>> dec = module.functions(name='multilinedecorated')[0].decorators()[0]
    >>> dec.args
    []
    >>> dec.kwargs
    odict([('a', 'object'),
    ('b', {'args': [], 'name': 'object', 'kwargs': odict()}),
    ('c', 'None')])

    >>> dec = module.functions(\
    ...           name=u'multidecoratedfunction')[0].decorators()[0]
    >>> dec.args
    ["'a'"]
    >>> dec.kwargs
    odict()

    >>> dec = module.functions(\
    ...           name=u'multidecoratedfunction')[0].decorators()[1]
    >>> dec.args
    [{'args': [1], 'name': 'object',
    'kwargs': odict([('foo', {'args': [], 'name': 'anothercall',
    'kwargs': odict()})])}]

    >>> dec.kwargs
    odict()

Check some ``Function`` contents::

    >>> from node.ext.python.interfaces import IFunction
    >>> functions = [f for f in module.filtereditems(IFunction)]
    >>> func = functions[0]
    >>> func.functionname
    'somefunction'

    >>> func.args
    ['x', 'y', 'z']

    >>> func.kwargs
    odict()

    >>> func = functions[2]
    >>> func.functionname
    'multilinefunctiondef'

    >>> func.args
    ['aa', 'bb']

    >>> func.kwargs
    odict([('cc', "'hello'")])

    >>> func = module.functions(name=u'functionwithdocstring')[0]
    >>> func.args
    []

    >>> func.kwargs
    odict([('d', {"'foo'": 1}),
    ('l', [1, 2, 3]),
    ('t', (1, 2, 3)),
    ('o', {'args': [], 'name': 'object', 'kwargs': odict()})])

Check some ``Class`` contents::

    >>> from node.ext.python.interfaces import IClass
    >>> classes = [c for c in module.filtereditems(IClass)]
    >>> class_ = classes[0]
    >>> class_.classname
    'SomeClass'

    >>> class_.bases
    ['object']

Check pointers of the code generated by renderer tests::

    >>> path = os.path.join(datadir, 'rendered.py')
    >>> Module._do_parse = True
    >>> module = Module(path)
    >>> module.bufstart, module.bufend, module.startlineno, module.endlineno, \
    ...     module.indent
    (0, 43, 1, 43, 0)

    >>> doc = module.docstrings()[0]
    >>> doc.bufstart, doc.bufend, doc.startlineno, doc.endlineno, doc.indent
    (1, 5, 2, 5, 0)

    >>> psec = module.protectedsections()[0]
    >>> psec.bufstart, psec.bufend, psec.startlineno, psec.endlineno, \
    ...     psec.indent
    (6, 9, 7, 9, 0)

    >>> block = module.blocks()[0]
    >>> block.bufstart, block.bufend, block.startlineno, block.endlineno, \
    ...     block.indent
    (9, 13, 11, 12, 0)

    >>> attr = module.attributes()[0]
    >>> attr.bufstart, attr.bufend, attr.startlineno, attr.endlineno, \
    ...     attr.indent
    (13, 17, 14, 17, 0)

    >>> imp = module.imports()[0]
    >>> imp.bufstart, imp.bufend, imp.startlineno, imp.endlineno, imp.indent
    (18, 20, 19, 20, 0)

    >>> cla = module.classes()[0]
    >>> cla.bufstart, cla.bufend, cla.startlineno, cla.endlineno, cla.indent
    (21, 38, 22, 38, 0)

    >>> doc = cla.docstrings()[0]
    >>> doc.bufstart, doc.bufend, doc.startlineno, doc.endlineno, doc.indent
    (22, 24, 23, 24, 1)

    >>> attr = cla.attributes()[0]
    >>> attr.bufstart, attr.bufend, attr.startlineno, attr.endlineno, \
    ...     attr.indent
    (25, 26, 26, 26, 1)

    >>> attr = cla.attributes()[1]
    >>> attr.bufstart, attr.bufend, attr.startlineno, attr.endlineno, \
    ...     attr.indent
    (26, 30, 27, 30, 1)

    >>> func = cla.functions()[0]
    >>> func.bufstart, func.bufend, func.startlineno, func.endlineno, \
    ...     func.indent
    (32, 38, 33, 38, 1)

    >>> dec = func.decorators()[0]
    >>> dec.bufstart, dec.bufend, dec.startlineno, dec.endlineno, dec.indent
    (31, 32, 32, 32, 1)

    >>> doc = func.docstrings()[0]
    >>> doc.bufstart, doc.bufend, doc.startlineno, doc.endlineno, doc.indent
    (33, 35, 34, 35, 2)

    >>> block = func.blocks()[0]
    >>> block.bufstart, block.bufend, block.startlineno, block.endlineno, \
    ...     block.indent
    (35, 39, 36, 38, 2)

    >>> cla = module.classes()[1]
    >>> cla.bufstart, cla.bufend, cla.startlineno, cla.endlineno, cla.indent
    (39, 43, 40, 43, 0)

    >>> func = cla.functions()[0]
    >>> func.bufstart, func.bufend, func.startlineno, func.endlineno, \
    ...     func.indent
    (41, 43, 42, 43, 1)

Check Namespace package ``__init__.py`` parsing::

    >>> init = Module('%s/__init_.py' % datadir)
    >>> init.printtree()
    <class 'node.ext.python.nodes.Module'>: [1:2] - -1
      <class 'node.ext.python.nodes.Block'>: [2:2] - 0

Create ``node.ext.directory.Directory`` instance and test the parsing handler::

    >>> from node.ext.directory import Directory
    >>> directory = Directory(datadir)
    >>> module = Module()
    >>> module.printtree()
    <class 'node.ext.python.nodes.Module'>: [?:?] - -1

    >>> directory['rendered.py'] = module
    >>> module.printtree()
    <class 'node.ext.python.nodes.Module'>: [1:43] - -1
      <class 'node.ext.python.nodes.Docstring'>: [2:5] - 0
      <class 'node.ext.python.nodes.ProtectedSection'>: [7:9] - 0
      <class 'node.ext.python.nodes.Block'>: [11:12] - 0
      <class 'node.ext.python.nodes.Attribute'>: [14:17] - 0
      <class 'node.ext.python.nodes.Import'>: [19:20] - 0
      <class 'node.ext.python.nodes.Class'>: [22:38] - 0
        <class 'node.ext.python.nodes.Docstring'>: [23:24] - 1
        <class 'node.ext.python.nodes.Attribute'>: [26:26] - 1
        <class 'node.ext.python.nodes.Attribute'>: [27:30] - 1
        <class 'node.ext.python.nodes.Function'>: [33:38] - 1
          <class 'node.ext.python.nodes.Docstring'>: [34:35] - 2
          <class 'node.ext.python.nodes.Block'>: [36:38] - 2
          <class 'node.ext.python.nodes.Decorator'>: [32:32] - 1
      <class 'node.ext.python.nodes.Class'>: [40:43] - 0
        <class 'node.ext.python.nodes.Function'>: [42:43] - 1
          <class 'node.ext.python.nodes.Block'>: [43:43] - 2

Check class only containing attributes, no follow ups::

    >>> modulepath = os.path.join(datadir, 'class_wo_functions.py')
    >>> module = Module(modulepath)

    >>> module.printtree()
    <class 'node.ext.python.nodes.Module'>: [1:7] - -1
      <class 'node.ext.python.nodes.Class'>: [3:7] - 0
        <class 'node.ext.python.nodes.Attribute'>: [5:5] - 1
        <class 'node.ext.python.nodes.Attribute'>: [6:6] - 1
        <class 'node.ext.python.nodes.Attribute'>: [7:7] - 1

    >>> module.classes()[0].attributes()[-1].startlineno
    7

    >>> module.classes()[0].attributes()[-1].bufstart
    6

    >>> module.classes()[0].attributes()[-1].endlineno
    7

    >>> module.classes()[0].attributes()[-1].bufend
    7


text:
package TBC.Combat.Effects;

import TBC.Combat.CombatEngine;
import TBC.Combat.CombatEntity;
import TBC.Combat.DamageAlgorithm;
import TBC.Combat.DamageType;
import net.minecraft.entity.player.EntityPlayer;

public class LifeStealEffect implements IOneTimeEffect, IDamageEffect
{
	private int flatPhysicalStrength;
	private int flatMagicalStrength;
	private float physMultiplier;
	private float magMultiplier;
	private float conversionRate;

	public LifeStealEffect(int flatPhysicalStrength, int flatMagicalStrength, float physMultiplier, float magMultiplier, float conversionRate)
	{
		this.flatPhysicalStrength = flatPhysicalStrength;
		this.flatMagicalStrength = flatMagicalStrength;
		this.physMultiplier = physMultiplier;
		this.magMultiplier = magMultiplier;
		this.conversionRate = conversionRate;
	}

	public void ApplyToEntity(CombatEngine engine, CombatEntity user, CombatEntity target)
	{
		int physicalStrength = this.flatPhysicalStrength + Math.round(user.GetAttack() * this.physMultiplier);
		int magicalStrength = this.flatMagicalStrength + Math.round(user.GetMagic() * this.magMultiplier);
		int mDefense = target.GetMagicDefense();
		int defense = target.GetDefense();
		int damage = DamageAlgorithm.GetPhysicalDamage(physicalStrength, defense);
		damage += DamageAlgorithm.GetMagicalDamage(magicalStrength, mDefense);
		engine.DoDamage(user, target, this, damage);

		int healing = (int)(conversionRate * damage);
		engine.DoDamage(user, user, this, -healing);
	}

	public int GetDamageType()
	{
		int damageType = 0;
		if(flatPhysicalStrength != 0 || physMultiplier > 0)
		{
			damageType |= DamageType.Physical;
		}

		if(flatMagicalStrength != 0 || magMultiplier > 0)
		{
			damageType |= DamageType.Magical;
		}

		return damageType;
	}
}

redpajama_set_name: RedPajamaGithub


text:
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using System;
using System.Security.Cryptography.X509Certificates;
using System.ServiceModel;
using System.ServiceModel.Activation;
using System.ServiceModel.Channels;
using System.ServiceModel.Security;

namespace WcfService
{
    public class TcpTransportSecuritySslClientCredentialTypeCertificateTestServiceHostFactory : ServiceHostFactory
    {
        protected override ServiceHost CreateServiceHost(Type serviceType, Uri[] baseAddresses)
        {
            TcpTransportSecuritySslClientCredentialTypeCertificateTestServiceHost serviceHost = new TcpTransportSecuritySslClientCredentialTypeCertificateTestServiceHost(serviceType, baseAddresses);
            return serviceHost;
        }
    }
    public class TcpTransportSecuritySslClientCredentialTypeCertificateTestServiceHost : TestServiceHostBase<IWcfService>
    {
        protected override string Address { get { return "tcp-server-ssl-security-clientcredentialtype-certificate"; } }

        protected override Binding GetBinding()
        {
            NetTcpBinding binding = new NetTcpBinding(SecurityMode.Transport);
            binding.Security.Transport.ClientCredentialType = TcpClientCredentialType.Certificate;
            return binding;
        }

        protected override void ApplyConfiguration()
        {
 	        base.ApplyConfiguration();
            // Ensure the https certificate is installed before this endpoint resource is used
            string thumbprint = Util.CertificateFromFridendlyName(StoreName.My, StoreLocation.LocalMachine, "WCF Bridge - Machine certificate generated by the CertificateManager").Thumbprint;

            this.Credentials.ClientCertificate.Authentication.CertificateValidationMode = X509CertificateValidationMode.None;
            this.Credentials.ServiceCertificate.SetCertificate(StoreLocation.LocalMachine,
                                                      StoreName.My,
                                                      X509FindType.FindByThumbprint,
                                                      thumbprint);
        }

        public TcpTransportSecuritySslClientCredentialTypeCertificateTestServiceHost(Type serviceType, params Uri[] baseAddresses)
            : base(serviceType, baseAddresses)
        {
        }
    }
}


text:
<?xml version="1.0" encoding="UTF-8"?>
<lint>
    <issue id="GoogleAppIndexingWarning" severity="ignore"/>
</lint>


text:
#include <linux/platform_device.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/rtc.h>
#include "../iio.h"
#include "../trigger.h"

LIST_HEAD(iio_prtc_trigger_list);
DEFINE_MUTEX(iio_prtc_trigger_list_lock);

struct iio_prtc_trigger_info {
	struct rtc_device *rtc;
	int frequency;
	char *name;
	struct rtc_task task;
};

static int iio_trig_periodic_rtc_set_state(struct iio_trigger *trig, bool state)
{
	struct iio_prtc_trigger_info *trig_info = trig->private_data;
	if (trig_info->frequency == 0)
		return -EINVAL;
	printk(KERN_INFO "trigger frequency is %d\n", trig_info->frequency);
	return rtc_irq_set_state(trig_info->rtc, &trig_info->task, state);
}

static ssize_t iio_trig_periodic_read_freq(struct device *dev,
					   struct device_attribute *attr,
					   char *buf)
{
	struct iio_trigger *trig = dev_get_drvdata(dev);
	struct iio_prtc_trigger_info *trig_info = trig->private_data;
	return sprintf(buf, "%u\n", trig_info->frequency);
}

static ssize_t iio_trig_periodic_write_freq(struct device *dev,
					    struct device_attribute *attr,
					    const char *buf,
					    size_t len)
{
	struct iio_trigger *trig = dev_get_drvdata(dev);
	struct iio_prtc_trigger_info *trig_info = trig->private_data;
	unsigned long val;
	int ret;

	ret = strict_strtoul(buf, 10, &val);
	if (ret)
		goto error_ret;

	ret = rtc_irq_set_freq(trig_info->rtc, &trig_info->task, val);
	if (ret)
		goto error_ret;

	trig_info->frequency = val;

	return len;

error_ret:
	return ret;
}

static ssize_t iio_trig_periodic_read_name(struct device *dev,
					   struct device_attribute *attr,
					   char *buf)
{
	struct iio_trigger *trig = dev_get_drvdata(dev);
	struct iio_prtc_trigger_info *trig_info = trig->private_data;
	return sprintf(buf, "%s\n", trig_info->name);
}

static DEVICE_ATTR(name, S_IRUGO,
	    iio_trig_periodic_read_name,
	    NULL);
static DEVICE_ATTR(frequency, S_IRUGO | S_IWUSR,
	    iio_trig_periodic_read_freq,
	    iio_trig_periodic_write_freq);

static struct attribute *iio_trig_prtc_attrs[] = {
	&dev_attr_frequency.attr,
	&dev_attr_name.attr,
	NULL,
};
static const struct attribute_group iio_trig_prtc_attr_group = {
	.attrs = iio_trig_prtc_attrs,
};

static void iio_prtc_trigger_poll(void *private_data)
{
	iio_trigger_poll(private_data);
}

static int iio_trig_periodic_rtc_probe(struct platform_device *dev)
{
	char **pdata = dev->dev.platform_data;
	struct iio_prtc_trigger_info *trig_info;
	struct iio_trigger *trig, *trig2;

	int i, ret;

	for (i = 0;; i++) {
		if (pdata[i] == NULL)
			break;
		trig = iio_allocate_trigger();
		if (!trig) {
			ret = -ENOMEM;
			goto error_free_completed_registrations;
		}
		list_add(&trig->alloc_list, &iio_prtc_trigger_list);

		trig_info = kzalloc(sizeof(*trig_info), GFP_KERNEL);
		if (!trig_info) {
			ret = -ENOMEM;
			goto error_put_trigger_and_remove_from_list;
		}
		trig->private_data = trig_info;
		trig->owner = THIS_MODULE;
		trig->set_trigger_state = &iio_trig_periodic_rtc_set_state;
		trig->name = kmalloc(IIO_TRIGGER_NAME_LENGTH, GFP_KERNEL);
		if (trig->name == NULL) {
			ret = -ENOMEM;
			goto error_free_trig_info;
		}
		snprintf((char *)trig->name,
			 IIO_TRIGGER_NAME_LENGTH,
			 "periodic%s",
			 pdata[i]);
		trig_info->name = (char *)trig->name;
		/* RTC access */
		trig_info->rtc
			= rtc_class_open(pdata[i]);
		if (trig_info->rtc == NULL) {
			ret = -EINVAL;
			goto error_free_name;
		}
		trig_info->task.func = iio_prtc_trigger_poll;
		trig_info->task.private_data = trig;
		ret = rtc_irq_register(trig_info->rtc, &trig_info->task);
		if (ret)
			goto error_close_rtc;
		trig->control_attrs = &iio_trig_prtc_attr_group;
		ret = iio_trigger_register(trig);
		if (ret)
			goto error_unregister_rtc_irq;
	}
	return 0;
error_unregister_rtc_irq:
	rtc_irq_unregister(trig_info->rtc, &trig_info->task);
error_close_rtc:
	rtc_class_close(trig_info->rtc);
error_free_name:
	kfree(trig->name);
error_free_trig_info:
	kfree(trig_info);
error_put_trigger_and_remove_from_list:
	list_del(&trig->alloc_list);
	iio_put_trigger(trig);
error_free_completed_registrations:
	list_for_each_entry_safe(trig,
				 trig2,
				 &iio_prtc_trigger_list,
				 alloc_list) {
		trig_info = trig->private_data;
		rtc_irq_unregister(trig_info->rtc, &trig_info->task);
		rtc_class_close(trig_info->rtc);
		kfree(trig->name);
		kfree(trig_info);
		iio_trigger_unregister(trig);
	}
	return ret;
}

static int iio_trig_periodic_rtc_remove(struct platform_device *dev)
{
	struct iio_trigger *trig, *trig2;
	struct iio_prtc_trigger_info *trig_info;
	mutex_lock(&iio_prtc_trigger_list_lock);
	list_for_each_entry_safe(trig,
				 trig2,
				 &iio_prtc_trigger_list,
				 alloc_list) {
		trig_info = trig->private_data;
		rtc_irq_unregister(trig_info->rtc, &trig_info->task);
		rtc_class_close(trig_info->rtc);
		kfree(trig->name);
		kfree(trig_info);
		iio_trigger_unregister(trig);
	}
	mutex_unlock(&iio_prtc_trigger_list_lock);
	return 0;
}

static struct platform_driver iio_trig_periodic_rtc_driver = {
	.probe = iio_trig_periodic_rtc_probe,
	.remove = iio_trig_periodic_rtc_remove,
	.driver = {
		.name = "iio_prtc_trigger",
		.owner = THIS_MODULE,
	},
};

static int __init iio_trig_periodic_rtc_init(void)
{
	return platform_driver_register(&iio_trig_periodic_rtc_driver);
}

static void __exit iio_trig_periodic_rtc_exit(void)
{
	return platform_driver_unregister(&iio_trig_periodic_rtc_driver);
}

module_init(iio_trig_periodic_rtc_init);
module_exit(iio_trig_periodic_rtc_exit);
MODULE_AUTHOR("Jonathan Cameron <jic23@cam.ac.uk>");
MODULE_DESCRIPTION("Periodic realtime clock  trigger for the iio subsystem");
MODULE_LICENSE("GPL v2");


text:
<!DOCTYPE html>

  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="generator" content="Mobirise v3.12, #">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="shortcut icon" href="assets/images/otm-logo-128x53.png" type="image/x-icon">
  <meta name="description" content="Web Generator Description">
  <title>Gallery</title>
  <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Lora:400,700,400italic,700italic&subset=latin">
  <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Montserrat:400,700">
  <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Raleway:100,100i,200,200i,300,300i,400,400i,500,500i,600,600i,700,700i,800,800i,900,900i">
  <link rel="stylesheet" href="assets/bootstrap-material-design-font/css/material.css">
  <link rel="stylesheet" href="assets/et-line-font-plugin/style.css">
  <link rel="stylesheet" href="assets/tether/tether.min.css">
  <link rel="stylesheet" href="assets/bootstrap/css/bootstrap.min.css">
  <link rel="stylesheet" href="assets/dropdown/css/style.css">
  <link rel="stylesheet" href="assets/theme/css/style.css">
  <link rel="stylesheet" href="assets/mobirise-gallery/style.css">
  <link rel="stylesheet" href="assets/mobirise/css/mbr-additional.css" type="text/css">
  <link rel="stylesheet" href="css/font-awesome.css" type="text/css">

                    <button class="navbar-toggler pull-xs-right hidden-md-up" type="button" data-toggle="collapse" data-target="#exCollapsingNavbar">

                    </button>

                        OTM
About
Attendees
ExhibitorsVisitors

FAQs

VISITORS
Visit OTMVisitor's RegistrationHosted Buyer's Registration

EXHIBITORS
Why ExhibitExhbitor Enquiry

Sponsorship
Sponsorship and PromotionSponsorship PackagesOn-site AdvertisingAdvertising materialDigital and Print Advertising

PRESS
Press ServicesMedia KitImage LibraryPress ReleasesMedia partners
Register As
Travel BloggerMedia

RESOURCES
Link1
                    Link2Link3

                    <button hidden="" class="navbar-toggler navbar-close" type="button" data-toggle="collapse" data-target="#exCollapsingNavbar">

                    </button>

#/

OTM Media Kit

Print Ad Specifications and Rate

                    Previous

                    Next

Booking Deadline

20th of Previous month

Material Deadline

25th of Previous month

BOOK NOW DOWNLOAD BROCHURE

Online Ad Rates

                          General Banner Ads

                              Banner Size (W X H)
                              Price Per Month (INR/USD)

                              Leaderboard
                              865 X 75
                              INR 150000/$3500

                              Top Right
                              234 X 60
                              INR 65000/$1517

                              Top Left
                              234 X 60
                              INR 65000/$1517

                              IMU 1
                              300 X 320
                              INR 125000/$2918

                              IMU 2
                              300 X 320
                              INR 125000/$2918

                          Rich Media Properties

                              Page Curl(3d Depth Effect)
                              INR 1,80,000/$ 4200

                              Road Block (100% ownership)-2 times a week
                              INR 1,80,000/$ 4200

                              Road Block (100% ownership)-2 times a week + Page Curl on Other days

                              INR 3,50,000/$ 8167

                          Downloads

                              Price Per Month (INR/USD)

                              Minimum Commitment of 50 Contacts Additional contact @ INR 5,000 / Contact
                              INR  1,50,000 / $ 3500

                          NewsLetters and EDM

                              Banner Size (W X H)
                              Price Per Month (INR/USD)

                              Full Banner
                              800 X 150
                              INR 1,50,000 / $3500

                              Vertical Banner
                              400 X 550
                              INR 1,00,000 / $2333

                              EDM (Electronic Direct Mailer)

                              INR 3 / $0.07 / email ID

Note:

All ads are on a tenancy basis

 All positions are sold on 33% SOV

All dimensions are given in pixels and in width x height format for 1366 x 768 screen resolution

BOOK NOW VIEW LAYOUT

Thanks for filling out form!

                    <form action="#/" method="post" data-form-title="CONTACT FORM">

                        <input type="hidden" value="UBi5c1mlrjNxCNWWGPRn2v94r6xhy3xi7LeeArz2TR/3YpKk+my+3mlmS5OpgOJz4lkvLc5T+golzcoWQhns1/xP9VrXdlPD9N0RUhHSgyy0zAjpKgcKp6D+cV/aVNas" data-form-email="true">

Booking Form

                                    Name
                                    <input type="text" class="form-control" name="name" required="" data-form-field="Name" id="form1-47-name">

                                    Designation
                                    <input type="text" class="form-control" name="designation" required="true" data-form-field="designation" id="designation">

                                    Organisation
                                    <input type="text" class="form-control" name="organisation" required="true" data-form-field="organisation" id="organisation">

                                Address
                                <textarea class="form-control" name="address" rows="7" data-form-field="address" id="address"></textarea>

                                    City
                                    <input type="text" class="form-control" name="city" required="true" id="city">

                                    Postal Code
                                    <input type="number" class="form-control" name="postalcode" required="true" data-form-field="postalcode" id="postalcode">

                                    Country
                                    <input type="text" class="form-control" name="country" required="true" id="country">

                                    Telephone Number
                                    <input type="number" class="form-control" name="phone" data-form-field="Phone" id="form1-47-phone">

                                    Website
                                    <input type="text" class="form-control" name="website" required="true" id="website">

                                    Ad Space Booking Priority(Select Either or both)

                                      <input type="radio" name="optradio1" class="custom-control-input">

                                      Print Issue

                                      <input type="radio" name="optradio1" class="custom-control-input">  Online Space

                                      <input type="radio" name="optradio1" class="custom-control-input">
                                      Both

                                Details
                                <textarea class="form-control" name="address" rows="7" data-form-field="address" id="address" placeholder="Describe your Requirements here"></textarea>

                                    Total Amount(INR)
                                    <input type="number" class="form-control" name="phone" data-form-field="Phone" id="form1-47-phone">

                            Any other comments?
                            <textarea class="form-control" name="message" rows="7" data-form-field="Message" id="form1-47-message"></textarea>

                                <button type="submit" class="btn btn-primary">Book Now</button>

                                <button type="link" class="btn btn-black btn-black-outline">Download Brochure</button>

                </form>

© OTM, All Rights Reserved | Fairfest Media Limited

                                    Connect On:

About

Why Exhibit?

Why Visit?

Dates and Location

Attendee Profile

Downloads

OTM 2018 Brochure

OTM 2017 Post Show Report

Exhibitor Handbook

Order Booking Form

Thanks for filling out form!

                <form action="https://#/" method="post" data-form-title="MESSAGE">
                    <input type="hidden" value="20W9Uv8r9ejL2b2QAorQoBiBOcRvuCrUbO8lPYNOJEEKWvJduJ93Gg+v3ObysU4W0tRt9/9p0AEvjKrxPCWKYLitHI5ecPkL2ZC/EJ4hl5ufTgYv5CnP8gRSGtKONPwn" data-form-email="true">
                    Subscribe to our Mailing List

                        <input type="email" class="form-control input-sm input-inverse" name="email" required="" data-form-field="Email" id="contacts4-4r-email" placeholder="email">

                            <button class="btn btn-success btn-sm" type="button" style="border-radius: 0px;"></button>

                </form>

                Privacy Policy |
                Terms and Conditions


text:
package org.springframework.security.web.authentication.session;

import java.util.List;

import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpSession;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import org.springframework.core.log.LogMessage;
import org.springframework.security.core.Authentication;
import org.springframework.util.Assert;

/**
 * A {@link SessionAuthenticationStrategy} that accepts multiple
 * {@link SessionAuthenticationStrategy} implementations to delegate to. Each
 * {@link SessionAuthenticationStrategy} is invoked in turn. The invocations are short
 * circuited if any exception, (i.e. SessionAuthenticationException) is thrown.
 *
 *

 * Typical usage would include having the following delegates (in this order)
 *

 *
 *

 *
{@link ConcurrentSessionControlAuthenticationStrategy} - verifies that a user is
 * allowed to authenticate (i.e. they have not already logged into the application.

 *
{@link SessionFixationProtectionStrategy} - If session fixation is desired,
 * {@link SessionFixationProtectionStrategy} should be after
 * {@link ConcurrentSessionControlAuthenticationStrategy} to prevent unnecessary
 * {@link HttpSession} creation if the
 * {@link ConcurrentSessionControlAuthenticationStrategy} rejects authentication.

 *
{@link RegisterSessionAuthenticationStrategy} - It is important this is after
 * {@link SessionFixationProtectionStrategy} so that the correct session is registered.
 *

 *

 *
 * @author Rob Winch
 * @since 3.2
 */
public class CompositeSessionAuthenticationStrategy implements SessionAuthenticationStrategy {

	private final Log logger = LogFactory.getLog(getClass());

	private final List<SessionAuthenticationStrategy> delegateStrategies;

	public CompositeSessionAuthenticationStrategy(List<SessionAuthenticationStrategy> delegateStrategies) {
		Assert.notEmpty(delegateStrategies, "delegateStrategies cannot be null or empty");
		for (SessionAuthenticationStrategy strategy : delegateStrategies) {
			Assert.notNull(strategy, () -> "delegateStrategies cannot contain null entires. Got " + delegateStrategies);
		}
		this.delegateStrategies = delegateStrategies;
	}

	@Override
	public void onAuthentication(Authentication authentication, HttpServletRequest request,
			HttpServletResponse response) throws SessionAuthenticationException {
		int currentPosition = 0;
		int size = this.delegateStrategies.size();
		for (SessionAuthenticationStrategy delegate : this.delegateStrategies) {
			if (this.logger.isTraceEnabled()) {
				this.logger.trace(LogMessage.format("Preparing session with %s (%d/%d)",
						delegate.getClass().getSimpleName(), ++currentPosition, size));
			}
			delegate.onAuthentication(authentication, request, response);
		}
	}

	@Override
	public String toString() {
		return getClass().getName() + " [delegateStrategies = " + this.delegateStrategies + "]";
	}

}


text:
import Manga from 'crawlers/manhuagui/manga';
import search from 'crawlers/manhuagui/search';
import { buildMangaSearcherTestCases } from '../test-case-helpers';

describe('hhimm', () => {
  buildMangaSearcherTestCases({
    search,
    keyword: '龙珠',
    tester: {
      url: Manga.identifier,
      authors: true,
      description: true,
    },
  });
});


text:
    <form ng-show="!modeRegister" ng-submit="login()" id="auth">

Incorrect email or password

            <input class="in" type="email" placeholder="Enter Email" name="email" ng-model="loginUser.email" required>
            <input class="in" type="password" placeholder="Enter Password" name="password" ng-model="loginUser.password" required>

    <button type="submit" id="login-btn">Login</button>
    <button type="button" id="register" ng-click="toggleRegisterLogin()">Don't have account?</button>
    </form>

    <form ng-show="modeRegister" ng-submit="register()" id="auth">

Email already in use

            <input class="in" type="name" placeholder="Enter Name" name="name" ng-model="registerUser.name">
            <input class="in" type="email" placeholder="Enter Email" name="email" ng-model="registerUser.email" required>
            <input class="in" type="password" placeholder="Enter Password" name="password" ng-model="registerUser.password" required>

        <button type="submit" id="login-btn">Register</button>
        <button type="button" id="register" ng-click="toggleRegisterLogin()">Have account?</button>
    </form>


text:
/* tslint:disable:no-unused-variable */

import { TestBed, async } from '@angular/core/testing';
import { UserComponent } from './user.component';

describe('Component: User', () => {
  it('should create an instance', () => {
    let component = new UserComponent();
    expect(component).toBeTruthy();
  });
});


text:
package com.planet_ink.coffee_web.converters;

import java.io.ByteArrayOutputStream;
import java.io.File;
import java.nio.ByteBuffer;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import com.planet_ink.coffee_web.http.HTTPException;
import com.planet_ink.coffee_web.http.HTTPStatus;
import com.planet_ink.coffee_web.interfaces.HTTPOutputConverter;
import com.planet_ink.coffee_web.interfaces.HTTPRequest;
import com.planet_ink.coffee_web.server.WebServer;
import com.planet_ink.coffee_web.util.CWConfig;

public class CWHTMLConverter implements HTTPOutputConverter
{
	private static enum Macro
	{
		HTTPSTATUS,
		HTTPSTATUSINFO,
		WEBSERVERVERSION,
		WEBSERVERNAME,
		WEBSERVERPORT,
		STARTFILELOOP,
		ENDFILELOOP,
		FILETYPE,
		FILENAME,
		FILESIZE,
		FILELASTMOD,
		FILEURLPATH,
		URLPATH
	}
	private static Map<String,Macro> macros=new HashMap<String,Macro>();
	static
	{
		for(final Macro m : Macro.values())
			macros.put(m.toString().toLowerCase(), m);
	}

	/**
	 * Standard method for converting an input buffer for writing to
	 * the client.   The position and limit of the bytebuffer must
	 * already be set for reading the content.
	 * Call generateOutput() to get the new output.
	 * @param config the http configuration (optional, may be null)
	 * @param request the http request bring processed  (optional, may be null)
	 * @param pageFile the file whose data is being converted
	 * @param status the status of the request (so far)
	 * @param buffer the input buffer
	 * @throws HTTPException
	 */
	@Override
	public ByteBuffer convertOutput(final CWConfig config, final HTTPRequest request, final File pageFile, final HTTPStatus status, final ByteBuffer buffer) throws HTTPException
	{
		final int oldPosition=buffer.position();
		final ByteArrayOutputStream out=new ByteArrayOutputStream();
		int state=-1;
		final StringBuilder macro=new StringBuilder("");
		int fileLoopCounter = -1;
		final File[] files = (pageFile.isDirectory() ? pageFile.listFiles() : null);
		if((files != null) && (files.length>0))
		{
			Arrays.sort(files,new Comparator<File>()
			{
				@Override
				public int compare(final File arg0, final File arg1)
				{
					final boolean isDir0=arg0.isDirectory();
					final boolean isDir1=arg1.isDirectory();
					if(isDir0 && (!isDir1))
						return -1;
					if(isDir1 && (!isDir0))
						return 1;
					return arg0.getName().compareToIgnoreCase(arg1.getName());
				}
			});
		}
		int fileLoopBufferPosition = -1;
		while(buffer.remaining()>0)
		{
			final char c=(char)buffer.get();
			if(c=='@')
			{
				if(state<0)
					state=buffer.position();
				else
				{
					final Macro m = macros.get(macro.toString().toLowerCase());
					try
					{
						if(m != null)
						{
							switch(m)
							{
							case URLPATH:
								if(request != null)
									out.write((""+request.getUrlPath()).getBytes());
								break;
							case HTTPSTATUS:
								if(status != null)
									out.write((""+status.getStatusCode()).getBytes());
								break;
							case HTTPSTATUSINFO:
								if(status != null)
									out.write(status.description().getBytes());
								break;
							case WEBSERVERVERSION:
								out.write((""+WebServer.VERSION).getBytes());
								break;
							case WEBSERVERNAME:
								out.write((""+WebServer.NAME).getBytes());
								break;
							case WEBSERVERPORT:
								if(request != null)
									out.write((""+request.getClientPort()).getBytes());
								break;
							case STARTFILELOOP:
								fileLoopCounter = 0;
								fileLoopBufferPosition = buffer.position();
								break;
							case ENDFILELOOP:
								fileLoopCounter++ ;
								if((files != null) && (fileLoopCounter >=0) && (fileLoopCounter < files.length))
									buffer.position(fileLoopBufferPosition);
								break;
							case FILETYPE:
								if((files != null) && (fileLoopCounter >=0) && (fileLoopCounter < files.length))
								{
									final File file=files[fileLoopCounter];
									if(file.isDirectory())
										out.write("directory".getBytes());
									else
										out.write("file".getBytes());
								}
								break;
							case FILENAME:
								if((files != null) && (fileLoopCounter >=0) && (fileLoopCounter < files.length))
								{
									final File file=files[fileLoopCounter];
									out.write(file.getName().getBytes());
								}
								break;
							case FILEURLPATH:
								if((files != null) && (fileLoopCounter >=0) && (fileLoopCounter < files.length))
								{
									final File file=files[fileLoopCounter];
									if(request != null)
										out.write((request.getUrlPath()+file.getName()).getBytes());
									if(file.isDirectory())
										out.write("/".getBytes());
								}
								break;
							case FILESIZE:
								if((files != null) && (fileLoopCounter >=0) && (fileLoopCounter < files.length))
								{
									final File file=files[fileLoopCounter];
									if(!file.isDirectory())
										out.write(Long.toString(file.length()).getBytes());
								}
								break;
							case FILELASTMOD:
								if((files != null) && (fileLoopCounter >=0) && (fileLoopCounter < files.length))
								{
									final File file=files[fileLoopCounter];
									out.write(SimpleDateFormat.getDateTimeInstance().format(new Date(file.lastModified())).getBytes());
								}
								break;
							}
						}
						else
							out.write(("@"+macro.toString()+"@").getBytes());
					}
					catch (final Exception e)
					{
					}
					state=-1;
					macro.setLength(0);
				}
			}
			else
			if(state<0)
				out.write(c);
			else
				macro.append(c);
		}
		final ByteBuffer output=ByteBuffer.wrap(out.toByteArray());
		buffer.position(oldPosition);
		return output;
	}
}


text:
![PRONG](https://github.com/JDatPNW/Prong/blob/master/logo/Prong.png)

Making a simple Pong game in processing.

## Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

### Prerequisites

What things you need to install the software and how to install them:

```
a Processing IDE
```

### Installing

A step by step series of examples that tell you have to get a development env running

```
Open the code inside the Processing IDE and run it
```

## Running the tests

At this stage its just tial and error, which works great with processing

## Authors

* **JD** - *Initial work*

## License

This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details


text:
@implementation PlaceAnnotation

@synthesize placeType;
@synthesize placeLocation;
@synthesize placeStation;

- (id)init {
    self = [super init];
    if (self) {
        placeType = kStation;
        placeLocation = kUndefined;
    }
    return self;
}

- (id)copyWithZone:(NSZone *)zone
{
    id copy = [[[self class] alloc] init];

    if (copy) {

        // Set primitives
        [copy setCoordinate:self.coordinate];
        [copy setPlaceType:self.placeType];
        [copy setPlaceLocation:self.placeLocation];

        // Copy NSObject subclasses
        [copy setTitle:[self.title copyWithZone:zone]];
        [copy setSubtitle:[self.subtitle copyWithZone:zone]];
        [copy setPlaceStation:self.placeStation];
    }

    return copy;
}

- (BOOL)isEqual:(id)object {
    if (self == object)
        return true;
    if ([self class] != [object class])
        return false;
    PlaceAnnotation *other = (PlaceAnnotation *)object;
    if (self.placeStation == nil) {
        if (other.placeStation != nil) {
            return false;
        }
    } else if (![self.placeStation isEqual:other.placeStation]) {
        return false;
    }
    return true;
}

- (NSUInteger)hash {
    const NSUInteger prime = 31;
    NSUInteger result = 1;
    result = prime * result + [self.placeStation hash];
    return result;
}

@end


text:
var $export    = require('./_export')
  , ownKeys    = require('./_own-keys')
  , toIObject  = require('./_to-iobject')
  , createDesc = require('./_property-desc')
  , gOPD       = require('./_object-gopd')
  , dP         = require('./_object-dp');

$export($export.S, 'Object', {
  getOwnPropertyDescriptors: function getOwnPropertyDescriptors(object){
    var O       = toIObject(object)
      , getDesc = gOPD.f
      , keys    = ownKeys(O)
      , result  = {}
      , i       = 0
      , key, D;
    while(keys.length > i){
      D = getDesc(O, key = keys[i++]);
      if(key in result)dP.f(result, key, createDesc(0, D));
      else result[key] = D;
    } return result;
  }
});


text:
import { TestBed } from '@angular/core/testing';
import { Component, ViewChild } from '@angular/core';
import * as Infragistics from '../../../dist/npm/igniteui.angular2';

export function main() {
    describe('Infragistics Angular2 Sparkline', () => {

        beforeEach(() => {
            TestBed.configureTestingModule({
                declarations: [ Infragistics.IgSparklineComponent, TestComponent]
            });
        });

        it('should initialize correctly', (done) => {
            var template = '
<ig-sparkline widgetId="sparkLine" [(options)]="opts"></ig-sparkline>
';
            TestBed.overrideComponent(TestComponent, {
                set: {
                    template: template
                }
            });
            TestBed.compileComponents().then(() => {
                let fixture = TestBed.createComponent(TestComponent);
                fixture.detectChanges();
                expect(fixture.debugElement.componentInstance.viewChild instanceof Infragistics.IgSparklineComponent)
                    .toBe(true);
                done();
            });
        });

    });
}

@Component({
    selector: 'test-cmp',
    template: '

' //"Component 'TestComponent' must have either 'template' or 'templateUrl' set."
})
class TestComponent {
    private opts: any;

    @ViewChild(Infragistics.IgSparklineComponent) public viewChild: Infragistics.IgSparklineComponent;

    constructor() {
        this.opts = {
            dataSource: [
                { "OrderDate": "\/Date(836452800000)\/", "ExtendedPrice": 168.0000, "Freight": 32.3800 },
                { "OrderDate": "\/Date(836452800000)\/", "ExtendedPrice": 98.0000, "Freight": 32.3800 },
                { "OrderDate": "\/Date(836452800000)\/", "ExtendedPrice": 174.0000, "Freight": 32.3800 }],
            height: "100px",
            width: "300px",
            valueMemberPath: 'ExtendedPrice',
            labelMemberPath: 'OrderDate'
        };
    }
}


text:
package de.voidplus.leapmotion;

import processing.core.PApplet;
import processing.core.PConstants;
import processing.core.PVector;

public class Finger extends Pointable {

	private com.leapmotion.leap.Finger finger;

	public Finger(PApplet parent, LeapMotion leap, com.leapmotion.leap.Finger finger) {
		super(parent, leap, (com.leapmotion.leap.Pointable) finger);
		this.finger = finger;
	}
	public Finger(PApplet parent, LeapMotion leap, com.leapmotion.leap.Pointable pointable) {
		super(parent, leap, pointable);
	}

	/**
	 * Draw the direction.
	 */
	public void drawDirection(){
		PVector position = this.getPosition();
		PVector direction = this.getDirection();
		float length = this.getLength();

		this.parent.stroke(0);
		this.parent.line(
				position.x,
				position.y,
				position.z,
				position.x+direction.x*length,
				position.y+direction.y*length,
				position.z+direction.z*length
		);
	}

}


text:
Tiempo (en segundos) entre escaneos de la cola deferida

<tt>queue_run_delay</tt>

Este parámetro especifica el tiempo en segundo entre escaneos consecutivos
de la cola deferida por parte del gestor de cola.


text:
/*
 * File:		arm_cm4.c
 * Purpose:		Generic high-level routines for ARM Cortex M4 processors
 *
 * Notes:
 */

#include "common.h"

/***********************************************************************/
/*
 * Configures the ARM system control register for STOP (deep sleep) mode
 * and then executes the WFI instruction to enter the mode.
 *
 * Parameters:
 * none
 *
 * Note: Might want to change this later to allow for passing in a parameter
 *       to optionally set the sleep on exit bit.
 */

void stop (void)
{
	/* Set the SLEEPDEEP bit to enable deep sleep mode (STOP) */
	SCB_SCR |= SCB_SCR_SLEEPDEEP_MASK;

	/* WFI instruction will start entry into STOP mode */
	asm("WFI");
}
/***********************************************************************/
/*
 * Configures the ARM system control register for WAIT (sleep) mode
 * and then executes the WFI instruction to enter the mode.
 *
 * Parameters:
 * none
 *
 * Note: Might want to change this later to allow for passing in a parameter
 *       to optionally set the sleep on exit bit.
 */

void wait (void)
{
	/* Clear the SLEEPDEEP bit to make sure we go into WAIT (sleep) mode instead
	 * of deep sleep.
	 */
	SCB_SCR &= ~SCB_SCR_SLEEPDEEP_MASK;

	/* WFI instruction will start entry into WAIT mode */
	asm("WFI");
}
/***********************************************************************/
/*
 * Change the value of the vector table offset register to the specified value.
 *
 * Parameters:
 * vtor     new value to write to the VTOR
 */

void write_vtor (int vtor)
{
        /* Write the VTOR with the new value */
        SCB_VTOR = vtor;
}
/***********************************************************************/
/*
 * Initialize the NVIC to enable the specified IRQ.
 *
 * NOTE: The function only initializes the NVIC to enable a single IRQ.
 * Interrupts will also need to be enabled in the ARM core. This can be
 * done using the EnableInterrupts macro.
 *
 * Parameters:
 * irq    irq number to be enabled (the irq number NOT the vector number)
 */

void enable_irq (int irq)
{
    int div;

    /* Determine which of the NVICISERs corresponds to the irq */
    div = irq/32;

    switch (div)
    {
    	case 0x0:
              NVICICPR0 = 1 << (irq%32);
              NVICISER0 = 1 << (irq%32);
              break;
    	case 0x1:
              NVICICPR1 = 1 << (irq%32);
              NVICISER1 = 1 << (irq%32);
              break;
    	case 0x2:
              NVICICPR2 = 1 << (irq%32);
              NVICISER2 = 1 << (irq%32);
              break;
    }
}
/***********************************************************************/
/*
 * Initialize the NVIC to disable the specified IRQ.
 *
 * NOTE: The function only initializes the NVIC to disable a single IRQ.
 * If you want to disable all interrupts, then use the DisableInterrupts
 * macro instead.
 *
 * Parameters:
 * irq    irq number to be disabled (the irq number NOT the vector number)
 */

void disable_irq (int irq)
{
    int div;

    /* Determine which of the NVICICERs corresponds to the irq */
    div = irq/32;

    switch (div)
    {
    	case 0x0:
               NVICICER0 = 1 << (irq%32);
              break;
    	case 0x1:
              NVICICER1 = 1 << (irq%32);
              break;
    	case 0x2:
              NVICICER2 = 1 << (irq%32);
              break;
    }
}
/***********************************************************************/
/*
 * Initialize the NVIC to set specified IRQ priority.
 *
 * NOTE: The function only initializes the NVIC to set a single IRQ priority.
 * Interrupts will also need to be enabled in the ARM core. This can be
 * done using the EnableInterrupts macro.
 *
 * Parameters:
 * irq    irq number to be enabled (the irq number NOT the vector number)
 * prio   irq priority. 0-15 levels. 0 max priority
 */

void set_irq_priority (int irq, int prio)
{
    /*irq priority pointer*/
    uint8 *prio_reg;

    /* Determine which of the NVICIPx corresponds to the irq */
    prio_reg = (uint8 *)(((uint32)&NVICIP0) + irq);
    /* Assign priority to IRQ */
    *prio_reg = ( (prio&0xF) << (8 - ARM_INTERRUPT_LEVEL_BITS) );
}
/***********************************************************************/


text:
package com.furkanbayraktar.databinding.common.resolver;

import android.view.View;
import android.widget.CompoundButton;
import com.furkanbayraktar.databinding.exception.FunctionException;
import com.furkanbayraktar.databinding.exception.ResolverException;
import com.furkanbayraktar.databinding.logging.Logger;
import com.furkanbayraktar.databinding.model.BasePOJO;

import java.lang.reflect.InvocationTargetException;

/**
 * Created by Furkan Bayraktar.
 * Created at 8/15/14.
 *
 */
public class FunctionResolver {

    private static FunctionResolver instance;

    private FunctionResolver(){
        Logger.info("FunctionResolver object created.");
    }

    public static FunctionResolver getInstance(){
        if(instance == null){
            instance = new FunctionResolver();
        }
        return instance;
    }

    public void resolve(View view, String tag, BasePOJO object, final Object actionObject) {

        if (actionObject == null) {
            ResolverException ex = new ResolverException("Action object not defined!");
            Logger.error("Action object not defined.", ex);
        } else {
            try {
                Logger.info("Searching for function name...");

                Object[] args = null;
                Class[] classes = null;

                int start = tag.indexOf("#methodName");
                start = tag.indexOf(":", start);
                int end = tag.length();

                if (tag.contains("#args")) {
                    end = tag.indexOf("#args");

                    Logger.info("Searching for function arguments...");

                    String argsString = tag.substring(tag.indexOf(":", end) + 1).trim();
                    String[] argKeys = argsString.split(",");
                    if(view instanceof CompoundButton) {
                        classes = new Class[argKeys.length+1];
                        args = new Object[argKeys.length+1];
                        classes[0] = Boolean.class;
                    }else{
                        classes = new Class[argKeys.length];
                        args = new Object[argKeys.length];
                    }

                    for (int i = 0; i < argKeys.length; i++) {
                        Object temp = PathResolver.getInstance().resolve(argKeys[i], object);
                        if(view instanceof CompoundButton){
                            args[i+1] = temp;
                        }else {
                            args[i] = temp;
                        }
                        if (temp == null) {
                            if(view instanceof CompoundButton){
                                classes[i+1] = Object.class;
                            }else {
                                classes[i] = Object.class;
                            }
                        } else {
                            if(view instanceof CompoundButton) {
                                classes[i+1] = temp.getClass();
                            }else{
                                classes[i] = temp.getClass();
                            }
                        }
                    }

                    Logger.info("Argument search completed.");
                }

                Logger.info("Function name search completed.");

                final String methodName = tag.substring(start + 1, end).trim();

                final Class[] finalClasses = classes;
                final Object[] finalArgs;
                if(args == null) {
                    finalArgs = new Object[1];
                }else{
                    finalArgs = args;
                }

                Logger.info("Setting on click listener for view...");

                if(view instanceof CompoundButton){

                    ((CompoundButton) view).setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
                        @Override
                        public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
                            finalArgs[0] = b;
                            try {
                                if (finalClasses != null) {
                                    actionObject.getClass().getDeclaredMethod(methodName, finalClasses).invoke(actionObject, finalArgs);
                                } else {
                                    actionObject.getClass().getDeclaredMethod(methodName, Boolean.class).invoke(actionObject, b);
                                }
                            } catch (NoSuchMethodException e) {
                                FunctionException ex = new FunctionException("Function not found with name: " + methodName, e);
                                Logger.error("Function not found.", ex);
                            } catch (InvocationTargetException e) {
                                FunctionException ex = new FunctionException("Invocation error for method: " + methodName, e);
                                Logger.error("Invocation error.", ex);
                            } catch (IllegalAccessException e) {
                                FunctionException ex = new FunctionException("Illegal access to method: " + methodName, e);
                                Logger.error("Illegal Access.", ex);
                            } catch (Exception e) {
                                FunctionException ex = new FunctionException("Unexpected error during call for method: " + methodName, e);
                                Logger.error("Unexpected Error.", ex);
                            }
                        }
                    });

                }else {
                    view.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {
                            try {
                                if (finalClasses != null) {
                                    actionObject.getClass().getDeclaredMethod(methodName, finalClasses).invoke(actionObject, finalArgs);
                                } else {
                                    actionObject.getClass().getDeclaredMethod(methodName).invoke(actionObject);
                                }
                            } catch (NoSuchMethodException e) {
                                FunctionException ex = new FunctionException("Function not found with name: " + methodName, e);
                                Logger.error("Function not found.", ex);
                            } catch (InvocationTargetException e) {
                                FunctionException ex = new FunctionException("Invocation error for method: " + methodName, e);
                                Logger.error("Invocation error.", ex);
                            } catch (IllegalAccessException e) {
                                FunctionException ex = new FunctionException("Illegal access to method: " + methodName, e);
                                Logger.error("Illegal Access.", ex);
                            } catch (Exception e) {
                                FunctionException ex = new FunctionException("Unexpected error during call for method: " + methodName, e);
                                Logger.error("Unexpected Error.", ex);
                            }
                        }
                    });
                }

                Logger.info("On click listener set.");

            } catch (Exception ex) {
                Logger.error("Unexpected error.", ex);
            }
        }
    }
}


text:
package mods.immibis.redlogic.api.wiring;

/**
 * Marker interface for insulated wire tile entities.
 */
public interface IInsulatedRedstoneWire extends IRedstoneWire {
	/**
	 * Returns the colour as a standard Minecraft wool colour.
	 * 0=white, 15=black
	 */
	public int getInsulatedWireColour();
}