Half-assed JRuby boilerplate.
Blowing my brains out over getting this fat pig to do what I want but we're getting there.
This commit is contained in:
		
							parent
							
								
									2b3a6be24d
								
							
						
					
					
						commit
						c30d3a7627
					
				
							
								
								
									
										16
									
								
								MANIFEST
								
								
								
								
							
							
						
						
									
										16
									
								
								MANIFEST
								
								
								
								
							|  | @ -5,14 +5,14 @@ README.md | ||||||
| doc/DCO.md | doc/DCO.md | ||||||
| doc/changelog.md | doc/changelog.md | ||||||
| doc/css/common.css | doc/css/common.css | ||||||
| ext/liboga/extconf.rb | ext/c/liboga/extconf.rb | ||||||
| ext/liboga/lexer.c | ext/c/liboga/lexer.c | ||||||
| ext/liboga/lexer.h | ext/c/liboga/lexer.h | ||||||
| ext/liboga/lexer.rl | ext/c/liboga/lexer.rl | ||||||
| ext/liboga/liboga.c | ext/c/liboga/liboga.c | ||||||
| ext/liboga/liboga.h | ext/c/liboga/liboga.h | ||||||
| ext/liboga/xml.c | ext/c/liboga/xml.c | ||||||
| ext/liboga/xml.h | ext/c/liboga/xml.h | ||||||
| lib/oga.rb | lib/oga.rb | ||||||
| lib/oga/html/parser.rb | lib/oga/html/parser.rb | ||||||
| lib/oga/version.rb | lib/oga/version.rb | ||||||
|  |  | ||||||
							
								
								
									
										15
									
								
								Rakefile
								
								
								
								
							
							
						
						
									
										15
									
								
								Rakefile
								
								
								
								
							|  | @ -1,11 +1,20 @@ | ||||||
| require 'bundler/gem_tasks' | require 'bundler/gem_tasks' | ||||||
| require 'digest/sha2' | require 'digest/sha2' | ||||||
| require 'rake/clean' | require 'rake/clean' | ||||||
| require 'rake/extensiontask' |  | ||||||
| require 'cliver' | require 'cliver' | ||||||
| 
 | 
 | ||||||
| GEMSPEC = Gem::Specification.load('oga.gemspec') | GEMSPEC = Gem::Specification.load('oga.gemspec') | ||||||
| 
 | 
 | ||||||
|  | if RUBY_PLATFORM == 'java' | ||||||
|  |   require 'rake/javaextensiontask' | ||||||
|  | 
 | ||||||
|  |   Rake::JavaExtensionTask.new('liboga', GEMSPEC) | ||||||
|  | else | ||||||
|  |   require 'rake/extensiontask' | ||||||
|  | 
 | ||||||
|  |   Rake::ExtensionTask.new('liboga', GEMSPEC) | ||||||
|  | end | ||||||
|  | 
 | ||||||
| PARSER_OUTPUT = 'lib/oga/xml/parser.rb' | PARSER_OUTPUT = 'lib/oga/xml/parser.rb' | ||||||
| 
 | 
 | ||||||
