text:
(function() {
	'use strict';

	process.env.debug_sql = true;

	var   log 			= require('ee-log')
		, assert 		= require('assert')
		, async 		= require('ee-async')
		, fs 			= require('fs')
		, ORM 			= require('related');

	var   NestedSet = require('../')
		, sqlStatments
		, extension
		, orm
		, db;

	// sql for test db
	sqlStatments = fs.readFileSync(__dirname+'/db.postgres.sql').toString().split(';').map(function(input){
		return input.trim().replace(/\n/gi, ' ').replace(/\s{2,}/g, ' ')
	}).filter(function(item){
		return item.length;
	});

	describe('Travis', function(){
		it('should have set up the test db', function(done){
			var config;

			try {
				config = require('../config.js').db
			} catch(e) {
				config = [{
					  type: 'postgres'
					, schema: 'related_nestedset_test'
					, database: 'test'
					, hosts: [{
						  host 		: 'localhost'
						, username 	: 'postgres'
						, password 	: ''
						, port 		: 5432
						, mode 		: 'readwrite'
						, database 	: 'test'
					}]
				}];
			}

			this.timeout(5000);
			orm = new ORM(config);
			orm.load(done);
		});

		it('should be able to drop & create the testing schema ('+sqlStatments.length+' raw SQL queries)', function(done) {
			orm.getDatabase('related_nestedset_test').getConnection('write').then((connection) => {
                return new Promise((resolve, reject) => {
                    let exec = (index) => {
                        if (sqlStatments[index]) {
                            connection.query(sqlStatments[index]).then(() => {
                                exec(index + 1);
                            }).catch(reject);
                        }
                        else resolve();
                    }

                    exec(0);
                });
            }).then(() => {
                done();
            }).catch(done);
		});
	});

	var getJSON = function(input) {
		if (Array.isArray(input)) return input.map(getJSON);
		else if (typeof input === 'object') {
			var output = input.toJSON ? input.toJSON() : input;
			if (input.children) output.children = getJSON(input.children);
			return output;
		}
		else return input;
	}

	var expect = function(val, cb){
		if (typeof val === 'string') val = JSON.parse(val);

		return function(err, result) { //log(JSON.stringify(result));
			try {
				assert.deepEqual(getJSON(result), val);
			} catch (err) {
				return cb(err);
			}
			cb();
		}
	};

	describe('The NestedSet Extension', function() {
		var oldDate;

		it('should not crash when instatiated', function() {
			db = orm.related_nestedset_test;
			extension = new NestedSet();
		});

		it('should not crash when injected into the orm', function(done) {
			orm.use(extension);
			orm.reload(done);
		});

		it('set var should work ;)', function() {
			db = orm.related_nestedset_test;
		});

	});

	describe('[Inserting]', function() {
		it('should set corrent position parameters when inserting records', function(done) {

			new db.tree({name: 'root1'}).setParent().save(function(err, node) {
				if (err) done(err);
				else {
					assert.equal(node.left, 1);
					assert.equal(node.right, 2);
					done();
				}
			});
		});

		it('should set corrent position parameters when inserting a root node above another node', function(done) {
			db = orm.related_nestedset_test;

			new db.tree({name: 'root2'}).setParent().save(function(err, node) {
				if (err) done(err);
				else {
					assert.equal(node.left, 1);
					assert.equal(node.right, 2);
					done();
				}
			});
		});

		it('should set corrent position parameters when inserting a root node below another node', function(done) {
			db = orm.related_nestedset_test;

			new db.tree({name: 'root3'}).setParent(null, true).save(function(err, node) {
				if (err) done(err);
				else {
					assert.equal(node.left, 5);
					assert.equal(node.right, 6);
					done();
				}
			});
		});

		it('should set corrent position parameters when inserting a node as child of another node using an id', function(done) {
			db = orm.related_nestedset_test;

			new db.tree({name: 'child1.1'}).setParent(1).save(function(err, node) {
				if (err) done(err);
				else {
					assert.equal(node.left, 4);
					assert.equal(node.right, 5);
					done();
				}
			});
		});

		it('should set corrent position parameters when inserting a node as child of another node using a query', function(done) {
			db = orm.related_nestedset_test;

			new db.tree({name: 'child1.2'}).setParent(db.tree({id:1})).save(function(err, node) {
				if (err) done(err);
				else {
					assert.equal(node.left, 4);
					assert.equal(node.right, 5);
					done();
				}
			});
		});

		it('should set corrent position parameters when inserting a node after another node using a model', function(done) {
			db = orm.related_nestedset_test;

			db.tree({name: 'child1.2'}, ['*']).findOne(function(err, model) {
				if (err) done(err);
				else {
					new db.tree({name: 'child1.3'}).after(model).save(function(err, node) {
						if (err) done(err);
						else {
							assert.equal(node.left, 6);
							assert.equal(node.right, 7);
							done();
						}
					});
				}
			});
		});

		it('should set corrent position parameters when inserting before another node using an id', function(done) {
			db = orm.related_nestedset_test;

			db.tree({name: 'child1.2'}, ['*']).findOne(function(err, model) {
				if (err) done(err);
				else {
					new db.tree({name: 'child1.4'}).before(5).save(function(err, node) {
						if (err) done(err);
						else {
							assert.equal(node.left, 4);
							assert.equal(node.right, 5);
							done();
						}
					});
				}
			});
		});
	});

	describe('[Updating]', function() {
		it('setting a new parent, moving left', function(done) {
			db.tree({id: 5}).findOne(function(err, node) {
				if (err) done(err);
				else {
					node.setParent(2).save(function(err, movedNode) {
						if (err) done(err);
						else {
							assert.equal(movedNode.left, 2);
							assert.equal(movedNode.right, 3);
							done();
						}
					});
				}
			});
		});

		it('setting a new parent, moving right', function(done) {
			db.tree({id: 7}).findOne(function(err, node) {
				if (err) done(err);
				else {
					node.setParent(3).save(function(err, movedNode) {
						if (err) done(err);
						else {
							assert.equal(movedNode.left, 12);
							assert.equal(movedNode.right, 13);
							done();
						}
					});
				}
			});
		});

		it('setting myself as parent should fail!', function(done) {
			db.tree({id: 7}).findOne(function(err, node) {
				if (err) done(err);
				else {
					node.setParent(7).save(function(err, movedNode) {
						if (err) done();
						else done(new Error('self references are not ok!'));
					});
				}
			});
		});
	});

	describe('[Deleting]', function() {
		it('deleting a node containing children should not be possible', function(done) {
			db.tree({id: 2}).findOne(function(err, node) {
				if (err) done(err);
				else {
					node.delete(function(err, deletedNode) {
						assert(err instanceof Error);
						done();
					});
				}
			});
		});

		it('deleting a node not containing children', function(done) {
			db.tree({id: 5}).findOne(function(err, node) {
				if (err) done(err);
				else {
					node.delete(function(err, deletedNode) {
						if (err) done(err);
						else {
							assert.equal(deletedNode.isDeleted(), true);
							done();
						}
					});
				}
			});
		});
	});

	describe('[TreeBuilding]', function() {
		it('fetching the tree', function(done) {
			db.tree().loadTree(expect('[{"id":2,"name":"root2","right":2,"left":1,"group":null},{"id":1,"name":"root1","right":8,"left":3,"group":null,"children":[{"id":6,"name":"child1.3","right":5,"left":4,"group":null},{"id":4,"name":"child1.1","right":7,"left":6,"group":null}]},{"id":3,"name":"root3","right":12,"left":9,"group":null,"children":[{"id":7,"name":"child1.4","right":11,"left":10,"group":null}]}]', done));
		});
	});

	describe('[Tree Syncing]', function() {
		it('updating an exsiiting tree', function(done) {
			db.tree().loadTree(function(err, tree) {
				if (err) done(err);
				else {
					tree[1].children = [];
					tree[2].children.push({});

					db.tree().syncTree(tree, expect('[{"id":2,"left":1,"group":null,"name":"root2","right":2},{"id":1,"left":3,"group":null,"name":"root1","right":4},{"id":3,"left":5,"group":null,"name":"root3","right":10,"children":[{"id":7,"left":6,"group":null,"name":"child1.4","right":7},{"id":8,"left":8,"group":null,"name":null,"right":9}]}]', done));
				}
			});
		});

		it('truncating the table', function(done) {
			db.tree().delete(done);
		});

		it('creating a new tree', function(done) {
			db.tree().syncTree([
				  {name: '1'}
				, {
					  name: '2'
					, children:[
						 {name: '2_1'}
						,{name: '2_2'}
						,{
							  name: '2_3'
							, children:[
								{name: '2_3_1'}
							]
						}
					]
				}
				, {name: '3'}
				, {name: '4'}
			], expect('[{"id":9,"group":null,"left":1,"right":2,"name":"1"},{"id":10,"group":null,"left":3,"right":12,"name":"2","children":[{"id":11,"group":null,"left":4,"right":5,"name":"2_1"},{"id":12,"group":null,"left":6,"right":7,"name":"2_2"},{"id":13,"group":null,"left":8,"right":11,"name":"2_3","children":[{"id":14,"group":null,"left":9,"right":10,"name":"2_3_1"}]}]},{"id":15,"group":null,"left":13,"right":14,"name":"3"},{"id":16,"group":null,"left":15,"right":16,"name":"4"}]', done));
		});
	});

	describe('[Perparation for the Group Key Tests]', function() {
		it('truncating the table', function(done) {
			db.tree().delete(done);
		});

		it('setting the group key', function() {
			extension.setGroupKey('related_nestedset_test', 'tree', 'group');
		});

		it('createing a second tree', function(done) {
			new db.tree({name: 'secondTree', group:1000}).setParent().save(function(err, node) {
				if (err) done(err);
				else {
					assert.equal(node.left, 1);
					assert.equal(node.right, 2);
					done();
				}
			});
		});
	});

	describe('[Inserting]', function() {
		it('should set corrent position parameters when inserting a node', function(done) {
			new db.tree({name: 'root1', group:999}).setParent().save(function(err, node) {
				if (err) done(err);
				else {
					assert.equal(node.left, 1);
					assert.equal(node.right, 2);
					done();
				}
			});
		});

		it('should set corrent position parameters when inserting a node another group', function(done) {
			new db.tree({name: 'thirdTree', group:1}).setParent().save(function(err, node) {
				if (err) done(err);
				else {
					assert.equal(node.left, 1);
					assert.equal(node.right, 2);
					done();
				}
			});
		});

		it('should set corrent position parameters when inserting a root node above another node', function(done) {
			db = orm.related_nestedset_test;

			new db.tree({name: 'root2', group: 999}).setParent().save(function(err, node) {
				if (err) done(err);
				else {
					assert.equal(node.left, 1);
					assert.equal(node.right, 2);
					done();
				}
			});
		});

		it('should set corrent position parameters when inserting a root node below another node', function(done) {
			db = orm.related_nestedset_test;

			new db.tree({name: 'root3', group: 999}).setParent(null, true).save(function(err, node) {
				if (err) done(err);
				else {
					assert.equal(node.left, 5);
					assert.equal(node.right, 6);
					done();
				}
			});
		});

		it('should set corrent position parameters when inserting a node as child of another node using an id', function(done) {
			db = orm.related_nestedset_test;

			new db.tree({name: 'child1.1', group: 999}).setParent(18).save(function(err, node) {
				if (err) done(err);
				else {
					assert.equal(node.left, 4);
					assert.equal(node.right, 5);
					done();
				}
			});
		});

		it('should set corrent position parameters when inserting a node as child of another node using a query', function(done) {
			db = orm.related_nestedset_test;

			new db.tree({name: 'child1.2', group: 999}).setParent(db.tree({id:18})).save(function(err, node) {
				if (err) done(err);
				else {
					assert.equal(node.left, 4);
					assert.equal(node.right, 5);
					done();
				}
			});
		});

		it('should set corrent position parameters when inserting a node after another node using a model', function(done) {
			db = orm.related_nestedset_test;

			db.tree({name: 'child1.2', group: 999}, ['*']).findOne(function(err, model) {
				if (err) done(err);
				else {
					new db.tree({name: 'child1.3', group: 999}).after(model).save(function(err, node) {
						if (err) done(err);
						else {
							assert.equal(node.left, 6);
							assert.equal(node.right, 7);
							done();
						}
					});
				}
			});
		});

		it('should set corrent position parameters when inserting before another node using an id', function(done) {
			db = orm.related_nestedset_test;

			db.tree({name: 'child1.2', group: 999}, ['*']).findOne(function(err, model) {
				if (err) done(err);
				else {
					new db.tree({name: 'child1.4', group: 999}).before(23).save(function(err, node) {
						if (err) done(err);
						else {
							assert.equal(node.left, 4);
							assert.equal(node.right, 5);
							done();
						}
					});
				}
			});
		});
	});

	describe('[Updating]', function() {
		it('setting a new parent, moving left', function(done) {
			db.tree({id: 23}, '*').findOne(function(err, node) {
				if (err) done(err);
				else {
					node.setParent(20).save(function(err, movedNode) {
						if (err) done(err);
						else {
							assert.equal(movedNode.left, 2);
							assert.equal(movedNode.right, 3);
							done();
						}
					});
				}
			});
		});

		it('setting a new parent, moving right', function(done) {
			db.tree({id: 25}, '*').findOne(function(err, node) {
				if (err) done(err);
				else {
					node.setParent(21).save(function(err, movedNode) {
						if (err) done(err);
						else {
							assert.equal(movedNode.left, 12);
							assert.equal(movedNode.right, 13);
							done();
						}
					});
				}
			});
		});

		it('setting a new parent from another group should fail', function(done) {
			db.tree({id: 24}, '*').findOne(function(err, node) {
				if (err) done(err);
				else {
					node.setParent(19).save(function(err, movedNode) {
						if (err) done();
						else done(new Error('should not be able to set parents from another group!'));
					});
				}
			});
		});

		it('setting a new parent that is achild of the node should fail', function(done) {
			db.tree({id: 21}, '*').findOne(function(err, node) {
				if (err) done(err);
				else {
					node.setParent(25).save(function(err, movedNode) {
						if (err) done();
						else done(new Error('should not be able to set parents that are children of the same subtree!'));
					});
				}
			});
		});

		it('setting a new parent from another group should work when the group on the source was changed', function(done) {
			db.tree({id: 24}, '*').findOne(function(err, node) {
				if (err) done(err);
				else {
					node.group = 1;
					node.setParent(19).save(function(err, movedNode) {
						if (err) done(err);
						else {
							assert.equal(movedNode.left, 2);
							assert.equal(movedNode.right, 3);
							done();
						}
					});
				}
			});
		});

		it('movin an entire subtree to another group', function(done) {
			var moverNode, parentNode;

			new db.tree({group: 333, name: '333-1'}).setParent().save().then(function(node) {
				return new db.tree({group: 333, name: '333-2'}).setParent(node).save();
			}).then(function(node) {
				parentNode = node;
				return new db.tree({group: 333, name: '333-3'}).setParent(node).save();
			}).then(function(node) {
				return new db.tree({group: 333, name: '333-4'}).setParent(node).save();
			}).then(function(node) {
				return new db.tree({group: 333, name: '333-5'}).setParent(node).save();
			}).then(function(node) {
				return new db.tree({group: 444, name: '444-1'}).setParent().save();
			}).then(function(node) {
				return new db.tree({group: 444, name: '444-2'}).setParent(node).save();
			}).then(function(node) {
				moverNode = node;
				return new db.tree({group: 444, name: '444-3'}).setParent(node).save();
			}).then(function(node) {
				return new db.tree({group: 444, name: '444-4'}).setParent(node).save();
			}).then(function(node) {
				return new db.tree({group: 444, name: '444-5'}).setParent(node).save();
			}).then(function(node) {
				return new db.tree({group: 444, name: '444-6'}).setParent(node).save();
			}).then(function(node) {
				return db.tree().loadTree(444);
			}).then(function(tree) {
				assert(JSON.stringify(tree) == '[{"id":31,"name":"444-1","group":444,"left":1,"right":12,"children":[{"id":32,"name":"444-2","group":444,"left":2,"right":11,"children":[{"id":33,"name":"444-3","group":444,"left":3,"right":10,"children":[{"id":34,"name":"444-4","group":444,"left":4,"right":9,"children":[{"id":35,"name":"444-5","group":444,"left":5,"right":8,"children":[{"id":36,"name":"444-6","group":444,"left":6,"right":7}]}]}]}]}]}]');
				return db.tree().loadTree(333);
			}).then(function(tree) {
				assert(JSON.stringify(tree) == '[{"id":26,"name":"333-1","group":333,"left":1,"right":10,"children":[{"id":27,"name":"333-2","group":333,"left":2,"right":9,"children":[{"id":28,"name":"333-3","group":333,"left":3,"right":8,"children":[{"id":29,"name":"333-4","group":333,"left":4,"right":7,"children":[{"id":30,"name":"333-5","group":333,"left":5,"right":6}]}]}]}]}]');

				moverNode.group = 333;
				return moverNode.setParent(parentNode).save();
			}).then(function() {
				return db.tree().loadTree(333);
			}).then(function(tree) {
				assert(JSON.stringify(tree) == '[{"id":26,"name":"333-1","group":333,"left":1,"right":20,"children":[{"id":27,"name":"333-2","group":333,"left":2,"right":19,"children":[{"id":32,"name":"444-2","group":333,"left":3,"right":12,"children":[{"id":33,"name":"444-3","group":333,"left":4,"right":11,"children":[{"id":34,"name":"444-4","group":333,"left":5,"right":10,"children":[{"id":35,"name":"444-5","group":333,"left":6,"right":9,"children":[{"id":36,"name":"444-6","group":333,"left":7,"right":8}]}]}]}]},{"id":28,"name":"333-3","group":333,"left":13,"right":18,"children":[{"id":29,"name":"333-4","group":333,"left":14,"right":17,"children":[{"id":30,"name":"333-5","group":333,"left":15,"right":16}]}]}]}]}]');

				return db.tree({group: ORM.in(333, 444)}).delete();
			}).then(function() {
				done();
			}).catch(done);
		});
	});

	describe('[Deleting]', function() {
		it('deleting a node containing children should not be possible', function(done) {
			db.tree({id: 20}).findOne(function(err, node) {
				if (err) done(err);
				else {
					node.delete(function(err, deletedNode) {
						assert(err instanceof Error);
						done();
					});
				}
			});
		});

		it('deleting a node not containing children', function(done) {
			db.tree({id: 24}).findOne(function(err, node) {
				if (err) done(err);
				else {
					node.delete(function(err, deletedNode) {
						if (err) done(err);
						else {
							assert.equal(deletedNode.isDeleted(), true);
							done();
						}
					});
				}
			});
		});
	});

	describe('[TreeBuilding]', function() {
		it('fetching the tree', function(done) {
			db.tree().loadTree(999, expect('[{"id":20,"name":"root2","group":999,"left":1,"right":4,"children":[{"id":23,"name":"child1.2","group":999,"left":2,"right":3}]},{"id":18,"name":"root1","group":999,"left":5,"right":8,"children":[{"id":22,"name":"child1.1","group":999,"left":6,"right":7}]},{"id":21,"name":"root3","group":999,"left":9,"right":12,"children":[{"id":25,"name":"child1.4","group":999,"left":10,"right":11}]}]', done));
		});
	});

	describe('[Tree Syncing]', function() {
		it('updating an exsisting tree', function(done) {
			db.tree().loadTree(999, function(err, tree) {
				if (err) done(err);
				else {
					tree[1].children = [];
					tree[2].children.push({});

					db.tree().syncTree(tree, expect('[{"id":20,"name":"root2","group":999,"left":1,"right":4,"children":[{"id":23,"name":"child1.2","group":999,"left":2,"right":3}]},{"id":18,"name":"root1","group":999,"left":5,"right":6},{"id":21,"name":"root3","group":999,"left":7,"right":12,"children":[{"id":25,"name":"child1.4","group":999,"left":8,"right":9},{"id":37,"name":null,"group":999,"left":10,"right":11}]}]', done));
				}
			});
		});

		it('the second tree should be correct', function(done) {
			db.tree().loadTree(1000, expect('[{"id":17,"name":"secondTree","group":1000,"left":1,"right":2}]', done));
		});

		it('truncating the table', function(done) {
			db.tree().delete(done);
		});

		it('creating a new tree', function(done) {
			db.tree().syncTree([
				  {name: '1', group: 999}
				, {
					  name: '2'
					, children:[
						 {name: '2_1'}
						,{name: '2_2'}
						,{
							  name: '2_3'
							, children:[
								{name: '2_3_1'}
							]
						}
					]
				}
				, {name: '3'}
				, {name: '4'}
			], expect('[{"id":38,"name":"1","group":999,"left":1,"right":2},{"id":39,"name":"2","group":999,"left":3,"right":12,"children":[{"id":40,"name":"2_1","group":999,"left":4,"right":5},{"id":41,"name":"2_2","group":999,"left":6,"right":7},{"id":42,"name":"2_3","group":999,"left":8,"right":11,"children":[{"id":43,"name":"2_3_1","group":999,"left":9,"right":10}]}]},{"id":44,"name":"3","group":999,"left":13,"right":14},{"id":45,"name":"4","group":999,"left":15,"right":16}]', done));
		});
	});
})();


