0.3.3 • Published 11 years ago

jsoop v0.3.3

Weekly downloads
28
License
-
Repository
github
Last release
11 years ago

jsoop

It's designed to provide Object-oriented programming (OOP) support for javascript.

Introduction

There are many kinds of Object-oriented programming (OOP) libs for javascript, and I never think I would write one. When I try to migrate my javascript project into Node.JS, and try to hide the difference between client and server, to make it work on both client and Node.js. I found there no OOP javascript libs is design for this goal.

I like Script#'s OOP programming style, and Script# is now under Microsoft Permissive License (Ms-PL). So this is posible to migrate it. I make some change to make it work on node.js, and keep the feature that run on client side. also I want make it can co-work with Script#'s original's javascript runtime lib.

Features

  • Supports node.js
  • Supports client side
  • Work together with Script#'s javascript runtime lib

How it work

jsoop is a node.js javascript module, and it puts typeName, baseType, interfaces, modules RTTI into class type(function), so when new a class intance, it bind all base member into derived class's prototype, and so on.

All the RTTI is transparent maintained, so it's load is easy to estimate.

Samples

//namespace

var unitTest = {};

//////////////////////////////////////////////////////////////////////////////
//enum unitTest.DemoEnum
unitTest.DemoEnum = function unitTest_DemoEnum() {
    throw jsoop.errorNotImplemented();
};

unitTest.DemoEnum.prototype = {
    val1: 1,
    val2: 2,
    val3: 3
};

jsoop.registerEnum(jsoop.setTypeName(unitTest.DemoEnum, 'unitTest.DemoEnum'));


//////////////////////////////////////////////////////////////////////////////
//interface unitTest.DemoIntf
unitTest.IDemoIntf = function unitTest_IDemoIntf() {
};

unitTest.IDemoIntf.prototype = {
};

jsoop.registerInterface(jsoop.setTypeName(unitTest.IDemoIntf, 'unitTest.IDemoIntf'));

//////////////////////////////////////////////////////////////////////////////
//interface unitTest.DemoIntf2
unitTest.IDemoIntf2 = function unitTest_IDemoIntf2() {
};

unitTest.IDemoIntf2.prototype = {
};

jsoop.registerInterface(jsoop.setTypeName(unitTest.IDemoIntf2, 'unitTest.IDemoIntf2'));

//////////////////////////////////////////////////////////////////////////////
//module unitTest.DemoMod
unitTest.DemoMod = function unitTest_DemoMod() {
};

function unitTest_DemoMod$modFoo() {
    return 'unitTest.DemoMod';
}

unitTest.DemoMod.prototype = {
    modFoo: unitTest_DemoMod$modFoo
};

jsoop.registerModule(jsoop.setTypeName(unitTest.DemoMod, 'unitTest.DemoMod'));

//////////////////////////////////////////////////////////////////////////////
//module unitTest.DemoMod
unitTest.DemoMod2 = function unitTest_DemoMod2() {
};

function unitTest_DemoMod2$mod2Foo() {
    return 'unitTest.DemoMod2';
}

unitTest.DemoMod2.prototype = {
    mod2Foo: unitTest_DemoMod2$mod2Foo
};

jsoop.registerModule(jsoop.setTypeName(unitTest.DemoMod2, 'unitTest.DemoMod2'));

//////////////////////////////////////////////////////////////////////////////
//class unitTest.DemoBase
unitTest.DemoBase = function unitTest_DemoBase() {
};


function unitTest_DemoBase$foo() {
    return 'unitTest.DemoBase';
}

unitTest.DemoBase.prototype = {
    foo: unitTest_DemoBase$foo
};

jsoop.registerClass(jsoop.setTypeName(unitTest.DemoBase, 'unitTest.DemoBase'), null, [unitTest.IDemoIntf, unitTest.IDemoIntf2], [unitTest.DemoMod, unitTest.DemoMod2]);

//////////////////////////////////////////////////////////////////////////////
//class unitTest.Demo
unitTest.Demo = function unitTest_Demo() {
    jsoop.initializeBase(unitTest.Demo, this);
};


function unitTest_Demo$foo() {
    return 'unitTest.Demo';
}

function unitTest_Demo$baseFoo() {
    return jsoop.callBaseMethod(unitTest.Demo, this, "foo");
}

unitTest.Demo.prototype = {
    foo: unitTest_Demo$foo,
    baseFoo: unitTest_Demo$baseFoo
};

jsoop.registerClass(jsoop.setTypeName(unitTest.Demo, 'unitTest.Demo'), unitTest.DemoBase);

licence

Copyright 2012, Yin MingJun - email: yinmingjuncn@gmail.com Dual licensed under the MIT or GPL Version 2 licenses. http://jquery.org/license

0.3.3

11 years ago

0.3.2

11 years ago

0.3.0

11 years ago

0.2.8

11 years ago

0.2.6

11 years ago

0.2.5

11 years ago

0.2.3

11 years ago

0.2.2

11 years ago

0.2.1

11 years ago