Permalink
Browse files

Tiddy up the code and use unified conventions throughout the code.

  • Loading branch information...
1 parent 9af4b60 commit 21ff28136cefb9e2cf9d3bc290ed39b5e7a09e17 Josh Roesslein committed Dec 23, 2010
Showing 421 changed files with 27,545 additions and 25,239 deletions.
View
397 LICENSE
Oops, something went wrong.
View
@@ -1,180 +0,0 @@
-#!/usr/bin/env ruby
-#
-# script for creating a template module that can
-# allow you to get started really fast with basic
-# files pre-created
-#
-#
-require 'fileutils'
-
-dir = File.expand_path(File.dirname(__FILE__))
-
-arg = ARGV.first
-if arg.nil?
- $stderr.puts "Usage: create.rb <module_name>"
- exit 1
-end
-
-name = arg.downcase
-
-if name=~/^ti\./
- s = name.index '.'
- name = name[s+1..-1]
-end
-
-module_name = name.capitalize
-module_dir_name = "ti.#{module_name}"
-header_define = name.upcase
-module_lib_name = module_dir_name.gsub '.','_'
-
-FileUtils.mkdir_p module_dir_name unless File.exists?(module_dir_name)
-
-bh = File.open(File.join(module_dir_name,"#{name}_binding.h"),'w')
-bh.puts <<-END
-/**
- * Appcelerator Titanium - licensed under the Apache Public License 2
- * see LICENSE in the root folder for details on the license.
- * Copyright (c) 2009 Appcelerator, Inc. All Rights Reserved.
- */
-
-#ifndef _#{header_define}_BINDING_H_
-#define _#{header_define}_BINDING_H_
-
-#include <kroll/kroll.h>
-
-namespace ti
-{
- class #{module_name}Binding : public StaticBoundObject
- {
- public:
- #{module_name}Binding(KObjectRef);
- protected:
- virtual ~#{module_name}Binding();
- private:
- KObjectRef global;
- };
-}
-
-#endif
-END
-bh.close
-
-
-bc = File.open(File.join(module_dir_name,"#{name}_binding.cpp"),'w')
-bc.puts <<-END
-/**
- * Appcelerator Titanium - licensed under the Apache Public License 2
- * see LICENSE in the root folder for details on the license.
- * Copyright (c) 2009 Appcelerator, Inc. All Rights Reserved.
- */
-#include <kroll/kroll.h>
-#include "#{name}_binding.h"
-
-namespace ti
-{
- #{module_name}Binding::#{module_name}Binding(KObjectRef global) : global(global)
- {
- }
- #{module_name}Binding::~#{module_name}Binding()
- {
- }
-}
-END
-bc.close
-
-mh = File.open(File.join(module_dir_name,"#{name}_module.h"),'w')
-mh.puts <<-END
-/**
- * Appcelerator Titanium - licensed under the Apache Public License 2
- * see LICENSE in the root folder for details on the license.
- * Copyright (c) 2009 Appcelerator, Inc. All Rights Reserved.
- */
-
-#ifndef TI_#{header_define}_MODULE_H_
-#define TI_#{header_define}_MODULE_H_
-
-#include <kroll/kroll.h>
-
-#if defined(OS_OSX) || defined(OS_LINUX)
-#define EXPORT __attribute__((visibility("default")))
-#define TITANIUM_#{header_define}_API EXPORT
-#elif defined(OS_WIN32)
-# ifdef TITANIUM_#{header_define}_API_EXPORT
-# define TITANIUM_#{header_define}_API __declspec(dllexport)
-# else
-# define TITANIUM_#{header_define}_API __declspec(dllimport)
-# endif
-# define EXPORT __declspec(dllexport)
-#endif
-
-namespace ti
-{
- class TITANIUM_#{header_define}_API #{module_name}Module : public kroll::Module
- {
- KROLL_MODULE_CLASS(#{module_name}Module)
-
- private:
- kroll::KObjectRef binding;
- };
-
-}
-#endif
-END
-mh.close
-
-mc = File.open(File.join(module_dir_name,"#{name}_module.cpp"),'w')
-mc.puts <<-END
-/**
- * Appcelerator Titanium - licensed under the Apache Public License 2
- * see LICENSE in the root folder for details on the license.
- * Copyright (c) 2009 Appcelerator, Inc. All Rights Reserved.
- */
-#include <kroll/kroll.h>
-#include "#{name}_module.h"
-#include "#{name}_binding.h"
-
-using namespace kroll;
-using namespace ti;
-
-namespace ti
-{
- KROLL_MODULE(#{module_name}Module,STRING(MODULE_NAME), STRING(MODULE_VERSION));
-
- void #{module_name}Module::Initialize()
- {
- // load our variables
- this->binding = new #{module_name}Binding(host->GetGlobalObject());
-
- // set our #{module_dir_name}
- KValueRef value = Value::NewObject(this->binding);
- host->GetGlobalObject()->Set("#{module_name}", value);
- }
-
- void #{module_name}Module::Stop()
- {
- }
-
-}
-END
-mc.close
-
-
-sc = File.open(File.join(module_dir_name,"SConscript"),'w')
-sc.puts <<-END
-#!/usr/bin/env python
-import os
-Import('build')
-
-env = build.env.Clone();
-env.Append(CPPDEFINES = ('TITANIUM_#{header_define}_API_EXPORT', 1))
-build.add_thirdparty(env, 'poco')
-
-m = build.add_module('ti.#{name}', env=env)
-t = env.SharedLibrary(target = m.build_dir + '/ti#{name}module', source = Glob('*.cpp'))
-build.mark_build_target(t)
-END
-sc.close
-
-puts "Created: #{module_dir_name}"
-exit 0
-
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2008-2010 Appcelerator, Inc. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "AppModule.h"
+
+#include <Poco/File.h>
+
+#include "ApplicationConfig.h"
+#include "Application.h"
+#include "Properties.h"
+
+namespace Titanium {
+
+KROLL_MODULE(AppModule, STRING(MODULE_NAME), STRING(MODULE_VERSION));
+
+static Logger* GetLogger()
+{
+ static Logger* logger = Logger::Get("App");
+ return logger;
+}
+
+void AppModule::Initialize()
+{
+ // Nudge the creation of the first app config instance.
+ ApplicationConfig* config = ApplicationConfig::Instance();
+ if (config)
+ GetLogger()->Debug("Loaded config file successfully");
+
+ KObjectRef global(host->GetGlobalObject());
+ KObjectRef binding = new Application(host, host->GetGlobalObject());
+ host->GetGlobalObject()->SetObject("App", binding);
+
+ // Create the data directory for the app, if it doesn't exist.
+ std::string dataPath(host->GetApplication()->GetDataPath());
+ Poco::File dataPathFile(dataPath);
+ if (!dataPathFile.exists())
+ dataPathFile.createDirectories();
+
+ std::string propFilename(FileUtils::Join(
+ dataPath.c_str(), "application.properties", 0));
+
+ // @tiapi(property=True,type=App.Properties,name=App.Properties,since=0.2)
+ // @tiapi The application's private Properties object
+ binding->SetObject("Properties", new Properties(propFilename));
+}
+
+void AppModule::Stop()
+{
+ host->GetGlobalObject()->SetNull("App");
+}
+
+} // namespace Titanium
View
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2008-2010 Appcelerator, Inc. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef AppModule_h
+#define AppModule_h
+
+#include <kroll/kroll.h>
+
+namespace Titanium {
+
+class AppModule : public kroll::Module
+{
+ KROLL_MODULE_CLASS(AppModule)
+};
+
+} // namespace Titanium
+
+#endif
Oops, something went wrong.

0 comments on commit 21ff281

Please sign in to comment.