text:
#include "usModuleRegistry.h"

#include "usModule.h"
#include "usModuleInfo.h"
#include "usModuleContext.h"
#include "usModuleActivator.h"
#include "usCoreModuleContext_p.h"
#include "usGetModuleContext.h"
#include "usStaticInit_p.h"

#include <cassert>
#include <map>

US_BEGIN_NAMESPACE

typedef US_UNORDERED_MAP_TYPE<long, Module*> ModuleMap;

US_GLOBAL_STATIC(CoreModuleContext, coreModuleContext)

template<typename T>
struct ModuleDeleter
{
  void operator()(GlobalStatic<T>& globalStatic) const
  {
    ModuleMap* moduleMap = globalStatic.pointer;
    for (ModuleMap::const_iterator i = moduleMap->begin();
         i != moduleMap->end(); ++i)
    {
      delete i->second;
    }
    DefaultGlobalStaticDeleter<T> defaultDeleter;
    defaultDeleter(globalStatic);
  }
};

/**
 * Table of all installed modules in this framework.
 * Key is the module id.
 */
US_GLOBAL_STATIC_WITH_DELETER(ModuleMap, modules, ModuleDeleter)

/**
 * Lock for protecting the modules object
 */
US_GLOBAL_STATIC(Mutex, modulesLock)

