Commit 77b60f7b authored by Robert Bradshaw's avatar Robert Bradshaw

Module is main flag for embedded mode.

parent 9b7cc754
...@@ -265,6 +265,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): ...@@ -265,6 +265,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
code = globalstate['before_global_var'] code = globalstate['before_global_var']
code.putln('#define __Pyx_MODULE_NAME "%s"' % self.full_module_name) code.putln('#define __Pyx_MODULE_NAME "%s"' % self.full_module_name)
code.putln("int %s%s = %s;" % (Naming.module_is_main, self.full_module_name.replace('.', '__'), int(Options.embed)))
code.putln("") code.putln("")
code.putln("/* Implementation of %s */" % env.qualified_name) code.putln("/* Implementation of %s */" % env.qualified_name)
self.generate_const_definitions(env, code) self.generate_const_definitions(env, code)
...@@ -1835,12 +1836,13 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): ...@@ -1835,12 +1836,13 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
env.module_cname, env.module_cname,
Naming.builtins_cname, Naming.builtins_cname,
code.error_goto(self.pos))) code.error_goto(self.pos)))
if Options.embed: code.putln("if (%s%s) {" % (Naming.module_is_main, self.full_module_name.replace('.', '__')))
code.putln( code.putln(
'if (__Pyx_SetAttrString(%s, "__name__", %s) < 0) %s;' % ( 'if (__Pyx_SetAttrString(%s, "__name__", %s) < 0) %s;' % (
env.module_cname, env.module_cname,
self.__main__cname, self.__main__cname,
code.error_goto(self.pos))) code.error_goto(self.pos)))
code.putln("}")
if Options.pre_import is not None: if Options.pre_import is not None:
code.putln( code.putln(
'%s = PyImport_AddModule(__Pyx_NAMESTR("%s"));' % ( '%s = PyImport_AddModule(__Pyx_NAMESTR("%s"));' % (
......
...@@ -43,6 +43,7 @@ vtabptr_prefix = pyrex_prefix + "vtabptr_" ...@@ -43,6 +43,7 @@ vtabptr_prefix = pyrex_prefix + "vtabptr_"
vtabstruct_prefix = pyrex_prefix + "vtabstruct_" vtabstruct_prefix = pyrex_prefix + "vtabstruct_"
opt_arg_prefix = pyrex_prefix + "opt_args_" opt_arg_prefix = pyrex_prefix + "opt_args_"
convert_func_prefix = pyrex_prefix + "convert_" convert_func_prefix = pyrex_prefix + "convert_"
module_is_main = pyrex_prefix + "module_is_main_"
args_cname = pyrex_prefix + "args" args_cname = pyrex_prefix + "args"
pykwdlist_cname = pyrex_prefix + "pyargnames" pykwdlist_cname = pyrex_prefix + "pyargnames"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment