~ubuntu-branches/ubuntu/gutsy/blender/gutsy-security

« back to all changes in this revision

Viewing changes to source/blender/python/api2_2x/bpy.c

  • Committer: Bazaar Package Importer
  • Author(s): Florian Ernst
  • Date: 2007-05-17 11:47:59 UTC
  • mfrom: (1.2.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20070517114759-yp4ybrnhp2u7pk66
Tags: 2.44-1
* New upstream release.
* Drop debian/patches/01_64bits_stupidity, not needed anymore: as of this
  version blender is 64 bits safe again. Adjust README.Debian accordingly.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* 
 
2
 * $Id: bpy.c,v 1.2 2007/04/18 22:53:20 campbellbarton Exp $
 
3
 * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
 
4
 *
 
5
 * This program is free software; you can redistribute it and/or
 
6
 * modify it under the terms of the GNU General Public License
 
7
 * as published by the Free Software Foundation; either version 2
 
8
 * of the License, or (at your option) any later version. The Blender
 
9
 * Foundation also sells licenses for use in proprietary software under
 
10
 * the Blender License.  See http://www.blender.org/BL/ for information
 
11
 * about this.
 
12
 *
 
13
 * This program is distributed in the hope that it will be useful,
 
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
16
 * GNU General Public License for more details.
 
17
 *
 
18
 * You should have received a copy of the GNU General Public License
 
19
 * along with this program; if not, write to the Free Software Foundation,
 
20
 * Inc., 59 Temple Place - Suite 330, Boston, MA        02111-1307, USA.
 
21
 *
 
22
 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
 
23
 * All rights reserved.
 
24
 *
 
25
 * This is a new part of Blender.
 
26
 *
 
27
 * Contributor(s): Michel Selten, Willian P. Germano, Joseph Gilbert,
 
28
 * Campbell Barton
 
29
 *
 
30
 * ***** END GPL/BL DUAL LICENSE BLOCK *****
 
31
*/
 
32
 
 
33
/* for open, close in Blender_Load */
 
34
 
 
35
#include "BLI_blenlib.h"
 
36
#include "BKE_global.h"
 
37
#include "BKE_utildefines.h"
 
38
#include "BKE_scene.h"
 
39
#include "BKE_main.h"
 
40
 
 
41
#include "DNA_scene_types.h"
 
42
 
 
43
#include "Types.h"
 
44
#include "Library.h"
 
45
 
 
46
#include "bpy.h"
 
47
#include "bpy_data.h"
 
48
#include "bpy_config.h"
 
49
 
 
50
/*****************************************************************************/
 
51
/* Global variables      */
 
52
/*****************************************************************************/
 
53
PyObject *g_bpydict;
 
54
 
 
55
/*****************************************************************************/
 
56
/* Function:            initBlender              */
 
57
/*****************************************************************************/
 
58
 
 
59
void m_bpy_init(void)
 
60
{
 
61
        PyObject *module;
 
62
        PyObject *dict;
 
63
        
 
64
        /* G.scene should only aver be NULL if blender is executed in 
 
65
        background mode, not loading a blend file and executing a python script eg.
 
66
        blender -P somescript.py -b
 
67
        The if below solves the segfaults that happen when python runs and
 
68
        G.scene is NULL */
 
69
        if(G.background && G.main->scene.first==NULL) {
 
70
                Scene *sce= add_scene("1");
 
71
                /*set_scene(sce);*/ /* causes a crash */
 
72
                G.scene= sce;
 
73
        }
 
74
        
 
75
        module = Py_InitModule3("bpy", NULL, "The main bpy module");
 
76
 
 
77
        types_InitAll();        /* set all our pytypes to &PyType_Type */
 
78
 
 
79
        dict = PyModule_GetDict(module);
 
80
        g_bpydict = dict;
 
81
        
 
82
        PyModule_AddObject( module, "config", Config_CreatePyObject() );
 
83
        PyDict_SetItemString( dict, "data", Data_Init());
 
84
        PyDict_SetItemString( dict, "libraries", Library_Init(  ) );
 
85
        
 
86
}