/**
 * Lock for protecting the register count
 */
US_GLOBAL_STATIC(Mutex, countLock)

void ModuleRegistry::Register(ModuleInfo* info)
{
  static long regCount = 0;
  if (info->id > 0)
  {
    // The module was already registered
    Module* module = 0;
    {
      MutexLock lock(*modulesLock());
      module = modules()->operator[](info->id);
      assert(module != 0);
    }
    module->Start();
  }
  else
  {
    Module* module = 0;
    // check if the module is reloaded
    {
      MutexLock lock(*modulesLock());
      ModuleMap* map = modules();
      for (ModuleMap::const_iterator i = map->begin();
           i != map->end(); ++i)
      {
        if (i->second->GetLocation() == info->location)
        {
          module = i->second;
          info->id = module->GetModuleId();
        }
      }
    }

    if (!module)
    {
      module = new Module();
      countLock()->Lock();
      info->id = ++regCount;
      countLock()->Unlock();

      module->Init(coreModuleContext(), info);

      MutexLock lock(*modulesLock());
      ModuleMap* map = modules();
      map->insert(std::make_pair(info->id, module));
    }
    else
    {
      module->Init(coreModuleContext(), info);
    }

    module->Start();
  }
}

void ModuleRegistry::UnRegister(const ModuleInfo* info)
{
  // If we are unregistering the core module, we just call
  // the module activators Unload() method (if there is a
  // module activator). Since we cannot be sure that the
  // ModuleContext for the core library is still valid, we
  // just pass a null-pointer. Using the module context during
  // static deinitalization time of the core library makes
  // no sense anyway.
  if (info->id == 1)
  {
    // Remove listeners from static modules if they have forgotten to do so
    coreModuleContext()->listeners.RemoveAllListeners(GetModuleContext());

    if (info->activatorHook)
    {
      info->activatorHook()->Unload(0);
    }
    return;
  }

  Module* curr = 0;
  {
    MutexLock lock(*modulesLock());
    curr = modules()->operator[](info->id);
    assert(curr != 0);
  }

  curr->Stop();
}

