Skip to content

Instantly share code, notes, and snippets.

@brianleroux
Created October 9, 2010 20:25
Show Gist options
  • Save brianleroux/618572 to your computer and use it in GitHub Desktop.
Save brianleroux/618572 to your computer and use it in GitHub Desktop.
[javac] /Users/brianleroux/Repo/droidscript/src/comikit/droidscript/DroidScriptActivity.java:535: cannot find symbol
[javac] symbol : constructor Require(org.mozilla.javascript.Context,org.mozilla.javascript.Scriptable,comikit.droidscript.DroidScriptAssetProvider,<nulltype>,<nulltype>,boolean)
[javac] location: class org.mozilla.javascript.commonjs.module.Require
[javac] Require require = new Require(context, scope, provider, null, null, true);
[javac] ^
[javac] 1 error
[javac] 2 warnings
package comikit.droidscript;
import java.io.IOException;
import java.io.Serializable;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import org.mozilla.javascript.commonjs.module.provider.*;
import org.mozilla.javascript.ScriptRuntime;
import org.mozilla.javascript.Scriptable;
import org.mozilla.javascript.ScriptableObject;
import android.app.Activity;
public class DroidScriptAssetProvider implements ModuleSourceProvider, Serializable
{
private Activity activity;
DroidScriptAssetProvider(Activity a) {
activity = a;
}
public ModuleSource getModuleSource(String moduleId, Scriptable paths, Object validator) throws IOException
{
// activity.getAssets()
InputStream stream = DroidScriptIO.create().openAssetFileInputStream(activity, moduleId);
BufferedReader reader = new BufferedReader(new InputStreamReader(stream));
return new ModuleSource(reader, null, moduleId, null);
}
}
public Interpreter setActivity(Activity activity)
{
DroidScriptAssetProvider provider = new DroidScriptAssetProvider(activity);
Require require = new Require(context, scope, provider, null, null, true);
// Set the global JavaScript variable Activity.
ScriptableObject.putProperty(scope, "Activity", Context.javaToJS(activity, scope));
return this;
}
@brianleroux
Copy link
Author

I think the problem could be due to Interpretor being a nested class but not sure. I tend to block out Java semantics.

@hns
Copy link

hns commented Oct 9, 2010

Took me some time to figure this out: you have to implement ModuleScriptProvider there, not ModuleSourceProvider. Funny thing is I knew this would happen back when Attila implemented it. I think we should revise this API, thanks for the reminder.

@brianleroux
Copy link
Author

Thanks for pointing that out dude, works perfectly now =)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment