Added code samples to use with GObject Introspection

* JavaScript
* Python
* LUA
* Perl
This commit is contained in:
Gergely Polonkai 2013-09-27 02:11:17 +02:00
parent 8f52abadf0
commit 16003cebe9
4 changed files with 68 additions and 0 deletions

15
exapmles/basic.js Normal file
View File

@ -0,0 +1,15 @@
var Swe = imports.gi.SweGlib;
Swe.init();
var timestamp = new Swe.Timestamp();
timestamp.set_gregorian_full(1983, 3, 7, 11, 54, 45, 0, 1);
moment = new Swe.Moment();
moment.add_all_planets();
moment.set_timestamp(timestamp);
moment.set_coordinates(19.03990999, 47.49801000, 280);
moment.set_house_system(Swe.HouseSystem.PLACIDUS);
planet = moment.get_planet(Swe.Planet.SUN);
log(planet.position);

17
exapmles/basic.lua Normal file
View File

@ -0,0 +1,17 @@
local lgi = require 'lgi'
local SweGlib = lgi.require('SweGlib', '1.0')
SweGlib.init()
local timestamp = SweGlib.Timestamp.new()
timestamp:set_gregorian_full(1983, 3, 7, 11, 54, 45, 0, 1)
local moment = SweGlib.Moment.new()
moment:set_timestamp(timestamp)
moment:set_timestamp(timestamp)
moment:set_coordinates(19.03990999, 47.49801000, 280)
moment:set_house_system(SweGlib.HouseSystem.PLACIDUS)
moment:add_all_planets()
local planet = moment:get_planet(SweGlib.Planet.SUN)
io.write(planet.position, "\n")

21
exapmles/basic.pl Normal file
View File

@ -0,0 +1,21 @@
package SweGlib;
use Glib::Object::Introspection;
Glib::Object::Introspection->setup(basename => 'SweGlib', version => '1.0', package => 'SweGlib');
package main;
SweGlib::init();
$timestamp = SweGlib::Timestamp->new();
$timestamp->set_gregorian_full(1983, 3, 7, 11, 54, 45, 0, 1);
$moment = SweGlib::Moment->new();
$moment->set_timestamp($timestamp);
$moment->set_coordinates(19.0390999, 47.49801000, 280);
$moment->set_house_system("placidus");
$moment->add_all_planets();
$planet = $moment->get_planet("sun");
print($planet->position, "\n");

15
exapmles/basic.py Normal file
View File

@ -0,0 +1,15 @@
from gi.repository import SweGlib
SweGlib.init()
timestamp = SweGlib.Timestamp()
timestamp.set_gregorian_full(1983, 3, 7, 11, 54, 45, 0, 1)
moment = SweGlib.Moment()
moment.set_timestamp(timestamp)
moment.set_coordinates(19.03990999, 47.49801000, 280)
moment.set_house_system(SweGlib.HouseSystem.PLACIDUS)
moment.add_all_planets()
planet = moment.get_planet(SweGlib.Planet.SUN)
print planet.position