Module* ModuleRegistry::GetModule(long id)
{
  MutexLock lock(*modulesLock());

  ModuleMap::const_iterator iter = modules()->find(id);
  if (iter != modules()->end())
  {
    return iter->second;
  }
  return 0;
}

Module* ModuleRegistry::GetModule(const std::string& name)
{
  MutexLock lock(*modulesLock());

  ModuleMap::const_iterator iter = modules()->begin();
  ModuleMap::const_iterator iterEnd = modules()->end();
  for (; iter != iterEnd; ++iter)
  {
    if (iter->second->GetName() == name)
    {
      return iter->second;
    }
  }

  return 0;
}

std::vector<Module*> ModuleRegistry::GetModules()
{
  MutexLock lock(*modulesLock());

  std::vector<Module*> result;
  ModuleMap* map = modules();
  ModuleMap::const_iterator iter = map->begin();
  ModuleMap::const_iterator iterEnd = map->end();
  for (; iter != iterEnd; ++iter)
  {
    result.push_back(iter->second);
  }
  return result;
}

std::vector<Module*> ModuleRegistry::GetLoadedModules()
{
  MutexLock lock(*modulesLock());

  std::vector<Module*> result;
  ModuleMap::const_iterator iter = modules()->begin();
  ModuleMap::const_iterator iterEnd = modules()->end();
  for (; iter != iterEnd; ++iter)
  {
    if (iter->second->IsLoaded())
    {
      result.push_back(iter->second);
    }
  }
  return result;
}

US_END_NAMESPACE

redpajama_set_name: RedPajamaGithub


text:
SYNONYM

#### According to
Index Fungorum

#### Published in
null

#### Original name
Cicinnobolus heraclei Dejeva

### Remarks
null


text:
.class public final Lcom/upsight/mediation/vast/processor/VASTProcessor;
.super Ljava/lang/Object;
.source "VASTProcessor.java"

# static fields
.field private static final IS_VALIDATION_ON:Z = false

.field private static final MAX_VAST_LEVELS:I = 0x5