| CLEAN.include( | CLEAN.include( | ||||||
|  | @ -16,7 +25,7 @@ CLEAN.include( | ||||||
|   'profile/samples/**/*.txt', |   'profile/samples/**/*.txt', | ||||||
|   'lib/liboga.*', |   'lib/liboga.*', | ||||||
|   'tmp', |   'tmp', | ||||||
|   'ext/liboga/lexer.c' |   'ext/c/liboga/lexer.c' | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| FILE_LIST = FileList.new( | FILE_LIST = FileList.new( | ||||||
|  | @ -31,8 +40,6 @@ FILE_LIST = FileList.new( | ||||||
|   'ext/**/*.*' |   'ext/**/*.*' | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| Rake::ExtensionTask.new('liboga', GEMSPEC) |  | ||||||
| 
 |  | ||||||
| Dir['./task/*.rake'].each do |task| | Dir['./task/*.rake'].each do |task| | ||||||
|   import(task) |   import(task) | ||||||
| end | end | ||||||
|  |  | ||||||
|  | @ -0,0 +1,30 @@ | ||||||
|  | package org.liboga; | ||||||
|  | 
 | ||||||
|  | import java.io.IOException; | ||||||
|  | 
 | ||||||
|  | import org.jruby.Ruby; | ||||||
|  | import org.jruby.RubyModule; | ||||||
|  | import org.jruby.RubyClass; | ||||||
|  | import org.jruby.runtime.load.BasicLibraryService; | ||||||
|  | import org.jruby.runtime.load.Library; | ||||||
|  | 
 | ||||||
|  | public class LibogaService implements BasicLibraryService | ||||||
|  | { | ||||||
|  |     public boolean basicLoad(final Ruby runtime) throws IOException | ||||||
|  |     { | ||||||
|  |         // <jruby> Calling getModule on an instance of RubyModule? Nah fuck | ||||||
|  |         // that, that would be too easy. | ||||||
|  |         RubyModule xml = (RubyModule) runtime.getModule("Oga") | ||||||
|  |             .getConstant("XML"); | ||||||
|  | 
 | ||||||
|  |         RubyClass lexer = xml.defineClassUnder( | ||||||
|  |             "Lexer", | ||||||
|  |             runtime.getObject(), | ||||||
|  |             runtime.getObject().getAllocator() | ||||||
|  |         ); | ||||||
|  | 
 | ||||||
|  |         lexer.defineAnnotatedMethods(org.liboga.xml.Lexer.class); | ||||||
|  | 
 | ||||||
|  |         return true; | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | @ -0,0 +1,27 @@ | ||||||
|  | package org.liboga.xml; | ||||||
|  | 
 | ||||||
|  | import java.io.IOException; | ||||||
|  | 
 | ||||||
|  | import org.jruby.Ruby; | ||||||
|  | import org.jruby.RubyModule; | ||||||
|  | import org.jruby.RubyClass; | ||||||
|  | import org.jruby.RubyObject; | ||||||
|  | import org.jruby.anno.JRubyClass; | ||||||
|  | import org.jruby.anno.JRubyMethod; | ||||||
|  | import org.jruby.runtime.ThreadContext; | ||||||
|  | import org.jruby.runtime.builtin.IRubyObject; | ||||||
|  | 
 | ||||||
|  | @JRubyClass(name="Oga::XML::Lexer", parent="Object") | ||||||
|  | public class Lexer extends RubyObject | ||||||
|  | { | ||||||
|  |     public Lexer(Ruby runtime, RubyClass klass) | ||||||
|  |     { | ||||||
|  |         super(runtime, klass); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     @JRubyMethod | ||||||
|  |     public IRubyObject advance_native(ThreadContext context) | ||||||
|  |     { | ||||||
|  |         return context.getRuntime().getNil(); | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | @ -12,7 +12,13 @@ Gem::Specification.new do |s| | ||||||
| 
 | 
 | ||||||
|   s.files = File.read(File.expand_path('../MANIFEST', __FILE__)).split("\n") |   s.files = File.read(File.expand_path('../MANIFEST', __FILE__)).split("\n") | ||||||
| 
 | 
 | ||||||
|   s.extensions = ['ext/liboga/extconf.rb'] |   if RUBY_PLATFORM == 'java' | ||||||
|  |     s.files << 'lib/liboga.jar' | ||||||
|  | 
 | ||||||
|  |     s.platform = 'java' | ||||||
|  |   else | ||||||
|  |     s.extensions = ['ext/c/liboga/extconf.rb'] | ||||||
|  |   end | ||||||
| 
 | 
 | ||||||
|   s.has_rdoc              = 'yard' |   s.has_rdoc              = 'yard' | ||||||
|   s.required_ruby_version = '>= 1.9.3' |   s.required_ruby_version = '>= 1.9.3' | ||||||
|  |  | ||||||
|  | @ -25,4 +25,4 @@ rule '.c' => '.rl' do |task| | ||||||
| end | end | ||||||
| 
 | 
 | ||||||
| desc 'Generates the lexers' | desc 'Generates the lexers' | ||||||
| task :lexer => ['ext/liboga/lexer.c'] | task :lexer => ['ext/c/liboga/lexer.c'] | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue