# Path: pybindgen/module.py
# class MultiSectionFactory(object):
#     """
#     Abstract base class for objects providing support for
#     multi-section code generation, i.e., splitting the generated C/C++
#     code into multiple files.  The generated code will generally have
#     the following structure:
# 
#        1. For each section there is one source file specific to that section;
# 
#        2. There is a I{main} source file, e.g. C{foomodule.cc}.  Code
#        that does not belong to any section will be included in this
#        main file;
# 
#        3. Finally, there is a common header file, (e.g. foomodule.h),
#        which is included by the main file and section files alike.
#        Typically this header file contains function prototypes and
#        type definitions.
# 
#     @see: L{Module.generate}
# 
#     """
#     def get_section_code_sink(self, section_name):
#         """
#         Create and/or return a code sink for a given section.
# 
#         :param section_name: name of the section
#         :return: a L{CodeSink} object that will receive generated code belonging to the section C{section_name}
#         """
#         raise NotImplementedError
#     def get_main_code_sink(self):
#         """
#         Create and/or return a code sink for the main file.
#         """
#         raise NotImplementedError
#     def get_common_header_code_sink(self):
#         """
#         Create and/or return a code sink for the common header.
#         """
#         raise NotImplementedError
#     def get_common_header_include(self):
#         """
#         Return the argument for an #include directive to include the common header.
# 
#         :returns: a string with the header name, including surrounding
#         "" or <>.  For example, '"foomodule.h"'.
#         """
#         raise NotImplementedError
# 
# Path: pybindgen/typehandlers/codesink.py
# class FileCodeSink(CodeSink):
#     """A code sink that writes to a file-like object"""
#     def __init__(self, file_):
#         """
#         :param file_: a file like object
#         """
#         CodeSink.__init__(self)
#         self.file = file_
# 
#     def __repr__(self):
#         return "<pybindgen.typehandlers.codesink.FileCodeSink %r>" % (self.file.name,)
# 
#     def writeln(self, line=''):
#         """Write one or more lines of code"""
#         self.file.write('\n'.join(self._format_code(line)))
#         self.file.write('\n')
# 
#     def __lt__(self, other):
#         if isinstance(other, FileCodeSink):
#             return self.file.name < other.file.name


import sys
import os.path
import pybindgen
import foomodulegen_split
import foomodulegen_module1, foomodulegen_module2
import foomodulegen_common
        import cProfile as profile
from pybindgen.module import MultiSectionFactory
from pybindgen import (FileCodeSink)
#! /usr/bin/env python
from __future__ import unicode_literals, print_function




# TODO(cnicolaou): get the multi section tests working

class MyMultiSectionFactory(MultiSectionFactory):

    def __init__(self, dir):
        self.main_file_name = os.path.join(dir, "foomodule4.cc")
        self.main_sink = FileCodeSink(open(self.main_file_name, "wt"))
        self.header_name = "foomodule4.h"
        header_file_name = os.path.join(dir, self.header_name)

# Path: pybindgen/module.py
# class MultiSectionFactory(object):
#     """
#     Abstract base class for objects providing support for
#     multi-section code generation, i.e., splitting the generated C/C++
#     code into multiple files.  The generated code will generally have
#     the following structure:
# 
#        1. For each section there is one source file specific to that section;
# 
#        2. There is a I{main} source file, e.g. C{foomodule.cc}.  Code
#        that does not belong to any section will be included in this
#        main file;
# 
#        3. Finally, there is a common header file, (e.g. foomodule.h),
#        which is included by the main file and section files alike.
#        Typically this header file contains function prototypes and
#        type definitions.
# 
#     @see: L{Module.generate}
# 
#     """
#     def get_section_code_sink(self, section_name):
#         """
#         Create and/or return a code sink for a given section.
# 
#         :param section_name: name of the section
#         :return: a L{CodeSink} object that will receive generated code belonging to the section C{section_name}
#         """
#         raise NotImplementedError
#     def get_main_code_sink(self):
#         """
#         Create and/or return a code sink for the main file.
#         """
#         raise NotImplementedError
#     def get_common_header_code_sink(self):
#         """
#         Create and/or return a code sink for the common header.
#         """
#         raise NotImplementedError
#     def get_common_header_include(self):
#         """
#         Return the argument for an #include directive to include the common header.
# 
#         :returns: a string with the header name, including surrounding
#         "" or <>.  For example, '"foomodule.h"'.
#         """
#         raise NotImplementedError
# 
# Path: pybindgen/typehandlers/codesink.py
# class FileCodeSink(CodeSink):
#     """A code sink that writes to a file-like object"""
#     def __init__(self, file_):
#         """
#         :param file_: a file like object
#         """
#         CodeSink.__init__(self)
#         self.file = file_
# 
#     def __repr__(self):
#         return "<pybindgen.typehandlers.codesink.FileCodeSink %r>" % (self.file.name,)
# 
#     def writeln(self, line=''):
#         """Write one or more lines of code"""
#         self.file.write('\n'.join(self._format_code(line)))
#         self.file.write('\n')
# 
#     def __lt__(self, other):
#         if isinstance(other, FileCodeSink):
#             return self.file.name < other.file.name


# Path: tests/foomodulegen4.py
import sys
import os.path
import pybindgen
import foomodulegen_split
import foomodulegen_module1, foomodulegen_module2
import foomodulegen_common
        import cProfile as profile
from pybindgen.module import MultiSectionFactory
from pybindgen import (FileCodeSink)

#! /usr/bin/env python
from __future__ import unicode_literals, print_function




# TODO(cnicolaou): get the multi section tests working

class MyMultiSectionFactory(MultiSectionFactory):

    def __init__(self, dir):
        self.main_file_name = os.path.join(dir, "foomodule4.cc")
        self.main_sink = FileCodeSink(open(self.main_file_name, "wt"))
        self.header_name = "foomodule4.h"
        header_file_name = os.path.join(dir, self.header_name)

        self.header_sink = FileCodeSink(open(header_file_name, "wt"))