.field private static final TAG:Ljava/lang/String; = "VASTProcessor"

# instance fields
.field private final mVastPlayer:Lcom/upsight/mediation/vast/VASTPlayer;

.field private mediaPicker:Lcom/upsight/mediation/vast/processor/VASTMediaPicker;

.field private mergedVastDocs:Ljava/lang/StringBuilder;

.field private vastModel:Lcom/upsight/mediation/vast/model/VASTModel;

# direct methods
.method public constructor <init>(Lcom/upsight/mediation/vast/processor/VASTMediaPicker;Lcom/upsight/mediation/vast/VASTPlayer;)V
    .registers 5
    .param p1, "mediaPicker"    # Lcom/upsight/mediation/vast/processor/VASTMediaPicker;
    .param p2, "vastPlayer"    # Lcom/upsight/mediation/vast/VASTPlayer;

    .prologue
    .line 53
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    .line 51
    new-instance v0, Ljava/lang/StringBuilder;

    const/16 v1, 0x1f4

    invoke-direct {v0, v1}, Ljava/lang/StringBuilder;-><init>(I)V

    iput-object v0, p0, Lcom/upsight/mediation/vast/processor/VASTProcessor;->mergedVastDocs:Ljava/lang/StringBuilder;

    .line 54
    iput-object p1, p0, Lcom/upsight/mediation/vast/processor/VASTProcessor;->mediaPicker:Lcom/upsight/mediation/vast/processor/VASTMediaPicker;

    .line 55
    iput-object p2, p0, Lcom/upsight/mediation/vast/processor/VASTProcessor;->mVastPlayer:Lcom/upsight/mediation/vast/VASTPlayer;

    .line 56
    return-void
.end method

.method private createDoc(Ljava/io/InputStream;)Lorg/w3c/dom/Document;
    .registers 5
    .param p1, "is"    # Ljava/io/InputStream;

    .prologue
    .line 199
    :try_start_0
    invoke-static {}, Ljavax/xml/parsers/DocumentBuilderFactory;->newInstance()Ljavax/xml/parsers/DocumentBuilderFactory;

    move-result-object v2

    .line 200
    invoke-virtual {v2}, Ljavax/xml/parsers/DocumentBuilderFactory;->newDocumentBuilder()Ljavax/xml/parsers/DocumentBuilder;

    move-result-object v2

    invoke-virtual {v2, p1}, Ljavax/xml/parsers/DocumentBuilder;->parse(Ljava/io/InputStream;)Lorg/w3c/dom/Document;

    move-result-object v0

    .line 201
    .local v0, "doc":Lorg/w3c/dom/Document;
    invoke-interface {v0}, Lorg/w3c/dom/Document;->getDocumentElement()Lorg/w3c/dom/Element;

    move-result-object v2

    invoke-interface {v2}, Lorg/w3c/dom/Element;->normalize()V
    :try_end_13
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_13} :catch_14

    .line 206
    .end local v0    # "doc":Lorg/w3c/dom/Document;
    :goto_13
    return-object v0

    .line 204
    :catch_14
    move-exception v1

    .line 206
    .local v1, "e":Ljava/lang/Exception;
    const/4 v0, 0x0

    goto :goto_13
.end method

.method private merge(Lorg/w3c/dom/Document;)V
    .registers 6
    .param p1, "newDoc"    # Lorg/w3c/dom/Document;

    .prologue
    .line 211
    const-string v3, "VAST"

    invoke-interface {p1, v3}, Lorg/w3c/dom/Document;->getElementsByTagName(Ljava/lang/String;)Lorg/w3c/dom/NodeList;

    move-result-object v2

    .line 213
    .local v2, "nl":Lorg/w3c/dom/NodeList;
    const/4 v3, 0x0

    invoke-interface {v2, v3}, Lorg/w3c/dom/NodeList;->item(I)Lorg/w3c/dom/Node;

    move-result-object v1

    .line 215
    .local v1, "newDocElement":Lorg/w3c/dom/Node;
    invoke-static {v1}, Lcom/upsight/mediation/vast/util/XmlTools;->xmlDocumentToString(Lorg/w3c/dom/Node;)Ljava/lang/String;

    move-result-object v0

    .line 216
    .local v0, "doc":Ljava/lang/String;
    iget-object v3, p0, Lcom/upsight/mediation/vast/processor/VASTProcessor;->mergedVastDocs:Ljava/lang/StringBuilder;

    invoke-virtual {v3, v0}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    .line 217
    return-void
.end method

