Skip to content

Commit

Permalink
Adding LuwrainObjBase
Browse files Browse the repository at this point in the history
  • Loading branch information
marigostra committed Mar 3, 2024
1 parent b4bad09 commit 67d91d3
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/main/java/org/luwrain/script/core/LuwrainObj.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,28 +31,29 @@
import static org.luwrain.script.ScriptUtils.*;
import static org.luwrain.core.NullCheck.*;

public final class LuwrainObj
public final class LuwrainObj extends LuwrainObjBase
{
@HostAccess.Export public final LogObj log;
@HostAccess.Export public final ConstObj constants = new ConstObj();
@HostAccess.Export public final PopupsObj popups;

final Luwrain luwrain;
final Object syncObj;
final Module module;
// final Module module;
final Map<String, List<Value> > hooks = new HashMap<>();
final List<ExtensionObject> extObjs = new ArrayList<>();
final I18nObj i18nObj;
final List<Command> commands = new ArrayList<>();

LuwrainObj(Luwrain luwrain, Object syncObj, Module module)
{
super(module);
notNull(luwrain, "luwrain");
notNull(syncObj, "syncObj");
notNull(module, "module");
this.luwrain = luwrain;
this.syncObj = syncObj;
this.module = module;
// this.module = module;
this.log = new LogObj(luwrain);
this.i18nObj = new I18nObj(luwrain);
this.popups = new PopupsObj(luwrain);
Expand Down Expand Up @@ -435,9 +436,7 @@ private Object createWizardAreaImpl(Value[] args)
(onInput != null && !onInput.isNull())?onInput:null);
}

/*
@HostAccess.Export public final ProxyExecutable fetchUrl = AsyncFunction.create(null, syncObj, (args, res)->{
@HostAccess.Export public final ProxyExecutable fetchUrl = AsyncFunction.create(module.context, module.syncObj, (args, res)->{
if (!notNullAndLen(args, 1))
throw new IllegalArgumentException("Luwrain.fetchUrl takes exactly one argument");
if (!args[0].isString())
Expand All @@ -452,15 +451,14 @@ private Object createWizardAreaImpl(Value[] args)
b.append(line).append(System.lineSeparator());
line = r.readLine();
}
return new String(b);
return;//new String(b);
}
}
catch(Throwable e)
{
throw new ScriptException(e);
}
});
*/

@HostAccess.Export public final ProxyExecutable speak = this::speakImpl;
private Object speakImpl(Value[] values)
Expand Down
29 changes: 29 additions & 0 deletions src/main/java/org/luwrain/script/core/LuwrainObjBase.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
Copyright 2012-2024 Michael Pozhidaev <[email protected]>
This file is part of LUWRAIN.
LUWRAIN is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 3 of the License, or (at your option) any later version.
LUWRAIN is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
*/

package org.luwrain.script.core;

import static org.luwrain.core.NullCheck.*;

public class LuwrainObjBase
{
protected final Module module;
LuwrainObjBase(Module module)
{
notNull(module, "module");
this.module = module;
}
}

0 comments on commit 67d91d3

Please sign in to comment.