2 * $Id: KX_PythonMain.cpp 37750 2011-06-27 09:27:56Z sjoerd $
4 * ***** BEGIN GPL LICENSE BLOCK *****
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
21 * All rights reserved.
23 * The Original Code is: all of this file.
25 * Contributor(s): none yet.
27 * ***** END GPL LICENSE BLOCK *****
29 /** \file gameengine/Ketsji/KX_KetsjiPythonMain.cpp
33 #include "KX_PythonMain.h"
39 #include "RNA_access.h"
40 #include "MEM_guardedalloc.h"
48 extern "C" char *KX_GetPythonMain(struct Scene* scene)
50 //examine custom scene properties
53 RNA_id_pointer_create(&scene->id, &sceneptr);
55 PropertyRNA *pymain = RNA_struct_find_property(&sceneptr, "[\"__main__\"]");
56 if (pymain == NULL) return NULL;
59 python_main = RNA_property_string_get_alloc(&sceneptr, pymain, NULL, 0, &len);
63 extern "C" char *KX_GetPythonCode(Main *main, char *python_main)
65 PointerRNA mainptr, txtptr;
68 RNA_main_pointer_create(main, &mainptr);
69 texts = RNA_struct_find_property(&mainptr, "texts");
70 char *python_code = NULL;
71 int ok = RNA_property_collection_lookup_string(&mainptr, texts, python_main, &txtptr);
73 Text *text = (Text *) txtptr.data;
74 python_code = txt_to_buf(text);