.method private processUri(Ljava/io/InputStream;I)I
    .registers 18
    .param p1, "is"    # Ljava/io/InputStream;
    .param p2, "depth"    # I

    .prologue
    .line 127
    const/4 v12, 0x5

    move/from16 v0, p2

    if-lt v0, v12, :cond_8

    .line 131
    const/16 v5, 0x12e

    .line 192
    :goto_7
    return v5

    .line 134
    :cond_8
    invoke-direct/range {p0 .. p1}, Lcom/upsight/mediation/vast/processor/VASTProcessor;->createDoc(Ljava/io/InputStream;)Lorg/w3c/dom/Document;

    move-result-object v3

    .line 135
    .local v3, "doc":Lorg/w3c/dom/Document;
    if-nez v3, :cond_11

    .line 136
    const/16 v5, 0x64

    goto :goto_7

    .line 146
    :cond_11
    invoke-interface {v3}, Lorg/w3c/dom/Document;->getFirstChild()Lorg/w3c/dom/Node;

    move-result-object v12

    invoke-interface {v12}, Lorg/w3c/dom/Node;->getNodeName()Ljava/lang/String;

    move-result-object v12

    const-string v13, "VAST"

    invoke-virtual {v12, v13}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

    move-result v12

    if-eqz v12, :cond_4a

    invoke-interface {v3}, Lorg/w3c/dom/Document;->getFirstChild()Lorg/w3c/dom/Node;

    move-result-object v12

    invoke-interface {v12}, Lorg/w3c/dom/Node;->getAttributes()Lorg/w3c/dom/NamedNodeMap;

    move-result-object v12

    const-string v13, "version"

    invoke-interface {v12, v13}, Lorg/w3c/dom/NamedNodeMap;->getNamedItem(Ljava/lang/String;)Lorg/w3c/dom/Node;

    move-result-object v12

    invoke-interface {v12}, Lorg/w3c/dom/Node;->getNodeValue()Ljava/lang/String;

    move-result-object v12

    invoke-virtual {v12}, Ljava/lang/String;->toString()Ljava/lang/String;

    move-result-object v11

    .line 147
    .local v11, "version":Ljava/lang/String;
    :goto_37
    const-string v12, "2.0"

    invoke-virtual {v11, v12}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

    move-result v12

    if-nez v12, :cond_66

    const-string v12, "3.0"

    invoke-virtual {v11, v12}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

    move-result v12

    if-nez v12, :cond_66

    .line 148
    const/16 v5, 0x66

    goto :goto_7

    .line 146
    .end local v11    # "version":Ljava/lang/String;
    :cond_4a
    invoke-interface {v3}, Lorg/w3c/dom/Document;->getChildNodes()Lorg/w3c/dom/NodeList;

    move-result-object v12

    const/4 v13, 0x1

    invoke-interface {v12, v13}, Lorg/w3c/dom/NodeList;->item(I)Lorg/w3c/dom/Node;

    move-result-object v12

    invoke-interface {v12}, Lorg/w3c/dom/Node;->getAttributes()Lorg/w3c/dom/NamedNodeMap;

    move-result-object v12

    const-string v13, "version"

    invoke-interface {v12, v13}, Lorg/w3c/dom/NamedNodeMap;->getNamedItem(Ljava/lang/String;)Lorg/w3c/dom/Node;

    move-result-object v12

    invoke-interface {v12}, Lorg/w3c/dom/Node;->getNodeValue()Ljava/lang/String;

    move-result-object v12

    invoke-virtual {v12}, Ljava/lang/String;->toString()Ljava/lang/String;

    move-result-object v11

    goto :goto_37

    .line 152
    .restart local v11    # "version":Ljava/lang/String;
    :cond_66
    sget-object v12, Lcom/upsight/mediation/vast/model/VAST_DOC_ELEMENTS;->vastAdTagURI:Lcom/upsight/mediation/vast/model/VAST_DOC_ELEMENTS;

    .line 153
    invoke-virtual {v12}, Lcom/upsight/mediation/vast/model/VAST_DOC_ELEMENTS;->getValue()Ljava/lang/String;

    move-result-object v12

    invoke-interface {v3, v12}, Lorg/w3c/dom/Document;->getElementsByTagName(Ljava/lang/String;)Lorg/w3c/dom/NodeList;

    move-result-object v10

    .line 154
    .local v10, "uriToNextDoc":Lorg/w3c/dom/NodeList;
    if-eqz v10, :cond_78

    invoke-interface {v10}, Lorg/w3c/dom/NodeList;->getLength()I

    move-result v12

    if-nez v12, :cond_7d

    .line 156
    :cond_78
    invoke-direct {p0, v3}, Lcom/upsight/mediation/vast/processor/VASTProcessor;->merge(Lorg/w3c/dom/Document;)V

    .line 157
    const/4 v5, 0x0

    goto :goto_7

    .line 161
    :cond_7d
    const-string v12, "VASTProcessor"

    const-string v13, "Doc is a wrapper. "

    invoke-static {v12, v13}, Lcom/upsight/mediation/log/FuseLog;->v(Ljava/lang/String;Ljava/lang/String;)V

    .line 162
    const/4 v12, 0x0

    invoke-interface {v10, v12}, Lorg/w3c/dom/NodeList;->item(I)Lorg/w3c/dom/Node;

    move-result-object v9

    .line 163
    .local v9, "node":Lorg/w3c/dom/Node;
    invoke-static {v9}, Lcom/upsight/mediation/vast/util/XmlTools;->getElementValue(Lorg/w3c/dom/Node;)Ljava/lang/String;

    move-result-object v7

    .line 164
    .local v7, "nextUri":Ljava/lang/String;
    const-string v12, "VASTProcessor"

    new-instance v13, Ljava/lang/StringBuilder;

    invoke-direct {v13}, Ljava/lang/StringBuilder;-><init>()V

    const-string v14, "Wrapper URL: "

    invoke-virtual {v13, v14}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v13

    invoke-virtual {v13, v7}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v13

    invoke-virtual {v13}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v13

    invoke-static {v12, v13}, Lcom/upsight/mediation/log/FuseLog;->v(Ljava/lang/String;Ljava/lang/String;)V

    .line 165
    const/4 v6, 0x0

    .line 167
    .local v6, "nextInputStream":Ljava/io/InputStream;
    :try_start_a6
    new-instance v8, Ljava/net/URL;

    invoke-direct {v8, v7}, Ljava/net/URL;-><init>(Ljava/lang/String;)V

    .line 168
    .local v8, "nextUrl":Ljava/net/URL;
    invoke-virtual {v8}, Ljava/net/URL;->openConnection()Ljava/net/URLConnection;

    move-result-object v2

    check-cast v2, Ljava/net/HttpURLConnection;

    .line 169
    .local v2, "connection":Ljava/net/HttpURLConnection;
    const/16 v12, 0x1388

    invoke-virtual {v2, v12}, Ljava/net/HttpURLConnection;->setConnectTimeout(I)V

    .line 170
    const/16 v12, 0x1388

    invoke-virtual {v2, v12}, Ljava/net/HttpURLConnection;->setReadTimeout(I)V

    .line 171
    invoke-virtual {v2}, Ljava/net/HttpURLConnection;->getResponseCode()I

    move-result v1

    .line 173
    .local v1, "code":I
    const/16 v12, 0xc8

    if-eq v1, v12, :cond_c7

    .line 174
    const/16 v5, 0x12f

    goto/16 :goto_7

    .line 176
    :cond_c7
    invoke-virtual {v2}, Ljava/net/HttpURLConnection;->getInputStream()Ljava/io/InputStream;
    :try_end_ca
    .catch Ljava/net/MalformedURLException; {:try_start_a6 .. :try_end_ca} :catch_d9
    .catch Ljava/net/SocketTimeoutException; {:try_start_a6 .. :try_end_ca} :catch_de
    .catch Ljava/io/IOException; {:try_start_a6 .. :try_end_ca} :catch_e3

    move-result-object v6

    .line 187
    add-int/lit8 v12, p2, 0x1

    invoke-direct {p0, v6, v12}, Lcom/upsight/mediation/vast/processor/VASTProcessor;->processUri(Ljava/io/InputStream;I)I

    move-result v5

    .line 189
    .local v5, "error":I
    :try_start_d1
    invoke-virtual {v6}, Ljava/io/InputStream;->close()V
    :try_end_d4
    .catch Ljava/io/IOException; {:try_start_d1 .. :try_end_d4} :catch_d6

    goto/16 :goto_7

    .line 190
    :catch_d6
    move-exception v12

    goto/16 :goto_7

    .line 177
    .end local v1    # "code":I
    .end local v2    # "connection":Ljava/net/HttpURLConnection;
    .end local v5    # "error":I
    .end local v8    # "nextUrl":Ljava/net/URL;
    :catch_d9
    move-exception v4

    .line 179
    .local v4, "e":Ljava/net/MalformedURLException;
    const/16 v5, 0x12f

    goto/16 :goto_7

    .line 180
    .end local v4    # "e":Ljava/net/MalformedURLException;
    :catch_de
    move-exception v4

    .line 182
    .local v4, "e":Ljava/net/SocketTimeoutException;
    const/16 v5, 0x12d

    goto/16 :goto_7

    .line 183
    .end local v4    # "e":Ljava/net/SocketTimeoutException;
    :catch_e3
    move-exception v4

    .line 184
    .local v4, "e":Ljava/io/IOException;
    const-string v12, "VASTProcessor"

    invoke-virtual {v4}, Ljava/io/IOException;->getMessage()Ljava/lang/String;

    move-result-object v13

    invoke-static {v12, v13, v4}, Lcom/upsight/mediation/log/FuseLog;->w(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)V

    .line 185
    const/16 v5, 0x12c

    goto/16 :goto_7
