Created
June 25, 2018 08:16
-
-
Save rockjail/293c8b6a62954786914405d23174920d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import lx | |
import lxu.meta | |
class StringLength(lxu.meta.ChannelModifier): | |
def init_chan(self, desc): | |
desc.add ("input", lx.symbol.sTYPE_STRING) | |
desc.chmod_value (lx.symbol.fCHMOD_INPUT) | |
desc.add ("length", lx.symbol.sTYPE_INTEGER) | |
desc.chmod_value (lx.symbol.fCHMOD_OUTPUT) | |
def eval(self, chans): | |
string = chans.input.GetString() | |
if isinstance(string, str): | |
chans.length.SetInt(len(string)) | |
else: | |
chans.length.SetInt(0) | |
chmod_meta = lxu.meta.Meta_ChannelModifier("cmStringLength", StringLength) | |
lxu.meta.MetaRoot(chmod_meta) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment