From a6e879db912f1089410d340bb31c3820e46b955f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Minisini?= Date: Thu, 25 Mar 2010 11:16:33 +0000 Subject: [PATCH] [INTERPRETER] * NEW: Application.Startup is a new property that returns the name of the startup class. * NEW: Class.AutoCreate is a new method that creates the automatic instance of a class, and returns it. It returns NULL if the class is not auto-creatable. git-svn-id: svn://localhost/gambas/trunk@2820 867c0c6c-44f3-4631-809d-bfa615b0a4ec --- main/gbx/gbx_c_application.c | 7 +++++++ main/gbx/gbx_c_class.c | 19 ++++++++++++++----- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/main/gbx/gbx_c_application.c b/main/gbx/gbx_c_application.c index 0529a9a9b..a3eac0e14 100644 --- a/main/gbx/gbx_c_application.c +++ b/main/gbx/gbx_c_application.c @@ -291,6 +291,12 @@ BEGIN_PROPERTY(CAPPLICATION_daemon) END_PROPERTY +BEGIN_PROPERTY(Application_Startup) + + GB_ReturnString(PROJECT_startup); + +END_PROPERTY + BEGIN_PROPERTY(System_Language) @@ -408,6 +414,7 @@ GB_DESC NATIVE_App[] = GB_STATIC_PROPERTY_READ("Dir", "i", CAPPLICATION_dir), GB_STATIC_PROPERTY("Return", "i", CAPPLICATION_return), GB_STATIC_PROPERTY("Daemon", "b", CAPPLICATION_daemon), + GB_STATIC_PROPERTY_READ("Startup", "s", Application_Startup), GB_END_DECLARE }; diff --git a/main/gbx/gbx_c_class.c b/main/gbx/gbx_c_class.c index 8c6350770..1d085605b 100644 --- a/main/gbx/gbx_c_class.c +++ b/main/gbx/gbx_c_class.c @@ -291,6 +291,17 @@ BEGIN_PROPERTY(Class_Instance) END_PROPERTY +BEGIN_METHOD_VOID(Class_AutoCreate) + + CLASS *class = OBJECT(CLASS); + + if (!class->auto_create) + GB_ReturnNull(); + else + GB_ReturnObject(CLASS_auto_create(class, 0)); + +END_METHOD + /**** Symbol ***************************************************************/ @@ -701,16 +712,13 @@ BEGIN_METHOD(Object_Call, GB_OBJECT object; GB_STRING method; GB_OBJECT params) void *object = VARG(object); GB_FUNCTION func; GB_ARRAY params = VARGOPT(params, NULL); - CLASS *class; if (GB_CheckObject(object)) return; - - class = OBJECT_class(object); - + if (GB_GetFunction(&func, object, name, NULL, NULL)) { - GB_Error((char *)E_NSYMBOL, name, class->name); + GB_Error((char *)E_NSYMBOL, name, OBJECT_class(object)->name); return; } @@ -896,6 +904,7 @@ GB_DESC NATIVE_Class[] = GB_PROPERTY_READ("Count", "i", Class_Count), GB_PROPERTY_READ("Instance", "o", Class_Instance), GB_PROPERTY_READ("Symbols", "String[]", Class_Symbols), + GB_METHOD("AutoCreate", "o", Class_AutoCreate, NULL), GB_CONSTANT("Variable", "i", 1), GB_CONSTANT("Property", "i", 2),