.end method

.method private wrapMergedVastDocWithVasts()Lorg/w3c/dom/Document;
    .registers 4

    .prologue
    .line 118
    iget-object v2, p0, Lcom/upsight/mediation/vast/processor/VASTProcessor;->mergedVastDocs:Ljava/lang/StringBuilder;

    invoke-virtual {v2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v1

    .line 121
    .local v1, "merged":Ljava/lang/String;
    invoke-static {v1}, Lcom/upsight/mediation/vast/util/XmlTools;->stringToDocument(Ljava/lang/String;)Lorg/w3c/dom/Document;

    move-result-object v0

    .line 122
    .local v0, "doc":Lorg/w3c/dom/Document;
    return-object v0
.end method

# virtual methods
.method public getModel()Lcom/upsight/mediation/vast/model/VASTModel;
    .registers 2

    .prologue
    .line 59
    iget-object v0, p0, Lcom/upsight/mediation/vast/processor/VASTProcessor;->vastModel:Lcom/upsight/mediation/vast/model/VASTModel;

    return-object v0
.end method

.method public process(Landroid/content/Context;Ljava/lang/String;ZI)I
    .registers 14
    .param p1, "c"    # Landroid/content/Context;
    .param p2, "xmlData"    # Ljava/lang/String;
    .param p3, "shouldValidateSchema"    # Z
    .param p4, "downloadTimeout"    # I

    .prologue
    const/16 v5, 0x64

    const/4 v6, 0x0

    .line 63
    const-string v7, "VASTProcessor"

    const-string v8, "process"

    invoke-static {v7, v8}, Lcom/upsight/mediation/log/FuseLog;->d(Ljava/lang/String;Ljava/lang/String;)V

    .line 64
    const/4 v7, 0x0

    iput-object v7, p0, Lcom/upsight/mediation/vast/processor/VASTProcessor;->vastModel:Lcom/upsight/mediation/vast/model/VASTModel;

    .line 65
    const/4 v2, 0x0

    .line 68
    .local v2, "is":Ljava/io/InputStream;
    :try_start_e
    new-instance v3, Ljava/io/ByteArrayInputStream;

    .line 69
    invoke-static {}, Ljava/nio/charset/Charset;->defaultCharset()Ljava/nio/charset/Charset;

    move-result-object v7

    invoke-virtual {v7}, Ljava/nio/charset/Charset;->name()Ljava/lang/String;

    move-result-object v7

    .line 68
    invoke-virtual {p2, v7}, Ljava/lang/String;->getBytes(Ljava/lang/String;)[B

    move-result-object v7

    invoke-direct {v3, v7}, Ljava/io/ByteArrayInputStream;-><init>([B)V
    :try_end_1f
    .catch Ljava/io/UnsupportedEncodingException; {:try_start_e .. :try_end_1f} :catch_2a

    .line 75
    .end local v2    # "is":Ljava/io/InputStream;
    .local v3, "is":Ljava/io/InputStream;
    invoke-direct {p0, v3, v6}, Lcom/upsight/mediation/vast/processor/VASTProcessor;->processUri(Ljava/io/InputStream;I)I

    move-result v1

    .line 77
    .local v1, "error":I
    :try_start_23
    invoke-virtual {v3}, Ljava/io/InputStream;->close()V
    :try_end_26
    .catch Ljava/io/IOException; {:try_start_23 .. :try_end_26} :catch_91

    .line 80
    :goto_26
    if-eqz v1, :cond_36

    move-object v2, v3

    .line 110
    .end local v1    # "error":I
    .end local v3    # "is":Ljava/io/InputStream;
    .restart local v2    # "is":Ljava/io/InputStream;
    :goto_29
    return v1

    .line 70
    :catch_2a
    move-exception v0

    .line 71
    .local v0, "e":Ljava/io/UnsupportedEncodingException;
    const-string v6, "VASTProcessor"

    invoke-virtual {v0}, Ljava/io/UnsupportedEncodingException;->getMessage()Ljava/lang/String;

    move-result-object v7

    invoke-static {v6, v7, v0}, Lcom/upsight/mediation/log/FuseLog;->w(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)V

    move v1, v5

    .line 72
    goto :goto_29

    .line 84
    .end local v0    # "e":Ljava/io/UnsupportedEncodingException;
    .end local v2    # "is":Ljava/io/InputStream;
    .restart local v1    # "error":I
    .restart local v3    # "is":Ljava/io/InputStream;
    :cond_36
    invoke-direct {p0}, Lcom/upsight/mediation/vast/processor/VASTProcessor;->wrapMergedVastDocWithVasts()Lorg/w3c/dom/Document;

    move-result-object v4

    .line 85
    .local v4, "mainDoc":Lorg/w3c/dom/Document;
    new-instance v7, Lcom/upsight/mediation/vast/model/VASTModel;

    invoke-direct {v7, v4}, Lcom/upsight/mediation/vast/model/VASTModel;-><init>(Lorg/w3c/dom/Document;)V

    iput-object v7, p0, Lcom/upsight/mediation/vast/processor/VASTProcessor;->vastModel:Lcom/upsight/mediation/vast/model/VASTModel;

    .line 87
    if-nez v4, :cond_46

    move-object v2, v3

    .end local v3    # "is":Ljava/io/InputStream;
    .restart local v2    # "is":Ljava/io/InputStream;
    move v1, v5

    .line 88
    goto :goto_29

    .line 92
    .end local v2    # "is":Ljava/io/InputStream;
    .restart local v3    # "is":Ljava/io/InputStream;
    :cond_46
    if-eqz p3, :cond_54

    .line 93
    iget-object v5, p0, Lcom/upsight/mediation/vast/processor/VASTProcessor;->vastModel:Lcom/upsight/mediation/vast/model/VASTModel;

    invoke-static {v5}, Lcom/upsight/mediation/vast/processor/VASTModelPostValidator;->validate(Lcom/upsight/mediation/vast/model/VASTModel;)Z

    move-result v5

    if-nez v5, :cond_54

    .line 94
    const/16 v1, 0x65

    move-object v2, v3

    .end local v3    # "is":Ljava/io/InputStream;
    .restart local v2    # "is":Ljava/io/InputStream;
    goto :goto_29

    .line 99
    .end local v2    # "is":Ljava/io/InputStream;
    .restart local v3    # "is":Ljava/io/InputStream;
    :cond_54
    iget-object v5, p0, Lcom/upsight/mediation/vast/processor/VASTProcessor;->vastModel:Lcom/upsight/mediation/vast/model/VASTModel;

    iget-object v7, p0, Lcom/upsight/mediation/vast/processor/VASTProcessor;->mediaPicker:Lcom/upsight/mediation/vast/processor/VASTMediaPicker;

    invoke-static {v5, v7}, Lcom/upsight/mediation/vast/processor/VASTModelPostValidator;->pickMediaFile(Lcom/upsight/mediation/vast/model/VASTModel;Lcom/upsight/mediation/vast/processor/VASTMediaPicker;)Z

    move-result v5

    if-nez v5, :cond_62

    .line 100
    const/16 v1, 0x193

    move-object v2, v3

    .end local v3    # "is":Ljava/io/InputStream;
    .restart local v2    # "is":Ljava/io/InputStream;
    goto :goto_29

    .line 104
    .end local v2    # "is":Ljava/io/InputStream;
    .restart local v3    # "is":Ljava/io/InputStream;
    :cond_62
    iget-object v5, p0, Lcom/upsight/mediation/vast/processor/VASTProcessor;->vastModel:Lcom/upsight/mediation/vast/model/VASTModel;

    invoke-virtual {v5}, Lcom/upsight/mediation/vast/model/VASTModel;->getPickedMediaFileDeliveryType()Ljava/lang/String;

    move-result-object v5

    const-string v7, "progressive"

    invoke-virtual {v5, v7}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

    move-result v5

    if-eqz v5, :cond_7a

    .line 105
    iget-object v5, p0, Lcom/upsight/mediation/vast/processor/VASTProcessor;->vastModel:Lcom/upsight/mediation/vast/model/VASTModel;

    iget-object v6, p0, Lcom/upsight/mediation/vast/processor/VASTProcessor;->mVastPlayer:Lcom/upsight/mediation/vast/VASTPlayer;

    invoke-virtual {v5, p1, v6, p4}, Lcom/upsight/mediation/vast/model/VASTModel;->cache(Landroid/content/Context;Lcom/upsight/mediation/vast/VASTPlayer;I)I

    move-result v1

    .end local v1    # "error":I
    move-object v2, v3

    .end local v3    # "is":Ljava/io/InputStream;
    .restart local v2    # "is":Ljava/io/InputStream;
    goto :goto_29

    .line 106
    .end local v2    # "is":Ljava/io/InputStream;
    .restart local v1    # "error":I
    .restart local v3    # "is":Ljava/io/InputStream;
    :cond_7a
    iget-object v5, p0, Lcom/upsight/mediation/vast/processor/VASTProcessor;->vastModel:Lcom/upsight/mediation/vast/model/VASTModel;

    invoke-virtual {v5}, Lcom/upsight/mediation/vast/model/VASTModel;->getPickedMediaFileDeliveryType()Ljava/lang/String;

    move-result-object v5

    const-string v7, "streaming"

    invoke-virtual {v5, v7}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

    move-result v5

    if-eqz v5, :cond_8e

    .line 107
    iget-object v5, p0, Lcom/upsight/mediation/vast/processor/VASTProcessor;->mVastPlayer:Lcom/upsight/mediation/vast/VASTPlayer;

    const/4 v7, 0x1

    invoke-virtual {v5, v7}, Lcom/upsight/mediation/vast/VASTPlayer;->setLoaded(Z)V

    :cond_8e
    move-object v2, v3

    .end local v3    # "is":Ljava/io/InputStream;
    .restart local v2    # "is":Ljava/io/InputStream;
    move v1, v6

    .line 110
    goto :goto_29

    .line 78
    .end local v2    # "is":Ljava/io/InputStream;
    .end local v4    # "mainDoc":Lorg/w3c/dom/Document;
    .restart local v3    # "is":Ljava/io/InputStream;
    :catch_91
    move-exception v7

    goto :goto_26
.end method


text:
#include "Block.h"

#include "database/BlockDatabaseHelper.h"

namespace ledger {
    namespace core {

        std::string Block::getUid() const {
            return BlockDatabaseHelper::createBlockUid(*this);
        }

        api::Block Block::toApiBlock() const {
            return api::Block(hash, getUid(), time, currencyName, static_cast<int64_t>(height));
        }
    } // namespace core
} // namespace ledger


text:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/wrapper"
    android:layout_width="match_parent"
    android:paddingTop="3dp"
    android:paddingBottom="3dp"
    android:layout_height="wrap_content"
    android:padding="4dp">

    <ImageView
        android:id="@+id/icon"
        android:layout_width="25dp"
        android:layout_height="25dp"
        android:layout_alignParentRight="true"
        android:layout_alignParentEnd="true"
        android:layout_centerVertical="true"
        android:layout_marginLeft="20dp"
        android:layout_marginStart="20dp"
        android:layout_marginRight="10dp"
        android:layout_marginEnd="10dp"
        android:layout_marginTop="5dp"
        android:layout_marginBottom="5dp"
        android:tint="@color/colorPrimary"
        app:srcCompat="@drawable/ic_create_survey"
        tools:ignore="ContentDescription" />

    <TextView
        android:id="@+id/textViewStufe"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerVertical="true"
        android:layout_toLeftOf="@id/icon"
        android:layout_toStartOf="@id/icon"
        android:gravity="center"
        android:textColor="@color/colorPrimary"
        android:textSize="18sp"
        android:textStyle="normal|bold" />

    <TextView
        android:id="@+id/title"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_centerVertical="true"
        android:layout_toLeftOf="@id/textViewStufe"
        android:layout_toStartOf="@id/textViewStufe"
        android:paddingLeft="25dp"
        android:paddingRight="25dp"
        android:textColor="@color/colorText"
        android:textSize="18sp"
        android:textStyle="normal|bold" />

</RelativeLayout>


text:
var opts = {
    type       : 'lalr',
    moduleName : 'RamdaScriptParser',
    moduleType : 'commonjs',
}

var fs        = require('fs')
var jison     = require('jison')
var lexerBnf  = fs.readFileSync(__dirname + '/../src/bnf.l', 'utf8')
var parserBnf = fs.readFileSync(__dirname + '/../src/bnf.y', 'utf8')
var parser    = jison.Generator(lexerBnf + parserBnf, opts)

// write to file
fs.writeFileSync(__dirname + '/../src/parser.js', parser.generate(), 'utf8')